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,273 @@
1
+ // Copyright 2023-2026 LiveKit, Inc.
2
+ // Modifications Copyright 2026 Gravity Compile.
3
+ // Licensed under the Apache License, Version 2.0; see LICENSES/Apache-2.0.txt.
4
+
5
+ #import "GravixRtc.h"
6
+ #import "GravixRtcSetup.h"
7
+ #import "audio/GxAudioSetup.h"
8
+
9
+ #import <AVFAudio/AVFAudio.h>
10
+ #import <AVKit/AVKit.h>
11
+ #import <WebRTC/WebRTC.h>
12
+ #import <UIKit/UIKit.h>
13
+
14
+ // AllowBluetoothHFP is the iOS 26 SDK name of AllowBluetooth (same value); older Xcode only has the old one.
15
+ #if defined(__IPHONE_26_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_26_0
16
+ #define GX_ALLOW_BLUETOOTH_HFP AVAudioSessionCategoryOptionAllowBluetoothHFP
17
+ #else
18
+ #define GX_ALLOW_BLUETOOTH_HFP AVAudioSessionCategoryOptionAllowBluetooth
19
+ #endif
20
+
21
+ static NSString *const kGravixNativeVersion = @"0.2.0";
22
+
23
+ /// Keep in sync with NATIVE_FEATURES in src/unsupported.ts and the Android module.
24
+ static NSArray<NSString *> *GravixNativeFeatures(void)
25
+ {
26
+ return @[
27
+ @"voiceEffects", @"roomMusic", @"muteReleasesMic", @"noiseSuppression",
28
+ @"singerMode", @"audioScenario", @"screenShareService"
29
+ ];
30
+ }
31
+
32
+ static AVAudioSessionMode GravixAudioModeFromString(NSString *mode)
33
+ {
34
+ NSDictionary<NSString *, AVAudioSessionMode> *map = @{
35
+ @"default" : AVAudioSessionModeDefault,
36
+ @"voicePrompt" : AVAudioSessionModeVoicePrompt,
37
+ @"videoRecording" : AVAudioSessionModeVideoRecording,
38
+ @"videoChat" : AVAudioSessionModeVideoChat,
39
+ @"voiceChat" : AVAudioSessionModeVoiceChat,
40
+ @"gameChat" : AVAudioSessionModeGameChat,
41
+ @"measurement" : AVAudioSessionModeMeasurement,
42
+ @"moviePlayback" : AVAudioSessionModeMoviePlayback,
43
+ @"spokenAudio" : AVAudioSessionModeSpokenAudio,
44
+ };
45
+ return map[mode] ?: AVAudioSessionModeDefault;
46
+ }
47
+
48
+ static AVAudioSessionCategory GravixAudioCategoryFromString(NSString *category)
49
+ {
50
+ NSDictionary<NSString *, AVAudioSessionCategory> *map = @{
51
+ @"ambient" : AVAudioSessionCategoryAmbient,
52
+ @"soloAmbient" : AVAudioSessionCategorySoloAmbient,
53
+ @"playback" : AVAudioSessionCategoryPlayback,
54
+ @"record" : AVAudioSessionCategoryRecord,
55
+ @"playAndRecord" : AVAudioSessionCategoryPlayAndRecord,
56
+ @"multiRoute" : AVAudioSessionCategoryMultiRoute,
57
+ };
58
+ return map[category] ?: AVAudioSessionCategorySoloAmbient;
59
+ }
60
+
61
+ static AVAudioSessionCategoryOptions GravixAudioCategoryOptionsFromStrings(NSArray<NSString *> *options)
62
+ {
63
+ AVAudioSessionCategoryOptions result = 0;
64
+ for (NSString *option in options) {
65
+ if ([option isEqualToString:@"mixWithOthers"]) {
66
+ result |= AVAudioSessionCategoryOptionMixWithOthers;
67
+ } else if ([option isEqualToString:@"duckOthers"]) {
68
+ result |= AVAudioSessionCategoryOptionDuckOthers;
69
+ } else if ([option isEqualToString:@"allowBluetooth"]) {
70
+ result |= GX_ALLOW_BLUETOOTH_HFP;
71
+ } else if ([option isEqualToString:@"allowBluetoothA2DP"]) {
72
+ result |= AVAudioSessionCategoryOptionAllowBluetoothA2DP;
73
+ } else if ([option isEqualToString:@"allowAirPlay"]) {
74
+ result |= AVAudioSessionCategoryOptionAllowAirPlay;
75
+ } else if ([option isEqualToString:@"defaultToSpeaker"]) {
76
+ result |= AVAudioSessionCategoryOptionDefaultToSpeaker;
77
+ } else if ([option isEqualToString:@"interruptSpokenAudioAndMixWithOthers"]) {
78
+ result |= AVAudioSessionCategoryOptionInterruptSpokenAudioAndMixWithOthers;
79
+ } else if ([option isEqualToString:@"overrideMutedMicrophoneInterruption"]) {
80
+ result |= AVAudioSessionCategoryOptionOverrideMutedMicrophoneInterruption;
81
+ }
82
+ }
83
+ return result;
84
+ }
85
+
86
+ @implementation GravixRtc
87
+
88
+
89
+ + (NSString *)moduleName
90
+ {
91
+ return @"GravixRtc";
92
+ }
93
+
94
+ - (NSDictionary *)getCapabilities
95
+ {
96
+ NSMutableDictionary *features = [NSMutableDictionary dictionary];
97
+ for (NSString *feature in GravixNativeFeatures()) {
98
+ features[feature] = @NO;
99
+ }
100
+ // iOS audio (ios/audio): the capture-chain features need the Gravix audio
101
+ // device in react-native-webrtc's options (GravixRtcSetup.setup before React
102
+ // Native starts; an app-set device or the plist rollback: false).
103
+ BOOL chain = [GxAudioSetup isChainLive];
104
+ features[@"voiceEffects"] = @(chain);
105
+ features[@"noiseSuppression"] = @(chain);
106
+ features[@"roomMusic"] = @(chain);
107
+ features[@"singerMode"] = @(chain);
108
+ // Mute releases mic needs the Gravix device (stock WebRTC records on under a
109
+ // track stop): the mic close makes the unit playout-only. Scenario = NS AGC order.
110
+ features[@"muteReleasesMic"] = @(chain);
111
+ features[@"audioScenario"] = @YES;
112
+ return @{
113
+ @"platform" : @"ios",
114
+ @"nativeVersion" : kGravixNativeVersion,
115
+ @"setUp" : @([GravixRtcSetup isSetUp]),
116
+ @"features" : features,
117
+ };
118
+ }
119
+
120
+ - (void)configureAudio:(NSDictionary *)config
121
+ resolve:(RCTPromiseResolveBlock)resolve
122
+ reject:(RCTPromiseRejectBlock)reject
123
+ {
124
+ NSDictionary *ios = [config[@"ios"] isKindOfClass:[NSDictionary class]] ? config[@"ios"] : nil;
125
+ if (ios == nil) {
126
+ resolve(nil);
127
+ return;
128
+ }
129
+ NSString *defaultOutput = [ios[@"defaultOutput"] isKindOfClass:[NSString class]] ? ios[@"defaultOutput"] : @"speaker";
130
+ RTCAudioSessionConfiguration *rtcConfig = [[RTCAudioSessionConfiguration alloc] init];
131
+ rtcConfig.category = AVAudioSessionCategoryPlayAndRecord;
132
+ AVAudioSessionCategoryOptions options = AVAudioSessionCategoryOptionAllowAirPlay |
133
+ GX_ALLOW_BLUETOOTH_HFP |
134
+ AVAudioSessionCategoryOptionAllowBluetoothA2DP;
135
+ if ([defaultOutput isEqualToString:@"earpiece"]) {
136
+ rtcConfig.categoryOptions = options;
137
+ rtcConfig.mode = AVAudioSessionModeVoiceChat;
138
+ } else {
139
+ rtcConfig.categoryOptions = options | AVAudioSessionCategoryOptionDefaultToSpeaker;
140
+ rtcConfig.mode = AVAudioSessionModeVideoChat;
141
+ }
142
+ [RTCAudioSessionConfiguration setWebRTCConfiguration:rtcConfig];
143
+ resolve(nil);
144
+ }
145
+
146
+ - (void)startAudioSession:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject
147
+ {
148
+ [self setSessionActive:YES resolve:resolve reject:reject];
149
+ }
150
+
151
+ - (void)stopAudioSession:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject
152
+ {
153
+ [self setSessionActive:NO resolve:resolve reject:reject];
154
+ }
155
+
156
+ - (void)setSessionActive:(BOOL)active resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject
157
+ {
158
+ RTCAudioSession *session = [RTCAudioSession sharedInstance];
159
+ [session lockForConfiguration];
160
+ NSError *error = nil;
161
+ BOOL ok = [session setActive:active error:&error];
162
+ [session unlockForConfiguration];
163
+ if (ok) {
164
+ resolve(nil);
165
+ } else {
166
+ reject(active ? @"startAudioSession" : @"stopAudioSession", error.localizedDescription, error);
167
+ }
168
+ }
169
+
170
+ - (void)getAudioOutputs:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject
171
+ {
172
+ resolve(@[ @"default", @"force_speaker" ]);
173
+ }
174
+
175
+ - (void)selectAudioOutput:(NSString *)deviceId
176
+ resolve:(RCTPromiseResolveBlock)resolve
177
+ reject:(RCTPromiseRejectBlock)reject
178
+ {
179
+ AVAudioSession *session = [AVAudioSession sharedInstance];
180
+ NSError *error = nil;
181
+ BOOL ok = YES;
182
+ if ([deviceId isEqualToString:@"default"]) {
183
+ ok = [session overrideOutputAudioPort:AVAudioSessionPortOverrideNone error:&error];
184
+ } else if ([deviceId isEqualToString:@"force_speaker"]) {
185
+ ok = [session overrideOutputAudioPort:AVAudioSessionPortOverrideSpeaker error:&error];
186
+ } else {
187
+ reject(@"selectAudioOutput", [NSString stringWithFormat:@"Unknown audio output '%@'", deviceId], nil);
188
+ return;
189
+ }
190
+ if (ok) {
191
+ resolve(nil);
192
+ } else {
193
+ reject(@"selectAudioOutput", error.localizedDescription, error);
194
+ }
195
+ }
196
+
197
+ - (void)showAudioRoutePicker:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject
198
+ {
199
+ dispatch_async(dispatch_get_main_queue(), ^{
200
+ AVRoutePickerView *picker = [[AVRoutePickerView alloc] init];
201
+ for (UIView *subview in picker.subviews) {
202
+ if ([subview isKindOfClass:[UIButton class]]) {
203
+ [(UIButton *)subview sendActionsForControlEvents:UIControlEventTouchUpInside];
204
+ break;
205
+ }
206
+ }
207
+ resolve(nil);
208
+ });
209
+ }
210
+
211
+ - (void)setAppleAudioConfiguration:(NSDictionary *)configuration
212
+ resolve:(RCTPromiseResolveBlock)resolve
213
+ reject:(RCTPromiseRejectBlock)reject
214
+ {
215
+ RTCAudioSession *session = [RTCAudioSession sharedInstance];
216
+ RTCAudioSessionConfiguration *config = [RTCAudioSessionConfiguration webRTCConfiguration];
217
+ NSString *category = configuration[@"audioCategory"];
218
+ NSArray *categoryOptions = configuration[@"audioCategoryOptions"];
219
+ NSString *mode = configuration[@"audioMode"];
220
+ if ([category isKindOfClass:[NSString class]]) {
221
+ config.category = GravixAudioCategoryFromString(category);
222
+ }
223
+ if ([categoryOptions isKindOfClass:[NSArray class]]) {
224
+ config.categoryOptions = GravixAudioCategoryOptionsFromStrings(categoryOptions);
225
+ }
226
+ if ([mode isKindOfClass:[NSString class]]) {
227
+ config.mode = GravixAudioModeFromString(mode);
228
+ }
229
+ [session lockForConfiguration];
230
+ NSError *error = nil;
231
+ BOOL ok = [session setConfiguration:config error:&error];
232
+ [session unlockForConfiguration];
233
+ if (ok) {
234
+ resolve(nil);
235
+ } else {
236
+ reject(@"setAppleAudioConfiguration", error.localizedDescription, error);
237
+ }
238
+ }
239
+
240
+ - (void)setWebRTCAudioConfiguration:(NSDictionary *)configuration
241
+ {
242
+ // The session WebRTC's audio unit applies when it starts (RTCAudioSession
243
+ // webRTCConfiguration). nil / empty: the GravixRtcSetup default.
244
+ RTCAudioSessionConfiguration *config = [[RTCAudioSessionConfiguration alloc] init];
245
+ if (![configuration isKindOfClass:[NSDictionary class]] || configuration.count == 0) {
246
+ config.category = AVAudioSessionCategoryPlayAndRecord;
247
+ config.categoryOptions = AVAudioSessionCategoryOptionAllowAirPlay | GX_ALLOW_BLUETOOTH_HFP |
248
+ AVAudioSessionCategoryOptionAllowBluetoothA2DP |
249
+ AVAudioSessionCategoryOptionDefaultToSpeaker;
250
+ config.mode = AVAudioSessionModeVideoChat;
251
+ } else {
252
+ NSString *category = configuration[@"audioCategory"];
253
+ NSArray *categoryOptions = configuration[@"audioCategoryOptions"];
254
+ NSString *mode = configuration[@"audioMode"];
255
+ config.category = [category isKindOfClass:[NSString class]] ? GravixAudioCategoryFromString(category)
256
+ : AVAudioSessionCategoryPlayAndRecord;
257
+ if ([categoryOptions isKindOfClass:[NSArray class]]) {
258
+ config.categoryOptions = GravixAudioCategoryOptionsFromStrings(categoryOptions);
259
+ }
260
+ if ([mode isKindOfClass:[NSString class]]) {
261
+ config.mode = GravixAudioModeFromString(mode);
262
+ }
263
+ }
264
+ [RTCAudioSessionConfiguration setWebRTCConfiguration:config];
265
+ }
266
+
267
+ - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
268
+ (const facebook::react::ObjCTurboModule::InitParams &)params
269
+ {
270
+ return std::make_shared<facebook::react::NativeGravixRtcSpecJSI>(params);
271
+ }
272
+
273
+ @end
@@ -0,0 +1,29 @@
1
+ // Copyright (c) 2026 Gravity Compile. MIT License; see LICENSE.
2
+
3
+ #import <Foundation/Foundation.h>
4
+
5
+ NS_ASSUME_NONNULL_BEGIN
6
+
7
+ /// Native setup for the Gravix React Native SDK on iOS.
8
+ ///
9
+ /// Call `[GravixRtcSetup setup]` (Swift: `GravixRtcSetup.setup()`) in
10
+ /// `application:didFinishLaunchingWithOptions:` before React Native starts.
11
+ /// It installs the default audio
12
+ /// session configuration (playAndRecord / videoChat / speaker) into
13
+ /// react-native-webrtc, and installs the Gravix audio device
14
+ /// (`WebRTCModuleOptions.audioDevice`) that runs voice effects, noise
15
+ /// suppression and room music and closes the mic on mute; see
16
+ /// docs/IOS_NATIVE_HOOKS.md. Call it after setting any own
17
+ /// `WebRTCModuleOptions`; an app-set `audioDevice` is kept (the features then
18
+ /// report unavailable). Rollback to WebRTC's built-in audio device: Info.plist
19
+ /// boolean `GravixAudioDevice` is not YES (the device is opt-in beta).
20
+ @interface GravixRtcSetup : NSObject
21
+
22
+ + (void)setup;
23
+
24
+ /// Whether `+setup` ran in this process.
25
+ + (BOOL)isSetUp;
26
+
27
+ @end
28
+
29
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,52 @@
1
+ // Copyright 2023-2026 LiveKit, Inc.
2
+ // Modifications Copyright 2026 Gravity Compile.
3
+ // Licensed under the Apache License, Version 2.0; see LICENSES/Apache-2.0.txt.
4
+
5
+ #import "GravixRtcSetup.h"
6
+
7
+ #import <AVFAudio/AVFAudio.h>
8
+ #import <WebRTC/WebRTC.h>
9
+ #import "audio/GxAudioSetup.h"
10
+
11
+ // AllowBluetoothHFP is the iOS 26 SDK name of AllowBluetooth (same value); older Xcode only has the old one.
12
+ #if defined(__IPHONE_26_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_26_0
13
+ #define GX_ALLOW_BLUETOOTH_HFP AVAudioSessionCategoryOptionAllowBluetoothHFP
14
+ #else
15
+ #define GX_ALLOW_BLUETOOTH_HFP AVAudioSessionCategoryOptionAllowBluetooth
16
+ #endif
17
+
18
+ static BOOL gGravixRtcSetUp = NO;
19
+
20
+ @implementation GravixRtcSetup
21
+
22
+ + (void)setup
23
+ {
24
+ // Video codecs: react-native-webrtc's own factories (its WebRTC build has no
25
+ // simulcast encoder factory wrapper; VP8 simulcast runs in libvpx).
26
+ // No WebRTC field trials are forced on: they are not verified against the
27
+ // Gravix SFU. Apps can set WebRTCModuleOptions.fieldTrials themselves.
28
+
29
+ RTCAudioSessionConfiguration *config = [[RTCAudioSessionConfiguration alloc] init];
30
+ config.category = AVAudioSessionCategoryPlayAndRecord;
31
+ config.categoryOptions = AVAudioSessionCategoryOptionAllowAirPlay |
32
+ GX_ALLOW_BLUETOOTH_HFP |
33
+ AVAudioSessionCategoryOptionAllowBluetoothA2DP |
34
+ AVAudioSessionCategoryOptionDefaultToSpeaker;
35
+ config.mode = AVAudioSessionModeVideoChat;
36
+ [RTCAudioSessionConfiguration setWebRTCConfiguration:config];
37
+
38
+ // Voice effects, noise suppression, room music, mute releases mic: the Gravix
39
+ // audio device (WebRTCModuleOptions.audioDevice, read when react-native-webrtc
40
+ // builds its factory). Not installed when the app set its own audio device or
41
+ // Info.plist GravixAudioDevice not YES (opt-in beta; GxAudioSetup logs why).
42
+ [GxAudioSetup installProcessing];
43
+
44
+ gGravixRtcSetUp = YES;
45
+ }
46
+
47
+ + (BOOL)isSetUp
48
+ {
49
+ return gGravixRtcSetUp;
50
+ }
51
+
52
+ @end
@@ -0,0 +1,157 @@
1
+ // Copyright (c) 2026 Gravity Compile. MIT License; see LICENSE.
2
+
3
+ #import <React/RCTBridgeModule.h>
4
+ #import <React/RCTEventEmitter.h>
5
+ #import "GxAudioDevice.h"
6
+ #import "GxAudioSetup.h"
7
+ #import "gravix_rtc_react_native-Swift.h"
8
+
9
+ static NSString *const kGxEvent = @"GravixIosAudioEvent";
10
+
11
+ /// iOS-only audio features (voice effects, noise suppression, room music,
12
+ /// recorder state). A plain interop module, not part of the shared codegen
13
+ /// spec, so the Android build is unaffected; JS reaches it only from the iOS
14
+ /// branches (src/ios/). One generic `call(method, args)` keeps the native
15
+ /// surface identical to the Flutter method channels.
16
+ @interface GravixRtcIosAudio : RCTEventEmitter <RCTBridgeModule>
17
+ @end
18
+
19
+ @implementation GravixRtcIosAudio {
20
+ BOOL _listening;
21
+ }
22
+
23
+
24
+ RCT_EXPORT_MODULE(GravixRtcIosAudio)
25
+
26
+ + (BOOL)requiresMainQueueSetup
27
+ {
28
+ return NO;
29
+ }
30
+
31
+ /// Rollback (Info.plist boolean `GravixMuteStopsMicTrack` = YES): the JS policy
32
+ /// also stops the mic track on mute (`stopOnMute`, reacquired on unmute), the
33
+ /// 0.2.0-beta behaviour. Default NO: with the Gravix audio device the device's
34
+ /// mic close (`setCaptureClosed`) is the only mute path.
35
+ - (NSDictionary *)constantsToExport
36
+ {
37
+ id v = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"GravixMuteStopsMicTrack"];
38
+ BOOL stops = [v respondsToSelector:@selector(boolValue)] && [v boolValue];
39
+ return @{ @"muteStopsMicTrack" : @(stops) };
40
+ }
41
+
42
+ - (NSArray<NSString *> *)supportedEvents
43
+ {
44
+ return @[ kGxEvent ];
45
+ }
46
+
47
+ - (void)startObserving
48
+ {
49
+ _listening = YES;
50
+ __weak GravixRtcIosAudio *weakSelf = self;
51
+ [GxEvents setSink:^(NSString *name, NSDictionary<NSString *, id> *body) {
52
+ GravixRtcIosAudio *strongSelf = weakSelf;
53
+ if (strongSelf == nil) {
54
+ return;
55
+ }
56
+ [strongSelf sendEventWithName:kGxEvent body:@{ @"name" : name, @"body" : body ?: @{} }];
57
+ }];
58
+ }
59
+
60
+ - (void)stopObserving
61
+ {
62
+ _listening = NO;
63
+ [GxEvents setSink:nil];
64
+ }
65
+
66
+ - (void)invalidate
67
+ {
68
+ [GxEvents setSink:nil];
69
+ // JS reload / teardown: the JS mute state is gone; a mute close must not
70
+ // outlive it (it opens once WebRTC stops recording, no flash before).
71
+ if ([GxAudioSetup isChainLive]) {
72
+ [[GxAudioDevice shared] releaseCaptureCloseOnStop];
73
+ }
74
+ [super invalidate];
75
+ }
76
+
77
+ /// Reports whether the Gravix chain is installed (the audio device in
78
+ /// react-native-webrtc's options). The JS layer calls it at
79
+ /// import and before each feature's first native call.
80
+ RCT_EXPORT_METHOD(attach : (RCTPromiseResolveBlock)resolve reject : (RCTPromiseRejectBlock)reject)
81
+ {
82
+ BOOL live = [GxAudioSetup isChainLive];
83
+ resolve(@{
84
+ @"processingInstalled" : @(live),
85
+ // The room-music monitor is mixed by the Gravix audio device itself.
86
+ @"graphHooked" : @(live),
87
+ });
88
+ }
89
+
90
+ /// The microphone recorder as the Gravix audio device sees it (mute releases
91
+ /// the mic: `recording` false, `microphoneMuted` true, playout-only unit).
92
+ RCT_EXPORT_METHOD(getRecorderState : (RCTPromiseResolveBlock)resolve reject : (RCTPromiseRejectBlock)reject)
93
+ {
94
+ if (![GxAudioSetup isChainLive]) {
95
+ reject(@"adm_unavailable", @"the Gravix audio device is not in use (GravixRtcSetup.setup not called before React "
96
+ @"Native started, an app audio device, or Info.plist GravixAudioDevice not YES: opt-in beta)", nil);
97
+ return;
98
+ }
99
+ resolve([[GxAudioDevice shared] recorderState]);
100
+ }
101
+
102
+ /// Mute releases the mic (room mic policy, every local mic mute / unmute):
103
+ /// closes or reopens the microphone input of the Gravix audio device.
104
+ /// Resolves false when the device is not in use (nothing to close).
105
+ RCT_EXPORT_METHOD(setCaptureClosed
106
+ : (BOOL)closed resolve
107
+ : (RCTPromiseResolveBlock)resolve reject
108
+ : (RCTPromiseRejectBlock)reject)
109
+ {
110
+ if (![GxAudioSetup isChainLive]) {
111
+ resolve(@NO);
112
+ return;
113
+ }
114
+ [[GxAudioDevice shared] setCaptureClosed:closed];
115
+ resolve(@YES);
116
+ }
117
+
118
+ /// The muted mic's publication ended (final unpublish, room left): the mute
119
+ /// close lasts while WebRTC still records and ends when recording stops, so a
120
+ /// reconnect republish (which keeps the publication) never reopens the mic.
121
+ RCT_EXPORT_METHOD(releaseCaptureClose : (RCTPromiseResolveBlock)resolve reject : (RCTPromiseRejectBlock)reject)
122
+ {
123
+ if (![GxAudioSetup isChainLive]) {
124
+ resolve(@NO);
125
+ return;
126
+ }
127
+ [[GxAudioDevice shared] releaseCaptureCloseOnStop];
128
+ resolve(@YES);
129
+ }
130
+
131
+ RCT_EXPORT_METHOD(call
132
+ : (NSString *)method args
133
+ : (NSDictionary *)args resolve
134
+ : (RCTPromiseResolveBlock)resolve reject
135
+ : (RCTPromiseRejectBlock)reject)
136
+ {
137
+ static NSSet<NSString *> *needsDevice;
138
+ static dispatch_once_t once;
139
+ dispatch_once(&once, ^{
140
+ needsDevice = [NSSet setWithArray:@[ @"fxConfigure", @"nsConfigure", @"nsSetSingerMode", @"music.start" ]];
141
+ });
142
+ if ([needsDevice containsObject:method] && ![GxAudioSetup isChainLive]) {
143
+ reject(@"unavailable", [NSString stringWithFormat:@"%@: the Gravix audio device is not in use", method], nil);
144
+ return;
145
+ }
146
+ [GxIosAudio call:method
147
+ args:args
148
+ completion:^(id _Nullable value, NSArray<NSString *> *_Nullable error) {
149
+ if (error != nil) {
150
+ reject(error.firstObject ?: @"error", error.count > 1 ? error[1] : @"error", nil);
151
+ } else {
152
+ resolve(value ?: [NSNull null]);
153
+ }
154
+ }];
155
+ }
156
+
157
+ @end
@@ -0,0 +1,62 @@
1
+ // Copyright (c) 2026 Gravity Compile. MIT License; see LICENSE.
2
+
3
+ #import <Foundation/Foundation.h>
4
+ #import <WebRTC/WebRTC.h>
5
+
6
+ NS_ASSUME_NONNULL_BEGIN
7
+
8
+ /// The Gravix iOS audio device: a complete `RTCAudioDevice` (the only audio
9
+ /// seam stock WebRTC 155 / react-native-webrtc 155 offers, through
10
+ /// `WebRTCModuleOptions.audioDevice`), so the Gravix capture chain can run.
11
+ ///
12
+ /// - Capture: one voice-processing I/O unit (VPIO: Apple AEC / NS / AGC),
13
+ /// 16-bit mono at the session rate. Each IO block goes through the Gravix
14
+ /// chain (`gx_ios_capture_process`: noise suppression -> voice effect ->
15
+ /// room music) and is then handed to WebRTC (`deliverRecordedData`).
16
+ /// - Playout: WebRTC's `getPlayoutData`, plus the room-music monitor.
17
+ /// - Mute releases the mic: while WebRTC records nothing, or the mic is
18
+ /// closed for a mute (`setCaptureClosed:`), the unit is a playout-only
19
+ /// RemoteIO unit (input disabled, no mic indicator); a listener who never
20
+ /// publishes never opens the mic.
21
+ /// - Owns the audio session as WebRTC's built-in device does: applies
22
+ /// `RTCAudioSessionConfiguration.webRTCConfiguration` and activates it
23
+ /// while playing or recording, honours `useManualAudio` /
24
+ /// `isAudioEnabled`, restarts on interruptions, route / rate changes and
25
+ /// media-services resets.
26
+ ///
27
+ /// Threads: the protocol methods run on WebRTC's audio device thread, inside a
28
+ /// control mutex that also serialises a newer factory's takeover (rule in
29
+ /// gx_adm_state.h: calls from an older factory are no-ops); session events hop
30
+ /// there with `dispatchAsync`; the IO callbacks run on the audio
31
+ /// unit's real-time threads (no locks, no Objective-C messages; the Gravix chain
32
+ /// itself allocates nothing, except the studio noise suppressor's Core ML
33
+ /// prediction, as in the Flutter SDK).
34
+ @interface GxAudioDevice : NSObject <RTCAudioDevice>
35
+
36
+ /// The process-lifetime instance (react-native-webrtc holds it strongly).
37
+ + (instancetype)shared;
38
+
39
+ /// Some WebRTC factory initialised the device and still owns it (any thread;
40
+ /// the protocol's `isInitialized` answers per factory thread).
41
+ @property(readonly) BOOL isUsable;
42
+
43
+ /// Mute releases the mic: closes (YES) or reopens the microphone input while
44
+ /// WebRTC keeps its send stream (stock WebRTC records on under a track mute).
45
+ /// Closed, the unit is playout-only and no capture reaches WebRTC (the room
46
+ /// music position holds). Any thread; applied on the audio device thread.
47
+ /// The close survives WebRTC stopping and restarting its recording (a
48
+ /// reconnect republish of a muted mic never opens the input); it ends with an
49
+ /// unmute (`NO`), `releaseCaptureCloseOnStop`, a newer factory or terminate.
50
+ - (void)setCaptureClosed:(BOOL)closed;
51
+
52
+ /// The muted publication ended (final unpublish, room left, JS reload): the mic
53
+ /// stays closed while WebRTC still records and opens once recording stops, so
54
+ /// the next fresh publish starts with the input open. Any thread.
55
+ - (void)releaseCaptureCloseOnStop;
56
+
57
+ /// The microphone recorder state for `getRecorderState` (any thread).
58
+ - (NSDictionary<NSString *, id> *)recorderState;
59
+
60
+ @end
61
+
62
+ NS_ASSUME_NONNULL_END