react-native-audio-concat 0.2.3 → 0.3.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 (62) hide show
  1. package/AudioConcat.podspec +2 -21
  2. package/README.md +3 -7
  3. package/android/build.gradle +2 -54
  4. package/android/src/main/java/com/{margelo/nitro/audioconcat/AudioConcat.kt → audioconcat/AudioConcatModule.kt} +73 -31
  5. package/android/src/main/java/com/audioconcat/AudioConcatPackage.kt +33 -0
  6. package/ios/AudioConcat.h +5 -0
  7. package/ios/AudioConcat.mm +104 -0
  8. package/lib/module/NativeAudioConcat.js +5 -0
  9. package/lib/module/NativeAudioConcat.js.map +1 -0
  10. package/lib/module/index.js +2 -28
  11. package/lib/module/index.js.map +1 -1
  12. package/lib/typescript/src/NativeAudioConcat.d.ts +12 -0
  13. package/lib/typescript/src/NativeAudioConcat.d.ts.map +1 -0
  14. package/lib/typescript/src/index.d.ts +6 -27
  15. package/lib/typescript/src/index.d.ts.map +1 -1
  16. package/package.json +14 -18
  17. package/src/NativeAudioConcat.ts +12 -0
  18. package/src/index.tsx +4 -32
  19. package/android/CMakeLists.txt +0 -24
  20. package/android/src/main/cpp/cpp-adapter.cpp +0 -6
  21. package/android/src/main/java/com/margelo/nitro/audioconcat/AudioConcatPackage.kt +0 -22
  22. package/ios/AudioConcat.swift +0 -75
  23. package/lib/module/AudioConcat.nitro.js +0 -4
  24. package/lib/module/AudioConcat.nitro.js.map +0 -1
  25. package/lib/typescript/src/AudioConcat.nitro.d.ts +0 -16
  26. package/lib/typescript/src/AudioConcat.nitro.d.ts.map +0 -1
  27. package/nitro.json +0 -17
  28. package/nitrogen/generated/android/audioconcat+autolinking.cmake +0 -82
  29. package/nitrogen/generated/android/audioconcat+autolinking.gradle +0 -27
  30. package/nitrogen/generated/android/audioconcatOnLoad.cpp +0 -44
  31. package/nitrogen/generated/android/audioconcatOnLoad.hpp +0 -25
  32. package/nitrogen/generated/android/c++/JAudioData.hpp +0 -53
  33. package/nitrogen/generated/android/c++/JAudioDataOrSilence.cpp +0 -26
  34. package/nitrogen/generated/android/c++/JAudioDataOrSilence.hpp +0 -72
  35. package/nitrogen/generated/android/c++/JHybridAudioConcatSpec.cpp +0 -77
  36. package/nitrogen/generated/android/c++/JHybridAudioConcatSpec.hpp +0 -64
  37. package/nitrogen/generated/android/c++/JSilentData.hpp +0 -53
  38. package/nitrogen/generated/android/kotlin/com/margelo/nitro/audioconcat/AudioData.kt +0 -29
  39. package/nitrogen/generated/android/kotlin/com/margelo/nitro/audioconcat/AudioDataOrSilence.kt +0 -42
  40. package/nitrogen/generated/android/kotlin/com/margelo/nitro/audioconcat/HybridAudioConcatSpec.kt +0 -52
  41. package/nitrogen/generated/android/kotlin/com/margelo/nitro/audioconcat/SilentData.kt +0 -29
  42. package/nitrogen/generated/android/kotlin/com/margelo/nitro/audioconcat/audioconcatOnLoad.kt +0 -35
  43. package/nitrogen/generated/ios/AudioConcat+autolinking.rb +0 -60
  44. package/nitrogen/generated/ios/AudioConcat-Swift-Cxx-Bridge.cpp +0 -48
  45. package/nitrogen/generated/ios/AudioConcat-Swift-Cxx-Bridge.hpp +0 -160
  46. package/nitrogen/generated/ios/AudioConcat-Swift-Cxx-Umbrella.hpp +0 -53
  47. package/nitrogen/generated/ios/AudioConcatAutolinking.mm +0 -33
  48. package/nitrogen/generated/ios/AudioConcatAutolinking.swift +0 -25
  49. package/nitrogen/generated/ios/c++/HybridAudioConcatSpecSwift.cpp +0 -11
  50. package/nitrogen/generated/ios/c++/HybridAudioConcatSpecSwift.hpp +0 -81
  51. package/nitrogen/generated/ios/swift/AudioData.swift +0 -35
  52. package/nitrogen/generated/ios/swift/AudioDataOrSilence.swift +0 -18
  53. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +0 -47
  54. package/nitrogen/generated/ios/swift/Func_void_std__string.swift +0 -47
  55. package/nitrogen/generated/ios/swift/HybridAudioConcatSpec.swift +0 -49
  56. package/nitrogen/generated/ios/swift/HybridAudioConcatSpec_cxx.swift +0 -142
  57. package/nitrogen/generated/ios/swift/SilentData.swift +0 -35
  58. package/nitrogen/generated/shared/c++/AudioData.hpp +0 -67
  59. package/nitrogen/generated/shared/c++/HybridAudioConcatSpec.cpp +0 -21
  60. package/nitrogen/generated/shared/c++/HybridAudioConcatSpec.hpp +0 -70
  61. package/nitrogen/generated/shared/c++/SilentData.hpp +0 -67
  62. package/src/AudioConcat.nitro.ts +0 -19
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-audio-concat",
3
- "version": "0.2.3",
3
+ "version": "0.3.0",
4
4
  "description": "audio-concat for react-native",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
