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
package/README.md CHANGED
@@ -1,3 +1,314 @@
1
- # Temporary Holding Version
1
+ # gravix-rtc-react-native
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Real-time voice, video and live rooms for **React Native** (Android and iOS) on
4
+ **Gravix Cloud**. The React Native sibling of the Flutter `gravix_rtc` package
5
+ and the web `gravix-rtc` package.
6
+
7
+ > Status: 0.2.0, the first npm release. Run on Android phones (Xiaomi Redmi, Infinix)
8
+ > on 2026-12-01: join, camera, mic, mute-releases-mic, voice effect and the
9
+ > Gravix beauty effects, side by side with Flutter `gravix_rtc` 0.12.2. iOS is
10
+ > build- and unit-tested only (no device run), and the beauty effects are
11
+ > Android-only. The native audio features (voice effects, room music,
12
+ > mute-releases-mic, noise suppression, singer capture, audio scenario) are
13
+ > ported from Flutter `gravix_rtc` 0.12.2; screen share is still a typed stub.
14
+ > See [docs/FEATURE_MATRIX.md](docs/FEATURE_MATRIX.md).
15
+
16
+ ## How it is built
17
+
18
+ - **JavaScript core:** the published [`gravix-rtc`](https://www.npmjs.com/package/gravix-rtc)
19
+ package (peer dependency). Room, tracks, events, `GravixJoin`, region probe,
20
+ `GravixTokenProvider`, `createToken` and the analytics reports live there
21
+ once, for web and React Native; this package re-exports all of it, so apps
22
+ import from one place.
23
+ - **WebRTC engine:** [`react-native-webrtc`](https://github.com/react-native-webrtc/react-native-webrtc)
24
+ ^155 (peer dependency, MIT), the same base as the Gravix effects packages.
25
+ - **This package:** `registerGlobals`, `AudioSession`, `VideoView`, hooks, the
26
+ React Native join lifecycle, the `GravixRtc` native module (Kotlin / Obj-C++)
27
+ and the native-feature APIs. Some files are modified from Apache-2.0
28
+ sources; see [NOTICE](NOTICE).
29
+
30
+ ## Install
31
+
32
+ ```sh
33
+ npm install gravix-rtc-react-native "gravix-rtc@>=0.10.0 <0.12.0" react-native-webrtc@^155.0.0
34
+ ```
35
+
36
+ `gravix-rtc` 0.10.x and 0.11.x both work. npm has 0.10.0 today (2026-12-01);
37
+ move to **0.11.0** once it is published: it has the fix for muted room music
38
+ being reported as speaking.
39
+
40
+ React Native **0.88+** with the New Architecture (tested with 0.88.0, React
41
+ 19.3, Gradle 9.4, compileSdk 37). Expo Go is not supported (use a development
42
+ build). For the beauty effects add the optional packages (Android):
43
+
44
+ ```sh
45
+ npm install react-native-gravix-effects@^1.4.3 react-native-gravix-effects-webrtc@^1.4.3
46
+ ```
47
+
48
+ ### iOS
49
+
50
+ 1. `cd ios && pod install` (react-native-webrtc 155 brings `JitsiWebRTC`
51
+ 155 from the CocoaPods trunk).
52
+ 2. `Info.plist`: `NSCameraUsageDescription`, `NSMicrophoneUsageDescription`,
53
+ and `UIBackgroundModes` `audio` (+ `voip` for calls).
54
+ 3. `AppDelegate.swift`, before React Native starts:
55
+
56
+ ```swift
57
+ import gravix_rtc_react_native
58
+
59
+ GravixRtcSetup.setup()
60
+ ```
61
+ 4. **Native audio features on iOS (beta, opt-in).** Voice effects, noise
62
+ suppression, room music, singer mode and mute-releases-mic run in a Gravix
63
+ audio device (`RTCAudioDevice`) that has **not yet been verified on a real
64
+ iPhone**. It is off by default: WebRTC's built-in audio device runs and those
65
+ features report unavailable. To try it, add the boolean `GravixAudioDevice`
66
+ = YES to `Info.plist`, and check the iPhone list in
67
+ [docs/IOS_NATIVE_HOOKS.md](docs/IOS_NATIVE_HOOKS.md) section 8b (echo,
68
+ mute indicator, routes, interruptions, CallKit) before you ship it.
69
+
70
+ ### Android
71
+
72
+ 1. `MainApplication.kt`, in `onCreate()` before `loadReactNative(this)`:
73
+
74
+ ```kotlin
75
+ import com.gravitycompile.gravixrtc.GravixRtc
76
+
77
+ GravixRtc.setup(this)
78
+ ```
79
+ 2. The library manifest adds the permissions WebRTC and audio routing need
80
+ (`INTERNET`, `ACCESS_NETWORK_STATE`, `CAMERA`, `RECORD_AUDIO`,
81
+ `MODIFY_AUDIO_SETTINGS`, `BLUETOOTH` (API ≤ 30), `BLUETOOTH_CONNECT`);
82
+ request camera/mic at runtime. `GravixRtc.setup(this, audioScenario =
83
+ "chatRoom")` picks the chatRoom scenario (Agora parity).
84
+ `setup` also warms up networking on a background thread (WebView cookie
85
+ store + TLS trust store, main process only), which saves ~250 ms on the
86
+ first join token request. If the app calls
87
+ `WebView.setDataDirectorySuffix()`, do it before `setup`, or pass
88
+ `prewarmNetworking = false`.
89
+ 3. Audio routing uses `com.github.davidliu:audioswitch` from JitPack; the
90
+ library adds the JitPack repository itself. If your build sets
91
+ `dependencyResolutionManagement { repositoriesMode = FAIL_ON_PROJECT_REPOS }`,
92
+ add `maven { url "https://jitpack.io" }` to `settings.gradle`.
93
+ 4. Studio noise suppression (DeepFilterNet3, arm64-v8a, ~6 MB) is **off by
94
+ default** and its binaries are not in the npm package. Opt in with
95
+ `gravixNsStudio=true` in `android/gradle.properties`: the build fetches the
96
+ four `.so` files once (pinned SHA-256) from the public `gravix_rtc` repo, or
97
+ from `gravixNsStudioDir=/path` (offline / CI cache), or
98
+ `gravixNsStudioUrl=<base url>`. Without it, `studio` mode reports
99
+ `studio_unavailable` and RNNoise (`standard`) runs.
100
+
101
+ ### Metro (required)
102
+
103
+ ```js
104
+ // metro.config.js
105
+ const { getDefaultConfig } = require('@react-native/metro-config');
106
+ const { withGravixRtc } = require('gravix-rtc-react-native/metro');
107
+
108
+ module.exports = withGravixRtc(getDefaultConfig(__dirname));
109
+ ```
110
+
111
+ This step is mandatory: without it the Hermes bundle fails to compile.
112
+ `withGravixRtc` keeps gravix-rtc's browser noise-suppression module (WASM +
113
+ `import.meta`, which Hermes cannot compile) out of the bundle.
114
+
115
+ ## Quick start
116
+
117
+ ```tsx
118
+ // index.js — once, before any Room exists
119
+ import { registerGlobals } from 'gravix-rtc-react-native';
120
+ registerGlobals();
121
+ ```
122
+
123
+ ```tsx
124
+ import {
125
+ AudioSession, GravixRoomProvider, Room, Track, useRoom, VideoView,
126
+ } from 'gravix-rtc-react-native';
127
+
128
+ async function join(url: string, token: string) {
129
+ const room = new Room({ adaptiveStream: true, dynacast: true });
130
+ await AudioSession.startAudioSession();
131
+ await room.connect(url, token); // token from your server
132
+ await room.localParticipant.setMicrophoneEnabled(true);
133
+ return room;
134
+ }
135
+
136
+ function RoomScreen() {
137
+ const { participants, activeSpeakers, tracks } = useRoom(undefined, {
138
+ sources: [Track.Source.Camera],
139
+ });
140
+ return tracks.map((t) => (
141
+ <VideoView key={t.publication.trackSid} trackRef={t} style={{ height: 200 }} />
142
+ ));
143
+ }
144
+ // <GravixRoomProvider room={room}><RoomScreen /></GravixRoomProvider>
145
+ ```
146
+
147
+ Leaving: `await room.disconnect(); await AudioSession.stopAudioSession();`
148
+
149
+ Speaker: `AudioSession.setSpeakerphoneOn(true | false)`.
150
+
151
+ ## Gravix extras (from gravix-rtc)
152
+
153
+ - **Tokens:** `GravixTokenProvider.endpoint(url)` / `.callback(fn)` /
154
+ `.literal({ token, url })`, `connectWithTokenProvider(room, {...})`.
155
+ `GravixTokenProvider.local` and `createToken` sign on the device (needs the
156
+ App Certificate in the app; prefer a server). `registerGlobals()` installs an
157
+ HMAC-SHA256-only `crypto.subtle` for this, since Hermes has no WebCrypto.
158
+ - **Fast join:** use `createGravixJoin({ tokenProvider })` instead of
159
+ `new GravixJoin(...)`: it is the same `GravixJoin` with the app lifecycle
160
+ (`AppState`) as the join guard (a join left in the background before the
161
+ room screen attached is abandoned). `warm` / `prepare` / `attach` /
162
+ `switchTo` / `leave` work as in the
163
+ [gravix-rtc README](https://www.npmjs.com/package/gravix-rtc).
164
+ - **Region selection:** `connectOptions: { regionProbe: true }`,
165
+ `prewarmJoin(...)`, `RoomEvent.JoinTimeline`, join retry, standby sockets.
166
+ - **Singer mode (publish half):** `room.setSingerMode(on, options)`.
167
+
168
+ ## Native-only features
169
+
170
+ ```ts
171
+ import { GravixVoiceEffects, isFeatureSupported, GravixUnsupportedError } from 'gravix-rtc-react-native';
172
+
173
+ if (isFeatureSupported('voiceEffects')) {
174
+ await GravixVoiceEffects.instance.set('hall');
175
+ }
176
+ ```
177
+
178
+ `getCapabilities()` reports, per platform, which native features are
179
+ available (after `GravixRtc.setup` / `GravixRtcSetup.setup()`). Where one is
180
+ missing, calls throw `GravixUnsupportedError` (`code:
181
+ 'not_supported_on_platform'`, with `feature`, `operation`, `platform`).
182
+
183
+ ### Mute releases the microphone (on by default; iOS: opt-in beta)
184
+
185
+ As in Flutter `gravix_rtc` 0.12.1+, a mic mute closes the platform recorder
186
+ (the OS mic indicator goes off) on every Room, with no app code:
187
+ `registerGlobals()` installs a room hook. iOS: only with the opt-in Gravix
188
+ audio device (`Info.plist` `GravixAudioDevice` = YES, beta); without it a
189
+ mute is a plain track mute and the mic stays open. Android: WebRTC stops the recorder on mute, and a mic
190
+ published while already muted (also after a reconnect) gets its recorder
191
+ closed. Under room music on Android, `music.setMicMuted(true)` is a voice-only
192
+ mute: the song keeps going out and no mute is signalled, so drive the mic
193
+ button from `useMicMuted()` (or `GravixMicRelease.isMicMuted(room)`), not from
194
+ `track.isMuted`.
195
+
196
+ Rollback (one flag): `registerGlobals({ muteReleasesMic: false })`.
197
+
198
+ ### Room music bitrate (iOS)
199
+
200
+ Call `music.attach(room)`: while the song plays, `musicMaxBitrate` and
201
+ `disableDtxWhileMusic` are applied through `room.setSingerMode(true, …)` and
202
+ undone on stop (an app-owned singer mode is left alone).
203
+
204
+ ### Beauty effects (Android)
205
+
206
+ The Gravix beauty filter (looks, reshape, makeup; Flutter `GravixBeautyEffect`)
207
+ runs through the optional peer packages `react-native-gravix-effects` +
208
+ `react-native-gravix-effects-webrtc` (1.4.3+, React Native >= 0.88, the same
209
+ `react-native-webrtc` ^155). Install both in the app to turn it on; without
210
+ them the SDK builds and runs, and the room uses its normal camera.
211
+
212
+ ```ts
213
+ import { GravixBeautyEffect, GravixRoomCamera } from 'gravix-rtc-react-native';
214
+ import { GravixPreview } from 'react-native-gravix-effects-webrtc';
215
+
216
+ const beauty = new GravixBeautyEffect({ licenseToken }); // null = watermark
217
+ beauty.preload(); // when the screen opens
218
+ await GravixBeautyEffect.ensurePack(onProgress); // gravixEffectsPack=models: download on first use
219
+ const camera = new GravixRoomCamera(room, { videoEffect: beauty });
220
+ await camera.connect(url, token); // join; the camera opens during the connect, published when up
221
+ // (or: await room.connect(url, token); await camera.setCameraEnabled(true);)
222
+ await camera.setVideoEffectParams({ look: 'glow' });
223
+ await camera.setVideoEffectParams({ tone: { smoothness: 0.7 } });
224
+ await camera.setVideoEffectParams({ lut: 'warm' }); // or lutBytes (base64 PNG); null resets
225
+ await camera.setVideoEffectEnabled(false); // bypass, the camera keeps running
226
+ await camera.switchCamera(); // same track, no republish
227
+ await camera.setCameraEnabled(false); // unpublish + close; on again replays enabled + look + sliders
228
+ // preview: <GravixPreview camera={beauty.camera} />
229
+ ```
230
+
231
+ Use `GravixRoomCamera` for the camera instead of
232
+ `localParticipant.setCameraEnabled` (both together open two cameras). The
233
+ camera closes on leave (`RoomEvent.Disconnected`); call `camera.dispose()`
234
+ when the screen goes away. Params (`look` / `lookBytes`, `tone` / `region` / `reshape`, `lut` /
235
+ `lutBytes`) are merged across calls and replayed in that order after every
236
+ camera reopen (a new camera session starts empty). Flutter replays only the
237
+ last call; rollback `mergeEffectParams: false`. `connect()` opens the effect
238
+ camera while the room connects (Flutter opens it after the connect); rollback
239
+ `openCameraDuringConnect: false`. If the room drops the camera track (a failed
240
+ republish after a reconnect), the camera closes and the next
241
+ `setCameraEnabled(true)` reopens it. `switchCamera()` rejects on an error
242
+ (e.g. no second camera); Flutter only logs it.
243
+
244
+ The camera is published with Flutter's profile,
245
+ `GRAVIX_CAMERA_PUBLISH_OPTIONS` (800 kbps / 24 fps top layer, one 180p rung at
246
+ 160 kbps, balanced degradation); `publishOptions` overrides it and `{}` goes
247
+ back to the room's publishDefaults.
248
+
249
+ Everything else of the effects API (overlays, stickers, stats,
250
+ `currentValues()`) is on `beauty.camera` while it runs, or via
251
+ `gravixEffects()`. Calls made there directly are **not** replayed after a
252
+ camera reopen; use the params above for what must survive.
253
+
254
+ Android setup for the effects (same as Flutter): `gravixEffectsPack=models` in
255
+ `android/gradle.properties` downloads the effects pack on first use
256
+ (`ensurePack`); the effects packages need portrait orientation, the New
257
+ Architecture and the `INTERNET` permission (their manifest adds it).
258
+
259
+ #### Licence token (no watermark)
260
+
261
+ Like Flutter, the effects licence token comes from **your server**, not from
262
+ the SDK: in the Gravix customer panel open the App ID's **Effects** page,
263
+ enable it, add the Android package name and the SHA-256 of every signing
264
+ certificate you ship (debug and release: `./gradlew signingReport`), and
265
+ press **Create token**. Pass it as `new GravixBeautyEffect({ licenseToken })`.
266
+
267
+ - The token is bound to the package name + signing certificate: another APK
268
+ gets `WRONG_PACKAGE` / `WRONG_CERT`.
269
+ - Its expiry follows the App ID's package (30 days rolling with wallet balance
270
+ only). The native SDK renews it by itself at
271
+ `console.gravixcloud.com/v1/effects/license` (daily while OK, every 5 min
272
+ while refused and in the last 10 min); offline it stays valid until it
273
+ expires.
274
+ - No token or a refused one: the effects keep running with a "Gravix Cloud"
275
+ watermark + QR; nothing stops or crashes.
276
+ - `await GravixBeautyEffect.licenseStatus()` reads the state: `OK`, `MISSING`,
277
+ `INVALID_SIGNATURE`, `MALFORMED`, `WRONG_PACKAGE`, `WRONG_CERT`, `EXPIRED`,
278
+ and after the online check `LIMIT`, `REVOKED`, `UNKNOWN_APP`; null without
279
+ the effects packages. The licence is set once, at the first camera open.
280
+
281
+ The room join token is separate and works as for every Gravix SDK:
282
+ `GravixTokenProvider.endpoint(tokenUrl)` (your server signs it) or
283
+ `GravixTokenProvider.local` / `createToken` (signs on the device; needs the App
284
+ Certificate in the app).
285
+
286
+ #### Not on iOS (yet)
287
+
288
+ The effects packages are Android-only. On iOS, `GravixBeautyEffect.isAvailable()`
289
+ is false and `GravixRoomCamera` publishes the normal camera, so the same app
290
+ code runs on both platforms. The example's iOS project has not been rebuilt on
291
+ React Native 0.88.
292
+
293
+ ## Development
294
+
295
+ ```sh
296
+ node .yarn/releases/yarn-4.18.1.cjs install # or: corepack yarn install
297
+ npx tsc && npx eslint "**/*.{js,ts,tsx}" && npx jest
298
+ npx bob build
299
+ cd example/android && ./gradlew assembleDebug -PreactNativeArchitectures=arm64-v8a
300
+ cd example/ios && pod install && xcodebuild -workspace GravixRtcReactNativeExample.xcworkspace \
301
+ -scheme GravixRtcReactNativeExample -sdk iphonesimulator -configuration Debug build
302
+ ```
303
+
304
+ The example app (`example/`) joins a room with a server URL and a join token
305
+ and shows participants, speaking state, mic/camera/speaker controls and video,
306
+ the beauty effects panel (`example/src/EffectsPanel.tsx`) and the beauty
307
+ baseline device harness (`example/src/BeautyBaseline.tsx`, started with
308
+ `am start --es role beauty ...`).
309
+
310
+ ## License
311
+
312
+ MIT, Copyright (c) 2026 Gravity Compile. Includes code under the Apache
313
+ License 2.0 ([LICENSES/Apache-2.0.txt](LICENSES/Apache-2.0.txt)); see
314
+ [NOTICE](NOTICE).
@@ -0,0 +1,137 @@
1
+ // Copyright (c) 2026 Gravity Compile. MIT License; see LICENSE.
2
+
3
+ ext.GravixRtc = [
4
+ minSdkVersion: 24,
5
+ compileSdkVersion: 36,
6
+ // react-native-webrtc 155 declares org.jitsi:webrtc:155.+ (floating); the recorder
7
+ // reflection, the keep rules and the JVM contract test are checked against this
8
+ // exact build, so it is pinned strictly here.
9
+ webrtcVersion: "155.0.1",
10
+ // audioswitch commit of the AudioSwitchManager port.
11
+ audioswitchVersion: "89582c47c9a04c62f90aa5e57251af4800a62c9a",
12
+ ]
13
+
14
+ ext.getExtOrDefault = { prop ->
15
+ if (rootProject.ext.has(prop)) {
16
+ return rootProject.ext.get(prop)
17
+ }
18
+ return GravixRtc[prop]
19
+ }
20
+
21
+ // Studio noise suppression (DeepFilterNet3 on a minimal ONNX Runtime, arm64-v8a, ~6 MB).
22
+ // OFF by default in this package (the Flutter SDK bundles it): the binaries are not in
23
+ // the npm package or the repo. Opt in with `gravixNsStudio=true` in the app's
24
+ // gradle.properties; the four .so files are then fetched once into the build dir and
25
+ // checked against the pinned SHA-256 below, from
26
+ // gravixNsStudioDir=/path/with/the/so/files (offline / CI cache), or
27
+ // gravixNsStudioUrl=<base url> (default: the public gravix_rtc repo).
28
+ // Without it, studio mode reports studio_unavailable and RNNoise (standard) runs.
29
+ def gravixNsStudio = (rootProject.findProperty("gravixNsStudio") ?: "false").toString().toBoolean()
30
+ def gravixNsStudioFiles = [
31
+ "libgxort.so" : "385c89a98d61cac5c93f279fec35d9b98ba43973bede6725456a47af7aa90b73",
32
+ "libgxns_dfn3_std.so" : "0e4c4f4fc2c5f564528419957267f017fb3d0fc8f1bc33765d06dca67230e14d",
33
+ "libgxns_dfn3_bench.so" : "c577c2960c469ad3d9c2f53d0c6dc0512a41bc5a720bcba33181daf0ace4a99a",
34
+ "libgxns_dfn3_ref.so" : "28314c0ac2c1f1d9a8da5fd63941103c8c8ce48400d59a1db0f257c0fc44d16e",
35
+ ]
36
+ def gravixNsStudioJniLibs = new File(project.layout.buildDirectory.get().asFile, "gravix-ns-studio/jniLibs")
37
+
38
+ def gravixSha256 = { File f ->
39
+ def md = java.security.MessageDigest.getInstance("SHA-256")
40
+ f.eachByte(65536) { buf, n -> md.update(buf, 0, n) }
41
+ return md.digest().encodeHex().toString()
42
+ }
43
+
44
+ // Runs at configuration time so CMake (which links libgxort.so) finds the files.
45
+ def gravixFetchNsStudio = {
46
+ def out = new File(gravixNsStudioJniLibs, "arm64-v8a")
47
+ out.mkdirs()
48
+ def dir = rootProject.findProperty("gravixNsStudioDir")
49
+ def base = (rootProject.findProperty("gravixNsStudioUrl") ?:
50
+ "https://raw.githubusercontent.com/assajeeb/gravix_rtc/v0.5.2/android/src/studio/jniLibs/arm64-v8a").toString()
51
+ gravixNsStudioFiles.each { name, sha ->
52
+ def f = new File(out, name)
53
+ if (f.exists() && gravixSha256(f) == sha) return
54
+ def tmp = new File(out, name + ".part")
55
+ if (dir) {
56
+ tmp.bytes = new File(dir.toString(), name).bytes
57
+ } else {
58
+ logger.lifecycle("gravix-rtc-react-native: downloading ${name} (studio noise suppression)")
59
+ new URL("${base}/${name}").withInputStream { i -> tmp.withOutputStream { o -> o << i } }
60
+ }
61
+ def got = gravixSha256(tmp)
62
+ if (got != sha) {
63
+ tmp.delete()
64
+ throw new GradleException("gravixNsStudio: ${name} SHA-256 ${got} != pinned ${sha}")
65
+ }
66
+ f.delete()
67
+ tmp.renameTo(f)
68
+ }
69
+ }
70
+ if (gravixNsStudio) gravixFetchNsStudio()
71
+
72
+ apply plugin: "com.android.library"
73
+
74
+ if (project.extensions.findByName("kotlin") == null) {
75
+ apply plugin: "kotlin-android"
76
+ }
77
+
78
+ apply plugin: "com.facebook.react"
79
+
80
+ android {
81
+ namespace "com.gravitycompile.gravixrtc"
82
+
83
+ compileSdkVersion getExtOrDefault("compileSdkVersion")
84
+
85
+ defaultConfig {
86
+ minSdkVersion getExtOrDefault("minSdkVersion")
87
+ consumerProguardFiles "consumer-rules.pro"
88
+ externalNativeBuild {
89
+ cmake {
90
+ arguments "-DANDROID_STL=c++_static", "-DGXNS_STUDIO=" + (gravixNsStudio ? "ON" : "OFF"),
91
+ "-DGXNS_STUDIO_LIBS=" + new File(gravixNsStudioJniLibs, "arm64-v8a").absolutePath
92
+ }
93
+ }
94
+ }
95
+
96
+ // Native audio (noise suppression gx_ns, voice effects gxfx, studio DFN3), vendored
97
+ // from the Flutter SDK (gravix_rtc 0.12.2): the C cores in ../native (shared with iOS),
98
+ // the JNI bridges in src/main/cpp.
99
+ externalNativeBuild {
100
+ cmake {
101
+ path "src/main/cpp/CMakeLists.txt"
102
+ version "3.22.1"
103
+ }
104
+ }
105
+
106
+ sourceSets {
107
+ main {
108
+ // The studio engine's prebuilt files (arm64-v8a only), fetched above when opted in.
109
+ if (gravixNsStudio) jniLibs.srcDirs += gravixNsStudioJniLibs
110
+ }
111
+ }
112
+
113
+ testOptions {
114
+ unitTests {
115
+ // android.* stubs return defaults (Log, SystemClock) in the JVM tests
116
+ returnDefaultValues = true
117
+ }
118
+ }
119
+ }
120
+
121
+ repositories {
122
+ google()
123
+ mavenCentral()
124
+ // com.github.davidliu:audioswitch is only published on JitPack.
125
+ maven { url "https://jitpack.io" }
126
+ }
127
+
128
+ dependencies {
129
+ implementation "com.facebook.react:react-android"
130
+ implementation project(":react-native-webrtc")
131
+ api("org.jitsi:webrtc") {
132
+ version { strictly getExtOrDefault('webrtcVersion') }
133
+ }
134
+ api "com.github.davidliu:audioswitch:${getExtOrDefault('audioswitchVersion')}"
135
+ implementation "androidx.annotation:annotation:1.9.1"
136
+ testImplementation "junit:junit:4.13.2"
137
+ }
@@ -0,0 +1,29 @@
1
+ -keep class com.gravitycompile.gravixrtc.** { *; }
2
+ -keep class org.webrtc.audio.WebRtcAudioTrackHelper { *; }
3
+ # --- Gravix native audio (voice effects, noise suppression, room music, mic release) ---
4
+ # JNI-bound classes: the native method names are fixed in libgxns / libgxfx / libgxns_dfn.
5
+ -keep class com.gravitycompile.gravixrtc.processing.GxNsNative { native <methods>; }
6
+ -keep class com.gravitycompile.gravixrtc.processing.GxVoiceFx { native <methods>; }
7
+ -keep class com.gravitycompile.gravixrtc.processing.GxNsStudio { native <methods>; *; }
8
+ -keepclasseswithmembernames class com.gravitycompile.gravixrtc.** { native <methods>; }
9
+ # Private WebRTC (org.jitsi:webrtc 155.0.1) members reached by reflection (GxRecorderSeam,
10
+ # GxCaptureSwitcher, WebRtcAudioTrackHelper). Pinned by WebRtcReflectionContractTest.
11
+ -keepclassmembers class org.webrtc.audio.WebRtcAudioRecord {
12
+ private android.media.AudioRecord audioRecord;
13
+ private org.webrtc.audio.WebRtcAudioRecord$AudioRecordThread audioThread;
14
+ private final int audioSource;
15
+ private final boolean isAcousticEchoCancelerSupported;
16
+ private final boolean isNoiseSuppressorSupported;
17
+ private final org.webrtc.audio.WebRtcAudioEffects effects;
18
+ }
19
+ -keepclassmembers class org.webrtc.audio.WebRtcAudioEffects {
20
+ public void enable(int);
21
+ public void release();
22
+ }
23
+ -keepclassmembers class org.webrtc.audio.JavaAudioDeviceModule {
24
+ private final org.webrtc.audio.WebRtcAudioRecord audioInput;
25
+ private final org.webrtc.audio.WebRtcAudioTrack audioOutput;
26
+ }
27
+ -keepclassmembers class org.webrtc.audio.WebRtcAudioTrack {
28
+ private final android.media.AudioAttributes audioAttributes;
29
+ }
@@ -0,0 +1,9 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ <uses-permission android:name="android.permission.INTERNET" />
3
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
4
+ <uses-permission android:name="android.permission.CAMERA" />
5
+ <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
6
+ <uses-permission android:name="android.permission.RECORD_AUDIO" />
7
+ <uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
8
+ <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
9
+ </manifest>
@@ -0,0 +1,48 @@
1
+ # libgxns.so for Android: the gx_ns core (RNNoise + speexdsp resampler + gx_ns)
2
+ # from ./gxns (vendored from the Flutter SDK native/gxns, 5c4d44c) plus the JNI bridge used by GxNoiseProcessor.kt.
3
+ cmake_minimum_required(VERSION 3.18)
4
+ project(gxns_android C CXX)
5
+
6
+ set(GXNS_ROOT ${CMAKE_CURRENT_LIST_DIR}/../../../../native/gxns)
7
+ # Reuse the core's source list / defines (it only defines static targets).
8
+ add_subdirectory(${GXNS_ROOT} ${CMAKE_CURRENT_BINARY_DIR}/gxns_core EXCLUDE_FROM_ALL)
9
+ set_target_properties(gxns PROPERTIES POSITION_INDEPENDENT_CODE ON)
10
+
11
+ add_library(gxns_jni SHARED gx_ns_jni.c)
12
+ set_target_properties(gxns_jni PROPERTIES OUTPUT_NAME gxns)
13
+ target_link_libraries(gxns_jni PRIVATE gxns log m)
14
+ target_compile_options(gxns_jni PRIVATE -O2 -fvisibility=hidden -ffunction-sections -fdata-sections)
15
+ # 16 KB page alignment (Android 15+ devices) regardless of the NDK default;
16
+ # drop unused sections; export only the JNI entry points.
17
+ target_link_options(gxns_jni PRIVATE
18
+ -Wl,-z,max-page-size=16384
19
+ -Wl,--gc-sections
20
+ -Wl,--exclude-libs,ALL
21
+ -Wl,--build-id=sha1)
22
+
23
+ # libgxfx.so: voice effects (../native/gxfx). C++ with a private static libc++,
24
+ # separate from libgxns so noise suppression never depends on it.
25
+ set(GXFX_ROOT ${CMAKE_CURRENT_LIST_DIR}/../../../../native/gxfx)
26
+ add_library(gxfx SHARED gx_fx_jni.cpp ${GXFX_ROOT}/src/gx_fx.cpp)
27
+ target_include_directories(gxfx PRIVATE ${GXFX_ROOT}/include)
28
+ target_compile_features(gxfx PRIVATE cxx_std_17)
29
+ target_compile_options(gxfx PRIVATE -O2 -fvisibility=hidden -fvisibility-inlines-hidden -fno-exceptions -fno-rtti -ffunction-sections -fdata-sections)
30
+ target_link_libraries(gxfx PRIVATE log m)
31
+ target_link_options(gxfx PRIVATE -Wl,-z,max-page-size=16384 -Wl,--gc-sections -Wl,--exclude-libs,ALL -Wl,--build-id=sha1)
32
+
33
+ # Studio engine (DeepFilterNet3 on the bundled minimal ONNX Runtime): arm64-v8a
34
+ # only. A separate library so libgxns never depends on ORT.
35
+ option(GXNS_STUDIO "Build the DFN3 studio engine (arm64-v8a)" OFF)
36
+ # GXNS_STUDIO_LIBS: the folder with libgxort.so (android/build.gradle fetches it).
37
+ if(GXNS_STUDIO AND ANDROID_ABI STREQUAL "arm64-v8a")
38
+ # libgxort.so = the release ORT 1.31.0 minimal with its soname renamed
39
+ # (tool/ns_android/rename_ort.py): never collides with an app's libonnxruntime.so
40
+ add_library(gx_onnxruntime SHARED IMPORTED)
41
+ set_target_properties(gx_onnxruntime PROPERTIES
42
+ IMPORTED_LOCATION ${GXNS_STUDIO_LIBS}/libgxort.so)
43
+ add_library(gxns_dfn SHARED gx_dfn_engine.c)
44
+ target_include_directories(gxns_dfn PRIVATE ${GXNS_ROOT}/include ${CMAKE_CURRENT_LIST_DIR}/third_party/onnxruntime/include)
45
+ target_link_libraries(gxns_dfn PRIVATE gx_onnxruntime log m)
46
+ target_compile_options(gxns_dfn PRIVATE -O2 -fvisibility=hidden -ffunction-sections -fdata-sections)
47
+ target_link_options(gxns_dfn PRIVATE -Wl,-z,max-page-size=16384 -Wl,--gc-sections -Wl,--build-id=sha1)
48
+ endif()