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.
Files changed (378) hide show
  1. package/CHANGELOG.md +134 -0
  2. package/LICENSE +20 -0
  3. package/LICENSES/Apache-2.0.txt +175 -0
  4. package/NOTICE +68 -0
  5. package/README.md +313 -2
  6. package/android/build.gradle +137 -0
  7. package/android/consumer-rules.pro +29 -0
  8. package/android/src/main/AndroidManifest.xml +9 -0
  9. package/android/src/main/cpp/CMakeLists.txt +48 -0
  10. package/android/src/main/cpp/gx_dfn_engine.c +332 -0
  11. package/android/src/main/cpp/gx_fx_jni.cpp +34 -0
  12. package/android/src/main/cpp/gx_ns_jni.c +162 -0
  13. package/android/src/main/cpp/third_party/onnxruntime/LICENSE +21 -0
  14. package/android/src/main/cpp/third_party/onnxruntime/include/onnxruntime_c_api.h +9227 -0
  15. package/android/src/main/cpp/third_party/onnxruntime/include/onnxruntime_ep_c_api.h +3315 -0
  16. package/android/src/main/cpp/third_party/onnxruntime/include/onnxruntime_error_code.h +98 -0
  17. package/android/src/main/java/com/gravitycompile/gravixrtc/GravixAudioHooks.kt +144 -0
  18. package/android/src/main/java/com/gravitycompile/gravixrtc/GravixAudioModule.kt +105 -0
  19. package/android/src/main/java/com/gravitycompile/gravixrtc/GravixNativeAudio.kt +310 -0
  20. package/android/src/main/java/com/gravitycompile/gravixrtc/GravixRtc.kt +134 -0
  21. package/android/src/main/java/com/gravitycompile/gravixrtc/GravixRtcModule.kt +176 -0
  22. package/android/src/main/java/com/gravitycompile/gravixrtc/GravixRtcPackage.kt +39 -0
  23. package/android/src/main/java/com/gravitycompile/gravixrtc/audio/AudioDeviceKind.java +44 -0
  24. package/android/src/main/java/com/gravitycompile/gravixrtc/audio/AudioManagerUtils.kt +120 -0
  25. package/android/src/main/java/com/gravitycompile/gravixrtc/audio/AudioSwitchManager.java +270 -0
  26. package/android/src/main/java/com/gravitycompile/gravixrtc/audio/AudioType.kt +50 -0
  27. package/android/src/main/java/com/gravitycompile/gravixrtc/music/MusicCaptureRouter.kt +375 -0
  28. package/android/src/main/java/com/gravitycompile/gravixrtc/music/MusicDecoder.kt +339 -0
  29. package/android/src/main/java/com/gravitycompile/gravixrtc/music/MusicInterruptionWatcher.kt +82 -0
  30. package/android/src/main/java/com/gravitycompile/gravixrtc/music/MusicMicRelease.kt +117 -0
  31. package/android/src/main/java/com/gravitycompile/gravixrtc/music/MusicMixKernel.kt +191 -0
  32. package/android/src/main/java/com/gravitycompile/gravixrtc/music/MusicMixerEngine.kt +617 -0
  33. package/android/src/main/java/com/gravitycompile/gravixrtc/processing/AudioRoutePolicy.kt +137 -0
  34. package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GravixCaptureProcessing.kt +67 -0
  35. package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GxCaptureDump.kt +143 -0
  36. package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GxCaptureSwitcher.kt +196 -0
  37. package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GxNoiseProcessor.kt +795 -0
  38. package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GxNsLogic.kt +180 -0
  39. package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GxNsNative.kt +83 -0
  40. package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GxNsStudio.kt +372 -0
  41. package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GxRecordStartGuard.kt +76 -0
  42. package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GxRecorderSeam.kt +434 -0
  43. package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GxSingerSource.kt +37 -0
  44. package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GxVoiceFx.kt +160 -0
  45. package/android/src/main/java/com/gravitycompile/gravixrtc/processing/OtherAppAudioPolicy.kt +143 -0
  46. package/android/src/main/java/org/webrtc/audio/WebRtcAudioTrackHelper.kt +43 -0
  47. package/docs/ANDROID_NATIVE_HOOKS.md +102 -0
  48. package/docs/FEATURE_MATRIX.md +192 -0
  49. package/docs/IOS_NATIVE_HOOKS.md +190 -0
  50. package/gravix-rtc-react-native.podspec +49 -0
  51. package/ios/GravixRtc.h +7 -0
  52. package/ios/GravixRtc.mm +273 -0
  53. package/ios/GravixRtcSetup.h +29 -0
  54. package/ios/GravixRtcSetup.m +52 -0
  55. package/ios/audio/GravixRtcIosAudio.m +157 -0
  56. package/ios/audio/GxAudioDevice.h +62 -0
  57. package/ios/audio/GxAudioDevice.m +857 -0
  58. package/ios/audio/GxAudioSetup.h +34 -0
  59. package/ios/audio/GxAudioSetup.m +70 -0
  60. package/ios/audio/GxCompat.swift +53 -0
  61. package/ios/audio/GxIosAudio.swift +99 -0
  62. package/ios/audio/GxMusicController.swift +150 -0
  63. package/ios/audio/GxMusicPost.swift +362 -0
  64. package/ios/audio/GxNoiseProcessor.swift +718 -0
  65. package/ios/audio/GxNsDfn3CoreML.swift +195 -0
  66. package/ios/audio/GxNsStudioEngine.swift +237 -0
  67. package/ios/audio/GxNsStudioPack.swift +212 -0
  68. package/ios/audio/GxVoiceFx.swift +161 -0
  69. package/ios/audio/gx_adm_state.h +153 -0
  70. package/ios/gxcore/apple/gx_music_post.c +312 -0
  71. package/ios/gxcore/apple/gx_pcm.c +30 -0
  72. package/ios/gxcore/apple/gxns_build.h +19 -0
  73. package/ios/gxcore/apple/gxns_ios.c +17 -0
  74. package/ios/gxcore/apple/include/gx_fx.h +3 -0
  75. package/ios/gxcore/apple/include/gx_music_post.h +88 -0
  76. package/ios/gxcore/apple/include/gx_ns.h +3 -0
  77. package/ios/gxcore/apple/include/gx_pcm.h +33 -0
  78. package/ios/gxcore/apple/include/gxns_ios.h +18 -0
  79. package/ios/gxcore/apple/include/module.modulemap +10 -0
  80. package/ios/gxcore/apple/shim/rnnoise.h +2 -0
  81. package/ios/gxcore/apple/shim/speex_resampler.h +2 -0
  82. package/ios/gxcore/apple/units/gx_fx_forward.cpp +3 -0
  83. package/ios/gxcore/apple/units/gx_ns.c +7 -0
  84. package/ios/gxcore/apple/units/gx_ns_timer.c +7 -0
  85. package/ios/gxcore/apple/units/rnnoise_celt_lpc.c +7 -0
  86. package/ios/gxcore/apple/units/rnnoise_denoise.c +7 -0
  87. package/ios/gxcore/apple/units/rnnoise_kiss_fft.c +7 -0
  88. package/ios/gxcore/apple/units/rnnoise_pitch.c +7 -0
  89. package/ios/gxcore/apple/units/rnnoise_rnn.c +7 -0
  90. package/ios/gxcore/apple/units/rnnoise_rnn_data.c +7 -0
  91. package/ios/gxcore/apple/units/speexdsp_resample.c +7 -0
  92. package/ios/resources/ns/DFN3-NOTICE.txt +10 -0
  93. package/ios/resources/ns/DeepFilterNet-LICENSE-APACHE +201 -0
  94. package/ios/resources/ns/DeepFilterNet-LICENSE-MIT +19 -0
  95. package/ios/resources/ns/gxns_dfn3.mlmodelc/analytics/coremldata.bin +0 -0
  96. package/ios/resources/ns/gxns_dfn3.mlmodelc/coremldata.bin +0 -0
  97. package/ios/resources/ns/gxns_dfn3.mlmodelc/metadata.json +338 -0
  98. package/ios/resources/ns/gxns_dfn3.mlmodelc/model.mil +927 -0
  99. package/ios/resources/ns/gxns_dfn3.mlmodelc/weights/weight.bin +0 -0
  100. package/lib/module/android/bindings.js +49 -0
  101. package/lib/module/android/bindings.js.map +1 -0
  102. package/lib/module/android/index.js +13 -0
  103. package/lib/module/android/index.js.map +1 -0
  104. package/lib/module/android/micMute.js +341 -0
  105. package/lib/module/android/micMute.js.map +1 -0
  106. package/lib/module/android/nativeAudio.js +47 -0
  107. package/lib/module/android/nativeAudio.js.map +1 -0
  108. package/lib/module/android/noiseSuppression.js +170 -0
  109. package/lib/module/android/noiseSuppression.js.map +1 -0
  110. package/lib/module/android/roomMusic.js +142 -0
  111. package/lib/module/android/roomMusic.js.map +1 -0
  112. package/lib/module/android/singerMode.js +31 -0
  113. package/lib/module/android/singerMode.js.map +1 -0
  114. package/lib/module/android/voiceEffects.js +65 -0
  115. package/lib/module/android/voiceEffects.js.map +1 -0
  116. package/lib/module/audio/AudioManager.js +79 -0
  117. package/lib/module/audio/AudioManager.js.map +1 -0
  118. package/lib/module/audio/AudioSession.js +90 -0
  119. package/lib/module/audio/AudioSession.js.map +1 -0
  120. package/lib/module/audio/remoteVolume.js +54 -0
  121. package/lib/module/audio/remoteVolume.js.map +1 -0
  122. package/lib/module/components/VideoView.js +109 -0
  123. package/lib/module/components/VideoView.js.map +1 -0
  124. package/lib/module/features/audioScenario.js +53 -0
  125. package/lib/module/features/audioScenario.js.map +1 -0
  126. package/lib/module/features/beauty.js +828 -0
  127. package/lib/module/features/beauty.js.map +1 -0
  128. package/lib/module/features/micRelease.js +89 -0
  129. package/lib/module/features/micRelease.js.map +1 -0
  130. package/lib/module/features/noiseSuppression.js +213 -0
  131. package/lib/module/features/noiseSuppression.js.map +1 -0
  132. package/lib/module/features/roomMusic.js +90 -0
  133. package/lib/module/features/roomMusic.js.map +1 -0
  134. package/lib/module/features/roomMusicAndroid.js +294 -0
  135. package/lib/module/features/roomMusicAndroid.js.map +1 -0
  136. package/lib/module/features/roomMusicIos.js +250 -0
  137. package/lib/module/features/roomMusicIos.js.map +1 -0
  138. package/lib/module/features/roomMusicTypes.js +53 -0
  139. package/lib/module/features/roomMusicTypes.js.map +1 -0
  140. package/lib/module/features/screenShare.js +22 -0
  141. package/lib/module/features/screenShare.js.map +1 -0
  142. package/lib/module/features/singerMode.js +73 -0
  143. package/lib/module/features/singerMode.js.map +1 -0
  144. package/lib/module/features/voiceEffects.js +148 -0
  145. package/lib/module/features/voiceEffects.js.map +1 -0
  146. package/lib/module/hooks/context.js +34 -0
  147. package/lib/module/hooks/context.js.map +1 -0
  148. package/lib/module/hooks/hooks.js +145 -0
  149. package/lib/module/hooks/hooks.js.map +1 -0
  150. package/lib/module/hooks/types.js +4 -0
  151. package/lib/module/hooks/types.js.map +1 -0
  152. package/lib/module/hooks/useRoomEvents.js +30 -0
  153. package/lib/module/hooks/useRoomEvents.js.map +1 -0
  154. package/lib/module/index.js +43 -0
  155. package/lib/module/index.js.map +1 -0
  156. package/lib/module/ios/autoAttach.js +14 -0
  157. package/lib/module/ios/autoAttach.js.map +1 -0
  158. package/lib/module/ios/iosAudio.js +149 -0
  159. package/lib/module/ios/iosAudio.js.map +1 -0
  160. package/lib/module/join/appStateLifecycle.js +54 -0
  161. package/lib/module/join/appStateLifecycle.js.map +1 -0
  162. package/lib/module/micPolicy.js +249 -0
  163. package/lib/module/micPolicy.js.map +1 -0
  164. package/lib/module/native/NativeGravixAudio.js +18 -0
  165. package/lib/module/native/NativeGravixAudio.js.map +1 -0
  166. package/lib/module/native/NativeGravixRtc.js +13 -0
  167. package/lib/module/native/NativeGravixRtc.js.map +1 -0
  168. package/lib/module/native/module.js +23 -0
  169. package/lib/module/native/module.js.map +1 -0
  170. package/lib/module/package.json +1 -0
  171. package/lib/module/polyfills/DOMException.js +22 -0
  172. package/lib/module/polyfills/DOMException.js.map +1 -0
  173. package/lib/module/polyfills/early.js +18 -0
  174. package/lib/module/polyfills/early.js.map +1 -0
  175. package/lib/module/polyfills/event.js +71 -0
  176. package/lib/module/polyfills/event.js.map +1 -0
  177. package/lib/module/polyfills/sha256.js +92 -0
  178. package/lib/module/polyfills/sha256.js.map +1 -0
  179. package/lib/module/polyfills/subtleHmac.js +91 -0
  180. package/lib/module/polyfills/subtleHmac.js.map +1 -0
  181. package/lib/module/polyfills/textCoding.js +164 -0
  182. package/lib/module/polyfills/textCoding.js.map +1 -0
  183. package/lib/module/registerGlobals.js +135 -0
  184. package/lib/module/registerGlobals.js.map +1 -0
  185. package/lib/module/unsupported.js +90 -0
  186. package/lib/module/unsupported.js.map +1 -0
  187. package/lib/module/version.js +7 -0
  188. package/lib/module/version.js.map +1 -0
  189. package/lib/typescript/package.json +1 -0
  190. package/lib/typescript/src/android/bindings.d.ts +14 -0
  191. package/lib/typescript/src/android/bindings.d.ts.map +1 -0
  192. package/lib/typescript/src/android/index.d.ts +9 -0
  193. package/lib/typescript/src/android/index.d.ts.map +1 -0
  194. package/lib/typescript/src/android/micMute.d.ts +124 -0
  195. package/lib/typescript/src/android/micMute.d.ts.map +1 -0
  196. package/lib/typescript/src/android/nativeAudio.d.ts +40 -0
  197. package/lib/typescript/src/android/nativeAudio.d.ts.map +1 -0
  198. package/lib/typescript/src/android/noiseSuppression.d.ts +48 -0
  199. package/lib/typescript/src/android/noiseSuppression.d.ts.map +1 -0
  200. package/lib/typescript/src/android/roomMusic.d.ts +80 -0
  201. package/lib/typescript/src/android/roomMusic.d.ts.map +1 -0
  202. package/lib/typescript/src/android/singerMode.d.ts +27 -0
  203. package/lib/typescript/src/android/singerMode.d.ts.map +1 -0
  204. package/lib/typescript/src/android/voiceEffects.d.ts +30 -0
  205. package/lib/typescript/src/android/voiceEffects.d.ts.map +1 -0
  206. package/lib/typescript/src/audio/AudioManager.d.ts +32 -0
  207. package/lib/typescript/src/audio/AudioManager.d.ts.map +1 -0
  208. package/lib/typescript/src/audio/AudioSession.d.ts +70 -0
  209. package/lib/typescript/src/audio/AudioSession.d.ts.map +1 -0
  210. package/lib/typescript/src/audio/remoteVolume.d.ts +8 -0
  211. package/lib/typescript/src/audio/remoteVolume.d.ts.map +1 -0
  212. package/lib/typescript/src/components/VideoView.d.ts +44 -0
  213. package/lib/typescript/src/components/VideoView.d.ts.map +1 -0
  214. package/lib/typescript/src/features/audioScenario.d.ts +24 -0
  215. package/lib/typescript/src/features/audioScenario.d.ts.map +1 -0
  216. package/lib/typescript/src/features/beauty.d.ts +377 -0
  217. package/lib/typescript/src/features/beauty.d.ts.map +1 -0
  218. package/lib/typescript/src/features/micRelease.d.ts +28 -0
  219. package/lib/typescript/src/features/micRelease.d.ts.map +1 -0
  220. package/lib/typescript/src/features/noiseSuppression.d.ts +64 -0
  221. package/lib/typescript/src/features/noiseSuppression.d.ts.map +1 -0
  222. package/lib/typescript/src/features/roomMusic.d.ts +41 -0
  223. package/lib/typescript/src/features/roomMusic.d.ts.map +1 -0
  224. package/lib/typescript/src/features/roomMusicAndroid.d.ts +60 -0
  225. package/lib/typescript/src/features/roomMusicAndroid.d.ts.map +1 -0
  226. package/lib/typescript/src/features/roomMusicIos.d.ts +56 -0
  227. package/lib/typescript/src/features/roomMusicIos.d.ts.map +1 -0
  228. package/lib/typescript/src/features/roomMusicTypes.d.ts +76 -0
  229. package/lib/typescript/src/features/roomMusicTypes.d.ts.map +1 -0
  230. package/lib/typescript/src/features/screenShare.d.ts +12 -0
  231. package/lib/typescript/src/features/screenShare.d.ts.map +1 -0
  232. package/lib/typescript/src/features/singerMode.d.ts +20 -0
  233. package/lib/typescript/src/features/singerMode.d.ts.map +1 -0
  234. package/lib/typescript/src/features/voiceEffects.d.ts +46 -0
  235. package/lib/typescript/src/features/voiceEffects.d.ts.map +1 -0
  236. package/lib/typescript/src/hooks/context.d.ts +12 -0
  237. package/lib/typescript/src/hooks/context.d.ts.map +1 -0
  238. package/lib/typescript/src/hooks/hooks.d.ts +54 -0
  239. package/lib/typescript/src/hooks/hooks.d.ts.map +1 -0
  240. package/lib/typescript/src/hooks/types.d.ts +8 -0
  241. package/lib/typescript/src/hooks/types.d.ts.map +1 -0
  242. package/lib/typescript/src/hooks/useRoomEvents.d.ts +13 -0
  243. package/lib/typescript/src/hooks/useRoomEvents.d.ts.map +1 -0
  244. package/lib/typescript/src/index.d.ts +37 -0
  245. package/lib/typescript/src/index.d.ts.map +1 -0
  246. package/lib/typescript/src/ios/autoAttach.d.ts +2 -0
  247. package/lib/typescript/src/ios/autoAttach.d.ts.map +1 -0
  248. package/lib/typescript/src/ios/iosAudio.d.ts +96 -0
  249. package/lib/typescript/src/ios/iosAudio.d.ts.map +1 -0
  250. package/lib/typescript/src/join/appStateLifecycle.d.ts +14 -0
  251. package/lib/typescript/src/join/appStateLifecycle.d.ts.map +1 -0
  252. package/lib/typescript/src/micPolicy.d.ts +104 -0
  253. package/lib/typescript/src/micPolicy.d.ts.map +1 -0
  254. package/lib/typescript/src/native/NativeGravixAudio.d.ts +21 -0
  255. package/lib/typescript/src/native/NativeGravixAudio.d.ts.map +1 -0
  256. package/lib/typescript/src/native/NativeGravixRtc.d.ts +31 -0
  257. package/lib/typescript/src/native/NativeGravixRtc.d.ts.map +1 -0
  258. package/lib/typescript/src/native/module.d.ts +7 -0
  259. package/lib/typescript/src/native/module.d.ts.map +1 -0
  260. package/lib/typescript/src/polyfills/DOMException.d.ts +3 -0
  261. package/lib/typescript/src/polyfills/DOMException.d.ts.map +1 -0
  262. package/lib/typescript/src/polyfills/early.d.ts +2 -0
  263. package/lib/typescript/src/polyfills/early.d.ts.map +1 -0
  264. package/lib/typescript/src/polyfills/event.d.ts +2 -0
  265. package/lib/typescript/src/polyfills/event.d.ts.map +1 -0
  266. package/lib/typescript/src/polyfills/sha256.d.ts +3 -0
  267. package/lib/typescript/src/polyfills/sha256.d.ts.map +1 -0
  268. package/lib/typescript/src/polyfills/subtleHmac.d.ts +37 -0
  269. package/lib/typescript/src/polyfills/subtleHmac.d.ts.map +1 -0
  270. package/lib/typescript/src/polyfills/textCoding.d.ts +36 -0
  271. package/lib/typescript/src/polyfills/textCoding.d.ts.map +1 -0
  272. package/lib/typescript/src/registerGlobals.d.ts +42 -0
  273. package/lib/typescript/src/registerGlobals.d.ts.map +1 -0
  274. package/lib/typescript/src/unsupported.d.ts +42 -0
  275. package/lib/typescript/src/unsupported.d.ts.map +1 -0
  276. package/lib/typescript/src/version.d.ts +3 -0
  277. package/lib/typescript/src/version.d.ts.map +1 -0
  278. package/metro/index.js +39 -0
  279. package/metro/noise-stub.js +10 -0
  280. package/native/gxfx/include/gx_fx.h +82 -0
  281. package/native/gxfx/src/gx_fx.cpp +527 -0
  282. package/native/gxfx/third_party/README.md +4 -0
  283. package/native/gxfx/third_party/signalsmith-linear/LICENSE.txt +21 -0
  284. package/native/gxfx/third_party/signalsmith-linear/approx.h +191 -0
  285. package/native/gxfx/third_party/signalsmith-linear/fft.h +1386 -0
  286. package/native/gxfx/third_party/signalsmith-linear/linear.h +1129 -0
  287. package/native/gxfx/third_party/signalsmith-linear/platform/approx-cmsisdsp.h +40 -0
  288. package/native/gxfx/third_party/signalsmith-linear/platform/basic-fill-warnings.h +61 -0
  289. package/native/gxfx/third_party/signalsmith-linear/platform/fft-accelerate.h +340 -0
  290. package/native/gxfx/third_party/signalsmith-linear/platform/fft-cmsisdsp.h +307 -0
  291. package/native/gxfx/third_party/signalsmith-linear/platform/fft-ipp.h +532 -0
  292. package/native/gxfx/third_party/signalsmith-linear/platform/fft-linear.h +213 -0
  293. package/native/gxfx/third_party/signalsmith-linear/platform/fft-pffft-double.h +221 -0
  294. package/native/gxfx/third_party/signalsmith-linear/platform/fft-pffft.h +221 -0
  295. package/native/gxfx/third_party/signalsmith-linear/platform/linear-accelerate.h +593 -0
  296. package/native/gxfx/third_party/signalsmith-linear/platform/linear-cmsisdsp.h +713 -0
  297. package/native/gxfx/third_party/signalsmith-linear/platform/linear-xsimd-dispatch.cpp +6 -0
  298. package/native/gxfx/third_party/signalsmith-linear/platform/linear-xsimd.h +818 -0
  299. package/native/gxfx/third_party/signalsmith-linear/stft.h +700 -0
  300. package/native/gxfx/third_party/signalsmith-stretch-LICENSE.txt +21 -0
  301. package/native/gxfx/third_party/signalsmith-stretch.h +1060 -0
  302. package/native/gxns/CMakeLists.txt +67 -0
  303. package/native/gxns/include/gx_ns.h +285 -0
  304. package/native/gxns/src/gx_ns.c +1518 -0
  305. package/native/gxns/src/gx_ns_timer.c +84 -0
  306. package/native/gxns/src/gx_ns_timer.h +29 -0
  307. package/native/gxns/third_party/VENDOR.md +43 -0
  308. package/native/gxns/third_party/rnnoise/AUTHORS +1 -0
  309. package/native/gxns/third_party/rnnoise/COPYING +31 -0
  310. package/native/gxns/third_party/rnnoise/include/rnnoise.h +117 -0
  311. package/native/gxns/third_party/rnnoise/src/_kiss_fft_guts.h +182 -0
  312. package/native/gxns/third_party/rnnoise/src/arch.h +261 -0
  313. package/native/gxns/third_party/rnnoise/src/celt_lpc.c +172 -0
  314. package/native/gxns/third_party/rnnoise/src/celt_lpc.h +45 -0
  315. package/native/gxns/third_party/rnnoise/src/common.h +48 -0
  316. package/native/gxns/third_party/rnnoise/src/denoise.c +664 -0
  317. package/native/gxns/third_party/rnnoise/src/kiss_fft.c +601 -0
  318. package/native/gxns/third_party/rnnoise/src/kiss_fft.h +203 -0
  319. package/native/gxns/third_party/rnnoise/src/opus_types.h +159 -0
  320. package/native/gxns/third_party/rnnoise/src/pitch.c +523 -0
  321. package/native/gxns/third_party/rnnoise/src/pitch.h +149 -0
  322. package/native/gxns/third_party/rnnoise/src/rnn.c +178 -0
  323. package/native/gxns/third_party/rnnoise/src/rnn.h +65 -0
  324. package/native/gxns/third_party/rnnoise/src/rnn_data.c +11051 -0
  325. package/native/gxns/third_party/rnnoise/src/rnn_data.h +34 -0
  326. package/native/gxns/third_party/rnnoise/src/tansig_table.h +45 -0
  327. package/native/gxns/third_party/speexdsp/AUTHORS +18 -0
  328. package/native/gxns/third_party/speexdsp/COPYING +35 -0
  329. package/native/gxns/third_party/speexdsp/arch.h +232 -0
  330. package/native/gxns/third_party/speexdsp/resample.c +1239 -0
  331. package/native/gxns/third_party/speexdsp/resample_neon.h +339 -0
  332. package/native/gxns/third_party/speexdsp/resample_sse.h +128 -0
  333. package/native/gxns/third_party/speexdsp/speex_resampler.h +343 -0
  334. package/package.json +186 -4
  335. package/src/android/bindings.ts +61 -0
  336. package/src/android/index.ts +10 -0
  337. package/src/android/micMute.ts +422 -0
  338. package/src/android/nativeAudio.ts +94 -0
  339. package/src/android/noiseSuppression.ts +209 -0
  340. package/src/android/roomMusic.ts +193 -0
  341. package/src/android/singerMode.ts +53 -0
  342. package/src/android/voiceEffects.ts +126 -0
  343. package/src/audio/AudioManager.ts +111 -0
  344. package/src/audio/AudioSession.ts +190 -0
  345. package/src/audio/remoteVolume.ts +58 -0
  346. package/src/components/VideoView.tsx +152 -0
  347. package/src/features/audioScenario.ts +58 -0
  348. package/src/features/beauty.ts +1057 -0
  349. package/src/features/micRelease.ts +108 -0
  350. package/src/features/noiseSuppression.ts +251 -0
  351. package/src/features/roomMusic.ts +106 -0
  352. package/src/features/roomMusicAndroid.ts +310 -0
  353. package/src/features/roomMusicIos.ts +300 -0
  354. package/src/features/roomMusicTypes.ts +97 -0
  355. package/src/features/screenShare.ts +19 -0
  356. package/src/features/singerMode.ts +70 -0
  357. package/src/features/voiceEffects.ts +245 -0
  358. package/src/hooks/context.tsx +38 -0
  359. package/src/hooks/hooks.ts +247 -0
  360. package/src/hooks/types.ts +10 -0
  361. package/src/hooks/useRoomEvents.ts +35 -0
  362. package/src/index.tsx +134 -0
  363. package/src/ios/autoAttach.ts +11 -0
  364. package/src/ios/iosAudio.ts +202 -0
  365. package/src/join/appStateLifecycle.ts +55 -0
  366. package/src/micPolicy.ts +312 -0
  367. package/src/native/NativeGravixAudio.ts +30 -0
  368. package/src/native/NativeGravixRtc.ts +38 -0
  369. package/src/native/module.ts +22 -0
  370. package/src/polyfills/DOMException.ts +20 -0
  371. package/src/polyfills/early.ts +16 -0
  372. package/src/polyfills/event.ts +88 -0
  373. package/src/polyfills/sha256.ts +112 -0
  374. package/src/polyfills/subtleHmac.ts +124 -0
  375. package/src/polyfills/textCoding.ts +197 -0
  376. package/src/registerGlobals.ts +201 -0
  377. package/src/unsupported.ts +139 -0
  378. 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`.