@@ -18,8 +18,6 @@
18
18
  "android",
19
19
  "ios",
20
20
  "cpp",
21
- "nitrogen",
22
- "nitro.json",
23
21
  "*.podspec",
24
22
  "react-native.config.js",
25
23
  "!ios/build",
@@ -40,8 +38,7 @@
40
38
  "lint": "eslint \"**/*.{js,ts,tsx}\"",
41
39
  "clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
42
40
  "prepare": "bob build",
43
- "release": "release-it --only-version",
44
- "nitrogen": "nitrogen"
41
+ "release": "release-it --only-version"
45
42
  },
46
43
  "keywords": [
47
44
  "react-native",
@@ -67,6 +64,7 @@
67
64
  "@eslint/eslintrc": "^3.3.1",
68
65
  "@eslint/js": "^9.35.0",
69
66
  "@evilmartians/lefthook": "^1.12.3",
67
+ "@react-native-community/cli": "20.0.1",
70
68
  "@react-native/babel-preset": "0.81.1",
71
69
  "@react-native/eslint-config": "^0.81.1",
72
70
  "@release-it/conventional-changelog": "^10.0.1",
@@ -78,20 +76,17 @@
78
76
  "eslint-config-prettier": "^10.1.8",
79
77
  "eslint-plugin-prettier": "^5.5.4",
80
78
  "jest": "^29.7.0",
81
- "nitrogen": "^0.29.8",
82
79
  "prettier": "^3.6.2",
83
80
  "react": "19.1.0",
84
81
  "react-native": "0.81.1",
85
82
  "react-native-builder-bob": "^0.40.13",
86
- "react-native-nitro-modules": "^0.29.8",
87
83
  "release-it": "^19.0.4",
88
84
  "turbo": "^2.5.6",
89
85
  "typescript": "^5.9.2"
90
86
  },
91
87
  "peerDependencies": {
92
88
  "react": "*",
93
- "react-native": "*",
94
- "react-native-nitro-modules": "^0.29.8"
89
+ "react-native": "*"
95
90
  },
