munim-ffmpeg 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/LICENSE +178 -0
  2. package/NitroMunimFfmpeg.podspec +41 -0
  3. package/README.md +95 -0
  4. package/android/CMakeLists.txt +29 -0
  5. package/android/build.gradle +144 -0
  6. package/android/fix-prefab.gradle +51 -0
  7. package/android/gradle.properties +5 -0
  8. package/android/src/main/AndroidManifest.xml +2 -0
  9. package/android/src/main/cpp/cpp-adapter.cpp +9 -0
  10. package/android/src/main/java/com/margelo/nitro/munimffmpeg/HybridMunimFfmpeg.kt +141 -0
  11. package/android/src/main/java/com/margelo/nitro/munimffmpeg/NitroMunimFfmpegPackage.kt +18 -0
  12. package/app.plugin.js +5 -0
  13. package/ios/Bridge.h +8 -0
  14. package/ios/HybridMunimFfmpeg.swift +161 -0
  15. package/lib/index.d.ts +10 -0
  16. package/lib/index.js +21 -0
  17. package/lib/specs/MunimFfmpeg.nitro.d.ts +25 -0
  18. package/lib/specs/MunimFfmpeg.nitro.js +1 -0
  19. package/nitro.json +30 -0
  20. package/nitrogen/generated/.gitattributes +1 -0
  21. package/nitrogen/generated/android/NitroMunimFfmpeg+autolinking.cmake +81 -0
  22. package/nitrogen/generated/android/NitroMunimFfmpeg+autolinking.gradle +27 -0
  23. package/nitrogen/generated/android/NitroMunimFfmpegOnLoad.cpp +60 -0
  24. package/nitrogen/generated/android/NitroMunimFfmpegOnLoad.hpp +34 -0
  25. package/nitrogen/generated/android/c++/JFFmpegSessionResult.hpp +86 -0
  26. package/nitrogen/generated/android/c++/JFunc_void_double.hpp +75 -0
  27. package/nitrogen/generated/android/c++/JFunc_void_double_double_double_double_double_double_double.hpp +75 -0
  28. package/nitrogen/generated/android/c++/JFunc_void_std__string.hpp +76 -0
  29. package/nitrogen/generated/android/c++/JHybridMunimFfmpegSpec.cpp +138 -0
  30. package/nitrogen/generated/android/c++/JHybridMunimFfmpegSpec.hpp +67 -0
  31. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimffmpeg/FFmpegSessionResult.kt +86 -0
  32. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimffmpeg/Func_void_double.kt +78 -0
  33. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimffmpeg/Func_void_double_double_double_double_double_double_double.kt +78 -0
  34. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimffmpeg/Func_void_std__string.kt +78 -0
  35. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimffmpeg/HybridMunimFfmpegSpec.kt +85 -0
  36. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimffmpeg/NitroMunimFfmpegOnLoad.kt +35 -0
  37. package/nitrogen/generated/ios/NitroMunimFfmpeg+autolinking.rb +62 -0
  38. package/nitrogen/generated/ios/NitroMunimFfmpeg-Swift-Cxx-Bridge.cpp +73 -0
  39. package/nitrogen/generated/ios/NitroMunimFfmpeg-Swift-Cxx-Bridge.hpp +298 -0
  40. package/nitrogen/generated/ios/NitroMunimFfmpeg-Swift-Cxx-Umbrella.hpp +51 -0
  41. package/nitrogen/generated/ios/NitroMunimFfmpegAutolinking.mm +33 -0
  42. package/nitrogen/generated/ios/NitroMunimFfmpegAutolinking.swift +26 -0
  43. package/nitrogen/generated/ios/c++/HybridMunimFfmpegSpecSwift.cpp +11 -0
  44. package/nitrogen/generated/ios/c++/HybridMunimFfmpegSpecSwift.hpp +119 -0
  45. package/nitrogen/generated/ios/swift/FFmpegSessionResult.swift +77 -0
  46. package/nitrogen/generated/ios/swift/Func_void_FFmpegSessionResult.swift +46 -0
  47. package/nitrogen/generated/ios/swift/Func_void_double.swift +46 -0
  48. package/nitrogen/generated/ios/swift/Func_void_double_double_double_double_double_double_double.swift +46 -0
  49. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
  50. package/nitrogen/generated/ios/swift/Func_void_std__string.swift +46 -0
  51. package/nitrogen/generated/ios/swift/HybridMunimFfmpegSpec.swift +59 -0
  52. package/nitrogen/generated/ios/swift/HybridMunimFfmpegSpec_cxx.swift +277 -0
  53. package/nitrogen/generated/shared/c++/FFmpegSessionResult.hpp +112 -0
  54. package/nitrogen/generated/shared/c++/HybridMunimFfmpegSpec.cpp +26 -0
  55. package/nitrogen/generated/shared/c++/HybridMunimFfmpegSpec.hpp +72 -0
  56. package/package.json +131 -0
  57. package/react-native.config.js +16 -0
  58. package/scripts/patch-ffmpegkit-level.rb +45 -0
  59. package/src/index.ts +56 -0
  60. package/src/specs/MunimFfmpeg.nitro.ts +52 -0
