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,108 @@
|
|
|
1
|
+
// Copyright (c) 2026 Gravity Compile. MIT License; see LICENSE.
|
|
2
|
+
|
|
3
|
+
import type { Room } from 'gravix-rtc';
|
|
4
|
+
import { androidAudioFor } from '../android/bindings';
|
|
5
|
+
import { gravixMicMute } from '../android/micMute';
|
|
6
|
+
import { gravixRoomMicPolicy } from '../micPolicy';
|
|
7
|
+
import { unsupported, unsupportedAsync } from '../unsupported';
|
|
8
|
+
import {
|
|
9
|
+
iosRecorderState,
|
|
10
|
+
type GravixRecorderState,
|
|
11
|
+
iosFeature,
|
|
12
|
+
} from '../ios/iosAudio';
|
|
13
|
+
|
|
14
|
+
export type { GravixRecorderState } from '../ios/iosAudio';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Mute releases the microphone (Flutter 0.12.1/0.12.2
|
|
18
|
+
* `GravixRoomService(muteReleasesMic: true)`): muting stops and closes the
|
|
19
|
+
* platform recorder so the OS mic indicator goes off, and an unmute reopens it.
|
|
20
|
+
*
|
|
21
|
+
* ON BY DEFAULT and applied to every Room automatically (`registerGlobals()`
|
|
22
|
+
* installs the room hook, see src/micPolicy.ts): on iOS the Gravix audio
|
|
23
|
+
* device closes the mic input (the track stays live; Info.plist
|
|
24
|
+
* `GravixMuteStopsMicTrack` = YES also stops the track), Android mics published while muted get their recorder closed. Rollback:
|
|
25
|
+
* `registerGlobals({ muteReleasesMic: false })`.
|
|
26
|
+
*
|
|
27
|
+
* Android: under room music a mute through `GravixRoomMusic.setMicMuted(true)`
|
|
28
|
+
* is voice-only (no mute signal, the song keeps going out) and releases the
|
|
29
|
+
* recorder; {@link GravixMicRelease.isMicMuted} reports it (`track.isMuted`
|
|
30
|
+
* stays false). iOS: no voice-only mute; the song stops for listeners under a
|
|
31
|
+
* mute. {@link GravixMicRelease.getRecorderState} reads WebRTC's audio engine.
|
|
32
|
+
*/
|
|
33
|
+
function micTracks(room: Room): Array<{ stopOnMute?: boolean }> {
|
|
34
|
+
const out: Array<{ stopOnMute?: boolean }> = [];
|
|
35
|
+
const lp = room.localParticipant as unknown as {
|
|
36
|
+
audioTrackPublications?: Map<
|
|
37
|
+
string,
|
|
38
|
+
{ source?: string; track?: { stopOnMute?: boolean } }
|
|
39
|
+
>;
|
|
40
|
+
};
|
|
41
|
+
lp.audioTrackPublications?.forEach((pub) => {
|
|
42
|
+
if (pub.source === 'microphone' && pub.track) out.push(pub.track);
|
|
43
|
+
});
|
|
44
|
+
return out;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export const GravixMicRelease = {
|
|
48
|
+
/**
|
|
49
|
+
* Android: with this on, a mute through `GravixRoomMusic.setMicMuted(true)`
|
|
50
|
+
* while music plays zeroes only the voice and releases the recorder
|
|
51
|
+
* (`continueWhileMicReleased`), and the song keeps reaching the room. Off
|
|
52
|
+
* gives a released recorder back. iOS: a mute closes the mic in the Gravix
|
|
53
|
+
* audio device.
|
|
54
|
+
*/
|
|
55
|
+
async setMuteReleasesMic(on: boolean): Promise<void> {
|
|
56
|
+
if (androidAudioFor('muteReleasesMic')) {
|
|
57
|
+
gravixRoomMicPolicy.releasesMic = on;
|
|
58
|
+
if (!on) await gravixMicMute.unreleaseKeepingMute();
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (!iosFeature('muteReleasesMic'))
|
|
62
|
+
return unsupportedAsync('muteReleasesMic', 'setMuteReleasesMic');
|
|
63
|
+
gravixRoomMicPolicy.releasesMic = on;
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
/** Whether a mute releases the mic (default true, as Flutter 0.12.1+). */
|
|
67
|
+
get muteReleasesMic(): boolean {
|
|
68
|
+
return gravixRoomMicPolicy.releasesMic;
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
/** The local mic is muted: the core mute or an Android voice-only music mute. */
|
|
72
|
+
isMicMuted(room: Room): boolean {
|
|
73
|
+
return gravixRoomMicPolicy.isMicMuted(room as never);
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
/** Voice-only mute changes (pair with the core's TrackMuted / TrackUnmuted). */
|
|
77
|
+
onMicMuteChanged(fn: () => void): () => void {
|
|
78
|
+
return gravixRoomMicPolicy.onMicMuteChanged(fn);
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Applies the setting to the room's published microphone (`stopOnMute`) now.
|
|
83
|
+
* Not needed for new publishes (the room hook does it); kept for a mic
|
|
84
|
+
* published before `setMuteReleasesMic` changed. Returns the count.
|
|
85
|
+
*/
|
|
86
|
+
attach(room: Room): number {
|
|
87
|
+
if (androidAudioFor('muteReleasesMic')) {
|
|
88
|
+
// Android: a plain mute already stops the recorder (engine path); no stopOnMute
|
|
89
|
+
return 0;
|
|
90
|
+
}
|
|
91
|
+
if (!iosFeature('muteReleasesMic')) {
|
|
92
|
+
unsupported('muteReleasesMic', 'attach');
|
|
93
|
+
}
|
|
94
|
+
const tracks = micTracks(room);
|
|
95
|
+
// GxAudioDevice closes the mic natively; the track is stopped too only with the
|
|
96
|
+
// Info.plist rollback GravixMuteStopsMicTrack = YES (2026-12-01)
|
|
97
|
+
for (const t of tracks)
|
|
98
|
+
t.stopOnMute = gravixRoomMicPolicy.iosStopsTrackOnMute();
|
|
99
|
+
return tracks.length;
|
|
100
|
+
},
|
|
101
|
+
|
|
102
|
+
/** iOS: the recorder as WebRTC's audio engine sees it. */
|
|
103
|
+
getRecorderState(): Promise<GravixRecorderState> {
|
|
104
|
+
if (!iosFeature('muteReleasesMic'))
|
|
105
|
+
return unsupportedAsync('muteReleasesMic', 'getRecorderState');
|
|
106
|
+
return iosRecorderState();
|
|
107
|
+
},
|
|
108
|
+
};
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
// Copyright (c) 2026 Gravity Compile. MIT License; see LICENSE.
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
noiseSuppressionOptions,
|
|
5
|
+
nsBenchmarkKey,
|
|
6
|
+
resolveNs,
|
|
7
|
+
type GravixNoiseSuppressionMode,
|
|
8
|
+
type GravixNoiseSuppressionOptions,
|
|
9
|
+
type GravixNsBenchmark,
|
|
10
|
+
type GravixNsDeviceFacts,
|
|
11
|
+
} from 'gravix-rtc';
|
|
12
|
+
import { androidAudioFor } from '../android/bindings';
|
|
13
|
+
import {
|
|
14
|
+
androidNoiseSuppressionStats,
|
|
15
|
+
configureAndroidNoiseSuppression,
|
|
16
|
+
} from '../android/noiseSuppression';
|
|
17
|
+
import { unsupportedAsync } from '../unsupported';
|
|
18
|
+
import {
|
|
19
|
+
iosAttach,
|
|
20
|
+
iosCall,
|
|
21
|
+
onIosAudioEvent,
|
|
22
|
+
iosFeature,
|
|
23
|
+
} from '../ios/iosAudio';
|
|
24
|
+
import { currentAudioScenario } from './audioScenario';
|
|
25
|
+
import { GRAVIX_RTC_RN_VERSION } from '../version';
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* On-device noise suppression of the published mic (RNNoise "standard",
|
|
29
|
+
* DFN3 "studio"; Flutter `GravixNoiseController`). The mode and option types
|
|
30
|
+
* are gravix-rtc's own, so policy/report logic stays shared. Native-only:
|
|
31
|
+
* until the platform implements it, every call throws `GravixUnsupportedError`.
|
|
32
|
+
* WebRTC's built-in noise suppression keeps working regardless.
|
|
33
|
+
*/
|
|
34
|
+
export interface GravixNoiseSuppressionState {
|
|
35
|
+
mode: GravixNoiseSuppressionMode;
|
|
36
|
+
/** The engine that runs now. */
|
|
37
|
+
engine: 'off' | 'rnnoise' | 'dfn3' | 'webrtc';
|
|
38
|
+
/** Why the engine differs from the mode (fallback, budget, thermal, ...). */
|
|
39
|
+
reason?: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** iOS: the native facts (`nsDeviceFacts`) plus what the resolver reads. */
|
|
43
|
+
type IosNsFacts = GravixNsDeviceFacts & {
|
|
44
|
+
studioAvailable?: boolean;
|
|
45
|
+
studioSha?: string;
|
|
46
|
+
osBuild?: string;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
type NativeNsState = {
|
|
50
|
+
active?: string;
|
|
51
|
+
requested?: string;
|
|
52
|
+
reason?: string;
|
|
53
|
+
enabled?: boolean;
|
|
54
|
+
route?: string;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
function engineName(v: unknown): GravixNoiseSuppressionState['engine'] {
|
|
58
|
+
return v === 'rnnoise' || v === 'dfn3' ? v : 'off';
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export class GravixNoiseSuppression {
|
|
62
|
+
static readonly instance = new GravixNoiseSuppression();
|
|
63
|
+
|
|
64
|
+
private last: GravixNoiseSuppressionState | null = null;
|
|
65
|
+
private mode: GravixNoiseSuppressionMode = 'off';
|
|
66
|
+
private options: GravixNoiseSuppressionOptions = noiseSuppressionOptions();
|
|
67
|
+
private facts: IosNsFacts | null = null;
|
|
68
|
+
/** Studio benchmark of this process (the native side keeps no cache). */
|
|
69
|
+
private bench: GravixNsBenchmark | null = null;
|
|
70
|
+
private benchRunning = false;
|
|
71
|
+
private resolvedReason = 'mode_off';
|
|
72
|
+
|
|
73
|
+
private constructor() {}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Android: resolved like Flutter / web (`resolveNs`, background studio
|
|
77
|
+
* benchmark for `auto`), then run natively on WebRTC's capture
|
|
78
|
+
* post-processing slot. Capture the mic with WebRTC's own
|
|
79
|
+
* `noiseSuppression` / `autoGainControl` off while the engine is ours.
|
|
80
|
+
*
|
|
81
|
+
* iOS: resolves the engine with gravix-rtc's `resolveNs` (device facts from
|
|
82
|
+
* native, the studio benchmark run natively when `auto` needs it) and
|
|
83
|
+
* configures the native chain. WebRTC's own software NS / AGC are NOT
|
|
84
|
+
* switched off here: publish the mic with `noiseSuppression: false,
|
|
85
|
+
* autoGainControl: false` while ours runs (see {@link webrtcProcessingFor}).
|
|
86
|
+
*/
|
|
87
|
+
async setMode(
|
|
88
|
+
mode: GravixNoiseSuppressionMode,
|
|
89
|
+
options?: Partial<GravixNoiseSuppressionOptions>
|
|
90
|
+
): Promise<GravixNoiseSuppressionState> {
|
|
91
|
+
if (androidAudioFor('noiseSuppression'))
|
|
92
|
+
return this.setModeAndroid(mode, options);
|
|
93
|
+
if (!iosFeature('noiseSuppression'))
|
|
94
|
+
return unsupportedAsync('noiseSuppression', 'setMode');
|
|
95
|
+
await iosAttach();
|
|
96
|
+
this.mode = mode;
|
|
97
|
+
this.options = noiseSuppressionOptions({ ...options, mode });
|
|
98
|
+
if (!this.facts) {
|
|
99
|
+
this.facts = {
|
|
100
|
+
...(await iosCall<IosNsFacts>('nsDeviceFacts')),
|
|
101
|
+
platform: 'ios',
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
return this.apply();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
async getState(): Promise<GravixNoiseSuppressionState> {
|
|
108
|
+
if (androidAudioFor('noiseSuppression')) return this.getStateAndroid();
|
|
109
|
+
if (!iosFeature('noiseSuppression'))
|
|
110
|
+
return unsupportedAsync('noiseSuppression', 'getState');
|
|
111
|
+
const m = await iosCall<NativeNsState>('nsGetState');
|
|
112
|
+
return this.stateFrom(m);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* The WebRTC capture processing to publish the mic with while Gravix NS
|
|
117
|
+
* runs (Flutter `gravixNsProcessing`): software NS off when
|
|
118
|
+
* `disableWebRtcNs`, AGC off unless `agcOrder: webrtcBeforeNs`.
|
|
119
|
+
*/
|
|
120
|
+
webrtcProcessingFor(engine: GravixNoiseSuppressionState['engine']): {
|
|
121
|
+
noiseSuppression?: boolean;
|
|
122
|
+
autoGainControl?: boolean;
|
|
123
|
+
} {
|
|
124
|
+
if (engine !== 'rnnoise' && engine !== 'dfn3') return {};
|
|
125
|
+
return {
|
|
126
|
+
...(this.options.disableWebRtcNs ? { noiseSuppression: false } : {}),
|
|
127
|
+
...(this.options.agcOrder === 'webrtcBeforeNs'
|
|
128
|
+
? {}
|
|
129
|
+
: { autoGainControl: false }),
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
private stateFrom(m: NativeNsState): GravixNoiseSuppressionState {
|
|
134
|
+
return {
|
|
135
|
+
mode: this.mode,
|
|
136
|
+
engine: engineName(m.active),
|
|
137
|
+
reason: typeof m.reason === 'string' ? m.reason : this.resolvedReason,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
private benchKey(): string | null {
|
|
142
|
+
const f = this.facts;
|
|
143
|
+
if (!f?.studioSha) return null;
|
|
144
|
+
return nsBenchmarkKey({
|
|
145
|
+
sdkVersion: GRAVIX_RTC_RN_VERSION,
|
|
146
|
+
modelSha256: f.studioSha,
|
|
147
|
+
runtimeVersion: 'coreml',
|
|
148
|
+
osBuild: f.osBuild ?? `${f.model ?? ''}/${f.osVersion ?? ''}`,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
private async apply(): Promise<GravixNoiseSuppressionState> {
|
|
153
|
+
const o = this.options;
|
|
154
|
+
const key = this.benchKey();
|
|
155
|
+
const r = resolveNs({
|
|
156
|
+
mode: this.mode,
|
|
157
|
+
facts: this.facts ?? { platform: 'ios' },
|
|
158
|
+
policy: o.policy ?? null,
|
|
159
|
+
benchmark: this.bench,
|
|
160
|
+
benchmarkKey: key,
|
|
161
|
+
studioAvailable: this.facts?.studioAvailable === true,
|
|
162
|
+
benchmarkP95Us: o.benchmarkP95Us,
|
|
163
|
+
});
|
|
164
|
+
this.resolvedReason = r.reason;
|
|
165
|
+
// chatRoom runs without our AGC (Agora ChatRoom parity), as in Flutter
|
|
166
|
+
const agcOff =
|
|
167
|
+
currentAudioScenario() === 'chatRoom' && o.agcOrder === 'ownAfterNs';
|
|
168
|
+
const engine =
|
|
169
|
+
r.engine === 'rnnoise' || r.engine === 'dfn3' ? r.engine : 'off';
|
|
170
|
+
const m = await iosCall<NativeNsState>('nsConfigure', {
|
|
171
|
+
engine,
|
|
172
|
+
agcOrder: o.agcOrder,
|
|
173
|
+
...(agcOff ? { agc: false } : {}),
|
|
174
|
+
musicBypass: o.musicBypass,
|
|
175
|
+
watchdogUs: Math.round(o.watchdogFrameMs * 1000),
|
|
176
|
+
watchdogConsecutive: Math.round(o.watchdogConsecutive),
|
|
177
|
+
thermalFallback: o.thermalFallback,
|
|
178
|
+
batterySaverFallback: o.batterySaverFallback,
|
|
179
|
+
benchmarkP95Us: Math.round(o.benchmarkP95Us),
|
|
180
|
+
...(this.bench && this.bench.key === key
|
|
181
|
+
? { benchmarkCachedP95Us: Math.round(this.bench.p95Us) }
|
|
182
|
+
: {}),
|
|
183
|
+
studioModel: 'std',
|
|
184
|
+
studioDownload: o.studioDownload,
|
|
185
|
+
studioAttenLimitDb: o.studioAttenLimitDb,
|
|
186
|
+
studioP95BudgetUs: Math.round(o.studioP95BudgetUs),
|
|
187
|
+
studioP95WindowMs: Math.round(o.studioP95WindowMs),
|
|
188
|
+
});
|
|
189
|
+
if (r.needsBenchmark && key) this.runBenchmark(key).catch(() => {});
|
|
190
|
+
return this.stateFrom(m);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/** auto: the studio benchmark off the audio path, then re-resolve. */
|
|
194
|
+
private async runBenchmark(key: string): Promise<void> {
|
|
195
|
+
if (this.benchRunning) return;
|
|
196
|
+
this.benchRunning = true;
|
|
197
|
+
try {
|
|
198
|
+
const b = await iosCall<{
|
|
199
|
+
ok?: boolean;
|
|
200
|
+
p95Us?: number;
|
|
201
|
+
outputOk?: boolean;
|
|
202
|
+
}>('nsBenchmark');
|
|
203
|
+
if (b.ok === true && typeof b.p95Us === 'number') {
|
|
204
|
+
this.bench = { key, p95Us: b.p95Us, outputOk: b.outputOk !== false };
|
|
205
|
+
if (this.mode === 'auto' || this.mode === 'studio') await this.apply();
|
|
206
|
+
}
|
|
207
|
+
} catch {
|
|
208
|
+
// RNNoise stays; the next setMode retries
|
|
209
|
+
} finally {
|
|
210
|
+
this.benchRunning = false;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* iOS native events (`engineChanged`, `benchmark`, `routeReset`,
|
|
216
|
+
* `musicBypass`, `musicDetected`, `singerMode`, `download`), the Flutter
|
|
217
|
+
* `onNsEvent` maps. Returns the unsubscribe function.
|
|
218
|
+
*/
|
|
219
|
+
onNativeEvent(fn: (event: Record<string, unknown>) => void): () => void {
|
|
220
|
+
if (!iosFeature('noiseSuppression')) return () => {};
|
|
221
|
+
return onIosAudioEvent('onNsEvent', fn);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
private async setModeAndroid(
|
|
225
|
+
mode: GravixNoiseSuppressionMode,
|
|
226
|
+
options?: Partial<GravixNoiseSuppressionOptions>
|
|
227
|
+
): Promise<GravixNoiseSuppressionState> {
|
|
228
|
+
const r = await configureAndroidNoiseSuppression({ ...options, mode });
|
|
229
|
+
this.options = noiseSuppressionOptions({ ...options, mode });
|
|
230
|
+
const state: GravixNoiseSuppressionState = {
|
|
231
|
+
mode,
|
|
232
|
+
// 'browser' (WebRTC's own) is 'webrtc' here
|
|
233
|
+
engine: r.engine === 'browser' ? 'webrtc' : r.engine,
|
|
234
|
+
reason: r.reason,
|
|
235
|
+
};
|
|
236
|
+
this.last = state;
|
|
237
|
+
return state;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
private async getStateAndroid(): Promise<GravixNoiseSuppressionState> {
|
|
241
|
+
const s = await androidNoiseSuppressionStats();
|
|
242
|
+
const mode = this.last?.mode ?? 'off';
|
|
243
|
+
if (!s) return this.last ?? { mode, engine: 'off' };
|
|
244
|
+
const eng = s.eng === 'rnnoise' || s.eng === 'dfn3' ? s.eng : 'off';
|
|
245
|
+
return {
|
|
246
|
+
mode,
|
|
247
|
+
engine: eng,
|
|
248
|
+
reason: typeof s.reason === 'string' ? s.reason : undefined,
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// Copyright (c) 2026 Gravity Compile. MIT License; see LICENSE.
|
|
2
|
+
|
|
3
|
+
import type { Room } from 'gravix-rtc';
|
|
4
|
+
import { Platform } from 'react-native';
|
|
5
|
+
import { androidAudioFor } from '../android/bindings';
|
|
6
|
+
import { iosFeature } from '../ios/iosAudio';
|
|
7
|
+
import { unsupportedAsync } from '../unsupported';
|
|
8
|
+
import { AndroidRoomMusic } from './roomMusicAndroid';
|
|
9
|
+
import { IosRoomMusic } from './roomMusicIos';
|
|
10
|
+
import {
|
|
11
|
+
DEFAULT_MUSIC_OPTIONS,
|
|
12
|
+
type GravixMusicOptions,
|
|
13
|
+
type GravixMusicSource,
|
|
14
|
+
type GravixMusicStartOptions,
|
|
15
|
+
type GravixMusicState,
|
|
16
|
+
} from './roomMusicTypes';
|
|
17
|
+
|
|
18
|
+
export * from './roomMusicTypes';
|
|
19
|
+
|
|
20
|
+
type Impl = AndroidRoomMusic | IosRoomMusic;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Room music / karaoke: a local audio file mixed into the published
|
|
24
|
+
* microphone (Flutter `GravixRoomMusic`). The work is done per platform:
|
|
25
|
+
* Android in `roomMusicAndroid.ts` (docs/ANDROID_NATIVE_HOOKS.md), iOS in
|
|
26
|
+
* `roomMusicIos.ts` (docs/IOS_NATIVE_HOOKS.md). Where the platform has no
|
|
27
|
+
* native music, every call throws `GravixUnsupportedError`.
|
|
28
|
+
*/
|
|
29
|
+
export class GravixRoomMusic {
|
|
30
|
+
readonly options: Readonly<Required<GravixMusicOptions>>;
|
|
31
|
+
private readonly impl: Impl;
|
|
32
|
+
|
|
33
|
+
constructor(options: GravixMusicOptions = {}) {
|
|
34
|
+
this.options = Object.freeze({ ...DEFAULT_MUSIC_OPTIONS, ...options });
|
|
35
|
+
const android =
|
|
36
|
+
androidAudioFor('roomMusic') != null ||
|
|
37
|
+
(!iosFeature('roomMusic') && Platform.OS === 'android');
|
|
38
|
+
this.impl = android
|
|
39
|
+
? new AndroidRoomMusic(options)
|
|
40
|
+
: new IosRoomMusic(options);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
get state(): GravixMusicState {
|
|
44
|
+
return this.impl.state;
|
|
45
|
+
}
|
|
46
|
+
/** Binds the controller to a connected room (the published mic carries the mix). */
|
|
47
|
+
attach(room: Room): void {
|
|
48
|
+
this.impl.attach(room);
|
|
49
|
+
}
|
|
50
|
+
/** Decodes ahead so `start` begins without a gap. */
|
|
51
|
+
prepare(source: GravixMusicSource): Promise<void> {
|
|
52
|
+
return this.impl.prepare(source);
|
|
53
|
+
}
|
|
54
|
+
start(
|
|
55
|
+
source: GravixMusicSource,
|
|
56
|
+
options?: GravixMusicStartOptions
|
|
57
|
+
): Promise<void> {
|
|
58
|
+
return this.impl.start(source, options);
|
|
59
|
+
}
|
|
60
|
+
pause(): Promise<void> {
|
|
61
|
+
return this.impl.pause();
|
|
62
|
+
}
|
|
63
|
+
resume(): Promise<void> {
|
|
64
|
+
return this.impl.resume();
|
|
65
|
+
}
|
|
66
|
+
stop(): Promise<void> {
|
|
67
|
+
return this.impl.stop();
|
|
68
|
+
}
|
|
69
|
+
seek(positionMs: number): Promise<void> {
|
|
70
|
+
return this.impl.seek(positionMs);
|
|
71
|
+
}
|
|
72
|
+
setMusicVolume(volume: number): Promise<void> {
|
|
73
|
+
return this.impl.setMusicVolume(volume);
|
|
74
|
+
}
|
|
75
|
+
setMicVolume(volume: number): Promise<void> {
|
|
76
|
+
return this.impl.setMicVolume(volume);
|
|
77
|
+
}
|
|
78
|
+
setDucking(on: boolean): Promise<void> {
|
|
79
|
+
return this.impl.setDucking(on);
|
|
80
|
+
}
|
|
81
|
+
setLoop(on: boolean): Promise<void> {
|
|
82
|
+
return this.impl.setLoop(on);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Mutes the singer's voice. Android: with music playing this is a
|
|
86
|
+
* voice-only mute (the song keeps going out; the recorder is released when
|
|
87
|
+
* `continueWhileMicReleased`). iOS: a plain mic mute.
|
|
88
|
+
*/
|
|
89
|
+
setMicMuted(muted: boolean): Promise<void> {
|
|
90
|
+
if (this.impl instanceof AndroidRoomMusic) {
|
|
91
|
+
return this.impl.setMicMuted(muted);
|
|
92
|
+
}
|
|
93
|
+
return unsupportedAsync('roomMusic', 'setMicMuted');
|
|
94
|
+
}
|
|
95
|
+
/** The singer's song position now, extrapolated from the last native stamp. */
|
|
96
|
+
positionNow(): number {
|
|
97
|
+
return this.impl.positionNow();
|
|
98
|
+
}
|
|
99
|
+
/** A listener's view of a singer's position (lyric sync over `gx.music`). */
|
|
100
|
+
remotePositionNow(participantIdentity: string): number | undefined {
|
|
101
|
+
return this.impl.remotePositionNow(participantIdentity);
|
|
102
|
+
}
|
|
103
|
+
dispose(): Promise<void> {
|
|
104
|
+
return this.impl.dispose();
|
|
105
|
+
}
|
|
106
|
+
}
|