3 struct CapturaSettings {
4 static var frameRate: Int {
6 if NSUbiquitousKeyValueStore.default.object(forKey: "frameRate") == nil {
9 return min(10, max(4, Int(NSUbiquitousKeyValueStore.default.longLong(forKey: "frameRate"))))
13 NSUbiquitousKeyValueStore.default.setValue(newValue, forKey: "frameRate")
17 static var outputFormats: OutputFormatSetting {
19 OutputFormatSetting(rawValue: Int(NSUbiquitousKeyValueStore.default.longLong(forKey: "outputFormats"))) ?? .all
22 NSUbiquitousKeyValueStore.default.setValue(newValue.rawValue, forKey: "outputFormats")
26 static var shouldSaveMp4: Bool {
27 outputFormats.shouldSaveMp4() || (shouldUseBackend && shouldUploadMp4)
30 static var shouldSaveGif: Bool {
31 outputFormats.shouldSaveGif() || (shouldUseBackend && shouldUploadGif)
34 static var shouldUploadGif: Bool {
35 backendFormat.shouldSaveGif()
38 static var shouldUploadMp4: Bool {
39 backendFormat.shouldSaveMp4()
42 static var shouldUseBackend: Bool {
46 static var backend: URL? {
48 if let url = NSUbiquitousKeyValueStore.default.string(forKey: "backendUrl") {
49 return URL(string: url)
54 NSUbiquitousKeyValueStore.default.setValue(newValue?.absoluteString, forKey: "backendUrl")
58 static var backendFormat: OutputFormatSetting {
60 OutputFormatSetting(rawValue: Int(NSUbiquitousKeyValueStore.default.longLong(forKey: "backendFormat"))) ?? .gifOnly
63 NSUbiquitousKeyValueStore.default.setValue(newValue.rawValue, forKey: "backendFormat")
67 static var shouldKeepLocalFiles: Bool {
69 if NSUbiquitousKeyValueStore.default.object(forKey: "keepFiles") == nil {
72 return NSUbiquitousKeyValueStore.default.bool(forKey: "keepFiles")
76 NSUbiquitousKeyValueStore.default.set(newValue, forKey: "keepFiles")
80 static var shouldAllowURLAutomation: Bool {
82 NSUbiquitousKeyValueStore.default.bool(forKey: "allowURLAutomation")
85 NSUbiquitousKeyValueStore.default.setValue(newValue, forKey: "allowURLAutomation")
89 static func apply(_ config: ConfigureAction) {
90 if let fps = config.fps {
93 if let outputs = config.outputs {
94 outputFormats = outputs
96 if let newBackend = config.backend {
99 if let backendOutput = config.backendOutput {
100 backendFormat = backendOutput
102 if let keepLocalFiles = config.keepLocalFiles {
103 shouldKeepLocalFiles = keepLocalFiles