96
91
  "workspaces": [
97
92
  "example"
@@ -139,13 +134,6 @@
139
134
  "source": "src",
140
135
  "output": "lib",
141
136
  "targets": [
142
- [
143
- "custom",
144
- {
145
- "script": "nitrogen",
146
- "clean": "nitrogen/"
147
- }
148
- ],
149
137
  [
150
138
  "module",
151
139
  {
@@ -160,9 +148,17 @@
160
148
  ]
161
149
  ]
162
150
  },
151
+ "codegenConfig": {
152
+ "name": "AudioConcatSpec",
153
+ "type": "modules",
154
+ "jsSrcsDir": "src",
155
+ "android": {
156
+ "javaPackageName": "com.audioconcat"
157
+ }
158
+ },
163
159
  "create-react-native-library": {
164
- "languages": "kotlin-swift",
165
- "type": "nitro-module",
160
+ "languages": "kotlin-objc",
161
+ "type": "turbo-module",
166
162
  "version": "0.54.5"
167
163
  }
168
164
  }
@@ -0,0 +1,12 @@
1
+ import { TurboModuleRegistry, type TurboModule } from 'react-native';
2
+
3
+ export type AudioDataOrSilence = { filePath: string } | { durationMs: number };
4
+
5
+ export interface Spec extends TurboModule {
6
+ concatAudioFiles(
7
+ data: AudioDataOrSilence[],
8
+ outputPath: string
9
+ ): Promise<string>;
10
+ }
11
+
12
+ export default TurboModuleRegistry.getEnforcing<Spec>('AudioConcat');
package/src/index.tsx CHANGED
@@ -1,38 +1,10 @@
1
- import { NitroModules } from 'react-native-nitro-modules';
2
- import type { AudioConcat, AudioDataOrSilence } from './AudioConcat.nitro';
1
+ import AudioConcat from './NativeAudioConcat';
3
2
 
4
- const AudioConcatHybridObject =
5
- NitroModules.createHybridObject<AudioConcat>('AudioConcat');
3
+ export type { AudioDataOrSilence } from './NativeAudioConcat';
6
4
 
7
- /**
8
- * Concat audio files and silence periods into a single output file.
9
- *
10
- * @param data - Array of audio files and silence periods to merge.
11
- * Each item can be either:
12
- * - `{ filePath: string }` for an audio file
13
- * - `{ durationMs: number }` for a silence period
14
- * @param outputPath - Absolute path where the merged audio file will be saved (M4A format)
15
- * @returns Promise that resolves with the output file path
16
- *
17
- * @example
18
- * ```typescript
19
- * const data = [
20
- * { filePath: '/path/to/audio1.m4a' },
21
- * { durationMs: 500 }, // 500ms silence
22
- * { filePath: '/path/to/audio2.m4a' },
23
- * { durationMs: 1000 }, // 1 second silence
24
- * { filePath: '/path/to/audio3.m4a' }
25
- * ];
26
- * const output = '/path/to/merged.m4a';
27
- * const result = await concatAudioFiles(data, output);
28
- * console.log('concat file:', result);
29
- * ```
30
- */
31
5
  export function concatAudioFiles(
32
- data: AudioDataOrSilence[],
6
+ data: Array<{ filePath: string } | { durationMs: number }>,
33
7
  outputPath: string
34
8
  ): Promise<string> {
35
- return AudioConcatHybridObject.concatAudioFiles(data, outputPath);
9
+ return AudioConcat.concatAudioFiles(data, outputPath);
36
10
  }
