shengwang-electron-sdk 4.6.2-rc.1

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 (369) hide show
  1. package/CHANGELOG.md +391 -0
  2. package/LICENSE +21 -0
  3. package/README.md +146 -0
  4. package/gulpfile.js +52 -0
  5. package/js/AgoraSdk.js +54 -0
  6. package/js/Decoder/gpu-utils.js +74 -0
  7. package/js/Decoder/index.js +172 -0
  8. package/js/Private/AgoraBase.js +4292 -0
  9. package/js/Private/AgoraMediaBase.js +1017 -0
  10. package/js/Private/AgoraMediaPlayerTypes.js +320 -0
  11. package/js/Private/IAgoraH265Transcoder.js +36 -0
  12. package/js/Private/IAgoraLog.js +78 -0
  13. package/js/Private/IAgoraMediaEngine.js +32 -0
  14. package/js/Private/IAgoraMediaPlayer.js +16 -0
  15. package/js/Private/IAgoraMediaPlayerSource.js +3 -0
  16. package/js/Private/IAgoraMediaRecorder.js +10 -0
  17. package/js/Private/IAgoraMediaStreamingSource.js +74 -0
  18. package/js/Private/IAgoraMusicContentCenter.js +160 -0
  19. package/js/Private/IAgoraRhythmPlayer.js +62 -0
  20. package/js/Private/IAgoraRtcEngine.js +1042 -0
  21. package/js/Private/IAgoraRtcEngineEx.js +19 -0
  22. package/js/Private/IAgoraSpatialAudio.js +24 -0
  23. package/js/Private/IAudioDeviceManager.js +20 -0
  24. package/js/Private/extension/AgoraBaseExtension.js +3 -0
  25. package/js/Private/extension/AgoraMediaBaseExtension.js +2 -0
  26. package/js/Private/extension/AgoraMediaPlayerTypesExtension.js +2 -0
  27. package/js/Private/extension/IAgoraH265TranscoderExtension.js +2 -0
  28. package/js/Private/extension/IAgoraLogExtension.js +2 -0
  29. package/js/Private/extension/IAgoraMediaEngineExtension.js +2 -0
  30. package/js/Private/extension/IAgoraMediaPlayerExtension.js +2 -0
  31. package/js/Private/extension/IAgoraMediaPlayerSourceExtension.js +2 -0
  32. package/js/Private/extension/IAgoraMediaRecorderExtension.js +2 -0
  33. package/js/Private/extension/IAgoraMusicContentCenterExtension.js +2 -0
  34. package/js/Private/extension/IAgoraRhythmPlayerExtension.js +2 -0
  35. package/js/Private/extension/IAgoraRtcEngineExExtension.js +2 -0
  36. package/js/Private/extension/IAgoraRtcEngineExtension.js +2 -0
  37. package/js/Private/extension/IAgoraSpatialAudioExtension.js +2 -0
  38. package/js/Private/extension/IAudioDeviceManagerExtension.js +2 -0
  39. package/js/Private/impl/AgoraBaseImpl.js +23 -0
  40. package/js/Private/impl/AgoraMediaBaseImpl.js +149 -0
  41. package/js/Private/impl/IAgoraH265TranscoderImpl.js +116 -0
  42. package/js/Private/impl/IAgoraMediaEngineImpl.js +337 -0
  43. package/js/Private/impl/IAgoraMediaPlayerImpl.js +960 -0
  44. package/js/Private/impl/IAgoraMediaPlayerSourceImpl.js +73 -0
  45. package/js/Private/impl/IAgoraMediaRecorderImpl.js +47 -0
  46. package/js/Private/impl/IAgoraMusicContentCenterImpl.js +422 -0
  47. package/js/Private/impl/IAgoraRtcEngineExImpl.js +1178 -0
  48. package/js/Private/impl/IAgoraRtcEngineImpl.js +5428 -0
  49. package/js/Private/impl/IAgoraSpatialAudioImpl.js +358 -0
  50. package/js/Private/impl/IAudioDeviceManagerImpl.js +375 -0
  51. package/js/Private/internal/AgoraH265TranscoderInternal.js +62 -0
  52. package/js/Private/internal/AgoraMediaBaseInternal.js +15 -0
  53. package/js/Private/internal/AudioDeviceManagerInternal.js +44 -0
  54. package/js/Private/internal/IrisApiEngine.js +451 -0
  55. package/js/Private/internal/LocalSpatialAudioEngineInternal.js +7 -0
  56. package/js/Private/internal/MediaEngineInternal.js +122 -0
  57. package/js/Private/internal/MediaPlayerInternal.js +194 -0
  58. package/js/Private/internal/MediaRecorderInternal.js +70 -0
  59. package/js/Private/internal/MusicContentCenterInternal.js +139 -0
  60. package/js/Private/internal/RtcEngineExInternal.js +488 -0
  61. package/js/Private/ipc/main.js +21 -0
  62. package/js/Private/ipc/renderer.js +21 -0
  63. package/js/Private/ti/AgoraBase-ti.js +40 -0
  64. package/js/Private/ti/AgoraMediaBase-ti.js +75 -0
  65. package/js/Private/ti/AgoraMediaPlayerTypes-ti.js +5 -0
  66. package/js/Private/ti/IAgoraH265Transcoder-ti.js +40 -0
  67. package/js/Private/ti/IAgoraLog-ti.js +5 -0
  68. package/js/Private/ti/IAgoraMediaEngine-ti.js +5 -0
  69. package/js/Private/ti/IAgoraMediaPlayer-ti.js +38 -0
  70. package/js/Private/ti/IAgoraMediaPlayerSource-ti.js +50 -0
  71. package/js/Private/ti/IAgoraMediaRecorder-ti.js +5 -0
  72. package/js/Private/ti/IAgoraMediaStreamingSource-ti.js +5 -0
  73. package/js/Private/ti/IAgoraMusicContentCenter-ti.js +42 -0
  74. package/js/Private/ti/IAgoraRhythmPlayer-ti.js +5 -0
  75. package/js/Private/ti/IAgoraRtcEngine-ti.js +144 -0
  76. package/js/Private/ti/IAgoraRtcEngineEx-ti.js +5 -0
  77. package/js/Private/ti/IAgoraSpatialAudio-ti.js +5 -0
  78. package/js/Private/ti/IAudioDeviceManager-ti.js +5 -0
  79. package/js/Renderer/AgoraView.js +178 -0
  80. package/js/Renderer/CapabilityManager.js +99 -0
  81. package/js/Renderer/IRenderer.js +139 -0
  82. package/js/Renderer/IRendererCache.js +91 -0
  83. package/js/Renderer/RendererCache.js +252 -0
  84. package/js/Renderer/RendererManager.js +250 -0
  85. package/js/Renderer/WebCodecsRenderer/index.js +109 -0
  86. package/js/Renderer/WebCodecsRendererCache.js +127 -0
  87. package/js/Renderer/WebGLRenderer/index.js +467 -0
  88. package/js/Renderer/WebGLRenderer/webgl-utils.js +1337 -0
  89. package/js/Renderer/YUVCanvasRenderer/index.js +53 -0
  90. package/js/Renderer/index.js +17 -0
  91. package/js/Types.js +67 -0
  92. package/js/Utils.js +187 -0
  93. package/package.json +168 -0
  94. package/scripts/bootstrap.js +29 -0
  95. package/scripts/build.js +37 -0
  96. package/scripts/buildJS.js +14 -0
  97. package/scripts/checkElectron.js +43 -0
  98. package/scripts/clean.js +16 -0
  99. package/scripts/download.js +102 -0
  100. package/scripts/downloadPrebuild.js +199 -0
  101. package/scripts/getConfig.js +73 -0
  102. package/scripts/logger.js +32 -0
  103. package/scripts/synclib.js +69 -0
  104. package/scripts/util.js +47 -0
  105. package/scripts/zipBuild.js +40 -0
  106. package/ts/AgoraSdk.ts +44 -0
  107. package/ts/Decoder/gpu-utils.ts +92 -0
  108. package/ts/Decoder/index.ts +210 -0
  109. package/ts/Private/AgoraBase.ts +5941 -0
  110. package/ts/Private/AgoraMediaBase.ts +1814 -0
  111. package/ts/Private/AgoraMediaPlayerTypes.ts +467 -0
  112. package/ts/Private/IAgoraH265Transcoder.ts +73 -0
  113. package/ts/Private/IAgoraLog.ts +93 -0
  114. package/ts/Private/IAgoraMediaEngine.ts +321 -0
  115. package/ts/Private/IAgoraMediaPlayer.ts +759 -0
  116. package/ts/Private/IAgoraMediaPlayerSource.ts +137 -0
  117. package/ts/Private/IAgoraMediaRecorder.ts +65 -0
  118. package/ts/Private/IAgoraMediaStreamingSource.ts +81 -0
  119. package/ts/Private/IAgoraMusicContentCenter.ts +676 -0
  120. package/ts/Private/IAgoraRhythmPlayer.ts +67 -0
  121. package/ts/Private/IAgoraRtcEngine.ts +7909 -0
  122. package/ts/Private/IAgoraRtcEngineEx.ts +1138 -0
  123. package/ts/Private/IAgoraSpatialAudio.ts +248 -0
  124. package/ts/Private/IAudioDeviceManager.ts +351 -0
  125. package/ts/Private/extension/AgoraBaseExtension.ts +14 -0
  126. package/ts/Private/extension/AgoraMediaBaseExtension.ts +1 -0
  127. package/ts/Private/extension/AgoraMediaPlayerTypesExtension.ts +1 -0
  128. package/ts/Private/extension/IAgoraH265TranscoderExtension.ts +39 -0
  129. package/ts/Private/extension/IAgoraLogExtension.ts +1 -0
  130. package/ts/Private/extension/IAgoraMediaEngineExtension.ts +62 -0
  131. package/ts/Private/extension/IAgoraMediaPlayerExtension.ts +64 -0
  132. package/ts/Private/extension/IAgoraMediaPlayerSourceExtension.ts +1 -0
  133. package/ts/Private/extension/IAgoraMediaRecorderExtension.ts +59 -0
  134. package/ts/Private/extension/IAgoraMusicContentCenterExtension.ts +34 -0
  135. package/ts/Private/extension/IAgoraRhythmPlayerExtension.ts +1 -0
  136. package/ts/Private/extension/IAgoraRtcEngineExExtension.ts +1 -0
  137. package/ts/Private/extension/IAgoraRtcEngineExtension.ts +64 -0
  138. package/ts/Private/extension/IAgoraSpatialAudioExtension.ts +1 -0
  139. package/ts/Private/extension/IAudioDeviceManagerExtension.ts +1 -0
  140. package/ts/Private/impl/AgoraBaseImpl.ts +39 -0
  141. package/ts/Private/impl/AgoraMediaBaseImpl.ts +238 -0
  142. package/ts/Private/impl/IAgoraH265TranscoderImpl.ts +152 -0
  143. package/ts/Private/impl/IAgoraMediaEngineImpl.ts +491 -0
  144. package/ts/Private/impl/IAgoraMediaPlayerImpl.ts +1181 -0
  145. package/ts/Private/impl/IAgoraMediaPlayerSourceImpl.ts +94 -0
  146. package/ts/Private/impl/IAgoraMediaRecorderImpl.ts +59 -0
  147. package/ts/Private/impl/IAgoraMusicContentCenterImpl.ts +562 -0
  148. package/ts/Private/impl/IAgoraRtcEngineExImpl.ts +1912 -0
  149. package/ts/Private/impl/IAgoraRtcEngineImpl.ts +7738 -0
  150. package/ts/Private/impl/IAgoraSpatialAudioImpl.ts +495 -0
  151. package/ts/Private/impl/IAudioDeviceManagerImpl.ts +443 -0
  152. package/ts/Private/internal/AgoraH265TranscoderInternal.ts +97 -0
  153. package/ts/Private/internal/AgoraMediaBaseInternal.ts +15 -0
  154. package/ts/Private/internal/AudioDeviceManagerInternal.ts +46 -0
  155. package/ts/Private/internal/IrisApiEngine.ts +627 -0
  156. package/ts/Private/internal/LocalSpatialAudioEngineInternal.ts +3 -0
  157. package/ts/Private/internal/MediaEngineInternal.ts +190 -0
  158. package/ts/Private/internal/MediaPlayerInternal.ts +311 -0
  159. package/ts/Private/internal/MediaRecorderInternal.ts +100 -0
  160. package/ts/Private/internal/MusicContentCenterInternal.ts +208 -0
  161. package/ts/Private/internal/RtcEngineExInternal.ts +720 -0
  162. package/ts/Private/ipc/main.ts +22 -0
  163. package/ts/Private/ipc/renderer.ts +21 -0
  164. package/ts/Private/ti/AgoraBase-ti.ts +16 -0
  165. package/ts/Private/ti/AgoraMediaBase-ti.ts +58 -0
  166. package/ts/Private/ti/AgoraMediaPlayerTypes-ti.ts +11 -0
  167. package/ts/Private/ti/IAgoraH265Transcoder-ti.ts +16 -0
  168. package/ts/Private/ti/IAgoraLog-ti.ts +11 -0
  169. package/ts/Private/ti/IAgoraMediaEngine-ti.ts +11 -0
  170. package/ts/Private/ti/IAgoraMediaPlayer-ti.ts +14 -0
  171. package/ts/Private/ti/IAgoraMediaPlayerSource-ti.ts +26 -0
  172. package/ts/Private/ti/IAgoraMediaRecorder-ti.ts +11 -0
  173. package/ts/Private/ti/IAgoraMediaStreamingSource-ti.ts +11 -0
  174. package/ts/Private/ti/IAgoraMusicContentCenter-ti.ts +18 -0
  175. package/ts/Private/ti/IAgoraRhythmPlayer-ti.ts +11 -0
  176. package/ts/Private/ti/IAgoraRtcEngine-ti.ts +122 -0
  177. package/ts/Private/ti/IAgoraRtcEngineEx-ti.ts +11 -0
  178. package/ts/Private/ti/IAgoraSpatialAudio-ti.ts +11 -0
  179. package/ts/Private/ti/IAudioDeviceManager-ti.ts +11 -0
  180. package/ts/Renderer/AgoraView.ts +264 -0
  181. package/ts/Renderer/CapabilityManager.ts +126 -0
  182. package/ts/Renderer/IRenderer.ts +163 -0
  183. package/ts/Renderer/IRendererCache.ts +130 -0
  184. package/ts/Renderer/RendererCache.ts +323 -0
  185. package/ts/Renderer/RendererManager.ts +322 -0
  186. package/ts/Renderer/WebCodecsRenderer/index.ts +148 -0
  187. package/ts/Renderer/WebCodecsRendererCache.ts +153 -0
  188. package/ts/Renderer/WebGLRenderer/index.ts +695 -0
  189. package/ts/Renderer/WebGLRenderer/webgl-utils.js +1510 -0
  190. package/ts/Renderer/YUVCanvasRenderer/index.ts +80 -0
  191. package/ts/Renderer/index.ts +1 -0
  192. package/ts/Types.ts +254 -0
  193. package/ts/Utils.ts +198 -0
  194. package/types/AgoraSdk.d.ts +30 -0
  195. package/types/AgoraSdk.d.ts.map +1 -0
  196. package/types/Decoder/gpu-utils.d.ts +21 -0
  197. package/types/Decoder/gpu-utils.d.ts.map +1 -0
  198. package/types/Decoder/index.d.ts +26 -0
  199. package/types/Decoder/index.d.ts.map +1 -0
  200. package/types/Private/AgoraBase.d.ts +5728 -0
  201. package/types/Private/AgoraBase.d.ts.map +1 -0
  202. package/types/Private/AgoraMediaBase.d.ts +1717 -0
  203. package/types/Private/AgoraMediaBase.d.ts.map +1 -0
  204. package/types/Private/AgoraMediaPlayerTypes.d.ts +456 -0
  205. package/types/Private/AgoraMediaPlayerTypes.d.ts.map +1 -0
  206. package/types/Private/IAgoraH265Transcoder.d.ts +28 -0
  207. package/types/Private/IAgoraH265Transcoder.d.ts.map +1 -0
  208. package/types/Private/IAgoraLog.d.ts +91 -0
  209. package/types/Private/IAgoraLog.d.ts.map +1 -0
  210. package/types/Private/IAgoraMediaEngine.d.ts +255 -0
  211. package/types/Private/IAgoraMediaEngine.d.ts.map +1 -0
  212. package/types/Private/IAgoraMediaPlayer.d.ts +662 -0
  213. package/types/Private/IAgoraMediaPlayer.d.ts.map +1 -0
  214. package/types/Private/IAgoraMediaPlayerSource.d.ts +109 -0
  215. package/types/Private/IAgoraMediaPlayerSource.d.ts.map +1 -0
  216. package/types/Private/IAgoraMediaRecorder.d.ts +60 -0
  217. package/types/Private/IAgoraMediaRecorder.d.ts.map +1 -0
  218. package/types/Private/IAgoraMediaStreamingSource.d.ts +42 -0
  219. package/types/Private/IAgoraMediaStreamingSource.d.ts.map +1 -0
  220. package/types/Private/IAgoraMusicContentCenter.d.ts +602 -0
  221. package/types/Private/IAgoraMusicContentCenter.d.ts.map +1 -0
  222. package/types/Private/IAgoraRhythmPlayer.d.ts +65 -0
  223. package/types/Private/IAgoraRhythmPlayer.d.ts.map +1 -0
  224. package/types/Private/IAgoraRtcEngine.d.ts +6640 -0
  225. package/types/Private/IAgoraRtcEngine.d.ts.map +1 -0
  226. package/types/Private/IAgoraRtcEngineEx.d.ts +847 -0
  227. package/types/Private/IAgoraRtcEngineEx.d.ts.map +1 -0
  228. package/types/Private/IAgoraSpatialAudio.d.ts +194 -0
  229. package/types/Private/IAgoraSpatialAudio.d.ts.map +1 -0
  230. package/types/Private/IAudioDeviceManager.d.ts +321 -0
  231. package/types/Private/IAudioDeviceManager.d.ts.map +1 -0
  232. package/types/Private/extension/AgoraBaseExtension.d.ts +14 -0
  233. package/types/Private/extension/AgoraBaseExtension.d.ts.map +1 -0
  234. package/types/Private/extension/AgoraMediaBaseExtension.d.ts +2 -0
  235. package/types/Private/extension/AgoraMediaBaseExtension.d.ts.map +1 -0
  236. package/types/Private/extension/AgoraMediaPlayerTypesExtension.d.ts +2 -0
  237. package/types/Private/extension/AgoraMediaPlayerTypesExtension.d.ts.map +1 -0
  238. package/types/Private/extension/IAgoraH265TranscoderExtension.d.ts +24 -0
  239. package/types/Private/extension/IAgoraH265TranscoderExtension.d.ts.map +1 -0
  240. package/types/Private/extension/IAgoraLogExtension.d.ts +2 -0
  241. package/types/Private/extension/IAgoraLogExtension.d.ts.map +1 -0
  242. package/types/Private/extension/IAgoraMediaEngineExtension.d.ts +40 -0
  243. package/types/Private/extension/IAgoraMediaEngineExtension.d.ts.map +1 -0
  244. package/types/Private/extension/IAgoraMediaPlayerExtension.d.ts +46 -0
  245. package/types/Private/extension/IAgoraMediaPlayerExtension.d.ts.map +1 -0
  246. package/types/Private/extension/IAgoraMediaPlayerSourceExtension.d.ts +2 -0
  247. package/types/Private/extension/IAgoraMediaPlayerSourceExtension.d.ts.map +1 -0
  248. package/types/Private/extension/IAgoraMediaRecorderExtension.d.ts +44 -0
  249. package/types/Private/extension/IAgoraMediaRecorderExtension.d.ts.map +1 -0
  250. package/types/Private/extension/IAgoraMusicContentCenterExtension.d.ts +20 -0
  251. package/types/Private/extension/IAgoraMusicContentCenterExtension.d.ts.map +1 -0
  252. package/types/Private/extension/IAgoraRhythmPlayerExtension.d.ts +2 -0
  253. package/types/Private/extension/IAgoraRhythmPlayerExtension.d.ts.map +1 -0
  254. package/types/Private/extension/IAgoraRtcEngineExExtension.d.ts +2 -0
  255. package/types/Private/extension/IAgoraRtcEngineExExtension.d.ts.map +1 -0
  256. package/types/Private/extension/IAgoraRtcEngineExtension.d.ts +42 -0
  257. package/types/Private/extension/IAgoraRtcEngineExtension.d.ts.map +1 -0
  258. package/types/Private/extension/IAgoraSpatialAudioExtension.d.ts +2 -0
  259. package/types/Private/extension/IAgoraSpatialAudioExtension.d.ts.map +1 -0
  260. package/types/Private/extension/IAudioDeviceManagerExtension.d.ts +2 -0
  261. package/types/Private/extension/IAudioDeviceManagerExtension.d.ts.map +1 -0
  262. package/types/Private/impl/AgoraBaseImpl.d.ts +3 -0
  263. package/types/Private/impl/AgoraBaseImpl.d.ts.map +1 -0
  264. package/types/Private/impl/AgoraMediaBaseImpl.d.ts +14 -0
  265. package/types/Private/impl/AgoraMediaBaseImpl.d.ts.map +1 -0
  266. package/types/Private/impl/IAgoraH265TranscoderImpl.d.ts +15 -0
  267. package/types/Private/impl/IAgoraH265TranscoderImpl.d.ts.map +1 -0
  268. package/types/Private/impl/IAgoraMediaEngineImpl.d.ts +46 -0
  269. package/types/Private/impl/IAgoraMediaEngineImpl.d.ts.map +1 -0
  270. package/types/Private/impl/IAgoraMediaPlayerImpl.d.ts +145 -0
  271. package/types/Private/impl/IAgoraMediaPlayerImpl.d.ts.map +1 -0
  272. package/types/Private/impl/IAgoraMediaPlayerSourceImpl.d.ts +3 -0
  273. package/types/Private/impl/IAgoraMediaPlayerSourceImpl.d.ts.map +1 -0
  274. package/types/Private/impl/IAgoraMediaRecorderImpl.d.ts +11 -0
  275. package/types/Private/impl/IAgoraMediaRecorderImpl.d.ts.map +1 -0
  276. package/types/Private/impl/IAgoraMusicContentCenterImpl.d.ts +67 -0
  277. package/types/Private/impl/IAgoraMusicContentCenterImpl.d.ts.map +1 -0
  278. package/types/Private/impl/IAgoraRtcEngineExImpl.d.ts +128 -0
  279. package/types/Private/impl/IAgoraRtcEngineExImpl.d.ts.map +1 -0
  280. package/types/Private/impl/IAgoraRtcEngineImpl.d.ts +656 -0
  281. package/types/Private/impl/IAgoraRtcEngineImpl.d.ts.map +1 -0
  282. package/types/Private/impl/IAgoraSpatialAudioImpl.d.ts +47 -0
  283. package/types/Private/impl/IAgoraSpatialAudioImpl.d.ts.map +1 -0
  284. package/types/Private/impl/IAudioDeviceManagerImpl.d.ts +65 -0
  285. package/types/Private/impl/IAudioDeviceManagerImpl.d.ts.map +1 -0
  286. package/types/Private/internal/AgoraH265TranscoderInternal.d.ts +14 -0
  287. package/types/Private/internal/AgoraH265TranscoderInternal.d.ts.map +1 -0
  288. package/types/Private/internal/AgoraMediaBaseInternal.d.ts +8 -0
  289. package/types/Private/internal/AgoraMediaBaseInternal.d.ts.map +1 -0
  290. package/types/Private/internal/AudioDeviceManagerInternal.d.ts +9 -0
  291. package/types/Private/internal/AudioDeviceManagerInternal.d.ts.map +1 -0
  292. package/types/Private/internal/IrisApiEngine.d.ts +69 -0
  293. package/types/Private/internal/IrisApiEngine.d.ts.map +1 -0
  294. package/types/Private/internal/LocalSpatialAudioEngineInternal.d.ts +4 -0
  295. package/types/Private/internal/LocalSpatialAudioEngineInternal.d.ts.map +1 -0
  296. package/types/Private/internal/MediaEngineInternal.d.ts +23 -0
  297. package/types/Private/internal/MediaEngineInternal.d.ts.map +1 -0
  298. package/types/Private/internal/MediaPlayerInternal.d.ts +30 -0
  299. package/types/Private/internal/MediaPlayerInternal.d.ts.map +1 -0
  300. package/types/Private/internal/MediaRecorderInternal.d.ts +16 -0
  301. package/types/Private/internal/MediaRecorderInternal.d.ts.map +1 -0
  302. package/types/Private/internal/MusicContentCenterInternal.d.ts +31 -0
  303. package/types/Private/internal/MusicContentCenterInternal.d.ts.map +1 -0
  304. package/types/Private/internal/RtcEngineExInternal.d.ts +77 -0
  305. package/types/Private/internal/RtcEngineExInternal.d.ts.map +1 -0
  306. package/types/Private/ipc/main.d.ts +2 -0
  307. package/types/Private/ipc/main.d.ts.map +1 -0
  308. package/types/Private/ipc/renderer.d.ts +3 -0
  309. package/types/Private/ipc/renderer.d.ts.map +1 -0
  310. package/types/Private/ti/AgoraBase-ti.d.ts +8 -0
  311. package/types/Private/ti/AgoraBase-ti.d.ts.map +1 -0
  312. package/types/Private/ti/AgoraMediaBase-ti.d.ts +15 -0
  313. package/types/Private/ti/AgoraMediaBase-ti.d.ts.map +1 -0
  314. package/types/Private/ti/AgoraMediaPlayerTypes-ti.d.ts +7 -0
  315. package/types/Private/ti/AgoraMediaPlayerTypes-ti.d.ts.map +1 -0
  316. package/types/Private/ti/IAgoraH265Transcoder-ti.d.ts +8 -0
  317. package/types/Private/ti/IAgoraH265Transcoder-ti.d.ts.map +1 -0
  318. package/types/Private/ti/IAgoraLog-ti.d.ts +7 -0
  319. package/types/Private/ti/IAgoraLog-ti.d.ts.map +1 -0
  320. package/types/Private/ti/IAgoraMediaEngine-ti.d.ts +7 -0
  321. package/types/Private/ti/IAgoraMediaEngine-ti.d.ts.map +1 -0
  322. package/types/Private/ti/IAgoraMediaPlayer-ti.d.ts +8 -0
  323. package/types/Private/ti/IAgoraMediaPlayer-ti.d.ts.map +1 -0
  324. package/types/Private/ti/IAgoraMediaPlayerSource-ti.d.ts +8 -0
  325. package/types/Private/ti/IAgoraMediaPlayerSource-ti.d.ts.map +1 -0
  326. package/types/Private/ti/IAgoraMediaRecorder-ti.d.ts +7 -0
  327. package/types/Private/ti/IAgoraMediaRecorder-ti.d.ts.map +1 -0
  328. package/types/Private/ti/IAgoraMediaStreamingSource-ti.d.ts +7 -0
  329. package/types/Private/ti/IAgoraMediaStreamingSource-ti.d.ts.map +1 -0
  330. package/types/Private/ti/IAgoraMusicContentCenter-ti.d.ts +8 -0
  331. package/types/Private/ti/IAgoraMusicContentCenter-ti.d.ts.map +1 -0
  332. package/types/Private/ti/IAgoraRhythmPlayer-ti.d.ts +7 -0
  333. package/types/Private/ti/IAgoraRhythmPlayer-ti.d.ts.map +1 -0
  334. package/types/Private/ti/IAgoraRtcEngine-ti.d.ts +10 -0
  335. package/types/Private/ti/IAgoraRtcEngine-ti.d.ts.map +1 -0
  336. package/types/Private/ti/IAgoraRtcEngineEx-ti.d.ts +7 -0
  337. package/types/Private/ti/IAgoraRtcEngineEx-ti.d.ts.map +1 -0
  338. package/types/Private/ti/IAgoraSpatialAudio-ti.d.ts +7 -0
  339. package/types/Private/ti/IAgoraSpatialAudio-ti.d.ts.map +1 -0
  340. package/types/Private/ti/IAudioDeviceManager-ti.d.ts +7 -0
  341. package/types/Private/ti/IAudioDeviceManager-ti.d.ts.map +1 -0
  342. package/types/Renderer/AgoraView.d.ts +82 -0
  343. package/types/Renderer/AgoraView.d.ts.map +1 -0
  344. package/types/Renderer/CapabilityManager.d.ts +20 -0
  345. package/types/Renderer/CapabilityManager.d.ts.map +1 -0
  346. package/types/Renderer/IRenderer.d.ts +20 -0
  347. package/types/Renderer/IRenderer.d.ts.map +1 -0
  348. package/types/Renderer/IRendererCache.d.ts +47 -0
  349. package/types/Renderer/IRendererCache.d.ts.map +1 -0
  350. package/types/Renderer/RendererCache.d.ts +51 -0
  351. package/types/Renderer/RendererCache.d.ts.map +1 -0
  352. package/types/Renderer/RendererManager.d.ts +53 -0
  353. package/types/Renderer/RendererManager.d.ts.map +1 -0
  354. package/types/Renderer/WebCodecsRenderer/index.d.ts +14 -0
  355. package/types/Renderer/WebCodecsRenderer/index.d.ts.map +1 -0
  356. package/types/Renderer/WebCodecsRendererCache.d.ts +22 -0
  357. package/types/Renderer/WebCodecsRendererCache.d.ts.map +1 -0
  358. package/types/Renderer/WebGLRenderer/index.d.ts +37 -0
  359. package/types/Renderer/WebGLRenderer/index.d.ts.map +1 -0
  360. package/types/Renderer/WebGLRenderer/webgl-utils.d.ts +1 -0
  361. package/types/Renderer/WebGLRenderer/webgl-utils.d.ts.map +1 -0
  362. package/types/Renderer/YUVCanvasRenderer/index.d.ts +10 -0
  363. package/types/Renderer/YUVCanvasRenderer/index.d.ts.map +1 -0
  364. package/types/Renderer/index.d.ts +2 -0
  365. package/types/Renderer/index.d.ts.map +1 -0
  366. package/types/Types.d.ts +182 -0
  367. package/types/Types.d.ts.map +1 -0
  368. package/types/Utils.d.ts +50 -0
  369. package/types/Utils.d.ts.map +1 -0
