Compare commits
4 Commits
3d09106e45
...
bump-react
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e7b295546a | ||
|
|
d87ed8ced2 | ||
| f055119735 | |||
| 35d80b13d6 |
@@ -19,9 +19,7 @@ endif()
|
||||
|
||||
|
||||
# Add react-native-vision-camera sources
|
||||
add_library(
|
||||
${PACKAGE_NAME}
|
||||
SHARED
|
||||
set(SOURCES
|
||||
# Shared C++
|
||||
../cpp/MutableRawBuffer.cpp
|
||||
# Java JNI
|
||||
@@ -31,17 +29,33 @@ add_library(
|
||||
src/main/cpp/OpenGLContext.cpp
|
||||
src/main/cpp/OpenGLRenderer.cpp
|
||||
src/main/cpp/MutableJByteBuffer.cpp
|
||||
# Frame Processor
|
||||
src/main/cpp/frameprocessor/FrameHostObject.cpp
|
||||
src/main/cpp/frameprocessor/FrameProcessorPluginHostObject.cpp
|
||||
src/main/cpp/frameprocessor/JSIJNIConversion.cpp
|
||||
src/main/cpp/frameprocessor/VisionCameraProxy.cpp
|
||||
src/main/cpp/frameprocessor/java-bindings/JSharedArray.cpp
|
||||
src/main/cpp/frameprocessor/java-bindings/JFrame.cpp
|
||||
src/main/cpp/frameprocessor/java-bindings/JFrameProcessor.cpp
|
||||
src/main/cpp/frameprocessor/java-bindings/JFrameProcessorPlugin.cpp
|
||||
src/main/cpp/frameprocessor/java-bindings/JVisionCameraProxy.cpp
|
||||
src/main/cpp/frameprocessor/java-bindings/JVisionCameraScheduler.cpp
|
||||
)
|
||||
|
||||
# Only add Frame Processor sources if enabled
|
||||
if (ENABLE_FRAME_PROCESSORS)
|
||||
list(APPEND SOURCES
|
||||
src/main/cpp/frameprocessor/FrameHostObject.cpp
|
||||
src/main/cpp/frameprocessor/FrameProcessorPluginHostObject.cpp
|
||||
src/main/cpp/frameprocessor/JSIJNIConversion.cpp
|
||||
src/main/cpp/frameprocessor/VisionCameraProxy.cpp
|
||||
src/main/cpp/frameprocessor/java-bindings/JSharedArray.cpp
|
||||
src/main/cpp/frameprocessor/java-bindings/JFrame.cpp
|
||||
src/main/cpp/frameprocessor/java-bindings/JFrameProcessor.cpp
|
||||
src/main/cpp/frameprocessor/java-bindings/JFrameProcessorPlugin.cpp
|
||||
src/main/cpp/frameprocessor/java-bindings/JVisionCameraProxy.cpp
|
||||
src/main/cpp/frameprocessor/java-bindings/JVisionCameraScheduler.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
add_library(
|
||||
${PACKAGE_NAME}
|
||||
SHARED
|
||||
${SOURCES}
|
||||
)
|
||||
|
||||
# Force 16KB page alignment for Android 15+ compatibility
|
||||
set_target_properties(${PACKAGE_NAME} PROPERTIES
|
||||
LINK_FLAGS "-Wl,-z,max-page-size=16384"
|
||||
)
|
||||
|
||||
# Header Search Paths (includes)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-all.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
@@ -9,11 +9,13 @@
|
||||
|
||||
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) {
|
||||
return facebook::jni::initialize(vm, [] {
|
||||
// VideoPipeline is needed for video recording even without Frame Processors
|
||||
vision::VideoPipeline::registerNatives();
|
||||
#if VISION_CAMERA_ENABLE_FRAME_PROCESSORS
|
||||
// Frame Processor JNI bindings - only register when Frame Processors are enabled
|
||||
vision::VisionCameraInstaller::registerNatives();
|
||||
vision::JVisionCameraProxy::registerNatives();
|
||||
vision::JVisionCameraScheduler::registerNatives();
|
||||
vision::VideoPipeline::registerNatives();
|
||||
#if VISION_CAMERA_ENABLE_FRAME_PROCESSORS
|
||||
vision::JFrameProcessor::registerNatives();
|
||||
vision::JSharedArray::registerNatives();
|
||||
#endif
|
||||
|
||||
@@ -29,10 +29,16 @@ class CameraViewModule(reactContext: ReactApplicationContext) : ReactContextBase
|
||||
var sharedRequestCode = 10
|
||||
|
||||
init {
|
||||
// Skip loading native library for React Native 0.79+ compatibility
|
||||
// Frame Processors are disabled (react-native-worklets-core not installed)
|
||||
// The native library has incompatible JNI signatures for RN 0.79+
|
||||
Log.i(TAG, "VisionCamera native library not loaded - Frame Processors disabled for RN 0.79+ compatibility")
|
||||
try {
|
||||
// Load the native part of VisionCamera.
|
||||
// Includes the OpenGL VideoPipeline (needed for video recording)
|
||||
// Frame Processors remain disabled for RN 0.79+ compatibility
|
||||
System.loadLibrary("VisionCamera")
|
||||
Log.i(TAG, "VisionCamera native library loaded successfully")
|
||||
} catch (e: UnsatisfiedLinkError) {
|
||||
Log.e(TAG, "Failed to load VisionCamera C++ library!", e)
|
||||
throw e
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -105,6 +105,12 @@ class ChunkedRecordingManager(private val encoder: MediaCodec, private val outpu
|
||||
muxerContext?.finish()
|
||||
chunkIndex++
|
||||
|
||||
val format = this.encodedFormat
|
||||
if (format == null) {
|
||||
Log.e(TAG, "Cannot create muxer: encodedFormat is null (onOutputFormatChanged not called yet)")
|
||||
return
|
||||
}
|
||||
|
||||
val newFileName = "$chunkIndex.mp4"
|
||||
val newOutputFile = File(this.outputDirectory, newFileName)
|
||||
Log.i(TAG, "Creating new muxer for file: $newFileName")
|
||||
@@ -114,7 +120,7 @@ class ChunkedRecordingManager(private val encoder: MediaCodec, private val outpu
|
||||
)
|
||||
muxer.setOrientationHint(orientationHint)
|
||||
muxerContext = MuxerContext(
|
||||
muxer, newOutputFile, chunkIndex, bufferInfo.presentationTimeUs, this.encodedFormat!!, this.callbacks
|
||||
muxer, newOutputFile, chunkIndex, bufferInfo.presentationTimeUs, format, this.callbacks
|
||||
)
|
||||
}
|
||||
|
||||
@@ -123,7 +129,8 @@ class ChunkedRecordingManager(private val encoder: MediaCodec, private val outpu
|
||||
}
|
||||
|
||||
private fun chunkLengthUs(bufferInfo: BufferInfo): Long {
|
||||
return bufferInfo.presentationTimeUs - muxerContext!!.startTimeUs
|
||||
val context = muxerContext ?: return 0L
|
||||
return bufferInfo.presentationTimeUs - context.startTimeUs
|
||||
}
|
||||
|
||||
fun start() {
|
||||
@@ -155,7 +162,13 @@ class ChunkedRecordingManager(private val encoder: MediaCodec, private val outpu
|
||||
if (muxerContext == null || (atKeyframe(bufferInfo) && chunkLengthUs(bufferInfo) >= targetDurationUs)) {
|
||||
this.createNextMuxer(bufferInfo)
|
||||
}
|
||||
muxerContext!!.muxer.writeSampleData(muxerContext!!.videoTrack, encodedData, bufferInfo)
|
||||
val context = muxerContext
|
||||
if (context == null) {
|
||||
Log.e(TAG, "Cannot write sample data: muxerContext is null")
|
||||
encoder.releaseOutputBuffer(index, false)
|
||||
return
|
||||
}
|
||||
context.muxer.writeSampleData(context.videoTrack, encodedData, bufferInfo)
|
||||
encoder.releaseOutputBuffer(index, false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import com.facebook.jni.HybridData
|
||||
import com.facebook.proguard.annotations.DoNotStrip
|
||||
import com.facebook.react.bridge.ReactApplicationContext
|
||||
import com.facebook.react.bridge.UiThreadUtil
|
||||
// import com.facebook.react.turbomodule.core.CallInvokerHolderImpl // Commented out due to RN 0.79+ compatibility
|
||||
import com.facebook.react.uimanager.UIManagerHelper
|
||||
import com.mrousavy.camera.CameraView
|
||||
import com.mrousavy.camera.core.ViewNotFoundError
|
||||
@@ -78,9 +77,9 @@ class VisionCameraProxy(private val reactContext: ReactApplicationContext) {
|
||||
FrameProcessorPluginRegistry.getPlugin(name, this, options)
|
||||
|
||||
// private C++ funcs
|
||||
// Keep this declared (even though we don't call it) so JNI can register it
|
||||
// The native library expects this method signature to exist
|
||||
@DoNotStrip
|
||||
@Keep
|
||||
private external fun initHybrid(jsContext: Long, jsCallInvokerHolder: Any, scheduler: VisionCameraScheduler): HybridData
|
||||
// Frame Processors are disabled - native registration is skipped via VISION_CAMERA_ENABLE_FRAME_PROCESSORS=OFF
|
||||
// This method is never called or registered, kept for reference only
|
||||
// @DoNotStrip
|
||||
// @Keep
|
||||
// private external fun initHybrid(jsContext: Long, jsCallInvokerHolder: Any, scheduler: VisionCameraScheduler): HybridData
|
||||
}
|
||||
|
||||
@@ -11,6 +11,6 @@ inline fun withPromise(promise: Promise, closure: () -> Any?) {
|
||||
} catch (e: Throwable) {
|
||||
e.printStackTrace()
|
||||
val error = if (e is CameraError) e else UnknownCameraError(e)
|
||||
promise.reject("${error.domain}/${error.id}", error.message, error.cause)
|
||||
promise.reject("${error.domain}/${error.id}", error.message ?: "Unknown error", error.cause)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user