37
-
38
- export type { AudioDataOrSilence } from './AudioConcat.nitro';
@@ -1,24 +0,0 @@
1
- project(audioconcat)
2
- cmake_minimum_required(VERSION 3.9.0)
3
-
4
- set(PACKAGE_NAME audioconcat)
5
- set(CMAKE_VERBOSE_MAKEFILE ON)
6
- set(CMAKE_CXX_STANDARD 20)
7
-
8
- # Define C++ library and add all sources
9
- add_library(${PACKAGE_NAME} SHARED src/main/cpp/cpp-adapter.cpp)
10
-
11
- # Add Nitrogen specs :)
12
- include(${CMAKE_SOURCE_DIR}/../nitrogen/generated/android/audioconcat+autolinking.cmake)
13
-
14
- # Set up local includes
15
- include_directories("src/main/cpp" "../cpp")
16
-
17
- find_library(LOG_LIB log)
18
-
19
- # Link all libraries together
20
- target_link_libraries(
21
- ${PACKAGE_NAME}
22
- ${LOG_LIB}
23
- android # <-- Android core
24
- )
@@ -1,6 +0,0 @@
1
- #include <jni.h>
2
- #include "audioconcatOnLoad.hpp"
3
-
4
- JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) {
5
- return margelo::nitro::audioconcat::initialize(vm);
6
- }
@@ -1,22 +0,0 @@
1
- package com.margelo.nitro.audioconcat
2
-
3
- import com.facebook.react.TurboReactPackage
4
- import com.facebook.react.bridge.NativeModule
5
- import com.facebook.react.bridge.ReactApplicationContext
6
- import com.facebook.react.module.model.ReactModuleInfoProvider
7
-
8
- class AudioConcatPackage : TurboReactPackage() {
9
- override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
10
- return null
11
- }
12
-
13
- override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
14
- return ReactModuleInfoProvider { HashMap() }
15
- }
16
-
17
- companion object {
18
- init {
19
- System.loadLibrary("audioconcat")
20
- }
21
- }
22
- }
@@ -1,75 +0,0 @@
1
- import AVFoundation
2
- import NitroModules
3
-
4
- class AudioConcat: HybridAudioConcatSpec {
5
- public func concatAudioFiles(data: [AudioDataOrSilence], outputPath: String) throws -> Promise<String> {
6
- return Promise.async { [weak self] in
7
- guard !data.isEmpty else {
8
- throw NSError(domain: "AwesomeLibrary", code: 1, userInfo: [NSLocalizedDescriptionKey: "Data array is empty"])
9
- }
10
-
11
- let composition = AVMutableComposition()
12
- guard let audioTrack = composition.addMutableTrack(withMediaType: .audio, preferredTrackID: kCMPersistentTrackID_Invalid) else {
13
- throw NSError(domain: "AwesomeLibrary", code: 2, userInfo: [NSLocalizedDescriptionKey: "Failed to create audio track"])
14
- }
15
-
16
- var currentTime = CMTime.zero
17
-
18
- for (index, item) in data.enumerated() {
19
- switch item {
20
- case .first(let audioData):
21
- // Audio file
22
- let filePath = audioData.filePath
23
- let fileURL = URL(fileURLWithPath: filePath)
24
- let asset = AVAsset(url: fileURL)
25
-
26
- guard let sourceTrack = asset.tracks(withMediaType: .audio).first else {
27
- throw NSError(domain: "AwesomeLibrary", code: 3, userInfo: [NSLocalizedDescriptionKey: "No audio track found in \(filePath)"])
28
- }
29
-
30
- let duration = asset.duration
31
- let timeRange = CMTimeRange(start: .zero, duration: duration)
32
-
33
- try audioTrack.insertTimeRange(timeRange, of: sourceTrack, at: currentTime)
34
- currentTime = CMTimeAdd(currentTime, duration)
35
-
36
- case .second(let silentData):
37
- // Silence
38
- let durationMs = silentData.durationMs
39
- let silenceDuration = CMTime(seconds: durationMs / 1000.0, preferredTimescale: 600)
40
-
41
- // In AVMutableComposition, leaving a gap (not inserting anything)
42
- // automatically creates silence
43
- currentTime = CMTimeAdd(currentTime, silenceDuration)
44
- }
45
- }
46
-
47
- let outputURL = URL(fileURLWithPath: outputPath)
48
-
49
- // Remove existing file if present
50
- try? FileManager.default.removeItem(at: outputURL)
51
-
52
- guard let exportSession = AVAssetExportSession(asset: composition, presetName: AVAssetExportPresetAppleM4A) else {
53
- throw NSError(domain: "AwesomeLibrary", code: 4, userInfo: [NSLocalizedDescriptionKey: "Failed to create export session"])
54
- }
55
-
56
- exportSession.outputURL = outputURL
57
- exportSession.outputFileType = .m4a
58
-
59
- return try await withCheckedThrowingContinuation { continuation in
60
- exportSession.exportAsynchronously {
61
- switch exportSession.status {
62
- case .completed:
63
- continuation.resume(returning: outputPath)
64
- case .failed:
65
- continuation.resume(throwing: exportSession.error ?? NSError(domain: "AwesomeLibrary", code: 5, userInfo: [NSLocalizedDescriptionKey: "Export failed"]))
66
- case .cancelled:
67
- continuation.resume(throwing: NSError(domain: "AwesomeLibrary", code: 6, userInfo: [NSLocalizedDescriptionKey: "Export cancelled"]))
68
- default:
69
- continuation.resume(throwing: NSError(domain: "AwesomeLibrary", code: 7, userInfo: [NSLocalizedDescriptionKey: "Unknown export status"]))
70
- }
71
- }
72
- }
73
- }
74
- }
75
- }
@@ -1,4 +0,0 @@
1
- "use strict";
2
-
3
- export {};
4
- //# sourceMappingURL=AudioConcat.nitro.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sourceRoot":"../../src","sources":["AudioConcat.nitro.ts"],"mappings":"","ignoreList":[]}
@@ -1,16 +0,0 @@
1
- import type { HybridObject } from 'react-native-nitro-modules';
2
- type SilentData = {
3
- durationMs: number;
4
- };
5
- type AudioData = {
6
- filePath: string;
7
- };
8
- export type AudioDataOrSilence = AudioData | SilentData;
9
- export interface AudioConcat extends HybridObject<{
10
- ios: 'swift';
11
- android: 'kotlin';
12
- }> {
13
- concatAudioFiles(data: AudioDataOrSilence[], outputPath: string): Promise<string>;
14
- }
15
- export {};
16
- //# sourceMappingURL=AudioConcat.nitro.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AudioConcat.nitro.d.ts","sourceRoot":"","sources":["../../../src/AudioConcat.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE/D,KAAK,UAAU,GAAG;IAChB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,KAAK,SAAS,GAAG;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,UAAU,CAAC;AAExD,MAAM,WAAW,WACf,SAAQ,YAAY,CAAC;IAAE,GAAG,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,QAAQ,CAAA;CAAE,CAAC;IACzD,gBAAgB,CACd,IAAI,EAAE,kBAAkB,EAAE,EAC1B,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,MAAM,CAAC,CAAC;CACpB"}
package/nitro.json DELETED
@@ -1,17 +0,0 @@
1
- {
2
- "cxxNamespace": ["audioconcat"],
3
- "ios": {
4
- "iosModuleName": "AudioConcat"
5
- },
6
- "android": {
7
- "androidNamespace": ["audioconcat"],
8
- "androidCxxLibName": "audioconcat"
9
- },
10
- "autolinking": {
11
- "AudioConcat": {
12
- "swift": "AudioConcat",
13
- "kotlin": "AudioConcat"
14
- }
15
- },
16
- "ignorePaths": ["node_modules"]
17
- }
@@ -1,82 +0,0 @@
1
- #
2
- # audioconcat+autolinking.cmake
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
- # This is a CMake file that adds all files generated by Nitrogen
9
- # to the current CMake project.
10
- #
11
- # To use it, add this to your CMakeLists.txt:
12
- # ```cmake
13
- # include(${CMAKE_SOURCE_DIR}/../nitrogen/generated/android/audioconcat+autolinking.cmake)
14
- # ```
15
-
16
- # Define a flag to check if we are building properly
17
- add_definitions(-DBUILDING_AUDIOCONCAT_WITH_GENERATED_CMAKE_PROJECT)
18
-
19
- # Enable Raw Props parsing in react-native (for Nitro Views)
20
- add_definitions(-DRN_SERIALIZABLE_STATE)
21
-
22
- # Add all headers that were generated by Nitrogen
23
- include_directories(
24
- "../nitrogen/generated/shared/c++"
25
- "../nitrogen/generated/android/c++"
26
- "../nitrogen/generated/android/"
27
- )
28
-
29
- # Add all .cpp sources that were generated by Nitrogen
30
- target_sources(
31
- # CMake project name (Android C++ library name)
32
- audioconcat PRIVATE
33
- # Autolinking Setup
34
- ../nitrogen/generated/android/audioconcatOnLoad.cpp
35
- # Shared Nitrogen C++ sources
36
- ../nitrogen/generated/shared/c++/HybridAudioConcatSpec.cpp
37
- # Android-specific Nitrogen C++ sources
38
- ../nitrogen/generated/android/c++/JHybridAudioConcatSpec.cpp
39
- ../nitrogen/generated/android/c++/JAudioDataOrSilence.cpp
40
- )
41
-
42
- # From node_modules/react-native/ReactAndroid/cmake-utils/folly-flags.cmake
43
- # Used in node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake
44
- target_compile_definitions(
45
- audioconcat PRIVATE
46
- -DFOLLY_NO_CONFIG=1
47
- -DFOLLY_HAVE_CLOCK_GETTIME=1
48
- -DFOLLY_USE_LIBCPP=1
49
- -DFOLLY_CFG_NO_COROUTINES=1
50
- -DFOLLY_MOBILE=1
51
- -DFOLLY_HAVE_RECVMMSG=1
52
- -DFOLLY_HAVE_PTHREAD=1
53
- # Once we target android-23 above, we can comment
54
- # the following line. NDK uses GNU style stderror_r() after API 23.
55
- -DFOLLY_HAVE_XSI_STRERROR_R=1
56
- )
57
-
58
- # Add all libraries required by the generated specs
59
- find_package(fbjni REQUIRED) # <-- Used for communication between Java <-> C++
60
- find_package(ReactAndroid REQUIRED) # <-- Used to set up React Native bindings (e.g. CallInvoker/TurboModule)
61
- find_package(react-native-nitro-modules REQUIRED) # <-- Used to create all HybridObjects and use the Nitro core library
62
-
63
- # Link all libraries together
64
- target_link_libraries(
65
- audioconcat
66
- fbjni::fbjni # <-- Facebook C++ JNI helpers
67
- ReactAndroid::jsi # <-- RN: JSI
68
- react-native-nitro-modules::NitroModules # <-- NitroModules Core :)
69
- )
70
-
71
- # Link react-native (different prefab between RN 0.75 and RN 0.76)
72
- if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
73
- target_link_libraries(
74
- audioconcat
75
- ReactAndroid::reactnative # <-- RN: Native Modules umbrella prefab
76
- )
77
- else()
78
- target_link_libraries(
79
- audioconcat
80
- ReactAndroid::react_nativemodule_core # <-- RN: TurboModules Core
81
- )
82
- endif()
@@ -1,27 +0,0 @@
1
- ///
2
- /// audioconcat+autolinking.gradle
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
- /// This is a Gradle file that adds all files generated by Nitrogen
9
- /// to the current Gradle project.
10
- ///
11
- /// To use it, add this to your build.gradle:
12
- /// ```gradle
13
- /// apply from: '../nitrogen/generated/android/audioconcat+autolinking.gradle'
14
- /// ```
15
-
16
- logger.warn("[NitroModules] 🔥 audioconcat is boosted by nitro!")
17
-
18
- android {
19
- sourceSets {
20
- main {
21
- java.srcDirs += [
22
- // Nitrogen files
23
- "${project.projectDir}/../nitrogen/generated/android/kotlin"
24
- ]
25
- }
26
- }
27
- }
@@ -1,44 +0,0 @@
1
- ///
2
- /// audioconcatOnLoad.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
- #ifndef BUILDING_AUDIOCONCAT_WITH_GENERATED_CMAKE_PROJECT
9
- #error audioconcatOnLoad.cpp is not being built with the autogenerated CMakeLists.txt project. Is a different CMakeLists.txt building this?
10
- #endif
11
-
12
- #include "audioconcatOnLoad.hpp"
13
-
14
- #include <jni.h>
15
- #include <fbjni/fbjni.h>
16
- #include <NitroModules/HybridObjectRegistry.hpp>
17
-
18
- #include "JHybridAudioConcatSpec.hpp"
19
- #include <NitroModules/DefaultConstructableObject.hpp>
20
-
21
- namespace margelo::nitro::audioconcat {
22
-
23
- int initialize(JavaVM* vm) {
24
- using namespace margelo::nitro;
25
- using namespace margelo::nitro::audioconcat;
26
- using namespace facebook;
27
-
28
- return facebook::jni::initialize(vm, [] {
29
- // Register native JNI methods
30
- margelo::nitro::audioconcat::JHybridAudioConcatSpec::registerNatives();
31
-
32
- // Register Nitro Hybrid Objects
33
- HybridObjectRegistry::registerHybridObjectConstructor(
34
- "AudioConcat",
35
- []() -> std::shared_ptr<HybridObject> {
36
- static DefaultConstructableObject<JHybridAudioConcatSpec::javaobject> object("com/margelo/nitro/audioconcat/AudioConcat");
37
- auto instance = object.create();
38
- return instance->cthis()->shared();
39
- }
40
- );
41
- });
42
- }
43
-
44
- } // namespace margelo::nitro::audioconcat
@@ -1,25 +0,0 @@
1
- ///
2
- /// audioconcatOnLoad.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
- #include <jni.h>
9
- #include <NitroModules/NitroDefines.hpp>
10
-
11
- namespace margelo::nitro::audioconcat {
12
-
13
- /**
14
- * Initializes the native (C++) part of audioconcat, and autolinks all Hybrid Objects.
15
- * Call this in your `JNI_OnLoad` function (probably inside `cpp-adapter.cpp`).
16
- * Example:
17
- * ```cpp (cpp-adapter.cpp)
18
- * JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) {
19
- * return margelo::nitro::audioconcat::initialize(vm);
20
- * }
21
- * ```
22
- */
23
- int initialize(JavaVM* vm);
24
-
25
- } // namespace margelo::nitro::audioconcat
@@ -1,53 +0,0 @@
1
- ///
2
- /// JAudioData.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
- #include <fbjni/fbjni.h>
11
- #include "AudioData.hpp"
12
-
13
- #include <string>
14
-
15
- namespace margelo::nitro::audioconcat {
16
-
17
- using namespace facebook;
18
-
19
- /**
20
- * The C++ JNI bridge between the C++ struct "AudioData" and the the Kotlin data class "AudioData".
21
- */
22
- struct JAudioData final: public jni::JavaClass<JAudioData> {
23
- public:
24
- static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/audioconcat/AudioData;";
25
-
26
- public:
27
- /**
28
- * Convert this Java/Kotlin-based struct to the C++ struct AudioData by copying all values to C++.
29
- */
30
- [[maybe_unused]]
31
- [[nodiscard]]
32
- AudioData toCpp() const {
33
- static const auto clazz = javaClassStatic();
34
- static const auto fieldFilePath = clazz->getField<jni::JString>("filePath");
35
- jni::local_ref<jni::JString> filePath = this->getFieldValue(fieldFilePath);
36
- return AudioData(
37
- filePath->toStdString()
38
- );
39
- }
40
-
41
- public:
42
- /**
43
- * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
44
- */
45
- [[maybe_unused]]
46
- static jni::local_ref<JAudioData::javaobject> fromCpp(const AudioData& value) {
47
- return newInstance(
48
- jni::make_jstring(value.filePath)
49
- );
50
- }
51
- };
52
-
53
- } // namespace margelo::nitro::audioconcat
@@ -1,26 +0,0 @@
1
- ///
2
- /// JAudioDataOrSilence.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 "JAudioDataOrSilence.hpp"
9
-
10
- namespace margelo::nitro::audioconcat {
11
- /**
12
- * Converts JAudioDataOrSilence to std::variant<AudioData, SilentData>
13
- */
14
- std::variant<AudioData, SilentData> JAudioDataOrSilence::toCpp() const {
15
- if (isInstanceOf(JAudioDataOrSilence_impl::First::javaClassStatic())) {
16
- // It's a `AudioData`
17
- auto jniValue = static_cast<const JAudioDataOrSilence_impl::First*>(this)->getValue();
18
- return jniValue->toCpp();
19
- } else if (isInstanceOf(JAudioDataOrSilence_impl::Second::javaClassStatic())) {
20
- // It's a `SilentData`
21
- auto jniValue = static_cast<const JAudioDataOrSilence_impl::Second*>(this)->getValue();
22
- return jniValue->toCpp();
23
- }
24
- throw std::invalid_argument("Variant is unknown Kotlin instance!");
25
- }
26
- } // namespace margelo::nitro::audioconcat
@@ -1,72 +0,0 @@
1
- ///
2
- /// JAudioDataOrSilence.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
- #include <fbjni/fbjni.h>
11
- #include <variant>
12
-
13
- #include "AudioData.hpp"
14
- #include "SilentData.hpp"
15
- #include <variant>
16
- #include "JAudioData.hpp"
17
- #include <string>
18
- #include "JSilentData.hpp"
19
-
20
- namespace margelo::nitro::audioconcat {
21
-
22
- using namespace facebook;
23
-
24
- /**
25
- * The C++ JNI bridge between the C++ std::variant and the Java class "AudioDataOrSilence".
26
- */
27
- class JAudioDataOrSilence: public jni::JavaClass<JAudioDataOrSilence> {
28
- public:
29
- static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/audioconcat/AudioDataOrSilence;";
30
-
31
- static jni::local_ref<JAudioDataOrSilence> create_0(jni::alias_ref<JAudioData> value) {
32
- static const auto method = javaClassStatic()->getStaticMethod<JAudioDataOrSilence(jni::alias_ref<JAudioData>)>("create");
33
- return method(javaClassStatic(), value);
34
- }
35
- static jni::local_ref<JAudioDataOrSilence> create_1(jni::alias_ref<JSilentData> value) {
36
- static const auto method = javaClassStatic()->getStaticMethod<JAudioDataOrSilence(jni::alias_ref<JSilentData>)>("create");
37
- return method(javaClassStatic(), value);
38
- }
39
-
40
- static jni::local_ref<JAudioDataOrSilence> fromCpp(const std::variant<AudioData, SilentData>& variant) {
41
- switch (variant.index()) {
42
- case 0: return create_0(JAudioData::fromCpp(std::get<0>(variant)));
43
- case 1: return create_1(JSilentData::fromCpp(std::get<1>(variant)));
44
- default: throw std::invalid_argument("Variant holds unknown index! (" + std::to_string(variant.index()) + ")");
45
- }
46
- }
47
-
48
- [[nodiscard]] std::variant<AudioData, SilentData> toCpp() const;
49
- };
50
-
51
- namespace JAudioDataOrSilence_impl {
52
- class First: public jni::JavaClass<First, JAudioDataOrSilence> {
53
- public:
54
- static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/audioconcat/AudioDataOrSilence$First;";
55
-
56
- [[nodiscard]] jni::local_ref<JAudioData> getValue() const {
57
- static const auto field = javaClassStatic()->getField<JAudioData>("value");
58
- return getFieldValue(field);
59
- }
60
- };
61
-
62
- class Second: public jni::JavaClass<Second, JAudioDataOrSilence> {
63
- public:
64
- static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/audioconcat/AudioDataOrSilence$Second;";
65
-
66
- [[nodiscard]] jni::local_ref<JSilentData> getValue() const {
67
- static const auto field = javaClassStatic()->getField<JSilentData>("value");
68
- return getFieldValue(field);
69
- }
70
- };
71
- } // namespace JAudioDataOrSilence_impl
72
- } // namespace margelo::nitro::audioconcat