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,160 @@
|
|
|
1
|
+
// Copyright (c) 2024-2026 Gravity Compile. MIT License; see LICENSE.
|
|
2
|
+
|
|
3
|
+
package com.gravitycompile.gravixrtc.processing
|
|
4
|
+
|
|
5
|
+
import android.util.Log
|
|
6
|
+
import java.nio.ByteBuffer
|
|
7
|
+
import java.util.concurrent.Executors
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Voice effects on the capture stream (native/gxfx). Runs right after noise
|
|
11
|
+
* suppression, inside [GxNoiseProcessor.process], so the order cannot change.
|
|
12
|
+
*
|
|
13
|
+
* Until the first effect is asked for, process() is one volatile read and the
|
|
14
|
+
* library is not loaded. The native instance lives for the process.
|
|
15
|
+
* Threads: process() = WebRTC capture thread; the rest = main / [worker].
|
|
16
|
+
*/
|
|
17
|
+
internal object GxVoiceFx {
|
|
18
|
+
private const val TAG = "GravixRTC"
|
|
19
|
+
private const val WATCHDOG_US = 6000
|
|
20
|
+
private const val WATCHDOG_CONSECUTIVE = 5
|
|
21
|
+
val PRESETS = listOf(
|
|
22
|
+
"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",
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
@Volatile var eventSink: ((Map<String, Any?>) -> Unit)? = null
|
|
26
|
+
@Volatile private var used = false
|
|
27
|
+
@Volatile private var handle = 0L
|
|
28
|
+
@Volatile private var musicActive = false
|
|
29
|
+
/** Music is mixed BEFORE the effect (pre-APM route): the effect must be dry. */
|
|
30
|
+
@Volatile private var musicPreMixed = false
|
|
31
|
+
private var loadError: String? = null
|
|
32
|
+
private val worker by lazy { Executors.newSingleThreadExecutor { r -> Thread(r, "gravix-fx") } }
|
|
33
|
+
|
|
34
|
+
/** libgxfx loads on this device (capability flag). */
|
|
35
|
+
val libraryLoaded: Boolean get() = loaded
|
|
36
|
+
|
|
37
|
+
private val loaded: Boolean by lazy {
|
|
38
|
+
try {
|
|
39
|
+
System.loadLibrary("gxfx")
|
|
40
|
+
true
|
|
41
|
+
} catch (t: Throwable) {
|
|
42
|
+
loadError = "library_missing"
|
|
43
|
+
Log.w(TAG, "[GravixFX] library missing: ${t.javaClass.simpleName}")
|
|
44
|
+
false
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
fun wanted(): Boolean = used
|
|
49
|
+
|
|
50
|
+
/** Capture thread, after noise suppression. Mono full-band floats only. */
|
|
51
|
+
fun process(buffer: ByteBuffer, numFrames: Int, channels: Int) {
|
|
52
|
+
if (!used) return
|
|
53
|
+
val h = handle
|
|
54
|
+
if (h == 0L) return
|
|
55
|
+
if (GxNsFrameShape.reject(numFrames, buffer.capacity(), buffer.isDirect, channels) != null) return
|
|
56
|
+
when (nativeProcess(h, buffer, numFrames, numFrames * 100)) {
|
|
57
|
+
RESULT_NEED_REBUILD -> worker.execute { nativeRebuild(handle) }
|
|
58
|
+
RESULT_WATCHDOG -> worker.execute {
|
|
59
|
+
Log.w(TAG, "[GravixFX] watchdog budget_us=$WATCHDOG_US consecutive=$WATCHDOG_CONSECUTIVE: effect off")
|
|
60
|
+
eventSink?.invoke(state(handle) + ("type" to "watchdog"))
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** fxConfigure from Dart: {effect}. Main thread. */
|
|
66
|
+
@Synchronized
|
|
67
|
+
fun configure(args: Map<String, Any?>): Map<String, Any?> {
|
|
68
|
+
val name = args["effect"] as? String ?: "none"
|
|
69
|
+
val preset = PRESETS.indexOf(name)
|
|
70
|
+
if (preset < 0) return mapOf("ok" to false, "reason" to "unknown_effect")
|
|
71
|
+
if (preset == 0 && handle == 0L) return mapOf("ok" to true, "effect" to "none", "active" to "none", "reason" to "ok")
|
|
72
|
+
if (!loaded) return mapOf("ok" to false, "reason" to (loadError ?: "library_missing"))
|
|
73
|
+
if (handle == 0L) {
|
|
74
|
+
handle = nativeCreate()
|
|
75
|
+
nativeSetWatchdog(handle, WATCHDOG_US, WATCHDOG_CONSECUTIVE)
|
|
76
|
+
nativeSetBypass(handle, musicPreMixed)
|
|
77
|
+
}
|
|
78
|
+
val rc = nativeSetPreset(handle, preset)
|
|
79
|
+
used = true
|
|
80
|
+
// effect on: room music moves after it (MusicCaptureRouter), "none": back before APM
|
|
81
|
+
com.gravitycompile.gravixrtc.music.MusicMixerEngine.router.effectWanted = preset != 0 && rc == 0
|
|
82
|
+
val installed = GxNoiseProcessor.installOn("fxConfigure")
|
|
83
|
+
Log.i(TAG, "[GravixFX] step=configure effect=$name rc=$rc installed=$installed music=$musicActive bypass=$musicPreMixed")
|
|
84
|
+
return state(handle) + mapOf("ok" to (rc == 0), "installed" to installed, "reason" to if (rc == 0) "ok" else "failed")
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** Music session start / end (any thread). The bypass itself follows [setMusicBypass]. */
|
|
88
|
+
fun onMusic(active: Boolean) {
|
|
89
|
+
if (musicActive == active) return
|
|
90
|
+
musicActive = active
|
|
91
|
+
if (handle == 0L) return
|
|
92
|
+
Log.i(TAG, "[GravixFX] step=music active=$active bypass=$musicPreMixed")
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* MusicCaptureRouter: [on] = the music is in the buffer before the effect
|
|
97
|
+
* (go dry), off = no music there (effect on the voice; the music, if any,
|
|
98
|
+
* is added after it). Record or control thread: an atomic store, the log
|
|
99
|
+
* and the event go to [worker].
|
|
100
|
+
*/
|
|
101
|
+
fun setMusicBypass(on: Boolean) {
|
|
102
|
+
if (musicPreMixed == on) return
|
|
103
|
+
musicPreMixed = on
|
|
104
|
+
val h = handle
|
|
105
|
+
if (h == 0L) return
|
|
106
|
+
nativeSetBypass(h, on)
|
|
107
|
+
worker.execute {
|
|
108
|
+
Log.i(TAG, "[GravixFX] step=music bypass=$on active=$musicActive")
|
|
109
|
+
eventSink?.invoke(state(handle) + ("type" to "music"))
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** Delay of the active chain, ms (0 = none). Control / timer thread. */
|
|
114
|
+
fun latencyMs(): Int {
|
|
115
|
+
val h = handle
|
|
116
|
+
if (h == 0L || !used) return 0
|
|
117
|
+
val v = IntArray(9)
|
|
118
|
+
nativeStatus(h, v)
|
|
119
|
+
return if (v[1] == 0 || v[4] != 0) 0 else v[5] // no chain, or watchdog: passthrough
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
fun stats(): Map<String, Any?> {
|
|
123
|
+
if (handle == 0L) return mapOf("ok" to true, "effect" to "none", "active" to "none", "reason" to "ok")
|
|
124
|
+
return state(handle) + mapOf("ok" to true, "reason" to "ok")
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** On a private chain, off the audio path. */
|
|
128
|
+
fun benchmark(args: Map<String, Any?>, done: (Map<String, Any?>) -> Unit) {
|
|
129
|
+
val preset = PRESETS.indexOf(args["effect"] as? String ?: "girl")
|
|
130
|
+
val rate = (args["rate"] as? Number)?.toInt() ?: 48000
|
|
131
|
+
val seconds = (args["seconds"] as? Number)?.toInt() ?: 5
|
|
132
|
+
if (preset < 0 || !loaded) return done(mapOf("ok" to false, "reason" to (loadError ?: "unknown_effect")))
|
|
133
|
+
worker.execute {
|
|
134
|
+
val v = IntArray(5)
|
|
135
|
+
val rc = nativeBenchmark(preset, rate, seconds, v)
|
|
136
|
+
Log.i(TAG, "[GravixFX] step=benchmark effect=${PRESETS[preset]} rate=$rate p50=${v[1]} p95=${v[2]} max=${v[3]} rc=$rc")
|
|
137
|
+
done(mapOf("ok" to (rc == 0), "effect" to PRESETS[preset], "rate" to rate, "blocks" to v[0],
|
|
138
|
+
"p50Us" to v[1], "p95Us" to v[2], "maxUs" to v[3], "latencyMs" to v[4]))
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
private fun state(h: Long): Map<String, Any?> {
|
|
143
|
+
val v = IntArray(9)
|
|
144
|
+
nativeStatus(h, v)
|
|
145
|
+
return mapOf("effect" to PRESETS[v[0]], "active" to PRESETS[v[1]], "rate" to v[2], "musicBypass" to (v[3] != 0),
|
|
146
|
+
"watchdog" to (v[4] != 0), "latencyMs" to v[5], "frames" to v[6], "over" to v[7], "maxUs" to v[8])
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
private const val RESULT_NEED_REBUILD = 2
|
|
150
|
+
private const val RESULT_WATCHDOG = 3
|
|
151
|
+
|
|
152
|
+
@JvmStatic private external fun nativeCreate(): Long
|
|
153
|
+
@JvmStatic private external fun nativeSetPreset(h: Long, preset: Int): Int
|
|
154
|
+
@JvmStatic private external fun nativeRebuild(h: Long)
|
|
155
|
+
@JvmStatic private external fun nativeSetBypass(h: Long, on: Boolean)
|
|
156
|
+
@JvmStatic private external fun nativeSetWatchdog(h: Long, budgetUs: Int, consecutive: Int)
|
|
157
|
+
@JvmStatic private external fun nativeProcess(h: Long, buffer: ByteBuffer, frames: Int, rate: Int): Int
|
|
158
|
+
@JvmStatic private external fun nativeStatus(h: Long, out: IntArray)
|
|
159
|
+
@JvmStatic private external fun nativeBenchmark(preset: Int, rate: Int, seconds: Int, out: IntArray): Int
|
|
160
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
// Copyright (c) 2026 Gravity Compile. MIT License; see LICENSE.
|
|
2
|
+
|
|
3
|
+
package com.gravitycompile.gravixrtc.processing
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Pure decisions of the other-app audio watcher (owner report 2026-10-10: "with
|
|
7
|
+
* the mic on, YouTube or a game on the phone is heard by the room"). In the
|
|
8
|
+
* media profile WebRTC captures from the MIC source and its software echo
|
|
9
|
+
* canceller only knows what WebRTC itself plays, so another app's audio on the
|
|
10
|
+
* loudspeaker goes to the room. No Android types here, so it is unit-tested on
|
|
11
|
+
* the JVM.
|
|
12
|
+
*/
|
|
13
|
+
internal object OtherAppAudioPolicy {
|
|
14
|
+
// android.media.AudioAttributes values (stable public constants)
|
|
15
|
+
private const val USAGE_UNKNOWN = 0
|
|
16
|
+
private const val USAGE_MEDIA = 1
|
|
17
|
+
private const val USAGE_ASSISTANCE_NAVIGATION_GUIDANCE = 12
|
|
18
|
+
private const val USAGE_GAME = 14
|
|
19
|
+
private const val USAGE_ASSISTANT = 16
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Usages that carry sustained audible content from another app. Calls
|
|
23
|
+
* (voice communication), ringtones, alarms, notifications and UI sounds are
|
|
24
|
+
* left out: they are short, or the SDK's own call handling covers them.
|
|
25
|
+
* USAGE_UNKNOWN is in because many games never set a usage.
|
|
26
|
+
*/
|
|
27
|
+
private val audible = setOf(USAGE_UNKNOWN, USAGE_MEDIA, USAGE_ASSISTANCE_NAVIGATION_GUIDANCE, USAGE_GAME, USAGE_ASSISTANT)
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* One started player from AudioManager's playback configurations. The public
|
|
31
|
+
* API gives no uid (configurations are anonymised for apps), only the
|
|
32
|
+
* attributes and, on API 31+, the output device. [onSpeaker] false = routed
|
|
33
|
+
* to a headset (not an acoustic leak); null = unknown (counted).
|
|
34
|
+
*/
|
|
35
|
+
data class Player(val usage: Int, val contentType: Int, val onSpeaker: Boolean?)
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* How many started players are NOT the room's own playout and can be heard
|
|
39
|
+
* by the microphone. [ownPlayout] = the attributes of WebRTC's running
|
|
40
|
+
* playout track, or null when it is not playing; exactly one player with
|
|
41
|
+
* those attributes is ours (another app with identical attributes still
|
|
42
|
+
* counts).
|
|
43
|
+
*/
|
|
44
|
+
fun foreignPlayers(players: List<Player>, ownPlayout: Player?): Int = foreignPlayers(players, listOfNotNull(ownPlayout))
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Same, with every player of our own process that is running now: WebRTC's
|
|
48
|
+
* playout and the SDK's keep-alive ([keepAlivePlayer]). Each entry is one
|
|
49
|
+
* player of ours: it removes exactly one started player with the same usage
|
|
50
|
+
* and content type (another app with identical attributes still counts).
|
|
51
|
+
*/
|
|
52
|
+
fun foreignPlayers(players: List<Player>, own: List<Player>): Int {
|
|
53
|
+
val ownLeft = own.toMutableList()
|
|
54
|
+
var count = 0
|
|
55
|
+
for (p in players) {
|
|
56
|
+
val mine = ownLeft.indexOfFirst { it.usage == p.usage && it.contentType == p.contentType }
|
|
57
|
+
if (mine >= 0) {
|
|
58
|
+
ownLeft.removeAt(mine)
|
|
59
|
+
continue
|
|
60
|
+
}
|
|
61
|
+
if (p.usage !in audible) continue
|
|
62
|
+
if (p.onSpeaker == false) continue
|
|
63
|
+
count++
|
|
64
|
+
}
|
|
65
|
+
return count
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// android.media.AudioAttributes.CONTENT_TYPE_UNKNOWN
|
|
69
|
+
private const val CONTENT_TYPE_UNKNOWN = 0
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* The SDK's silent keep-alive player (GxKeepAlivePlayer,
|
|
73
|
+
* backgroundKeepAlive) with the session's [usage]; the keep-alive builds its
|
|
74
|
+
* AudioAttributes from this, so both always agree.
|
|
75
|
+
*
|
|
76
|
+
* Why (merge 2026-10-11): in the media profile it is a USAGE_MEDIA player
|
|
77
|
+
* that starts exactly when WebRTC's playout is not running (backgrounded,
|
|
78
|
+
* no remote audio), so with only the playout excluded the other-app watcher
|
|
79
|
+
* counted it as another app and muteMicInBackground muted the user. The
|
|
80
|
+
* public playback configurations carry no uid or session id (they are
|
|
81
|
+
* anonymised for apps), so it is told apart like the playout: by attributes.
|
|
82
|
+
*/
|
|
83
|
+
fun keepAlivePlayer(usage: Int): Player = Player(usage, CONTENT_TYPE_UNKNOWN, true)
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Reports "playing" after [onDelayMs] of continuous presence and "stopped"
|
|
87
|
+
* after [offDelayMs] of continuous absence: a 300 ms game blip or a gap
|
|
88
|
+
* between two videos must not toggle the capture (each toggle of the
|
|
89
|
+
* VOICE_COMMUNICATION action restarts the recorder). Times are injected.
|
|
90
|
+
*/
|
|
91
|
+
class Debouncer(private val onDelayMs: Long, private val offDelayMs: Long) {
|
|
92
|
+
var state = false
|
|
93
|
+
private set
|
|
94
|
+
private var pendingSince: Long? = null
|
|
95
|
+
|
|
96
|
+
/** Feeds the raw observation at [nowMs]; returns the debounced state. */
|
|
97
|
+
fun update(raw: Boolean, nowMs: Long): Boolean {
|
|
98
|
+
if (raw == state) {
|
|
99
|
+
pendingSince = null
|
|
100
|
+
return state
|
|
101
|
+
}
|
|
102
|
+
val since = pendingSince ?: nowMs.also { pendingSince = it }
|
|
103
|
+
val delay = if (raw) onDelayMs else offDelayMs
|
|
104
|
+
if (nowMs - since >= delay) {
|
|
105
|
+
state = raw
|
|
106
|
+
pendingSince = null
|
|
107
|
+
}
|
|
108
|
+
return state
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** Back to "stopped" with nothing pending (the watcher stopped). */
|
|
112
|
+
fun reset() {
|
|
113
|
+
state = false
|
|
114
|
+
pendingSince = null
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** When a re-check is due (the pending change matures), or null. */
|
|
118
|
+
fun nextCheckAt(): Long? = pendingSince?.let { it + if (state) offDelayMs else onDelayMs }
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** The capture action Dart asks for (GravixOtherAppCaptureAction.wire). */
|
|
122
|
+
enum class Action {
|
|
123
|
+
NONE,
|
|
124
|
+
PLATFORM_EFFECTS,
|
|
125
|
+
VOICE_COMMUNICATION,
|
|
126
|
+
MUTE;
|
|
127
|
+
|
|
128
|
+
companion object {
|
|
129
|
+
fun parse(wire: String?): Action = when (wire) {
|
|
130
|
+
"platformEffects" -> PLATFORM_EFFECTS
|
|
131
|
+
"voiceCommunication" -> VOICE_COMMUNICATION
|
|
132
|
+
"mute" -> MUTE
|
|
133
|
+
else -> NONE
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* The audio engine's microphone mute: the user's mute and the automatic
|
|
140
|
+
* other-app mute are kept apart, so neither undoes the other.
|
|
141
|
+
*/
|
|
142
|
+
fun engineMute(userMuted: Boolean, autoMuted: Boolean): Boolean = userMuted || autoMuted
|
|
143
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// Copyright 2023-2026 LiveKit, Inc.
|
|
2
|
+
// Modifications Copyright 2026 Gravity Compile.
|
|
3
|
+
// Licensed under the Apache License, Version 2.0; see LICENSES/Apache-2.0.txt.
|
|
4
|
+
|
|
5
|
+
package org.webrtc.audio
|
|
6
|
+
|
|
7
|
+
import android.media.AudioAttributes
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The playout AudioAttributes of WebRTC's AudioTrack. In org.jitsi:webrtc 155.0.1
|
|
11
|
+
* `JavaAudioDeviceModule.audioOutput` and `WebRtcAudioTrack.audioAttributes` are
|
|
12
|
+
* private (final), so they are read and replaced by reflection; WebRTC uses the
|
|
13
|
+
* new value the next time it creates its AudioTrack (playout start).
|
|
14
|
+
*/
|
|
15
|
+
object WebRtcAudioTrackHelper {
|
|
16
|
+
|
|
17
|
+
private fun audioOutput(adm: JavaAudioDeviceModule): WebRtcAudioTrack =
|
|
18
|
+
JavaAudioDeviceModule::class.java.getDeclaredField("audioOutput")
|
|
19
|
+
.apply { isAccessible = true }.get(adm) as WebRtcAudioTrack
|
|
20
|
+
|
|
21
|
+
private val attributesField by lazy {
|
|
22
|
+
WebRtcAudioTrack::class.java.getDeclaredField("audioAttributes").apply { isAccessible = true }
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
fun getAudioOutputAttributes(adm: JavaAudioDeviceModule): AudioAttributes {
|
|
26
|
+
val current = try {
|
|
27
|
+
attributesField.get(audioOutput(adm)) as AudioAttributes?
|
|
28
|
+
} catch (_: Throwable) {
|
|
29
|
+
null
|
|
30
|
+
}
|
|
31
|
+
return current ?: AudioAttributes.Builder()
|
|
32
|
+
.setUsage(AudioAttributes.USAGE_VOICE_COMMUNICATION)
|
|
33
|
+
.setContentType(AudioAttributes.CONTENT_TYPE_SPEECH)
|
|
34
|
+
.build()
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
fun setAudioOutputAttributes(
|
|
38
|
+
adm: JavaAudioDeviceModule,
|
|
39
|
+
audioAttributes: AudioAttributes,
|
|
40
|
+
) {
|
|
41
|
+
attributesField.set(audioOutput(adm), audioAttributes)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# Android native audio/video hooks: Flutter SDK vs React Native
|
|
2
|
+
|
|
3
|
+
Status: the React Native SDK's Android port of the Flutter SDK's native
|
|
4
|
+
features (reference: Flutter `gravix_rtc` 0.12.2 = `5c4d44c`).
|
|
5
|
+
Date: 2026-11-30; rebased on react-native-webrtc 155 on 2026-12-01.
|
|
6
|
+
|
|
7
|
+
## 1. What the Flutter SDK hooks into
|
|
8
|
+
|
|
9
|
+
| Feature | Flutter hook (0.12.2) | Where |
|
|
10
|
+
|---|---|---|
|
|
11
|
+
| Noise suppression (levels off/standard/studio/auto) | flutter_webrtc `AudioProcessingController.capturePostProcessing` = an `ExternalAudioProcessingFactory` capture post-processor (after WebRTC's AEC) | `rtc/GxNoiseProcessor.kt` (`installOn`) |
|
|
12
|
+
| Voice effects (35 presets + none) | Same post-processor, called after NS inside `GxNoiseProcessor.process` | `rtc/GxVoiceFx.kt` |
|
|
13
|
+
| Room music mixed into the mic | `JavaAudioDeviceModule.AudioBufferCallback` on `WebRtcAudioRecord`, installed by **reflection** into the private final field `audioBufferCallback` of the ADM flutter_webrtc built; post-effect route through the APM post-processor | `music/MusicMixerPlugin.kt`, `music/MusicMixerEngine.kt`, `music/MusicCaptureRouter.kt` |
|
|
14
|
+
| Mic volume, ducking, singer mode, singer capture source | Mixer kernel gains; capture source = reflective rewrite of `WebRtcAudioRecord.audioSource` + recorder restart | `music/MusicMixKernel.kt`, `rtc/GxCaptureSwitcher.kt`, `rtc/GxSingerSource.kt` |
|
|
15
|
+
| Mute (module mute, recorder released under music, 0.12.2 close after a muted publish) | `JavaAudioDeviceModule.setMicrophoneMute`; reflection on `WebRtcAudioRecord` privates `useAudioRecord`, `audioRecordStateLock`, `audioRecord`, `audioThread`, `nativeCalledStartRecording`, `clientCalledStartRecording`; the orchestration is in Dart (`LocalAudioTrack.mute/unmute`, `GravixEngineMicMute`) | `music/MusicMicRelease.kt`, `GravixClientPlugin.recorderNativeState`, Dart `track/local/audio.dart` |
|
|
16
|
+
| Refused mic start guard | `JavaAudioDeviceModule` record error callback (reflection-installed in Flutter) | `rtc/GxRecordStartGuard.kt` |
|
|
17
|
+
| Audio scenario `chatRoom` | flutter_webrtc `WebRTC.initialize` options: communication audio attributes, hardware AEC/NS, input 16 kHz, output 48 kHz | Dart `gravix_audio_scenario.dart` |
|
|
18
|
+
| Beauty effects | `gravix_effects` (own CameraX camera + GL engine, licensed `com.gravix:gravix-effects*` AARs bundled in the plugin's `android/maven`) + `gravix_effects_webrtc` (`factory.createVideoSource`, a `CapturerObserver` bridge, track added to a flutter_webrtc local stream) | pub `gravix_effects{,_webrtc}` 1.4.x |
|
|
19
|
+
|
|
20
|
+
## 2. What react-native-webrtc 155 exposes (2026-12-01)
|
|
21
|
+
|
|
22
|
+
WebRTC build: `org.jitsi:webrtc` (react-native-webrtc declares `155.+`; this
|
|
23
|
+
library pins `155.0.1` strictly in `android/build.gradle`), package
|
|
24
|
+
`org.webrtc`, a stock libwebrtc. Evidence (reproducible):
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
W=node_modules/react-native-webrtc/android/src/main/java/com/oney/WebRTCModule
|
|
28
|
+
cat $W/WebRTCModuleOptions.java # videoEncoderFactory, videoDecoderFactory, audioDeviceModule, logger, fieldTrials
|
|
29
|
+
sed -n '/public WebRTCModule(/,/^ }/p' $W/WebRTCModule.java # no audio processing factory is passed to the factory builder
|
|
30
|
+
# the WebRTC jar (from the AAR's libs/libwebrtc.jar):
|
|
31
|
+
javap -p org.webrtc.audio.WebRtcAudioRecord # no audioBufferCallback / useAudioRecord / start latches
|
|
32
|
+
javap -p 'org.webrtc.audio.JavaAudioDeviceModule$Builder' # no setAudioBufferCallback
|
|
33
|
+
javap -p org.webrtc.AudioTrack # no setAudioProcessingOptions
|
|
34
|
+
javap -p -c 'org.webrtc.audio.WebRtcAudioRecord$AudioRecordThread' # reads this$0.audioRecord every loop, then read(byteBuffer, capacity)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## 3. API map: what the SDK used from `react-native-webrtc` 150.2 (webrtc-sdk build) and its replacement
|
|
38
|
+
|
|
39
|
+
| Used before | Where | On react-native-webrtc 155 |
|
|
40
|
+
|---|---|---|
|
|
41
|
+
| `JavaAudioDeviceModule.Builder.setAudioBufferCallback` (pre-APM music mix) | `MusicMixerEngine` | **Capture seam** `processing/GxRecorderSeam.kt`: at each recording start (record-state callback, record thread) WebRTC's AudioRecord is replaced by a `GxAudioRecord` (same source / rate / channels / format / buffer / device, platform AEC + NS re-attached when the builder asked for them). Its `read()` calls `MusicMixerEngine.onBuffer` (same contract, own `CaptureBufferCallback` interface). |
|
|
42
|
+
| `ExternalAudioProcessingFactory` capture post-processing (NS -> voice FX -> post-effect music) via `WebRTCModuleOptions.audioProcessingFactoryFactory` | `GravixCaptureProcessing`, `GxNoiseProcessor` | Same chain, fed by the seam: each 10 ms mono frame as int16-scale floats (one band). **Behaviour change: it now runs BEFORE WebRTC's audio processing (software AEC / NS / AGC), not after it.** Stereo capture is passed through unprocessed. |
|
|
43
|
+
| `WebRtcAudioRecord.useAudioRecord` + `audioRecordStateLock` (recorder release under music, silent clock) | `MusicMicRelease` | `GxRecorderSeam.released`: the seam stops the hardware recorder and delivers silence that `MusicMixerEngine` clocks (bytesRead = 0); restore restarts it in the next read. A refused restart sets `reopenFailed` and keeps the record thread alive. |
|
|
44
|
+
| webrtc-sdk's ADM stopping the AudioRecord when every send stream is muted (0.12.1 mute releases mic) | JS `micPolicy` | Not in stock WebRTC. `GxRecorderSeam.closedByMute`, set from JS (`GravixMicMute.setCaptureClosed`, native `setCaptureClosed`) on every local mic `trackMuted` / `trackUnmuted` and for a mic published while muted (`closeMutedCapture`). |
|
|
45
|
+
| `nativeCalledStartRecording` / `clientCalledStartRecording` (recorder state, start guard) | `GravixNativeAudio.recorderNativeState`, `GxRecordStartGuard` | Stock has neither latch. `recorderNativeState.nativeStart` = the record thread runs; the start guard is only the failure reporter, set with `Builder.setAudioRecordErrorCallback` (no reflection; stock has no double-start abort). |
|
|
46
|
+
| Reflective `audioSource` rewrite + `stop/init/startRecordingImpl` (singer source, VOICE_COMMUNICATION) | `GxCaptureSwitcher` | `GxRecorderSeam.requestSource`: the record thread swaps in a recorder on the new source between two reads; refused -> stays on the current one. |
|
|
47
|
+
| `JavaAudioDeviceModule.setMicrophoneMute` (voice-only mute) | `GxCaptureSwitcher` | `GxRecorderSeam.applyEngineMute`: with the seam attached the voice is zeroed in `read()` before the music (the stock module mute zeroes after `read()`, music included); the module mute is used only while no seam recorder runs. |
|
|
48
|
+
| `org.webrtc.AudioTrack.setAudioProcessingOptions` (relax NS / AGC / HPF during music) | `GravixAudioModule` | Not in stock WebRTC: answers `{result: false, code: "rejectedPlatformUnavailable"}` (callers treat it as best effort). WebRTC keeps the processing chosen at capture. |
|
|
49
|
+
| `adm.audioOutput.audioAttributes` (package-private) | `WebRtcAudioTrackHelper` | Same fields, private in the stock jar: reflection (`audioOutput`, `audioAttributes`). |
|
|
50
|
+
| `WebRTCModuleOptions.defaultTrackVolume` | `GravixRtcModule.setDefaultRemoteAudioTrackVolume` | Removed from the native spec; `AudioSession.setDefaultRemoteAudioTrackVolume` sets a JS default that `registerGlobals()`'s room hook applies with `MediaStreamTrack._setVolume` on each `trackSubscribed`. |
|
|
51
|
+
| `WrappedVideoDecoderFactory`, `SimulcastVideoEncoderFactory` (webrtc-sdk Java classes) | `video/*` (Custom encoder / decoder factories) | Not in the stock jar. The factories were removed: react-native-webrtc's defaults (hardware H.264, software VP8 / VP9 / AV1; VP8 simulcast in libvpx). Hardware-encoder simulcast is gone. |
|
|
52
|
+
| Same-package helper in the old bridge package (`ThreadUtils`, `getTrack`) | `GravixWebRtcAccess` | No longer needed (it served `setAudioProcessingOptions`); removed. The effects package ships its own same-package helper (`com.oney.WebRTCModule.GravixRtcAccess`). |
|
|
53
|
+
| JS: `registerGlobals`, `RTCView` | `src/registerGlobals.ts`, `VideoView` | Same exports in 155. |
|
|
54
|
+
| JS: `AudioDeviceModule.setAutomaticAudioSessionConfiguration` (iOS) | `setupIOSAudioManagement` | Not in 155: native `setWebRTCAudioConfiguration` (`RTCAudioSessionConfiguration.webRTCConfiguration`). |
|
|
55
|
+
| JS: frame / data-packet cryptors, key provider | not used by this SDK | Not in 155 (E2EE stays not ported). |
|
|
56
|
+
|
|
57
|
+
The reflected members (`WebRtcAudioRecord.audioRecord` non-final, `audioThread`,
|
|
58
|
+
`audioSource`, `isAcousticEchoCancelerSupported`, `isNoiseSuppressorSupported`;
|
|
59
|
+
`JavaAudioDeviceModule.audioInput` / `audioOutput`; `WebRtcAudioTrack.audioAttributes`)
|
|
60
|
+
are pinned by `WebRtcReflectionContractTest` against the pinned jar and kept by
|
|
61
|
+
`consumer-rules.pro`.
|
|
62
|
+
|
|
63
|
+
## 4. Risks and what to measure on a device
|
|
64
|
+
|
|
65
|
+
1. **Processing order.** NS, voice effects and the music mix now sit before
|
|
66
|
+
WebRTC's AEC / NS / AGC. With platform (hardware) AEC the recorder already
|
|
67
|
+
delivers echo-cancelled audio; with software AEC a voice effect before AEC
|
|
68
|
+
makes the echo path non-linear. WebRTC's own NS / AGC also stay on during
|
|
69
|
+
a song or with Gravix NS (no runtime switch). Listen for echo, pumping and
|
|
70
|
+
music quality.
|
|
71
|
+
2. **Recorder swap.** One extra AudioRecord open per recording start (WebRTC
|
|
72
|
+
opens its own, the seam replaces it before the first read). Check start
|
|
73
|
+
latency, Bluetooth / wired routes (the preferred device is copied), and
|
|
74
|
+
that platform AEC / NS attach to the new session.
|
|
75
|
+
3. **Mute releases mic** now reopens the recorder on unmute (first ~100 ms of
|
|
76
|
+
speech may be lost). Check the OS mic indicator.
|
|
77
|
+
4. **WebRTC's own recorder still opens** for a moment at every recording
|
|
78
|
+
start (the seam replaces it before the first read), also while the mic is
|
|
79
|
+
closed by a mute: a brief OS mic indicator blink is possible.
|
|
80
|
+
5. **Stereo capture** is passed through without the capture chain (NS / voice
|
|
81
|
+
effects run on mono only; WebRTC captures mono by default).
|
|
82
|
+
6. **Platform AEC / NS:** WebRTC's own `WebRtcAudioEffects` is moved to the
|
|
83
|
+
swapped recorder's session (`release()` + `enable(session)`), so the
|
|
84
|
+
effect state matches stock and `setNoiseSuppressorEnabled` keeps working.
|
|
85
|
+
7. **Mute that releases the mic** is held by `GxRecorderSeam.closedByMute`,
|
|
86
|
+
set on the local mic's `trackMuted` and cleared on `trackUnmuted`, on an
|
|
87
|
+
unmuted publish and on unpublish. A failed reopen retries every 500 ms.
|
|
88
|
+
`restore(waitOpen=false)` no longer waits for the record thread to stop
|
|
89
|
+
(stock WebRTC keeps it running on a track mute).
|
|
90
|
+
8. The app must call `GravixRtc.setup(this)` in `Application.onCreate`, before
|
|
91
|
+
the React host starts (unchanged).
|
|
92
|
+
|
|
93
|
+
## 5. Beauty
|
|
94
|
+
|
|
95
|
+
Beauty / camera effects stay in separate packages, like Flutter (`gravix_rtc`
|
|
96
|
+
depends on `gravix_effects`): `react-native-gravix-effects` +
|
|
97
|
+
`react-native-gravix-effects-webrtc` 1.4.3 (optional peers, React Native >=
|
|
98
|
+
0.88, `react-native-webrtc` ^155 by name, so they share this SDK's WebRTC).
|
|
99
|
+
The SDK side is JS wiring only (`src/features/beauty.ts`): the effect opens
|
|
100
|
+
its own CameraX camera and the SDK publishes the effect's WebRTC track as a
|
|
101
|
+
user-provided `LocalVideoTrack` (source camera). The example runs on React
|
|
102
|
+
Native 0.88.0 with both packages and `gravixEffectsPack=models`.
|