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,141 @@
1
+ package com.margelo.nitro.munimffmpeg
2
+
3
+ import androidx.annotation.Keep
4
+ import com.arthenica.ffmpegkit.FFmpegKit
5
+ import com.arthenica.ffmpegkit.FFmpegKitConfig
6
+ import com.arthenica.ffmpegkit.FFprobeKit
7
+ import com.arthenica.ffmpegkit.ReturnCode
8
+ import com.arthenica.ffmpegkit.Session
9
+ import com.facebook.proguard.annotations.DoNotStrip
10
+ import com.margelo.nitro.core.Promise
11
+
12
+ @Keep
13
+ @DoNotStrip
14
+ class HybridMunimFfmpeg : HybridMunimFfmpegSpec() {
15
+ override val ffmpegVersion: String
16
+ get() = FFmpegKitConfig.getFFmpegVersion()
17
+
18
+ override fun execute(
19
+ arguments_: Array<String>,
20
+ onLog: ((message: String) -> Unit)?,
21
+ onStatistics: ((
22
+ timeMs: Double,
23
+ sizeBytes: Double,
24
+ bitrateKbits: Double,
25
+ speed: Double,
26
+ videoFrameNumber: Double,
27
+ fps: Double,
28
+ quality: Double,
29
+ ) -> Unit)?,
30
+ onSessionCreated: ((sessionId: Double) -> Unit)?,
31
+ ): Promise<FFmpegSessionResult> {
32
+ val promise = Promise<FFmpegSessionResult>()
33
+
34
+ try {
35
+ val session = FFmpegKit.executeWithArgumentsAsync(
36
+ arguments_,
37
+ { session -> promise.resolve(session.toResult()) },
38
+ { log -> onLog?.invoke(log.message) },
39
+ { statistics ->
40
+ onStatistics?.invoke(
41
+ statistics.time,
42
+ statistics.size.toDouble(),
43
+ statistics.bitrate,
44
+ statistics.speed,
45
+ statistics.videoFrameNumber.toDouble(),
46
+ statistics.videoFps,
47
+ statistics.videoQuality,
48
+ )
49
+ },
50
+ )
51
+ onSessionCreated?.invoke(session.sessionId.toDouble())
52
+ } catch (error: Throwable) {
53
+ promise.reject(error)
54
+ }
55
+
56
+ return promise
57
+ }
58
+
59
+ override fun probe(
60
+ arguments_: Array<String>,
61
+ onLog: ((message: String) -> Unit)?,
62
+ onSessionCreated: ((sessionId: Double) -> Unit)?,
63
+ ): Promise<FFmpegSessionResult> {
64
+ val promise = Promise<FFmpegSessionResult>()
65
+
66
+ try {
67
+ val session = FFprobeKit.executeWithArgumentsAsync(
68
+ arguments_,
69
+ { session -> promise.resolve(session.toResult()) },
70
+ { log -> onLog?.invoke(log.message) },
71
+ )
72
+ onSessionCreated?.invoke(session.sessionId.toDouble())
73
+ } catch (error: Throwable) {
74
+ promise.reject(error)
75
+ }
76
+
77
+ return promise
78
+ }
79
+
80
+ override fun getMediaInformation(path: String): Promise<String> {
81
+ return Promise.async {
82
+ val session = FFprobeKit.executeWithArguments(
83
+ arrayOf(
84
+ "-v",
85
+ "error",
86
+ "-print_format",
87
+ "json",
88
+ "-show_format",
89
+ "-show_streams",
90
+ "-show_chapters",
91
+ path,
92
+ ),
93
+ )
94
+ val returnCode = session.returnCode
95
+
96
+ if (!ReturnCode.isSuccess(returnCode)) {
97
+ throw IllegalStateException(
98
+ session.failStackTrace ?: session.output.ifEmpty {
99
+ "FFprobe failed with return code ${returnCode?.value ?: -1}"
100
+ },
101
+ )
102
+ }
103
+
104
+ session.output
105
+ }
106
+ }
107
+
108
+ override fun cancel(sessionId: Double?) {
109
+ if (sessionId == null) {
110
+ FFmpegKit.cancel()
111
+ } else {
112
+ require(
113
+ sessionId.isFinite() &&
114
+ sessionId > 0 &&
115
+ sessionId % 1.0 == 0.0 &&
116
+ sessionId <= 9_007_199_254_740_991.0,
117
+ ) {
118
+ "Invalid FFmpeg session ID: $sessionId. Expected a positive safe integer."
119
+ }
120
+ FFmpegKit.cancel(sessionId.toLong())
121
+ }
122
+ }
123
+
124
+ override fun cancelAll() {
125
+ FFmpegKit.cancel()
126
+ }
127
+
128
+ private fun Session.toResult(): FFmpegSessionResult {
129
+ val code = returnCode
130
+ return FFmpegSessionResult(
131
+ sessionId = sessionId.toDouble(),
132
+ returnCode = (code?.value ?: -1).toDouble(),
133
+ success = ReturnCode.isSuccess(code),
134
+ cancelled = ReturnCode.isCancel(code),
135
+ state = state.name.lowercase(),
136
+ durationMs = duration.toDouble(),
137
+ output = output,
138
+ failStackTrace = failStackTrace,
139
+ )
140
+ }
141
+ }
@@ -0,0 +1,18 @@
1
+ package com.margelo.nitro.munimffmpeg
2
+
3
+ import com.facebook.react.bridge.NativeModule
4
+ import com.facebook.react.bridge.ReactApplicationContext
5
+ import com.facebook.react.module.model.ReactModuleInfoProvider
6
+ import com.facebook.react.BaseReactPackage
7
+
8
+ class NitroMunimFfmpegPackage : BaseReactPackage() {
9
+ override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? = null
10
+
11
+ override fun getReactModuleInfoProvider(): ReactModuleInfoProvider = ReactModuleInfoProvider { HashMap() }
12
+
13
+ companion object {
14
+ init {
15
+ NitroMunimFfmpegOnLoad.initializeNative()
16
+ }
17
+ }
18
+ }
package/app.plugin.js ADDED
@@ -0,0 +1,5 @@
1
+ module.exports = function withMunimFfmpeg(config) {
2
+ return config
3
+ }
4
+
5
+ module.exports.default = module.exports
package/ios/Bridge.h ADDED
@@ -0,0 +1,8 @@
1
+ //
2
+ // Bridge.h
3
+ // NitroMunimFfmpeg
4
+ //
5
+ // Created by Marc Rousavy on 22.07.24.
6
+ //
7
+
8
+ #pragma once
@@ -0,0 +1,161 @@
1
+ import NitroModules
2
+ import ffmpegkit
3
+
4
+ final class HybridMunimFfmpeg: HybridMunimFfmpegSpec {
5
+ var ffmpegVersion: String {
6
+ FFmpegKitConfig.getFFmpegVersion()
7
+ }
8
+
9
+ func execute(
10
+ arguments_: [String],
11
+ onLog: ((_ message: String) -> Void)?,
12
+ onStatistics: ((_ timeMs: Double, _ sizeBytes: Double, _ bitrateKbits: Double, _ speed: Double, _ videoFrameNumber: Double, _ fps: Double, _ quality: Double) -> Void)?,
13
+ onSessionCreated: ((_ sessionId: Double) -> Void)?
14
+ ) throws -> Promise<FFmpegSessionResult> {
15
+ let promise = Promise<FFmpegSessionResult>()
16
+
17
+ let session = FFmpegKit.execute(
18
+ withArgumentsAsync: arguments_,
19
+ withCompleteCallback: { session in
20
+ guard let session else {
21
+ promise.reject(withError: MunimFfmpegError.missingSession)
22
+ return
23
+ }
24
+ promise.resolve(withResult: Self.result(from: session))
25
+ },
26
+ withLogCallback: { log in
27
+ guard let message = log?.getMessage() else { return }
28
+ onLog?(message)
29
+ },
30
+ withStatisticsCallback: { statistics in
31
+ guard let statistics else { return }
32
+ onStatistics?(
33
+ statistics.getTime(),
34
+ Double(statistics.getSize()),
35
+ statistics.getBitrate(),
36
+ statistics.getSpeed(),
37
+ Double(statistics.getVideoFrameNumber()),
38
+ Double(statistics.getVideoFps()),
39
+ Double(statistics.getVideoQuality())
40
+ )
41
+ }
42
+ )
43
+ if let session {
44
+ onSessionCreated?(Double(session.getId()))
45
+ }
46
+
47
+ return promise
48
+ }
49
+
50
+ func probe(
51
+ arguments_: [String],
52
+ onLog: ((_ message: String) -> Void)?,
53
+ onSessionCreated: ((_ sessionId: Double) -> Void)?
54
+ ) throws -> Promise<FFmpegSessionResult> {
55
+ let promise = Promise<FFmpegSessionResult>()
56
+
57
+ let session = FFprobeKit.execute(
58
+ withArgumentsAsync: arguments_,
59
+ withCompleteCallback: { session in
60
+ guard let session else {
61
+ promise.reject(withError: MunimFfmpegError.missingSession)
62
+ return
63
+ }
64
+ promise.resolve(withResult: Self.result(from: session))
65
+ },
66
+ withLogCallback: { log in
67
+ guard let message = log?.getMessage() else { return }
68
+ onLog?(message)
69
+ }
70
+ )
71
+ if let session {
72
+ onSessionCreated?(Double(session.getId()))
73
+ }
74
+
75
+ return promise
76
+ }
77
+
78
+ func getMediaInformation(path: String) throws -> Promise<String> {
79
+ let promise = Promise<String>()
80
+ let arguments = [
81
+ "-v",
82
+ "error",
83
+ "-print_format",
84
+ "json",
85
+ "-show_format",
86
+ "-show_streams",
87
+ "-show_chapters",
88
+ path,
89
+ ]
90
+
91
+ FFprobeKit.execute(
92
+ withArgumentsAsync: arguments,
93
+ withCompleteCallback: { session in
94
+ guard let session else {
95
+ promise.reject(withError: MunimFfmpegError.missingSession)
96
+ return
97
+ }
98
+ let returnCode = session.getReturnCode()
99
+ guard ReturnCode.isSuccess(returnCode) else {
100
+ let message = session.getFailStackTrace() ?? session.getOutput() ?? "FFprobe failed"
101
+ promise.reject(withError: MunimFfmpegError.executionFailed(message))
102
+ return
103
+ }
104
+ promise.resolve(withResult: session.getOutput() ?? "{}")
105
+ }
106
+ )
107
+
108
+ return promise
109
+ }
110
+
111
+ func cancel(sessionId: Double?) throws {
112
+ if let sessionId {
113
+ guard
114
+ sessionId.isFinite,
115
+ sessionId > 0,
116
+ sessionId.rounded(.towardZero) == sessionId,
117
+ sessionId <= 9_007_199_254_740_991
118
+ else {
119
+ throw MunimFfmpegError.invalidSessionId(sessionId)
120
+ }
121
+ FFmpegKit.cancel(Int(sessionId))
122
+ } else {
123
+ FFmpegKit.cancel()
124
+ }
125
+ }
126
+
127
+ func cancelAll() throws {
128
+ FFmpegKit.cancel()
129
+ }
130
+
131
+ private static func result(from session: Session) -> FFmpegSessionResult {
132
+ let returnCode = session.getReturnCode()
133
+ return FFmpegSessionResult(
134
+ sessionId: Double(session.getId()),
135
+ returnCode: Double(returnCode?.getValue() ?? -1),
136
+ success: ReturnCode.isSuccess(returnCode),
137
+ cancelled: ReturnCode.isCancel(returnCode),
138
+ state: String(describing: session.getState()).lowercased(),
139
+ durationMs: Double(session.getDuration()),
140
+ output: session.getOutput() ?? "",
141
+ failStackTrace: session.getFailStackTrace()
142
+ )
143
+ }
144
+ }
145
+
146
+ private enum MunimFfmpegError: LocalizedError {
147
+ case missingSession
148
+ case executionFailed(String)
149
+ case invalidSessionId(Double)
150
+
151
+ var errorDescription: String? {
152
+ switch self {
153
+ case .missingSession:
154
+ return "FFmpegKit did not return a session."
155
+ case .executionFailed(let message):
156
+ return message
157
+ case .invalidSessionId(let sessionId):
158
+ return "Invalid FFmpeg session ID: \(sessionId). Expected a positive safe integer."
159
+ }
160
+ }
161
+ }
package/lib/index.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ import type { FFmpegLogCallback, FFmpegSessionResult, FFmpegSessionCreatedCallback, FFmpegStatisticsCallback, MunimFfmpeg as MunimFfmpegSpec } from './specs/MunimFfmpeg.nitro';
2
+ declare const MunimFfmpeg: MunimFfmpegSpec;
3
+ export type { FFmpegLogCallback, FFmpegSessionResult, FFmpegSessionCreatedCallback, FFmpegStatisticsCallback, MunimFfmpegSpec, };
4
+ export declare function execute(arguments_: string[], onLog?: FFmpegLogCallback, onStatistics?: FFmpegStatisticsCallback, onSessionCreated?: FFmpegSessionCreatedCallback): Promise<FFmpegSessionResult>;
5
+ export declare function probe(arguments_: string[], onLog?: FFmpegLogCallback, onSessionCreated?: FFmpegSessionCreatedCallback): Promise<FFmpegSessionResult>;
6
+ export declare function getMediaInformation(path: string): Promise<unknown>;
7
+ export declare function cancel(sessionId?: number): void;
8
+ export declare function cancelAll(): void;
9
+ export declare function getFFmpegVersion(): string;
10
+ export default MunimFfmpeg;
package/lib/index.js ADDED
@@ -0,0 +1,21 @@
1
+ import { NitroModules } from 'react-native-nitro-modules';
2
+ const MunimFfmpeg = NitroModules.createHybridObject('MunimFfmpeg');
3
+ export function execute(arguments_, onLog, onStatistics, onSessionCreated) {
4
+ return MunimFfmpeg.execute(arguments_, onLog, onStatistics, onSessionCreated);
5
+ }
6
+ export function probe(arguments_, onLog, onSessionCreated) {
7
+ return MunimFfmpeg.probe(arguments_, onLog, onSessionCreated);
8
+ }
9
+ export function getMediaInformation(path) {
10
+ return MunimFfmpeg.getMediaInformation(path).then((value) => JSON.parse(value));
11
+ }
12
+ export function cancel(sessionId) {
13
+ MunimFfmpeg.cancel(sessionId);
14
+ }
15
+ export function cancelAll() {
16
+ MunimFfmpeg.cancelAll();
17
+ }
18
+ export function getFFmpegVersion() {
19
+ return MunimFfmpeg.ffmpegVersion;
20
+ }
21
+ export default MunimFfmpeg;
@@ -0,0 +1,25 @@
1
+ import type { HybridObject } from 'react-native-nitro-modules';
2
+ export type FFmpegSessionResult = {
3
+ sessionId: number;
4
+ returnCode: number;
5
+ success: boolean;
6
+ cancelled: boolean;
7
+ state: string;
8
+ durationMs: number;
9
+ output: string;
10
+ failStackTrace?: string;
11
+ };
12
+ export type FFmpegLogCallback = (message: string) => void;
13
+ export type FFmpegSessionCreatedCallback = (sessionId: number) => void;
14
+ export type FFmpegStatisticsCallback = (timeMs: number, sizeBytes: number, bitrateKbits: number, speed: number, videoFrameNumber: number, fps: number, quality: number) => void;
15
+ export interface MunimFfmpeg extends HybridObject<{
16
+ ios: 'swift';
17
+ android: 'kotlin';
18
+ }> {
19
+ readonly ffmpegVersion: string;
20
+ execute(arguments_: string[], onLog?: FFmpegLogCallback, onStatistics?: FFmpegStatisticsCallback, onSessionCreated?: FFmpegSessionCreatedCallback): Promise<FFmpegSessionResult>;
21
+ probe(arguments_: string[], onLog?: FFmpegLogCallback, onSessionCreated?: FFmpegSessionCreatedCallback): Promise<FFmpegSessionResult>;
22
+ getMediaInformation(path: string): Promise<string>;
23
+ cancel(sessionId?: number): void;
24
+ cancelAll(): void;
25
+ }
@@ -0,0 +1 @@
1
+ export {};
package/nitro.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "$schema": "https://nitro.margelo.com/nitro.schema.json",
3
+ "cxxNamespace": [
4
+ "munimffmpeg"
5
+ ],
6
+ "ios": {
7
+ "iosModuleName": "NitroMunimFfmpeg"
8
+ },
9
+ "android": {
10
+ "androidNamespace": [
11
+ "munimffmpeg"
12
+ ],
13
+ "androidCxxLibName": "NitroMunimFfmpeg"
14
+ },
15
+ "autolinking": {
16
+ "MunimFfmpeg": {
17
+ "ios": {
18
+ "language": "swift",
19
+ "implementationClassName": "HybridMunimFfmpeg"
20
+ },
21
+ "android": {
22
+ "language": "kotlin",
23
+ "implementationClassName": "HybridMunimFfmpeg"
24
+ }
25
+ }
26
+ },
27
+ "ignorePaths": [
28
+ "**/node_modules"
29
+ ]
30
+ }
@@ -0,0 +1 @@
1
+ ** linguist-generated=true
@@ -0,0 +1,81 @@
1
+ #
2
+ # NitroMunimFfmpeg+autolinking.cmake
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
+ # 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/NitroMunimFfmpeg+autolinking.cmake)
14
+ # ```
15
+
16
+ # Define a flag to check if we are building properly
17
+ add_definitions(-DBUILDING_NITROMUNIMFFMPEG_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
+ NitroMunimFfmpeg PRIVATE
33
+ # Autolinking Setup
34
+ ../nitrogen/generated/android/NitroMunimFfmpegOnLoad.cpp
35
+ # Shared Nitrogen C++ sources
36
+ ../nitrogen/generated/shared/c++/HybridMunimFfmpegSpec.cpp
37
+ # Android-specific Nitrogen C++ sources
38
+ ../nitrogen/generated/android/c++/JHybridMunimFfmpegSpec.cpp
39
+ )
40
+
41
+ # From node_modules/react-native/ReactAndroid/cmake-utils/folly-flags.cmake
42
+ # Used in node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake
43
+ target_compile_definitions(
44
+ NitroMunimFfmpeg PRIVATE
45
+ -DFOLLY_NO_CONFIG=1
46
+ -DFOLLY_HAVE_CLOCK_GETTIME=1
47
+ -DFOLLY_USE_LIBCPP=1
48
+ -DFOLLY_CFG_NO_COROUTINES=1
49
+ -DFOLLY_MOBILE=1
50
+ -DFOLLY_HAVE_RECVMMSG=1
51
+ -DFOLLY_HAVE_PTHREAD=1
52
+ # Once we target android-23 above, we can comment
53
+ # the following line. NDK uses GNU style stderror_r() after API 23.
54
+ -DFOLLY_HAVE_XSI_STRERROR_R=1
55
+ )
56
+
57
+ # Add all libraries required by the generated specs
58
+ find_package(fbjni REQUIRED) # <-- Used for communication between Java <-> C++
59
+ find_package(ReactAndroid REQUIRED) # <-- Used to set up React Native bindings (e.g. CallInvoker/TurboModule)
60
+ find_package(react-native-nitro-modules REQUIRED) # <-- Used to create all HybridObjects and use the Nitro core library
61
+
62
+ # Link all libraries together
63
+ target_link_libraries(
64
+ NitroMunimFfmpeg
65
+ fbjni::fbjni # <-- Facebook C++ JNI helpers
66
+ ReactAndroid::jsi # <-- RN: JSI
67
+ react-native-nitro-modules::NitroModules # <-- NitroModules Core :)
68
+ )
69
+
70
+ # Link react-native (different prefab between RN 0.75 and RN 0.76)
71
+ if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
72
+ target_link_libraries(
73
+ NitroMunimFfmpeg
74
+ ReactAndroid::reactnative # <-- RN: Native Modules umbrella prefab
75
+ )
76
+ else()
77
+ target_link_libraries(
78
+ NitroMunimFfmpeg
79
+ ReactAndroid::react_nativemodule_core # <-- RN: TurboModules Core
80
+ )
81
+ endif()
@@ -0,0 +1,27 @@
1
+ ///
2
+ /// NitroMunimFfmpeg+autolinking.gradle
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
+ /// 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/NitroMunimFfmpeg+autolinking.gradle'
14
+ /// ```
15
+
16
+ logger.warn("[NitroModules] 🔥 NitroMunimFfmpeg 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
+ }
@@ -0,0 +1,60 @@
1
+ ///
2
+ /// NitroMunimFfmpegOnLoad.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
+ #ifndef BUILDING_NITROMUNIMFFMPEG_WITH_GENERATED_CMAKE_PROJECT
9
+ #error NitroMunimFfmpegOnLoad.cpp is not being built with the autogenerated CMakeLists.txt project. Is a different CMakeLists.txt building this?
10
+ #endif
11
+
12
+ #include "NitroMunimFfmpegOnLoad.hpp"
13
+
14
+ #include <jni.h>
15
+ #include <fbjni/fbjni.h>
16
+ #include <NitroModules/HybridObjectRegistry.hpp>
17
+
18
+ #include "JHybridMunimFfmpegSpec.hpp"
19
+ #include "JFunc_void_std__string.hpp"
20
+ #include "JFunc_void_double_double_double_double_double_double_double.hpp"
21
+ #include "JFunc_void_double.hpp"
22
+ #include <NitroModules/DefaultConstructableObject.hpp>
23
+
24
+ namespace margelo::nitro::munimffmpeg {
25
+
26
+ int initialize(JavaVM* vm) {
27
+ return facebook::jni::initialize(vm, []() {
28
+ ::margelo::nitro::munimffmpeg::registerAllNatives();
29
+ });
30
+ }
31
+
32
+ struct JHybridMunimFfmpegSpecImpl: public jni::JavaClass<JHybridMunimFfmpegSpecImpl, JHybridMunimFfmpegSpec::JavaPart> {
33
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/munimffmpeg/HybridMunimFfmpeg;";
34
+ static std::shared_ptr<JHybridMunimFfmpegSpec> create() {
35
+ static const auto constructorFn = javaClassStatic()->getConstructor<JHybridMunimFfmpegSpecImpl::javaobject()>();
36
+ jni::local_ref<JHybridMunimFfmpegSpec::JavaPart> javaPart = javaClassStatic()->newObject(constructorFn);
37
+ return javaPart->getJHybridMunimFfmpegSpec();
38
+ }
39
+ };
40
+
41
+ void registerAllNatives() {
42
+ using namespace margelo::nitro;
43
+ using namespace margelo::nitro::munimffmpeg;
44
+
45
+ // Register native JNI methods
46
+ margelo::nitro::munimffmpeg::JHybridMunimFfmpegSpec::CxxPart::registerNatives();
47
+ margelo::nitro::munimffmpeg::JFunc_void_std__string_cxx::registerNatives();
48
+ margelo::nitro::munimffmpeg::JFunc_void_double_double_double_double_double_double_double_cxx::registerNatives();
49
+ margelo::nitro::munimffmpeg::JFunc_void_double_cxx::registerNatives();
50
+
51
+ // Register Nitro Hybrid Objects
52
+ HybridObjectRegistry::registerHybridObjectConstructor(
53
+ "MunimFfmpeg",
54
+ []() -> std::shared_ptr<HybridObject> {
55
+ return JHybridMunimFfmpegSpecImpl::create();
56
+ }
57
+ );
58
+ }
59
+
60
+ } // namespace margelo::nitro::munimffmpeg
@@ -0,0 +1,34 @@
1
+ ///
2
+ /// NitroMunimFfmpegOnLoad.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
+ #include <jni.h>
9
+ #include <functional>
10
+ #include <NitroModules/NitroDefines.hpp>
11
+
12
+ namespace margelo::nitro::munimffmpeg {
13
+
14
+ [[deprecated("Use registerNatives() instead.")]]
15
+ int initialize(JavaVM* vm);
16
+
17
+ /**
18
+ * Register the native (C++) part of NitroMunimFfmpeg, and autolinks all Hybrid Objects.
19
+ * Call this in your `JNI_OnLoad` function (probably inside `cpp-adapter.cpp`),
20
+ * inside a `facebook::jni::initialize(vm, ...)` call.
21
+ * Example:
22
+ * ```cpp (cpp-adapter.cpp)
23
+ * JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) {
24
+ * return facebook::jni::initialize(vm, []() {
25
+ * // register all NitroMunimFfmpeg HybridObjects
26
+ * margelo::nitro::munimffmpeg::registerNatives();
27
+ * // any other custom registrations go here.
28
+ * });
29
+ * }
30
+ * ```
31
+ */
32
+ void registerAllNatives();
33
+
34
+ } // namespace margelo::nitro::munimffmpeg