]>
Commit | Line | Data |
---|---|---|
5802c153 RBR |
1 | /* |
2 | Copyright (C) 2024 Rubén Beltrán del Río | |
3 | ||
4 | This program is free software: you can redistribute it and/or modify | |
5 | it under the terms of the GNU General Public License as published by | |
6 | the Free Software Foundation, either version 3 of the License, or | |
7 | (at your option) any later version. | |
8 | ||
9 | This program is distributed in the hope that it will be useful, | |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | GNU General Public License for more details. | |
13 | ||
14 | You should have received a copy of the GNU General Public License | |
15 | along with this program. If not, see https://captura.tranquil.systems. | |
16 | */ | |
377442f2 RBR |
17 | import Foundation |
18 | ||
19 | @objc(RecordCommand) | |
20 | class RecordCommand: NSScriptCommand { | |
505c1e62 RBR |
21 | override func performDefaultImplementation() -> Any? { |
22 | ||
23 | let args = self.directParameter as? [String: Any] ?? [:] | |
24 | ||
25 | // Here you can extract the parameters from the args dictionary and configure your settings | |
26 | let x = args["x"] as? Int | |
27 | let y = args["y"] as? Int | |
28 | let width = args["width"] as? Int | |
29 | let height = args["height"] as? Int | |
30 | let preventResize = args["prevent_resize"] as? Bool | |
31 | let preventMove = args["prevent_move"] as? Bool | |
32 | let fps = args["fps"] as? Int | |
33 | let outputs = OutputFormatSetting(args["outputs"] as? String ?? "") | |
34 | let backend = URL(string: args["backend"] as? String ?? "") | |
35 | let backendOutput = OutputFormatSetting(args["backend_output"] as? String ?? "") | |
36 | let keepLocalFiles = args["keep_local_files"] as? Bool | |
37 | let autoStart = args["auto_start"] as? Bool | |
38 | let maxLength = args["max_length"] as? Int | |
39 | ||
40 | var skipBackend = false | |
41 | if let backendString = args["backend"] as? String { | |
42 | if backendString == "" { | |
43 | skipBackend = true | |
377442f2 | 44 | } |
505c1e62 RBR |
45 | } |
46 | ||
47 | let config = RecordAction( | |
48 | action: "record", | |
49 | x: x, | |
50 | y: y, | |
51 | width: width, | |
52 | height: height, | |
53 | preventResize: preventResize, | |
54 | preventMove: preventMove, | |
55 | fps: fps, | |
56 | outputs: outputs, | |
57 | backend: backend, | |
58 | backendOutput: backendOutput, | |
59 | keepLocalFiles: keepLocalFiles, | |
60 | autoStart: autoStart, | |
61 | skipBackend: skipBackend, | |
62 | maxLength: maxLength | |
63 | ) | |
64 | ||
65 | NotificationCenter.default.post( | |
66 | name: .setCaptureSessionConfiguration, object: nil, | |
67 | userInfo: [ | |
377442f2 RBR |
68 | "config": config |
69 | ]) | |
505c1e62 | 70 | NotificationCenter.default.post(name: .startAreaSelection, object: nil, userInfo: nil) |
377442f2 | 71 | |
505c1e62 RBR |
72 | // Return a result if needed |
73 | return nil | |
74 | } | |
377442f2 | 75 | } |