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,422 @@
|
|
|
1
|
+
// Copyright (c) 2026 Gravity Compile. MIT License; see LICENSE.
|
|
2
|
+
|
|
3
|
+
import { asMap, gravixAndroidAudioBridge } from './nativeAudio';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Mute that releases the OS microphone (Flutter SDK 0.12.1 / 0.12.2, Android).
|
|
7
|
+
*
|
|
8
|
+
* In React Native a plain mute of a published mic (`LocalAudioTrack.mute()`
|
|
9
|
+
* of the gravix-rtc core = `MediaStreamTrack.enabled = false`) does not stop
|
|
10
|
+
* the AudioRecord of react-native-webrtc 155's WebRTC build. The Gravix
|
|
11
|
+
* capture seam closes it instead: {@link GravixMicMute.setCaptureClosed}
|
|
12
|
+
* (the room mic policy calls it on every local mic mute / unmute) stops the
|
|
13
|
+
* hardware recorder while WebRTC's record thread keeps clocking silence, so
|
|
14
|
+
* the OS mic indicator goes off (0.12.1 behaviour). Two cases need more,
|
|
15
|
+
* ported here over the native primitives (`setMicrophoneMute`,
|
|
16
|
+
* `setRecorderReleased`, `recorderNativeState`, `setCaptureClosed`):
|
|
17
|
+
*
|
|
18
|
+
* 1. Room music under a mute ({@link GravixMicMute.muteForMusic}, 0.12.2,
|
|
19
|
+
* `continueWhileMicReleased`): the voice is zeroed in the module, then the
|
|
20
|
+
* hardware recorder is released while WebRTC's record thread keeps
|
|
21
|
+
* delivering frames (silence + the music, clocked by the mixer). The track
|
|
22
|
+
* stays enabled and published (no mute signal): the room keeps hearing the
|
|
23
|
+
* music, the OS mic indicator goes off.
|
|
24
|
+
* 2. A mic published while ALREADY muted ({@link GravixMicMute.closeMutedCapture}):
|
|
25
|
+
* WebRTC starts the recorder when the send stream is added, muted or not.
|
|
26
|
+
* With the capture seam the recorder is simply closed; without it (a
|
|
27
|
+
* native side that lacks `setCaptureClosed`) the stream is unmuted and
|
|
28
|
+
* muted again once under the module mute, until the recorder is seen
|
|
29
|
+
* stopped (at most 3 rounds).
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/** The parts of a gravix-rtc `LocalAudioTrack` this needs. */
|
|
33
|
+
export interface GravixMicTrackLike {
|
|
34
|
+
readonly isMuted: boolean;
|
|
35
|
+
readonly mediaStreamTrack: { enabled: boolean };
|
|
36
|
+
mute(): Promise<unknown>;
|
|
37
|
+
unmute(): Promise<unknown>;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface GravixMicNative {
|
|
41
|
+
setMicrophoneMute(mute: boolean): Promise<boolean>;
|
|
42
|
+
setRecorderReleased(
|
|
43
|
+
released: boolean,
|
|
44
|
+
opts?: { waitOpen?: boolean; timeoutMs?: number }
|
|
45
|
+
): Promise<boolean>;
|
|
46
|
+
recorderNativeState(): Promise<Record<string, boolean> | null>;
|
|
47
|
+
/** Closes (true) or reopens the hardware recorder for a mute; null: not available. */
|
|
48
|
+
setCaptureClosed?(closed: boolean): Promise<boolean | null>;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** The native primitives through the Android bridge; no-ops (false / null) without it. */
|
|
52
|
+
export const bridgeMicNative: GravixMicNative = {
|
|
53
|
+
async setMicrophoneMute(mute) {
|
|
54
|
+
const b = gravixAndroidAudioBridge();
|
|
55
|
+
if (!b) return false;
|
|
56
|
+
return (await b.call('setMicrophoneMute', { mute })) === true;
|
|
57
|
+
},
|
|
58
|
+
async setRecorderReleased(released, opts = {}) {
|
|
59
|
+
const b = gravixAndroidAudioBridge();
|
|
60
|
+
if (!b) return false;
|
|
61
|
+
return (
|
|
62
|
+
(await b.call('setRecorderReleased', {
|
|
63
|
+
released,
|
|
64
|
+
waitOpen: opts.waitOpen ?? false,
|
|
65
|
+
timeoutMs: opts.timeoutMs ?? 1500,
|
|
66
|
+
})) === true
|
|
67
|
+
);
|
|
68
|
+
},
|
|
69
|
+
async recorderNativeState() {
|
|
70
|
+
const b = gravixAndroidAudioBridge();
|
|
71
|
+
if (!b) return null;
|
|
72
|
+
return asMap(await b.call('recorderNativeState')) as Record<
|
|
73
|
+
string,
|
|
74
|
+
boolean
|
|
75
|
+
> | null;
|
|
76
|
+
},
|
|
77
|
+
async setCaptureClosed(closed) {
|
|
78
|
+
const b = gravixAndroidAudioBridge();
|
|
79
|
+
if (!b) return null;
|
|
80
|
+
const r = asMap(await b.call('setCaptureClosed', { closed }));
|
|
81
|
+
return r ? r.ok === true : null;
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const delay = (ms: number) => new Promise<void>((r) => setTimeout(r, ms));
|
|
86
|
+
|
|
87
|
+
export type GravixMicMuteKind = 'none' | 'voiceOnlyReleased' | 'voiceOnly';
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Engine-wide state (one audio device module per process), port of Dart
|
|
91
|
+
* `GravixEngineMicMute` + the matching `LocalAudioTrack` flows.
|
|
92
|
+
*/
|
|
93
|
+
export class GravixMicMute {
|
|
94
|
+
/**
|
|
95
|
+
* `GravixMicRelease.setMuteReleasesMic`: a mute under room music may release
|
|
96
|
+
* the recorder. Default true (Flutter 0.12.1+ `muteReleasesMic`); rollback:
|
|
97
|
+
* `registerGlobals({ muteReleasesMic: false })`.
|
|
98
|
+
*/
|
|
99
|
+
muteReleasesMic = true;
|
|
100
|
+
private readonly listeners = new Set<() => void>();
|
|
101
|
+
private engaged = false;
|
|
102
|
+
private recorderReleased = false;
|
|
103
|
+
private kind: GravixMicMuteKind = 'none';
|
|
104
|
+
private owner: GravixMicTrackLike | null = null;
|
|
105
|
+
|
|
106
|
+
constructor(
|
|
107
|
+
private readonly native: GravixMicNative = bridgeMicNative,
|
|
108
|
+
private readonly sleep: (ms: number) => Promise<void> = delay,
|
|
109
|
+
private readonly log: (
|
|
110
|
+
level: 'info' | 'warn' | 'error',
|
|
111
|
+
msg: string
|
|
112
|
+
) => void = () => {}
|
|
113
|
+
) {}
|
|
114
|
+
|
|
115
|
+
get muteKind(): GravixMicMuteKind {
|
|
116
|
+
return this.kind;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** Called on every voice-only mute change ({@link muteKind}). Returns the unsubscribe. */
|
|
120
|
+
onChange(fn: () => void): () => void {
|
|
121
|
+
this.listeners.add(fn);
|
|
122
|
+
return () => {
|
|
123
|
+
this.listeners.delete(fn);
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** @internal */
|
|
128
|
+
setKind(kind: GravixMicMuteKind, owner: GravixMicTrackLike | null): void {
|
|
129
|
+
const changed = kind !== this.kind;
|
|
130
|
+
this.kind = kind;
|
|
131
|
+
this.owner = owner;
|
|
132
|
+
if (!changed) return;
|
|
133
|
+
for (const fn of [...this.listeners]) {
|
|
134
|
+
try {
|
|
135
|
+
fn();
|
|
136
|
+
} catch (e) {
|
|
137
|
+
this.log('warn', `mic mute listener failed: ${e}`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Mute releases the mic (stock WebRTC keeps recording under a track mute):
|
|
144
|
+
* closes / reopens the hardware recorder through the capture seam. Null when
|
|
145
|
+
* the native side has no seam (then nothing changed). Off while
|
|
146
|
+
* {@link muteReleasesMic} is false (the reopen always runs).
|
|
147
|
+
*/
|
|
148
|
+
async setCaptureClosed(closed: boolean): Promise<boolean | null> {
|
|
149
|
+
if (!this.native.setCaptureClosed) return null;
|
|
150
|
+
if (closed && !this.muteReleasesMic) return false;
|
|
151
|
+
try {
|
|
152
|
+
return await this.native.setCaptureClosed(closed);
|
|
153
|
+
} catch (e) {
|
|
154
|
+
this.log(
|
|
155
|
+
'warn',
|
|
156
|
+
`mic mute: capture ${closed ? 'close' : 'reopen'} failed: ${e}`
|
|
157
|
+
);
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** The room is gone: a voice-only mute and the module mute are given back. */
|
|
163
|
+
async leave(): Promise<void> {
|
|
164
|
+
await this.setCaptureClosed(false);
|
|
165
|
+
if (this.kind !== 'none') this.setKind('none', null);
|
|
166
|
+
if (this.recorderReleased) await this.restoreRecorder(false);
|
|
167
|
+
await this.release();
|
|
168
|
+
}
|
|
169
|
+
get isEngaged(): boolean {
|
|
170
|
+
return this.engaged;
|
|
171
|
+
}
|
|
172
|
+
get isRecorderReleased(): boolean {
|
|
173
|
+
return this.recorderReleased;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/** The module mute (PCM zeroed, recorder running). False: not available (no setup / not Android). */
|
|
177
|
+
async engage(): Promise<boolean> {
|
|
178
|
+
let ok = false;
|
|
179
|
+
try {
|
|
180
|
+
ok = await this.native.setMicrophoneMute(true);
|
|
181
|
+
} catch (e) {
|
|
182
|
+
this.log('warn', `engine microphone mute failed: ${e}`);
|
|
183
|
+
}
|
|
184
|
+
this.engaged = ok;
|
|
185
|
+
return ok;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
async releaseRecorder(): Promise<boolean> {
|
|
189
|
+
if (!this.engaged) return false;
|
|
190
|
+
if (this.recorderReleased) return true;
|
|
191
|
+
let ok = false;
|
|
192
|
+
try {
|
|
193
|
+
ok = await this.native.setRecorderReleased(true);
|
|
194
|
+
} catch (e) {
|
|
195
|
+
this.log('warn', `recorder release failed: ${e}`);
|
|
196
|
+
}
|
|
197
|
+
this.recorderReleased = ok;
|
|
198
|
+
return ok;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
async restoreRecorder(waitOpen: boolean): Promise<boolean> {
|
|
202
|
+
if (!this.recorderReleased) return true;
|
|
203
|
+
this.recorderReleased = false;
|
|
204
|
+
try {
|
|
205
|
+
return await this.native.setRecorderReleased(false, { waitOpen });
|
|
206
|
+
} catch (e) {
|
|
207
|
+
this.log('error', `recorder restore failed: ${e}`);
|
|
208
|
+
return false;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/** Gives back the module mute (a released recorder first). */
|
|
213
|
+
async release(): Promise<void> {
|
|
214
|
+
if (this.recorderReleased) await this.restoreRecorder(false);
|
|
215
|
+
if (!this.engaged) return;
|
|
216
|
+
this.engaged = false;
|
|
217
|
+
try {
|
|
218
|
+
if (!(await this.native.setMicrophoneMute(false)))
|
|
219
|
+
this.log('error', 'engine microphone unmute refused');
|
|
220
|
+
} catch (e) {
|
|
221
|
+
this.log('error', `engine microphone unmute failed: ${e}`);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Mute while room music plays. [releaseMic] = `continueWhileMicReleased`.
|
|
227
|
+
* Returns the kind of mute taken; `none` means the caller's plain
|
|
228
|
+
* `track.mute()` ran instead (music silenced for the room: the 0.12.1 mute).
|
|
229
|
+
*/
|
|
230
|
+
async muteForMusic(
|
|
231
|
+
track: GravixMicTrackLike,
|
|
232
|
+
releaseMic: boolean
|
|
233
|
+
): Promise<GravixMicMuteKind> {
|
|
234
|
+
if (track.isMuted || this.kind !== 'none') return this.kind;
|
|
235
|
+
if (await this.engage()) {
|
|
236
|
+
if (releaseMic) {
|
|
237
|
+
if (await this.releaseRecorder()) {
|
|
238
|
+
this.setKind('voiceOnlyReleased', track);
|
|
239
|
+
this.log(
|
|
240
|
+
'info',
|
|
241
|
+
'mic mute: voice-only with the recorder released (room music playing; the publication stays live)'
|
|
242
|
+
);
|
|
243
|
+
return this.kind;
|
|
244
|
+
}
|
|
245
|
+
this.log(
|
|
246
|
+
'warn',
|
|
247
|
+
'mic mute: recorder release refused; a mute that releases the mic (the music stops for the room)'
|
|
248
|
+
);
|
|
249
|
+
} else {
|
|
250
|
+
this.setKind('voiceOnly', track);
|
|
251
|
+
this.log(
|
|
252
|
+
'info',
|
|
253
|
+
'mic mute: voice-only (room music playing; the mic stays open)'
|
|
254
|
+
);
|
|
255
|
+
return this.kind;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
// plain mute: the module mute stays on until the track is disabled (no voice frame in between)
|
|
259
|
+
await track.mute();
|
|
260
|
+
await this.release();
|
|
261
|
+
return 'none';
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/** Unmute of a {@link muteForMusic} mute (a plain mute: call `track.unmute()` yourself). */
|
|
265
|
+
async unmuteFromMusic(track: GravixMicTrackLike): Promise<boolean> {
|
|
266
|
+
if (this.kind === 'none' || this.owner !== track) return false;
|
|
267
|
+
const wasReleased = this.kind === 'voiceOnlyReleased';
|
|
268
|
+
this.setKind('none', null);
|
|
269
|
+
if (
|
|
270
|
+
wasReleased &&
|
|
271
|
+
this.recorderReleased &&
|
|
272
|
+
!(await this.restoreRecorder(true))
|
|
273
|
+
) {
|
|
274
|
+
// the capture seam keeps retrying the recorder start (every 500 ms) while the
|
|
275
|
+
// record thread delivers silence; nothing more to do from here
|
|
276
|
+
this.log(
|
|
277
|
+
'error',
|
|
278
|
+
'mic unmute: the recorder could not be reopened yet (no microphone?); the capture seam keeps retrying'
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
await this.release();
|
|
282
|
+
track.mediaStreamTrack.enabled = true;
|
|
283
|
+
return true;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* The music ended while {@link muteForMusic} held: becomes a plain mute
|
|
288
|
+
* (wire signalled; the room mic policy closes the recorder through the
|
|
289
|
+
* capture seam when mute releases the mic).
|
|
290
|
+
*/
|
|
291
|
+
async musicEnded(track: GravixMicTrackLike): Promise<void> {
|
|
292
|
+
if (this.kind === 'none' || this.owner !== track) return;
|
|
293
|
+
this.setKind('none', null);
|
|
294
|
+
// the core mute first (its trackMuted closes the recorder through the seam when mute
|
|
295
|
+
// releases the mic); then the release flag back, then the module mute off
|
|
296
|
+
await track.mute();
|
|
297
|
+
if (this.recorderReleased) await this.restoreRecorder(false);
|
|
298
|
+
await this.release();
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* The app muted the track through the core (`setMicrophoneEnabled(false)`)
|
|
303
|
+
* during a voice-only mute: the core now owns the mute. The recorder flag
|
|
304
|
+
* and the module mute are given back so a later core unmute carries voice.
|
|
305
|
+
*/
|
|
306
|
+
async coreMuted(track: GravixMicTrackLike): Promise<void> {
|
|
307
|
+
if (this.kind === 'none' || this.owner !== track) return;
|
|
308
|
+
this.setKind('none', null);
|
|
309
|
+
if (this.recorderReleased) await this.restoreRecorder(false);
|
|
310
|
+
await this.release();
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/** `setMuteReleasesMic(false)` under a released mute: the recorder is back, the voice stays muted. */
|
|
314
|
+
async unreleaseKeepingMute(): Promise<void> {
|
|
315
|
+
if (this.kind !== 'voiceOnlyReleased') return;
|
|
316
|
+
await this.restoreRecorder(true);
|
|
317
|
+
this.setKind('voiceOnly', this.owner);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
private async waitRecorder(
|
|
321
|
+
ok: (s: Record<string, boolean>) => boolean,
|
|
322
|
+
timeoutMs: number
|
|
323
|
+
): Promise<boolean | null> {
|
|
324
|
+
let waited = 0;
|
|
325
|
+
for (;;) {
|
|
326
|
+
const s = await this.native.recorderNativeState();
|
|
327
|
+
if (s == null) return null;
|
|
328
|
+
if (ok(s)) return true;
|
|
329
|
+
if (waited >= timeoutMs) return false;
|
|
330
|
+
await this.sleep(20);
|
|
331
|
+
waited += 20;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Closes the recorder of a mic published while already muted (device
|
|
337
|
+
* 2026-11-28: WebRTC starts it ~300 ms after the publish returns; a toggle
|
|
338
|
+
* before that changes nothing). Returns true when the recorder was seen
|
|
339
|
+
* stopped (or the state is unreadable after one toggle).
|
|
340
|
+
*/
|
|
341
|
+
async closeMutedCapture(track: GravixMicTrackLike): Promise<boolean> {
|
|
342
|
+
if (!track.isMuted || this.kind !== 'none') return false;
|
|
343
|
+
// capture seam: close the recorder directly (the toggle below needs an
|
|
344
|
+
// audio device module that stops recording on a send-stream mute)
|
|
345
|
+
const seam = await this.setCaptureClosed(true);
|
|
346
|
+
if (seam !== null) {
|
|
347
|
+
this.log(
|
|
348
|
+
'info',
|
|
349
|
+
`mic mute: recorder of the muted publish closed (seam ok=${seam})`
|
|
350
|
+
);
|
|
351
|
+
return true;
|
|
352
|
+
}
|
|
353
|
+
const engagedHere = !this.engaged && (await this.engage());
|
|
354
|
+
if (!this.engaged) {
|
|
355
|
+
this.log(
|
|
356
|
+
'warn',
|
|
357
|
+
'mic mute: no engine mute for the recorder close; the recorder may stay open'
|
|
358
|
+
);
|
|
359
|
+
return false;
|
|
360
|
+
}
|
|
361
|
+
try {
|
|
362
|
+
for (let round = 1; round <= 3; round++) {
|
|
363
|
+
const started = await this.waitRecorder(
|
|
364
|
+
(s) => s.nativeStart === true,
|
|
365
|
+
1500
|
|
366
|
+
);
|
|
367
|
+
// the user may have unmuted while we waited: leave the live mic alone
|
|
368
|
+
if (!track.isMuted) {
|
|
369
|
+
this.log(
|
|
370
|
+
'info',
|
|
371
|
+
'mic mute: unmuted during the recorder close; stopped'
|
|
372
|
+
);
|
|
373
|
+
return false;
|
|
374
|
+
}
|
|
375
|
+
track.mediaStreamTrack.enabled = true;
|
|
376
|
+
track.mediaStreamTrack.enabled = false;
|
|
377
|
+
if (started == null) {
|
|
378
|
+
this.log(
|
|
379
|
+
'info',
|
|
380
|
+
'mic mute: recorder of the muted publish closed (toggle; state unreadable)'
|
|
381
|
+
);
|
|
382
|
+
return true;
|
|
383
|
+
}
|
|
384
|
+
const stopped = await this.waitRecorder(
|
|
385
|
+
(s) => s.nativeStart === false,
|
|
386
|
+
1000
|
|
387
|
+
);
|
|
388
|
+
await this.sleep(250);
|
|
389
|
+
const still = await this.waitRecorder(
|
|
390
|
+
(s) => s.nativeStart === false,
|
|
391
|
+
0
|
|
392
|
+
);
|
|
393
|
+
if (!track.isMuted) {
|
|
394
|
+
// unmuted mid-round: the core set enabled = true after our toggle; keep it
|
|
395
|
+
track.mediaStreamTrack.enabled = true;
|
|
396
|
+
return false;
|
|
397
|
+
}
|
|
398
|
+
if (stopped === true && still === true) {
|
|
399
|
+
this.log(
|
|
400
|
+
'info',
|
|
401
|
+
`mic mute: recorder of the muted publish closed (round ${round})`
|
|
402
|
+
);
|
|
403
|
+
return true;
|
|
404
|
+
}
|
|
405
|
+
this.log(
|
|
406
|
+
'warn',
|
|
407
|
+
`mic mute: the engine still records after round ${round}; retrying`
|
|
408
|
+
);
|
|
409
|
+
}
|
|
410
|
+
this.log(
|
|
411
|
+
'error',
|
|
412
|
+
'mic mute: the engine kept the recorder after 3 rounds'
|
|
413
|
+
);
|
|
414
|
+
return false;
|
|
415
|
+
} finally {
|
|
416
|
+
if (engagedHere) await this.release();
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
/** Process-wide instance (the audio device module is one per process). */
|
|
422
|
+
export const gravixMicMute = new GravixMicMute();
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// Copyright (c) 2026 Gravity Compile. MIT License; see LICENSE.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Bridge to the Android-native audio features (`GravixNativeAudio.kt`): one
|
|
5
|
+
* call with the Flutter SDK's method names and argument maps, plus native
|
|
6
|
+
* events. The TurboModule binding installs itself with
|
|
7
|
+
* {@link setGravixAndroidAudioBridge}; tests install a fake.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export type GravixAndroidAudioEvent =
|
|
11
|
+
| 'onVoiceEffects'
|
|
12
|
+
| 'onNoiseSuppression'
|
|
13
|
+
| 'onMicrophoneFailure'
|
|
14
|
+
| 'music.onCompleted'
|
|
15
|
+
| 'music.onError'
|
|
16
|
+
| 'music.onInterruption';
|
|
17
|
+
|
|
18
|
+
export type GravixAndroidAudioListener = (
|
|
19
|
+
payload: Record<string, unknown> | null
|
|
20
|
+
) => void;
|
|
21
|
+
|
|
22
|
+
export interface GravixAndroidAudioBridge {
|
|
23
|
+
call(method: string, args?: Record<string, unknown>): Promise<unknown>;
|
|
24
|
+
addListener(
|
|
25
|
+
event: GravixAndroidAudioEvent,
|
|
26
|
+
listener: GravixAndroidAudioListener
|
|
27
|
+
): () => void;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Thrown when the native side is missing (iOS, web, no `GravixRtc.setup`). */
|
|
31
|
+
export class GravixNativeUnavailableError extends Error {
|
|
32
|
+
readonly code = 'NATIVE_UNAVAILABLE';
|
|
33
|
+
constructor(feature: string, why: string) {
|
|
34
|
+
super(`${feature}: ${why}`);
|
|
35
|
+
this.name = 'GravixNativeUnavailableError';
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
let bridge: GravixAndroidAudioBridge | null = null;
|
|
40
|
+
|
|
41
|
+
export function setGravixAndroidAudioBridge(
|
|
42
|
+
b: GravixAndroidAudioBridge | null
|
|
43
|
+
): void {
|
|
44
|
+
bridge = b;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function gravixAndroidAudioBridge(): GravixAndroidAudioBridge | null {
|
|
48
|
+
return bridge;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function requireBridge(feature: string): GravixAndroidAudioBridge {
|
|
52
|
+
if (!bridge) {
|
|
53
|
+
throw new GravixNativeUnavailableError(
|
|
54
|
+
feature,
|
|
55
|
+
'the Android native audio module is not available on this platform'
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
return bridge;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** The native capability map (`GravixNativeAudio.capabilities`). */
|
|
62
|
+
export interface GravixAndroidAudioCapabilities {
|
|
63
|
+
/** `GravixRtc.setup` ran (our audio device module exists). */
|
|
64
|
+
setup: boolean;
|
|
65
|
+
/** Our module / processing are still the ones WebRTC uses (another library may replace them). */
|
|
66
|
+
admInstalled: boolean;
|
|
67
|
+
processingInstalled: boolean;
|
|
68
|
+
/** WebRTC created its factory (and with it our capture post-processing). */
|
|
69
|
+
processingCreated: boolean;
|
|
70
|
+
audioScenario: 'standard' | 'chatRoom';
|
|
71
|
+
voiceEffects: boolean;
|
|
72
|
+
noiseSuppression: boolean;
|
|
73
|
+
roomMusic: boolean;
|
|
74
|
+
singerMode: boolean;
|
|
75
|
+
muteReleasesMic: boolean;
|
|
76
|
+
audioScenarioSupported?: boolean;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export async function androidAudioCapabilities(): Promise<GravixAndroidAudioCapabilities | null> {
|
|
80
|
+
if (!bridge) return null;
|
|
81
|
+
try {
|
|
82
|
+
return (await bridge.call(
|
|
83
|
+
'capabilities'
|
|
84
|
+
)) as GravixAndroidAudioCapabilities;
|
|
85
|
+
} catch {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function asMap(v: unknown): Record<string, unknown> | null {
|
|
91
|
+
return v !== null && typeof v === 'object'
|
|
92
|
+
? (v as Record<string, unknown>)
|
|
93
|
+
: null;
|
|
94
|
+
}
|