3 struct CapturaSettings {
4 static var frameRate: Int {
6 UserDefaults.standard.integer(forKey: "frameRate")
9 UserDefaults.standard.setValue(newValue, forKey: "frameRate")
13 static var outputFormats: OutputFormatSetting {
15 OutputFormatSetting(rawValue: UserDefaults.standard.integer(forKey: "outputFormats")) ?? .all
18 UserDefaults.standard.setValue(newValue.rawValue, forKey: "outputFormats")
22 static var shouldSaveMp4: Bool {
23 outputFormats.shouldSaveMp4() || (shouldUseBackend && shouldUploadMp4)
26 static var shouldSaveGif: Bool {
27 outputFormats.shouldSaveGif() || (shouldUseBackend && shouldUploadGif)
30 static var shouldUploadGif: Bool {
31 backendFormat.shouldSaveGif()
34 static var shouldUploadMp4: Bool {
35 backendFormat.shouldSaveMp4()
38 static var shouldUseBackend: Bool {
42 static var backend: URL? {
44 if let url = UserDefaults.standard.string(forKey: "backendUrl") {
45 return URL(string: url)
50 UserDefaults.standard.setValue(newValue?.absoluteString, forKey: "backendUrl")
54 static var backendFormat: OutputFormatSetting {
56 OutputFormatSetting(rawValue: UserDefaults.standard.integer(forKey: "backendFormat")) ?? .gifOnly
59 UserDefaults.standard.setValue(newValue.rawValue, forKey: "backendFormat")
63 static var shouldKeepLocalFiles: Bool {
65 UserDefaults.standard.bool(forKey: "keepFiles")
68 UserDefaults.standard.set(newValue, forKey: "keepFiles")
72 static var shouldAllowURLAutomation: Bool {
73 UserDefaults.standard.bool(forKey: "allowURLAutomation")
76 static func apply(_ config: ConfigureAction) {
77 if let fps = config.fps {
80 if let outputs = config.outputs {
81 outputFormats = outputs
83 if let newBackend = config.backend {
86 if let backendOutput = config.backendOutput {
87 backendFormat = backendOutput
89 if let keepLocalFiles = config.keepLocalFiles {
90 shouldKeepLocalFiles = keepLocalFiles