@@ -0,0 +1,46 @@
1
+ ///
2
+ /// Func_void_double.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import NitroModules
9
+
10
+ /**
11
+ * Wraps a Swift `(_ sessionId: Double) -> Void` as a class.
12
+ * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
13
+ */
14
+ public final class Func_void_double {
15
+ public typealias bridge = margelo.nitro.munimffmpeg.bridge.swift
16
+
17
+ private let closure: (_ sessionId: Double) -> Void
18
+
19
+ public init(_ closure: @escaping (_ sessionId: Double) -> Void) {
20
+ self.closure = closure
21
+ }
22
+
23
+ @inline(__always)
24
+ public func call(sessionId: Double) -> Void {
25
+ self.closure(sessionId)
26
+ }
27
+
28
+ /**
29
+ * Casts this instance to a retained unsafe raw pointer.
30
+ * This acquires one additional strong reference on the object!
31
+ */
32
+ @inline(__always)
33
+ public func toUnsafe() -> UnsafeMutableRawPointer {
34
+ return Unmanaged.passRetained(self).toOpaque()
35
+ }
36
+
37
+ /**
38
+ * Casts an unsafe pointer to a `Func_void_double`.
39
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_double>`.
40
+ * This removes one strong reference from the object!
41
+ */
42
+ @inline(__always)
43
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_double {
44
+ return Unmanaged<Func_void_double>.fromOpaque(pointer).takeRetainedValue()
45
+ }
46
+ }
@@ -0,0 +1,46 @@
1
+ ///
2
+ /// Func_void_double_double_double_double_double_double_double.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import NitroModules
9
+
10
+ /**
11
+ * Wraps a Swift `(_ timeMs: Double, _ sizeBytes: Double, _ bitrateKbits: Double, _ speed: Double, _ videoFrameNumber: Double, _ fps: Double, _ quality: Double) -> Void` as a class.
12
+ * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
13
+ */
14
+ public final class Func_void_double_double_double_double_double_double_double {
15
+ public typealias bridge = margelo.nitro.munimffmpeg.bridge.swift
16
+
17
+ private let closure: (_ timeMs: Double, _ sizeBytes: Double, _ bitrateKbits: Double, _ speed: Double, _ videoFrameNumber: Double, _ fps: Double, _ quality: Double) -> Void
18
+
19
+ public init(_ closure: @escaping (_ timeMs: Double, _ sizeBytes: Double, _ bitrateKbits: Double, _ speed: Double, _ videoFrameNumber: Double, _ fps: Double, _ quality: Double) -> Void) {
20
+ self.closure = closure
21
+ }
22
+
23
+ @inline(__always)
24
+ public func call(timeMs: Double, sizeBytes: Double, bitrateKbits: Double, speed: Double, videoFrameNumber: Double, fps: Double, quality: Double) -> Void {
25
+ self.closure(timeMs, sizeBytes, bitrateKbits, speed, videoFrameNumber, fps, quality)
26
+ }
27
+
28
+ /**
29
+ * Casts this instance to a retained unsafe raw pointer.
30
+ * This acquires one additional strong reference on the object!
31
+ */
32
+ @inline(__always)
33
+ public func toUnsafe() -> UnsafeMutableRawPointer {
34
+ return Unmanaged.passRetained(self).toOpaque()
35
+ }
36
+
37
+ /**
38
+ * Casts an unsafe pointer to a `Func_void_double_double_double_double_double_double_double`.
39
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_double_double_double_double_double_double_double>`.
40
+ * This removes one strong reference from the object!
41
+ */
42
+ @inline(__always)
43
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_double_double_double_double_double_double_double {
44
+ return Unmanaged<Func_void_double_double_double_double_double_double_double>.fromOpaque(pointer).takeRetainedValue()
45
+ }
46
+ }
@@ -0,0 +1,46 @@
1
+ ///
2
+ /// Func_void_std__exception_ptr.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import NitroModules
9
+
10
+ /**
11
+ * Wraps a Swift `(_ error: Error) -> Void` as a class.
12
+ * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
13
+ */
14
+ public final class Func_void_std__exception_ptr {
15
+ public typealias bridge = margelo.nitro.munimffmpeg.bridge.swift
16
+
17
+ private let closure: (_ error: Error) -> Void
18
+
19
+ public init(_ closure: @escaping (_ error: Error) -> Void) {
20
+ self.closure = closure
21
+ }
22
+
23
+ @inline(__always)
24
+ public func call(error: std.exception_ptr) -> Void {
25
+ self.closure(RuntimeError.from(cppError: error))
26
+ }
27
+
28
+ /**
29
+ * Casts this instance to a retained unsafe raw pointer.
30
+ * This acquires one additional strong reference on the object!
31
+ */
32
+ @inline(__always)
33
+ public func toUnsafe() -> UnsafeMutableRawPointer {
34
+ return Unmanaged.passRetained(self).toOpaque()
35
+ }
36
+
37
+ /**
38
+ * Casts an unsafe pointer to a `Func_void_std__exception_ptr`.
39
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_std__exception_ptr>`.
40
+ * This removes one strong reference from the object!
41
+ */
42
+ @inline(__always)
43
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__exception_ptr {
44
+ return Unmanaged<Func_void_std__exception_ptr>.fromOpaque(pointer).takeRetainedValue()
45
+ }
46
+ }
@@ -0,0 +1,46 @@
1
+ ///
2
+ /// Func_void_std__string.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import NitroModules
9
+
10
+ /**
11
+ * Wraps a Swift `(_ message: String) -> Void` as a class.
12
+ * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
13
+ */
14
+ public final class Func_void_std__string {
15
+ public typealias bridge = margelo.nitro.munimffmpeg.bridge.swift
16
+
17
+ private let closure: (_ message: String) -> Void
18
+
19
+ public init(_ closure: @escaping (_ message: String) -> Void) {
20
+ self.closure = closure
21
+ }
22
+
23
+ @inline(__always)
24
+ public func call(message: std.string) -> Void {
25
+ self.closure(String(message))
26
+ }
27
+
28
+ /**
29
+ * Casts this instance to a retained unsafe raw pointer.
30
+ * This acquires one additional strong reference on the object!
31
+ */
32
+ @inline(__always)
33
+ public func toUnsafe() -> UnsafeMutableRawPointer {
34
+ return Unmanaged.passRetained(self).toOpaque()
35
+ }
36
+
37
+ /**
38
+ * Casts an unsafe pointer to a `Func_void_std__string`.
39
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_std__string>`.
40
+ * This removes one strong reference from the object!
41
+ */
42
+ @inline(__always)
43
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__string {
44
+ return Unmanaged<Func_void_std__string>.fromOpaque(pointer).takeRetainedValue()
45
+ }
46
+ }
@@ -0,0 +1,59 @@
1
+ ///
2
+ /// HybridMunimFfmpegSpec.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import NitroModules
9
+
10
+ /// See ``HybridMunimFfmpegSpec``
11
+ public protocol HybridMunimFfmpegSpec_protocol: HybridObject {
12
+ // Properties
13
+ var ffmpegVersion: String { get }
14
+
15
+ // Methods
16
+ func execute(arguments_: [String], onLog: ((_ message: String) -> Void)?, onStatistics: ((_ timeMs: Double, _ sizeBytes: Double, _ bitrateKbits: Double, _ speed: Double, _ videoFrameNumber: Double, _ fps: Double, _ quality: Double) -> Void)?, onSessionCreated: ((_ sessionId: Double) -> Void)?) throws -> Promise<FFmpegSessionResult>
17
+ func probe(arguments_: [String], onLog: ((_ message: String) -> Void)?, onSessionCreated: ((_ sessionId: Double) -> Void)?) throws -> Promise<FFmpegSessionResult>
18
+ func getMediaInformation(path: String) throws -> Promise<String>
19
+ func cancel(sessionId: Double?) throws -> Void
20
+ func cancelAll() throws -> Void
21
+ }
22
+
23
+ public extension HybridMunimFfmpegSpec_protocol {
24
+ /// Default implementation of ``HybridObject.toString``
25
+ func toString() -> String {
26
+ return "[HybridObject MunimFfmpeg]"
27
+ }
28
+ }
29
+
30
+ /// See ``HybridMunimFfmpegSpec``
31
+ open class HybridMunimFfmpegSpec_base {
32
+ private weak var cxxWrapper: HybridMunimFfmpegSpec_cxx? = nil
33
+ public init() { }
34
+ public func getCxxWrapper() -> HybridMunimFfmpegSpec_cxx {
35
+ #if DEBUG
36
+ guard self is any HybridMunimFfmpegSpec else {
37
+ fatalError("`self` is not a `HybridMunimFfmpegSpec`! Did you accidentally inherit from `HybridMunimFfmpegSpec_base` instead of `HybridMunimFfmpegSpec`?")
38
+ }
39
+ #endif
40
+ if let cxxWrapper = self.cxxWrapper {
41
+ return cxxWrapper
42
+ } else {
43
+ let cxxWrapper = HybridMunimFfmpegSpec_cxx(self as! any HybridMunimFfmpegSpec)
44
+ self.cxxWrapper = cxxWrapper
45
+ return cxxWrapper
46
+ }
47
+ }
48
+ }
49
+
50
+ /**
51
+ * A Swift base-protocol representing the MunimFfmpeg HybridObject.
52
+ * Implement this protocol to create Swift-based instances of MunimFfmpeg.
53
+ * ```swift
54
+ * class HybridMunimFfmpeg : HybridMunimFfmpegSpec {
55
+ * // ...
56
+ * }
57
+ * ```
58
+ */
59
+ public typealias HybridMunimFfmpegSpec = HybridMunimFfmpegSpec_protocol & HybridMunimFfmpegSpec_base
@@ -0,0 +1,277 @@
1
+ ///
2
+ /// HybridMunimFfmpegSpec_cxx.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import NitroModules
9
+
10
+ /**
11
+ * A class implementation that bridges HybridMunimFfmpegSpec over to C++.
12
+ * In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
13
+ *
14
+ * Also, some Swift types need to be bridged with special handling:
15
+ * - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330)
16
+ * - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
17
+ * - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
18
+ */
19
+ open class HybridMunimFfmpegSpec_cxx {
20
+ /**
21
+ * The Swift <> C++ bridge's namespace (`margelo::nitro::munimffmpeg::bridge::swift`)
22
+ * from `NitroMunimFfmpeg-Swift-Cxx-Bridge.hpp`.
23
+ * This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
24
+ */
25
+ public typealias bridge = margelo.nitro.munimffmpeg.bridge.swift
26
+
27
+ /**
28
+ * Holds an instance of the `HybridMunimFfmpegSpec` Swift protocol.
29
+ */
30
+ private var __implementation: any HybridMunimFfmpegSpec
31
+
32
+ /**
33
+ * Holds a weak pointer to the C++ class that wraps the Swift class.
34
+ */
35
+ private var __cxxPart: bridge.std__weak_ptr_HybridMunimFfmpegSpec_
36
+
37
+ /**
38
+ * Create a new `HybridMunimFfmpegSpec_cxx` that wraps the given `HybridMunimFfmpegSpec`.
39
+ * All properties and methods bridge to C++ types.
40
+ */
41
+ public init(_ implementation: any HybridMunimFfmpegSpec) {
42
+ self.__implementation = implementation
43
+ self.__cxxPart = .init()
44
+ /* no base class */
45
+ }
46
+
47
+ /**
48
+ * Get the actual `HybridMunimFfmpegSpec` instance this class wraps.
49
+ */
50
+ @inline(__always)
51
+ public func getHybridMunimFfmpegSpec() -> any HybridMunimFfmpegSpec {
52
+ return __implementation
53
+ }
54
+
55
+ /**
56
+ * Casts this instance to a retained unsafe raw pointer.
57
+ * This acquires one additional strong reference on the object!
58
+ */
59
+ public func toUnsafe() -> UnsafeMutableRawPointer {
60
+ return Unmanaged.passRetained(self).toOpaque()
61
+ }
62
+
63
+ /**
64
+ * Casts an unsafe pointer to a `HybridMunimFfmpegSpec_cxx`.
65
+ * The pointer has to be a retained opaque `Unmanaged<HybridMunimFfmpegSpec_cxx>`.
66
+ * This removes one strong reference from the object!
67
+ */
68
+ public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridMunimFfmpegSpec_cxx {
69
+ return Unmanaged<HybridMunimFfmpegSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
70
+ }
71
+
72
+ /**
73
+ * Gets (or creates) the C++ part of this Hybrid Object.
74
+ * The C++ part is a `std::shared_ptr<HybridMunimFfmpegSpec>`.
75
+ */
76
+ public func getCxxPart() -> bridge.std__shared_ptr_HybridMunimFfmpegSpec_ {
77
+ let cachedCxxPart = self.__cxxPart.lock()
78
+ if Bool(fromCxx: cachedCxxPart) {
79
+ return cachedCxxPart
80
+ } else {
81
+ let newCxxPart = bridge.create_std__shared_ptr_HybridMunimFfmpegSpec_(self.toUnsafe())
82
+ __cxxPart = bridge.weakify_std__shared_ptr_HybridMunimFfmpegSpec_(newCxxPart)
83
+ return newCxxPart
84
+ }
85
+ }
86
+
87
+
88
+
89
+ /**
90
+ * Get the memory size of the Swift class (plus size of any other allocations)
91
+ * so the JS VM can properly track it and garbage-collect the JS object if needed.
92
+ */
93
+ @inline(__always)
94
+ public var memorySize: Int {
95
+ return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
96
+ }
97
+
98
+ /**
99
+ * Compares this object with the given [other] object for reference equality.
100
+ */
101
+ @inline(__always)
102
+ public func equals(other: HybridMunimFfmpegSpec_cxx) -> Bool {
103
+ return self.__implementation === other.__implementation
104
+ }
105
+
106
+ /**
107
+ * Call dispose() on the Swift class.
108
+ * This _may_ be called manually from JS.
109
+ */
110
+ @inline(__always)
111
+ public func dispose() {
112
+ self.__implementation.dispose()
113
+ }
114
+
115
+ /**
116
+ * Call toString() on the Swift class.
117
+ */
118
+ @inline(__always)
119
+ public func toString() -> String {
120
+ return self.__implementation.toString()
121
+ }
122
+
123
+ // Properties
124
+ public final var ffmpegVersion: std.string {
125
+ @inline(__always)
126
+ get {
127
+ return std.string(self.__implementation.ffmpegVersion)
128
+ }
129
+ }
130
+
131
+ // Methods
132
+ @inline(__always)
133
+ public final func execute(arguments_: bridge.std__vector_std__string_, onLog: bridge.std__optional_std__function_void_const_std__string_____message______, onStatistics: bridge.std__optional_std__function_void_double____timeMs_____double____sizeBytes_____double____bitrateKbits_____double____speed_____double____videoFrameNumber_____double____fps_____double____quality______, onSessionCreated: bridge.std__optional_std__function_void_double____sessionId______) -> bridge.Result_std__shared_ptr_Promise_FFmpegSessionResult___ {
134
+ do {
135
+ let __result = try self.__implementation.execute(arguments_: arguments_.map({ __item in String(__item) }), onLog: { () -> ((_ message: String) -> Void)? in
136
+ if bridge.has_value_std__optional_std__function_void_const_std__string_____message______(onLog) {
137
+ let __unwrapped = bridge.get_std__optional_std__function_void_const_std__string_____message______(onLog)
138
+ return { () -> (String) -> Void in
139
+ let __wrappedFunction = bridge.wrap_Func_void_std__string(__unwrapped)
140
+ return { (__message: String) -> Void in
141
+ __wrappedFunction.call(std.string(__message))
142
+ }
143
+ }()
144
+ } else {
145
+ return nil
146
+ }
147
+ }(), onStatistics: { () -> ((_ timeMs: Double, _ sizeBytes: Double, _ bitrateKbits: Double, _ speed: Double, _ videoFrameNumber: Double, _ fps: Double, _ quality: Double) -> Void)? in
148
+ if bridge.has_value_std__optional_std__function_void_double____timeMs_____double____sizeBytes_____double____bitrateKbits_____double____speed_____double____videoFrameNumber_____double____fps_____double____quality______(onStatistics) {
149
+ let __unwrapped = bridge.get_std__optional_std__function_void_double____timeMs_____double____sizeBytes_____double____bitrateKbits_____double____speed_____double____videoFrameNumber_____double____fps_____double____quality______(onStatistics)
150
+ return { () -> (Double, Double, Double, Double, Double, Double, Double) -> Void in
151
+ let __wrappedFunction = bridge.wrap_Func_void_double_double_double_double_double_double_double(__unwrapped)
152
+ return { (__timeMs: Double, __sizeBytes: Double, __bitrateKbits: Double, __speed: Double, __videoFrameNumber: Double, __fps: Double, __quality: Double) -> Void in
153
+ __wrappedFunction.call(__timeMs, __sizeBytes, __bitrateKbits, __speed, __videoFrameNumber, __fps, __quality)
154
+ }
155
+ }()
156
+ } else {
157
+ return nil
158
+ }
159
+ }(), onSessionCreated: { () -> ((_ sessionId: Double) -> Void)? in
160
+ if bridge.has_value_std__optional_std__function_void_double____sessionId______(onSessionCreated) {
161
+ let __unwrapped = bridge.get_std__optional_std__function_void_double____sessionId______(onSessionCreated)
162
+ return { () -> (Double) -> Void in
163
+ let __wrappedFunction = bridge.wrap_Func_void_double(__unwrapped)
164
+ return { (__sessionId: Double) -> Void in
165
+ __wrappedFunction.call(__sessionId)
166
+ }
167
+ }()
168
+ } else {
169
+ return nil
170
+ }
171
+ }())
172
+ let __resultCpp = { () -> bridge.std__shared_ptr_Promise_FFmpegSessionResult__ in
173
+ let __promise = bridge.create_std__shared_ptr_Promise_FFmpegSessionResult__()
174
+ let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_FFmpegSessionResult__(__promise)
175
+ __result
176
+ .then({ __result in __promiseHolder.resolve(__result) })
177
+ .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
178
+ return __promise
179
+ }()
180
+ return bridge.create_Result_std__shared_ptr_Promise_FFmpegSessionResult___(__resultCpp)
181
+ } catch (let __error) {
182
+ let __exceptionPtr = __error.toCpp()
183
+ return bridge.create_Result_std__shared_ptr_Promise_FFmpegSessionResult___(__exceptionPtr)
184
+ }
185
+ }
186
+
187
+ @inline(__always)
188
+ public final func probe(arguments_: bridge.std__vector_std__string_, onLog: bridge.std__optional_std__function_void_const_std__string_____message______, onSessionCreated: bridge.std__optional_std__function_void_double____sessionId______) -> bridge.Result_std__shared_ptr_Promise_FFmpegSessionResult___ {
189
+ do {
190
+ let __result = try self.__implementation.probe(arguments_: arguments_.map({ __item in String(__item) }), onLog: { () -> ((_ message: String) -> Void)? in
191
+ if bridge.has_value_std__optional_std__function_void_const_std__string_____message______(onLog) {
192
+ let __unwrapped = bridge.get_std__optional_std__function_void_const_std__string_____message______(onLog)
193
+ return { () -> (String) -> Void in
194
+ let __wrappedFunction = bridge.wrap_Func_void_std__string(__unwrapped)
195
+ return { (__message: String) -> Void in
196
+ __wrappedFunction.call(std.string(__message))
197
+ }
198
+ }()
199
+ } else {
200
+ return nil
201
+ }
202
+ }(), onSessionCreated: { () -> ((_ sessionId: Double) -> Void)? in
203
+ if bridge.has_value_std__optional_std__function_void_double____sessionId______(onSessionCreated) {
204
+ let __unwrapped = bridge.get_std__optional_std__function_void_double____sessionId______(onSessionCreated)
205
+ return { () -> (Double) -> Void in
206
+ let __wrappedFunction = bridge.wrap_Func_void_double(__unwrapped)
207
+ return { (__sessionId: Double) -> Void in
208
+ __wrappedFunction.call(__sessionId)
209
+ }
210
+ }()
211
+ } else {
212
+ return nil
213
+ }
214
+ }())
215
+ let __resultCpp = { () -> bridge.std__shared_ptr_Promise_FFmpegSessionResult__ in
216
+ let __promise = bridge.create_std__shared_ptr_Promise_FFmpegSessionResult__()
217
+ let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_FFmpegSessionResult__(__promise)
218
+ __result
219
+ .then({ __result in __promiseHolder.resolve(__result) })
220
+ .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
221
+ return __promise
222
+ }()
223
+ return bridge.create_Result_std__shared_ptr_Promise_FFmpegSessionResult___(__resultCpp)
224
+ } catch (let __error) {
225
+ let __exceptionPtr = __error.toCpp()
226
+ return bridge.create_Result_std__shared_ptr_Promise_FFmpegSessionResult___(__exceptionPtr)
227
+ }
228
+ }
229
+
230
+ @inline(__always)
231
+ public final func getMediaInformation(path: std.string) -> bridge.Result_std__shared_ptr_Promise_std__string___ {
232
+ do {
233
+ let __result = try self.__implementation.getMediaInformation(path: String(path))
234
+ let __resultCpp = { () -> bridge.std__shared_ptr_Promise_std__string__ in
235
+ let __promise = bridge.create_std__shared_ptr_Promise_std__string__()
236
+ let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_std__string__(__promise)
237
+ __result
238
+ .then({ __result in __promiseHolder.resolve(std.string(__result)) })
239
+ .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
240
+ return __promise
241
+ }()
242
+ return bridge.create_Result_std__shared_ptr_Promise_std__string___(__resultCpp)
243
+ } catch (let __error) {
244
+ let __exceptionPtr = __error.toCpp()
245
+ return bridge.create_Result_std__shared_ptr_Promise_std__string___(__exceptionPtr)
246
+ }
247
+ }
248
+
249
+ @inline(__always)
250
+ public final func cancel(sessionId: bridge.std__optional_double_) -> bridge.Result_void_ {
251
+ do {
252
+ try self.__implementation.cancel(sessionId: { () -> Double? in
253
+ if bridge.has_value_std__optional_double_(sessionId) {
254
+ let __unwrapped = bridge.get_std__optional_double_(sessionId)
255
+ return __unwrapped
256
+ } else {
257
+ return nil
258
+ }
259
+ }())
260
+ return bridge.create_Result_void_()
261
+ } catch (let __error) {
262
+ let __exceptionPtr = __error.toCpp()
263
+ return bridge.create_Result_void_(__exceptionPtr)
264
+ }
265
+ }
266
+
267
+ @inline(__always)
268
+ public final func cancelAll() -> bridge.Result_void_ {
269
+ do {
270
+ try self.__implementation.cancelAll()
271
+ return bridge.create_Result_void_()
272
+ } catch (let __error) {
273
+ let __exceptionPtr = __error.toCpp()
274
+ return bridge.create_Result_void_(__exceptionPtr)
275
+ }
276
+ }
277
+ }
@@ -0,0 +1,112 @@
1
+ ///
2
+ /// FFmpegSessionResult.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
11
+ #include <NitroModules/JSIConverter.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
16
+ #include <NitroModules/NitroDefines.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
+ #include <NitroModules/JSIHelpers.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+ #if __has_include(<NitroModules/PropNameIDCache.hpp>)
26
+ #include <NitroModules/PropNameIDCache.hpp>
27
+ #else
28
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
29
+ #endif
30
+
31
+
32
+
33
+ #include <string>
34
+ #include <optional>
35
+
36
+ namespace margelo::nitro::munimffmpeg {
37
+
38
+ /**
39
+ * A struct which can be represented as a JavaScript object (FFmpegSessionResult).
40
+ */
41
+ struct FFmpegSessionResult final {
42
+ public:
43
+ double sessionId SWIFT_PRIVATE;
44
+ double returnCode SWIFT_PRIVATE;
45
+ bool success SWIFT_PRIVATE;
46
+ bool cancelled SWIFT_PRIVATE;
47
+ std::string state SWIFT_PRIVATE;
48
+ double durationMs SWIFT_PRIVATE;
49
+ std::string output SWIFT_PRIVATE;
50
+ std::optional<std::string> failStackTrace SWIFT_PRIVATE;
51
+
52
+ public:
53
+ FFmpegSessionResult() = default;
54
+ explicit FFmpegSessionResult(double sessionId, double returnCode, bool success, bool cancelled, std::string state, double durationMs, std::string output, std::optional<std::string> failStackTrace): sessionId(sessionId), returnCode(returnCode), success(success), cancelled(cancelled), state(state), durationMs(durationMs), output(output), failStackTrace(failStackTrace) {}
55
+
56
+ public:
57
+ friend bool operator==(const FFmpegSessionResult& lhs, const FFmpegSessionResult& rhs) = default;
58
+ };
59
+
60
+ } // namespace margelo::nitro::munimffmpeg
61
+
62
+ namespace margelo::nitro {
63
+
64
+ // C++ FFmpegSessionResult <> JS FFmpegSessionResult (object)
65
+ template <>
66
+ struct JSIConverter<margelo::nitro::munimffmpeg::FFmpegSessionResult> final {
67
+ static inline margelo::nitro::munimffmpeg::FFmpegSessionResult fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
68
+ jsi::Object obj = arg.asObject(runtime);
69
+ return margelo::nitro::munimffmpeg::FFmpegSessionResult(
70
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "sessionId"))),
71
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "returnCode"))),
72
+ JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "success"))),
73
+ JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "cancelled"))),
74
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "state"))),
75
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "durationMs"))),
76
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "output"))),
77
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "failStackTrace")))
78
+ );
79
+ }
80
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::munimffmpeg::FFmpegSessionResult& arg) {
81
+ jsi::Object obj(runtime);
82
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "sessionId"), JSIConverter<double>::toJSI(runtime, arg.sessionId));
83
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "returnCode"), JSIConverter<double>::toJSI(runtime, arg.returnCode));
84
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "success"), JSIConverter<bool>::toJSI(runtime, arg.success));
85
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "cancelled"), JSIConverter<bool>::toJSI(runtime, arg.cancelled));
86
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "state"), JSIConverter<std::string>::toJSI(runtime, arg.state));
87
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "durationMs"), JSIConverter<double>::toJSI(runtime, arg.durationMs));
88
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "output"), JSIConverter<std::string>::toJSI(runtime, arg.output));
89
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "failStackTrace"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.failStackTrace));
90
+ return obj;
91
+ }
92
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
93
+ if (!value.isObject()) {
94
+ return false;
95
+ }
96
+ jsi::Object obj = value.getObject(runtime);
97
+ if (!nitro::isPlainObject(runtime, obj)) {
98
+ return false;
99
+ }
100
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "sessionId")))) return false;
101
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "returnCode")))) return false;
102
+ if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "success")))) return false;
103
+ if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "cancelled")))) return false;
104
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "state")))) return false;
105
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "durationMs")))) return false;
106
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "output")))) return false;
107
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "failStackTrace")))) return false;
108
+ return true;
109
+ }
110
+ };
111
+
112
+ } // namespace margelo::nitro
@@ -0,0 +1,26 @@
1
+ ///
2
+ /// HybridMunimFfmpegSpec.cpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #include "HybridMunimFfmpegSpec.hpp"
9
+
10
+ namespace margelo::nitro::munimffmpeg {
11
+
12
+ void HybridMunimFfmpegSpec::loadHybridMethods() {
13
+ // load base methods/properties
14
+ HybridObject::loadHybridMethods();
15
+ // load custom methods/properties
16
+ registerHybrids(this, [](Prototype& prototype) {
17
+ prototype.registerHybridGetter("ffmpegVersion", &HybridMunimFfmpegSpec::getFfmpegVersion);
18
+ prototype.registerHybridMethod("execute", &HybridMunimFfmpegSpec::execute);
19
+ prototype.registerHybridMethod("probe", &HybridMunimFfmpegSpec::probe);
20
+ prototype.registerHybridMethod("getMediaInformation", &HybridMunimFfmpegSpec::getMediaInformation);
21
+ prototype.registerHybridMethod("cancel", &HybridMunimFfmpegSpec::cancel);
22
+ prototype.registerHybridMethod("cancelAll", &HybridMunimFfmpegSpec::cancelAll);
23
+ });
24
+ }
25
+
26
+ } // namespace margelo::nitro::munimffmpeg