@arfuhad/react-native-smart-camera 0.1.2 → 0.1.5
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/CHANGELOG.md +75 -3
- package/README.md +259 -206
- package/android/build.gradle +14 -39
- package/android/src/main/java/com/smartcamera/FaceDetectorFrameProcessorPlugin.kt +324 -0
- package/android/src/main/java/com/smartcamera/SmartCameraPackage.kt +28 -0
- package/build/detection/blinkProcessor.js +2 -1
- package/build/detection/blinkProcessor.js.map +1 -1
- package/build/detection/faceDetector.d.ts +4 -4
- package/build/detection/faceDetector.d.ts.map +1 -1
- package/build/detection/faceDetector.js +31 -11
- package/build/detection/faceDetector.js.map +1 -1
- package/build/detection/index.d.ts +1 -1
- package/build/detection/index.d.ts.map +1 -1
- package/build/detection/index.js +1 -1
- package/build/detection/index.js.map +1 -1
- package/build/detection/staticImageDetector.d.ts +11 -11
- package/build/detection/staticImageDetector.d.ts.map +1 -1
- package/build/detection/staticImageDetector.js +19 -23
- package/build/detection/staticImageDetector.js.map +1 -1
- package/build/hooks/index.d.ts +6 -0
- package/build/hooks/index.d.ts.map +1 -1
- package/build/hooks/index.js +8 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/useBlinkDetection.d.ts +27 -16
- package/build/hooks/useBlinkDetection.d.ts.map +1 -1
- package/build/hooks/useBlinkDetection.js +63 -37
- package/build/hooks/useBlinkDetection.js.map +1 -1
- package/build/hooks/useFaceDetection.js +3 -2
- package/build/hooks/useFaceDetection.js.map +1 -1
- package/build/hooks/useFaceDetector.d.ts +123 -0
- package/build/hooks/useFaceDetector.d.ts.map +1 -0
- package/build/hooks/useFaceDetector.js +133 -0
- package/build/hooks/useFaceDetector.js.map +1 -0
- package/build/hooks/useSmartCamera.js.map +1 -1
- package/build/hooks/useSmartCameraWebRTC.d.ts +3 -5
- package/build/hooks/useSmartCameraWebRTC.d.ts.map +1 -1
- package/build/hooks/useSmartCameraWebRTC.js +19 -87
- package/build/hooks/useSmartCameraWebRTC.js.map +1 -1
- package/build/hooks/useWebRTC.d.ts +88 -0
- package/build/hooks/useWebRTC.d.ts.map +1 -0
- package/build/hooks/useWebRTC.js +394 -0
- package/build/hooks/useWebRTC.js.map +1 -0
- package/build/hooks/useWebRTCWithDetection.d.ts +89 -0
- package/build/hooks/useWebRTCWithDetection.d.ts.map +1 -0
- package/build/hooks/useWebRTCWithDetection.js +131 -0
- package/build/hooks/useWebRTCWithDetection.js.map +1 -0
- package/build/index.d.ts +24 -10
- package/build/index.d.ts.map +1 -1
- package/build/index.js +38 -13
- package/build/index.js.map +1 -1
- package/build/types.d.ts +28 -12
- package/build/types.d.ts.map +1 -1
- package/build/types.js.map +1 -1
- package/build/utils/index.js.map +1 -1
- package/build/webrtc/WebRTCBridge.d.ts +3 -0
- package/build/webrtc/WebRTCBridge.d.ts.map +1 -1
- package/build/webrtc/WebRTCBridge.js +12 -15
- package/build/webrtc/WebRTCBridge.js.map +1 -1
- package/build/webrtc/WebRTCManager.d.ts +148 -0
- package/build/webrtc/WebRTCManager.d.ts.map +1 -0
- package/build/webrtc/WebRTCManager.js +383 -0
- package/build/webrtc/WebRTCManager.js.map +1 -0
- package/build/webrtc/index.d.ts +3 -1
- package/build/webrtc/index.d.ts.map +1 -1
- package/build/webrtc/index.js +5 -0
- package/build/webrtc/index.js.map +1 -1
- package/build/webrtc/types.d.ts +212 -4
- package/build/webrtc/types.d.ts.map +1 -1
- package/build/webrtc/types.js +34 -1
- package/build/webrtc/types.js.map +1 -1
- package/ios/FaceDetectorFrameProcessorPlugin.m +11 -0
- package/ios/FaceDetectorFrameProcessorPlugin.swift +304 -0
- package/package.json +11 -11
- package/react-native-smart-camera.podspec +32 -0
- package/src/detection/blinkProcessor.ts +127 -0
- package/src/detection/faceDetector.ts +78 -0
- package/src/detection/index.ts +3 -0
- package/src/detection/staticImageDetector.ts +53 -0
- package/src/hooks/index.ts +26 -0
- package/src/hooks/useBlinkDetection.ts +127 -0
- package/src/hooks/useFaceDetection.ts +105 -0
- package/src/hooks/useFaceDetector.ts +191 -0
- package/src/hooks/useSmartCamera.ts +83 -0
- package/src/hooks/useSmartCameraWebRTC.ts +120 -0
- package/src/hooks/useWebRTC.ts +453 -0
- package/src/hooks/useWebRTCWithDetection.ts +181 -0
- package/src/index.ts +170 -0
- package/src/types.ts +636 -0
- package/src/utils/index.ts +355 -0
- package/src/webrtc/WebRTCBridge.ts +127 -0
- package/src/webrtc/WebRTCManager.ts +453 -0
- package/src/webrtc/index.ts +50 -0
- package/src/webrtc/types.ts +361 -0
- package/android/build/.transforms/e0a0b120a9ccc3a8de4f5784bc36b161/results.bin +0 -1
- package/android/build/.transforms/e0a0b120a9ccc3a8de4f5784bc36b161/transformed/classes/classes_dex/classes.dex +0 -0
- package/android/build/generated/source/buildConfig/debug/expo/modules/smartcamera/BuildConfig.java +0 -10
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/AndroidManifest.xml +0 -7
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/output-metadata.json +0 -18
- package/android/build/intermediates/aar_metadata/debug/aar-metadata.properties +0 -6
- package/android/build/intermediates/annotation_processor_list/debug/annotationProcessors.json +0 -1
- package/android/build/intermediates/compile_library_classes_jar/debug/classes.jar +0 -0
- package/android/build/intermediates/compile_r_class_jar/debug/R.jar +0 -0
- package/android/build/intermediates/compile_symbol_list/debug/R.txt +0 -0
- package/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +0 -1
- package/android/build/intermediates/incremental/debug/packageDebugResources/merger.xml +0 -2
- package/android/build/intermediates/java_res/debug/out/META-INF/arfuhad-react-native-smart-camera_debug.kotlin_module +0 -0
- package/android/build/intermediates/javac/debug/classes/expo/modules/smartcamera/BuildConfig.class +0 -0
- package/android/build/intermediates/local_only_symbol_list/debug/R-def.txt +0 -2
- package/android/build/intermediates/manifest_merge_blame_file/debug/manifest-merger-blame-debug-report.txt +0 -7
- package/android/build/intermediates/merged_manifest/debug/AndroidManifest.xml +0 -7
- package/android/build/intermediates/navigation_json/debug/navigation.json +0 -1
- package/android/build/intermediates/runtime_library_classes_jar/debug/classes.jar +0 -0
- package/android/build/intermediates/symbol_list_with_package_name/debug/package-aware-r.txt +0 -1
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/counters.tab +0 -2
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/last-build.bin +0 -0
- package/android/build/kotlin/compileDebugKotlin/classpath-snapshot/shrunk-classpath-snapshot.bin +0 -0
- package/android/build/kotlin/compileDebugKotlin/local-state/build-history.bin +0 -0
- package/android/build/outputs/logs/manifest-merger-debug-report.txt +0 -16
- package/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
- package/android/build/tmp/kotlin-classes/debug/META-INF/arfuhad-react-native-smart-camera_debug.kotlin_module +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/DetectedFace.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/FaceBounds.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/FaceContoursData.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/FaceDetectionOptions.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/FaceLandmarksData.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/ImageLoader$Companion.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/ImageLoader$loadImage$2.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/ImageLoader.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/MLKitFaceDetector$detectFaces$2$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/MLKitFaceDetector$detectFaces$2$2.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/MLKitFaceDetector.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/MLKitFaceDetectorKt$sam$com_google_android_gms_tasks_OnSuccessListener$0.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/MLKitFaceDetectorKt.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/PointData.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$Companion.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$1$1$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$1$3$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$1$4$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$AsyncFunction$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$AsyncFunction$2.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$AsyncFunction$3.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$AsyncFunctionWithPromise$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$AsyncFunctionWithPromise$2.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$AsyncFunctionWithPromise$3.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$AsyncFunctionWithPromise$4.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$Function$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$Function$2.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$Function$3.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$Function$4.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$FunctionWithoutArgs$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$FunctionWithoutArgs$2.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$OnActivityEntersBackground$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$OnActivityEntersForeground$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$OnDestroy$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraView.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/WebRTCFrameBridge$Companion.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/WebRTCFrameBridge.class +0 -0
- package/android/src/main/java/expo/modules/smartcamera/ImageLoader.kt +0 -106
- package/android/src/main/java/expo/modules/smartcamera/MLKitFaceDetector.kt +0 -273
- package/android/src/main/java/expo/modules/smartcamera/SmartCameraModule.kt +0 -205
- package/android/src/main/java/expo/modules/smartcamera/SmartCameraView.kt +0 -153
- package/android/src/main/java/expo/modules/smartcamera/WebRTCFrameBridge.kt +0 -184
- package/build/SmartCamera.d.ts +0 -17
- package/build/SmartCamera.d.ts.map +0 -1
- package/build/SmartCamera.js +0 -270
- package/build/SmartCamera.js.map +0 -1
- package/build/SmartCameraModule.d.ts +0 -112
- package/build/SmartCameraModule.d.ts.map +0 -1
- package/build/SmartCameraModule.js +0 -121
- package/build/SmartCameraModule.js.map +0 -1
- package/build/SmartCameraView.d.ts +0 -8
- package/build/SmartCameraView.d.ts.map +0 -1
- package/build/SmartCameraView.js +0 -7
- package/build/SmartCameraView.js.map +0 -1
- package/expo-module.config.json +0 -9
- package/ios/MLKitFaceDetector.swift +0 -310
- package/ios/SmartCamera.podspec +0 -33
- package/ios/SmartCameraModule.swift +0 -225
- package/ios/SmartCameraView.swift +0 -146
- package/ios/WebRTCFrameBridge.swift +0 -150
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useWebRTC Hook
|
|
3
|
+
*
|
|
4
|
+
* React hook for managing WebRTC video calling with peer connections,
|
|
5
|
+
* local/remote streams, and signaling integration.
|
|
6
|
+
*
|
|
7
|
+
* This hook provides all the functionality needed for 1-to-1 video calls.
|
|
8
|
+
* Users are responsible for implementing their own signaling mechanism
|
|
9
|
+
* (WebSocket, Socket.io, etc.) to exchange SDP offers/answers and ICE candidates.
|
|
10
|
+
*/
|
|
11
|
+
import { useState, useCallback, useRef, useEffect } from 'react';
|
|
12
|
+
import { WebRTCManager, isWebRTCAvailable, } from '../webrtc/WebRTCManager';
|
|
13
|
+
/**
|
|
14
|
+
* Hook for WebRTC video calling
|
|
15
|
+
*
|
|
16
|
+
* @param options - Configuration options
|
|
17
|
+
* @returns WebRTC controls and state
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* import { useWebRTC } from '@arfuhad/react-native-smart-camera';
|
|
22
|
+
* import { RTCView } from 'react-native-webrtc';
|
|
23
|
+
*
|
|
24
|
+
* function VideoCall() {
|
|
25
|
+
* const {
|
|
26
|
+
* localStream,
|
|
27
|
+
* remoteStream,
|
|
28
|
+
* callState,
|
|
29
|
+
* startLocalStream,
|
|
30
|
+
* createPeerConnection,
|
|
31
|
+
* createOffer,
|
|
32
|
+
* setRemoteDescription,
|
|
33
|
+
* addIceCandidate,
|
|
34
|
+
* onIceCandidate,
|
|
35
|
+
* switchCamera,
|
|
36
|
+
* toggleAudio,
|
|
37
|
+
* toggleVideo,
|
|
38
|
+
* cleanup,
|
|
39
|
+
* } = useWebRTC({
|
|
40
|
+
* config: {
|
|
41
|
+
* iceServers: [{ urls: 'stun:stun.l.google.com:19302' }],
|
|
42
|
+
* },
|
|
43
|
+
* onRemoteStream: (stream) => console.log('Remote stream received'),
|
|
44
|
+
* });
|
|
45
|
+
*
|
|
46
|
+
* // Start a call
|
|
47
|
+
* const startCall = async () => {
|
|
48
|
+
* await startLocalStream();
|
|
49
|
+
* createPeerConnection();
|
|
50
|
+
* const offer = await createOffer();
|
|
51
|
+
* // Send offer via your signaling server
|
|
52
|
+
* socket.emit('offer', offer);
|
|
53
|
+
* };
|
|
54
|
+
*
|
|
55
|
+
* // Handle incoming call
|
|
56
|
+
* useEffect(() => {
|
|
57
|
+
* socket.on('offer', async (offer) => {
|
|
58
|
+
* await startLocalStream();
|
|
59
|
+
* createPeerConnection();
|
|
60
|
+
* await setRemoteDescription(offer);
|
|
61
|
+
* const answer = await createAnswer();
|
|
62
|
+
* socket.emit('answer', answer);
|
|
63
|
+
* });
|
|
64
|
+
*
|
|
65
|
+
* socket.on('ice-candidate', (candidate) => {
|
|
66
|
+
* addIceCandidate(candidate);
|
|
67
|
+
* });
|
|
68
|
+
*
|
|
69
|
+
* onIceCandidate((event) => {
|
|
70
|
+
* if (event.candidate) {
|
|
71
|
+
* socket.emit('ice-candidate', event.candidate);
|
|
72
|
+
* }
|
|
73
|
+
* });
|
|
74
|
+
* }, []);
|
|
75
|
+
*
|
|
76
|
+
* return (
|
|
77
|
+
* <View>
|
|
78
|
+
* {remoteStream && <RTCView streamURL={remoteStream.toURL()} />}
|
|
79
|
+
* {localStream && <RTCView streamURL={localStream.toURL()} />}
|
|
80
|
+
* <Button onPress={switchCamera} title="Switch Camera" />
|
|
81
|
+
* <Button onPress={toggleAudio} title="Mute/Unmute" />
|
|
82
|
+
* </View>
|
|
83
|
+
* );
|
|
84
|
+
* }
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
export function useWebRTC(options = {}) {
|
|
88
|
+
const { config, mediaConstraints, initialCamera = 'front', autoStartLocalStream = false, onCallStateChange, onConnectionStateChange, onIceConnectionStateChange, onRemoteStream, onRemoteStreamRemoved, onError, } = options;
|
|
89
|
+
// State
|
|
90
|
+
const [localStream, setLocalStream] = useState(null);
|
|
91
|
+
const [remoteStream, setRemoteStream] = useState(null);
|
|
92
|
+
const [callState, setCallState] = useState('idle');
|
|
93
|
+
const [isAudioEnabled, setIsAudioEnabled] = useState(true);
|
|
94
|
+
const [isVideoEnabled, setIsVideoEnabled] = useState(true);
|
|
95
|
+
const [currentCamera, setCurrentCamera] = useState(initialCamera);
|
|
96
|
+
const [peerConnection, setPeerConnection] = useState(null);
|
|
97
|
+
// Refs
|
|
98
|
+
const managerRef = useRef(null);
|
|
99
|
+
const isMountedRef = useRef(true);
|
|
100
|
+
const iceCandidateCallbackRef = useRef(null);
|
|
101
|
+
const callbacksRef = useRef({
|
|
102
|
+
onCallStateChange,
|
|
103
|
+
onConnectionStateChange,
|
|
104
|
+
onIceConnectionStateChange,
|
|
105
|
+
onRemoteStream,
|
|
106
|
+
onRemoteStreamRemoved,
|
|
107
|
+
onError,
|
|
108
|
+
});
|
|
109
|
+
// Keep callbacks ref updated
|
|
110
|
+
useEffect(() => {
|
|
111
|
+
callbacksRef.current = {
|
|
112
|
+
onCallStateChange,
|
|
113
|
+
onConnectionStateChange,
|
|
114
|
+
onIceConnectionStateChange,
|
|
115
|
+
onRemoteStream,
|
|
116
|
+
onRemoteStreamRemoved,
|
|
117
|
+
onError,
|
|
118
|
+
};
|
|
119
|
+
}, [
|
|
120
|
+
onCallStateChange,
|
|
121
|
+
onConnectionStateChange,
|
|
122
|
+
onIceConnectionStateChange,
|
|
123
|
+
onRemoteStream,
|
|
124
|
+
onRemoteStreamRemoved,
|
|
125
|
+
onError,
|
|
126
|
+
]);
|
|
127
|
+
// Initialize manager
|
|
128
|
+
useEffect(() => {
|
|
129
|
+
if (!isWebRTCAvailable()) {
|
|
130
|
+
console.warn('[useWebRTC] react-native-webrtc is not available');
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
managerRef.current = new WebRTCManager(config);
|
|
134
|
+
return () => {
|
|
135
|
+
var _a;
|
|
136
|
+
isMountedRef.current = false;
|
|
137
|
+
(_a = managerRef.current) === null || _a === void 0 ? void 0 : _a.cleanup();
|
|
138
|
+
};
|
|
139
|
+
}, []);
|
|
140
|
+
// Auto-start local stream if configured
|
|
141
|
+
useEffect(() => {
|
|
142
|
+
if (autoStartLocalStream && isWebRTCAvailable()) {
|
|
143
|
+
startLocalStream();
|
|
144
|
+
}
|
|
145
|
+
}, [autoStartLocalStream]);
|
|
146
|
+
// Update call state and notify
|
|
147
|
+
const updateCallState = useCallback((newState) => {
|
|
148
|
+
var _a, _b;
|
|
149
|
+
if (isMountedRef.current) {
|
|
150
|
+
setCallState(newState);
|
|
151
|
+
(_b = (_a = callbacksRef.current).onCallStateChange) === null || _b === void 0 ? void 0 : _b.call(_a, newState);
|
|
152
|
+
}
|
|
153
|
+
}, []);
|
|
154
|
+
// ==========================================================================
|
|
155
|
+
// Local Stream Controls
|
|
156
|
+
// ==========================================================================
|
|
157
|
+
/**
|
|
158
|
+
* Start local camera/microphone stream
|
|
159
|
+
*/
|
|
160
|
+
const startLocalStream = useCallback(async () => {
|
|
161
|
+
var _a, _b;
|
|
162
|
+
if (!managerRef.current) {
|
|
163
|
+
throw new Error('WebRTC not initialized');
|
|
164
|
+
}
|
|
165
|
+
try {
|
|
166
|
+
const constraints = Object.assign({ video: {
|
|
167
|
+
width: { ideal: 1280 },
|
|
168
|
+
height: { ideal: 720 },
|
|
169
|
+
frameRate: { ideal: 30 },
|
|
170
|
+
facingMode: currentCamera === 'front' ? 'user' : 'environment',
|
|
171
|
+
}, audio: {
|
|
172
|
+
echoCancellation: true,
|
|
173
|
+
noiseSuppression: true,
|
|
174
|
+
autoGainControl: true,
|
|
175
|
+
} }, mediaConstraints);
|
|
176
|
+
const stream = await managerRef.current.getLocalStream(constraints);
|
|
177
|
+
if (isMountedRef.current) {
|
|
178
|
+
setLocalStream(stream);
|
|
179
|
+
setIsAudioEnabled(true);
|
|
180
|
+
setIsVideoEnabled(true);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
catch (error) {
|
|
184
|
+
(_b = (_a = callbacksRef.current).onError) === null || _b === void 0 ? void 0 : _b.call(_a, error);
|
|
185
|
+
throw error;
|
|
186
|
+
}
|
|
187
|
+
}, [currentCamera, mediaConstraints]);
|
|
188
|
+
/**
|
|
189
|
+
* Stop local stream
|
|
190
|
+
*/
|
|
191
|
+
const stopLocalStream = useCallback(() => {
|
|
192
|
+
var _a;
|
|
193
|
+
(_a = managerRef.current) === null || _a === void 0 ? void 0 : _a.stopLocalStream();
|
|
194
|
+
if (isMountedRef.current) {
|
|
195
|
+
setLocalStream(null);
|
|
196
|
+
}
|
|
197
|
+
}, []);
|
|
198
|
+
/**
|
|
199
|
+
* Switch between front and back camera
|
|
200
|
+
*/
|
|
201
|
+
const switchCamera = useCallback(async () => {
|
|
202
|
+
var _a, _b, _c;
|
|
203
|
+
try {
|
|
204
|
+
await ((_a = managerRef.current) === null || _a === void 0 ? void 0 : _a.switchCamera());
|
|
205
|
+
if (isMountedRef.current) {
|
|
206
|
+
setCurrentCamera((prev) => (prev === 'front' ? 'back' : 'front'));
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
catch (error) {
|
|
210
|
+
(_c = (_b = callbacksRef.current).onError) === null || _c === void 0 ? void 0 : _c.call(_b, error);
|
|
211
|
+
throw error;
|
|
212
|
+
}
|
|
213
|
+
}, []);
|
|
214
|
+
/**
|
|
215
|
+
* Toggle local audio on/off
|
|
216
|
+
*/
|
|
217
|
+
const toggleAudio = useCallback(() => {
|
|
218
|
+
var _a;
|
|
219
|
+
const newState = !isAudioEnabled;
|
|
220
|
+
(_a = managerRef.current) === null || _a === void 0 ? void 0 : _a.toggleAudio(newState);
|
|
221
|
+
if (isMountedRef.current) {
|
|
222
|
+
setIsAudioEnabled(newState);
|
|
223
|
+
}
|
|
224
|
+
}, [isAudioEnabled]);
|
|
225
|
+
/**
|
|
226
|
+
* Toggle local video on/off
|
|
227
|
+
*/
|
|
228
|
+
const toggleVideo = useCallback(() => {
|
|
229
|
+
var _a;
|
|
230
|
+
const newState = !isVideoEnabled;
|
|
231
|
+
(_a = managerRef.current) === null || _a === void 0 ? void 0 : _a.toggleVideo(newState);
|
|
232
|
+
if (isMountedRef.current) {
|
|
233
|
+
setIsVideoEnabled(newState);
|
|
234
|
+
}
|
|
235
|
+
}, [isVideoEnabled]);
|
|
236
|
+
// ==========================================================================
|
|
237
|
+
// Peer Connection Management
|
|
238
|
+
// ==========================================================================
|
|
239
|
+
/**
|
|
240
|
+
* Create a new peer connection
|
|
241
|
+
*/
|
|
242
|
+
const createPeerConnection = useCallback((pcConfig) => {
|
|
243
|
+
if (!managerRef.current) {
|
|
244
|
+
throw new Error('WebRTC not initialized');
|
|
245
|
+
}
|
|
246
|
+
const pc = managerRef.current.createPeerConnection(pcConfig || config);
|
|
247
|
+
// Setup callbacks
|
|
248
|
+
managerRef.current.onRemoteStream((stream) => {
|
|
249
|
+
var _a, _b;
|
|
250
|
+
if (isMountedRef.current) {
|
|
251
|
+
setRemoteStream(stream);
|
|
252
|
+
updateCallState('connected');
|
|
253
|
+
(_b = (_a = callbacksRef.current).onRemoteStream) === null || _b === void 0 ? void 0 : _b.call(_a, stream);
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
managerRef.current.onConnectionStateChange((state) => {
|
|
257
|
+
var _a, _b;
|
|
258
|
+
(_b = (_a = callbacksRef.current).onConnectionStateChange) === null || _b === void 0 ? void 0 : _b.call(_a, state);
|
|
259
|
+
// Update call state based on connection state
|
|
260
|
+
if (state === 'connected') {
|
|
261
|
+
updateCallState('connected');
|
|
262
|
+
}
|
|
263
|
+
else if (state === 'disconnected' || state === 'failed') {
|
|
264
|
+
updateCallState('disconnected');
|
|
265
|
+
}
|
|
266
|
+
else if (state === 'connecting') {
|
|
267
|
+
updateCallState('connecting');
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
managerRef.current.onIceConnectionStateChange((state) => {
|
|
271
|
+
var _a, _b;
|
|
272
|
+
(_b = (_a = callbacksRef.current).onIceConnectionStateChange) === null || _b === void 0 ? void 0 : _b.call(_a, state);
|
|
273
|
+
});
|
|
274
|
+
managerRef.current.onIceCandidate((event) => {
|
|
275
|
+
var _a;
|
|
276
|
+
(_a = iceCandidateCallbackRef.current) === null || _a === void 0 ? void 0 : _a.call(iceCandidateCallbackRef, event);
|
|
277
|
+
});
|
|
278
|
+
// Add local stream to peer connection if available
|
|
279
|
+
const stream = managerRef.current.getLocalStreamInstance();
|
|
280
|
+
if (stream) {
|
|
281
|
+
managerRef.current.addLocalStream(stream);
|
|
282
|
+
}
|
|
283
|
+
if (isMountedRef.current) {
|
|
284
|
+
setPeerConnection(pc);
|
|
285
|
+
updateCallState('connecting');
|
|
286
|
+
}
|
|
287
|
+
return pc;
|
|
288
|
+
}, [config, updateCallState]);
|
|
289
|
+
/**
|
|
290
|
+
* Close the peer connection
|
|
291
|
+
*/
|
|
292
|
+
const closePeerConnection = useCallback(() => {
|
|
293
|
+
var _a, _b, _c;
|
|
294
|
+
(_a = managerRef.current) === null || _a === void 0 ? void 0 : _a.closePeerConnection();
|
|
295
|
+
if (isMountedRef.current) {
|
|
296
|
+
setPeerConnection(null);
|
|
297
|
+
setRemoteStream(null);
|
|
298
|
+
updateCallState('idle');
|
|
299
|
+
(_c = (_b = callbacksRef.current).onRemoteStreamRemoved) === null || _c === void 0 ? void 0 : _c.call(_b);
|
|
300
|
+
}
|
|
301
|
+
}, [updateCallState]);
|
|
302
|
+
// ==========================================================================
|
|
303
|
+
// Signaling Helpers
|
|
304
|
+
// ==========================================================================
|
|
305
|
+
/**
|
|
306
|
+
* Create an SDP offer
|
|
307
|
+
*/
|
|
308
|
+
const createOffer = useCallback(async () => {
|
|
309
|
+
if (!managerRef.current) {
|
|
310
|
+
throw new Error('WebRTC not initialized');
|
|
311
|
+
}
|
|
312
|
+
return managerRef.current.createOffer();
|
|
313
|
+
}, []);
|
|
314
|
+
/**
|
|
315
|
+
* Create an SDP answer
|
|
316
|
+
*/
|
|
317
|
+
const createAnswer = useCallback(async () => {
|
|
318
|
+
if (!managerRef.current) {
|
|
319
|
+
throw new Error('WebRTC not initialized');
|
|
320
|
+
}
|
|
321
|
+
return managerRef.current.createAnswer();
|
|
322
|
+
}, []);
|
|
323
|
+
/**
|
|
324
|
+
* Set the remote SDP description
|
|
325
|
+
*/
|
|
326
|
+
const setRemoteDescription = useCallback(async (description) => {
|
|
327
|
+
if (!managerRef.current) {
|
|
328
|
+
throw new Error('WebRTC not initialized');
|
|
329
|
+
}
|
|
330
|
+
await managerRef.current.setRemoteDescription(description);
|
|
331
|
+
}, []);
|
|
332
|
+
/**
|
|
333
|
+
* Add an ICE candidate from remote peer
|
|
334
|
+
*/
|
|
335
|
+
const addIceCandidate = useCallback(async (candidate) => {
|
|
336
|
+
if (!managerRef.current) {
|
|
337
|
+
throw new Error('WebRTC not initialized');
|
|
338
|
+
}
|
|
339
|
+
await managerRef.current.addIceCandidate(candidate);
|
|
340
|
+
}, []);
|
|
341
|
+
/**
|
|
342
|
+
* Register callback for ICE candidates
|
|
343
|
+
*/
|
|
344
|
+
const onIceCandidate = useCallback((callback) => {
|
|
345
|
+
iceCandidateCallbackRef.current = callback;
|
|
346
|
+
}, []);
|
|
347
|
+
// ==========================================================================
|
|
348
|
+
// Cleanup
|
|
349
|
+
// ==========================================================================
|
|
350
|
+
/**
|
|
351
|
+
* Clean up all resources
|
|
352
|
+
*/
|
|
353
|
+
const cleanup = useCallback(() => {
|
|
354
|
+
var _a;
|
|
355
|
+
(_a = managerRef.current) === null || _a === void 0 ? void 0 : _a.cleanup();
|
|
356
|
+
if (isMountedRef.current) {
|
|
357
|
+
setLocalStream(null);
|
|
358
|
+
setRemoteStream(null);
|
|
359
|
+
setPeerConnection(null);
|
|
360
|
+
setCallState('idle');
|
|
361
|
+
setIsAudioEnabled(true);
|
|
362
|
+
setIsVideoEnabled(true);
|
|
363
|
+
}
|
|
364
|
+
}, []);
|
|
365
|
+
return {
|
|
366
|
+
// Streams
|
|
367
|
+
localStream,
|
|
368
|
+
remoteStream,
|
|
369
|
+
// State
|
|
370
|
+
callState,
|
|
371
|
+
isAudioEnabled,
|
|
372
|
+
isVideoEnabled,
|
|
373
|
+
currentCamera,
|
|
374
|
+
peerConnection,
|
|
375
|
+
// Local stream controls
|
|
376
|
+
startLocalStream,
|
|
377
|
+
stopLocalStream,
|
|
378
|
+
switchCamera,
|
|
379
|
+
toggleAudio,
|
|
380
|
+
toggleVideo,
|
|
381
|
+
// Peer connection management
|
|
382
|
+
createPeerConnection,
|
|
383
|
+
closePeerConnection,
|
|
384
|
+
// Signaling helpers
|
|
385
|
+
createOffer,
|
|
386
|
+
createAnswer,
|
|
387
|
+
setRemoteDescription,
|
|
388
|
+
addIceCandidate,
|
|
389
|
+
onIceCandidate,
|
|
390
|
+
// Cleanup
|
|
391
|
+
cleanup,
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
//# sourceMappingURL=useWebRTC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useWebRTC.js","sourceRoot":"","sources":["../../src/hooks/useWebRTC.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,EACL,aAAa,EACb,iBAAiB,GAClB,MAAM,yBAAyB,CAAC;AAajC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyEG;AACH,MAAM,UAAU,SAAS,CAAC,UAA4B,EAAE;IACtD,MAAM,EACJ,MAAM,EACN,gBAAgB,EAChB,aAAa,GAAG,OAAO,EACvB,oBAAoB,GAAG,KAAK,EA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AC,CAAC;YACrB,iBAAiB,CAAC,IAAI,CAAC,CAAC;YACxB,iBAAiB,CAAC,IAAI,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO;QACL,UAAU;QACV,WAAW;QACX,YAAY;QAEZ,QAAQ;QACR,SAAS;QACT,cAAc;QACd,cAAc;QACd,aAAa;QACb,cAAc;QAEd,wBAAwB;QACxB,gBAAgB;QAChB,eAAe;QACf,YAAY;QACZ,WAAW;QACX,WAAW;QAEX,6BAA6B;QAC7B,oBAAoB;QACpB,mBAAmB;QAEnB,oBAAoB;QACpB,WAAW;QACX,YAAY;QACZ,oBAAoB;QACpB,eAAe;QACf,cAAc;QAEd,UAAU;QACV,OAAO;KACR,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useWebRTCWithDetection Hook
|
|
3
|
+
*
|
|
4
|
+
* Combined hook that provides WebRTC video calling functionality
|
|
5
|
+
* alongside face detection and eye tracking capabilities.
|
|
6
|
+
*
|
|
7
|
+
* This hook allows you to:
|
|
8
|
+
* - Make video calls using WebRTC
|
|
9
|
+
* - Detect faces in the local camera feed using VisionCamera
|
|
10
|
+
* - Track eye status for blink detection
|
|
11
|
+
*/
|
|
12
|
+
import type { Frame } from 'react-native-vision-camera';
|
|
13
|
+
import type { Face, EyeStatusResult } from '../types';
|
|
14
|
+
import type { UseWebRTCResult, UseWebRTCWithDetectionOptions } from '../webrtc/types';
|
|
15
|
+
export type { UseWebRTCWithDetectionOptions } from '../webrtc/types';
|
|
16
|
+
/**
|
|
17
|
+
* Result type for useWebRTCWithDetection hook
|
|
18
|
+
*/
|
|
19
|
+
export interface UseWebRTCWithDetectionResult extends UseWebRTCResult {
|
|
20
|
+
/** Currently detected faces */
|
|
21
|
+
faces: Face[];
|
|
22
|
+
/** Detect faces in a frame (for use in VisionCamera frame processor) */
|
|
23
|
+
detectFaces: (frame: Frame) => Face[];
|
|
24
|
+
/** Current eye status */
|
|
25
|
+
eyeStatus: EyeStatusResult | null;
|
|
26
|
+
/** Process faces for eye tracking */
|
|
27
|
+
processEyeStatus: (faces: Face[]) => void;
|
|
28
|
+
/** Reset eye status */
|
|
29
|
+
resetEyeStatus: () => void;
|
|
30
|
+
/** Process a frame for both face detection and eye tracking */
|
|
31
|
+
processFrame: (frame: Frame) => void;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Hook combining WebRTC video calling with face detection and eye tracking
|
|
35
|
+
*
|
|
36
|
+
* @param options - Configuration options
|
|
37
|
+
* @returns Combined WebRTC, face detection, and eye tracking controls
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```tsx
|
|
41
|
+
* import { useWebRTCWithDetection } from '@arfuhad/react-native-smart-camera';
|
|
42
|
+
* import { Camera, useFrameProcessor } from 'react-native-vision-camera';
|
|
43
|
+
* import { RTCView } from 'react-native-webrtc';
|
|
44
|
+
*
|
|
45
|
+
* function VideoCallWithDetection() {
|
|
46
|
+
* const {
|
|
47
|
+
* // WebRTC
|
|
48
|
+
* localStream,
|
|
49
|
+
* remoteStream,
|
|
50
|
+
* callState,
|
|
51
|
+
* startLocalStream,
|
|
52
|
+
* createPeerConnection,
|
|
53
|
+
* // Face detection
|
|
54
|
+
* faces,
|
|
55
|
+
* detectFaces,
|
|
56
|
+
* // Eye tracking
|
|
57
|
+
* eyeStatus,
|
|
58
|
+
* // Combined handler
|
|
59
|
+
* processFrame,
|
|
60
|
+
* } = useWebRTCWithDetection({
|
|
61
|
+
* config: { iceServers: [{ urls: 'stun:stun.l.google.com:19302' }] },
|
|
62
|
+
* faceDetection: { enabled: true, classificationMode: 'all' },
|
|
63
|
+
* eyeTracking: { enabled: true, eyeClosedThreshold: 0.3 },
|
|
64
|
+
* });
|
|
65
|
+
*
|
|
66
|
+
* // Use VisionCamera for local preview + detection
|
|
67
|
+
* // Use RTCView for remote stream
|
|
68
|
+
* const frameProcessor = useFrameProcessor((frame) => {
|
|
69
|
+
* 'worklet';
|
|
70
|
+
* processFrame(frame);
|
|
71
|
+
* }, [processFrame]);
|
|
72
|
+
*
|
|
73
|
+
* return (
|
|
74
|
+
* <View>
|
|
75
|
+
* <Camera
|
|
76
|
+
* device={device}
|
|
77
|
+
* isActive={true}
|
|
78
|
+
* frameProcessor={frameProcessor}
|
|
79
|
+
* />
|
|
80
|
+
* {remoteStream && <RTCView streamURL={remoteStream.toURL()} />}
|
|
81
|
+
* <Text>Faces: {faces.length}</Text>
|
|
82
|
+
* <Text>Left Eye: {eyeStatus?.leftEye.openProbability.toFixed(2)}</Text>
|
|
83
|
+
* </View>
|
|
84
|
+
* );
|
|
85
|
+
* }
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
export declare function useWebRTCWithDetection(options?: UseWebRTCWithDetectionOptions): UseWebRTCWithDetectionResult;
|
|
89
|
+
//# sourceMappingURL=useWebRTCWithDetection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useWebRTCWithDetection.d.ts","sourceRoot":"","sources":["../../src/hooks/useWebRTCWithDetection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAIxD,OAAO,KAAK,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,KAAK,EAEV,eAAe,EACf,6BAA6B,EAC9B,MAAM,iBAAiB,CAAC;AAGzB,YAAY,EAAE,6BAA6B,EAAE,MAAM,iBAAiB,CAAC;AAErE;;GAEG;AACH,MAAM,WAAW,4BAA6B,SAAQ,eAAe;IAEnE,+BAA+B;IAC/B,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,wEAAwE;IACxE,WAAW,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,EAAE,CAAC;IAGtC,yBAAyB;IACzB,SAAS,EAAE,eAAe,GAAG,IAAI,CAAC;IAClC,qCAAqC;IACrC,gBAAgB,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,IAAI,CAAC;IAC1C,uBAAuB;IACvB,cAAc,EAAE,MAAM,IAAI,CAAC;IAG3B,+DAA+D;IAC/D,YAAY,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACtC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,GAAE,6BAAkC,GAC1C,4BAA4B,CAqE9B"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useWebRTCWithDetection Hook
|
|
3
|
+
*
|
|
4
|
+
* Combined hook that provides WebRTC video calling functionality
|
|
5
|
+
* alongside face detection and eye tracking capabilities.
|
|
6
|
+
*
|
|
7
|
+
* This hook allows you to:
|
|
8
|
+
* - Make video calls using WebRTC
|
|
9
|
+
* - Detect faces in the local camera feed using VisionCamera
|
|
10
|
+
* - Track eye status for blink detection
|
|
11
|
+
*/
|
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
23
|
+
import { useState, useCallback } from 'react';
|
|
24
|
+
import { useRunOnJS } from 'react-native-worklets-core';
|
|
25
|
+
import { useWebRTC } from './useWebRTC';
|
|
26
|
+
import { useFaceDetector } from './useFaceDetector';
|
|
27
|
+
import { useBlinkDetection } from './useBlinkDetection';
|
|
28
|
+
/**
|
|
29
|
+
* Hook combining WebRTC video calling with face detection and eye tracking
|
|
30
|
+
*
|
|
31
|
+
* @param options - Configuration options
|
|
32
|
+
* @returns Combined WebRTC, face detection, and eye tracking controls
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```tsx
|
|
36
|
+
* import { useWebRTCWithDetection } from '@arfuhad/react-native-smart-camera';
|
|
37
|
+
* import { Camera, useFrameProcessor } from 'react-native-vision-camera';
|
|
38
|
+
* import { RTCView } from 'react-native-webrtc';
|
|
39
|
+
*
|
|
40
|
+
* function VideoCallWithDetection() {
|
|
41
|
+
* const {
|
|
42
|
+
* // WebRTC
|
|
43
|
+
* localStream,
|
|
44
|
+
* remoteStream,
|
|
45
|
+
* callState,
|
|
46
|
+
* startLocalStream,
|
|
47
|
+
* createPeerConnection,
|
|
48
|
+
* // Face detection
|
|
49
|
+
* faces,
|
|
50
|
+
* detectFaces,
|
|
51
|
+
* // Eye tracking
|
|
52
|
+
* eyeStatus,
|
|
53
|
+
* // Combined handler
|
|
54
|
+
* processFrame,
|
|
55
|
+
* } = useWebRTCWithDetection({
|
|
56
|
+
* config: { iceServers: [{ urls: 'stun:stun.l.google.com:19302' }] },
|
|
57
|
+
* faceDetection: { enabled: true, classificationMode: 'all' },
|
|
58
|
+
* eyeTracking: { enabled: true, eyeClosedThreshold: 0.3 },
|
|
59
|
+
* });
|
|
60
|
+
*
|
|
61
|
+
* // Use VisionCamera for local preview + detection
|
|
62
|
+
* // Use RTCView for remote stream
|
|
63
|
+
* const frameProcessor = useFrameProcessor((frame) => {
|
|
64
|
+
* 'worklet';
|
|
65
|
+
* processFrame(frame);
|
|
66
|
+
* }, [processFrame]);
|
|
67
|
+
*
|
|
68
|
+
* return (
|
|
69
|
+
* <View>
|
|
70
|
+
* <Camera
|
|
71
|
+
* device={device}
|
|
72
|
+
* isActive={true}
|
|
73
|
+
* frameProcessor={frameProcessor}
|
|
74
|
+
* />
|
|
75
|
+
* {remoteStream && <RTCView streamURL={remoteStream.toURL()} />}
|
|
76
|
+
* <Text>Faces: {faces.length}</Text>
|
|
77
|
+
* <Text>Left Eye: {eyeStatus?.leftEye.openProbability.toFixed(2)}</Text>
|
|
78
|
+
* </View>
|
|
79
|
+
* );
|
|
80
|
+
* }
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
export function useWebRTCWithDetection(options = {}) {
|
|
84
|
+
var _a;
|
|
85
|
+
const { faceDetection = {}, eyeTracking = {} } = options, webrtcOptions = __rest(options, ["faceDetection", "eyeTracking"]);
|
|
86
|
+
// WebRTC hook
|
|
87
|
+
const webrtc = useWebRTC(webrtcOptions);
|
|
88
|
+
// Face detection state
|
|
89
|
+
const [faces, setFaces] = useState([]);
|
|
90
|
+
// Face detector hook
|
|
91
|
+
const { detectFaces } = useFaceDetector({
|
|
92
|
+
performanceMode: faceDetection.performanceMode || 'fast',
|
|
93
|
+
landmarkMode: faceDetection.landmarkMode || 'none',
|
|
94
|
+
classificationMode: faceDetection.classificationMode || 'all', // Needed for eye tracking
|
|
95
|
+
trackingEnabled: true,
|
|
96
|
+
});
|
|
97
|
+
// Blink detection hook
|
|
98
|
+
const { eyeStatus, processEyeStatus, reset: resetEyeStatus, } = useBlinkDetection({
|
|
99
|
+
enabled: eyeTracking.enabled !== false,
|
|
100
|
+
eyeClosedThreshold: (_a = eyeTracking.eyeClosedThreshold) !== null && _a !== void 0 ? _a : 0.5,
|
|
101
|
+
});
|
|
102
|
+
// Handle detected faces on JS thread
|
|
103
|
+
const handleFaces = useRunOnJS((detectedFaces) => {
|
|
104
|
+
setFaces(detectedFaces);
|
|
105
|
+
// Process for eye tracking if enabled
|
|
106
|
+
if (eyeTracking.enabled !== false) {
|
|
107
|
+
processEyeStatus(detectedFaces);
|
|
108
|
+
}
|
|
109
|
+
}, [processEyeStatus, eyeTracking.enabled]);
|
|
110
|
+
// Combined frame processor function
|
|
111
|
+
const processFrame = useCallback((frame) => {
|
|
112
|
+
'worklet';
|
|
113
|
+
if (faceDetection.enabled === false) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
const detectedFaces = detectFaces(frame);
|
|
117
|
+
handleFaces(detectedFaces);
|
|
118
|
+
}, [detectFaces, handleFaces, faceDetection.enabled]);
|
|
119
|
+
return Object.assign(Object.assign({}, webrtc), {
|
|
120
|
+
// Face detection
|
|
121
|
+
faces,
|
|
122
|
+
detectFaces,
|
|
123
|
+
// Eye tracking
|
|
124
|
+
eyeStatus,
|
|
125
|
+
processEyeStatus,
|
|
126
|
+
resetEyeStatus,
|
|
127
|
+
// Combined handler
|
|
128
|
+
processFrame });
|
|
129
|
+
}
|
|
130
|
+
// Types are exported from the interface definition above
|
|
131
|
+
//# sourceMappingURL=useWebRTCWithDetection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useWebRTCWithDetection.js","sourceRoot":"","sources":["../../src/hooks/useWebRTCWithDetection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;;;;;;;;;;;;AAEH,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAqB,MAAM,OAAO,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAExD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAkCxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,MAAM,UAAU,sBAAsB,CACpC,UAAyC,EAAE;;IAE3C,MAAM,EACJ,aAAa,GAAG,EAAE,EAClB,WAAW,GAAG,EAAE,KAEd,OAAO,EADN,aAAa,UACd,OAAO,EAJL,gCAIL,CAAU,CAAC;IAEZ,cAAc;IACd,MAAM,MAAM,GAAG,SAAS,CAAC,aAAa,C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