react-native-audio-concat 0.2.3 → 0.4.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/AudioConcat.podspec +2 -21
- package/README.md +3 -7
- package/android/build.gradle +2 -54
- package/android/src/main/java/com/audioconcat/AudioConcatModule.kt +1178 -0
- package/android/src/main/java/com/audioconcat/AudioConcatPackage.kt +33 -0
- package/ios/AudioConcat.h +5 -0
- package/ios/AudioConcat.mm +104 -0
- package/lib/module/NativeAudioConcat.js +5 -0
- package/lib/module/NativeAudioConcat.js.map +1 -0
- package/lib/module/index.js +2 -28
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/NativeAudioConcat.d.ts +12 -0
- package/lib/typescript/src/NativeAudioConcat.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +6 -27
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +14 -18
- package/src/NativeAudioConcat.ts +12 -0
- package/src/index.tsx +4 -32
- package/android/CMakeLists.txt +0 -24
- package/android/src/main/cpp/cpp-adapter.cpp +0 -6
- package/android/src/main/java/com/margelo/nitro/audioconcat/AudioConcat.kt +0 -349
- package/android/src/main/java/com/margelo/nitro/audioconcat/AudioConcatPackage.kt +0 -22
- package/ios/AudioConcat.swift +0 -75
- package/lib/module/AudioConcat.nitro.js +0 -4
- package/lib/module/AudioConcat.nitro.js.map +0 -1
- package/lib/typescript/src/AudioConcat.nitro.d.ts +0 -16
- package/lib/typescript/src/AudioConcat.nitro.d.ts.map +0 -1
- package/nitro.json +0 -17
- package/nitrogen/generated/android/audioconcat+autolinking.cmake +0 -82
- package/nitrogen/generated/android/audioconcat+autolinking.gradle +0 -27
- package/nitrogen/generated/android/audioconcatOnLoad.cpp +0 -44
- package/nitrogen/generated/android/audioconcatOnLoad.hpp +0 -25
- package/nitrogen/generated/android/c++/JAudioData.hpp +0 -53
- package/nitrogen/generated/android/c++/JAudioDataOrSilence.cpp +0 -26
- package/nitrogen/generated/android/c++/JAudioDataOrSilence.hpp +0 -72
- package/nitrogen/generated/android/c++/JHybridAudioConcatSpec.cpp +0 -77
- package/nitrogen/generated/android/c++/JHybridAudioConcatSpec.hpp +0 -64
- package/nitrogen/generated/android/c++/JSilentData.hpp +0 -53
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/audioconcat/AudioData.kt +0 -29
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/audioconcat/AudioDataOrSilence.kt +0 -42
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/audioconcat/HybridAudioConcatSpec.kt +0 -52
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/audioconcat/SilentData.kt +0 -29
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/audioconcat/audioconcatOnLoad.kt +0 -35
- package/nitrogen/generated/ios/AudioConcat+autolinking.rb +0 -60
- package/nitrogen/generated/ios/AudioConcat-Swift-Cxx-Bridge.cpp +0 -48
- package/nitrogen/generated/ios/AudioConcat-Swift-Cxx-Bridge.hpp +0 -160
- package/nitrogen/generated/ios/AudioConcat-Swift-Cxx-Umbrella.hpp +0 -53
- package/nitrogen/generated/ios/AudioConcatAutolinking.mm +0 -33
- package/nitrogen/generated/ios/AudioConcatAutolinking.swift +0 -25
- package/nitrogen/generated/ios/c++/HybridAudioConcatSpecSwift.cpp +0 -11
- package/nitrogen/generated/ios/c++/HybridAudioConcatSpecSwift.hpp +0 -81
- package/nitrogen/generated/ios/swift/AudioData.swift +0 -35
- package/nitrogen/generated/ios/swift/AudioDataOrSilence.swift +0 -18
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +0 -47
- package/nitrogen/generated/ios/swift/Func_void_std__string.swift +0 -47
- package/nitrogen/generated/ios/swift/HybridAudioConcatSpec.swift +0 -49
- package/nitrogen/generated/ios/swift/HybridAudioConcatSpec_cxx.swift +0 -142
- package/nitrogen/generated/ios/swift/SilentData.swift +0 -35
- package/nitrogen/generated/shared/c++/AudioData.hpp +0 -67
- package/nitrogen/generated/shared/c++/HybridAudioConcatSpec.cpp +0 -21
- package/nitrogen/generated/shared/c++/HybridAudioConcatSpec.hpp +0 -70
- package/nitrogen/generated/shared/c++/SilentData.hpp +0 -67
- package/src/AudioConcat.nitro.ts +0 -19
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// HybridAudioConcatSpec_cxx.swift
|
|
3
|
-
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
-
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
-
///
|
|
7
|
-
|
|
8
|
-
import Foundation
|
|
9
|
-
import NitroModules
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* A class implementation that bridges HybridAudioConcatSpec over to C++.
|
|
13
|
-
* In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
|
|
14
|
-
*
|
|
15
|
-
* Also, some Swift types need to be bridged with special handling:
|
|
16
|
-
* - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330)
|
|
17
|
-
* - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
|
|
18
|
-
* - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
|
|
19
|
-
*/
|
|
20
|
-
open class HybridAudioConcatSpec_cxx {
|
|
21
|
-
/**
|
|
22
|
-
* The Swift <> C++ bridge's namespace (`margelo::nitro::audioconcat::bridge::swift`)
|
|
23
|
-
* from `AudioConcat-Swift-Cxx-Bridge.hpp`.
|
|
24
|
-
* This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
|
|
25
|
-
*/
|
|
26
|
-
public typealias bridge = margelo.nitro.audioconcat.bridge.swift
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Holds an instance of the `HybridAudioConcatSpec` Swift protocol.
|
|
30
|
-
*/
|
|
31
|
-
private var __implementation: any HybridAudioConcatSpec
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Holds a weak pointer to the C++ class that wraps the Swift class.
|
|
35
|
-
*/
|
|
36
|
-
private var __cxxPart: bridge.std__weak_ptr_HybridAudioConcatSpec_
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Create a new `HybridAudioConcatSpec_cxx` that wraps the given `HybridAudioConcatSpec`.
|
|
40
|
-
* All properties and methods bridge to C++ types.
|
|
41
|
-
*/
|
|
42
|
-
public init(_ implementation: any HybridAudioConcatSpec) {
|
|
43
|
-
self.__implementation = implementation
|
|
44
|
-
self.__cxxPart = .init()
|
|
45
|
-
/* no base class */
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Get the actual `HybridAudioConcatSpec` instance this class wraps.
|
|
50
|
-
*/
|
|
51
|
-
@inline(__always)
|
|
52
|
-
public func getHybridAudioConcatSpec() -> any HybridAudioConcatSpec {
|
|
53
|
-
return __implementation
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Casts this instance to a retained unsafe raw pointer.
|
|
58
|
-
* This acquires one additional strong reference on the object!
|
|
59
|
-
*/
|
|
60
|
-
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
61
|
-
return Unmanaged.passRetained(self).toOpaque()
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Casts an unsafe pointer to a `HybridAudioConcatSpec_cxx`.
|
|
66
|
-
* The pointer has to be a retained opaque `Unmanaged<HybridAudioConcatSpec_cxx>`.
|
|
67
|
-
* This removes one strong reference from the object!
|
|
68
|
-
*/
|
|
69
|
-
public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridAudioConcatSpec_cxx {
|
|
70
|
-
return Unmanaged<HybridAudioConcatSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Gets (or creates) the C++ part of this Hybrid Object.
|
|
75
|
-
* The C++ part is a `std::shared_ptr<HybridAudioConcatSpec>`.
|
|
76
|
-
*/
|
|
77
|
-
public func getCxxPart() -> bridge.std__shared_ptr_HybridAudioConcatSpec_ {
|
|
78
|
-
let cachedCxxPart = self.__cxxPart.lock()
|
|
79
|
-
if cachedCxxPart.__convertToBool() {
|
|
80
|
-
return cachedCxxPart
|
|
81
|
-
} else {
|
|
82
|
-
let newCxxPart = bridge.create_std__shared_ptr_HybridAudioConcatSpec_(self.toUnsafe())
|
|
83
|
-
__cxxPart = bridge.weakify_std__shared_ptr_HybridAudioConcatSpec_(newCxxPart)
|
|
84
|
-
return newCxxPart
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Get the memory size of the Swift class (plus size of any other allocations)
|
|
92
|
-
* so the JS VM can properly track it and garbage-collect the JS object if needed.
|
|
93
|
-
*/
|
|
94
|
-
@inline(__always)
|
|
95
|
-
public var memorySize: Int {
|
|
96
|
-
return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Call dispose() on the Swift class.
|
|
101
|
-
* This _may_ be called manually from JS.
|
|
102
|
-
*/
|
|
103
|
-
@inline(__always)
|
|
104
|
-
public func dispose() {
|
|
105
|
-
self.__implementation.dispose()
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// Properties
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
// Methods
|
|
112
|
-
@inline(__always)
|
|
113
|
-
public final func concatAudioFiles(data: bridge.std__vector_std__variant_AudioData__SilentData__, outputPath: std.string) -> bridge.Result_std__shared_ptr_Promise_std__string___ {
|
|
114
|
-
do {
|
|
115
|
-
let __result = try self.__implementation.concatAudioFiles(data: data.map({ __item in { () -> AudioDataOrSilence in
|
|
116
|
-
let __variant = bridge.std__variant_AudioData__SilentData_(__item)
|
|
117
|
-
switch __variant.index() {
|
|
118
|
-
case 0:
|
|
119
|
-
let __actual = __variant.get_0()
|
|
120
|
-
return .first(__actual)
|
|
121
|
-
case 1:
|
|
122
|
-
let __actual = __variant.get_1()
|
|
123
|
-
return .second(__actual)
|
|
124
|
-
default:
|
|
125
|
-
fatalError("Variant can never have index \(__variant.index())!")
|
|
126
|
-
}
|
|
127
|
-
}() }), outputPath: String(outputPath))
|
|
128
|
-
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_std__string__ in
|
|
129
|
-
let __promise = bridge.create_std__shared_ptr_Promise_std__string__()
|
|
130
|
-
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_std__string__(__promise)
|
|
131
|
-
__result
|
|
132
|
-
.then({ __result in __promiseHolder.resolve(std.string(__result)) })
|
|
133
|
-
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
134
|
-
return __promise
|
|
135
|
-
}()
|
|
136
|
-
return bridge.create_Result_std__shared_ptr_Promise_std__string___(__resultCpp)
|
|
137
|
-
} catch (let __error) {
|
|
138
|
-
let __exceptionPtr = __error.toCpp()
|
|
139
|
-
return bridge.create_Result_std__shared_ptr_Promise_std__string___(__exceptionPtr)
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// SilentData.swift
|
|
3
|
-
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
-
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
-
///
|
|
7
|
-
|
|
8
|
-
import NitroModules
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Represents an instance of `SilentData`, backed by a C++ struct.
|
|
12
|
-
*/
|
|
13
|
-
public typealias SilentData = margelo.nitro.audioconcat.SilentData
|
|
14
|
-
|
|
15
|
-
public extension SilentData {
|
|
16
|
-
private typealias bridge = margelo.nitro.audioconcat.bridge.swift
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Create a new instance of `SilentData`.
|
|
20
|
-
*/
|
|
21
|
-
init(durationMs: Double) {
|
|
22
|
-
self.init(durationMs)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
var durationMs: Double {
|
|
26
|
-
@inline(__always)
|
|
27
|
-
get {
|
|
28
|
-
return self.__durationMs
|
|
29
|
-
}
|
|
30
|
-
@inline(__always)
|
|
31
|
-
set {
|
|
32
|
-
self.__durationMs = newValue
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// AudioData.hpp
|
|
3
|
-
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
-
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright © 2025 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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
#include <string>
|
|
24
|
-
|
|
25
|
-
namespace margelo::nitro::audioconcat {
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* A struct which can be represented as a JavaScript object (AudioData).
|
|
29
|
-
*/
|
|
30
|
-
struct AudioData {
|
|
31
|
-
public:
|
|
32
|
-
std::string filePath SWIFT_PRIVATE;
|
|
33
|
-
|
|
34
|
-
public:
|
|
35
|
-
AudioData() = default;
|
|
36
|
-
explicit AudioData(std::string filePath): filePath(filePath) {}
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
} // namespace margelo::nitro::audioconcat
|
|
40
|
-
|
|
41
|
-
namespace margelo::nitro {
|
|
42
|
-
|
|
43
|
-
// C++ AudioData <> JS AudioData (object)
|
|
44
|
-
template <>
|
|
45
|
-
struct JSIConverter<margelo::nitro::audioconcat::AudioData> final {
|
|
46
|
-
static inline margelo::nitro::audioconcat::AudioData fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
47
|
-
jsi::Object obj = arg.asObject(runtime);
|
|
48
|
-
return margelo::nitro::audioconcat::AudioData(
|
|
49
|
-
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "filePath"))
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::audioconcat::AudioData& arg) {
|
|
53
|
-
jsi::Object obj(runtime);
|
|
54
|
-
obj.setProperty(runtime, "filePath", JSIConverter<std::string>::toJSI(runtime, arg.filePath));
|
|
55
|
-
return obj;
|
|
56
|
-
}
|
|
57
|
-
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
58
|
-
if (!value.isObject()) {
|
|
59
|
-
return false;
|
|
60
|
-
}
|
|
61
|
-
jsi::Object obj = value.getObject(runtime);
|
|
62
|
-
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "filePath"))) return false;
|
|
63
|
-
return true;
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
} // namespace margelo::nitro
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// HybridAudioConcatSpec.cpp
|
|
3
|
-
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
-
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
-
///
|
|
7
|
-
|
|
8
|
-
#include "HybridAudioConcatSpec.hpp"
|
|
9
|
-
|
|
10
|
-
namespace margelo::nitro::audioconcat {
|
|
11
|
-
|
|
12
|
-
void HybridAudioConcatSpec::loadHybridMethods() {
|
|
13
|
-
// load base methods/properties
|
|
14
|
-
HybridObject::loadHybridMethods();
|
|
15
|
-
// load custom methods/properties
|
|
16
|
-
registerHybrids(this, [](Prototype& prototype) {
|
|
17
|
-
prototype.registerHybridMethod("concatAudioFiles", &HybridAudioConcatSpec::concatAudioFiles);
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
} // namespace margelo::nitro::audioconcat
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// HybridAudioConcatSpec.hpp
|
|
3
|
-
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
-
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright © 2025 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 `AudioData` to properly resolve imports.
|
|
17
|
-
namespace margelo::nitro::audioconcat { struct AudioData; }
|
|
18
|
-
// Forward declaration of `SilentData` to properly resolve imports.
|
|
19
|
-
namespace margelo::nitro::audioconcat { struct SilentData; }
|
|
20
|
-
|
|
21
|
-
#include <string>
|
|
22
|
-
#include <NitroModules/Promise.hpp>
|
|
23
|
-
#include "AudioData.hpp"
|
|
24
|
-
#include "SilentData.hpp"
|
|
25
|
-
#include <variant>
|
|
26
|
-
#include <vector>
|
|
27
|
-
|
|
28
|
-
namespace margelo::nitro::audioconcat {
|
|
29
|
-
|
|
30
|
-
using namespace margelo::nitro;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* An abstract base class for `AudioConcat`
|
|
34
|
-
* Inherit this class to create instances of `HybridAudioConcatSpec` in C++.
|
|
35
|
-
* You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
|
|
36
|
-
* @example
|
|
37
|
-
* ```cpp
|
|
38
|
-
* class HybridAudioConcat: public HybridAudioConcatSpec {
|
|
39
|
-
* public:
|
|
40
|
-
* HybridAudioConcat(...): HybridObject(TAG) { ... }
|
|
41
|
-
* // ...
|
|
42
|
-
* };
|
|
43
|
-
* ```
|
|
44
|
-
*/
|
|
45
|
-
class HybridAudioConcatSpec: public virtual HybridObject {
|
|
46
|
-
public:
|
|
47
|
-
// Constructor
|
|
48
|
-
explicit HybridAudioConcatSpec(): HybridObject(TAG) { }
|
|
49
|
-
|
|
50
|
-
// Destructor
|
|
51
|
-
~HybridAudioConcatSpec() override = default;
|
|
52
|
-
|
|
53
|
-
public:
|
|
54
|
-
// Properties
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
public:
|
|
58
|
-
// Methods
|
|
59
|
-
virtual std::shared_ptr<Promise<std::string>> concatAudioFiles(const std::vector<std::variant<AudioData, SilentData>>& data, const std::string& outputPath) = 0;
|
|
60
|
-
|
|
61
|
-
protected:
|
|
62
|
-
// Hybrid Setup
|
|
63
|
-
void loadHybridMethods() override;
|
|
64
|
-
|
|
65
|
-
protected:
|
|
66
|
-
// Tag for logging
|
|
67
|
-
static constexpr auto TAG = "AudioConcat";
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
} // namespace margelo::nitro::audioconcat
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// SilentData.hpp
|
|
3
|
-
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
-
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright © 2025 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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
namespace margelo::nitro::audioconcat {
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* A struct which can be represented as a JavaScript object (SilentData).
|
|
29
|
-
*/
|
|
30
|
-
struct SilentData {
|
|
31
|
-
public:
|
|
32
|
-
double durationMs SWIFT_PRIVATE;
|
|
33
|
-
|
|
34
|
-
public:
|
|
35
|
-
SilentData() = default;
|
|
36
|
-
explicit SilentData(double durationMs): durationMs(durationMs) {}
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
} // namespace margelo::nitro::audioconcat
|
|
40
|
-
|
|
41
|
-
namespace margelo::nitro {
|
|
42
|
-
|
|
43
|
-
// C++ SilentData <> JS SilentData (object)
|
|
44
|
-
template <>
|
|
45
|
-
struct JSIConverter<margelo::nitro::audioconcat::SilentData> final {
|
|
46
|
-
static inline margelo::nitro::audioconcat::SilentData fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
47
|
-
jsi::Object obj = arg.asObject(runtime);
|
|
48
|
-
return margelo::nitro::audioconcat::SilentData(
|
|
49
|
-
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "durationMs"))
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::audioconcat::SilentData& arg) {
|
|
53
|
-
jsi::Object obj(runtime);
|
|
54
|
-
obj.setProperty(runtime, "durationMs", JSIConverter<double>::toJSI(runtime, arg.durationMs));
|
|
55
|
-
return obj;
|
|
56
|
-
}
|
|
57
|
-
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
58
|
-
if (!value.isObject()) {
|
|
59
|
-
return false;
|
|
60
|
-
}
|
|
61
|
-
jsi::Object obj = value.getObject(runtime);
|
|
62
|
-
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "durationMs"))) return false;
|
|
63
|
-
return true;
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
} // namespace margelo::nitro
|
package/src/AudioConcat.nitro.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { HybridObject } from 'react-native-nitro-modules';
|
|
2
|
-
|
|
3
|
-
type SilentData = {
|
|
4
|
-
durationMs: number;
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
type AudioData = {
|
|
8
|
-
filePath: string;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export type AudioDataOrSilence = AudioData | SilentData;
|
|
12
|
-
|
|
13
|
-
export interface AudioConcat
|
|
14
|
-
extends HybridObject<{ ios: 'swift'; android: 'kotlin' }> {
|
|
15
|
-
concatAudioFiles(
|
|
16
|
-
data: AudioDataOrSilence[],
|
|
17
|
-
outputPath: string
|
|
18
|
-
): Promise<string>;
|
|
19
|
-
}
|