@@ -0,0 +1,695 @@
1
+ import {
2
+ ColorSpace,
3
+ PrimaryID,
4
+ RangeID,
5
+ VideoFrame,
6
+ } from '../../Private/AgoraMediaBase';
7
+ import { RendererContext, RendererType } from '../../Types';
8
+ import { logWarn } from '../../Utils';
9
+ import { IRenderer } from '../IRenderer';
10
+
11
+ export type WebGLFallback = (renderer: WebGLRenderer, error: Error) => void;
12
+
13
+ const createProgramFromSources =
14
+ require('./webgl-utils').createProgramFromSources;
15
+
16
+ const vertexShaderSource = `
17
+ attribute vec2 a_position;
18
+ attribute vec2 a_texCoord;
19
+ uniform vec2 u_resolution;
20
+ varying vec2 v_texCoord;
21
+ void main() {
22
+ vec2 zeroToOne = a_position / u_resolution;
23
+ vec2 zeroToTwo = zeroToOne * 2.0;
24
+ vec2 clipSpace = zeroToTwo - 1.0;
25
+ gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1);
26
+ v_texCoord = a_texCoord;
27
+ }`;
28
+
29
+ const yuvShaderSource = `
30
+ precision mediump float;
31
+ uniform sampler2D Ytex;
32
+ uniform sampler2D Utex;
33
+ uniform sampler2D Vtex;
34
+ uniform sampler2D Atex;
35
+ uniform bool hasAlpha;
36
+
37
+ // Dynamic color space conversion parameters
38
+ uniform float u_yOffset;
39
+ uniform float u_yScale;
40
+ uniform float u_rVCoeff;
41
+ uniform float u_gUCoeff;
42
+ uniform float u_gVCoeff;
43
+ uniform float u_bUCoeff;
44
+
45
+ varying vec2 v_texCoord;
46
+
47
+ void main(void) {
48
+ float nx = v_texCoord[0];
49
+ float ny = v_texCoord[1];
50
+
51
+ float y = texture2D(Ytex, vec2(nx, ny)).r;
52
+ float u = texture2D(Utex, vec2(nx, ny)).r;
53
+ float v = texture2D(Vtex, vec2(nx, ny)).r;
54
+ float a;
55
+
56
+ if (hasAlpha) {
57
+ a = texture2D(Atex, vec2(nx, ny)).r;
58
+ } else {
59
+ a = 1.0;
60
+ }
61
+
62
+ // Apply dynamic color space conversion
63
+ y = u_yScale * (y - u_yOffset);
64
+ u = u - 0.5;
65
+ v = v - 0.5;
66
+
67
+ float r = y + u_rVCoeff * v;
68
+ float g = y + u_gUCoeff * u + u_gVCoeff * v;
69
+ float b = y + u_bUCoeff * u;
70
+
71
+ gl_FragColor = vec4(r, g, b, a);
72
+ }`;
73
+
74
+ // Color space conversion coefficients
75
+ interface ColorSpaceParams {
76
+ yOffset: number;
77
+ yScale: number;
78
+ rVCoeff: number;
79
+ gUCoeff: number;
80
+ gVCoeff: number;
81
+ bUCoeff: number;
82
+ }
83
+
84
+ export class WebGLRenderer extends IRenderer {
85
+ gl: WebGLRenderingContext | WebGL2RenderingContext | null;
86
+ program: WebGLProgram | null;
87
+ positionLocation?: number;
88
+ texCoordLocation?: number;
89
+ yTexture: WebGLTexture | null;
90
+ uTexture: WebGLTexture | null;
91
+ vTexture: WebGLTexture | null;
92
+ aTexture: WebGLTexture | null;
93
+ hasAlpha: WebGLUniformLocation | null;
94
+ texCoordBuffer: WebGLBuffer | null;
95
+ surfaceBuffer: WebGLBuffer | null;
96
+ fallback?: WebGLFallback;
97
+
98
+ // Color space uniform locations
99
+ private colorSpaceUniforms: {
100
+ yOffset?: WebGLUniformLocation | null;
101
+ yScale?: WebGLUniformLocation | null;
102
+ rVCoeff?: WebGLUniformLocation | null;
103
+ gUCoeff?: WebGLUniformLocation | null;
104
+ gVCoeff?: WebGLUniformLocation | null;
105
+ bUCoeff?: WebGLUniformLocation | null;
106
+ } = {};
107
+
108
+ constructor(fallback?: WebGLFallback) {
109
+ super();
110
+ this.gl = null;
111
+ this.rendererType = RendererType.WEBGL;
112
+ this.program = null;
113
+ this.yTexture = null;
114
+ this.uTexture = null;
115
+ this.vTexture = null;
116
+ this.aTexture = null;
117
+ this.hasAlpha = null;
118
+ this.texCoordBuffer = null;
119
+ this.surfaceBuffer = null;
120
+ this.fallback = fallback;
121
+ }
122
+
123
+ public override bind(context: RendererContext) {
124
+ super.bind(context);
125
+
126
+ this.canvas?.addEventListener(
127
+ 'webglcontextlost',
128
+ this.handleContextLost,
129
+ false
130
+ );
131
+ this.canvas?.addEventListener(
132
+ 'webglcontextrestored',
133
+ this.handleContextRestored,
134
+ false
135
+ );
136
+
137
+ const getContext = (
138
+ contextNames = ['webgl2', 'webgl', 'experimental-webgl']
139
+ ): WebGLRenderingContext | WebGLRenderingContext | null => {
140
+ for (let i = 0; i < contextNames.length; i++) {
141
+ const contextName = contextNames[i]!;
142
+ const canvasContext = this.canvas?.getContext(contextName, {
143
+ depth: true,
144
+ stencil: true,
145
+ alpha: context.enableAlphaMask,
146
+ antialias: false,
147
+ premultipliedAlpha: true,
148
+ preserveDrawingBuffer: !context.enableAlphaMask,
149
+ powerPreference: 'default',
150
+ failIfMajorPerformanceCaveat: false,
151
+ });
152
+ if (canvasContext) {
153
+ return canvasContext as WebGLRenderingContext | WebGLRenderingContext;
154
+ }
155
+ }
156
+ return null;
157
+ };
158
+ this.gl ??= getContext();
159
+
160
+ if (!this.gl) {
161
+ this.fallback?.call(
162
+ null,
163
+ this,
164
+ new Error('Browser not support! No WebGL detected.')
165
+ );
166
+ return;
167
+ }
168
+
169
+ // Set clear color to black, fully opaque
170
+ this.gl.clearColor(0.0, 0.0, 0.0, 0.0);
171
+ // Enable depth testing
172
+ this.gl.enable(this.gl.DEPTH_TEST);
173
+ // Near things obscure far things
174
+ this.gl.depthFunc(this.gl.LEQUAL);
175
+ // Enable blending
176
+ this.gl.enable(this.gl.BLEND);
177
+ // Set blending function
178
+ this.gl.blendFunc(this.gl.SRC_ALPHA, this.gl.ONE_MINUS_SRC_ALPHA);
179
+ // Clear the color as well as the depth buffer.
180
+ this.gl.clear(
181
+ this.gl.COLOR_BUFFER_BIT |
182
+ this.gl.DEPTH_BUFFER_BIT |
183
+ this.gl.STENCIL_BUFFER_BIT
184
+ );
185
+
186
+ // Setup GLSL program
187
+ this.program = createProgramFromSources(this.gl, [
188
+ vertexShaderSource,
189
+ yuvShaderSource,
190
+ ]) as WebGLProgram;
191
+ this.gl.useProgram(this.program);
192
+
193
+ this.initTextures();
194
+ }
195
+
196
+ public override unbind() {
197
+ this.canvas?.removeEventListener(
198
+ 'webglcontextlost',
199
+ this.handleContextLost,
200
+ false
201
+ );
202
+ this.canvas?.removeEventListener(
203
+ 'webglcontextrestored',
204
+ this.handleContextRestored,
205
+ false
206
+ );
207
+
208
+ this.releaseTextures();
209
+ this.gl = null;
210
+
211
+ super.unbind();
212
+ }
213
+
214
+ public override drawFrame(
215
+ uid: number,
216
+ {
217
+ width,
218
+ height,
219
+ yStride,
220
+ uStride,
221
+ vStride,
222
+ yBuffer,
223
+ uBuffer,
224
+ vBuffer,
225
+ rotation,
226
+ alphaBuffer,
227
+ colorSpace,
228
+ }: VideoFrame
229
+ ) {
230
+ this.rotateCanvas({ width, height, rotation });
231
+ this.updateRenderMode();
232
+
233
+ if (!this.gl || !this.program) return;
234
+
235
+ // Set color space conversion parameters based on frame properties
236
+ this.setColorSpaceUniforms(colorSpace);
237
+
238
+ const left = 0,
239
+ top = 0,
240
+ right = yStride! - width!,
241
+ bottom = 0;
242
+
243
+ this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.texCoordBuffer);
244
+ const xWidth = width! + left + right;
245
+ const xHeight = height! + top + bottom;
246
+ this.gl.bufferData(
247
+ this.gl.ARRAY_BUFFER,
248
+ new Float32Array([
249
+ left / xWidth,
250
+ bottom / xHeight,
251
+ 1 - right / xWidth,
252
+ bottom / xHeight,
253
+ left / xWidth,
254
+ 1 - top / xHeight,
255
+ left / xWidth,
256
+ 1 - top / xHeight,
257
+ 1 - right / xWidth,
258
+ bottom / xHeight,
259
+ 1 - right / xWidth,
260
+ 1 - top / xHeight,
261
+ ]),
262
+ this.gl.STATIC_DRAW
263
+ );
264
+ this.gl.enableVertexAttribArray(this.texCoordLocation!);
265
+ this.gl.vertexAttribPointer(
266
+ this.texCoordLocation!,
267
+ 2,
268
+ this.gl.FLOAT,
269
+ false,
270
+ 0,
271
+ 0
272
+ );
273
+
274
+ this.gl.pixelStorei(this.gl.UNPACK_ALIGNMENT, 1);
275
+
276
+ type TextureInfo = {
277
+ texture: WebGLTexture | null;
278
+ stride: number;
279
+ height: number;
280
+ pixels: ArrayBufferView | null;
281
+ };
282
+
283
+ const activeTexture = (
284
+ textureIndex: number,
285
+ { texture, stride, height, pixels }: TextureInfo
286
+ ) => {
287
+ if (!this.gl) return;
288
+
289
+ this.gl.activeTexture(textureIndex);
290
+ this.gl.bindTexture(this.gl.TEXTURE_2D, texture);
291
+ this.gl.texImage2D(
292
+ this.gl.TEXTURE_2D,
293
+ 0,
294
+ this.gl.LUMINANCE,
295
+ stride,
296
+ height,
297
+ 0,
298
+ this.gl.LUMINANCE,
299
+ this.gl.UNSIGNED_BYTE,
300
+ pixels
301
+ );
302
+ };
303
+
304
+ const textures: Record<number, TextureInfo> = {
305
+ [this.gl.TEXTURE0]: {
306
+ texture: this.yTexture,
307
+ stride: yStride!,
308
+ height: height!,
309
+ pixels: yBuffer!,
310
+ },
311
+ [this.gl.TEXTURE1]: {
312
+ texture: this.uTexture,
313
+ stride: uStride!,
314
+ height: height! / 2,
315
+ pixels: uBuffer!,
316
+ },
317
+ [this.gl.TEXTURE2]: {
318
+ texture: this.vTexture,
319
+ stride: vStride!,
320
+ height: height! / 2,
321
+ pixels: vBuffer!,
322
+ },
323
+ };
324
+ if (alphaBuffer && alphaBuffer.length > 0 && this.context.enableAlphaMask) {
325
+ textures[this.gl.TEXTURE3] = {
326
+ texture: this.aTexture,
327
+ stride: width!,
328
+ height: height!,
329
+ pixels: alphaBuffer,
330
+ };
331
+ this.gl.uniform1i(this.hasAlpha, 1);
332
+ } else {
333
+ this.gl.uniform1i(this.hasAlpha, 0);
334
+ }
335
+
336
+ for (const textureIndex in textures) {
337
+ if (textures.hasOwnProperty(textureIndex)) {
338
+ activeTexture(+textureIndex, textures[textureIndex]!);
339
+ }
340
+ }
341
+
342
+ this.gl.drawArrays(this.gl.TRIANGLES, 0, 6);
343
+
344
+ super.drawFrame(uid);
345
+ }
346
+
347
+ protected override rotateCanvas({ width, height, rotation }: VideoFrame) {
348
+ super.rotateCanvas({ width, height, rotation });
349
+
350
+ if (!this.gl || !this.program) return;
351
+
352
+ this.gl.viewport(0, 0, width!, height!);
353
+
354
+ this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.surfaceBuffer);
355
+ this.gl.enableVertexAttribArray(this.positionLocation!);
356
+ this.gl.vertexAttribPointer(
357
+ this.positionLocation!,
358
+ 2,
359
+ this.gl.FLOAT,
360
+ false,
361
+ 0,
362
+ 0
363
+ );
364
+
365
+ // 4 vertex, 1(x1,y1), 2(x2,y1), 3(x2,y2), 4(x1,y2)
366
+ // 0: 1,2,4/4,2,3
367
+ // 90: 2,3,1/1,3,4
368
+ // 180: 3,4,2/2,4,1
369
+ // 270: 4,1,3/3,1,2
370
+ const p1 = { x: 0, y: 0 };
371
+ const p2 = { x: width!, y: 0 };
372
+ const p3 = { x: width!, y: height! };
373
+ const p4 = { x: 0, y: height! };
374
+ let pp1 = p1,
375
+ pp2 = p2,
376
+ pp3 = p3,
377
+ pp4 = p4;
378
+
379
+ switch (rotation) {
380
+ case 0:
381
+ break;
382
+ case 90:
383
+ pp1 = p2;
384
+ pp2 = p3;
385
+ pp3 = p4;
386
+ pp4 = p1;
387
+ break;
388
+ case 180:
389
+ pp1 = p3;
390
+ pp2 = p4;
391
+ pp3 = p1;
392
+ pp4 = p2;
393
+ break;
394
+ case 270:
395
+ pp1 = p4;
396
+ pp2 = p1;
397
+ pp3 = p2;
398
+ pp4 = p3;
399
+ break;
400
+ default:
401
+ }
402
+ this.gl.bufferData(
403
+ this.gl.ARRAY_BUFFER,
404
+ new Float32Array([
405
+ pp1.x,
406
+ pp1.y,
407
+ pp2.x,
408
+ pp2.y,
409
+ pp4.x,
410
+ pp4.y,
411
+ pp4.x,
412
+ pp4.y,
413
+ pp2.x,
414
+ pp2.y,
415
+ pp3.x,
416
+ pp3.y,
417
+ ]),
418
+ this.gl.STATIC_DRAW
419
+ );
420
+
421
+ const resolutionLocation = this.gl.getUniformLocation(
422
+ this.program,
423
+ 'u_resolution'
424
+ );
425
+ this.gl.uniform2f(resolutionLocation, width!, height!);
426
+ }
427
+
428
+ private initTextures() {
429
+ if (!this.gl || !this.program) return;
430
+
431
+ this.positionLocation = this.gl.getAttribLocation(
432
+ this.program,
433
+ 'a_position'
434
+ );
435
+ this.texCoordLocation = this.gl.getAttribLocation(
436
+ this.program,
437
+ 'a_texCoord'
438
+ );
439
+
440
+ this.hasAlpha = this.gl.getUniformLocation(this.program, 'hasAlpha');
441
+
442
+ // Get color space uniform locations
443
+ this.colorSpaceUniforms.yOffset = this.gl.getUniformLocation(
444
+ this.program,
445
+ 'u_yOffset'
446
+ );
447
+ this.colorSpaceUniforms.yScale = this.gl.getUniformLocation(
448
+ this.program,
449
+ 'u_yScale'
450
+ );
451
+ this.colorSpaceUniforms.rVCoeff = this.gl.getUniformLocation(
452
+ this.program,
453
+ 'u_rVCoeff'
454
+ );
455
+ this.colorSpaceUniforms.gUCoeff = this.gl.getUniformLocation(
456
+ this.program,
457
+ 'u_gUCoeff'
458
+ );
459
+ this.colorSpaceUniforms.gVCoeff = this.gl.getUniformLocation(
460
+ this.program,
461
+ 'u_gVCoeff'
462
+ );
463
+ this.colorSpaceUniforms.bUCoeff = this.gl.getUniformLocation(
464
+ this.program,
465
+ 'u_bUCoeff'
466
+ );
467
+
468
+ this.surfaceBuffer = this.gl.createBuffer();
469
+ this.texCoordBuffer = this.gl.createBuffer();
470
+
471
+ const createTexture = (
472
+ texture: number,
473
+ textureIndex: number,
474
+ textureName: string
475
+ ) => {
476
+ if (!this.gl || !this.program) return null;
477
+
478
+ // Create a texture.
479
+ this.gl.activeTexture(texture);
480
+ const textureObj = this.gl.createTexture();
481
+ this.gl.bindTexture(this.gl.TEXTURE_2D, textureObj);
482
+ // Set the parameters so we can render any size
483
+ this.gl.texParameteri(
484
+ this.gl.TEXTURE_2D,
485
+ this.gl.TEXTURE_WRAP_S,
486
+ this.gl.CLAMP_TO_EDGE
487
+ );
488
+ this.gl.texParameteri(
489
+ this.gl.TEXTURE_2D,
490
+ this.gl.TEXTURE_WRAP_T,
491
+ this.gl.CLAMP_TO_EDGE
492
+ );
493
+ this.gl.texParameteri(
494
+ this.gl.TEXTURE_2D,
495
+ this.gl.TEXTURE_MIN_FILTER,
496
+ this.gl.NEAREST
497
+ );
498
+ this.gl.texParameteri(
499
+ this.gl.TEXTURE_2D,
500
+ this.gl.TEXTURE_MAG_FILTER,
501
+ this.gl.NEAREST
502
+ );
503
+
504
+ this.gl.uniform1i(
505
+ this.gl.getUniformLocation(this.program, textureName),
506
+ textureIndex
507
+ ); /* Bind Ytex to texture unit index */
508
+ return textureObj;
509
+ };
510
+
511
+ this.yTexture = createTexture(this.gl.TEXTURE0, 0, 'Ytex');
512
+ this.uTexture = createTexture(this.gl.TEXTURE1, 1, 'Utex');
513
+ this.vTexture = createTexture(this.gl.TEXTURE2, 2, 'Vtex');
514
+ this.aTexture = createTexture(this.gl.TEXTURE3, 3, 'Atex');
515
+
516
+ // Set default color space parameters (BT.601 Limited Range)
517
+ this.setColorSpaceUniforms();
518
+ }
519
+
520
+ private releaseTextures() {
521
+ this.gl?.deleteProgram(this.program);
522
+ this.program = null;
523
+
524
+ this.positionLocation = undefined;
525
+ this.texCoordLocation = undefined;
526
+
527
+ this.gl?.deleteTexture(this.yTexture);
528
+ this.gl?.deleteTexture(this.uTexture);
529
+ this.gl?.deleteTexture(this.vTexture);
530
+ this.yTexture = null;
531
+ this.uTexture = null;
532
+ this.vTexture = null;
533
+ this.aTexture = null;
534
+ this.hasAlpha = null;
535
+
536
+ this.gl?.deleteBuffer(this.texCoordBuffer);
537
+ this.gl?.deleteBuffer(this.surfaceBuffer);
538
+ this.texCoordBuffer = null;
539
+ this.surfaceBuffer = null;
540
+ }
541
+
542
+ private handleContextLost = (event: Event) => {
543
+ event.preventDefault();
544
+ logWarn('webglcontextlost', event);
545
+
546
+ this.releaseTextures();
547
+
548
+ this.fallback?.call(
549
+ null,
550
+ this,
551
+ new Error('Browser not support! No WebGL detected.')
552
+ );
553
+ };
554
+
555
+ private handleContextRestored = (event: Event) => {
556
+ event.preventDefault();
557
+ logWarn('webglcontextrestored', event);
558
+
559
+ // Setup GLSL program
560
+ this.program = createProgramFromSources(this.gl, [
561
+ vertexShaderSource,
562
+ yuvShaderSource,
563
+ ]) as WebGLProgram;
564
+ this.gl?.useProgram(this.program);
565
+
566
+ this.initTextures();
567
+ };
568
+
569
+ /**
570
+ * Get color space conversion parameters based on color space and range
571
+ */
572
+ private getColorSpaceParams(colorSpace?: ColorSpace): ColorSpaceParams {
573
+ // Default to BT.601 Limited if not specified
574
+ const primaries = colorSpace?.primaries ?? PrimaryID.PrimaryidBt709;
575
+ const range = colorSpace?.range ?? RangeID.RangeidLimited;
576
+
577
+ // Y offset and scale based on ran
578
+ let yOffset: number;
579
+ let yScale: number;
580
+
581
+ if (range === RangeID.RangeidFull) {
582
+ yOffset = 0.0;
583
+ yScale = 1.0;
584
+ } else {
585
+ // Limited range: Y [16, 235] -> [0, 1]
586
+ yOffset = 16.0 / 255.0; // 0.0625
587
+ yScale = 255.0 / (235.0 - 16.0); // 1.1643
588
+ }
589
+
590
+ // Color space conversion coefficients
591
+ let rVCoeff: number, gUCoeff: number, gVCoeff: number, bUCoeff: number;
592
+
593
+ switch (primaries) {
594
+ case PrimaryID.PrimaryidBt709:
595
+ if (range === RangeID.RangeidFull) {
596
+ // BT.709 Full Range
597
+ rVCoeff = 1.5748;
598
+ gUCoeff = -0.187324;
599
+ gVCoeff = -0.468124;
600
+ bUCoeff = 1.8556;
601
+ } else {
602
+ // BT.709 Limited Range
603
+ rVCoeff = 1.792741;
604
+ gUCoeff = -0.213249;
605
+ gVCoeff = -0.532909;
606
+ bUCoeff = 2.112402;
607
+ }
608
+ break;
609
+
610
+ case PrimaryID.PrimaryidBt2020:
611
+ if (range === RangeID.RangeidFull) {
612
+ // BT.2020 Full Range
613
+ rVCoeff = 1.4746;
614
+ gUCoeff = -0.164553;
615
+ gVCoeff = -0.571353;
616
+ bUCoeff = 1.8814;
617
+ } else {
618
+ // BT.2020 Limited Range
619
+ rVCoeff = 1.678674;
620
+ gUCoeff = -0.187326;
621
+ gVCoeff = -0.650424;
622
+ bUCoeff = 2.141772;
623
+ }
624
+ break;
625
+
626
+ case PrimaryID.PrimaryidSmpte170m || PrimaryID.PrimaryidBt470bg:
627
+ if (range === RangeID.RangeidFull) {
628
+ // BT.601 Full Range
629
+ rVCoeff = 1.402;
630
+ gUCoeff = -0.344136;
631
+ gVCoeff = -0.714136;
632
+ bUCoeff = 1.772;
633
+ } else {
634
+ // BT.601 Limited Range
635
+ rVCoeff = 1.596027;
636
+ gUCoeff = -0.391762;
637
+ gVCoeff = -0.812968;
638
+ bUCoeff = 2.017232;
639
+ }
640
+ break;
641
+ default:
642
+ if (range === RangeID.RangeidFull) {
643
+ // BT.601 Full Range
644
+ rVCoeff = 1.402;
645
+ gUCoeff = -0.344136;
646
+ gVCoeff = -0.714136;
647
+ bUCoeff = 1.772;
648
+ } else {
649
+ // BT.601 Limited Range (your original values)
650
+ rVCoeff = 1.596027;
651
+ gUCoeff = -0.391762;
652
+ gVCoeff = -0.812968;
653
+ bUCoeff = 2.017232;
654
+ }
655
+ break;
656
+ }
657
+
658
+ return {
659
+ yOffset,
660
+ yScale,
661
+ rVCoeff,
662
+ gUCoeff,
663
+ gVCoeff,
664
+ bUCoeff,
665
+ };
666
+ }
667
+
668
+ /**
669
+ * Set color space uniform values in the shader
670
+ */
671
+ private setColorSpaceUniforms(colorSpace?: ColorSpace): void {
672
+ if (!this.gl || !this.program) return;
673
+
674
+ const params = this.getColorSpaceParams(colorSpace);
675
+
676
+ if (this.colorSpaceUniforms.yOffset) {
677
+ this.gl.uniform1f(this.colorSpaceUniforms.yOffset, params.yOffset);
678
+ }
679
+ if (this.colorSpaceUniforms.yScale) {
680
+ this.gl.uniform1f(this.colorSpaceUniforms.yScale, params.yScale);
681
+ }
682
+ if (this.colorSpaceUniforms.rVCoeff) {
683
+ this.gl.uniform1f(this.colorSpaceUniforms.rVCoeff, params.rVCoeff);
684
+ }
685
+ if (this.colorSpaceUniforms.gUCoeff) {
686
+ this.gl.uniform1f(this.colorSpaceUniforms.gUCoeff, params.gUCoeff);
687
+ }
688
+ if (this.colorSpaceUniforms.gVCoeff) {
689
+ this.gl.uniform1f(this.colorSpaceUniforms.gVCoeff, params.gVCoeff);
690
+ }
691
+ if (this.colorSpaceUniforms.bUCoeff) {
692
+ this.gl.uniform1f(this.colorSpaceUniforms.bUCoeff, params.bUCoeff);
693
+ }
694
+ }
695
+ }