Skip to content

Commit

Permalink
Merge pull request #807 from glouel/master
Browse files Browse the repository at this point in the history
1.5.1beta3 with HDR support (Catalina Only)
  • Loading branch information
glouel authored Jun 9, 2019
2 parents 76d6efe + b7ea4ec commit 03c8f23
Show file tree
Hide file tree
Showing 10 changed files with 190 additions and 103 deletions.
8 changes: 4 additions & 4 deletions Aerial.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1169,15 +1169,15 @@
CODE_SIGN_IDENTITY = "Developer ID Application: Guillaume Louel (3L54M5L5KK)";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1.5.1beta2;
CURRENT_PROJECT_VERSION = 1.5.1beta3;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 3L54M5L5KK;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = "$(SRCROOT)/Resources/Info.plist";
INSTALL_PATH = "$(HOME)/Library/Screen Savers";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.9;
MARKETING_VERSION = 1.5.1beta2;
MARKETING_VERSION = 1.5.1beta3;
PRODUCT_BUNDLE_IDENTIFIER = com.johncoates.Aerial;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -1198,15 +1198,15 @@
CODE_SIGN_IDENTITY = "Developer ID Application: Guillaume Louel (3L54M5L5KK)";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1.5.1beta2;
CURRENT_PROJECT_VERSION = 1.5.1beta3;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 3L54M5L5KK;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = "$(SRCROOT)/Resources/Info.plist";
INSTALL_PATH = "$(HOME)/Library/Screen Savers";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.9;
MARKETING_VERSION = 1.5.1beta2;
MARKETING_VERSION = 1.5.1beta3;
OTHER_CODE_SIGN_FLAGS = "--timestamp";
PRODUCT_BUNDLE_IDENTIFIER = com.johncoates.Aerial;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
9 changes: 9 additions & 0 deletions Aerial/Source/Controllers/PWC Tabs/PWC+Advanced.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ extension PreferencesWindowController {
if preferences.logMilliseconds {
logMillisecondsButton.state = .on
}
if preferences.synchronizedMode {
synchronizedModeCheckbox.state = .on
}
}
// MARK: - Advanced panel

Expand Down Expand Up @@ -103,6 +106,12 @@ extension PreferencesWindowController {
showLogBottomClick.isHidden = false
}

@IBAction func synchronizedModeClick(_ sender: NSButton) {
let onState = sender.state == .on
preferences.synchronizedMode = onState
debugLog("UI synchronizedMode \(onState)")
}

