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,49 @@
1
+ "use strict";
2
+
3
+ // Copyright (c) 2026 Gravity Compile. MIT License; see LICENSE.
4
+
5
+ import { DeviceEventEmitter, Platform } from 'react-native';
6
+ import NativeGravixAudio from "../native/NativeGravixAudio.js";
7
+ import { isFeatureSupported } from "../unsupported.js";
8
+ import { gravixAndroidAudioBridge, setGravixAndroidAudioBridge } from "./nativeAudio.js";
9
+
10
+ /** Device event of `GravixAudioModule.kt`: `{ name, payload }`. */
11
+ export const GRAVIX_AUDIO_EVENT = 'GravixAudioEvent';
12
+
13
+ /** Installs the bridge over the `GravixAudio` TurboModule (Android). Idempotent; false when absent. */
14
+ export function installGravixAndroidAudioBridge() {
15
+ if (gravixAndroidAudioBridge()) return true;
16
+ if (Platform.OS !== 'android') return false;
17
+ const m = NativeGravixAudio;
18
+ if (!m) return false;
19
+ const bridge = {
20
+ async call(method, args = {}) {
21
+ const r = await m.call(method, args);
22
+ return r?.value ?? null;
23
+ },
24
+ addListener(event, listener) {
25
+ const sub = DeviceEventEmitter.addListener(GRAVIX_AUDIO_EVENT, e => {
26
+ if (e?.name === event) listener(e.payload ?? null);
27
+ });
28
+ return () => sub.remove();
29
+ }
30
+ };
31
+ setGravixAndroidAudioBridge(bridge);
32
+ return true;
33
+ }
34
+
35
+ /** The bridge, installed on first use. Null off Android or without the module. */
36
+ export function androidAudio() {
37
+ installGravixAndroidAudioBridge();
38
+ return gravixAndroidAudioBridge();
39
+ }
40
+
41
+ /**
42
+ * The bridge when [feature] runs natively here (Android, `GravixRtc.setup` done,
43
+ * capability flag on), else null: the caller then keeps its `unsupported*()` path.
44
+ */
45
+ export function androidAudioFor(feature) {
46
+ if (Platform.OS !== 'android' || !isFeatureSupported(feature)) return null;
47
+ return androidAudio();
48
+ }
49
+ //# sourceMappingURL=bindings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["DeviceEventEmitter","Platform","NativeGravixAudio","isFeatureSupported","gravixAndroidAudioBridge","setGravixAndroidAudioBridge","GRAVIX_AUDIO_EVENT","installGravixAndroidAudioBridge","OS","m","bridge","call","method","args","r","value","addListener","event","listener","sub","e","name","payload","remove","androidAudio","androidAudioFor","feature"],"sourceRoot":"../../../src","sources":["android/bindings.ts"],"mappings":";;AAAA;;AAEA,SAASA,kBAAkB,EAAEC,QAAQ,QAAQ,cAAc;AAC3D,OAAOC,iBAAiB,MAAM,gCAA6B;AAC3D,SAASC,kBAAkB,QAAkC,mBAAgB;AAC7E,SACEC,wBAAwB,EACxBC,2BAA2B,QAItB,kBAAe;;AAEtB;AACA,OAAO,MAAMC,kBAAkB,GAAG,kBAAkB;;AAEpD;AACA,OAA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gravity Compile. MIT License; see LICENSE.
4
+
5
+ /** Android-native audio features (voice effects, noise suppression, room music, singer mode, mic release). */
6
+ export * from "./nativeAudio.js";
7
+ export * from "./voiceEffects.js";
8
+ export * from "./noiseSuppression.js";
9
+ export * from "./roomMusic.js";
10
+ export * from "./singerMode.js";
11
+ export * from "./micMute.js";
12
+ export * from "./bindings.js";
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["android/index.ts"],"mappings":";;AAAA;;AAEA;AACA,cAAc,kBAAe;AAC7B,cAAc,mBAAgB;AAC9B,cAAc,uBAAoB;AAClC,cAAc,gBAAa;AAC3B,cAAc,iBAAc;AAC5B,cAAc,cAAW;AACzB,cAAc,eAAY","ignoreList":[]}
@@ -0,0 +1,341 @@
1
+ "use strict";
2
+
3
+ // Copyright (c) 2026 Gravity Compile. MIT License; see LICENSE.
4
+
5
+ import { asMap, gravixAndroidAudioBridge } from "./nativeAudio.js";
6
+
7
+ /**
8
+ * Mute that releases the OS microphone (Flutter SDK 0.12.1 / 0.12.2, Android).
9
+ *
10
+ * In React Native a plain mute of a published mic (`LocalAudioTrack.mute()`
11
+ * of the gravix-rtc core = `MediaStreamTrack.enabled = false`) does not stop
12
+ * the AudioRecord of react-native-webrtc 155's WebRTC build. The Gravix
13
+ * capture seam closes it instead: {@link GravixMicMute.setCaptureClosed}
14
+ * (the room mic policy calls it on every local mic mute / unmute) stops the
15
+ * hardware recorder while WebRTC's record thread keeps clocking silence, so
16
+ * the OS mic indicator goes off (0.12.1 behaviour). Two cases need more,
17
+ * ported here over the native primitives (`setMicrophoneMute`,
18
+ * `setRecorderReleased`, `recorderNativeState`, `setCaptureClosed`):
19
+ *
20
+ * 1. Room music under a mute ({@link GravixMicMute.muteForMusic}, 0.12.2,
21
+ * `continueWhileMicReleased`): the voice is zeroed in the module, then the
22
+ * hardware recorder is released while WebRTC's record thread keeps
23
+ * delivering frames (silence + the music, clocked by the mixer). The track
24
+ * stays enabled and published (no mute signal): the room keeps hearing the
25
+ * music, the OS mic indicator goes off.
26
+ * 2. A mic published while ALREADY muted ({@link GravixMicMute.closeMutedCapture}):
27
+ * WebRTC starts the recorder when the send stream is added, muted or not.
28
+ * With the capture seam the recorder is simply closed; without it (a
29
+ * native side that lacks `setCaptureClosed`) the stream is unmuted and
30
+ * muted again once under the module mute, until the recorder is seen
31
+ * stopped (at most 3 rounds).
32
+ */
33
+
34
+ /** The parts of a gravix-rtc `LocalAudioTrack` this needs. */
35
+
36
+ /** The native primitives through the Android bridge; no-ops (false / null) without it. */
37
+ export const bridgeMicNative = {
38
+ async setMicrophoneMute(mute) {
39
+ const b = gravixAndroidAudioBridge();
40
+ if (!b) return false;
41
+ return (await b.call('setMicrophoneMute', {
42
+ mute
43
+ })) === true;
44
+ },
45
+ async setRecorderReleased(released, opts = {}) {
46
+ const b = gravixAndroidAudioBridge();
47
+ if (!b) return false;
48
+ return (await b.call('setRecorderReleased', {
49
+ released,
50
+ waitOpen: opts.waitOpen ?? false,
51
+ timeoutMs: opts.timeoutMs ?? 1500
52
+ })) === true;
53
+ },
54
+ async recorderNativeState() {
55
+ const b = gravixAndroidAudioBridge();
56
+ if (!b) return null;
57
+ return asMap(await b.call('recorderNativeState'));
58
+ },
59
+ async setCaptureClosed(closed) {
60
+ const b = gravixAndroidAudioBridge();
61
+ if (!b) return null;
62
+ const r = asMap(await b.call('setCaptureClosed', {
63
+ closed
64
+ }));
65
+ return r ? r.ok === true : null;
66
+ }
67
+ };
68
+ const delay = ms => new Promise(r => setTimeout(r, ms));
69
+ /**
70
+ * Engine-wide state (one audio device module per process), port of Dart
71
+ * `GravixEngineMicMute` + the matching `LocalAudioTrack` flows.
72
+ */
73
+ export class GravixMicMute {
74
+ /**
75
+ * `GravixMicRelease.setMuteReleasesMic`: a mute under room music may release
76
+ * the recorder. Default true (Flutter 0.12.1+ `muteReleasesMic`); rollback:
77
+ * `registerGlobals({ muteReleasesMic: false })`.
78
+ */
79
+ muteReleasesMic = true;
80
+ listeners = new Set();
81
+ engaged = false;
82
+ recorderReleased = false;
83
+ kind = 'none';
84
+ owner = null;
85
+ constructor(native = bridgeMicNative, sleep = delay, log = () => {}) {
86
+ this.native = native;
87
+ this.sleep = sleep;
88
+ this.log = log;
89
+ }
90
+ get muteKind() {
91
+ return this.kind;
92
+ }
93
+
94
+ /** Called on every voice-only mute change ({@link muteKind}). Returns the unsubscribe. */
95
+ onChange(fn) {
96
+ this.listeners.add(fn);
97
+ return () => {
98
+ this.listeners.delete(fn);
99
+ };
100
+ }
101
+
102
+ /** @internal */
103
+ setKind(kind, owner) {
104
+ const changed = kind !== this.kind;
105
+ this.kind = kind;
106
+ this.owner = owner;
107
+ if (!changed) return;
108
+ for (const fn of [...this.listeners]) {
109
+ try {
110
+ fn();
111
+ } catch (e) {
112
+ this.log('warn', `mic mute listener failed: ${e}`);
113
+ }
114
+ }
115
+ }
116
+
117
+ /**
118
+ * Mute releases the mic (stock WebRTC keeps recording under a track mute):
119
+ * closes / reopens the hardware recorder through the capture seam. Null when
120
+ * the native side has no seam (then nothing changed). Off while
121
+ * {@link muteReleasesMic} is false (the reopen always runs).
122
+ */
123
+ async setCaptureClosed(closed) {
124
+ if (!this.native.setCaptureClosed) return null;
125
+ if (closed && !this.muteReleasesMic) return false;
126
+ try {
127
+ return await this.native.setCaptureClosed(closed);
128
+ } catch (e) {
129
+ this.log('warn', `mic mute: capture ${closed ? 'close' : 'reopen'} failed: ${e}`);
130
+ return null;
131
+ }
132
+ }
133
+
134
+ /** The room is gone: a voice-only mute and the module mute are given back. */
135
+ async leave() {
136
+ await this.setCaptureClosed(false);
137
+ if (this.kind !== 'none') this.setKind('none', null);
138
+ if (this.recorderReleased) await this.restoreRecorder(false);
139
+ await this.release();
140
+ }
141
+ get isEngaged() {
142
+ return this.engaged;
143
+ }
144
+ get isRecorderReleased() {
145
+ return this.recorderReleased;
146
+ }
147
+
148
+ /** The module mute (PCM zeroed, recorder running). False: not available (no setup / not Android). */
149
+ async engage() {
150
+ let ok = false;
151
+ try {
152
+ ok = await this.native.setMicrophoneMute(true);
153
+ } catch (e) {
154
+ this.log('warn', `engine microphone mute failed: ${e}`);
155
+ }
156
+ this.engaged = ok;
157
+ return ok;
158
+ }
159
+ async releaseRecorder() {
160
+ if (!this.engaged) return false;
161
+ if (this.recorderReleased) return true;
162
+ let ok = false;
163
+ try {
164
+ ok = await this.native.setRecorderReleased(true);
165
+ } catch (e) {
166
+ this.log('warn', `recorder release failed: ${e}`);
167
+ }
168
+ this.recorderReleased = ok;
169
+ return ok;
170
+ }
171
+ async restoreRecorder(waitOpen) {
172
+ if (!this.recorderReleased) return true;
173
+ this.recorderReleased = false;
174
+ try {
175
+ return await this.native.setRecorderReleased(false, {
176
+ waitOpen
177
+ });
178
+ } catch (e) {
179
+ this.log('error', `recorder restore failed: ${e}`);
180
+ return false;
181
+ }
182
+ }
183
+
184
+ /** Gives back the module mute (a released recorder first). */
185
+ async release() {
186
+ if (this.recorderReleased) await this.restoreRecorder(false);
187
+ if (!this.engaged) return;
188
+ this.engaged = false;
189
+ try {
190
+ if (!(await this.native.setMicrophoneMute(false))) this.log('error', 'engine microphone unmute refused');
191
+ } catch (e) {
192
+ this.log('error', `engine microphone unmute failed: ${e}`);
193
+ }
194
+ }
195
+
196
+ /**
197
+ * Mute while room music plays. [releaseMic] = `continueWhileMicReleased`.
198
+ * Returns the kind of mute taken; `none` means the caller's plain
199
+ * `track.mute()` ran instead (music silenced for the room: the 0.12.1 mute).
200
+ */
201
+ async muteForMusic(track, releaseMic) {
202
+ if (track.isMuted || this.kind !== 'none') return this.kind;
203
+ if (await this.engage()) {
204
+ if (releaseMic) {
205
+ if (await this.releaseRecorder()) {
206
+ this.setKind('voiceOnlyReleased', track);
207
+ this.log('info', 'mic mute: voice-only with the recorder released (room music playing; the publication stays live)');
208
+ return this.kind;
209
+ }
210
+ this.log('warn', 'mic mute: recorder release refused; a mute that releases the mic (the music stops for the room)');
211
+ } else {
212
+ this.setKind('voiceOnly', track);
213
+ this.log('info', 'mic mute: voice-only (room music playing; the mic stays open)');
214
+ return this.kind;
215
+ }
216
+ }
217
+ // plain mute: the module mute stays on until the track is disabled (no voice frame in between)
218
+ await track.mute();
219
+ await this.release();
220
+ return 'none';
221
+ }
222
+
223
+ /** Unmute of a {@link muteForMusic} mute (a plain mute: call `track.unmute()` yourself). */
224
+ async unmuteFromMusic(track) {
225
+ if (this.kind === 'none' || this.owner !== track) return false;
226
+ const wasReleased = this.kind === 'voiceOnlyReleased';
227
+ this.setKind('none', null);
228
+ if (wasReleased && this.recorderReleased && !(await this.restoreRecorder(true))) {
229
+ // the capture seam keeps retrying the recorder start (every 500 ms) while the
230
+ // record thread delivers silence; nothing more to do from here
231
+ this.log('error', 'mic unmute: the recorder could not be reopened yet (no microphone?); the capture seam keeps retrying');
232
+ }
233
+ await this.release();
234
+ track.mediaStreamTrack.enabled = true;
235
+ return true;
236
+ }
237
+
238
+ /**
239
+ * The music ended while {@link muteForMusic} held: becomes a plain mute
240
+ * (wire signalled; the room mic policy closes the recorder through the
241
+ * capture seam when mute releases the mic).
242
+ */
243
+ async musicEnded(track) {
244
+ if (this.kind === 'none' || this.owner !== track) return;
245
+ this.setKind('none', null);
246
+ // the core mute first (its trackMuted closes the recorder through the seam when mute
247
+ // releases the mic); then the release flag back, then the module mute off
248
+ await track.mute();
249
+ if (this.recorderReleased) await this.restoreRecorder(false);
250
+ await this.release();
251
+ }
252
+
253
+ /**
254
+ * The app muted the track through the core (`setMicrophoneEnabled(false)`)
255
+ * during a voice-only mute: the core now owns the mute. The recorder flag
256
+ * and the module mute are given back so a later core unmute carries voice.
257
+ */
258
+ async coreMuted(track) {
259
+ if (this.kind === 'none' || this.owner !== track) return;
260
+ this.setKind('none', null);
261
+ if (this.recorderReleased) await this.restoreRecorder(false);
262
+ await this.release();
263
+ }
264
+
265
+ /** `setMuteReleasesMic(false)` under a released mute: the recorder is back, the voice stays muted. */
266
+ async unreleaseKeepingMute() {
267
+ if (this.kind !== 'voiceOnlyReleased') return;
268
+ await this.restoreRecorder(true);
269
+ this.setKind('voiceOnly', this.owner);
270
+ }
271
+ async waitRecorder(ok, timeoutMs) {
272
+ let waited = 0;
273
+ for (;;) {
274
+ const s = await this.native.recorderNativeState();
275
+ if (s == null) return null;
276
+ if (ok(s)) return true;
277
+ if (waited >= timeoutMs) return false;
278
+ await this.sleep(20);
279
+ waited += 20;
280
+ }
281
+ }
282
+
283
+ /**
284
+ * Closes the recorder of a mic published while already muted (device
285
+ * 2026-11-28: WebRTC starts it ~300 ms after the publish returns; a toggle
286
+ * before that changes nothing). Returns true when the recorder was seen
287
+ * stopped (or the state is unreadable after one toggle).
288
+ */
289
+ async closeMutedCapture(track) {
290
+ if (!track.isMuted || this.kind !== 'none') return false;
291
+ // capture seam: close the recorder directly (the toggle below needs an
292
+ // audio device module that stops recording on a send-stream mute)
293
+ const seam = await this.setCaptureClosed(true);
294
+ if (seam !== null) {
295
+ this.log('info', `mic mute: recorder of the muted publish closed (seam ok=${seam})`);
296
+ return true;
297
+ }
298
+ const engagedHere = !this.engaged && (await this.engage());
299
+ if (!this.engaged) {
300
+ this.log('warn', 'mic mute: no engine mute for the recorder close; the recorder may stay open');
301
+ return false;
302
+ }
303
+ try {
304
+ for (let round = 1; round <= 3; round++) {
305
+ const started = await this.waitRecorder(s => s.nativeStart === true, 1500);
306
+ // the user may have unmuted while we waited: leave the live mic alone
307
+ if (!track.isMuted) {
308
+ this.log('info', 'mic mute: unmuted during the recorder close; stopped');
309
+ return false;
310
+ }
311
+ track.mediaStreamTrack.enabled = true;
312
+ track.mediaStreamTrack.enabled = false;
313
+ if (started == null) {
314
+ this.log('info', 'mic mute: recorder of the muted publish closed (toggle; state unreadable)');
315
+ return true;
316
+ }
317
+ const stopped = await this.waitRecorder(s => s.nativeStart === false, 1000);
318
+ await this.sleep(250);
319
+ const still = await this.waitRecorder(s => s.nativeStart === false, 0);
320
+ if (!track.isMuted) {
321
+ // unmuted mid-round: the core set enabled = true after our toggle; keep it
322
+ track.mediaStreamTrack.enabled = true;
323
+ return false;
324
+ }
325
+ if (stopped === true && still === true) {
326
+ this.log('info', `mic mute: recorder of the muted publish closed (round ${round})`);
327
+ return true;
328
+ }
329
+ this.log('warn', `mic mute: the engine still records after round ${round}; retrying`);
330
+ }
331
+ this.log('error', 'mic mute: the engine kept the recorder after 3 rounds');
332
+ return false;
333
+ } finally {
334
+ if (engagedHere) await this.release();
335
+ }
336
+ }
337
+ }
338
+
339
+ /** Process-wide instance (the audio device module is one per process). */
340
+ export const gravixMicMute = new GravixMicMute();
341
+ //# sourceMappingURL=micMute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["asMap","gravixAndroidAudioBridge","bridgeMicNative","setMicrophoneMute","mute","b","call","setRecorderReleased","released","opts","waitOpen","timeoutMs","recorderNativeState","setCaptureClosed","closed","r","ok","delay","ms","Promise","setTimeout","GravixMicMute","muteReleasesMic","listeners","Set","engaged","recorderReleased","kind","owner","constructor","native","sleep","log","muteKind","onChange","fn","add","delete","setKind","changed","e","leave","restoreRecorder","release","isEngaged","isRecorderReleased","engage","releaseRecorder","muteForMusic","track","releaseMic","isMuted","unmuteFromMusic","wasReleased","mediaStreamTrack","enabled","musicEnded","coreMuted","unreleaseKeepingMute","waitRecorder","waited","s","closeMutedCapture","seam","engagedHere","round","started","nativeStart","stopped","still","gravixMicMute"],"sourceRoot":"../../../src","sources":["android/micMute.ts"],"mappings":";;AAAA;;AAEA,SAASA,KAAK,EAAEC,wBAAwB,QAAQ,kBAAe;;AAE/D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAmBA;AACA,OAAO,MAAMC,eAAgC,GAAG;EAC9C,MAAMC,iBAAiBA,CAACC,IAAI,EAAE;IAC5B,MAAMC,CAAC,GAAGJ,wBAAwB,CAAC,CAAC;IAC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iB,KAAK,CAACK,gBAAgB,CAACC,OAAO,GAAG,IAAI;QACrCN,KAAK,CAACK,gBAAgB,CAACC,OAAO,GAAG,KAAK;QACtC,IAAIW,OAAO,IAAI,IAAI,EAAE;UACnB,IAAI,CAAClC,GAAG,CACN,MAAM,EACN,2EACF,CAAC;UACD,OAAO,IAAI;QACb;QACA,MAAMoC,OAAO,GAAG,MAAM,IAAI,CAACT,YAAY,CACpCE,CAAC,IAAKA,CAAC,CAACM,WAAW,KAAK,KAAK,EAC9B,IACF,CAAC;QACD,MAAM,IAAI,CAACpC,KAAK,CAAC,GAAG,CAAC;QACrB,MAAMsC,KAAK,GAAG,MAAM,IAAI,CAACV,YAAY,CAClCE,CAAC,IAAKA,CAAC,CAACM,WAAW,KAAK,KAAK,EAC9B,CACF,CAAC;QACD,IAAI,CAAClB,KAAK,CAACE,OAAO,EAAE;UAClB;UACAF,KAAK,CAACK,gBAAgB,CAACC,OAAO,GAAG,IAAI;UACrC,OAAO,KAAK;QACd;QACA,IAAIa,OAAO,KAAK,IAAI,IAAIC,KAAK,KAAK,IAAI,EAAE;UACtC,IAAI,CAACrC,GAAG,CACN,MAAM,EACN,yDAAyDiC,KAAK,GAChE,CAAC;UACD,OAAO,IAAI;QACb;QACA,IAAI,CAACjC,GAAG,CACN,MAAM,EACN,kDAAkDiC,KAAK,YACzD,CAAC;MACH;MACA,IAAI,CAACjC,GAAG,CACN,OAAO,EACP,uDACF,CAAC;MACD,OAAO,KAAK;IACd,CAAC,SAAS;MACR,IAAIgC,WAAW,EAAE,MAAM,IAAI,CAACrB,OAAO,CAAC,CAAC;IACvC;EACF;AACF;;AAEA;AACA,OAAO,MAAM2B,aAAa,GAAG,IAAIjD,aAAa,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+
3
+ // Copyright (c) 2026 Gravity Compile. MIT License; see LICENSE.
4
+
5
+ /**
6
+ * Bridge to the Android-native audio features (`GravixNativeAudio.kt`): one
7
+ * call with the Flutter SDK's method names and argument maps, plus native
8
+ * events. The TurboModule binding installs itself with
9
+ * {@link setGravixAndroidAudioBridge}; tests install a fake.
10
+ */
11
+
12
+ /** Thrown when the native side is missing (iOS, web, no `GravixRtc.setup`). */
13
+ export class GravixNativeUnavailableError extends Error {
14
+ code = 'NATIVE_UNAVAILABLE';
15
+ constructor(feature, why) {
16
+ super(`${feature}: ${why}`);
17
+ this.name = 'GravixNativeUnavailableError';
18
+ }
19
+ }
20
+ let bridge = null;
21
+ export function setGravixAndroidAudioBridge(b) {
22
+ bridge = b;
23
+ }
24
+ export function gravixAndroidAudioBridge() {
25
+ return bridge;
26
+ }
27
+ export function requireBridge(feature) {
28
+ if (!bridge) {
29
+ throw new GravixNativeUnavailableError(feature, 'the Android native audio module is not available on this platform');
30
+ }
31
+ return bridge;
32
+ }
33
+
34
+ /** The native capability map (`GravixNativeAudio.capabilities`). */
35
+
36
+ export async function androidAudioCapabilities() {
37
+ if (!bridge) return null;
38
+ try {
39
+ return await bridge.call('capabilities');
40
+ } catch {
41
+ return null;
42
+ }
43
+ }
44
+ export function asMap(v) {
45
+ return v !== null && typeof v === 'object' ? v : null;
46
+ }
47
+ //# sourceMappingURL=nativeAudio.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["GravixNativeUnavailableError","Error","code","constructor","feature","why","name","bridge","setGravixAndroidAudioBridge","b","gravixAndroidAudioBridge","requireBridge","androidAudioCapabilities","call","asMap","v"],"sourceRoot":"../../../src","sources":["android/nativeAudio.ts"],"mappings":";;AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAsBA;AACA,OAAO,MAAMA,4BAA4B,SAASC,KAAK,CAAC;EAC7CC,IAAI,GAAG,oBAAoB;EACpCC,WAAWA,CAACC,OAAe,EAAEC,GAAW,EAAE;IACxC,KAAK,CAAC,GAAGD,OAAO,KAAKC,GAAG,EAAE,CAAC;IAC3B,IAAI,CAACC,IAAI,GAAG,8BAA8B;EAC5C;AACF;AAEA,IAAIC,MAAuC,GAAG,IAAI;AAElD,OAAO,SAASC,2BAA2BA,CACzCC,CAAkC,EAC5B;EACNF,MAAM,GAAGE,CAAC;AACZ;AAEA,OAAO,SAASC,wBAAwBA,CAAA,EAAoC;EAC1E,OAAOH,MAAM;AACf;AAEA,OAAO,SAASI,aAAaA,CAACP,OAAe,EAA4B;EACvE,IAAI,CAACG,MAAM,EAAE;IACX,MAAM,IAAIP,4BAA4B,CACpCI,OAAO,EACP,mEACF,CAAC;EACH;EACA,OAAOG,MAAM;AACf;;AAEA;;AAkBA,OAAO,eAAeK,wBAAwBA,CAAA,EAAmD;EAC/F,IAAI,CAACL,MAAM,EAAE,OAAO,IAAI;EACxB,IAAI;IACF,OAAQ,MAAMA,MAAM,CAACM,IAAI,CACvB,cACF,CAAC;EACH,CAAC,CAAC,MAAM;IACN,OAAO,IAAI;EACb;AACF;AAEA,OAAO,SAASC,KAAKA,CAACC,CAAU,EAAkC;EAChE,OAAOA,CAAC,KAAK,IAAI,IAAI,OAAOA,CAAC,KAAK,QAAQ,GACrCA,CAAC,GACF,IAAI;AACV","ignoreList":[]}
@@ -0,0 +1,170 @@
1
+ "use strict";
2
+
3
+ // Copyright (c) 2026 Gravity Compile. MIT License; see LICENSE.
4
+
5
+ import { noiseSuppressionOptions, nsBenchmarkKey, resolveNs } from 'gravix-rtc';
6
+ import { asMap, requireBridge } from "./nativeAudio.js";
7
+
8
+ /**
9
+ * On-device noise suppression on Android (native gx_ns: RNNoise `standard`,
10
+ * DeepFilterNet3 `studio` on arm64), the levels of the Flutter SDK:
11
+ * `off` | `standard` | `studio` | `auto`. The engine is resolved in JS with
12
+ * the shared resolver of the `gravix-rtc` core (same policy fixture as
13
+ * Flutter / web), then configured natively (Flutter `nsConfigure`).
14
+ *
15
+ * WebRTC's own NS / AGC should be off on the microphone while ours runs: the
16
+ * caller captures the mic with `noiseSuppression: false, autoGainControl:
17
+ * false` (echo cancellation on) when {@link GravixAndroidNsState.engine} is
18
+ * ours, exactly as the web SDK does (`disableWebRtcNs`).
19
+ */
20
+
21
+ /** Flutter's engine names on the native side. */
22
+ function nativeEngineName(e) {
23
+ switch (e) {
24
+ case 'rnnoise':
25
+ return 'rnnoise';
26
+ case 'dfn3':
27
+ return 'dfn3';
28
+ default:
29
+ return 'off';
30
+ }
31
+ }
32
+ let cachedBenchmark = null;
33
+ let benchmarkRunning = null;
34
+
35
+ /** Static device facts from the native side (model, soc, abi, RAM, ...). */
36
+ export async function androidNsDeviceFacts() {
37
+ const m = asMap(await requireBridge('noiseSuppression').call('nsDeviceFacts')) ?? {};
38
+ return {
39
+ platform: 'android',
40
+ ...m
41
+ };
42
+ }
43
+
44
+ /** The `nsConfigure` arguments for [o] resolved to [engine] (Flutter GravixNoiseController). */
45
+ export function androidNsConfigureArgs(o, engine, reason) {
46
+ return {
47
+ mode: o.mode,
48
+ engine: nativeEngineName(engine),
49
+ reason,
50
+ agcOrder: o.agcOrder,
51
+ musicBypass: o.musicBypass,
52
+ autoMusic: o.autoMusic ?? true,
53
+ hardwareNs: o.hardwareNs,
54
+ headsetNs: o.headsetNs,
55
+ watchdogFrameUs: Math.round(o.watchdogFrameMs * 1000),
56
+ watchdogConsecutive: o.watchdogConsecutive,
57
+ thermalFallback: o.thermalFallback,
58
+ batterySaverFallback: o.batterySaverFallback,
59
+ studioSource: o.studioSource,
60
+ studioDownload: o.studioDownload,
61
+ studioAttenLimitDb: o.studioAttenLimitDb,
62
+ studioP95BudgetUs: o.studioP95BudgetUs,
63
+ studioP95WindowMs: o.studioP95WindowMs,
64
+ studioLowLatency: o.studioLowLatency
65
+ };
66
+ }
67
+
68
+ /**
69
+ * Resolves and applies the noise suppression level. `auto` without a cached
70
+ * benchmark runs RNNoise first and benchmarks studio in the background; once
71
+ * the benchmark is in, call this again (or pass `rerunAfterBenchmark`).
72
+ */
73
+ export async function configureAndroidNoiseSuppression(options, opts = {}) {
74
+ const b = requireBridge('noiseSuppression');
75
+ const o = noiseSuppressionOptions(options);
76
+ const facts = o.mode === 'off' ? {
77
+ platform: 'android'
78
+ } : await androidNsDeviceFacts();
79
+ // the resolver reads the typed facts; the studio keys ride along
80
+ const key = androidNsBenchmarkKey(facts);
81
+ const r = resolveNs({
82
+ mode: o.mode,
83
+ facts,
84
+ policy: o.policy ?? null,
85
+ benchmark: cachedBenchmark,
86
+ benchmarkKey: key,
87
+ studioAvailable: facts.studioAvailable === true,
88
+ benchmarkP95Us: o.benchmarkP95Us
89
+ });
90
+ if (r.needsBenchmark && key && !benchmarkRunning) {
91
+ benchmarkRunning = runBenchmark(o.benchmarkP95Us, key).then(() => {
92
+ benchmarkRunning = null;
93
+ if (opts.rerunAfterBenchmark !== false && cachedBenchmark) {
94
+ configureAndroidNoiseSuppression(options, {
95
+ rerunAfterBenchmark: false
96
+ }).catch(() => {});
97
+ }
98
+ });
99
+ }
100
+ let reply = null;
101
+ try {
102
+ reply = asMap(await b.call('nsConfigure', androidNsConfigureArgs(o, r.engine, r.reason)));
103
+ } catch {
104
+ reply = null;
105
+ }
106
+ let engine = r.engine;
107
+ let reason = r.reason;
108
+ const ours = engine === 'rnnoise' || engine === 'dfn3';
109
+ if (ours && (reply == null || reply.ok !== true)) {
110
+ engine = 'off';
111
+ reason = typeof reply?.reason === 'string' ? reply.reason : 'native_unavailable';
112
+ } else if (ours && typeof reply?.engine === 'string') {
113
+ // the native side may have downgraded (thermal, saver, watchdog)
114
+ if (reply.engine === 'rnnoise' || reply.engine === 'dfn3' || reply.engine === 'off') {
115
+ engine = reply.engine;
116
+ }
117
+ if (typeof reply.reason === 'string') reason = reply.reason;
118
+ }
119
+ return {
120
+ mode: o.mode,
121
+ engine,
122
+ reason,
123
+ installed: reply?.installed === true,
124
+ route: typeof reply?.route === 'string' ? reply.route : undefined,
125
+ rate: typeof reply?.rate === 'number' ? reply.rate : undefined
126
+ };
127
+ }
128
+
129
+ /** SDK version in the benchmark key: a new native build re-benchmarks. */
130
+ export const GRAVIX_RN_NS_SDK_VERSION = 'rn-android-0.1.0';
131
+
132
+ /** Same key shape as Flutter / web (`nsBenchmarkKey`); null without a studio model. */
133
+ export function androidNsBenchmarkKey(facts) {
134
+ const sha = facts.studioSha;
135
+ if (typeof sha !== 'string' || !sha) return null;
136
+ return nsBenchmarkKey({
137
+ sdkVersion: GRAVIX_RN_NS_SDK_VERSION,
138
+ modelSha256: sha,
139
+ runtimeVersion: String(facts.studioRuntime ?? ''),
140
+ osBuild: String(facts.osBuild ?? '')
141
+ });
142
+ }
143
+ async function runBenchmark(budgetUs, key) {
144
+ try {
145
+ const m = asMap(await requireBridge('noiseSuppression').call('nsBenchmark', {
146
+ budgetUs
147
+ }));
148
+ if (m && m.ok === true && typeof m.p95Us === 'number') {
149
+ cachedBenchmark = {
150
+ key,
151
+ p95Us: m.p95Us,
152
+ outputOk: m.outputOk === true
153
+ };
154
+ }
155
+ } catch {
156
+ // no benchmark: auto stays on RNNoise
157
+ }
158
+ }
159
+
160
+ /** The native state map (`nsStats`): engine, rate, route, stats. */
161
+ export async function androidNoiseSuppressionStats() {
162
+ return asMap(await requireBridge('noiseSuppression').call('nsStats'));
163
+ }
164
+
165
+ /** Test seam. */
166
+ export function __resetAndroidNsForTests() {
167
+ cachedBenchmark = null;
168
+ benchmarkRunning = null;
169
+ }
170
+ //# sourceMappingURL=noiseSuppression.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["noiseSuppressionOptions","nsBenchmarkKey","resolveNs","asMap","requireBridge","nativeEngineName","e","cachedBenchmark","benchmarkRunning","androidNsDeviceFacts","m","call","platform","androidNsConfigureArgs","o","engine","reason","mode","agcOrder","musicBypass","autoMusic","hardwareNs","headsetNs","watchdogFrameUs","Math","round","watchdogFrameMs","watchdogConsecutive","thermalFallback","batterySaverFallback","studioSource","studioDownload","studioAttenLimitDb","studioP95BudgetUs","studioP95WindowMs","studioLowLatency","configureAndroidNoiseSuppression","options","opts","b","facts","key","androidNsBenchmarkKey","r","policy","benchmark","benchmarkKey","studioAvailable","benchmarkP95Us","needsBenchmark","runBenchmark","then","rerunAfterBenchmark","catch","reply","ours","ok","installed","route","undefined","rate","GRAVIX_RN_NS_SDK_VERSION","sha","studioSha","sdkVersion","modelSha256","runtimeVersion","String","studioRuntime","osBuild","budgetUs","p95Us","outputOk","androidNoiseSuppressionStats","__resetAndroidNsForTests"],"sourceRoot":"../../../src","sources":["android/noiseSuppression.ts"],"mappings":";;AAAA;;AAEA,SACEA,uBAAuB,EACvBC,cAAc,EACdC,SAAS,QAMJ,YAAY;AACnB,SAASC,KAAK,EAAEC,aAAa,QAAQ,kBAAe;;AAEpD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYA;AACA,SAASC,gBAAgBA,CAACC,CAAiB,EAAU;EACnD,QAAQA,CAAC;IACP,KAAK,SAAS;MACZ,OAAO,SAAS;IAClB,KAAK,MAAM;MACT,OAAO,MAAM;IACf;MACE,OAAO,KAAK;EAChB;AACF;AAEA,IAAIC,eAAyC,GAAG,IAAI;AACpD,IAAIC,gBAAsC,GAAG,IAAI;;AAEjD;AACA,OAAO,eAAeC,oBAAoBA,CAAA,EAExC;EACA,MAAMC,CAAC,GACLP,KAAK,CAAC,MAAMC,aAAa,CAAC,kBAAkB,CAAC,CAACO,IAAI,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,CAAC;EAC5E,OAAO;IAAEC,QAAQ,EAAE,SAAS;IAAE,GAAIF;EAAa,CAAC;AAGlD;;AAEA;AACA,OAAO,SAASG,sBAAsBA,CACpCC,CAAgC,EAChCC,MAAsB,EACtBC,MAAc,EACW;EACzB,OAAO;IACLC,IAAI,EAAEH,CAAC,CAACG,IAAI;IACZF,MAAM,EAAEV,gBAAgB,CAACU,MAAM,CAAC;IAChCC,MAAM;IACNE,QAAQ,EAAEJ,CAAC,CAACI,QAAQ;IACpBC,WAAW,EAAEL,CAAC,CAACK,WAAW;IAC1BC,SAAS,EAAGN,CAAC,CAA6BM,SAAS,IAAI,IAAI;IAC3DC,UAAU,EAAEP,CAAC,CAACO,U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