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.
- package/CHANGELOG.md +391 -0
- package/LICENSE +21 -0
- package/README.md +146 -0
- package/gulpfile.js +52 -0
- package/js/AgoraSdk.js +54 -0
- package/js/Decoder/gpu-utils.js +74 -0
- package/js/Decoder/index.js +172 -0
- package/js/Private/AgoraBase.js +4292 -0
- package/js/Private/AgoraMediaBase.js +1017 -0
- package/js/Private/AgoraMediaPlayerTypes.js +320 -0
- package/js/Private/IAgoraH265Transcoder.js +36 -0
- package/js/Private/IAgoraLog.js +78 -0
- package/js/Private/IAgoraMediaEngine.js +32 -0
- package/js/Private/IAgoraMediaPlayer.js +16 -0
- package/js/Private/IAgoraMediaPlayerSource.js +3 -0
- package/js/Private/IAgoraMediaRecorder.js +10 -0
- package/js/Private/IAgoraMediaStreamingSource.js +74 -0
- package/js/Private/IAgoraMusicContentCenter.js +160 -0
- package/js/Private/IAgoraRhythmPlayer.js +62 -0
- package/js/Private/IAgoraRtcEngine.js +1042 -0
- package/js/Private/IAgoraRtcEngineEx.js +19 -0
- package/js/Private/IAgoraSpatialAudio.js +24 -0
- package/js/Private/IAudioDeviceManager.js +20 -0
- package/js/Private/extension/AgoraBaseExtension.js +3 -0
- package/js/Private/extension/AgoraMediaBaseExtension.js +2 -0
- package/js/Private/extension/AgoraMediaPlayerTypesExtension.js +2 -0
- package/js/Private/extension/IAgoraH265TranscoderExtension.js +2 -0
- package/js/Private/extension/IAgoraLogExtension.js +2 -0
- package/js/Private/extension/IAgoraMediaEngineExtension.js +2 -0
- package/js/Private/extension/IAgoraMediaPlayerExtension.js +2 -0
- package/js/Private/extension/IAgoraMediaPlayerSourceExtension.js +2 -0
- package/js/Private/extension/IAgoraMediaRecorderExtension.js +2 -0
- package/js/Private/extension/IAgoraMusicContentCenterExtension.js +2 -0
- package/js/Private/extension/IAgoraRhythmPlayerExtension.js +2 -0
- package/js/Private/extension/IAgoraRtcEngineExExtension.js +2 -0
- package/js/Private/extension/IAgoraRtcEngineExtension.js +2 -0
- package/js/Private/extension/IAgoraSpatialAudioExtension.js +2 -0
- package/js/Private/extension/IAudioDeviceManagerExtension.js +2 -0
- package/js/Private/impl/AgoraBaseImpl.js +23 -0
- package/js/Private/impl/AgoraMediaBaseImpl.js +149 -0
- package/js/Private/impl/IAgoraH265TranscoderImpl.js +116 -0
- package/js/Private/impl/IAgoraMediaEngineImpl.js +337 -0
- package/js/Private/impl/IAgoraMediaPlayerImpl.js +960 -0
- package/js/Private/impl/IAgoraMediaPlayerSourceImpl.js +73 -0
- package/js/Private/impl/IAgoraMediaRecorderImpl.js +47 -0
- package/js/Private/impl/IAgoraMusicContentCenterImpl.js +422 -0
- package/js/Private/impl/IAgoraRtcEngineExImpl.js +1178 -0
- package/js/Private/impl/IAgoraRtcEngineImpl.js +5428 -0
- package/js/Private/impl/IAgoraSpatialAudioImpl.js +358 -0
- package/js/Private/impl/IAudioDeviceManagerImpl.js +375 -0
- package/js/Private/internal/AgoraH265TranscoderInternal.js +62 -0
- package/js/Private/internal/AgoraMediaBaseInternal.js +15 -0
- package/js/Private/internal/AudioDeviceManagerInternal.js +44 -0
- package/js/Private/internal/IrisApiEngine.js +451 -0
- package/js/Private/internal/LocalSpatialAudioEngineInternal.js +7 -0
- package/js/Private/internal/MediaEngineInternal.js +122 -0
- package/js/Private/internal/MediaPlayerInternal.js +194 -0
- package/js/Private/internal/MediaRecorderInternal.js +70 -0
- package/js/Private/internal/MusicContentCenterInternal.js +139 -0
- package/js/Private/internal/RtcEngineExInternal.js +488 -0
- package/js/Private/ipc/main.js +21 -0
- package/js/Private/ipc/renderer.js +21 -0
- package/js/Private/ti/AgoraBase-ti.js +40 -0
- package/js/Private/ti/AgoraMediaBase-ti.js +75 -0
- package/js/Private/ti/AgoraMediaPlayerTypes-ti.js +5 -0
- package/js/Private/ti/IAgoraH265Transcoder-ti.js +40 -0
- package/js/Private/ti/IAgoraLog-ti.js +5 -0
- package/js/Private/ti/IAgoraMediaEngine-ti.js +5 -0
- package/js/Private/ti/IAgoraMediaPlayer-ti.js +38 -0
- package/js/Private/ti/IAgoraMediaPlayerSource-ti.js +50 -0
- package/js/Private/ti/IAgoraMediaRecorder-ti.js +5 -0
- package/js/Private/ti/IAgoraMediaStreamingSource-ti.js +5 -0
- package/js/Private/ti/IAgoraMusicContentCenter-ti.js +42 -0
- package/js/Private/ti/IAgoraRhythmPlayer-ti.js +5 -0
- package/js/Private/ti/IAgoraRtcEngine-ti.js +144 -0
- package/js/Private/ti/IAgoraRtcEngineEx-ti.js +5 -0
- package/js/Private/ti/IAgoraSpatialAudio-ti.js +5 -0
- package/js/Private/ti/IAudioDeviceManager-ti.js +5 -0
- package/js/Renderer/AgoraView.js +178 -0
- package/js/Renderer/CapabilityManager.js +99 -0
- package/js/Renderer/IRenderer.js +139 -0
- package/js/Renderer/IRendererCache.js +91 -0
- package/js/Renderer/RendererCache.js +252 -0
- package/js/Renderer/RendererManager.js +250 -0
- package/js/Renderer/WebCodecsRenderer/index.js +109 -0
- package/js/Renderer/WebCodecsRendererCache.js +127 -0
- package/js/Renderer/WebGLRenderer/index.js +467 -0
- package/js/Renderer/WebGLRenderer/webgl-utils.js +1337 -0
- package/js/Renderer/YUVCanvasRenderer/index.js +53 -0
- package/js/Renderer/index.js +17 -0
- package/js/Types.js +67 -0
- package/js/Utils.js +187 -0
- package/package.json +168 -0
- package/scripts/bootstrap.js +29 -0
- package/scripts/build.js +37 -0
- package/scripts/buildJS.js +14 -0
- package/scripts/checkElectron.js +43 -0
- package/scripts/clean.js +16 -0
- package/scripts/download.js +102 -0
- package/scripts/downloadPrebuild.js +199 -0
- package/scripts/getConfig.js +73 -0
- package/scripts/logger.js +32 -0
- package/scripts/synclib.js +69 -0
- package/scripts/util.js +47 -0
- package/scripts/zipBuild.js +40 -0
- package/ts/AgoraSdk.ts +44 -0
- package/ts/Decoder/gpu-utils.ts +92 -0
- package/ts/Decoder/index.ts +210 -0
- package/ts/Private/AgoraBase.ts +5941 -0
- package/ts/Private/AgoraMediaBase.ts +1814 -0
- package/ts/Private/AgoraMediaPlayerTypes.ts +467 -0
- package/ts/Private/IAgoraH265Transcoder.ts +73 -0
- package/ts/Private/IAgoraLog.ts +93 -0
- package/ts/Private/IAgoraMediaEngine.ts +321 -0
- package/ts/Private/IAgoraMediaPlayer.ts +759 -0
- package/ts/Private/IAgoraMediaPlayerSource.ts +137 -0
- package/ts/Private/IAgoraMediaRecorder.ts +65 -0
- package/ts/Private/IAgoraMediaStreamingSource.ts +81 -0
- package/ts/Private/IAgoraMusicContentCenter.ts +676 -0
- package/ts/Private/IAgoraRhythmPlayer.ts +67 -0
- package/ts/Private/IAgoraRtcEngine.ts +7909 -0
- package/ts/Private/IAgoraRtcEngineEx.ts +1138 -0
- package/ts/Private/IAgoraSpatialAudio.ts +248 -0
- package/ts/Private/IAudioDeviceManager.ts +351 -0
- package/ts/Private/extension/AgoraBaseExtension.ts +14 -0
- package/ts/Private/extension/AgoraMediaBaseExtension.ts +1 -0
- package/ts/Private/extension/AgoraMediaPlayerTypesExtension.ts +1 -0
- package/ts/Private/extension/IAgoraH265TranscoderExtension.ts +39 -0
- package/ts/Private/extension/IAgoraLogExtension.ts +1 -0
- package/ts/Private/extension/IAgoraMediaEngineExtension.ts +62 -0
- package/ts/Private/extension/IAgoraMediaPlayerExtension.ts +64 -0
- package/ts/Private/extension/IAgoraMediaPlayerSourceExtension.ts +1 -0
- package/ts/Private/extension/IAgoraMediaRecorderExtension.ts +59 -0
- package/ts/Private/extension/IAgoraMusicContentCenterExtension.ts +34 -0
- package/ts/Private/extension/IAgoraRhythmPlayerExtension.ts +1 -0
- package/ts/Private/extension/IAgoraRtcEngineExExtension.ts +1 -0
- package/ts/Private/extension/IAgoraRtcEngineExtension.ts +64 -0
- package/ts/Private/extension/IAgoraSpatialAudioExtension.ts +1 -0
- package/ts/Private/extension/IAudioDeviceManagerExtension.ts +1 -0
- package/ts/Private/impl/AgoraBaseImpl.ts +39 -0
- package/ts/Private/impl/AgoraMediaBaseImpl.ts +238 -0
- package/ts/Private/impl/IAgoraH265TranscoderImpl.ts +152 -0
- package/ts/Private/impl/IAgoraMediaEngineImpl.ts +491 -0
- package/ts/Private/impl/IAgoraMediaPlayerImpl.ts +1181 -0
- package/ts/Private/impl/IAgoraMediaPlayerSourceImpl.ts +94 -0
- package/ts/Private/impl/IAgoraMediaRecorderImpl.ts +59 -0
- package/ts/Private/impl/IAgoraMusicContentCenterImpl.ts +562 -0
- package/ts/Private/impl/IAgoraRtcEngineExImpl.ts +1912 -0
- package/ts/Private/impl/IAgoraRtcEngineImpl.ts +7738 -0
- package/ts/Private/impl/IAgoraSpatialAudioImpl.ts +495 -0
- package/ts/Private/impl/IAudioDeviceManagerImpl.ts +443 -0
- package/ts/Private/internal/AgoraH265TranscoderInternal.ts +97 -0
- package/ts/Private/internal/AgoraMediaBaseInternal.ts +15 -0
- package/ts/Private/internal/AudioDeviceManagerInternal.ts +46 -0
- package/ts/Private/internal/IrisApiEngine.ts +627 -0
- package/ts/Private/internal/LocalSpatialAudioEngineInternal.ts +3 -0
- package/ts/Private/internal/MediaEngineInternal.ts +190 -0
- package/ts/Private/internal/MediaPlayerInternal.ts +311 -0
- package/ts/Private/internal/MediaRecorderInternal.ts +100 -0
- package/ts/Private/internal/MusicContentCenterInternal.ts +208 -0
- package/ts/Private/internal/RtcEngineExInternal.ts +720 -0
- package/ts/Private/ipc/main.ts +22 -0
- package/ts/Private/ipc/renderer.ts +21 -0
- package/ts/Private/ti/AgoraBase-ti.ts +16 -0
- package/ts/Private/ti/AgoraMediaBase-ti.ts +58 -0
- package/ts/Private/ti/AgoraMediaPlayerTypes-ti.ts +11 -0
- package/ts/Private/ti/IAgoraH265Transcoder-ti.ts +16 -0
- package/ts/Private/ti/IAgoraLog-ti.ts +11 -0
- package/ts/Private/ti/IAgoraMediaEngine-ti.ts +11 -0
- package/ts/Private/ti/IAgoraMediaPlayer-ti.ts +14 -0
- package/ts/Private/ti/IAgoraMediaPlayerSource-ti.ts +26 -0
- package/ts/Private/ti/IAgoraMediaRecorder-ti.ts +11 -0
- package/ts/Private/ti/IAgoraMediaStreamingSource-ti.ts +11 -0
- package/ts/Private/ti/IAgoraMusicContentCenter-ti.ts +18 -0
- package/ts/Private/ti/IAgoraRhythmPlayer-ti.ts +11 -0
- package/ts/Private/ti/IAgoraRtcEngine-ti.ts +122 -0
- package/ts/Private/ti/IAgoraRtcEngineEx-ti.ts +11 -0
- package/ts/Private/ti/IAgoraSpatialAudio-ti.ts +11 -0
- package/ts/Private/ti/IAudioDeviceManager-ti.ts +11 -0
- package/ts/Renderer/AgoraView.ts +264 -0
- package/ts/Renderer/CapabilityManager.ts +126 -0
- package/ts/Renderer/IRenderer.ts +163 -0
- package/ts/Renderer/IRendererCache.ts +130 -0
- package/ts/Renderer/RendererCache.ts +323 -0
- package/ts/Renderer/RendererManager.ts +322 -0
- package/ts/Renderer/WebCodecsRenderer/index.ts +148 -0
- package/ts/Renderer/WebCodecsRendererCache.ts +153 -0
- package/ts/Renderer/WebGLRenderer/index.ts +695 -0
- package/ts/Renderer/WebGLRenderer/webgl-utils.js +1510 -0
- package/ts/Renderer/YUVCanvasRenderer/index.ts +80 -0
- package/ts/Renderer/index.ts +1 -0
- package/ts/Types.ts +254 -0
- package/ts/Utils.ts +198 -0
- package/types/AgoraSdk.d.ts +30 -0
- package/types/AgoraSdk.d.ts.map +1 -0
- package/types/Decoder/gpu-utils.d.ts +21 -0
- package/types/Decoder/gpu-utils.d.ts.map +1 -0
- package/types/Decoder/index.d.ts +26 -0
- package/types/Decoder/index.d.ts.map +1 -0
- package/types/Private/AgoraBase.d.ts +5728 -0
- package/types/Private/AgoraBase.d.ts.map +1 -0
- package/types/Private/AgoraMediaBase.d.ts +1717 -0
- package/types/Private/AgoraMediaBase.d.ts.map +1 -0
- package/types/Private/AgoraMediaPlayerTypes.d.ts +456 -0
- package/types/Private/AgoraMediaPlayerTypes.d.ts.map +1 -0
- package/types/Private/IAgoraH265Transcoder.d.ts +28 -0
- package/types/Private/IAgoraH265Transcoder.d.ts.map +1 -0
- package/types/Private/IAgoraLog.d.ts +91 -0
- package/types/Private/IAgoraLog.d.ts.map +1 -0
- package/types/Private/IAgoraMediaEngine.d.ts +255 -0
- package/types/Private/IAgoraMediaEngine.d.ts.map +1 -0
- package/types/Private/IAgoraMediaPlayer.d.ts +662 -0
- package/types/Private/IAgoraMediaPlayer.d.ts.map +1 -0
- package/types/Private/IAgoraMediaPlayerSource.d.ts +109 -0
- package/types/Private/IAgoraMediaPlayerSource.d.ts.map +1 -0
- package/types/Private/IAgoraMediaRecorder.d.ts +60 -0
- package/types/Private/IAgoraMediaRecorder.d.ts.map +1 -0
- package/types/Private/IAgoraMediaStreamingSource.d.ts +42 -0
- package/types/Private/IAgoraMediaStreamingSource.d.ts.map +1 -0
- package/types/Private/IAgoraMusicContentCenter.d.ts +602 -0
- package/types/Private/IAgoraMusicContentCenter.d.ts.map +1 -0
- package/types/Private/IAgoraRhythmPlayer.d.ts +65 -0
- package/types/Private/IAgoraRhythmPlayer.d.ts.map +1 -0
- package/types/Private/IAgoraRtcEngine.d.ts +6640 -0
- package/types/Private/IAgoraRtcEngine.d.ts.map +1 -0
- package/types/Private/IAgoraRtcEngineEx.d.ts +847 -0
- package/types/Private/IAgoraRtcEngineEx.d.ts.map +1 -0
- package/types/Private/IAgoraSpatialAudio.d.ts +194 -0
- package/types/Private/IAgoraSpatialAudio.d.ts.map +1 -0
- package/types/Private/IAudioDeviceManager.d.ts +321 -0
- package/types/Private/IAudioDeviceManager.d.ts.map +1 -0
- package/types/Private/extension/AgoraBaseExtension.d.ts +14 -0
- package/types/Private/extension/AgoraBaseExtension.d.ts.map +1 -0
- package/types/Private/extension/AgoraMediaBaseExtension.d.ts +2 -0
- package/types/Private/extension/AgoraMediaBaseExtension.d.ts.map +1 -0
- package/types/Private/extension/AgoraMediaPlayerTypesExtension.d.ts +2 -0
- package/types/Private/extension/AgoraMediaPlayerTypesExtension.d.ts.map +1 -0
- package/types/Private/extension/IAgoraH265TranscoderExtension.d.ts +24 -0
- package/types/Private/extension/IAgoraH265TranscoderExtension.d.ts.map +1 -0
- package/types/Private/extension/IAgoraLogExtension.d.ts +2 -0
- package/types/Private/extension/IAgoraLogExtension.d.ts.map +1 -0
- package/types/Private/extension/IAgoraMediaEngineExtension.d.ts +40 -0
- package/types/Private/extension/IAgoraMediaEngineExtension.d.ts.map +1 -0
- package/types/Private/extension/IAgoraMediaPlayerExtension.d.ts +46 -0
- package/types/Private/extension/IAgoraMediaPlayerExtension.d.ts.map +1 -0
- package/types/Private/extension/IAgoraMediaPlayerSourceExtension.d.ts +2 -0
- package/types/Private/extension/IAgoraMediaPlayerSourceExtension.d.ts.map +1 -0
- package/types/Private/extension/IAgoraMediaRecorderExtension.d.ts +44 -0
- package/types/Private/extension/IAgoraMediaRecorderExtension.d.ts.map +1 -0
- package/types/Private/extension/IAgoraMusicContentCenterExtension.d.ts +20 -0
- package/types/Private/extension/IAgoraMusicContentCenterExtension.d.ts.map +1 -0
- package/types/Private/extension/IAgoraRhythmPlayerExtension.d.ts +2 -0
- package/types/Private/extension/IAgoraRhythmPlayerExtension.d.ts.map +1 -0
- package/types/Private/extension/IAgoraRtcEngineExExtension.d.ts +2 -0
- package/types/Private/extension/IAgoraRtcEngineExExtension.d.ts.map +1 -0
- package/types/Private/extension/IAgoraRtcEngineExtension.d.ts +42 -0
- package/types/Private/extension/IAgoraRtcEngineExtension.d.ts.map +1 -0
- package/types/Private/extension/IAgoraSpatialAudioExtension.d.ts +2 -0
- package/types/Private/extension/IAgoraSpatialAudioExtension.d.ts.map +1 -0
- package/types/Private/extension/IAudioDeviceManagerExtension.d.ts +2 -0
- package/types/Private/extension/IAudioDeviceManagerExtension.d.ts.map +1 -0
- package/types/Private/impl/AgoraBaseImpl.d.ts +3 -0
- package/types/Private/impl/AgoraBaseImpl.d.ts.map +1 -0
- package/types/Private/impl/AgoraMediaBaseImpl.d.ts +14 -0
- package/types/Private/impl/AgoraMediaBaseImpl.d.ts.map +1 -0
- package/types/Private/impl/IAgoraH265TranscoderImpl.d.ts +15 -0
- package/types/Private/impl/IAgoraH265TranscoderImpl.d.ts.map +1 -0
- package/types/Private/impl/IAgoraMediaEngineImpl.d.ts +46 -0
- package/types/Private/impl/IAgoraMediaEngineImpl.d.ts.map +1 -0
- package/types/Private/impl/IAgoraMediaPlayerImpl.d.ts +145 -0
- package/types/Private/impl/IAgoraMediaPlayerImpl.d.ts.map +1 -0
- package/types/Private/impl/IAgoraMediaPlayerSourceImpl.d.ts +3 -0
- package/types/Private/impl/IAgoraMediaPlayerSourceImpl.d.ts.map +1 -0
- package/types/Private/impl/IAgoraMediaRecorderImpl.d.ts +11 -0
- package/types/Private/impl/IAgoraMediaRecorderImpl.d.ts.map +1 -0
- package/types/Private/impl/IAgoraMusicContentCenterImpl.d.ts +67 -0
- package/types/Private/impl/IAgoraMusicContentCenterImpl.d.ts.map +1 -0
- package/types/Private/impl/IAgoraRtcEngineExImpl.d.ts +128 -0
- package/types/Private/impl/IAgoraRtcEngineExImpl.d.ts.map +1 -0
- package/types/Private/impl/IAgoraRtcEngineImpl.d.ts +656 -0
- package/types/Private/impl/IAgoraRtcEngineImpl.d.ts.map +1 -0
- package/types/Private/impl/IAgoraSpatialAudioImpl.d.ts +47 -0
- package/types/Private/impl/IAgoraSpatialAudioImpl.d.ts.map +1 -0
- package/types/Private/impl/IAudioDeviceManagerImpl.d.ts +65 -0
- package/types/Private/impl/IAudioDeviceManagerImpl.d.ts.map +1 -0
- package/types/Private/internal/AgoraH265TranscoderInternal.d.ts +14 -0
- package/types/Private/internal/AgoraH265TranscoderInternal.d.ts.map +1 -0
- package/types/Private/internal/AgoraMediaBaseInternal.d.ts +8 -0
- package/types/Private/internal/AgoraMediaBaseInternal.d.ts.map +1 -0
- package/types/Private/internal/AudioDeviceManagerInternal.d.ts +9 -0
- package/types/Private/internal/AudioDeviceManagerInternal.d.ts.map +1 -0
- package/types/Private/internal/IrisApiEngine.d.ts +69 -0
- package/types/Private/internal/IrisApiEngine.d.ts.map +1 -0
- package/types/Private/internal/LocalSpatialAudioEngineInternal.d.ts +4 -0
- package/types/Private/internal/LocalSpatialAudioEngineInternal.d.ts.map +1 -0
- package/types/Private/internal/MediaEngineInternal.d.ts +23 -0
- package/types/Private/internal/MediaEngineInternal.d.ts.map +1 -0
- package/types/Private/internal/MediaPlayerInternal.d.ts +30 -0
- package/types/Private/internal/MediaPlayerInternal.d.ts.map +1 -0
- package/types/Private/internal/MediaRecorderInternal.d.ts +16 -0
- package/types/Private/internal/MediaRecorderInternal.d.ts.map +1 -0
- package/types/Private/internal/MusicContentCenterInternal.d.ts +31 -0
- package/types/Private/internal/MusicContentCenterInternal.d.ts.map +1 -0
- package/types/Private/internal/RtcEngineExInternal.d.ts +77 -0
- package/types/Private/internal/RtcEngineExInternal.d.ts.map +1 -0
- package/types/Private/ipc/main.d.ts +2 -0
- package/types/Private/ipc/main.d.ts.map +1 -0
- package/types/Private/ipc/renderer.d.ts +3 -0
- package/types/Private/ipc/renderer.d.ts.map +1 -0
- package/types/Private/ti/AgoraBase-ti.d.ts +8 -0
- package/types/Private/ti/AgoraBase-ti.d.ts.map +1 -0
- package/types/Private/ti/AgoraMediaBase-ti.d.ts +15 -0
- package/types/Private/ti/AgoraMediaBase-ti.d.ts.map +1 -0
- package/types/Private/ti/AgoraMediaPlayerTypes-ti.d.ts +7 -0
- package/types/Private/ti/AgoraMediaPlayerTypes-ti.d.ts.map +1 -0
- package/types/Private/ti/IAgoraH265Transcoder-ti.d.ts +8 -0
- package/types/Private/ti/IAgoraH265Transcoder-ti.d.ts.map +1 -0
- package/types/Private/ti/IAgoraLog-ti.d.ts +7 -0
- package/types/Private/ti/IAgoraLog-ti.d.ts.map +1 -0
- package/types/Private/ti/IAgoraMediaEngine-ti.d.ts +7 -0
- package/types/Private/ti/IAgoraMediaEngine-ti.d.ts.map +1 -0
- package/types/Private/ti/IAgoraMediaPlayer-ti.d.ts +8 -0
- package/types/Private/ti/IAgoraMediaPlayer-ti.d.ts.map +1 -0
- package/types/Private/ti/IAgoraMediaPlayerSource-ti.d.ts +8 -0
- package/types/Private/ti/IAgoraMediaPlayerSource-ti.d.ts.map +1 -0
- package/types/Private/ti/IAgoraMediaRecorder-ti.d.ts +7 -0
- package/types/Private/ti/IAgoraMediaRecorder-ti.d.ts.map +1 -0
- package/types/Private/ti/IAgoraMediaStreamingSource-ti.d.ts +7 -0
- package/types/Private/ti/IAgoraMediaStreamingSource-ti.d.ts.map +1 -0
- package/types/Private/ti/IAgoraMusicContentCenter-ti.d.ts +8 -0
- package/types/Private/ti/IAgoraMusicContentCenter-ti.d.ts.map +1 -0
- package/types/Private/ti/IAgoraRhythmPlayer-ti.d.ts +7 -0
- package/types/Private/ti/IAgoraRhythmPlayer-ti.d.ts.map +1 -0
- package/types/Private/ti/IAgoraRtcEngine-ti.d.ts +10 -0
- package/types/Private/ti/IAgoraRtcEngine-ti.d.ts.map +1 -0
- package/types/Private/ti/IAgoraRtcEngineEx-ti.d.ts +7 -0
- package/types/Private/ti/IAgoraRtcEngineEx-ti.d.ts.map +1 -0
- package/types/Private/ti/IAgoraSpatialAudio-ti.d.ts +7 -0
- package/types/Private/ti/IAgoraSpatialAudio-ti.d.ts.map +1 -0
- package/types/Private/ti/IAudioDeviceManager-ti.d.ts +7 -0
- package/types/Private/ti/IAudioDeviceManager-ti.d.ts.map +1 -0
- package/types/Renderer/AgoraView.d.ts +82 -0
- package/types/Renderer/AgoraView.d.ts.map +1 -0
- package/types/Renderer/CapabilityManager.d.ts +20 -0
- package/types/Renderer/CapabilityManager.d.ts.map +1 -0
- package/types/Renderer/IRenderer.d.ts +20 -0
- package/types/Renderer/IRenderer.d.ts.map +1 -0
- package/types/Renderer/IRendererCache.d.ts +47 -0
- package/types/Renderer/IRendererCache.d.ts.map +1 -0
- package/types/Renderer/RendererCache.d.ts +51 -0
- package/types/Renderer/RendererCache.d.ts.map +1 -0
- package/types/Renderer/RendererManager.d.ts +53 -0
- package/types/Renderer/RendererManager.d.ts.map +1 -0
- package/types/Renderer/WebCodecsRenderer/index.d.ts +14 -0
- package/types/Renderer/WebCodecsRenderer/index.d.ts.map +1 -0
- package/types/Renderer/WebCodecsRendererCache.d.ts +22 -0
- package/types/Renderer/WebCodecsRendererCache.d.ts.map +1 -0
- package/types/Renderer/WebGLRenderer/index.d.ts +37 -0
- package/types/Renderer/WebGLRenderer/index.d.ts.map +1 -0
- package/types/Renderer/WebGLRenderer/webgl-utils.d.ts +1 -0
- package/types/Renderer/WebGLRenderer/webgl-utils.d.ts.map +1 -0
- package/types/Renderer/YUVCanvasRenderer/index.d.ts +10 -0
- package/types/Renderer/YUVCanvasRenderer/index.d.ts.map +1 -0
- package/types/Renderer/index.d.ts +2 -0
- package/types/Renderer/index.d.ts.map +1 -0
- package/types/Types.d.ts +182 -0
- package/types/Types.d.ts.map +1 -0
- package/types/Utils.d.ts +50 -0
- package/types/Utils.d.ts.map +1 -0
|
@@ -0,0 +1,467 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WebGLRenderer = void 0;
|
|
4
|
+
const AgoraMediaBase_1 = require("../../Private/AgoraMediaBase");
|
|
5
|
+
const Types_1 = require("../../Types");
|
|
6
|
+
const Utils_1 = require("../../Utils");
|
|
7
|
+
const IRenderer_1 = require("../IRenderer");
|
|
8
|
+
const createProgramFromSources = require('./webgl-utils').createProgramFromSources;
|
|
9
|
+
const vertexShaderSource = `
|
|
10
|
+
attribute vec2 a_position;
|
|
11
|
+
attribute vec2 a_texCoord;
|
|
12
|
+
uniform vec2 u_resolution;
|
|
13
|
+
varying vec2 v_texCoord;
|
|
14
|
+
void main() {
|
|
15
|
+
vec2 zeroToOne = a_position / u_resolution;
|
|
16
|
+
vec2 zeroToTwo = zeroToOne * 2.0;
|
|
17
|
+
vec2 clipSpace = zeroToTwo - 1.0;
|
|
18
|
+
gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1);
|
|
19
|
+
v_texCoord = a_texCoord;
|
|
20
|
+
}`;
|
|
21
|
+
const yuvShaderSource = `
|
|
22
|
+
precision mediump float;
|
|
23
|
+
uniform sampler2D Ytex;
|
|
24
|
+
uniform sampler2D Utex;
|
|
25
|
+
uniform sampler2D Vtex;
|
|
26
|
+
uniform sampler2D Atex;
|
|
27
|
+
uniform bool hasAlpha;
|
|
28
|
+
|
|
29
|
+
// Dynamic color space conversion parameters
|
|
30
|
+
uniform float u_yOffset;
|
|
31
|
+
uniform float u_yScale;
|
|
32
|
+
uniform float u_rVCoeff;
|
|
33
|
+
uniform float u_gUCoeff;
|
|
34
|
+
uniform float u_gVCoeff;
|
|
35
|
+
uniform float u_bUCoeff;
|
|
36
|
+
|
|
37
|
+
varying vec2 v_texCoord;
|
|
38
|
+
|
|
39
|
+
void main(void) {
|
|
40
|
+
float nx = v_texCoord[0];
|
|
41
|
+
float ny = v_texCoord[1];
|
|
42
|
+
|
|
43
|
+
float y = texture2D(Ytex, vec2(nx, ny)).r;
|
|
44
|
+
float u = texture2D(Utex, vec2(nx, ny)).r;
|
|
45
|
+
float v = texture2D(Vtex, vec2(nx, ny)).r;
|
|
46
|
+
float a;
|
|
47
|
+
|
|
48
|
+
if (hasAlpha) {
|
|
49
|
+
a = texture2D(Atex, vec2(nx, ny)).r;
|
|
50
|
+
} else {
|
|
51
|
+
a = 1.0;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Apply dynamic color space conversion
|
|
55
|
+
y = u_yScale * (y - u_yOffset);
|
|
56
|
+
u = u - 0.5;
|
|
57
|
+
v = v - 0.5;
|
|
58
|
+
|
|
59
|
+
float r = y + u_rVCoeff * v;
|
|
60
|
+
float g = y + u_gUCoeff * u + u_gVCoeff * v;
|
|
61
|
+
float b = y + u_bUCoeff * u;
|
|
62
|
+
|
|
63
|
+
gl_FragColor = vec4(r, g, b, a);
|
|
64
|
+
}`;
|
|
65
|
+
class WebGLRenderer extends IRenderer_1.IRenderer {
|
|
66
|
+
constructor(fallback) {
|
|
67
|
+
super();
|
|
68
|
+
// Color space uniform locations
|
|
69
|
+
this.colorSpaceUniforms = {};
|
|
70
|
+
this.handleContextLost = (event) => {
|
|
71
|
+
event.preventDefault();
|
|
72
|
+
(0, Utils_1.logWarn)('webglcontextlost', event);
|
|
73
|
+
this.releaseTextures();
|
|
74
|
+
this.fallback?.call(null, this, new Error('Browser not support! No WebGL detected.'));
|
|
75
|
+
};
|
|
76
|
+
this.handleContextRestored = (event) => {
|
|
77
|
+
event.preventDefault();
|
|
78
|
+
(0, Utils_1.logWarn)('webglcontextrestored', event);
|
|
79
|
+
// Setup GLSL program
|
|
80
|
+
this.program = createProgramFromSources(this.gl, [
|
|
81
|
+
vertexShaderSource,
|
|
82
|
+
yuvShaderSource,
|
|
83
|
+
]);
|
|
84
|
+
this.gl?.useProgram(this.program);
|
|
85
|
+
this.initTextures();
|
|
86
|
+
};
|
|
87
|
+
this.gl = null;
|
|
88
|
+
this.rendererType = Types_1.RendererType.WEBGL;
|
|
89
|
+
this.program = null;
|
|
90
|
+
this.yTexture = null;
|
|
91
|
+
this.uTexture = null;
|
|
92
|
+
this.vTexture = null;
|
|
93
|
+
this.aTexture = null;
|
|
94
|
+
this.hasAlpha = null;
|
|
95
|
+
this.texCoordBuffer = null;
|
|
96
|
+
this.surfaceBuffer = null;
|
|
97
|
+
this.fallback = fallback;
|
|
98
|
+
}
|
|
99
|
+
bind(context) {
|
|
100
|
+
super.bind(context);
|
|
101
|
+
this.canvas?.addEventListener('webglcontextlost', this.handleContextLost, false);
|
|
102
|
+
this.canvas?.addEventListener('webglcontextrestored', this.handleContextRestored, false);
|
|
103
|
+
const getContext = (contextNames = ['webgl2', 'webgl', 'experimental-webgl']) => {
|
|
104
|
+
for (let i = 0; i < contextNames.length; i++) {
|
|
105
|
+
const contextName = contextNames[i];
|
|
106
|
+
const canvasContext = this.canvas?.getContext(contextName, {
|
|
107
|
+
depth: true,
|
|
108
|
+
stencil: true,
|
|
109
|
+
alpha: context.enableAlphaMask,
|
|
110
|
+
antialias: false,
|
|
111
|
+
premultipliedAlpha: true,
|
|
112
|
+
preserveDrawingBuffer: !context.enableAlphaMask,
|
|
113
|
+
powerPreference: 'default',
|
|
114
|
+
failIfMajorPerformanceCaveat: false,
|
|
115
|
+
});
|
|
116
|
+
if (canvasContext) {
|
|
117
|
+
return canvasContext;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return null;
|
|
121
|
+
};
|
|
122
|
+
this.gl ?? (this.gl = getContext());
|
|
123
|
+
if (!this.gl) {
|
|
124
|
+
this.fallback?.call(null, this, new Error('Browser not support! No WebGL detected.'));
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
// Set clear color to black, fully opaque
|
|
128
|
+
this.gl.clearColor(0.0, 0.0, 0.0, 0.0);
|
|
129
|
+
// Enable depth testing
|
|
130
|
+
this.gl.enable(this.gl.DEPTH_TEST);
|
|
131
|
+
// Near things obscure far things
|
|
132
|
+
this.gl.depthFunc(this.gl.LEQUAL);
|
|
133
|
+
// Enable blending
|
|
134
|
+
this.gl.enable(this.gl.BLEND);
|
|
135
|
+
// Set blending function
|
|
136
|
+
this.gl.blendFunc(this.gl.SRC_ALPHA, this.gl.ONE_MINUS_SRC_ALPHA);
|
|
137
|
+
// Clear the color as well as the depth buffer.
|
|
138
|
+
this.gl.clear(this.gl.COLOR_BUFFER_BIT |
|
|
139
|
+
this.gl.DEPTH_BUFFER_BIT |
|
|
140
|
+
this.gl.STENCIL_BUFFER_BIT);
|
|
141
|
+
// Setup GLSL program
|
|
142
|
+
this.program = createProgramFromSources(this.gl, [
|
|
143
|
+
vertexShaderSource,
|
|
144
|
+
yuvShaderSource,
|
|
145
|
+
]);
|
|
146
|
+
this.gl.useProgram(this.program);
|
|
147
|
+
this.initTextures();
|
|
148
|
+
}
|
|
149
|
+
unbind() {
|
|
150
|
+
this.canvas?.removeEventListener('webglcontextlost', this.handleContextLost, false);
|
|
151
|
+
this.canvas?.removeEventListener('webglcontextrestored', this.handleContextRestored, false);
|
|
152
|
+
this.releaseTextures();
|
|
153
|
+
this.gl = null;
|
|
154
|
+
super.unbind();
|
|
155
|
+
}
|
|
156
|
+
drawFrame(uid, { width, height, yStride, uStride, vStride, yBuffer, uBuffer, vBuffer, rotation, alphaBuffer, colorSpace, }) {
|
|
157
|
+
this.rotateCanvas({ width, height, rotation });
|
|
158
|
+
this.updateRenderMode();
|
|
159
|
+
if (!this.gl || !this.program)
|
|
160
|
+
return;
|
|
161
|
+
// Set color space conversion parameters based on frame properties
|
|
162
|
+
this.setColorSpaceUniforms(colorSpace);
|
|
163
|
+
const left = 0, top = 0, right = yStride - width, bottom = 0;
|
|
164
|
+
this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.texCoordBuffer);
|
|
165
|
+
const xWidth = width + left + right;
|
|
166
|
+
const xHeight = height + top + bottom;
|
|
167
|
+
this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array([
|
|
168
|
+
left / xWidth,
|
|
169
|
+
bottom / xHeight,
|
|
170
|
+
1 - right / xWidth,
|
|
171
|
+
bottom / xHeight,
|
|
172
|
+
left / xWidth,
|
|
173
|
+
1 - top / xHeight,
|
|
174
|
+
left / xWidth,
|
|
175
|
+
1 - top / xHeight,
|
|
176
|
+
1 - right / xWidth,
|
|
177
|
+
bottom / xHeight,
|
|
178
|
+
1 - right / xWidth,
|
|
179
|
+
1 - top / xHeight,
|
|
180
|
+
]), this.gl.STATIC_DRAW);
|
|
181
|
+
this.gl.enableVertexAttribArray(this.texCoordLocation);
|
|
182
|
+
this.gl.vertexAttribPointer(this.texCoordLocation, 2, this.gl.FLOAT, false, 0, 0);
|
|
183
|
+
this.gl.pixelStorei(this.gl.UNPACK_ALIGNMENT, 1);
|
|
184
|
+
const activeTexture = (textureIndex, { texture, stride, height, pixels }) => {
|
|
185
|
+
if (!this.gl)
|
|
186
|
+
return;
|
|
187
|
+
this.gl.activeTexture(textureIndex);
|
|
188
|
+
this.gl.bindTexture(this.gl.TEXTURE_2D, texture);
|
|
189
|
+
this.gl.texImage2D(this.gl.TEXTURE_2D, 0, this.gl.LUMINANCE, stride, height, 0, this.gl.LUMINANCE, this.gl.UNSIGNED_BYTE, pixels);
|
|
190
|
+
};
|
|
191
|
+
const textures = {
|
|
192
|
+
[this.gl.TEXTURE0]: {
|
|
193
|
+
texture: this.yTexture,
|
|
194
|
+
stride: yStride,
|
|
195
|
+
height: height,
|
|
196
|
+
pixels: yBuffer,
|
|
197
|
+
},
|
|
198
|
+
[this.gl.TEXTURE1]: {
|
|
199
|
+
texture: this.uTexture,
|
|
200
|
+
stride: uStride,
|
|
201
|
+
height: height / 2,
|
|
202
|
+
pixels: uBuffer,
|
|
203
|
+
},
|
|
204
|
+
[this.gl.TEXTURE2]: {
|
|
205
|
+
texture: this.vTexture,
|
|
206
|
+
stride: vStride,
|
|
207
|
+
height: height / 2,
|
|
208
|
+
pixels: vBuffer,
|
|
209
|
+
},
|
|
210
|
+
};
|
|
211
|
+
if (alphaBuffer && alphaBuffer.length > 0 && this.context.enableAlphaMask) {
|
|
212
|
+
textures[this.gl.TEXTURE3] = {
|
|
213
|
+
texture: this.aTexture,
|
|
214
|
+
stride: width,
|
|
215
|
+
height: height,
|
|
216
|
+
pixels: alphaBuffer,
|
|
217
|
+
};
|
|
218
|
+
this.gl.uniform1i(this.hasAlpha, 1);
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
this.gl.uniform1i(this.hasAlpha, 0);
|
|
222
|
+
}
|
|
223
|
+
for (const textureIndex in textures) {
|
|
224
|
+
if (textures.hasOwnProperty(textureIndex)) {
|
|
225
|
+
activeTexture(+textureIndex, textures[textureIndex]);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
this.gl.drawArrays(this.gl.TRIANGLES, 0, 6);
|
|
229
|
+
super.drawFrame(uid);
|
|
230
|
+
}
|
|
231
|
+
rotateCanvas({ width, height, rotation }) {
|
|
232
|
+
super.rotateCanvas({ width, height, rotation });
|
|
233
|
+
if (!this.gl || !this.program)
|
|
234
|
+
return;
|
|
235
|
+
this.gl.viewport(0, 0, width, height);
|
|
236
|
+
this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.surfaceBuffer);
|
|
237
|
+
this.gl.enableVertexAttribArray(this.positionLocation);
|
|
238
|
+
this.gl.vertexAttribPointer(this.positionLocation, 2, this.gl.FLOAT, false, 0, 0);
|
|
239
|
+
// 4 vertex, 1(x1,y1), 2(x2,y1), 3(x2,y2), 4(x1,y2)
|
|
240
|
+
// 0: 1,2,4/4,2,3
|
|
241
|
+
// 90: 2,3,1/1,3,4
|
|
242
|
+
// 180: 3,4,2/2,4,1
|
|
243
|
+
// 270: 4,1,3/3,1,2
|
|
244
|
+
const p1 = { x: 0, y: 0 };
|
|
245
|
+
const p2 = { x: width, y: 0 };
|
|
246
|
+
const p3 = { x: width, y: height };
|
|
247
|
+
const p4 = { x: 0, y: height };
|
|
248
|
+
let pp1 = p1, pp2 = p2, pp3 = p3, pp4 = p4;
|
|
249
|
+
switch (rotation) {
|
|
250
|
+
case 0:
|
|
251
|
+
break;
|
|
252
|
+
case 90:
|
|
253
|
+
pp1 = p2;
|
|
254
|
+
pp2 = p3;
|
|
255
|
+
pp3 = p4;
|
|
256
|
+
pp4 = p1;
|
|
257
|
+
break;
|
|
258
|
+
case 180:
|
|
259
|
+
pp1 = p3;
|
|
260
|
+
pp2 = p4;
|
|
261
|
+
pp3 = p1;
|
|
262
|
+
pp4 = p2;
|
|
263
|
+
break;
|
|
264
|
+
case 270:
|
|
265
|
+
pp1 = p4;
|
|
266
|
+
pp2 = p1;
|
|
267
|
+
pp3 = p2;
|
|
268
|
+
pp4 = p3;
|
|
269
|
+
break;
|
|
270
|
+
default:
|
|
271
|
+
}
|
|
272
|
+
this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array([
|
|
273
|
+
pp1.x,
|
|
274
|
+
pp1.y,
|
|
275
|
+
pp2.x,
|
|
276
|
+
pp2.y,
|
|
277
|
+
pp4.x,
|
|
278
|
+
pp4.y,
|
|
279
|
+
pp4.x,
|
|
280
|
+
pp4.y,
|
|
281
|
+
pp2.x,
|
|
282
|
+
pp2.y,
|
|
283
|
+
pp3.x,
|
|
284
|
+
pp3.y,
|
|
285
|
+
]), this.gl.STATIC_DRAW);
|
|
286
|
+
const resolutionLocation = this.gl.getUniformLocation(this.program, 'u_resolution');
|
|
287
|
+
this.gl.uniform2f(resolutionLocation, width, height);
|
|
288
|
+
}
|
|
289
|
+
initTextures() {
|
|
290
|
+
if (!this.gl || !this.program)
|
|
291
|
+
return;
|
|
292
|
+
this.positionLocation = this.gl.getAttribLocation(this.program, 'a_position');
|
|
293
|
+
this.texCoordLocation = this.gl.getAttribLocation(this.program, 'a_texCoord');
|
|
294
|
+
this.hasAlpha = this.gl.getUniformLocation(this.program, 'hasAlpha');
|
|
295
|
+
// Get color space uniform locations
|
|
296
|
+
this.colorSpaceUniforms.yOffset = this.gl.getUniformLocation(this.program, 'u_yOffset');
|
|
297
|
+
this.colorSpaceUniforms.yScale = this.gl.getUniformLocation(this.program, 'u_yScale');
|
|
298
|
+
this.colorSpaceUniforms.rVCoeff = this.gl.getUniformLocation(this.program, 'u_rVCoeff');
|
|
299
|
+
this.colorSpaceUniforms.gUCoeff = this.gl.getUniformLocation(this.program, 'u_gUCoeff');
|
|
300
|
+
this.colorSpaceUniforms.gVCoeff = this.gl.getUniformLocation(this.program, 'u_gVCoeff');
|
|
301
|
+
this.colorSpaceUniforms.bUCoeff = this.gl.getUniformLocation(this.program, 'u_bUCoeff');
|
|
302
|
+
this.surfaceBuffer = this.gl.createBuffer();
|
|
303
|
+
this.texCoordBuffer = this.gl.createBuffer();
|
|
304
|
+
const createTexture = (texture, textureIndex, textureName) => {
|
|
305
|
+
if (!this.gl || !this.program)
|
|
306
|
+
return null;
|
|
307
|
+
// Create a texture.
|
|
308
|
+
this.gl.activeTexture(texture);
|
|
309
|
+
const textureObj = this.gl.createTexture();
|
|
310
|
+
this.gl.bindTexture(this.gl.TEXTURE_2D, textureObj);
|
|
311
|
+
// Set the parameters so we can render any size
|
|
312
|
+
this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_S, this.gl.CLAMP_TO_EDGE);
|
|
313
|
+
this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_T, this.gl.CLAMP_TO_EDGE);
|
|
314
|
+
this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MIN_FILTER, this.gl.NEAREST);
|
|
315
|
+
this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MAG_FILTER, this.gl.NEAREST);
|
|
316
|
+
this.gl.uniform1i(this.gl.getUniformLocation(this.program, textureName), textureIndex); /* Bind Ytex to texture unit index */
|
|
317
|
+
return textureObj;
|
|
318
|
+
};
|
|
319
|
+
this.yTexture = createTexture(this.gl.TEXTURE0, 0, 'Ytex');
|
|
320
|
+
this.uTexture = createTexture(this.gl.TEXTURE1, 1, 'Utex');
|
|
321
|
+
this.vTexture = createTexture(this.gl.TEXTURE2, 2, 'Vtex');
|
|
322
|
+
this.aTexture = createTexture(this.gl.TEXTURE3, 3, 'Atex');
|
|
323
|
+
// Set default color space parameters (BT.601 Limited Range)
|
|
324
|
+
this.setColorSpaceUniforms();
|
|
325
|
+
}
|
|
326
|
+
releaseTextures() {
|
|
327
|
+
this.gl?.deleteProgram(this.program);
|
|
328
|
+
this.program = null;
|
|
329
|
+
this.positionLocation = undefined;
|
|
330
|
+
this.texCoordLocation = undefined;
|
|
331
|
+
this.gl?.deleteTexture(this.yTexture);
|
|
332
|
+
this.gl?.deleteTexture(this.uTexture);
|
|
333
|
+
this.gl?.deleteTexture(this.vTexture);
|
|
334
|
+
this.yTexture = null;
|
|
335
|
+
this.uTexture = null;
|
|
336
|
+
this.vTexture = null;
|
|
337
|
+
this.aTexture = null;
|
|
338
|
+
this.hasAlpha = null;
|
|
339
|
+
this.gl?.deleteBuffer(this.texCoordBuffer);
|
|
340
|
+
this.gl?.deleteBuffer(this.surfaceBuffer);
|
|
341
|
+
this.texCoordBuffer = null;
|
|
342
|
+
this.surfaceBuffer = null;
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Get color space conversion parameters based on color space and range
|
|
346
|
+
*/
|
|
347
|
+
getColorSpaceParams(colorSpace) {
|
|
348
|
+
// Default to BT.601 Limited if not specified
|
|
349
|
+
const primaries = colorSpace?.primaries ?? AgoraMediaBase_1.PrimaryID.PrimaryidBt709;
|
|
350
|
+
const range = colorSpace?.range ?? AgoraMediaBase_1.RangeID.RangeidLimited;
|
|
351
|
+
// Y offset and scale based on ran
|
|
352
|
+
let yOffset;
|
|
353
|
+
let yScale;
|
|
354
|
+
if (range === AgoraMediaBase_1.RangeID.RangeidFull) {
|
|
355
|
+
yOffset = 0.0;
|
|
356
|
+
yScale = 1.0;
|
|
357
|
+
}
|
|
358
|
+
else {
|
|
359
|
+
// Limited range: Y [16, 235] -> [0, 1]
|
|
360
|
+
yOffset = 16.0 / 255.0; // 0.0625
|
|
361
|
+
yScale = 255.0 / (235.0 - 16.0); // 1.1643
|
|
362
|
+
}
|
|
363
|
+
// Color space conversion coefficients
|
|
364
|
+
let rVCoeff, gUCoeff, gVCoeff, bUCoeff;
|
|
365
|
+
switch (primaries) {
|
|
366
|
+
case AgoraMediaBase_1.PrimaryID.PrimaryidBt709:
|
|
367
|
+
if (range === AgoraMediaBase_1.RangeID.RangeidFull) {
|
|
368
|
+
// BT.709 Full Range
|
|
369
|
+
rVCoeff = 1.5748;
|
|
370
|
+
gUCoeff = -0.187324;
|
|
371
|
+
gVCoeff = -0.468124;
|
|
372
|
+
bUCoeff = 1.8556;
|
|
373
|
+
}
|
|
374
|
+
else {
|
|
375
|
+
// BT.709 Limited Range
|
|
376
|
+
rVCoeff = 1.792741;
|
|
377
|
+
gUCoeff = -0.213249;
|
|
378
|
+
gVCoeff = -0.532909;
|
|
379
|
+
bUCoeff = 2.112402;
|
|
380
|
+
}
|
|
381
|
+
break;
|
|
382
|
+
case AgoraMediaBase_1.PrimaryID.PrimaryidBt2020:
|
|
383
|
+
if (range === AgoraMediaBase_1.RangeID.RangeidFull) {
|
|
384
|
+
// BT.2020 Full Range
|
|
385
|
+
rVCoeff = 1.4746;
|
|
386
|
+
gUCoeff = -0.164553;
|
|
387
|
+
gVCoeff = -0.571353;
|
|
388
|
+
bUCoeff = 1.8814;
|
|
389
|
+
}
|
|
390
|
+
else {
|
|
391
|
+
// BT.2020 Limited Range
|
|
392
|
+
rVCoeff = 1.678674;
|
|
393
|
+
gUCoeff = -0.187326;
|
|
394
|
+
gVCoeff = -0.650424;
|
|
395
|
+
bUCoeff = 2.141772;
|
|
396
|
+
}
|
|
397
|
+
break;
|
|
398
|
+
case AgoraMediaBase_1.PrimaryID.PrimaryidSmpte170m || AgoraMediaBase_1.PrimaryID.PrimaryidBt470bg:
|
|
399
|
+
if (range === AgoraMediaBase_1.RangeID.RangeidFull) {
|
|
400
|
+
// BT.601 Full Range
|
|
401
|
+
rVCoeff = 1.402;
|
|
402
|
+
gUCoeff = -0.344136;
|
|
403
|
+
gVCoeff = -0.714136;
|
|
404
|
+
bUCoeff = 1.772;
|
|
405
|
+
}
|
|
406
|
+
else {
|
|
407
|
+
// BT.601 Limited Range
|
|
408
|
+
rVCoeff = 1.596027;
|
|
409
|
+
gUCoeff = -0.391762;
|
|
410
|
+
gVCoeff = -0.812968;
|
|
411
|
+
bUCoeff = 2.017232;
|
|
412
|
+
}
|
|
413
|
+
break;
|
|
414
|
+
default:
|
|
415
|
+
if (range === AgoraMediaBase_1.RangeID.RangeidFull) {
|
|
416
|
+
// BT.601 Full Range
|
|
417
|
+
rVCoeff = 1.402;
|
|
418
|
+
gUCoeff = -0.344136;
|
|
419
|
+
gVCoeff = -0.714136;
|
|
420
|
+
bUCoeff = 1.772;
|
|
421
|
+
}
|
|
422
|
+
else {
|
|
423
|
+
// BT.601 Limited Range (your original values)
|
|
424
|
+
rVCoeff = 1.596027;
|
|
425
|
+
gUCoeff = -0.391762;
|
|
426
|
+
gVCoeff = -0.812968;
|
|
427
|
+
bUCoeff = 2.017232;
|
|
428
|
+
}
|
|
429
|
+
break;
|
|
430
|
+
}
|
|
431
|
+
return {
|
|
432
|
+
yOffset,
|
|
433
|
+
yScale,
|
|
434
|
+
rVCoeff,
|
|
435
|
+
gUCoeff,
|
|
436
|
+
gVCoeff,
|
|
437
|
+
bUCoeff,
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Set color space uniform values in the shader
|
|
442
|
+
*/
|
|
443
|
+
setColorSpaceUniforms(colorSpace) {
|
|
444
|
+
if (!this.gl || !this.program)
|
|
445
|
+
return;
|
|
446
|
+
const params = this.getColorSpaceParams(colorSpace);
|
|
447
|
+
if (this.colorSpaceUniforms.yOffset) {
|
|
448
|
+
this.gl.uniform1f(this.colorSpaceUniforms.yOffset, params.yOffset);
|
|
449
|
+
}
|
|
450
|
+
if (this.colorSpaceUniforms.yScale) {
|
|
451
|
+
this.gl.uniform1f(this.colorSpaceUniforms.yScale, params.yScale);
|
|
452
|
+
}
|
|
453
|
+
if (this.colorSpaceUniforms.rVCoeff) {
|
|
454
|
+
this.gl.uniform1f(this.colorSpaceUniforms.rVCoeff, params.rVCoeff);
|
|
455
|
+
}
|
|
456
|
+
if (this.colorSpaceUniforms.gUCoeff) {
|
|
457
|
+
this.gl.uniform1f(this.colorSpaceUniforms.gUCoeff, params.gUCoeff);
|
|
458
|
+
}
|
|
459
|
+
if (this.colorSpaceUniforms.gVCoeff) {
|
|
460
|
+
this.gl.uniform1f(this.colorSpaceUniforms.gVCoeff, params.gVCoeff);
|
|
461
|
+
}
|
|
462
|
+
if (this.colorSpaceUniforms.bUCoeff) {
|
|
463
|
+
this.gl.uniform1f(this.colorSpaceUniforms.bUCoeff, params.bUCoeff);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
exports.WebGLRenderer = WebGLRenderer;
|