3 struct CapturaSettings {
4 static var frameRate: Int {
6 if UserDefaults.standard.object(forKey: "frameRate") == nil {
9 return min(10, max(4, UserDefaults.standard.integer(forKey: "frameRate")))
13 UserDefaults.standard.setValue(newValue, forKey: "frameRate")
17 static var outputFormats: OutputFormatSetting {
19 OutputFormatSetting(rawValue: UserDefaults.standard.integer(forKey: "outputFormats")) ?? .all
22 UserDefaults.standard.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 = UserDefaults.standard.string(forKey: "backendUrl") {
49 return URL(string: url)
54 UserDefaults.standard.setValue(newValue?.absoluteString, forKey: "backendUrl")
58 static var backendFormat: OutputFormatSetting {
60 OutputFormatSetting(rawValue: UserDefaults.standard.integer(forKey: "backendFormat")) ?? .gifOnly
63 UserDefaults.standard.setValue(newValue.rawValue, forKey: "backendFormat")
67 static var shouldKeepLocalFiles: Bool {
69 if UserDefaults.standard.object(forKey: "keepFiles") == nil {
72 return UserDefaults.standard.bool(forKey: "keepFiles")
76 UserDefaults.standard.set(newValue, forKey: "keepFiles")
80 static var shouldAllowURLAutomation: Bool {
82 UserDefaults.standard.bool(forKey: "allowURLAutomation")
85 UserDefaults.standard.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