gravix-rtc-react-native 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +134 -0
- package/LICENSE +20 -0
- package/LICENSES/Apache-2.0.txt +175 -0
- package/NOTICE +68 -0
- package/README.md +313 -2
- package/android/build.gradle +137 -0
- package/android/consumer-rules.pro +29 -0
- package/android/src/main/AndroidManifest.xml +9 -0
- package/android/src/main/cpp/CMakeLists.txt +48 -0
- package/android/src/main/cpp/gx_dfn_engine.c +332 -0
- package/android/src/main/cpp/gx_fx_jni.cpp +34 -0
- package/android/src/main/cpp/gx_ns_jni.c +162 -0
- package/android/src/main/cpp/third_party/onnxruntime/LICENSE +21 -0
- package/android/src/main/cpp/third_party/onnxruntime/include/onnxruntime_c_api.h +9227 -0
- package/android/src/main/cpp/third_party/onnxruntime/include/onnxruntime_ep_c_api.h +3315 -0
- package/android/src/main/cpp/third_party/onnxruntime/include/onnxruntime_error_code.h +98 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/GravixAudioHooks.kt +144 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/GravixAudioModule.kt +105 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/GravixNativeAudio.kt +310 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/GravixRtc.kt +134 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/GravixRtcModule.kt +176 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/GravixRtcPackage.kt +39 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/audio/AudioDeviceKind.java +44 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/audio/AudioManagerUtils.kt +120 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/audio/AudioSwitchManager.java +270 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/audio/AudioType.kt +50 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/music/MusicCaptureRouter.kt +375 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/music/MusicDecoder.kt +339 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/music/MusicInterruptionWatcher.kt +82 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/music/MusicMicRelease.kt +117 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/music/MusicMixKernel.kt +191 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/music/MusicMixerEngine.kt +617 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/AudioRoutePolicy.kt +137 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GravixCaptureProcessing.kt +67 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GxCaptureDump.kt +143 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GxCaptureSwitcher.kt +196 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GxNoiseProcessor.kt +795 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GxNsLogic.kt +180 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GxNsNative.kt +83 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GxNsStudio.kt +372 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GxRecordStartGuard.kt +76 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GxRecorderSeam.kt +434 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GxSingerSource.kt +37 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GxVoiceFx.kt +160 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/OtherAppAudioPolicy.kt +143 -0
- package/android/src/main/java/org/webrtc/audio/WebRtcAudioTrackHelper.kt +43 -0
- package/docs/ANDROID_NATIVE_HOOKS.md +102 -0
- package/docs/FEATURE_MATRIX.md +192 -0
- package/docs/IOS_NATIVE_HOOKS.md +190 -0
- package/gravix-rtc-react-native.podspec +49 -0
- package/ios/GravixRtc.h +7 -0
- package/ios/GravixRtc.mm +273 -0
- package/ios/GravixRtcSetup.h +29 -0
- package/ios/GravixRtcSetup.m +52 -0
- package/ios/audio/GravixRtcIosAudio.m +157 -0
- package/ios/audio/GxAudioDevice.h +62 -0
- package/ios/audio/GxAudioDevice.m +857 -0
- package/ios/audio/GxAudioSetup.h +34 -0
- package/ios/audio/GxAudioSetup.m +70 -0
- package/ios/audio/GxCompat.swift +53 -0
- package/ios/audio/GxIosAudio.swift +99 -0
- package/ios/audio/GxMusicController.swift +150 -0
- package/ios/audio/GxMusicPost.swift +362 -0
- package/ios/audio/GxNoiseProcessor.swift +718 -0
- package/ios/audio/GxNsDfn3CoreML.swift +195 -0
- package/ios/audio/GxNsStudioEngine.swift +237 -0
- package/ios/audio/GxNsStudioPack.swift +212 -0
- package/ios/audio/GxVoiceFx.swift +161 -0
- package/ios/audio/gx_adm_state.h +153 -0
- package/ios/gxcore/apple/gx_music_post.c +312 -0
- package/ios/gxcore/apple/gx_pcm.c +30 -0
- package/ios/gxcore/apple/gxns_build.h +19 -0
- package/ios/gxcore/apple/gxns_ios.c +17 -0
- package/ios/gxcore/apple/include/gx_fx.h +3 -0
- package/ios/gxcore/apple/include/gx_music_post.h +88 -0
- package/ios/gxcore/apple/include/gx_ns.h +3 -0
- package/ios/gxcore/apple/include/gx_pcm.h +33 -0
- package/ios/gxcore/apple/include/gxns_ios.h +18 -0
- package/ios/gxcore/apple/include/module.modulemap +10 -0
- package/ios/gxcore/apple/shim/rnnoise.h +2 -0
- package/ios/gxcore/apple/shim/speex_resampler.h +2 -0
- package/ios/gxcore/apple/units/gx_fx_forward.cpp +3 -0
- package/ios/gxcore/apple/units/gx_ns.c +7 -0
- package/ios/gxcore/apple/units/gx_ns_timer.c +7 -0
- package/ios/gxcore/apple/units/rnnoise_celt_lpc.c +7 -0
- package/ios/gxcore/apple/units/rnnoise_denoise.c +7 -0
- package/ios/gxcore/apple/units/rnnoise_kiss_fft.c +7 -0
- package/ios/gxcore/apple/units/rnnoise_pitch.c +7 -0
- package/ios/gxcore/apple/units/rnnoise_rnn.c +7 -0
- package/ios/gxcore/apple/units/rnnoise_rnn_data.c +7 -0
- package/ios/gxcore/apple/units/speexdsp_resample.c +7 -0
- package/ios/resources/ns/DFN3-NOTICE.txt +10 -0
- package/ios/resources/ns/DeepFilterNet-LICENSE-APACHE +201 -0
- package/ios/resources/ns/DeepFilterNet-LICENSE-MIT +19 -0
- package/ios/resources/ns/gxns_dfn3.mlmodelc/analytics/coremldata.bin +0 -0
- package/ios/resources/ns/gxns_dfn3.mlmodelc/coremldata.bin +0 -0
- package/ios/resources/ns/gxns_dfn3.mlmodelc/metadata.json +338 -0
- package/ios/resources/ns/gxns_dfn3.mlmodelc/model.mil +927 -0
- package/ios/resources/ns/gxns_dfn3.mlmodelc/weights/weight.bin +0 -0
- package/lib/module/android/bindings.js +49 -0
- package/lib/module/android/bindings.js.map +1 -0
- package/lib/module/android/index.js +13 -0
- package/lib/module/android/index.js.map +1 -0
- package/lib/module/android/micMute.js +341 -0
- package/lib/module/android/micMute.js.map +1 -0
- package/lib/module/android/nativeAudio.js +47 -0
- package/lib/module/android/nativeAudio.js.map +1 -0
- package/lib/module/android/noiseSuppression.js +170 -0
- package/lib/module/android/noiseSuppression.js.map +1 -0
- package/lib/module/android/roomMusic.js +142 -0
- package/lib/module/android/roomMusic.js.map +1 -0
- package/lib/module/android/singerMode.js +31 -0
- package/lib/module/android/singerMode.js.map +1 -0
- package/lib/module/android/voiceEffects.js +65 -0
- package/lib/module/android/voiceEffects.js.map +1 -0
- package/lib/module/audio/AudioManager.js +79 -0
- package/lib/module/audio/AudioManager.js.map +1 -0
- package/lib/module/audio/AudioSession.js +90 -0
- package/lib/module/audio/AudioSession.js.map +1 -0
- package/lib/module/audio/remoteVolume.js +54 -0
- package/lib/module/audio/remoteVolume.js.map +1 -0
- package/lib/module/components/VideoView.js +109 -0
- package/lib/module/components/VideoView.js.map +1 -0
- package/lib/module/features/audioScenario.js +53 -0
- package/lib/module/features/audioScenario.js.map +1 -0
- package/lib/module/features/beauty.js +828 -0
- package/lib/module/features/beauty.js.map +1 -0
- package/lib/module/features/micRelease.js +89 -0
- package/lib/module/features/micRelease.js.map +1 -0
- package/lib/module/features/noiseSuppression.js +213 -0
- package/lib/module/features/noiseSuppression.js.map +1 -0
- package/lib/module/features/roomMusic.js +90 -0
- package/lib/module/features/roomMusic.js.map +1 -0
- package/lib/module/features/roomMusicAndroid.js +294 -0
- package/lib/module/features/roomMusicAndroid.js.map +1 -0
- package/lib/module/features/roomMusicIos.js +250 -0
- package/lib/module/features/roomMusicIos.js.map +1 -0
- package/lib/module/features/roomMusicTypes.js +53 -0
- package/lib/module/features/roomMusicTypes.js.map +1 -0
- package/lib/module/features/screenShare.js +22 -0
- package/lib/module/features/screenShare.js.map +1 -0
- package/lib/module/features/singerMode.js +73 -0
- package/lib/module/features/singerMode.js.map +1 -0
- package/lib/module/features/voiceEffects.js +148 -0
- package/lib/module/features/voiceEffects.js.map +1 -0
- package/lib/module/hooks/context.js +34 -0
- package/lib/module/hooks/context.js.map +1 -0
- package/lib/module/hooks/hooks.js +145 -0
- package/lib/module/hooks/hooks.js.map +1 -0
- package/lib/module/hooks/types.js +4 -0
- package/lib/module/hooks/types.js.map +1 -0
- package/lib/module/hooks/useRoomEvents.js +30 -0
- package/lib/module/hooks/useRoomEvents.js.map +1 -0
- package/lib/module/index.js +43 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/ios/autoAttach.js +14 -0
- package/lib/module/ios/autoAttach.js.map +1 -0
- package/lib/module/ios/iosAudio.js +149 -0
- package/lib/module/ios/iosAudio.js.map +1 -0
- package/lib/module/join/appStateLifecycle.js +54 -0
- package/lib/module/join/appStateLifecycle.js.map +1 -0
- package/lib/module/micPolicy.js +249 -0
- package/lib/module/micPolicy.js.map +1 -0
- package/lib/module/native/NativeGravixAudio.js +18 -0
- package/lib/module/native/NativeGravixAudio.js.map +1 -0
- package/lib/module/native/NativeGravixRtc.js +13 -0
- package/lib/module/native/NativeGravixRtc.js.map +1 -0
- package/lib/module/native/module.js +23 -0
- package/lib/module/native/module.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/polyfills/DOMException.js +22 -0
- package/lib/module/polyfills/DOMException.js.map +1 -0
- package/lib/module/polyfills/early.js +18 -0
- package/lib/module/polyfills/early.js.map +1 -0
- package/lib/module/polyfills/event.js +71 -0
- package/lib/module/polyfills/event.js.map +1 -0
- package/lib/module/polyfills/sha256.js +92 -0
- package/lib/module/polyfills/sha256.js.map +1 -0
- package/lib/module/polyfills/subtleHmac.js +91 -0
- package/lib/module/polyfills/subtleHmac.js.map +1 -0
- package/lib/module/polyfills/textCoding.js +164 -0
- package/lib/module/polyfills/textCoding.js.map +1 -0
- package/lib/module/registerGlobals.js +135 -0
- package/lib/module/registerGlobals.js.map +1 -0
- package/lib/module/unsupported.js +90 -0
- package/lib/module/unsupported.js.map +1 -0
- package/lib/module/version.js +7 -0
- package/lib/module/version.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/android/bindings.d.ts +14 -0
- package/lib/typescript/src/android/bindings.d.ts.map +1 -0
- package/lib/typescript/src/android/index.d.ts +9 -0
- package/lib/typescript/src/android/index.d.ts.map +1 -0
- package/lib/typescript/src/android/micMute.d.ts +124 -0
- package/lib/typescript/src/android/micMute.d.ts.map +1 -0
- package/lib/typescript/src/android/nativeAudio.d.ts +40 -0
- package/lib/typescript/src/android/nativeAudio.d.ts.map +1 -0
- package/lib/typescript/src/android/noiseSuppression.d.ts +48 -0
- package/lib/typescript/src/android/noiseSuppression.d.ts.map +1 -0
- package/lib/typescript/src/android/roomMusic.d.ts +80 -0
- package/lib/typescript/src/android/roomMusic.d.ts.map +1 -0
- package/lib/typescript/src/android/singerMode.d.ts +27 -0
- package/lib/typescript/src/android/singerMode.d.ts.map +1 -0
- package/lib/typescript/src/android/voiceEffects.d.ts +30 -0
- package/lib/typescript/src/android/voiceEffects.d.ts.map +1 -0
- package/lib/typescript/src/audio/AudioManager.d.ts +32 -0
- package/lib/typescript/src/audio/AudioManager.d.ts.map +1 -0
- package/lib/typescript/src/audio/AudioSession.d.ts +70 -0
- package/lib/typescript/src/audio/AudioSession.d.ts.map +1 -0
- package/lib/typescript/src/audio/remoteVolume.d.ts +8 -0
- package/lib/typescript/src/audio/remoteVolume.d.ts.map +1 -0
- package/lib/typescript/src/components/VideoView.d.ts +44 -0
- package/lib/typescript/src/components/VideoView.d.ts.map +1 -0
- package/lib/typescript/src/features/audioScenario.d.ts +24 -0
- package/lib/typescript/src/features/audioScenario.d.ts.map +1 -0
- package/lib/typescript/src/features/beauty.d.ts +377 -0
- package/lib/typescript/src/features/beauty.d.ts.map +1 -0
- package/lib/typescript/src/features/micRelease.d.ts +28 -0
- package/lib/typescript/src/features/micRelease.d.ts.map +1 -0
- package/lib/typescript/src/features/noiseSuppression.d.ts +64 -0
- package/lib/typescript/src/features/noiseSuppression.d.ts.map +1 -0
- package/lib/typescript/src/features/roomMusic.d.ts +41 -0
- package/lib/typescript/src/features/roomMusic.d.ts.map +1 -0
- package/lib/typescript/src/features/roomMusicAndroid.d.ts +60 -0
- package/lib/typescript/src/features/roomMusicAndroid.d.ts.map +1 -0
- package/lib/typescript/src/features/roomMusicIos.d.ts +56 -0
- package/lib/typescript/src/features/roomMusicIos.d.ts.map +1 -0
- package/lib/typescript/src/features/roomMusicTypes.d.ts +76 -0
- package/lib/typescript/src/features/roomMusicTypes.d.ts.map +1 -0
- package/lib/typescript/src/features/screenShare.d.ts +12 -0
- package/lib/typescript/src/features/screenShare.d.ts.map +1 -0
- package/lib/typescript/src/features/singerMode.d.ts +20 -0
- package/lib/typescript/src/features/singerMode.d.ts.map +1 -0
- package/lib/typescript/src/features/voiceEffects.d.ts +46 -0
- package/lib/typescript/src/features/voiceEffects.d.ts.map +1 -0
- package/lib/typescript/src/hooks/context.d.ts +12 -0
- package/lib/typescript/src/hooks/context.d.ts.map +1 -0
- package/lib/typescript/src/hooks/hooks.d.ts +54 -0
- package/lib/typescript/src/hooks/hooks.d.ts.map +1 -0
- package/lib/typescript/src/hooks/types.d.ts +8 -0
- package/lib/typescript/src/hooks/types.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useRoomEvents.d.ts +13 -0
- package/lib/typescript/src/hooks/useRoomEvents.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +37 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/ios/autoAttach.d.ts +2 -0
- package/lib/typescript/src/ios/autoAttach.d.ts.map +1 -0
- package/lib/typescript/src/ios/iosAudio.d.ts +96 -0
- package/lib/typescript/src/ios/iosAudio.d.ts.map +1 -0
- package/lib/typescript/src/join/appStateLifecycle.d.ts +14 -0
- package/lib/typescript/src/join/appStateLifecycle.d.ts.map +1 -0
- package/lib/typescript/src/micPolicy.d.ts +104 -0
- package/lib/typescript/src/micPolicy.d.ts.map +1 -0
- package/lib/typescript/src/native/NativeGravixAudio.d.ts +21 -0
- package/lib/typescript/src/native/NativeGravixAudio.d.ts.map +1 -0
- package/lib/typescript/src/native/NativeGravixRtc.d.ts +31 -0
- package/lib/typescript/src/native/NativeGravixRtc.d.ts.map +1 -0
- package/lib/typescript/src/native/module.d.ts +7 -0
- package/lib/typescript/src/native/module.d.ts.map +1 -0
- package/lib/typescript/src/polyfills/DOMException.d.ts +3 -0
- package/lib/typescript/src/polyfills/DOMException.d.ts.map +1 -0
- package/lib/typescript/src/polyfills/early.d.ts +2 -0
- package/lib/typescript/src/polyfills/early.d.ts.map +1 -0
- package/lib/typescript/src/polyfills/event.d.ts +2 -0
- package/lib/typescript/src/polyfills/event.d.ts.map +1 -0
- package/lib/typescript/src/polyfills/sha256.d.ts +3 -0
- package/lib/typescript/src/polyfills/sha256.d.ts.map +1 -0
- package/lib/typescript/src/polyfills/subtleHmac.d.ts +37 -0
- package/lib/typescript/src/polyfills/subtleHmac.d.ts.map +1 -0
- package/lib/typescript/src/polyfills/textCoding.d.ts +36 -0
- package/lib/typescript/src/polyfills/textCoding.d.ts.map +1 -0
- package/lib/typescript/src/registerGlobals.d.ts +42 -0
- package/lib/typescript/src/registerGlobals.d.ts.map +1 -0
- package/lib/typescript/src/unsupported.d.ts +42 -0
- package/lib/typescript/src/unsupported.d.ts.map +1 -0
- package/lib/typescript/src/version.d.ts +3 -0
- package/lib/typescript/src/version.d.ts.map +1 -0
- package/metro/index.js +39 -0
- package/metro/noise-stub.js +10 -0
- package/native/gxfx/include/gx_fx.h +82 -0
- package/native/gxfx/src/gx_fx.cpp +527 -0
- package/native/gxfx/third_party/README.md +4 -0
- package/native/gxfx/third_party/signalsmith-linear/LICENSE.txt +21 -0
- package/native/gxfx/third_party/signalsmith-linear/approx.h +191 -0
- package/native/gxfx/third_party/signalsmith-linear/fft.h +1386 -0
- package/native/gxfx/third_party/signalsmith-linear/linear.h +1129 -0
- package/native/gxfx/third_party/signalsmith-linear/platform/approx-cmsisdsp.h +40 -0
- package/native/gxfx/third_party/signalsmith-linear/platform/basic-fill-warnings.h +61 -0
- package/native/gxfx/third_party/signalsmith-linear/platform/fft-accelerate.h +340 -0
- package/native/gxfx/third_party/signalsmith-linear/platform/fft-cmsisdsp.h +307 -0
- package/native/gxfx/third_party/signalsmith-linear/platform/fft-ipp.h +532 -0
- package/native/gxfx/third_party/signalsmith-linear/platform/fft-linear.h +213 -0
- package/native/gxfx/third_party/signalsmith-linear/platform/fft-pffft-double.h +221 -0
- package/native/gxfx/third_party/signalsmith-linear/platform/fft-pffft.h +221 -0
- package/native/gxfx/third_party/signalsmith-linear/platform/linear-accelerate.h +593 -0
- package/native/gxfx/third_party/signalsmith-linear/platform/linear-cmsisdsp.h +713 -0
- package/native/gxfx/third_party/signalsmith-linear/platform/linear-xsimd-dispatch.cpp +6 -0
- package/native/gxfx/third_party/signalsmith-linear/platform/linear-xsimd.h +818 -0
- package/native/gxfx/third_party/signalsmith-linear/stft.h +700 -0
- package/native/gxfx/third_party/signalsmith-stretch-LICENSE.txt +21 -0
- package/native/gxfx/third_party/signalsmith-stretch.h +1060 -0
- package/native/gxns/CMakeLists.txt +67 -0
- package/native/gxns/include/gx_ns.h +285 -0
- package/native/gxns/src/gx_ns.c +1518 -0
- package/native/gxns/src/gx_ns_timer.c +84 -0
- package/native/gxns/src/gx_ns_timer.h +29 -0
- package/native/gxns/third_party/VENDOR.md +43 -0
- package/native/gxns/third_party/rnnoise/AUTHORS +1 -0
- package/native/gxns/third_party/rnnoise/COPYING +31 -0
- package/native/gxns/third_party/rnnoise/include/rnnoise.h +117 -0
- package/native/gxns/third_party/rnnoise/src/_kiss_fft_guts.h +182 -0
- package/native/gxns/third_party/rnnoise/src/arch.h +261 -0
- package/native/gxns/third_party/rnnoise/src/celt_lpc.c +172 -0
- package/native/gxns/third_party/rnnoise/src/celt_lpc.h +45 -0
- package/native/gxns/third_party/rnnoise/src/common.h +48 -0
- package/native/gxns/third_party/rnnoise/src/denoise.c +664 -0
- package/native/gxns/third_party/rnnoise/src/kiss_fft.c +601 -0
- package/native/gxns/third_party/rnnoise/src/kiss_fft.h +203 -0
- package/native/gxns/third_party/rnnoise/src/opus_types.h +159 -0
- package/native/gxns/third_party/rnnoise/src/pitch.c +523 -0
- package/native/gxns/third_party/rnnoise/src/pitch.h +149 -0
- package/native/gxns/third_party/rnnoise/src/rnn.c +178 -0
- package/native/gxns/third_party/rnnoise/src/rnn.h +65 -0
- package/native/gxns/third_party/rnnoise/src/rnn_data.c +11051 -0
- package/native/gxns/third_party/rnnoise/src/rnn_data.h +34 -0
- package/native/gxns/third_party/rnnoise/src/tansig_table.h +45 -0
- package/native/gxns/third_party/speexdsp/AUTHORS +18 -0
- package/native/gxns/third_party/speexdsp/COPYING +35 -0
- package/native/gxns/third_party/speexdsp/arch.h +232 -0
- package/native/gxns/third_party/speexdsp/resample.c +1239 -0
- package/native/gxns/third_party/speexdsp/resample_neon.h +339 -0
- package/native/gxns/third_party/speexdsp/resample_sse.h +128 -0
- package/native/gxns/third_party/speexdsp/speex_resampler.h +343 -0
- package/package.json +186 -4
- package/src/android/bindings.ts +61 -0
- package/src/android/index.ts +10 -0
- package/src/android/micMute.ts +422 -0
- package/src/android/nativeAudio.ts +94 -0
- package/src/android/noiseSuppression.ts +209 -0
- package/src/android/roomMusic.ts +193 -0
- package/src/android/singerMode.ts +53 -0
- package/src/android/voiceEffects.ts +126 -0
- package/src/audio/AudioManager.ts +111 -0
- package/src/audio/AudioSession.ts +190 -0
- package/src/audio/remoteVolume.ts +58 -0
- package/src/components/VideoView.tsx +152 -0
- package/src/features/audioScenario.ts +58 -0
- package/src/features/beauty.ts +1057 -0
- package/src/features/micRelease.ts +108 -0
- package/src/features/noiseSuppression.ts +251 -0
- package/src/features/roomMusic.ts +106 -0
- package/src/features/roomMusicAndroid.ts +310 -0
- package/src/features/roomMusicIos.ts +300 -0
- package/src/features/roomMusicTypes.ts +97 -0
- package/src/features/screenShare.ts +19 -0
- package/src/features/singerMode.ts +70 -0
- package/src/features/voiceEffects.ts +245 -0
- package/src/hooks/context.tsx +38 -0
- package/src/hooks/hooks.ts +247 -0
- package/src/hooks/types.ts +10 -0
- package/src/hooks/useRoomEvents.ts +35 -0
- package/src/index.tsx +134 -0
- package/src/ios/autoAttach.ts +11 -0
- package/src/ios/iosAudio.ts +202 -0
- package/src/join/appStateLifecycle.ts +55 -0
- package/src/micPolicy.ts +312 -0
- package/src/native/NativeGravixAudio.ts +30 -0
- package/src/native/NativeGravixRtc.ts +38 -0
- package/src/native/module.ts +22 -0
- package/src/polyfills/DOMException.ts +20 -0
- package/src/polyfills/early.ts +16 -0
- package/src/polyfills/event.ts +88 -0
- package/src/polyfills/sha256.ts +112 -0
- package/src/polyfills/subtleHmac.ts +124 -0
- package/src/polyfills/textCoding.ts +197 -0
- package/src/registerGlobals.ts +201 -0
- package/src/unsupported.ts +139 -0
- package/src/version.ts +4 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// Copyright (c) 2026 Gravity Compile. MIT License; see LICENSE.
|
|
4
|
+
|
|
5
|
+
import { asMap, requireBridge } from "./nativeAudio.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Karaoke / room music on Android: a local file or content URI decoded
|
|
9
|
+
* natively and mixed INTO the published microphone (one stream, no second
|
|
10
|
+
* track, no server bot), with the host's local monitor, mic volume, ducking,
|
|
11
|
+
* loop and seek. Port of the Flutter SDK's `GravixRoomMusic` native layer
|
|
12
|
+
* (`MusicMixerEngine`, channel `com.gravitycompile.gravix_rtc/music`).
|
|
13
|
+
*
|
|
14
|
+
* Needs a running microphone capture (publish the mic first):
|
|
15
|
+
* `CAPTURE_NOT_READY` otherwise.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
export const DEFAULT_ANDROID_MUSIC_OPTIONS = {
|
|
19
|
+
musicVolume: 1,
|
|
20
|
+
micVolume: 1,
|
|
21
|
+
ducking: false,
|
|
22
|
+
duckLevel: 0.35,
|
|
23
|
+
loop: false,
|
|
24
|
+
monitor: true,
|
|
25
|
+
continueWhileMicMuted: true,
|
|
26
|
+
continueWhileMicReleased: true,
|
|
27
|
+
pauseOnInterruption: true
|
|
28
|
+
};
|
|
29
|
+
const clamp01 = v => Number.isFinite(v) ? Math.min(1, Math.max(0, v)) : 1;
|
|
30
|
+
|
|
31
|
+
/** The `music.start` arguments (Flutter MusicMixerPlugin keys). */
|
|
32
|
+
export function musicStartArgs(source, o = {}) {
|
|
33
|
+
const m = {
|
|
34
|
+
...DEFAULT_ANDROID_MUSIC_OPTIONS,
|
|
35
|
+
...o
|
|
36
|
+
};
|
|
37
|
+
return {
|
|
38
|
+
source,
|
|
39
|
+
contentUri: source.startsWith('content://'),
|
|
40
|
+
loop: m.loop,
|
|
41
|
+
monitor: m.monitor,
|
|
42
|
+
musicVolume: clamp01(m.musicVolume),
|
|
43
|
+
micVolume: clamp01(m.micVolume),
|
|
44
|
+
ducking: m.ducking,
|
|
45
|
+
duckLevel: clamp01(m.duckLevel),
|
|
46
|
+
holdOnMute: !m.continueWhileMicMuted,
|
|
47
|
+
pauseOnInterruption: m.pauseOnInterruption
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** One room-music session at a time (the native mixer is process-wide). */
|
|
52
|
+
export class GravixAndroidRoomMusic {
|
|
53
|
+
constructor(options = {}) {
|
|
54
|
+
this.options = {
|
|
55
|
+
...DEFAULT_ANDROID_MUSIC_OPTIONS,
|
|
56
|
+
...options
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
get currentOptions() {
|
|
60
|
+
return this.options;
|
|
61
|
+
}
|
|
62
|
+
call(method, args) {
|
|
63
|
+
return requireBridge('roomMusic').call(`music.${method}`, args);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Starts [source] (file path or content:// URI), replacing a running one. Returns the duration (ms, -1 unknown). */
|
|
67
|
+
async start(source, options = {}) {
|
|
68
|
+
this.options = {
|
|
69
|
+
...this.options,
|
|
70
|
+
...options
|
|
71
|
+
};
|
|
72
|
+
const r = asMap(await this.call('start', musicStartArgs(source, this.options)));
|
|
73
|
+
return typeof r?.durationMs === 'number' ? r.durationMs : -1;
|
|
74
|
+
}
|
|
75
|
+
pause() {
|
|
76
|
+
return this.call('pause');
|
|
77
|
+
}
|
|
78
|
+
resume() {
|
|
79
|
+
return this.call('resume');
|
|
80
|
+
}
|
|
81
|
+
stop() {
|
|
82
|
+
return this.call('stop');
|
|
83
|
+
}
|
|
84
|
+
seek(positionMs) {
|
|
85
|
+
return this.call('seek', {
|
|
86
|
+
positionMs: Math.max(0, Math.round(positionMs))
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
setMusicVolume(volume) {
|
|
90
|
+
this.options.musicVolume = clamp01(volume);
|
|
91
|
+
return this.call('setMusicVolume', {
|
|
92
|
+
volume: this.options.musicVolume
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
setMicVolume(volume) {
|
|
96
|
+
this.options.micVolume = clamp01(volume);
|
|
97
|
+
return this.call('setMicVolume', {
|
|
98
|
+
volume: this.options.micVolume
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
setDucking(on, level) {
|
|
102
|
+
this.options.ducking = on;
|
|
103
|
+
if (level !== undefined) this.options.duckLevel = clamp01(level);
|
|
104
|
+
return this.call('setDucking', {
|
|
105
|
+
on,
|
|
106
|
+
level: this.options.duckLevel
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
setLoop(on) {
|
|
110
|
+
this.options.loop = on;
|
|
111
|
+
return this.call('setLoop', {
|
|
112
|
+
on
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
/** continueWhileMicMuted / pauseOnInterruption at runtime. */
|
|
116
|
+
configure(o) {
|
|
117
|
+
this.options = {
|
|
118
|
+
...this.options,
|
|
119
|
+
...o
|
|
120
|
+
};
|
|
121
|
+
return this.call('configure', {
|
|
122
|
+
holdOnMute: !this.options.continueWhileMicMuted,
|
|
123
|
+
pauseOnInterruption: this.options.pauseOnInterruption
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
async isActive() {
|
|
127
|
+
return (await this.call('isActive')) === true;
|
|
128
|
+
}
|
|
129
|
+
async getState() {
|
|
130
|
+
return asMap(await this.call('getState'));
|
|
131
|
+
}
|
|
132
|
+
onCompleted(l) {
|
|
133
|
+
return requireBridge('roomMusic').addListener('music.onCompleted', () => l());
|
|
134
|
+
}
|
|
135
|
+
onError(l) {
|
|
136
|
+
return requireBridge('roomMusic').addListener('music.onError', l);
|
|
137
|
+
}
|
|
138
|
+
onInterruption(l) {
|
|
139
|
+
return requireBridge('roomMusic').addListener('music.onInterruption', l);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=roomMusic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["asMap","requireBridge","DEFAULT_ANDROID_MUSIC_OPTIONS","musicVolume","micVolume","ducking","duckLevel","loop","monitor","continueWhileMicMuted","continueWhileMicReleased","pauseOnInterruption","clamp01","v","Number","isFinite","Math","min","max","musicStartArgs","source","o","m","contentUri","startsWith","holdOnMute","GravixAndroidRoomMusic","constructor","options","currentOptions","call","method","args","start","r","durationMs","pause","resume","stop","seek","positionMs","round","setMusicVolume","volume","setMicVolume","setDucking","on","level","undefined","setLoop","configure","isActive","getState","onCompleted","l","addListener","onError","onInterruption"],"sourceRoot":"../../../src","sources":["android/roomMusic.ts"],"mappings":";;AAAA;;AAEA,SACEA,KAAK,EACLC,aAAa,QAER,kBAAe;;AAEtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA6BA,OAAO,MAAMC,6BAAkE,GAC7E;EACEC,WAAW,EAAE,CAAC;EACdC,SAAS,EAAE,CAAC;EACZC,OAAO,EAAE,KAAK;EACdC,SAAS,EAAE,IAAI;EACfC,IAAI,EAAE,KAAK;EACXC,OAAO,EAAE,IAAI;EACbC,qBAAqB,EAAE,IAAI;EAC3BC,wBAAwB,EAAE,IAAI;EAC9BC,mBAAmB,EAAE;AACvB,CAAC;AAiBH,MAAMC,OAAO,GAAIC,CAAS,IACxBC,MAAM,CAACC,QAAQ,CAACF,CAAC,CAAC,GAAGG,IAAI,CAACC,GAAG,CAAC,CAAC,EAAED,IAAI,CAACE,GAAG,CAAC,CAAC,EAAEL,CAAC,CAAC,CAAC,GAAG,CAAC;;AAEtD;AACA,OAAO,SAASM,cAAcA,CAC5BC,MAAc,EACdC,CAA4B,GAAG,CAAC,CAAC,EACR;EACzB,MAAMC,CAAC,GAAG;IAAE,GAAGpB,6BAA6B;IAAE,GAAGmB;EAAE,CAAC;EACpD,OAAO;IACLD,MAAM;IACNG,UAAU,EAAEH,MAAM,CAACI,UAAU,CAAC,YAAY,CAAC;IAC3CjB,IAAI,EAAEe,CAAC,CAACf,IAAI;IACZC,OAAO,EAAEc,CAAC,CAACd,OAAO;IAClBL,WAAW,EAAES,OAAO,CAACU,CAAC,CAACnB,WAAW,CAAC;IACnCC,S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;EACA;EACAI,SAASA,CACP7B,CAKC,EACiB;IAClB,IAAI,CAACO,OAAO,GAAG;MAAE,GAAG,IAAI,CAACA,OAAO;MAAE,GAAGP;IAAE,CAAC;IACxC,OAAO,IAAI,CAACS,IAAI,CAAC,WAAW,EAAE;MAC5BL,UAAU,EAAE,CAAC,IAAI,CAACG,OAAO,CAACnB,qBAAqB;MAC/CE,mBAAmB,EAAE,IAAI,CAACiB,OAAO,CAACjB;IACpC,CAAC,CAAC;EACJ;EACA,MAAMwC,QAAQA,CAAA,EAAqB;IACjC,OAAO,CAAC,MAAM,IAAI,CAACrB,IAAI,CAAC,UAAU,CAAC,MAAM,IAAI;EAC/C;EACA,MAAMsB,QAAQA,CAAA,EAA2C;IACvD,OAAOpD,KAAK,CAAC,MAAM,IAAI,CAAC8B,IAAI,CAAC,UAAU,CAAC,CAAC;EAC3C;EAEAuB,WAAWA,CAACC,CAAa,EAAc;IACrC,OAAOrD,aAAa,CAAC,WAAW,CAAC,CAACsD,WAAW,CAAC,mBAAmB,EAAE,MACjED,CAAC,CAAC,CACJ,CAAC;EACH;EACAE,OAAOA,CAACF,CAA6B,EAAc;IACjD,OAAOrD,aAAa,CAAC,WAAW,CAAC,CAACsD,WAAW,CAAC,eAAe,EAAED,CAAC,CAAC;EACnE;EACAG,cAAcA,CAACH,CAA6B,EAAc;IACxD,OAAOrD,aAAa,CAAC,WAAW,CAAC,CAACsD,WAAW,CAAC,sBAAsB,EAAED,CAAC,CAAC;EAC1E;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// Copyright (c) 2026 Gravity Compile. MIT License; see LICENSE.
|
|
4
|
+
|
|
5
|
+
import { asMap, requireBridge } from "./nativeAudio.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The Android-native half of singer mode (Flutter `nsSetSingerMode`): our
|
|
9
|
+
* NS / AGC / pause expander bypassed (limiter near clip kept), the singer
|
|
10
|
+
* level normaliser, and WebRTC's recorder re-opened with the singer capture
|
|
11
|
+
* source (no audio device module rebuild). The browser-style half (WebRTC
|
|
12
|
+
* processing off, bitrate, DTX) is the gravix-rtc core's `room.setSingerMode`.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export async function setAndroidSingerMode(on, o = {}) {
|
|
16
|
+
const {
|
|
17
|
+
source = 'mic',
|
|
18
|
+
...level
|
|
19
|
+
} = o;
|
|
20
|
+
const r = asMap(await requireBridge('singerMode').call('nsSetSingerMode', {
|
|
21
|
+
on,
|
|
22
|
+
source,
|
|
23
|
+
...level
|
|
24
|
+
})) ?? {};
|
|
25
|
+
return {
|
|
26
|
+
ok: r.ok === true,
|
|
27
|
+
sourceRequested: typeof r.sourceRequested === 'number' ? r.sourceRequested : null,
|
|
28
|
+
unprocessedSupported: r.unprocessedSupported === true
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=singerMode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["asMap","requireBridge","setAndroidSingerMode","on","o","source","level","r","call","ok","sourceRequested","unprocessedSupported"],"sourceRoot":"../../../src","sources":["android/singerMode.ts"],"mappings":";;AAAA;;AAEA,SAASA,KAAK,EAAEC,aAAa,QAAQ,kBAAe;;AAEpD;AACA;AACA;AACA;AACA;AACA;AACA;;AAuBA,OAAO,eAAeC,oBAAoBA,CACxCC,EAAW,EACXC,CAA6B,GAAG,CAAC,CAAC,EACE;EACpC,MAAM;IAAEC,MAAM,GAAG,KAAK;IAAE,GAAGC;EAAM,CAAC,GAAGF,CAAC;EACtC,MAAMG,CAAC,GACLP,KAAK,CACH,MAAMC,aAAa,CAAC,YAAY,CAAC,CAACO,IAAI,CAAC,iBAAiB,EAAE;IACxDL,EAAE;IACFE,MAAM;IACN,GAAGC;EACL,CAAC,CACH,CAAC,IAAI,CAAC,CAAC;EACT,OAAO;IACLG,EAAE,EAAEF,CAAC,CAACE,EAAE,KAAK,IAAI;IACjBC,eAAe,EACb,OAAOH,CAAC,CAACG,eAAe,KAAK,QAAQ,GAAGH,CAAC,CAACG,eAAe,GAAG,IAAI;IAClEC,oBAAoB,EAAEJ,CAAC,CAACI,oBAAoB,KAAK;EACnD,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// Copyright (c) 2026 Gravity Compile. MIT License; see LICENSE.
|
|
4
|
+
|
|
5
|
+
import { asMap, requireBridge } from "./nativeAudio.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Voice effects on the published microphone (Android, native gxfx): the same
|
|
9
|
+
* 35 presets + `none` as the Flutter, Android and web SDKs, in the same order.
|
|
10
|
+
* Runs after noise suppression on WebRTC's capture post-processing slot; room
|
|
11
|
+
* music is mixed after the effect while one is on.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Same set and order as `GRAVIX_VOICE_EFFECTS` in `gravix-rtc/noise` and
|
|
16
|
+
* `GxVoiceFx.PRESETS` (the index is the engine's preset number). Kept here so
|
|
17
|
+
* the React Native bundle never loads the web WASM / worklet module; a test
|
|
18
|
+
* pins it to both.
|
|
19
|
+
*/
|
|
20
|
+
export const GRAVIX_ANDROID_VOICE_EFFECTS = ['none', 'studio', 'hall', 'robot', 'girl', 'transformer', 'boy', 'child', 'woman', 'man', 'foreigner', 'ethereal', 'magnetic', 'fresh', 'energetic', 'rich', 'muffled', 'round', 'falsetto', 'full', 'clear', 'resonant', 'loudClear', 'softRoom', 'largeRoom', 'valley', 'basement', 'ktv', 'enhancedKtv', 'popular', 'rock', 'vocalConcert', 'gramophone', 'autotuneMajorC', 'autotuneMinorA', 'autotuneHarmonicMinor'];
|
|
21
|
+
export function isGravixVoiceEffect(v) {
|
|
22
|
+
return typeof v === 'string' && GRAVIX_ANDROID_VOICE_EFFECTS.includes(v);
|
|
23
|
+
}
|
|
24
|
+
export async function setAndroidVoiceEffect(effect) {
|
|
25
|
+
if (!isGravixVoiceEffect(effect)) return {
|
|
26
|
+
ok: false,
|
|
27
|
+
reason: 'unknown_effect'
|
|
28
|
+
};
|
|
29
|
+
const r = asMap(await requireBridge('voiceEffects').call('fxConfigure', {
|
|
30
|
+
effect
|
|
31
|
+
})) ?? {};
|
|
32
|
+
return {
|
|
33
|
+
ok: r.ok === true,
|
|
34
|
+
reason: typeof r.reason === 'string' ? r.reason : 'failed',
|
|
35
|
+
effect: isGravixVoiceEffect(r.effect) ? r.effect : undefined,
|
|
36
|
+
active: isGravixVoiceEffect(r.active) ? r.active : undefined,
|
|
37
|
+
installed: typeof r.installed === 'boolean' ? r.installed : undefined,
|
|
38
|
+
latencyMs: typeof r.latencyMs === 'number' ? r.latencyMs : undefined
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export async function androidVoiceEffectStats() {
|
|
42
|
+
const r = asMap(await requireBridge('voiceEffects').call('fxStats'));
|
|
43
|
+
if (!r || !isGravixVoiceEffect(r.effect)) return null;
|
|
44
|
+
return {
|
|
45
|
+
effect: r.effect,
|
|
46
|
+
active: isGravixVoiceEffect(r.active) ? r.active : r.effect,
|
|
47
|
+
rate: Number(r.rate ?? 0),
|
|
48
|
+
musicBypass: r.musicBypass === true,
|
|
49
|
+
watchdog: r.watchdog === true,
|
|
50
|
+
latencyMs: Number(r.latencyMs ?? 0),
|
|
51
|
+
frames: Number(r.frames ?? 0),
|
|
52
|
+
overBudget: Number(r.over ?? 0),
|
|
53
|
+
maxBlockUs: Number(r.maxUs ?? 0)
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Runs [effect] on a private chain, off the audio path (device capability check). */
|
|
58
|
+
export async function benchmarkAndroidVoiceEffect(effect = 'girl', rate = 48000, seconds = 5) {
|
|
59
|
+
return asMap(await requireBridge('voiceEffects').call('fxBenchmark', {
|
|
60
|
+
effect,
|
|
61
|
+
rate,
|
|
62
|
+
seconds
|
|
63
|
+
}));
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=voiceEffects.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["asMap","requireBridge","GRAVIX_ANDROID_VOICE_EFFECTS","isGravixVoiceEffect","v","includes","setAndroidVoiceEffect","effect","ok","reason","r","call","undefined","active","installed","latencyMs","androidVoiceEffectStats","rate","Number","musicBypass","watchdog","frames","overBudget","over","maxBlockUs","maxUs","benchmarkAndroidVoiceEffect","seconds"],"sourceRoot":"../../../src","sources":["android/voiceEffects.ts"],"mappings":";;AAAA;;AAMA,SAASA,KAAK,EAAEC,aAAa,QAAQ,kBAAe;;AAEpD;AACA;AACA;AACA;AACA;AACA;;AAYA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,4BAA0D,GAAG,CACxE,MAAM,EACN,QAAQ,EACR,MAAM,EACN,OAAO,EACP,MAAM,EACN,aAAa,EACb,KAAK,EACL,OAAO,EACP,OAAO,EACP,KAAK,EACL,WAAW,EACX,UAAU,EACV,UAAU,EACV,OAAO,EACP,WAAW,EACX,MAAM,EACN,SAAS,EACT,OAAO,EACP,UAAU,EACV,MAAM,EACN,OAAO,EACP,UAAU,EACV,WAAW,EACX,UAAU,EACV,WAAW,EACX,QAAQ,EACR,UAAU,EACV,KAAK,EACL,aAAa,EACb,SAAS,EACT,MAAM,EACN,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,uBAAuB,CACxB;AAED,OAAO,SAASC,mBAAmBA,CAACC,CAAU,EAA0B;EACtE,OACE,OAAOA,CAAC,KAAK,QAAQ,IACpBF,4BAA4B,CAAuBG,QAAQ,CAACD,CAAC,CAAC;AAEnE;AAEA,OAAO,eAAeE,qBAAqBA,CACzCC,MAAyB,EACS;EAClC,IAAI,CAACJ,mBAAmB,CAACI,MAAM,CAAC,EAC9B,OAAO;IAAEC,EAAE,EAAE,KAAK;IAAEC,MAAM,EAAE;EAAiB,CAAC;EAChD,MAA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,EAAEV,CAAC,CAACU,QAAQ,KAAK,IAAI;IAC7BL,SAAS,EAAEG,MAAM,CAACR,CAAC,CAACK,SAAS,IAAI,CAAC,CAAC;IACnCM,MAAM,EAAEH,MAAM,CAACR,CAAC,CAACW,MAAM,IAAI,CAAC,CAAC;IAC7BC,UAAU,EAAEJ,MAAM,CAACR,CAAC,CAACa,IAAI,IAAI,CAAC,CAAC;IAC/BC,UAAU,EAAEN,MAAM,CAACR,CAAC,CAACe,KAAK,IAAI,CAAC;EACjC,CAAC;AACH;;AAEA;AACA,OAAO,eAAeC,2BAA2BA,CAC/CnB,MAAyB,GAAG,MAAM,EAClCU,IAAI,GAAG,KAAK,EACZU,OAAO,GAAG,CAAC,EAC8B;EACzC,OAAO3B,KAAK,CACV,MAAMC,aAAa,CAAC,cAAc,CAAC,CAACU,IAAI,CAAC,aAAa,EAAE;IACtDJ,MAAM;IACNU,IAAI;IACJU;EACF,CAAC,CACH,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// Copyright 2023-2026 LiveKit, Inc.
|
|
4
|
+
// Modifications Copyright 2026 Gravity Compile.
|
|
5
|
+
// Licensed under the Apache License, Version 2.0; see LICENSES/Apache-2.0.txt.
|
|
6
|
+
|
|
7
|
+
import { Platform } from 'react-native';
|
|
8
|
+
import { nativeModuleOrNull } from "../native/module.js";
|
|
9
|
+
|
|
10
|
+
/** The audio engine state an iOS session policy is chosen for. */
|
|
11
|
+
|
|
12
|
+
/** Per-engine-state AVAudioSession configuration, applied natively without a JS round trip. */
|
|
13
|
+
|
|
14
|
+
const playAndRecordOptions = ['mixWithOthers', 'allowBluetooth', 'allowBluetoothA2DP', 'allowAirPlay'];
|
|
15
|
+
const playAndRecordSpeakerOptions = [...playAndRecordOptions, 'defaultToSpeaker'];
|
|
16
|
+
|
|
17
|
+
/** The default iOS session for an engine state. */
|
|
18
|
+
export function getDefaultAppleAudioConfigurationForAudioState(state) {
|
|
19
|
+
if (state.isRecordingEnabled) {
|
|
20
|
+
const audioCategoryOptions = state.preferSpeakerOutput ? [...playAndRecordSpeakerOptions] : [...playAndRecordOptions];
|
|
21
|
+
if (!state.isVoiceProcessingEnabled) {
|
|
22
|
+
// Without Apple voice processing the chat modes play remote audio quieter;
|
|
23
|
+
// the default mode keeps media gain.
|
|
24
|
+
return {
|
|
25
|
+
audioCategory: 'playAndRecord',
|
|
26
|
+
audioCategoryOptions,
|
|
27
|
+
audioMode: 'default'
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
audioCategory: 'playAndRecord',
|
|
32
|
+
audioCategoryOptions,
|
|
33
|
+
audioMode: state.preferSpeakerOutput ? 'videoChat' : 'voiceChat'
|
|
34
|
+
};
|
|
35
|
+
} else if (state.isPlayoutEnabled) {
|
|
36
|
+
return {
|
|
37
|
+
audioCategory: 'playback',
|
|
38
|
+
audioCategoryOptions: ['mixWithOthers'],
|
|
39
|
+
audioMode: 'spokenAudio'
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
audioCategory: 'soloAmbient',
|
|
44
|
+
audioCategoryOptions: [],
|
|
45
|
+
audioMode: 'default'
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
let activeSetupToken;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* iOS: the AVAudioSession configuration WebRTC applies itself when its audio
|
|
52
|
+
* unit starts (react-native-webrtc 155's built-in audio device module
|
|
53
|
+
* activates and deactivates the session around playout/recording). Called by
|
|
54
|
+
* `registerGlobals()` unless `autoConfigureAudioSession: false`. Returns a
|
|
55
|
+
* cleanup function. No-op on Android.
|
|
56
|
+
*
|
|
57
|
+
* The policy's `recording` entry is the configuration applied; this WebRTC
|
|
58
|
+
* build has one session configuration for its audio unit, so
|
|
59
|
+
* `recordingWithoutVoiceProcessing`, `playout` and `deactivateOnStop` are not
|
|
60
|
+
* applied separately (kept in the type for compatibility).
|
|
61
|
+
*/
|
|
62
|
+
export function setupIOSAudioManagement(preferSpeakerOutput = true, policy) {
|
|
63
|
+
if (Platform.OS !== 'ios') return () => {};
|
|
64
|
+
const token = {};
|
|
65
|
+
activeSetupToken = token;
|
|
66
|
+
const recording = policy?.recording ?? getDefaultAppleAudioConfigurationForAudioState({
|
|
67
|
+
isPlayoutEnabled: true,
|
|
68
|
+
isRecordingEnabled: true,
|
|
69
|
+
isVoiceProcessingEnabled: true,
|
|
70
|
+
preferSpeakerOutput
|
|
71
|
+
});
|
|
72
|
+
nativeModuleOrNull()?.setWebRTCAudioConfiguration(recording);
|
|
73
|
+
return () => {
|
|
74
|
+
if (activeSetupToken !== token) return;
|
|
75
|
+
activeSetupToken = undefined;
|
|
76
|
+
nativeModuleOrNull()?.setWebRTCAudioConfiguration(null);
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=AudioManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Platform","nativeModuleOrNull","playAndRecordOptions","playAndRecordSpeakerOptions","getDefaultAppleAudioConfigurationForAudioState","state","isRecordingEnabled","audioCategoryOptions","preferSpeakerOutput","isVoiceProcessingEnabled","audioCategory","audioMode","isPlayoutEnabled","activeSetupToken","setupIOSAudioManagement","policy","OS","token","recording","setWebRTCAudioConfiguration","undefined"],"sourceRoot":"../../../src","sources":["audio/AudioManager.ts"],"mappings":";;AAAA;AACA;AACA;;AAEA,SAASA,QAAQ,QAAQ,cAAc;AACvC,SAASC,kBAAkB,QAAQ,qBAAkB;;AAMrD;;AAQA;;AASA,MAAMC,oBAAgD,GAAG,CACvD,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,cAAc,CACf;AACD,MAAMC,2BAAuD,GAAG,CAC9D,GAAGD,oBAAoB,EACvB,kBAAkB,CACnB;;AAED;AACA,OAAO,SAASE,8CAA8CA,CAC5DC,KAAoC,EACX;EACzB,IAAIA,KAAK,CAACC,kBA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B,KAAKI,KAAK,EAAE;IAChCJ,gBAAgB,GAAGO,SAAS;IAC5BnB,kBAAkB,CAAC,CAAC,EAAEkB,2BAA2B,CAAC,IAAI,CAAC;EACzD,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// Copyright 2023-2026 LiveKit, Inc.
|
|
4
|
+
// Modifications Copyright 2026 Gravity Compile.
|
|
5
|
+
// Licensed under the Apache License, Version 2.0; see LICENSES/Apache-2.0.txt.
|
|
6
|
+
|
|
7
|
+
import { Platform } from 'react-native';
|
|
8
|
+
import { nativeModule } from "../native/module.js";
|
|
9
|
+
import { setDefaultRemoteVolume } from "./remoteVolume.js";
|
|
10
|
+
|
|
11
|
+
/** Android playback/routing configuration; see {@link AndroidAudioTypePresets}. */
|
|
12
|
+
|
|
13
|
+
export const AndroidAudioTypePresets = {
|
|
14
|
+
communication: {
|
|
15
|
+
manageAudioFocus: true,
|
|
16
|
+
audioMode: 'inCommunication',
|
|
17
|
+
audioFocusMode: 'gain',
|
|
18
|
+
audioStreamType: 'voiceCall',
|
|
19
|
+
audioAttributesUsageType: 'voiceCommunication',
|
|
20
|
+
audioAttributesContentType: 'speech'
|
|
21
|
+
},
|
|
22
|
+
media: {
|
|
23
|
+
manageAudioFocus: true,
|
|
24
|
+
audioMode: 'normal',
|
|
25
|
+
audioFocusMode: 'gain',
|
|
26
|
+
audioStreamType: 'music',
|
|
27
|
+
audioAttributesUsageType: 'media',
|
|
28
|
+
audioAttributesContentType: 'unknown'
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/** iOS outputs: 'default' (system route) and 'force_speaker'. Android: see {@link AndroidAudioOutput}. */
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The platform audio session: Android audio mode / focus / output routing
|
|
36
|
+
* (AudioSwitch) and the iOS AVAudioSession.
|
|
37
|
+
*
|
|
38
|
+
* Typical use: `configureAudio` once, `startAudioSession()` before
|
|
39
|
+
* `room.connect`, `stopAudioSession()` after `room.disconnect()`.
|
|
40
|
+
*/
|
|
41
|
+
export default class AudioSession {
|
|
42
|
+
static configureAudio = async config => {
|
|
43
|
+
await nativeModule().configureAudio(config);
|
|
44
|
+
};
|
|
45
|
+
static startAudioSession = async () => {
|
|
46
|
+
await nativeModule().startAudioSession();
|
|
47
|
+
};
|
|
48
|
+
static stopAudioSession = async () => {
|
|
49
|
+
await nativeModule().stopAudioSession();
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Volume for remote audio tracks subscribed after this call (0..10, 1 =
|
|
54
|
+
* unchanged). Applied per track by `registerGlobals()`'s room hook.
|
|
55
|
+
*/
|
|
56
|
+
static setDefaultRemoteAudioTrackVolume = async volume => {
|
|
57
|
+
setDefaultRemoteVolume(volume);
|
|
58
|
+
};
|
|
59
|
+
static getAudioOutputs = async () => {
|
|
60
|
+
if (Platform.OS !== 'ios' && Platform.OS !== 'android') return [];
|
|
61
|
+
return await nativeModule().getAudioOutputs();
|
|
62
|
+
};
|
|
63
|
+
static selectAudioOutput = async deviceId => {
|
|
64
|
+
await nativeModule().selectAudioOutput(deviceId);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Speakerphone on/off, the common case of {@link selectAudioOutput}
|
|
69
|
+
* (Flutter: `GravixRoomService.setSpeakerphoneOn`). Off picks the earpiece on
|
|
70
|
+
* Android and the system route (receiver, or a connected headset) on iOS.
|
|
71
|
+
*/
|
|
72
|
+
static setSpeakerphoneOn = async on => {
|
|
73
|
+
if (Platform.OS === 'ios') {
|
|
74
|
+
await AudioSession.selectAudioOutput(on ? 'force_speaker' : 'default');
|
|
75
|
+
} else if (Platform.OS === 'android') {
|
|
76
|
+
await AudioSession.selectAudioOutput(on ? 'speaker' : 'earpiece');
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
/** iOS: opens the system route picker (AirPlay / Bluetooth). No-op elsewhere. */
|
|
81
|
+
static showAudioRoutePicker = async () => {
|
|
82
|
+
if (Platform.OS === 'ios') await nativeModule().showAudioRoutePicker();
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/** iOS: sets the AVAudioSession category / options / mode. No-op elsewhere. */
|
|
86
|
+
static setAppleAudioConfiguration = async config => {
|
|
87
|
+
if (Platform.OS === 'ios') await nativeModule().setAppleAudioConfiguration(config);
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=AudioSession.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Platform","nativeModule","setDefaultRemoteVolume","AndroidAudioTypePresets","communication","manageAudioFocus","audioMode","audioFocusMode","audioStreamType","audioAttributesUsageType","audioAttributesContentType","media","AudioSession","configureAudio","config","startAudioSession","stopAudioSession","setDefaultRemoteAudioTrackVolume","volume","getAudioOutputs","OS","selectAudioOutput","deviceId","setSpeakerphoneOn","on","showAudioRoutePicker","setAppleAudioConfiguration"],"sourceRoot":"../../../src","sources":["audio/AudioSession.ts"],"mappings":";;AAAA;AACA;AACA;;AAEA,SAASA,QAAQ,QAAQ,cAAc;AACvC,SAASC,YAAY,QAAQ,qBAAkB;AAC/C,SAASC,sBAAsB,QAAQ,mBAAgB;;AAEvD;;AAuDA,OAAO,MAAMC,uBAKZ,GAAG;EACFC,aAAa,EAAE;IACbC,gBAAgB,EAAE,IAAI;IACtBC,SAAS,EAAE,iBAAiB;IAC5BC,cAAc,EAAE,MAAM;IACtBC,eAAe,EAAE,WAAW;IAC5BC,wBAAwB,EAAE,oBAAoB;IAC9CC,0BAA0B,EAAE;EAC9B,CAAC;EACDC,KAAK,EAAE;IACLN,gBAAgB,EAAE,IAAI;IACtBC,SAAS,EAAE,QAAQ;IACnBC,cAAc,EAAE,MAAM;IACtBC,eAAe,EAAE,OAAO;IACxBC,wBAAwB,EAAE,OAAO;IACjCC,0BAA0B,EAAE;EAC9B;AACF,CAA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,UAAU,CAAC;IACnE;EACF,CAAC;;EAED;EACA,OAAOC,oBAAoB,GAAG,MAAAA,CAAA,KAA2B;IACvD,IAAIzB,QAAQ,CAACoB,EAAE,KAAK,KAAK,EAAE,MAAMnB,YAAY,CAAC,CAAC,CAACwB,oBAAoB,CAAC,CAAC;EACxE,CAAC;;EAED;EACA,OAAOC,0BAA0B,GAAG,MAClCZ,MAA+B,IACb;IAClB,IAAId,QAAQ,CAACoB,EAAE,KAAK,KAAK,EACvB,MAAMnB,YAAY,CAAC,CAAC,CAACyB,0BAA0B,CAACZ,MAAgB,CAAC;EACrE,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// Copyright (c) 2026 Gravity Compile. MIT License; see LICENSE.
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Default volume of remote audio tracks (`AudioSession.setDefaultRemoteAudioTrackVolume`).
|
|
7
|
+
*
|
|
8
|
+
* react-native-webrtc 155 has no native default track volume, so the value is
|
|
9
|
+
* applied in JS: every remote audio track a gravix-rtc Room subscribes to after
|
|
10
|
+
* the call gets `MediaStreamTrack._setVolume(volume)` (react-native-webrtc's
|
|
11
|
+
* per-track playout gain). 1 = unchanged (nothing is called).
|
|
12
|
+
*/
|
|
13
|
+
let defaultVolume = 1;
|
|
14
|
+
/** Sets the volume (0..10) for remote audio tracks subscribed after this call. */
|
|
15
|
+
export function setDefaultRemoteVolume(volume) {
|
|
16
|
+
if (!Number.isFinite(volume) || volume < 0) return;
|
|
17
|
+
defaultVolume = Math.min(volume, 10);
|
|
18
|
+
}
|
|
19
|
+
export function getDefaultRemoteVolume() {
|
|
20
|
+
return defaultVolume;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Applies the default volume to one subscribed track. Never throws. */
|
|
24
|
+
export function applyDefaultRemoteVolume(track) {
|
|
25
|
+
if (defaultVolume === 1) return;
|
|
26
|
+
const t = track;
|
|
27
|
+
const mst = t?.mediaStreamTrack;
|
|
28
|
+
if (!mst || (t?.kind ?? mst.kind) !== 'audio') return;
|
|
29
|
+
try {
|
|
30
|
+
mst._setVolume?.(defaultVolume);
|
|
31
|
+
} catch {
|
|
32
|
+
// a track that went away meanwhile keeps its volume
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const PATCHED = '__gravixRemoteVolume';
|
|
36
|
+
|
|
37
|
+
/** Taps [RoomClass]'s `emit` for `trackSubscribed`. Idempotent; the original emit always runs. */
|
|
38
|
+
export function installRemoteVolumeHook(RoomClass) {
|
|
39
|
+
const proto = RoomClass?.prototype;
|
|
40
|
+
if (!proto || typeof proto.emit !== 'function' || proto[PATCHED]) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
const original = proto.emit;
|
|
44
|
+
proto.emit = function (event, ...args) {
|
|
45
|
+
const r = original.call(this, event, ...args);
|
|
46
|
+
if (event === 'trackSubscribed') applyDefaultRemoteVolume(args[0]);
|
|
47
|
+
return r;
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(proto, PATCHED, {
|
|
50
|
+
value: true
|
|
51
|
+
});
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=remoteVolume.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["defaultVolume","setDefaultRemoteVolume","volume","Number","isFinite","Math","min","getDefaultRemoteVolume","applyDefaultRemoteVolume","track","t","mst","mediaStreamTrack","kind","_setVolume","PATCHED","installRemoteVolumeHook","RoomClass","proto","prototype","emit","original","event","args","r","call","Object","defineProperty","value"],"sourceRoot":"../../../src","sources":["audio/remoteVolume.ts"],"mappings":";;AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAIA,aAAa,GAAG,CAAC;AAOrB;AACA,OAAO,SAASC,sBAAsBA,CAACC,MAAc,EAAQ;EAC3D,IAAI,CAACC,MAAM,CAACC,QAAQ,CAACF,MAAM,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;EACtD,OAAO,IAAI;AACb","ignoreList":[]}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// Copyright 2023-2026 LiveKit, Inc.
|
|
4
|
+
// Modifications Copyright 2026 Gravity Compile.
|
|
5
|
+
// Licensed under the Apache License, Version 2.0; see LICENSES/Apache-2.0.txt.
|
|
6
|
+
|
|
7
|
+
import { RTCView } from 'react-native-webrtc';
|
|
8
|
+
import { LocalVideoTrack, RemoteVideoTrack, TrackEvent } from 'gravix-rtc';
|
|
9
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
10
|
+
import { StyleSheet, View } from 'react-native';
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
/**
|
|
13
|
+
* Renders a local or remote video track with `RTCView`, and reports its size
|
|
14
|
+
* and visibility to the track so adaptive stream picks the right layer.
|
|
15
|
+
*/
|
|
16
|
+
export function VideoView({
|
|
17
|
+
trackRef,
|
|
18
|
+
videoTrack: videoTrackProp,
|
|
19
|
+
style,
|
|
20
|
+
objectFit = 'cover',
|
|
21
|
+
mirror,
|
|
22
|
+
zOrder,
|
|
23
|
+
visible = true
|
|
24
|
+
}) {
|
|
25
|
+
const videoTrack = videoTrackProp ?? trackRef?.publication?.track;
|
|
26
|
+
const [elementInfo] = useState(() => new VideoViewElementInfo());
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
elementInfo.id = videoTrack?.sid;
|
|
29
|
+
}, [elementInfo, videoTrack]);
|
|
30
|
+
const onLayout = useCallback(e => elementInfo.onLayout(e), [elementInfo]);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
elementInfo.onVisibility(visible);
|
|
33
|
+
}, [elementInfo, visible]);
|
|
34
|
+
const [mediaStream, setMediaStream] = useState(videoTrack?.mediaStream);
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
setMediaStream(videoTrack?.mediaStream);
|
|
37
|
+
if (videoTrack instanceof LocalVideoTrack) {
|
|
38
|
+
const onRestarted = track => setMediaStream(track?.mediaStream);
|
|
39
|
+
videoTrack.on(TrackEvent.Restarted, onRestarted);
|
|
40
|
+
return () => {
|
|
41
|
+
videoTrack.off(TrackEvent.Restarted, onRestarted);
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return undefined;
|
|
45
|
+
}, [videoTrack]);
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (videoTrack instanceof RemoteVideoTrack && videoTrack.isAdaptiveStream) {
|
|
48
|
+
videoTrack.observeElementInfo(elementInfo);
|
|
49
|
+
return () => videoTrack.stopObservingElementInfo(elementInfo);
|
|
50
|
+
}
|
|
51
|
+
return undefined;
|
|
52
|
+
}, [videoTrack, elementInfo]);
|
|
53
|
+
const streamURL = mediaStream?.toURL?.() ?? '';
|
|
54
|
+
return /*#__PURE__*/_jsx(View, {
|
|
55
|
+
style: [styles.container, style],
|
|
56
|
+
onLayout: onLayout,
|
|
57
|
+
children: /*#__PURE__*/_jsx(RTCView, {
|
|
58
|
+
style: styles.video,
|
|
59
|
+
streamURL: streamURL,
|
|
60
|
+
objectFit: objectFit,
|
|
61
|
+
zOrder: zOrder,
|
|
62
|
+
mirror: mirror
|
|
63
|
+
})
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
const styles = StyleSheet.create({
|
|
67
|
+
container: {
|
|
68
|
+
overflow: 'hidden'
|
|
69
|
+
},
|
|
70
|
+
video: {
|
|
71
|
+
flex: 1,
|
|
72
|
+
width: '100%'
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
/** The adaptive-stream "element" of a native view (size + visibility). @internal */
|
|
77
|
+
export class VideoViewElementInfo {
|
|
78
|
+
element = {};
|
|
79
|
+
_width = 0;
|
|
80
|
+
_height = 0;
|
|
81
|
+
_observing = false;
|
|
82
|
+
visible = true;
|
|
83
|
+
pictureInPicture = false;
|
|
84
|
+
width = () => this._width;
|
|
85
|
+
height = () => this._height;
|
|
86
|
+
observe() {
|
|
87
|
+
this._observing = true;
|
|
88
|
+
}
|
|
89
|
+
stopObserving() {
|
|
90
|
+
this._observing = false;
|
|
91
|
+
}
|
|
92
|
+
onLayout(event) {
|
|
93
|
+
const {
|
|
94
|
+
width,
|
|
95
|
+
height
|
|
96
|
+
} = event.nativeEvent.layout;
|
|
97
|
+
this._width = width;
|
|
98
|
+
this._height = height;
|
|
99
|
+
if (this._observing) this.handleResize?.();
|
|
100
|
+
}
|
|
101
|
+
onVisibility(isVisible) {
|
|
102
|
+
if (this.visible !== isVisible) {
|
|
103
|
+
this.visible = isVisible;
|
|
104
|
+
this.visibilityChangedAt = Date.now();
|
|
105
|
+
if (this._observing) this.handleVisibilityChanged?.();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=VideoView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["RTCView","LocalVideoTrack","RemoteVideoTrack","TrackEvent","useCallback","useEffect","useState","StyleSheet","View","jsx","_jsx","VideoView","trackRef","videoTrack","videoTrackProp","style","objectFit","mirror","zOrder","visible","publication","track","elementInfo","VideoViewElementInfo","id","sid","onLayout","e","onVisibility","mediaStream","setMediaStream","onRestarted","on","Restarted","off","undefined","isAdaptiveStream","observeElementInfo","stopObservingElementInfo","streamURL","toURL","styles","container","children","video","create","overflow","flex","width","element","_width","_height","_observing","pictureInPicture","height","observe","stopObserving","event","nativeEvent","layout","handleResize","isVisible","visibilityChangedAt","Date","now","handleVisibilityChanged"],"sourceRoot":"../../../src","sources":["components/VideoView.tsx"],"mappings":";;AAAA;AACA;AACA;;AAEA,SAASA,OAAO,QAAQ,qBAAqB;AAC7C,SAEEC,eAAe,EACfC,gBAAgB,EAEhBC,UAAU,QAEL,YAAY;AACnB,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AACxD,SAGEC,UAAU,EACVC,IAAI,QAEC,cAAc;AAAC,SAAAC,GAAA,IAAAC,IAAA;AA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