@IBAction func moveOldVideosClick(_ sender: Any) {
ManifestLoader.instance.moveOldVideos()

Expand Down
3 changes: 0 additions & 3 deletions Aerial/Source/Controllers/PWC Tabs/PWC+Brightness.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ extension PreferencesWindowController {
if preferences.dimOnlyAtNight {
dimOnlyAtNight.state = .on
}
if preferences.synchronizedMode {
synchronizedModeCheckbox.state = .on
}
dimStartFrom.doubleValue = preferences.startDim ?? 0.5
dimFadeTo.doubleValue = preferences.endDim ?? 0.1
dimFadeInMinutes.stringValue = String(preferences.dimInMinutes!)
Expand Down
21 changes: 15 additions & 6 deletions Aerial/Source/Controllers/PWC Tabs/PWC+Videos.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,15 @@ extension PreferencesWindowController {

fadeInOutModePopup.selectItem(at: preferences.fadeMode!)

// We need catalina for HDR !
if #available(OSX 10.15, *) {
if preferences.useHDR {
useHDRCheckbox.state = .off
}
} else {
useHDRCheckbox.state = .off
useHDRCheckbox.isEnabled = false
}
}

@IBAction func rightArrowKeyPlaysNextClick(_ sender: NSButton) {
Expand All @@ -123,12 +132,6 @@ extension PreferencesWindowController {
debugLog("UI allowSkips \(onState)")
}

@IBAction func synchronizedModeClick(_ sender: NSButton) {
let onState = sender.state == .on
preferences.synchronizedMode = onState
debugLog("UI synchronizedMode \(onState)")
}

@IBAction func overrideOnBatteryClick(_ sender: NSButton) {
let onState = sender.state == .on
preferences.overrideOnBattery = onState
Expand Down Expand Up @@ -164,6 +167,12 @@ extension PreferencesWindowController {
outlineView.reloadData()
}

@IBAction func useHDRChange(_ sender: NSButton) {
let onState = sender.state == .on
preferences.useHDR = onState
debugLog("UI useHDR \(onState)")
}

@IBAction func helpButtonClick(_ button: NSButton!) {
popover.show(relativeTo: button.preparedContentRect, of: button, preferredEdge: .maxY)
}
Expand Down
11 changes: 11 additions & 0 deletions Aerial/Source/Controllers/Preferences.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ final class Preferences {

case synchronizedMode = "synchronizedMode"
case aspectMode = "aspectMode"
case useHDR = "useHDR"
}

enum AspectMode: Int {
Expand Down Expand Up @@ -228,6 +229,7 @@ final class Preferences {
defaultValues[.verticalMargin] = 0
defaultValues[.synchronizedMode] = false
defaultValues[.aspectMode] = AspectMode.fill
defaultValues[.useHDR] = true

// Set today's date as default
let dateFormatter = DateFormatter()
Expand Down Expand Up @@ -345,6 +347,15 @@ final class Preferences {
}
}

var useHDR: Bool {
get {
return value(forIdentifier: .useHDR)
}
set {
setValue(forIdentifier: .useHDR, value: newValue)
}
}

var synchronizedMode: Bool {
get {
return value(forIdentifier: .synchronizedMode)
Expand Down
2 changes: 2 additions & 0 deletions Aerial/Source/Controllers/PreferencesWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ final class PreferencesWindowController: NSWindowController, NSOutlineViewDataSo

@IBOutlet var fadeInOutModePopup: NSPopUpButton!
@IBOutlet var popupVideoFormat: NSPopUpButton!
@IBOutlet var useHDRCheckbox: NSButton!

@IBOutlet var overrideOnBatteryCheckbox: NSButton!
@IBOutlet var alternatePopupVideoFormat: NSPopUpButton!
@IBOutlet var powerSavingOnLowBatteryCheckbox: NSButton!
Expand Down
78 changes: 55 additions & 23 deletions Aerial/Source/Models/AerialVideo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,13 @@ final class AerialVideo: CustomStringConvertible, Equatable {
let secondaryName: String
let type: String
let timeOfDay: String

var url1080pH264: String
let url1080pHEVC: String
let url1080pHDR: String
let url4KHEVC: String
let url4KHDR: String

var sources: [Manifests]
let poi: [String: String]
let communityPoi: [String: String]
Expand All @@ -106,6 +110,7 @@ final class AerialVideo: CustomStringConvertible, Equatable {
return VideoCache.isAvailableOffline(video: self)
}

// MARK: - Public getter
var url: URL {
let preferences = Preferences.sharedInstance
let timeManagement = TimeManagement.sharedInstance
Expand All @@ -117,43 +122,66 @@ final class AerialVideo: CustomStringConvertible, Equatable {
return getClosestAvailable(wanted: preferences.videoFormat!)
}

// Returns the closest video we have in the manifests
func getClosestAvailable(wanted: Int) -> URL {
if wanted == Preferences.VideoFormat.v4KHEVC.rawValue {
if url4KHEVC != "" {
return URL(string: self.url4KHEVC)!
} else if url1080pHEVC != "" {
return URL(string: self.url1080pHEVC)!
} else {
return URL(string: self.url1080pH264)!
}
return getVideoFormatFrom(best: .v4KHEVC, option2: .v1080pHEVC, option3: .v1080pH264)
} else if wanted == Preferences.VideoFormat.v1080pHEVC.rawValue {
if url1080pHEVC != "" {
return URL(string: self.url1080pHEVC)!
} else if url1080pH264 != "" {
return URL(string: self.url1080pH264)!
} else {
return URL(string: self.url4KHEVC)!
}
return getVideoFormatFrom(best: .v1080pHEVC, option2: .v1080pH264, option3: .v4KHEVC)
} else {
if url1080pH264 != "" {
return URL(string: self.url1080pH264)!
} else if url1080pHEVC != "" {
// With the latest versions, we should always have a H.264 fallback so this is just for future proofing
return URL(string: self.url1080pHEVC)!
} else {
return URL(string: self.url4KHEVC)!
}
return getVideoFormatFrom(best: .v1080pH264, option2: .v1080pHEVC, option3: .v4KHEVC)
}
}

// Helper to find the best available format from the 3 options given, in that order
func getVideoFormatFrom(best: Preferences.VideoFormat, option2: Preferences.VideoFormat, option3: Preferences.VideoFormat) -> URL {
if urlFor(videoFormat: best) != "" {
return getDynamicRange(wanted: best)
} else if urlFor(videoFormat: option2) != "" {
return getDynamicRange(wanted: option2)
} else {
return getDynamicRange(wanted: option3)
}
}

// Helper to get the url for a given format
private func urlFor(videoFormat: Preferences.VideoFormat) -> String {
if videoFormat == .v4KHEVC {
return url4KHEVC
} else if videoFormat == .v1080pHEVC {
return url1080pHEVC
} else {
return url1080pH264
}
}

// Helper to get the correct Dynamic Range version based on Format, preferences, and OS availability
func getDynamicRange(wanted: Preferences.VideoFormat) -> URL {
let preferences = Preferences.sharedInstance
if #available(OSX 10.15, *), preferences.useHDR && wanted == .v4KHEVC {
return URL(string: url4KHDR)!
} else if wanted == .v4KHEVC {
return URL(string: url4KHEVC)!
} else if #available(OSX 10.15, *), preferences.useHDR && wanted == .v1080pHEVC {
return URL(string: url1080pHDR)!
} else if wanted == .v1080pHEVC {
return URL(string: url1080pHEVC)!
} else {
return URL(string: url1080pH264)!
}
}

// MARK: - Init
init(id: String,
name: String,
secondaryName: String,
type: String,
timeOfDay: String,
url1080pH264: String,
url1080pHEVC: String,
url1080pHDR: String,
url4KHEVC: String,
url4KHDR: String,
manifest: Manifests,
poi: [String: String],
communityPoi: [String: String]
Expand Down Expand Up @@ -189,13 +217,15 @@ final class AerialVideo: CustomStringConvertible, Equatable {

self.url1080pH264 = url1080pH264
self.url1080pHEVC = url1080pHEVC
self.url1080pHDR = url1080pHDR
self.url4KHEVC = url4KHEVC
self.url4KHDR = url4KHDR
self.sources = [manifest]
self.poi = poi
self.communityPoi = communityPoi
self.duration = 0

updateDuration()
updateDuration() // We need to have the video duration
}

func updateDuration() {
Expand Down Expand Up @@ -255,7 +285,9 @@ final class AerialVideo: CustomStringConvertible, Equatable {
timeofDay=\(timeOfDay),
url1080pH264=\(url1080pH264),
url1080pHEVC=\(url1080pHEVC),
url1080pHDR=\(url1080pHDR),
url4KHEVC=\(url4KHEVC)"
url4KHDR=\(url4KHDR)"
"""
}
}
1 change: 1 addition & 0 deletions Aerial/Source/Models/DisplayDetection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ final class DisplayDetection: NSObject {
for screen in NSScreen.screens {
debugLog("pass2: dict \(screen.deviceDescription)")
debugLog(" bottomLeftFrame \(screen.frame)")

let dscreen = findScreenWith(frame: screen.frame)

if dscreen != nil {
Expand Down
Loading

0 comments on commit 03c8f23

Please sign in to comment.