]> git.r.bdr.sh - rbdr/captura/blame - Captura/Domain/CaptureSessionConfiguration.swift
Format the code
[rbdr/captura] / Captura / Domain / CaptureSessionConfiguration.swift
CommitLineData
ba17de89
RBR
1import Foundation
2
3struct CaptureSessionConfiguration {
4 let frameRate: Int
5 let outputFormats: OutputFormatSetting
6 let backendFormat: OutputFormatSetting
7 let backend: URL?
8 let shouldKeepLocalFiles: Bool
8e932130
RBR
9 let x: Int?
10 let y: Int?
11 let width: Int?
12 let height: Int?
13 let preventMove: Bool
14 let preventResize: Bool
15 let autoStart: Bool
16 let maxLength: Int
505c1e62 17
ba17de89
RBR
18 init(
19 frameRate: Int? = nil,
20 outputFormats: OutputFormatSetting? = nil,
21 backendFormat: OutputFormatSetting? = nil,
22 backend: URL? = nil,
23 shouldKeepLocalFiles: Bool? = nil
24 ) {
25 self.frameRate = frameRate ?? CapturaSettings.frameRate
26 self.outputFormats = outputFormats ?? CapturaSettings.outputFormats
27 self.backendFormat = backendFormat ?? CapturaSettings.backendFormat
28 self.backend = backend ?? CapturaSettings.backend
29 self.shouldKeepLocalFiles = shouldKeepLocalFiles ?? CapturaSettings.shouldKeepLocalFiles
8e932130
RBR
30 x = nil
31 y = nil
32 width = nil
33 height = nil
34 preventMove = false
35 preventResize = false
36 autoStart = false
37 maxLength = 300
38 }
505c1e62 39
8e932130
RBR
40 init(from action: RecordAction) {
41 self.frameRate = action.fps ?? CapturaSettings.frameRate
42 self.outputFormats = action.outputs ?? CapturaSettings.outputFormats
43 self.backendFormat = action.backendOutput ?? CapturaSettings.backendFormat
44 if action.skipBackend {
45 self.backend = nil
46 } else {
47 self.backend = action.backend ?? CapturaSettings.backend
48 }
49 self.shouldKeepLocalFiles = action.keepLocalFiles ?? CapturaSettings.shouldKeepLocalFiles
50 self.x = action.x
51 self.y = action.y
52 self.width = action.width
53 self.height = action.height
54 preventMove = action.preventMove ?? false
55 preventResize = action.preventResize ?? false
56 autoStart = action.autoStart ?? false
57 maxLength = action.maxLength ?? 300
ba17de89 58 }
505c1e62 59
ba17de89
RBR
60 var shouldSaveMp4: Bool {
61 outputFormats.shouldSaveMp4() || (shouldUseBackend && shouldUploadMp4)
62 }
505c1e62 63
ba17de89
RBR
64 var shouldSaveGif: Bool {
65 outputFormats.shouldSaveGif() || (shouldUseBackend && shouldUploadGif)
66 }
505c1e62 67
ba17de89
RBR
68 var shouldUploadGif: Bool {
69 backendFormat.shouldSaveGif()
70 }
505c1e62 71
ba17de89
RBR
72 var shouldUploadMp4: Bool {
73 backendFormat.shouldSaveMp4()
74 }
505c1e62 75
ba17de89
RBR
76 var shouldUseBackend: Bool {
77 backend != nil
78 }
79}