]> git.r.bdr.sh - rbdr/captura/blame_incremental - Captura/Scripting/RecordCommand.swift
Add license and contributing
[rbdr/captura] / Captura / Scripting / RecordCommand.swift
... / ...
CommitLineData
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 */
17import Foundation
18
19@objc(RecordCommand)
20class RecordCommand: NSScriptCommand {
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
44 }
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(name: .setCaptureSessionConfiguration, object: nil, userInfo: [
66 "config": config
67 ])
68 NotificationCenter.default.post(name: .startAreaSelection, object: nil, userInfo: nil)
69
70 // Return a result if needed
71 return nil
72 }
73}