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,1057 @@
1
+ // Copyright (c) 2026 Gravity Compile. MIT License; see LICENSE.
2
+
3
+ /**
4
+ * Beauty / camera video effects: the React Native twin of Flutter gravix_rtc's
5
+ * `GravixVideoEffect` / `GravixCameraEffect` / `GravixBeautyEffect` and the
6
+ * camera part of `GravixRoomService` (reference: gravix_rtc 0.12.2, 5c4d44c).
7
+ *
8
+ * Thin wiring over the OPTIONAL peer packages `react-native-gravix-effects` +
9
+ * `react-native-gravix-effects-webrtc` (Android). They are loaded lazily; an
10
+ * app without them builds and runs, `GravixBeautyEffect.canOwnCamera()` answers
11
+ * false and {@link GravixRoomCamera} opens the normal camera instead (Flutter:
12
+ * a stripped native SDK).
13
+ *
14
+ * ```ts
15
+ * const beauty = new GravixBeautyEffect({ licenseToken });
16
+ * const camera = new GravixRoomCamera(room, { videoEffect: beauty });
17
+ * await camera.setCameraEnabled(true); // opens the Gravix camera, publishes its track
18
+ * await camera.setVideoEffectParams({ look: 'glow' });
19
+ * await camera.setVideoEffectEnabled(false); // bypass, the camera keeps running
20
+ * await camera.switchCamera(); // same track, no republish
21
+ * await camera.setCameraEnabled(false); // unpublish + close the camera; on again replays enabled/params
22
+ * ```
23
+ */
24
+
25
+ import type { Room } from 'gravix-rtc';
26
+
27
+ type RoomConnectOptions = NonNullable<Parameters<Room['connect']>[2]>;
28
+ type CameraPublishOptions = NonNullable<
29
+ Parameters<Room['localParticipant']['publishTrack']>[1]
30
+ >;
31
+
32
+ import { LocalVideoTrack, RoomEvent, Track, VideoPreset } from 'gravix-rtc';
33
+ import { Platform } from 'react-native';
34
+ import type { MediaStreamTrack } from 'react-native-webrtc';
35
+
36
+ /**
37
+ * Flutter GravixRoomService's camera publish options: 800 kbps / 24 fps top
38
+ * layer, one 180p rung at 160 kbps / 24 fps, balanced degradation. Only these
39
+ * keys: codec, backup codec etc. stay the Room's publishDefaults.
40
+ */
41
+ export const GRAVIX_CAMERA_PUBLISH_OPTIONS: CameraPublishOptions = {
42
+ simulcast: true,
43
+ videoEncoding: { maxBitrate: 800_000, maxFramerate: 24 },
44
+ degradationPreference: 'balanced',
45
+ videoSimulcastLayers: [new VideoPreset(320, 180, 160_000, 24)],
46
+ };
47
+
48
+ /** The core's track constructor takes the web MediaStreamTrack type; react-native-webrtc's is that object at runtime. */
49
+ type CoreMediaStreamTrack = ConstructorParameters<typeof LocalVideoTrack>[0];
50
+
51
+ // ── the optional effects packages, structurally typed (no import of their types) ──
52
+
53
+ /** The part of `react-native-gravix-effects`' `GravixPackAvailability` this SDK reads. */
54
+ export interface GravixPackAvailabilityLike {
55
+ readonly state: string;
56
+ readonly progress: number;
57
+ readonly code: string | null;
58
+ readonly isReady: boolean;
59
+ }
60
+
61
+ /** The part of `react-native-gravix-effects`' running `GravixCamera` this SDK drives. */
62
+ export interface GravixEffectsCameraLike {
63
+ readonly lens: 'front' | 'back';
64
+ readonly streamSize: { readonly width: number; readonly height: number };
65
+ switchCamera(): Promise<'front' | 'back'>;
66
+ setEnabled(enabled: boolean): Promise<void>;
67
+ setBuiltinLook(name: string): Promise<void>;
68
+ setLookBytes(bytes: string): Promise<string | null>;
69
+ setAdjustments(adjustments: {
70
+ tone?: Record<string, number | null>;
71
+ region?: Record<string, number | null>;
72
+ reshape?: Record<string, number | null>;
73
+ }): Promise<string[]>;
74
+ setLut?(name: string): Promise<void>;
75
+ setLutBytes?(png: string): Promise<void>;
76
+ resetLut?(): Promise<void>;
77
+ clearAdjustments?(): Promise<void>;
78
+ currentValues?(): Promise<unknown>;
79
+ stats(): Promise<Record<string, unknown> | null>;
80
+ stop(): Promise<void>;
81
+ /** The rest of the package's GravixCamera API (overlays, stickers, …). */
82
+ readonly [extra: string]: unknown;
83
+ }
84
+
85
+ /** The part of `react-native-gravix-effects-webrtc`' output this SDK publishes. */
86
+ export interface GravixEffectsOutputLike {
87
+ readonly stream: unknown;
88
+ readonly videoTrack: MediaStreamTrack;
89
+ detach(): Promise<void>;
90
+ }
91
+
92
+ /** The module surface of `react-native-gravix-effects-webrtc` (it re-exports the core package). */
93
+ export interface GravixEffectsModuleLike {
94
+ GravixCamera: {
95
+ readonly isSupported: boolean;
96
+ start(options?: Record<string, unknown>): Promise<GravixEffectsCameraLike>;
97
+ setLicense(token: string | null): Promise<string>;
98
+ licenseStatus(): Promise<string>;
99
+ hasPermission(): Promise<boolean>;
100
+ requestPermission(): Promise<boolean>;
101
+ preload(): Promise<boolean>;
102
+ };
103
+ GravixEffects: {
104
+ availability(): Promise<GravixPackAvailabilityLike>;
105
+ download(options?: {
106
+ onProgress?: (progress: number) => void;
107
+ }): Promise<GravixPackAvailabilityLike>;
108
+ };
109
+ GravixWebRtc: {
110
+ attach(
111
+ camera: GravixEffectsCameraLike,
112
+ options?: { textureFrames?: boolean }
113
+ ): Promise<GravixEffectsOutputLike>;
114
+ };
115
+ }
116
+
117
+ let moduleOverride: GravixEffectsModuleLike | null | undefined;
118
+ let loaded: GravixEffectsModuleLike | null | undefined;
119
+
120
+ function log(msg: string): void {
121
+ // Owner rule: every step logs its reason. One tag so it can be grepped in logcat (ReactNativeJS).
122
+ console.log(`[gravix-beauty] ${msg}`);
123
+ }
124
+
125
+ /**
126
+ * The `react-native-gravix-effects-webrtc` module (it re-exports the whole
127
+ * `react-native-gravix-effects` API: `GravixCamera`, `GravixPreview`,
128
+ * `GravixLooks`, `GravixEffects` …), or null when the app does not have it.
129
+ * Flutter re-exports these from `gravix_rtc`; an optional peer cannot be
130
+ * re-exported statically, so React Native apps reach it here (or import the
131
+ * package directly).
132
+ */
133
+ export function gravixEffects(): GravixEffectsModuleLike | null {
134
+ if (moduleOverride !== undefined) return moduleOverride;
135
+ if (loaded !== undefined) return loaded;
136
+ try {
137
+ // Metro: a require inside try/catch is an optional dependency (allowOptionalDependencies, on by default).
138
+ loaded =
139
+ require('react-native-gravix-effects-webrtc') as GravixEffectsModuleLike;
140
+ } catch (e) {
141
+ const msg = String(e);
142
+ log(
143
+ /Unable to resolve|Cannot find module|Requiring unknown module/.test(msg)
144
+ ? 'react-native-gravix-effects-webrtc is not installed; beauty effects are off'
145
+ : `react-native-gravix-effects-webrtc failed to load (${msg}); beauty effects are off`
146
+ );
147
+ loaded = null;
148
+ }
149
+ return loaded;
150
+ }
151
+
152
+ /** Test seam: replaces the optional package (null = not installed; undefined = back to the real one). */
153
+ export function setGravixEffectsModuleForTesting(
154
+ m: GravixEffectsModuleLike | null | undefined
155
+ ): void {
156
+ moduleOverride = m;
157
+ loaded = undefined;
158
+ }
159
+
160
+ // ── the effect interfaces (Flutter gravix_video_effect.dart) ──
161
+
162
+ export type GravixCameraPosition = 'front' | 'back';
163
+
164
+ /** The local camera track an effect is asked to process. */
165
+ export interface GravixVideoEffectTarget {
166
+ readonly track: LocalVideoTrack;
167
+ }
168
+
169
+ /**
170
+ * A real-time effect on the LOCAL camera. Flutter `GravixVideoEffect`.
171
+ * {@link attach} answers true only when frames of that track really go
172
+ * through the effect (no silent fake success).
173
+ */
174
+ export interface GravixVideoEffect {
175
+ readonly name: string;
176
+ /** The lowest capture frame rate the effect wants (a hint), or undefined. */
177
+ readonly minFps?: number;
178
+ attach(target: GravixVideoEffectTarget): Promise<boolean>;
179
+ detach(): Promise<void>;
180
+ setEnabled(enabled: boolean): Promise<void>;
181
+ setParams(params: Record<string, unknown>): Promise<void>;
182
+ }
183
+
184
+ export interface GravixCameraOpenOptions {
185
+ position: GravixCameraPosition;
186
+ /** Capture frame rate. */
187
+ fps: number;
188
+ /** Short side of the sent picture, px (540 = 540x960). */
189
+ shortSide: number;
190
+ }
191
+
192
+ /**
193
+ * An effect that OWNS the camera and hands the SDK the finished picture as a
194
+ * track (Flutter `GravixCameraEffect`). {@link GravixBeautyEffect} is one.
195
+ */
196
+ export interface GravixCameraEffect extends GravixVideoEffect {
197
+ canOwnCamera(): Promise<boolean>;
198
+ /** Opens the camera with the effect applied; resolves to the WebRTC track to publish. */
199
+ openCamera(options: GravixCameraOpenOptions): Promise<MediaStreamTrack>;
200
+ switchCamera(): Promise<GravixCameraPosition>;
201
+ }
202
+
203
+ function isCameraEffect(
204
+ e: GravixVideoEffect | undefined
205
+ ): e is GravixCameraEffect {
206
+ return (
207
+ !!e &&
208
+ typeof (e as GravixCameraEffect).openCamera === 'function' &&
209
+ typeof (e as GravixCameraEffect).canOwnCamera === 'function'
210
+ );
211
+ }
212
+
213
+ // ── the built-in beauty effect (Flutter gravix_beauty_effect.dart) ──
214
+
215
+ export interface GravixBeautyEffectOptions {
216
+ /** The App ID's effects license token (null = watermarked). */
217
+ licenseToken?: string | null;
218
+ /** Engine frame rate when the room asks for none. Default 30. */
219
+ fps?: number;
220
+ /** See `GravixWebRtc.attach`: true only with a known hardware encoder. Default false (I420). */
221
+ textureFrames?: boolean;
222
+ }
223
+
224
+ /**
225
+ * Real-time beauty effects from Gravix Effects (looks, reshape, makeup,
226
+ * stickers, 3D) as a camera-owning effect. Android only; elsewhere, or when
227
+ * the effects packages are not installed, {@link canOwnCamera} is false and the
228
+ * room opens its normal camera.
229
+ *
230
+ * Parameters ({@link GravixRoomCamera.setVideoEffectParams}): `look` (built-in
231
+ * look name), `lookBytes` (base64 `.gfx`), `tone` / `region` / `reshape`
232
+ * (`Record<string, number | null>`, as `GravixCamera.setAdjustments`).
233
+ */
234
+ export class GravixBeautyEffect implements GravixCameraEffect {
235
+ readonly name = 'gravix-beauty';
236
+ readonly minFps = 24;
237
+ readonly licenseToken: string | null;
238
+ readonly fps: number;
239
+ readonly textureFrames: boolean;
240
+
241
+ private _camera: GravixEffectsCameraLike | null = null;
242
+ private _output: GravixEffectsOutputLike | null = null;
243
+ private _licensed = false;
244
+
245
+ constructor(options: GravixBeautyEffectOptions = {}) {
246
+ this.licenseToken = options.licenseToken ?? null;
247
+ this.fps = options.fps ?? 30;
248
+ this.textureFrames = options.textureFrames ?? false;
249
+ }
250
+
251
+ /** The running Gravix camera while the room's camera is on (for `<GravixPreview camera={...}>`, looks, stats). */
252
+ get camera(): GravixEffectsCameraLike | null {
253
+ return this._camera;
254
+ }
255
+
256
+ /** The published WebRTC track while the camera is on. */
257
+ get track(): MediaStreamTrack | null {
258
+ return this._output?.videoTrack ?? null;
259
+ }
260
+
261
+ /** Whether the effects packages are installed and can run on this platform. */
262
+ static isAvailable(): boolean {
263
+ if (Platform.OS !== 'android') return false;
264
+ const m = gravixEffects();
265
+ try {
266
+ return !!m && m.GravixCamera.isSupported;
267
+ } catch {
268
+ return false;
269
+ }
270
+ }
271
+
272
+ /** The effects pack state (face models; `gravixEffectsPack=models` downloads them on first use). */
273
+ static async availability(): Promise<GravixPackAvailabilityLike | null> {
274
+ if (!GravixBeautyEffect.isAvailable()) return null;
275
+ return gravixEffects()!.GravixEffects.availability();
276
+ }
277
+
278
+ /**
279
+ * Downloads the effects pack if it is not ready (Flutter README: "download the
280
+ * pack when the user opens beauty"). Resolves to the final state; null when
281
+ * the effects packages are not installed.
282
+ */
283
+ static async ensurePack(
284
+ onProgress?: (progress: number) => void
285
+ ): Promise<GravixPackAvailabilityLike | null> {
286
+ if (!GravixBeautyEffect.isAvailable()) return null;
287
+ const fx = gravixEffects()!.GravixEffects;
288
+ const a = await fx.availability();
289
+ if (a.isReady) return a;
290
+ log(`effects pack ${a.state}; downloading`);
291
+ const r = await fx.download({ onProgress });
292
+ log(`effects pack download -> ${r.state}${r.code ? ` (${r.code})` : ''}`);
293
+ return r;
294
+ }
295
+
296
+ /**
297
+ * The effects licence status now (`OK`, `MISSING`, `INVALID_SIGNATURE`,
298
+ * `MALFORMED`, `WRONG_PACKAGE`, `WRONG_CERT`, `EXPIRED`, and after an
299
+ * online check `LIMIT`, `REVOKED`, `UNKNOWN_APP`), or null when the effects
300
+ * packages are not installed. Anything but `OK` draws the watermark; the
301
+ * native SDK renews the token online by itself.
302
+ */
303
+ static async licenseStatus(): Promise<string | null> {
304
+ if (!GravixBeautyEffect.isAvailable()) return null;
305
+ return gravixEffects()!.GravixCamera.licenseStatus();
306
+ }
307
+
308
+ /**
309
+ * Loads the face model and the engine ahead of the first camera open
310
+ * (Flutter `preload`). Safe to call more than once; false where the effect
311
+ * cannot run.
312
+ */
313
+ async preload(): Promise<boolean> {
314
+ if (!(await this.canOwnCamera())) return false;
315
+ try {
316
+ return await gravixEffects()!.GravixCamera.preload();
317
+ } catch (e) {
318
+ log(`preload failed: ${String(e)}`);
319
+ return false;
320
+ }
321
+ }
322
+
323
+ async canOwnCamera(): Promise<boolean> {
324
+ return GravixBeautyEffect.isAvailable();
325
+ }
326
+
327
+ async openCamera(
328
+ options: GravixCameraOpenOptions
329
+ ): Promise<MediaStreamTrack> {
330
+ await this.close();
331
+ const m = gravixEffects();
332
+ if (!m)
333
+ throw new Error(
334
+ 'gravix-beauty: react-native-gravix-effects-webrtc is not installed'
335
+ );
336
+ if (!this._licensed) {
337
+ const status = await m.GravixCamera.setLicense(this.licenseToken);
338
+ log(`license ${status}`);
339
+ this._licensed = true;
340
+ }
341
+ if (!(await m.GravixCamera.requestPermission())) {
342
+ throw new Error('gravix-beauty: camera permission denied');
343
+ }
344
+ const cam = await m.GravixCamera.start({
345
+ lens: options.position,
346
+ fps: options.fps || this.fps,
347
+ streamResolution: options.shortSide,
348
+ });
349
+ try {
350
+ const out = await m.GravixWebRtc.attach(cam, {
351
+ textureFrames: this.textureFrames,
352
+ });
353
+ this._camera = cam;
354
+ this._output = out;
355
+ log(
356
+ `camera open: lens=${options.position} fps=${options.fps} stream=${cam.streamSize.width}x${cam.streamSize.height}`
357
+ );
358
+ return out.videoTrack;
359
+ } catch (e) {
360
+ await cam.stop();
361
+ throw e;
362
+ }
363
+ }
364
+
365
+ async attach(target: GravixVideoEffectTarget): Promise<boolean> {
366
+ const t = this._output?.videoTrack;
367
+ return !!t && target.track.mediaStreamTrack?.id === t.id;
368
+ }
369
+
370
+ detach(): Promise<void> {
371
+ return this.close();
372
+ }
373
+
374
+ async switchCamera(): Promise<GravixCameraPosition> {
375
+ const cam = this._camera;
376
+ if (!cam) throw new Error('gravix-beauty: the camera is not open');
377
+ return cam.switchCamera();
378
+ }
379
+
380
+ async setEnabled(enabled: boolean): Promise<void> {
381
+ await this._camera?.setEnabled(enabled);
382
+ }
383
+
384
+ /**
385
+ * Applies `look` / `lookBytes` (base64 .gfx), then the adjustment groups
386
+ * `tone` / `region` / `reshape` (values absolute, null removes one), then
387
+ * `lut` (built-in name) / `lutBytes` (base64 PNG; null for either resets the
388
+ * LUT). That is the replay order a new camera session needs. Each step runs
389
+ * even if an earlier one fails; the first error is rethrown at the end.
390
+ */
391
+ async setParams(params: Record<string, unknown>): Promise<void> {
392
+ const cam = this._camera;
393
+ if (!cam) return;
394
+ let first: unknown;
395
+ const step = async (f: () => Promise<unknown>) => {
396
+ try {
397
+ await f();
398
+ } catch (e) {
399
+ first ??= e;
400
+ }
401
+ };
402
+ const look = params.look;
403
+ if (typeof look === 'string') await step(() => cam.setBuiltinLook(look));
404
+ const bytes = params.lookBytes;
405
+ if (typeof bytes === 'string') await step(() => cam.setLookBytes(bytes));
406
+ const adj = (v: unknown): Record<string, number | null> | undefined => {
407
+ if (!v || typeof v !== 'object') return undefined;
408
+ const out: Record<string, number | null> = {};
409
+ for (const [k, x] of Object.entries(v as Record<string, unknown>)) {
410
+ if (typeof x === 'number' || x === null) out[k] = x;
411
+ else log(`adjustment "${k}" skipped: not a number`);
412
+ }
413
+ return out;
414
+ };
415
+ const tone = adj(params.tone);
416
+ const region = adj(params.region);
417
+ const reshape = adj(params.reshape);
418
+ if (tone || region || reshape) {
419
+ await step(async () => {
420
+ const warnings = await cam.setAdjustments({ tone, region, reshape });
421
+ if (warnings.length) log(`adjustments: ${warnings.join(', ')}`);
422
+ });
423
+ }
424
+ if ('lut' in params || 'lutBytes' in params) {
425
+ const name = params.lut;
426
+ const png = params.lutBytes;
427
+ if (typeof name === 'string' && cam.setLut)
428
+ await step(() => cam.setLut!(name));
429
+ else if (typeof png === 'string' && cam.setLutBytes)
430
+ await step(() => cam.setLutBytes!(png));
431
+ else if (name == null && png == null && cam.resetLut)
432
+ await step(() => cam.resetLut!());
433
+ else
434
+ log('LUT param skipped: this effects package has no LUT call for it');
435
+ }
436
+ if (first !== undefined) throw first;
437
+ }
438
+
439
+ private async close(): Promise<void> {
440
+ const cam = this._camera;
441
+ const out = this._output;
442
+ this._camera = null;
443
+ this._output = null;
444
+ if (cam) {
445
+ try {
446
+ await cam.stop(); // also detaches the WebRTC output (its stop hook)
447
+ log('camera closed');
448
+ } finally {
449
+ await out?.detach().catch(() => undefined); // normally done by the stop hook
450
+ }
451
+ }
452
+ }
453
+ }
454
+
455
+ const ADJUSTMENT_GROUPS = new Set(['tone', 'region', 'reshape']);
456
+
457
+ /** Merges effect params: later keys win; the adjustment groups merge name by name. @internal */
458
+ export function mergeEffectParams(
459
+ prev: Readonly<Record<string, unknown>> | undefined,
460
+ next: Readonly<Record<string, unknown>>
461
+ ): Record<string, unknown> {
462
+ const out: Record<string, unknown> = { ...(prev ?? {}) };
463
+ for (const [k, v] of Object.entries(next)) {
464
+ const old = out[k];
465
+ if (
466
+ ADJUSTMENT_GROUPS.has(k) &&
467
+ v &&
468
+ typeof v === 'object' &&
469
+ old &&
470
+ typeof old === 'object'
471
+ ) {
472
+ out[k] = { ...(old as object), ...(v as object) };
473
+ } else if (ADJUSTMENT_GROUPS.has(k) && v && typeof v === 'object') {
474
+ out[k] = { ...(v as object) }; // a copy: later changes by the app do not reach the replay
475
+ } else {
476
+ out[k] = v;
477
+ }
478
+ }
479
+ // a new look replaces the other look source
480
+ if ('look' in next && !('lookBytes' in next)) delete out.lookBytes;
481
+ if ('lookBytes' in next && !('look' in next)) delete out.look;
482
+ if ('lut' in next && !('lutBytes' in next)) delete out.lutBytes;
483
+ if ('lutBytes' in next && !('lut' in next)) delete out.lut;
484
+ return out;
485
+ }
486
+
487
+ // ── the lifecycle binding (Flutter GravixVideoEffectBinding) ──
488
+
489
+ /**
490
+ * Drives a {@link GravixVideoEffect} from the camera lifecycle and remembers
491
+ * the app's enabled / params so they are replayed after every attach.
492
+ * @internal exported for tests.
493
+ */
494
+ export class GravixVideoEffectBinding {
495
+ readonly effect: GravixVideoEffect | undefined;
496
+ private _active = false;
497
+ private _enabled = true;
498
+ private _params: Record<string, unknown> | undefined;
499
+ private _target: GravixVideoEffectTarget | undefined;
500
+ private _disposed = false;
501
+ onActiveChanged?: (active: boolean) => void;
502
+
503
+ /** Merge successive setParams maps for the replay (default true); false = Flutter's replace. */
504
+ readonly mergeParams: boolean;
505
+
506
+ constructor(
507
+ effect?: GravixVideoEffect,
508
+ options: { mergeParams?: boolean } = {}
509
+ ) {
510
+ this.effect = effect;
511
+ this.mergeParams = options.mergeParams ?? true;
512
+ }
513
+
514
+ get active(): boolean {
515
+ return this._active;
516
+ }
517
+ get enabled(): boolean {
518
+ return this._enabled;
519
+ }
520
+ get params(): Readonly<Record<string, unknown>> | undefined {
521
+ return this._params;
522
+ }
523
+ get target(): GravixVideoEffectTarget | undefined {
524
+ return this._target;
525
+ }
526
+ get cameraOwner(): GravixCameraEffect | undefined {
527
+ return isCameraEffect(this.effect) ? this.effect : undefined;
528
+ }
529
+
530
+ /** The capture frame rate: `base`, raised to the effect's minFps. */
531
+ captureFps(base: number): number {
532
+ const min = this.effect?.minFps;
533
+ return min != null && min > base ? min : base;
534
+ }
535
+
536
+ private setActive(v: boolean): void {
537
+ if (this._active === v) return;
538
+ this._active = v;
539
+ this.onActiveChanged?.(v);
540
+ }
541
+
542
+ /** The camera track is live (first start or after a flip). Never throws. */
543
+ async onCameraTrack(target: GravixVideoEffectTarget): Promise<boolean> {
544
+ const fx = this.effect;
545
+ if (!fx || this._disposed) return false;
546
+ this._target = target;
547
+ let ok: boolean;
548
+ try {
549
+ ok = await fx.attach(target);
550
+ } catch (e) {
551
+ log(`effect "${fx.name}" attach failed: ${String(e)}`);
552
+ ok = false;
553
+ }
554
+ if (this._disposed) return false;
555
+ if (ok) {
556
+ try {
557
+ if (this._params) await fx.setParams(this._params);
558
+ } catch (e) {
559
+ log(`effect "${fx.name}" params replay failed: ${String(e)}`);
560
+ }
561
+ try {
562
+ await fx.setEnabled(this._enabled);
563
+ } catch (e) {
564
+ log(`effect "${fx.name}" enable replay failed: ${String(e)}`);
565
+ }
566
+ } else {
567
+ log(
568
+ `effect "${fx.name}" is not processing the camera track (attach answered false)`
569
+ );
570
+ }
571
+ this.setActive(ok);
572
+ return ok;
573
+ }
574
+
575
+ /** The camera stopped / the room went away. Never throws. */
576
+ async onCameraStopped(): Promise<void> {
577
+ const fx = this.effect;
578
+ const wasAttached = this._target !== undefined;
579
+ this._target = undefined;
580
+ if (!this._disposed) this.setActive(false);
581
+ if (!fx || !wasAttached) return;
582
+ try {
583
+ await fx.detach();
584
+ } catch (e) {
585
+ log(`effect "${fx.name}" detach failed: ${String(e)}`);
586
+ }
587
+ }
588
+
589
+ async setEnabled(enabled: boolean): Promise<void> {
590
+ this._enabled = enabled;
591
+ if (!this.effect || !this._active) return;
592
+ await this.effect.setEnabled(enabled);
593
+ }
594
+
595
+ /**
596
+ * Remembers `params` for the replay after the next attach and applies them
597
+ * now when the effect is active. With [mergeParams] (default) the replay map
598
+ * is the MERGE of every call (top-level keys; the `tone` / `region` /
599
+ * `reshape` groups name by name), so a look set by one call and sliders set
600
+ * by a later one both come back after a camera off/on. Flutter 0.12.2
601
+ * replaces the map instead (its baseline finding 3); `mergeParams: false`
602
+ * restores that behaviour. Live, only this call's params are applied.
603
+ */
604
+ async setParams(params: Record<string, unknown>): Promise<void> {
605
+ this._params = this.mergeParams
606
+ ? mergeEffectParams(this._params, params)
607
+ : { ...params };
608
+ if (!this.effect || !this._active) return;
609
+ await this.effect.setParams(this.mergeParams ? params : this._params);
610
+ }
611
+
612
+ async dispose(): Promise<void> {
613
+ await this.onCameraStopped();
614
+ this._disposed = true;
615
+ }
616
+ }
617
+
618
+ /** owner.detach() that never rejects (callers promise true / false). */
619
+ async function safeDetach(owner: GravixCameraEffect): Promise<void> {
620
+ try {
621
+ await owner.detach();
622
+ } catch (e) {
623
+ log(`closing the "${owner.name}" camera failed: ${String(e)}`);
624
+ }
625
+ }
626
+
627
+ // ── the room camera (the camera part of Flutter GravixRoomService) ──
628
+
629
+ export interface GravixRoomCameraOptions {
630
+ /** An optional effect; none = the normal camera and no effect code runs. */
631
+ videoEffect?: GravixVideoEffect;
632
+ /** Capture frame rate before the effect's minFps hint. Default 24 (Flutter room). */
633
+ captureFps?: number;
634
+ /** Short side of the captured / sent picture. Default 540 (Flutter `h540_169`). */
635
+ shortSide?: number;
636
+ /** Initial lens. Default front. */
637
+ cameraPosition?: GravixCameraPosition;
638
+ /**
639
+ * Rollback flag. true (default): the params replayed after a camera reopen
640
+ * are the merge of every setVideoEffectParams call. false: only the last
641
+ * call's map (Flutter gravix_rtc 0.12.2 behaviour).
642
+ */
643
+ mergeEffectParams?: boolean;
644
+ /**
645
+ * Rollback flag for {@link GravixRoomCamera.connect}. true (default): the
646
+ * effect opens its camera while the room connects and publishes it as soon
647
+ * as the room is up (Flutter `connect(enableVideo: true)`). false: connect
648
+ * first, then `setCameraEnabled(true)` (the 2026-12-01 morning behaviour).
649
+ */
650
+ openCameraDuringConnect?: boolean;
651
+ /**
652
+ * Publish options for the camera track. Default
653
+ * {@link GRAVIX_CAMERA_PUBLISH_OPTIONS} (Flutter's). Rollback: `{}` = the
654
+ * room's own publishDefaults (the 2026-12-01 morning behaviour, ~950 kbps).
655
+ */
656
+ publishOptions?: CameraPublishOptions;
657
+ }
658
+
659
+ export interface GravixRoomCameraState {
660
+ cameraEnabled: boolean;
661
+ videoEffectActive: boolean;
662
+ cameraPosition: GravixCameraPosition;
663
+ }
664
+
665
+ /**
666
+ * The room's camera with an optional video effect: Flutter
667
+ * `GravixRoomService.setCameraEnabled / switchCamera / setVideoEffectEnabled /
668
+ * setVideoEffectParams / videoEffectActive / cameraPosition`.
669
+ *
670
+ * With a camera-owning effect ({@link GravixBeautyEffect}) the effect opens the
671
+ * camera and this class publishes its track as the room's camera; off =
672
+ * unpublish + the effect closes the camera; on again = a fresh camera with the
673
+ * remembered enabled / params replayed. Without one (or when it cannot own the
674
+ * camera) the core's `localParticipant.setCameraEnabled` runs.
675
+ *
676
+ * Use this instead of `localParticipant.setCameraEnabled` for the camera:
677
+ * calling both opens two cameras.
678
+ */
679
+ export class GravixRoomCamera {
680
+ readonly room: Room;
681
+ private readonly binding: GravixVideoEffectBinding;
682
+ private readonly baseFps: number;
683
+ private readonly shortSide: number;
684
+ private readonly openDuringConnect: boolean;
685
+ private readonly publishOptions: CameraPublishOptions;
686
+ private _cameraEnabled = false;
687
+ private _position: GravixCameraPosition;
688
+ private _ownedTrack: LocalVideoTrack | null = null;
689
+ private _queue: Promise<unknown> = Promise.resolve();
690
+ private _wanted: boolean | undefined;
691
+ private _disposed = false;
692
+ private readonly listeners = new Set<(s: GravixRoomCameraState) => void>();
693
+ private readonly onDisconnected = () => {
694
+ this.serial(() => this.closeAfterLeave()).catch(() => undefined);
695
+ };
696
+ /**
697
+ * The room could not republish the camera after a full reconnect / region
698
+ * move (Flutter LocalTrackRepublishFailedEvent): the camera is off. An
699
+ * unpublish during the reconnect itself is not a loss (the same track is
700
+ * republished), so only this event counts.
701
+ */
702
+ private readonly onRepublishFailed = (info: unknown) => {
703
+ const i = info as { source?: unknown; track?: unknown } | undefined;
704
+ const t = this._ownedTrack;
705
+ if (t && i?.track === t) {
706
+ log('the room could not republish the effect camera; closing the camera');
707
+ this.serial(() => this.closeAfterLeave()).catch(() => undefined);
708
+ return;
709
+ }
710
+ if (!t && i?.source === Track.Source.Camera && this._cameraEnabled) {
711
+ log('the room could not republish the camera; camera off');
712
+ this.serial(async () => {
713
+ this._cameraEnabled = false;
714
+ await this.binding.onCameraStopped();
715
+ this.emit();
716
+ }).catch(() => undefined);
717
+ }
718
+ };
719
+
720
+ constructor(room: Room, options: GravixRoomCameraOptions = {}) {
721
+ this.room = room;
722
+ this.binding = new GravixVideoEffectBinding(options.videoEffect, {
723
+ mergeParams: options.mergeEffectParams,
724
+ });
725
+ this.binding.onActiveChanged = () => this.emit();
726
+ this.baseFps = options.captureFps ?? 24;
727
+ this.shortSide = options.shortSide ?? 540;
728
+ this._position = options.cameraPosition ?? 'front';
729
+ this.openDuringConnect = options.openCameraDuringConnect ?? true;
730
+ this.publishOptions =
731
+ options.publishOptions ?? GRAVIX_CAMERA_PUBLISH_OPTIONS;
732
+ room.on(RoomEvent.Disconnected, this.onDisconnected);
733
+ room.on(RoomEvent.LocalTrackRepublishFailed, this.onRepublishFailed);
734
+ }
735
+
736
+ get videoEffect(): GravixVideoEffect | undefined {
737
+ return this.binding.effect;
738
+ }
739
+ /** True while the effect reports it processes the live camera track. */
740
+ get videoEffectActive(): boolean {
741
+ return this.binding.active;
742
+ }
743
+ get isCameraEnabled(): boolean {
744
+ return this._cameraEnabled;
745
+ }
746
+ get cameraPosition(): GravixCameraPosition {
747
+ return this._position;
748
+ }
749
+ /** The published camera track (effect-owned or normal), if any. */
750
+ get localVideoTrack(): LocalVideoTrack | undefined {
751
+ const t = this.room.localParticipant?.getTrackPublication(
752
+ Track.Source.Camera
753
+ )?.track;
754
+ return t instanceof LocalVideoTrack ? t : undefined;
755
+ }
756
+ get state(): GravixRoomCameraState {
757
+ return {
758
+ cameraEnabled: this._cameraEnabled,
759
+ videoEffectActive: this.binding.active,
760
+ cameraPosition: this._position,
761
+ };
762
+ }
763
+
764
+ /** Subscribe to state changes; returns the unsubscribe function. */
765
+ addListener(listener: (s: GravixRoomCameraState) => void): () => void {
766
+ this.listeners.add(listener);
767
+ return () => this.listeners.delete(listener);
768
+ }
769
+
770
+ private emit(): void {
771
+ const s = this.state;
772
+ for (const l of this.listeners) {
773
+ try {
774
+ l(s);
775
+ } catch {
776
+ /* a listener's error is its own */
777
+ }
778
+ }
779
+ }
780
+
781
+ /** Calls run one after another; each waits for the one before it. */
782
+ private serial<T>(f: () => Promise<T>): Promise<T> {
783
+ const run = this._queue.then(f, f);
784
+ this._queue = run.catch(() => undefined);
785
+ return run;
786
+ }
787
+
788
+ /** Turn [videoEffect] on/off (a bypass; the camera keeps running). Remembered across camera off/on. */
789
+ setVideoEffectEnabled(enabled: boolean): Promise<void> {
790
+ return this.binding.setEnabled(enabled);
791
+ }
792
+
793
+ /** Effect parameters; remembered and replayed after every camera open. */
794
+ setVideoEffectParams(params: Record<string, unknown>): Promise<void> {
795
+ return this.binding.setParams(params);
796
+ }
797
+
798
+ /**
799
+ * Camera on/off. Resolves true when the camera ended up as asked. The newest
800
+ * call decides: a call overtaken by a later one returns without touching the camera.
801
+ */
802
+ setCameraEnabled(enabled: boolean): Promise<boolean> {
803
+ this._wanted = enabled;
804
+ return this.serial(async () => {
805
+ if (this._disposed) return false;
806
+ if (this._wanted !== enabled) return this._cameraEnabled === enabled; // overtaken
807
+ const ok = await this.applyCamera(enabled);
808
+ this.emit();
809
+ return ok;
810
+ });
811
+ }
812
+
813
+ /**
814
+ * Joins the room with the camera on (Flutter `connect(enableVideo: true)`).
815
+ * With an effect that owns the camera, the camera opens while the room
816
+ * connects and is published as soon as it is up; with the normal camera it
817
+ * is turned on right after the connect. The join declares `media: 'video'`
818
+ * unless `options.media` is set, so it never lands on an audio-only region.
819
+ * Rejects when the room does not connect (the camera opened for it is
820
+ * closed); otherwise resolves with the camera result, like
821
+ * {@link setCameraEnabled}.
822
+ */
823
+ async connect(
824
+ url: string,
825
+ token: string,
826
+ options: RoomConnectOptions = {}
827
+ ): Promise<boolean> {
828
+ this._wanted = true; // before any await: a later setCameraEnabled(false) wins
829
+ const opts: RoomConnectOptions = { media: 'video', ...options };
830
+ const owner = this.binding.cameraOwner;
831
+ if (!this.openDuringConnect || !owner || !(await owner.canOwnCamera())) {
832
+ await this.room.connect(url, token, opts);
833
+ if (this._wanted !== true || this._disposed) return this._cameraEnabled; // a newer off wins
834
+ return this.setCameraEnabled(true);
835
+ }
836
+ const connected = this.room.connect(url, token, opts);
837
+ const camera = this.serial(async () => {
838
+ if (this._disposed || this._cameraEnabled) {
839
+ await connected.catch(() => undefined);
840
+ return this._cameraEnabled;
841
+ }
842
+ if (this._wanted !== true) {
843
+ await connected.catch(() => undefined);
844
+ return this._cameraEnabled; // turned off before the camera opened
845
+ }
846
+ const opened = this.openOwnedTrack(owner);
847
+ const [up, track] = await Promise.all([
848
+ connected.then(
849
+ () => true,
850
+ () => false
851
+ ),
852
+ opened,
853
+ ]);
854
+ if (!track) return false; // as setCameraEnabled: no fallback to the normal camera
855
+ if (!up || this._wanted !== true || this._disposed) {
856
+ track.stop();
857
+ await safeDetach(owner);
858
+ return false;
859
+ }
860
+ const ok = await this.publishOwned(owner, track);
861
+ this.emit();
862
+ return ok;
863
+ });
864
+ // settle both: a failed connect rejects only after the camera job closed its camera
865
+ const [c, cam] = await Promise.allSettled([connected, camera]);
866
+ if (c.status === 'rejected') throw c.reason;
867
+ return cam.status === 'fulfilled' ? cam.value : false;
868
+ }
869
+
870
+ private async applyCamera(enabled: boolean): Promise<boolean> {
871
+ const lp = this.room.localParticipant;
872
+ if (!lp) return false;
873
+ const owner = this.binding.cameraOwner;
874
+ if (enabled) {
875
+ // the room dropped the effect track (e.g. republish disabled): reopen, Flutter's
876
+ // ownsTrack check. Only while connected: a reconnect republishes the same track.
877
+ if (
878
+ this._ownedTrack &&
879
+ String(this.room.state) === 'connected' &&
880
+ this.localVideoTrack !== this._ownedTrack
881
+ ) {
882
+ await this.closeAfterLeave();
883
+ }
884
+ if (this._cameraEnabled) return true;
885
+ if (owner && (await owner.canOwnCamera())) {
886
+ return this.openOwned(owner);
887
+ }
888
+ return this.openNormal();
889
+ }
890
+ if (!this._cameraEnabled && !this._ownedTrack) return true;
891
+ if (this._ownedTrack) {
892
+ await this.closeOwned();
893
+ } else {
894
+ try {
895
+ await lp.setCameraEnabled(false);
896
+ } catch (e) {
897
+ log(`camera off failed: ${String(e)}`);
898
+ return false;
899
+ }
900
+ await this.binding.onCameraStopped();
901
+ }
902
+ this._cameraEnabled = false;
903
+ return true;
904
+ }
905
+
906
+ private async openOwned(owner: GravixCameraEffect): Promise<boolean> {
907
+ const track = await this.openOwnedTrack(owner);
908
+ return track ? this.publishOwned(owner, track) : false;
909
+ }
910
+
911
+ /** Opens the effect's camera; null when it could not. */
912
+ private async openOwnedTrack(
913
+ owner: GravixCameraEffect
914
+ ): Promise<LocalVideoTrack | null> {
915
+ try {
916
+ const mst: MediaStreamTrack = await owner.openCamera({
917
+ position: this._position,
918
+ fps: this.binding.captureFps(this.baseFps),
919
+ shortSide: this.shortSide,
920
+ });
921
+ return new LocalVideoTrack(
922
+ mst as unknown as CoreMediaStreamTrack,
923
+ undefined,
924
+ true
925
+ );
926
+ } catch (e) {
927
+ log(`"${owner.name}" could not open the camera: ${String(e)}`);
928
+ await safeDetach(owner);
929
+ return null;
930
+ }
931
+ }
932
+
933
+ private async publishOwned(
934
+ owner: GravixCameraEffect,
935
+ track: LocalVideoTrack
936
+ ): Promise<boolean> {
937
+ try {
938
+ await this.room.localParticipant.publishTrack(track, {
939
+ ...this.publishOptions,
940
+ source: Track.Source.Camera,
941
+ });
942
+ } catch (e) {
943
+ log(`publishing the "${owner.name}" camera failed: ${String(e)}`);
944
+ await safeDetach(owner);
945
+ return false;
946
+ }
947
+ this._ownedTrack = track;
948
+ this._cameraEnabled = true;
949
+ await this.binding.onCameraTrack({ track });
950
+ return true;
951
+ }
952
+
953
+ private async closeOwned(): Promise<void> {
954
+ const track = this._ownedTrack;
955
+ this._ownedTrack = null;
956
+ this._cameraEnabled = false;
957
+ if (track) {
958
+ try {
959
+ await this.room.localParticipant?.unpublishTrack(track, true);
960
+ } catch (e) {
961
+ log(`unpublishing the effect camera failed: ${String(e)}`);
962
+ }
963
+ }
964
+ // onCameraStopped detaches the effect, which closes the effect's camera.
965
+ const owner = this.binding.cameraOwner;
966
+ const hadTarget = this.binding.target !== undefined;
967
+ await this.binding.onCameraStopped();
968
+ if (owner && !hadTarget) await safeDetach(owner); // attach had answered false: still close it
969
+ }
970
+
971
+ private async openNormal(): Promise<boolean> {
972
+ const lp = this.room.localParticipant;
973
+ const fps = this.binding.captureFps(this.baseFps);
974
+ const s = this.shortSide;
975
+ try {
976
+ const pub = await lp.setCameraEnabled(
977
+ true,
978
+ {
979
+ facingMode: this._position === 'front' ? 'user' : 'environment',
980
+ resolution: {
981
+ width: Math.round((s * 16) / 9),
982
+ height: s,
983
+ frameRate: fps,
984
+ },
985
+ },
986
+ this.publishOptions
987
+ );
988
+ if (!pub) return false;
989
+ } catch (e) {
990
+ log(`camera on failed: ${String(e)}`);
991
+ return false;
992
+ }
993
+ this._cameraEnabled = true;
994
+ const t = this.localVideoTrack;
995
+ if (t && this.binding.effect)
996
+ await this.binding.onCameraTrack({ track: t });
997
+ return true;
998
+ }
999
+
1000
+ /** Front <-> back. With the effect owning the camera it flips its own lens (same track, no republish). */
1001
+ switchCamera(): Promise<void> {
1002
+ return this.serial(async () => {
1003
+ const owner = this.binding.cameraOwner;
1004
+ if (owner && this._ownedTrack && this.binding.active) {
1005
+ this._position = await owner.switchCamera();
1006
+ this.emit();
1007
+ return;
1008
+ }
1009
+ // an effect track the effect is not processing: restarting it as a normal camera
1010
+ // would stop it under the open Gravix camera
1011
+ if (this._ownedTrack) return;
1012
+ const t = this.localVideoTrack;
1013
+ if (!t) return;
1014
+ const next: GravixCameraPosition =
1015
+ this._position === 'front' ? 'back' : 'front';
1016
+ await t.restartTrack({
1017
+ facingMode: next === 'front' ? 'user' : 'environment',
1018
+ });
1019
+ this._position = next;
1020
+ if (this.binding.effect) await this.binding.onCameraTrack({ track: t });
1021
+ this.emit();
1022
+ });
1023
+ }
1024
+
1025
+ private async closeAfterLeave(): Promise<void> {
1026
+ const track = this._ownedTrack;
1027
+ this._ownedTrack = null;
1028
+ const wasEnabled = this._cameraEnabled;
1029
+ this._cameraEnabled = false;
1030
+ track?.stop();
1031
+ const owner = this.binding.cameraOwner;
1032
+ const hadTarget = this.binding.target !== undefined;
1033
+ await this.binding.onCameraStopped();
1034
+ if (owner && track && !hadTarget) await safeDetach(owner);
1035
+ if (wasEnabled) this.emit();
1036
+ }
1037
+
1038
+ /** Closes the camera (effect or normal) and stops listening to the room. Call when the screen goes away. */
1039
+ async dispose(): Promise<void> {
1040
+ this.room.off(RoomEvent.Disconnected, this.onDisconnected);
1041
+ this.room.off(RoomEvent.LocalTrackRepublishFailed, this.onRepublishFailed);
1042
+ this._wanted = false;
1043
+ await this.serial(async () => {
1044
+ try {
1045
+ if (this._ownedTrack) await this.closeOwned();
1046
+ else if (this._cameraEnabled)
1047
+ await this.room.localParticipant?.setCameraEnabled(false);
1048
+ } catch (e) {
1049
+ log(`closing the camera on dispose failed: ${String(e)}`);
1050
+ }
1051
+ await this.binding.dispose();
1052
+ this._disposed = true;
1053
+ this._cameraEnabled = false;
1054
+ });
1055
+ this.listeners.clear();
1056
+ }
1057
+ }