@clarionhq/recorder 0.0.1 → 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.
- package/LICENSE +21 -0
- package/README.md +110 -0
- package/android/build.gradle +97 -0
- package/android/gradle.properties +4 -0
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/cpp/cpp-adapter.cpp +7 -0
- package/android/src/main/java/com/clarionhq/recorder/AudioLevelMeter.kt +38 -0
- package/android/src/main/java/com/clarionhq/recorder/ClarionRecorderPackage.kt +27 -0
- package/android/src/main/java/com/clarionhq/recorder/EncodeFile.kt +62 -0
- package/android/src/main/java/com/clarionhq/recorder/RecorderConfig.kt +33 -0
- package/android/src/main/java/com/clarionhq/recorder/RecorderConstants.kt +16 -0
- package/android/src/main/java/com/clarionhq/recorder/RecorderSession.kt +336 -0
- package/android/src/main/java/com/clarionhq/recorder/RecorderTypes.kt +29 -0
- package/android/src/main/java/com/margelo/nitro/clarion/recorder/HybridClarionRecorder.kt +174 -0
- package/clarionhq-recorder.podspec +31 -0
- package/ios/AudioLevelMeter.swift +37 -0
- package/ios/EncodeFile.swift +69 -0
- package/ios/HybridClarionRecorder.swift +186 -0
- package/ios/RecorderConstants.swift +11 -0
- package/ios/RecorderSession.swift +278 -0
- package/ios/RecorderTypes.swift +41 -0
- package/lib/RecorderEngine.d.ts +31 -0
- package/lib/RecorderEngine.d.ts.map +1 -0
- package/lib/RecorderEngine.js +245 -0
- package/lib/RecorderEngine.js.map +1 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -0
- package/lib/native.d.ts +3 -0
- package/lib/native.d.ts.map +1 -0
- package/lib/native.js +3 -0
- package/lib/native.js.map +1 -0
- package/lib/specs/ClarionRecorder.nitro.d.ts +49 -0
- package/lib/specs/ClarionRecorder.nitro.d.ts.map +1 -0
- package/lib/specs/ClarionRecorder.nitro.js +2 -0
- package/lib/specs/ClarionRecorder.nitro.js.map +1 -0
- package/nitro.json +24 -0
- package/nitrogen/generated/android/ClarionRecorder+autolinking.cmake +81 -0
- package/nitrogen/generated/android/ClarionRecorder+autolinking.gradle +27 -0
- package/nitrogen/generated/android/ClarionRecorderOnLoad.cpp +62 -0
- package/nitrogen/generated/android/ClarionRecorderOnLoad.hpp +34 -0
- package/nitrogen/generated/android/c++/JFunc_void_NativeRecorderError.hpp +78 -0
- package/nitrogen/generated/android/c++/JFunc_void_double_double.hpp +75 -0
- package/nitrogen/generated/android/c++/JFunc_void_std__string.hpp +76 -0
- package/nitrogen/generated/android/c++/JFunc_void_std__string_double_double_double.hpp +76 -0
- package/nitrogen/generated/android/c++/JHybridClarionRecorderSpec.cpp +207 -0
- package/nitrogen/generated/android/c++/JHybridClarionRecorderSpec.hpp +75 -0
- package/nitrogen/generated/android/c++/JNativeRecorderConfig.hpp +90 -0
- package/nitrogen/generated/android/c++/JNativeRecorderError.hpp +65 -0
- package/nitrogen/generated/android/c++/JNativeRecorderResult.hpp +77 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/clarion/recorder/ClarionRecorderOnLoad.kt +35 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/clarion/recorder/Func_void_NativeRecorderError.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/clarion/recorder/Func_void_double_double.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/clarion/recorder/Func_void_std__string.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/clarion/recorder/Func_void_std__string_double_double_double.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/clarion/recorder/HybridClarionRecorderSpec.kt +125 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/clarion/recorder/NativeRecorderConfig.kt +91 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/clarion/recorder/NativeRecorderError.kt +61 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/clarion/recorder/NativeRecorderResult.kt +76 -0
- package/nitrogen/generated/ios/ClarionRecorder+autolinking.rb +62 -0
- package/nitrogen/generated/ios/ClarionRecorder-Swift-Cxx-Bridge.cpp +89 -0
- package/nitrogen/generated/ios/ClarionRecorder-Swift-Cxx-Bridge.hpp +297 -0
- package/nitrogen/generated/ios/ClarionRecorder-Swift-Cxx-Umbrella.hpp +56 -0
- package/nitrogen/generated/ios/ClarionRecorderAutolinking.mm +33 -0
- package/nitrogen/generated/ios/ClarionRecorderAutolinking.swift +26 -0
- package/nitrogen/generated/ios/c++/HybridClarionRecorderSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridClarionRecorderSpecSwift.hpp +188 -0
- package/nitrogen/generated/ios/swift/Func_void.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_NativeRecorderError.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_NativeRecorderResult.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_double_double.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__string.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__string_double_double_double.swift +46 -0
- package/nitrogen/generated/ios/swift/HybridClarionRecorderSpec.swift +67 -0
- package/nitrogen/generated/ios/swift/HybridClarionRecorderSpec_cxx.swift +354 -0
- package/nitrogen/generated/ios/swift/NativeRecorderConfig.swift +108 -0
- package/nitrogen/generated/ios/swift/NativeRecorderError.swift +39 -0
- package/nitrogen/generated/ios/swift/NativeRecorderResult.swift +54 -0
- package/nitrogen/generated/shared/c++/HybridClarionRecorderSpec.cpp +34 -0
- package/nitrogen/generated/shared/c++/HybridClarionRecorderSpec.hpp +84 -0
- package/nitrogen/generated/shared/c++/NativeRecorderConfig.hpp +116 -0
- package/nitrogen/generated/shared/c++/NativeRecorderError.hpp +91 -0
- package/nitrogen/generated/shared/c++/NativeRecorderResult.hpp +103 -0
- package/package.json +66 -8
- package/src/RecorderEngine.ts +298 -0
- package/src/index.ts +8 -0
- package/src/native.ts +5 -0
- package/src/specs/ClarionRecorder.nitro.ts +58 -0
- package/index.js +0 -1
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridClarionRecorderSpec_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 HybridClarionRecorderSpec 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 HybridClarionRecorderSpec_cxx {
|
|
20
|
+
/**
|
|
21
|
+
* The Swift <> C++ bridge's namespace (`margelo::nitro::clarion::recorder::bridge::swift`)
|
|
22
|
+
* from `ClarionRecorder-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.clarion.recorder.bridge.swift
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Holds an instance of the `HybridClarionRecorderSpec` Swift protocol.
|
|
29
|
+
*/
|
|
30
|
+
private var __implementation: any HybridClarionRecorderSpec
|
|
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_HybridClarionRecorderSpec_
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Create a new `HybridClarionRecorderSpec_cxx` that wraps the given `HybridClarionRecorderSpec`.
|
|
39
|
+
* All properties and methods bridge to C++ types.
|
|
40
|
+
*/
|
|
41
|
+
public init(_ implementation: any HybridClarionRecorderSpec) {
|
|
42
|
+
self.__implementation = implementation
|
|
43
|
+
self.__cxxPart = .init()
|
|
44
|
+
/* no base class */
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Get the actual `HybridClarionRecorderSpec` instance this class wraps.
|
|
49
|
+
*/
|
|
50
|
+
@inline(__always)
|
|
51
|
+
public func getHybridClarionRecorderSpec() -> any HybridClarionRecorderSpec {
|
|
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 `HybridClarionRecorderSpec_cxx`.
|
|
65
|
+
* The pointer has to be a retained opaque `Unmanaged<HybridClarionRecorderSpec_cxx>`.
|
|
66
|
+
* This removes one strong reference from the object!
|
|
67
|
+
*/
|
|
68
|
+
public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridClarionRecorderSpec_cxx {
|
|
69
|
+
return Unmanaged<HybridClarionRecorderSpec_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<HybridClarionRecorderSpec>`.
|
|
75
|
+
*/
|
|
76
|
+
public func getCxxPart() -> bridge.std__shared_ptr_HybridClarionRecorderSpec_ {
|
|
77
|
+
let cachedCxxPart = self.__cxxPart.lock()
|
|
78
|
+
if Bool(fromCxx: cachedCxxPart) {
|
|
79
|
+
return cachedCxxPart
|
|
80
|
+
} else {
|
|
81
|
+
let newCxxPart = bridge.create_std__shared_ptr_HybridClarionRecorderSpec_(self.toUnsafe())
|
|
82
|
+
__cxxPart = bridge.weakify_std__shared_ptr_HybridClarionRecorderSpec_(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: HybridClarionRecorderSpec_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 state: std.string {
|
|
125
|
+
@inline(__always)
|
|
126
|
+
get {
|
|
127
|
+
return std.string(self.__implementation.state)
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// Methods
|
|
132
|
+
@inline(__always)
|
|
133
|
+
public final func prepare(config: NativeRecorderConfig) -> bridge.Result_std__shared_ptr_Promise_void___ {
|
|
134
|
+
do {
|
|
135
|
+
let __result = try self.__implementation.prepare(config: config)
|
|
136
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_void__ in
|
|
137
|
+
let __promise = bridge.create_std__shared_ptr_Promise_void__()
|
|
138
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_void__(__promise)
|
|
139
|
+
__result
|
|
140
|
+
.then({ __result in __promiseHolder.resolve() })
|
|
141
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
142
|
+
return __promise
|
|
143
|
+
}()
|
|
144
|
+
return bridge.create_Result_std__shared_ptr_Promise_void___(__resultCpp)
|
|
145
|
+
} catch (let __error) {
|
|
146
|
+
let __exceptionPtr = __error.toCpp()
|
|
147
|
+
return bridge.create_Result_std__shared_ptr_Promise_void___(__exceptionPtr)
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
@inline(__always)
|
|
152
|
+
public final func start() -> bridge.Result_std__shared_ptr_Promise_void___ {
|
|
153
|
+
do {
|
|
154
|
+
let __result = try self.__implementation.start()
|
|
155
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_void__ in
|
|
156
|
+
let __promise = bridge.create_std__shared_ptr_Promise_void__()
|
|
157
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_void__(__promise)
|
|
158
|
+
__result
|
|
159
|
+
.then({ __result in __promiseHolder.resolve() })
|
|
160
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
161
|
+
return __promise
|
|
162
|
+
}()
|
|
163
|
+
return bridge.create_Result_std__shared_ptr_Promise_void___(__resultCpp)
|
|
164
|
+
} catch (let __error) {
|
|
165
|
+
let __exceptionPtr = __error.toCpp()
|
|
166
|
+
return bridge.create_Result_std__shared_ptr_Promise_void___(__exceptionPtr)
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
@inline(__always)
|
|
171
|
+
public final func pause() -> bridge.Result_std__shared_ptr_Promise_void___ {
|
|
172
|
+
do {
|
|
173
|
+
let __result = try self.__implementation.pause()
|
|
174
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_void__ in
|
|
175
|
+
let __promise = bridge.create_std__shared_ptr_Promise_void__()
|
|
176
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_void__(__promise)
|
|
177
|
+
__result
|
|
178
|
+
.then({ __result in __promiseHolder.resolve() })
|
|
179
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
180
|
+
return __promise
|
|
181
|
+
}()
|
|
182
|
+
return bridge.create_Result_std__shared_ptr_Promise_void___(__resultCpp)
|
|
183
|
+
} catch (let __error) {
|
|
184
|
+
let __exceptionPtr = __error.toCpp()
|
|
185
|
+
return bridge.create_Result_std__shared_ptr_Promise_void___(__exceptionPtr)
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
@inline(__always)
|
|
190
|
+
public final func resume() -> bridge.Result_std__shared_ptr_Promise_void___ {
|
|
191
|
+
do {
|
|
192
|
+
let __result = try self.__implementation.resume()
|
|
193
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_void__ in
|
|
194
|
+
let __promise = bridge.create_std__shared_ptr_Promise_void__()
|
|
195
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_void__(__promise)
|
|
196
|
+
__result
|
|
197
|
+
.then({ __result in __promiseHolder.resolve() })
|
|
198
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
199
|
+
return __promise
|
|
200
|
+
}()
|
|
201
|
+
return bridge.create_Result_std__shared_ptr_Promise_void___(__resultCpp)
|
|
202
|
+
} catch (let __error) {
|
|
203
|
+
let __exceptionPtr = __error.toCpp()
|
|
204
|
+
return bridge.create_Result_std__shared_ptr_Promise_void___(__exceptionPtr)
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
@inline(__always)
|
|
209
|
+
public final func stop() -> bridge.Result_std__shared_ptr_Promise_NativeRecorderResult___ {
|
|
210
|
+
do {
|
|
211
|
+
let __result = try self.__implementation.stop()
|
|
212
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_NativeRecorderResult__ in
|
|
213
|
+
let __promise = bridge.create_std__shared_ptr_Promise_NativeRecorderResult__()
|
|
214
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_NativeRecorderResult__(__promise)
|
|
215
|
+
__result
|
|
216
|
+
.then({ __result in __promiseHolder.resolve(__result) })
|
|
217
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
218
|
+
return __promise
|
|
219
|
+
}()
|
|
220
|
+
return bridge.create_Result_std__shared_ptr_Promise_NativeRecorderResult___(__resultCpp)
|
|
221
|
+
} catch (let __error) {
|
|
222
|
+
let __exceptionPtr = __error.toCpp()
|
|
223
|
+
return bridge.create_Result_std__shared_ptr_Promise_NativeRecorderResult___(__exceptionPtr)
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
@inline(__always)
|
|
228
|
+
public final func discard() -> bridge.Result_std__shared_ptr_Promise_void___ {
|
|
229
|
+
do {
|
|
230
|
+
let __result = try self.__implementation.discard()
|
|
231
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_void__ in
|
|
232
|
+
let __promise = bridge.create_std__shared_ptr_Promise_void__()
|
|
233
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_void__(__promise)
|
|
234
|
+
__result
|
|
235
|
+
.then({ __result in __promiseHolder.resolve() })
|
|
236
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
237
|
+
return __promise
|
|
238
|
+
}()
|
|
239
|
+
return bridge.create_Result_std__shared_ptr_Promise_void___(__resultCpp)
|
|
240
|
+
} catch (let __error) {
|
|
241
|
+
let __exceptionPtr = __error.toCpp()
|
|
242
|
+
return bridge.create_Result_std__shared_ptr_Promise_void___(__exceptionPtr)
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
@inline(__always)
|
|
247
|
+
public final func release() -> bridge.Result_std__shared_ptr_Promise_void___ {
|
|
248
|
+
do {
|
|
249
|
+
let __result = try self.__implementation.release()
|
|
250
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_void__ in
|
|
251
|
+
let __promise = bridge.create_std__shared_ptr_Promise_void__()
|
|
252
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_void__(__promise)
|
|
253
|
+
__result
|
|
254
|
+
.then({ __result in __promiseHolder.resolve() })
|
|
255
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
256
|
+
return __promise
|
|
257
|
+
}()
|
|
258
|
+
return bridge.create_Result_std__shared_ptr_Promise_void___(__resultCpp)
|
|
259
|
+
} catch (let __error) {
|
|
260
|
+
let __exceptionPtr = __error.toCpp()
|
|
261
|
+
return bridge.create_Result_std__shared_ptr_Promise_void___(__exceptionPtr)
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
@inline(__always)
|
|
266
|
+
public final func addStateListener(listener: bridge.Func_void_std__string) -> bridge.Result_double_ {
|
|
267
|
+
do {
|
|
268
|
+
let __result = try self.__implementation.addStateListener(listener: { () -> (String) -> Void in
|
|
269
|
+
let __wrappedFunction = bridge.wrap_Func_void_std__string(listener)
|
|
270
|
+
return { (__state: String) -> Void in
|
|
271
|
+
__wrappedFunction.call(std.string(__state))
|
|
272
|
+
}
|
|
273
|
+
}())
|
|
274
|
+
let __resultCpp = __result
|
|
275
|
+
return bridge.create_Result_double_(__resultCpp)
|
|
276
|
+
} catch (let __error) {
|
|
277
|
+
let __exceptionPtr = __error.toCpp()
|
|
278
|
+
return bridge.create_Result_double_(__exceptionPtr)
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
@inline(__always)
|
|
283
|
+
public final func addAudioLevelListener(listener: bridge.Func_void_double_double) -> bridge.Result_double_ {
|
|
284
|
+
do {
|
|
285
|
+
let __result = try self.__implementation.addAudioLevelListener(listener: { () -> (Double, Double) -> Void in
|
|
286
|
+
let __wrappedFunction = bridge.wrap_Func_void_double_double(listener)
|
|
287
|
+
return { (__rms: Double, __peak: Double) -> Void in
|
|
288
|
+
__wrappedFunction.call(__rms, __peak)
|
|
289
|
+
}
|
|
290
|
+
}())
|
|
291
|
+
let __resultCpp = __result
|
|
292
|
+
return bridge.create_Result_double_(__resultCpp)
|
|
293
|
+
} catch (let __error) {
|
|
294
|
+
let __exceptionPtr = __error.toCpp()
|
|
295
|
+
return bridge.create_Result_double_(__exceptionPtr)
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
@inline(__always)
|
|
300
|
+
public final func addChunkListener(listener: bridge.Func_void_std__string_double_double_double) -> bridge.Result_double_ {
|
|
301
|
+
do {
|
|
302
|
+
let __result = try self.__implementation.addChunkListener(listener: { () -> (String, Double, Double, Double) -> Void in
|
|
303
|
+
let __wrappedFunction = bridge.wrap_Func_void_std__string_double_double_double(listener)
|
|
304
|
+
return { (__uri: String, __startMs: Double, __endMs: Double, __sizeBytes: Double) -> Void in
|
|
305
|
+
__wrappedFunction.call(std.string(__uri), __startMs, __endMs, __sizeBytes)
|
|
306
|
+
}
|
|
307
|
+
}())
|
|
308
|
+
let __resultCpp = __result
|
|
309
|
+
return bridge.create_Result_double_(__resultCpp)
|
|
310
|
+
} catch (let __error) {
|
|
311
|
+
let __exceptionPtr = __error.toCpp()
|
|
312
|
+
return bridge.create_Result_double_(__exceptionPtr)
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
@inline(__always)
|
|
317
|
+
public final func addErrorListener(listener: bridge.Func_void_NativeRecorderError) -> bridge.Result_double_ {
|
|
318
|
+
do {
|
|
319
|
+
let __result = try self.__implementation.addErrorListener(listener: { () -> (NativeRecorderError) -> Void in
|
|
320
|
+
let __wrappedFunction = bridge.wrap_Func_void_NativeRecorderError(listener)
|
|
321
|
+
return { (__error: NativeRecorderError) -> Void in
|
|
322
|
+
__wrappedFunction.call(__error)
|
|
323
|
+
}
|
|
324
|
+
}())
|
|
325
|
+
let __resultCpp = __result
|
|
326
|
+
return bridge.create_Result_double_(__resultCpp)
|
|
327
|
+
} catch (let __error) {
|
|
328
|
+
let __exceptionPtr = __error.toCpp()
|
|
329
|
+
return bridge.create_Result_double_(__exceptionPtr)
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
@inline(__always)
|
|
334
|
+
public final func removeListener(id: Double) -> bridge.Result_void_ {
|
|
335
|
+
do {
|
|
336
|
+
try self.__implementation.removeListener(id: id)
|
|
337
|
+
return bridge.create_Result_void_()
|
|
338
|
+
} catch (let __error) {
|
|
339
|
+
let __exceptionPtr = __error.toCpp()
|
|
340
|
+
return bridge.create_Result_void_(__exceptionPtr)
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
@inline(__always)
|
|
345
|
+
public final func removeAllListeners() -> bridge.Result_void_ {
|
|
346
|
+
do {
|
|
347
|
+
try self.__implementation.removeAllListeners()
|
|
348
|
+
return bridge.create_Result_void_()
|
|
349
|
+
} catch (let __error) {
|
|
350
|
+
let __exceptionPtr = __error.toCpp()
|
|
351
|
+
return bridge.create_Result_void_(__exceptionPtr)
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NativeRecorderConfig.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
|
+
* Represents an instance of `NativeRecorderConfig`, backed by a C++ struct.
|
|
12
|
+
*/
|
|
13
|
+
public typealias NativeRecorderConfig = margelo.nitro.clarion.recorder.NativeRecorderConfig
|
|
14
|
+
|
|
15
|
+
public extension NativeRecorderConfig {
|
|
16
|
+
private typealias bridge = margelo.nitro.clarion.recorder.bridge.swift
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create a new instance of `NativeRecorderConfig`.
|
|
20
|
+
*/
|
|
21
|
+
init(sampleRate: Double, channels: Double, bitDepth: Double, outputDirectory: String?, filenamePrefix: String?, rotateAfterMs: Double?, emitAudioLevel: Bool, audioLevelIntervalMs: Double, aacBitrate: Double) {
|
|
22
|
+
self.init(sampleRate, channels, bitDepth, { () -> bridge.std__optional_std__string_ in
|
|
23
|
+
if let __unwrappedValue = outputDirectory {
|
|
24
|
+
return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
|
|
25
|
+
} else {
|
|
26
|
+
return .init()
|
|
27
|
+
}
|
|
28
|
+
}(), { () -> bridge.std__optional_std__string_ in
|
|
29
|
+
if let __unwrappedValue = filenamePrefix {
|
|
30
|
+
return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
|
|
31
|
+
} else {
|
|
32
|
+
return .init()
|
|
33
|
+
}
|
|
34
|
+
}(), { () -> bridge.std__optional_double_ in
|
|
35
|
+
if let __unwrappedValue = rotateAfterMs {
|
|
36
|
+
return bridge.create_std__optional_double_(__unwrappedValue)
|
|
37
|
+
} else {
|
|
38
|
+
return .init()
|
|
39
|
+
}
|
|
40
|
+
}(), emitAudioLevel, audioLevelIntervalMs, aacBitrate)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@inline(__always)
|
|
44
|
+
var sampleRate: Double {
|
|
45
|
+
return self.__sampleRate
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@inline(__always)
|
|
49
|
+
var channels: Double {
|
|
50
|
+
return self.__channels
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@inline(__always)
|
|
54
|
+
var bitDepth: Double {
|
|
55
|
+
return self.__bitDepth
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
@inline(__always)
|
|
59
|
+
var outputDirectory: String? {
|
|
60
|
+
return { () -> String? in
|
|
61
|
+
if bridge.has_value_std__optional_std__string_(self.__outputDirectory) {
|
|
62
|
+
let __unwrapped = bridge.get_std__optional_std__string_(self.__outputDirectory)
|
|
63
|
+
return String(__unwrapped)
|
|
64
|
+
} else {
|
|
65
|
+
return nil
|
|
66
|
+
}
|
|
67
|
+
}()
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
@inline(__always)
|
|
71
|
+
var filenamePrefix: String? {
|
|
72
|
+
return { () -> String? in
|
|
73
|
+
if bridge.has_value_std__optional_std__string_(self.__filenamePrefix) {
|
|
74
|
+
let __unwrapped = bridge.get_std__optional_std__string_(self.__filenamePrefix)
|
|
75
|
+
return String(__unwrapped)
|
|
76
|
+
} else {
|
|
77
|
+
return nil
|
|
78
|
+
}
|
|
79
|
+
}()
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
@inline(__always)
|
|
83
|
+
var rotateAfterMs: Double? {
|
|
84
|
+
return { () -> Double? in
|
|
85
|
+
if bridge.has_value_std__optional_double_(self.__rotateAfterMs) {
|
|
86
|
+
let __unwrapped = bridge.get_std__optional_double_(self.__rotateAfterMs)
|
|
87
|
+
return __unwrapped
|
|
88
|
+
} else {
|
|
89
|
+
return nil
|
|
90
|
+
}
|
|
91
|
+
}()
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
@inline(__always)
|
|
95
|
+
var emitAudioLevel: Bool {
|
|
96
|
+
return self.__emitAudioLevel
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
@inline(__always)
|
|
100
|
+
var audioLevelIntervalMs: Double {
|
|
101
|
+
return self.__audioLevelIntervalMs
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
@inline(__always)
|
|
105
|
+
var aacBitrate: Double {
|
|
106
|
+
return self.__aacBitrate
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NativeRecorderError.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
|
+
* Represents an instance of `NativeRecorderError`, backed by a C++ struct.
|
|
12
|
+
*/
|
|
13
|
+
public typealias NativeRecorderError = margelo.nitro.clarion.recorder.NativeRecorderError
|
|
14
|
+
|
|
15
|
+
public extension NativeRecorderError {
|
|
16
|
+
private typealias bridge = margelo.nitro.clarion.recorder.bridge.swift
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create a new instance of `NativeRecorderError`.
|
|
20
|
+
*/
|
|
21
|
+
init(code: String, message: String, recoverable: Bool) {
|
|
22
|
+
self.init(std.string(code), std.string(message), recoverable)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@inline(__always)
|
|
26
|
+
var code: String {
|
|
27
|
+
return String(self.__code)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@inline(__always)
|
|
31
|
+
var message: String {
|
|
32
|
+
return String(self.__message)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@inline(__always)
|
|
36
|
+
var recoverable: Bool {
|
|
37
|
+
return self.__recoverable
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NativeRecorderResult.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
|
+
* Represents an instance of `NativeRecorderResult`, backed by a C++ struct.
|
|
12
|
+
*/
|
|
13
|
+
public typealias NativeRecorderResult = margelo.nitro.clarion.recorder.NativeRecorderResult
|
|
14
|
+
|
|
15
|
+
public extension NativeRecorderResult {
|
|
16
|
+
private typealias bridge = margelo.nitro.clarion.recorder.bridge.swift
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create a new instance of `NativeRecorderResult`.
|
|
20
|
+
*/
|
|
21
|
+
init(uri: String, durationMs: Double, sizeBytes: Double, sampleRate: Double, channels: Double, bitDepth: Double) {
|
|
22
|
+
self.init(std.string(uri), durationMs, sizeBytes, sampleRate, channels, bitDepth)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@inline(__always)
|
|
26
|
+
var uri: String {
|
|
27
|
+
return String(self.__uri)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@inline(__always)
|
|
31
|
+
var durationMs: Double {
|
|
32
|
+
return self.__durationMs
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@inline(__always)
|
|
36
|
+
var sizeBytes: Double {
|
|
37
|
+
return self.__sizeBytes
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@inline(__always)
|
|
41
|
+
var sampleRate: Double {
|
|
42
|
+
return self.__sampleRate
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@inline(__always)
|
|
46
|
+
var channels: Double {
|
|
47
|
+
return self.__channels
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@inline(__always)
|
|
51
|
+
var bitDepth: Double {
|
|
52
|
+
return self.__bitDepth
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridClarionRecorderSpec.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 "HybridClarionRecorderSpec.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::clarion::recorder {
|
|
11
|
+
|
|
12
|
+
void HybridClarionRecorderSpec::loadHybridMethods() {
|
|
13
|
+
// load base methods/properties
|
|
14
|
+
HybridObject::loadHybridMethods();
|
|
15
|
+
// load custom methods/properties
|
|
16
|
+
registerHybrids(this, [](Prototype& prototype) {
|
|
17
|
+
prototype.registerHybridGetter("state", &HybridClarionRecorderSpec::getState);
|
|
18
|
+
prototype.registerHybridMethod("prepare", &HybridClarionRecorderSpec::prepare);
|
|
19
|
+
prototype.registerHybridMethod("start", &HybridClarionRecorderSpec::start);
|
|
20
|
+
prototype.registerHybridMethod("pause", &HybridClarionRecorderSpec::pause);
|
|
21
|
+
prototype.registerHybridMethod("resume", &HybridClarionRecorderSpec::resume);
|
|
22
|
+
prototype.registerHybridMethod("stop", &HybridClarionRecorderSpec::stop);
|
|
23
|
+
prototype.registerHybridMethod("discard", &HybridClarionRecorderSpec::discard);
|
|
24
|
+
prototype.registerHybridMethod("release", &HybridClarionRecorderSpec::release);
|
|
25
|
+
prototype.registerHybridMethod("addStateListener", &HybridClarionRecorderSpec::addStateListener);
|
|
26
|
+
prototype.registerHybridMethod("addAudioLevelListener", &HybridClarionRecorderSpec::addAudioLevelListener);
|
|
27
|
+
prototype.registerHybridMethod("addChunkListener", &HybridClarionRecorderSpec::addChunkListener);
|
|
28
|
+
prototype.registerHybridMethod("addErrorListener", &HybridClarionRecorderSpec::addErrorListener);
|
|
29
|
+
prototype.registerHybridMethod("removeListener", &HybridClarionRecorderSpec::removeListener);
|
|
30
|
+
prototype.registerHybridMethod("removeAllListeners", &HybridClarionRecorderSpec::removeAllListeners);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
} // namespace margelo::nitro::clarion::recorder
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridClarionRecorderSpec.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/HybridObject.hpp>)
|
|
11
|
+
#include <NitroModules/HybridObject.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
|
|
16
|
+
// Forward declaration of `NativeRecorderConfig` to properly resolve imports.
|
|
17
|
+
namespace margelo::nitro::clarion::recorder { struct NativeRecorderConfig; }
|
|
18
|
+
// Forward declaration of `NativeRecorderResult` to properly resolve imports.
|
|
19
|
+
namespace margelo::nitro::clarion::recorder { struct NativeRecorderResult; }
|
|
20
|
+
// Forward declaration of `NativeRecorderError` to properly resolve imports.
|
|
21
|
+
namespace margelo::nitro::clarion::recorder { struct NativeRecorderError; }
|
|
22
|
+
|
|
23
|
+
#include <string>
|
|
24
|
+
#include <NitroModules/Promise.hpp>
|
|
25
|
+
#include "NativeRecorderConfig.hpp"
|
|
26
|
+
#include "NativeRecorderResult.hpp"
|
|
27
|
+
#include <functional>
|
|
28
|
+
#include "NativeRecorderError.hpp"
|
|
29
|
+
|
|
30
|
+
namespace margelo::nitro::clarion::recorder {
|
|
31
|
+
|
|
32
|
+
using namespace margelo::nitro;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* An abstract base class for `ClarionRecorder`
|
|
36
|
+
* Inherit this class to create instances of `HybridClarionRecorderSpec` in C++.
|
|
37
|
+
* You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
|
|
38
|
+
* @example
|
|
39
|
+
* ```cpp
|
|
40
|
+
* class HybridClarionRecorder: public HybridClarionRecorderSpec {
|
|
41
|
+
* public:
|
|
42
|
+
* HybridClarionRecorder(...): HybridObject(TAG) { ... }
|
|
43
|
+
* // ...
|
|
44
|
+
* };
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
class HybridClarionRecorderSpec: public virtual HybridObject {
|
|
48
|
+
public:
|
|
49
|
+
// Constructor
|
|
50
|
+
explicit HybridClarionRecorderSpec(): HybridObject(TAG) { }
|
|
51
|
+
|
|
52
|
+
// Destructor
|
|
53
|
+
~HybridClarionRecorderSpec() override = default;
|
|
54
|
+
|
|
55
|
+
public:
|
|
56
|
+
// Properties
|
|
57
|
+
virtual std::string getState() = 0;
|
|
58
|
+
|
|
59
|
+
public:
|
|
60
|
+
// Methods
|
|
61
|
+
virtual std::shared_ptr<Promise<void>> prepare(const NativeRecorderConfig& config) = 0;
|
|
62
|
+
virtual std::shared_ptr<Promise<void>> start() = 0;
|
|
63
|
+
virtual std::shared_ptr<Promise<void>> pause() = 0;
|
|
64
|
+
virtual std::shared_ptr<Promise<void>> resume() = 0;
|
|
65
|
+
virtual std::shared_ptr<Promise<NativeRecorderResult>> stop() = 0;
|
|
66
|
+
virtual std::shared_ptr<Promise<void>> discard() = 0;
|
|
67
|
+
virtual std::shared_ptr<Promise<void>> release() = 0;
|
|
68
|
+
virtual double addStateListener(const std::function<void(const std::string& /* state */)>& listener) = 0;
|
|
69
|
+
virtual double addAudioLevelListener(const std::function<void(double /* rms */, double /* peak */)>& listener) = 0;
|
|
70
|
+
virtual double addChunkListener(const std::function<void(const std::string& /* uri */, double /* startMs */, double /* endMs */, double /* sizeBytes */)>& listener) = 0;
|
|
71
|
+
virtual double addErrorListener(const std::function<void(const NativeRecorderError& /* error */)>& listener) = 0;
|
|
72
|
+
virtual void removeListener(double id) = 0;
|
|
73
|
+
virtual void removeAllListeners() = 0;
|
|
74
|
+
|
|
75
|
+
protected:
|
|
76
|
+
// Hybrid Setup
|
|
77
|
+
void loadHybridMethods() override;
|
|
78
|
+
|
|
79
|
+
protected:
|
|
80
|
+
// Tag for logging
|
|
81
|
+
static constexpr auto TAG = "ClarionRecorder";
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
} // namespace margelo::nitro::clarion::recorder
|