agora-electron-sdk 0.0.0-dev.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 +315 -0
- package/LICENSE +21 -0
- package/README.md +143 -0
- package/gulpfile.js +52 -0
- package/js/AgoraSdk.js +64 -0
- package/js/Decoder/gpu-utils.js +74 -0
- package/js/Decoder/index.js +172 -0
- package/js/Private/AgoraBase.js +3985 -0
- package/js/Private/AgoraMediaBase.js +1014 -0
- package/js/Private/AgoraMediaPlayerTypes.js +316 -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 +157 -0
- package/js/Private/IAgoraRhythmPlayer.js +62 -0
- package/js/Private/IAgoraRtcEngine.js +982 -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 +950 -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 +1042 -0
- package/js/Private/impl/IAgoraRtcEngineImpl.js +5167 -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 +424 -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 +430 -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 +141 -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 +161 -0
- package/js/Renderer/CapabilityManager.js +99 -0
- package/js/Renderer/IRenderer.js +136 -0
- package/js/Renderer/IRendererCache.js +75 -0
- package/js/Renderer/RendererCache.js +100 -0
- package/js/Renderer/RendererManager.js +301 -0
- package/js/Renderer/WebCodecsRenderer/index.js +109 -0
- package/js/Renderer/WebCodecsRendererCache.js +115 -0
- package/js/Renderer/WebGLRenderer/index.js +314 -0
- package/js/Renderer/WebGLRenderer/webgl-utils.js +1337 -0
- package/js/Renderer/YUVCanvasRenderer/index.js +46 -0
- package/js/Renderer/index.js +17 -0
- package/js/Types.js +67 -0
- package/js/Utils.js +187 -0
- package/package.json +167 -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 +105 -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 +54 -0
- package/ts/Decoder/gpu-utils.ts +92 -0
- package/ts/Decoder/index.ts +206 -0
- package/ts/Private/AgoraBase.ts +5511 -0
- package/ts/Private/AgoraMediaBase.ts +1764 -0
- package/ts/Private/AgoraMediaPlayerTypes.ts +464 -0
- package/ts/Private/IAgoraH265Transcoder.ts +73 -0
- package/ts/Private/IAgoraLog.ts +91 -0
- package/ts/Private/IAgoraMediaEngine.ts +316 -0
- package/ts/Private/IAgoraMediaPlayer.ts +744 -0
- package/ts/Private/IAgoraMediaPlayerSource.ts +137 -0
- package/ts/Private/IAgoraMediaRecorder.ts +25 -0
- package/ts/Private/IAgoraMediaStreamingSource.ts +81 -0
- package/ts/Private/IAgoraMusicContentCenter.ts +455 -0
- package/ts/Private/IAgoraRhythmPlayer.ts +67 -0
- package/ts/Private/IAgoraRtcEngine.ts +7306 -0
- package/ts/Private/IAgoraRtcEngineEx.ts +992 -0
- package/ts/Private/IAgoraSpatialAudio.ts +250 -0
- package/ts/Private/IAudioDeviceManager.ts +342 -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 +237 -0
- package/ts/Private/impl/IAgoraH265TranscoderImpl.ts +152 -0
- package/ts/Private/impl/IAgoraMediaEngineImpl.ts +491 -0
- package/ts/Private/impl/IAgoraMediaPlayerImpl.ts +1169 -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 +1672 -0
- package/ts/Private/impl/IAgoraRtcEngineImpl.ts +7352 -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 +598 -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 +647 -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 +119 -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 +235 -0
- package/ts/Renderer/CapabilityManager.ts +126 -0
- package/ts/Renderer/IRenderer.ts +158 -0
- package/ts/Renderer/IRendererCache.ts +96 -0
- package/ts/Renderer/RendererCache.ts +124 -0
- package/ts/Renderer/RendererManager.ts +400 -0
- package/ts/Renderer/WebCodecsRenderer/index.ts +145 -0
- package/ts/Renderer/WebCodecsRendererCache.ts +137 -0
- package/ts/Renderer/WebGLRenderer/index.ts +489 -0
- package/ts/Renderer/WebGLRenderer/webgl-utils.js +1510 -0
- package/ts/Renderer/YUVCanvasRenderer/index.ts +67 -0
- package/ts/Renderer/index.ts +1 -0
- package/ts/Types.ts +249 -0
- package/ts/Utils.ts +197 -0
- package/types/AgoraSdk.d.ts +40 -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 +5310 -0
- package/types/Private/AgoraBase.d.ts.map +1 -0
- package/types/Private/AgoraMediaBase.d.ts +1668 -0
- package/types/Private/AgoraMediaBase.d.ts.map +1 -0
- package/types/Private/AgoraMediaPlayerTypes.d.ts +453 -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 +89 -0
- package/types/Private/IAgoraLog.d.ts.map +1 -0
- package/types/Private/IAgoraMediaEngine.d.ts +250 -0
- package/types/Private/IAgoraMediaEngine.d.ts.map +1 -0
- package/types/Private/IAgoraMediaPlayer.d.ts +648 -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 +20 -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 +381 -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 +6103 -0
- package/types/Private/IAgoraRtcEngine.d.ts.map +1 -0
- package/types/Private/IAgoraRtcEngineEx.d.ts +741 -0
- package/types/Private/IAgoraRtcEngineEx.d.ts.map +1 -0
- package/types/Private/IAgoraSpatialAudio.d.ts +196 -0
- package/types/Private/IAgoraSpatialAudio.d.ts.map +1 -0
- package/types/Private/IAudioDeviceManager.d.ts +312 -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 +143 -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 +116 -0
- package/types/Private/impl/IAgoraRtcEngineExImpl.d.ts.map +1 -0
- package/types/Private/impl/IAgoraRtcEngineImpl.d.ts +628 -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 +73 -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 +76 -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 +26 -0
- package/types/Renderer/IRendererCache.d.ts.map +1 -0
- package/types/Renderer/RendererCache.d.ts +24 -0
- package/types/Renderer/RendererCache.d.ts.map +1 -0
- package/types/Renderer/RendererManager.d.ts +66 -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 +15 -0
- package/types/Renderer/WebCodecsRendererCache.d.ts.map +1 -0
- package/types/Renderer/WebGLRenderer/index.d.ts +27 -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 +9 -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 +177 -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,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WebCodecsRenderer = void 0;
|
|
4
|
+
const Types_1 = require("../../Types");
|
|
5
|
+
const Utils_1 = require("../../Utils");
|
|
6
|
+
const IRenderer_1 = require("../IRenderer");
|
|
7
|
+
class WebCodecsRenderer extends IRenderer_1.IRenderer {
|
|
8
|
+
constructor() {
|
|
9
|
+
super();
|
|
10
|
+
this.rendererType = Types_1.RendererType.WEBCODECSRENDERER;
|
|
11
|
+
}
|
|
12
|
+
bind(element) {
|
|
13
|
+
super.bind(element);
|
|
14
|
+
if (!this.canvas)
|
|
15
|
+
return;
|
|
16
|
+
this.offscreenCanvas = this.canvas.transferControlToOffscreen();
|
|
17
|
+
this.gl = (0, Utils_1.getContextByCanvas)(this.offscreenCanvas);
|
|
18
|
+
if (!this.gl)
|
|
19
|
+
return;
|
|
20
|
+
const vertexShader = this.gl.createShader(this.gl.VERTEX_SHADER);
|
|
21
|
+
if (!vertexShader)
|
|
22
|
+
return;
|
|
23
|
+
this.gl.shaderSource(vertexShader, WebCodecsRenderer.vertexShaderSource);
|
|
24
|
+
this.gl.compileShader(vertexShader);
|
|
25
|
+
if (!this.gl.getShaderParameter(vertexShader, this.gl.COMPILE_STATUS)) {
|
|
26
|
+
throw this.gl.getShaderInfoLog(vertexShader);
|
|
27
|
+
}
|
|
28
|
+
const fragmentShader = this.gl.createShader(this.gl.FRAGMENT_SHADER);
|
|
29
|
+
if (!fragmentShader)
|
|
30
|
+
return;
|
|
31
|
+
this.gl.shaderSource(fragmentShader, WebCodecsRenderer.fragmentShaderSource);
|
|
32
|
+
this.gl.compileShader(fragmentShader);
|
|
33
|
+
if (!this.gl.getShaderParameter(fragmentShader, this.gl.COMPILE_STATUS)) {
|
|
34
|
+
throw this.gl.getShaderInfoLog(fragmentShader);
|
|
35
|
+
}
|
|
36
|
+
const shaderProgram = this.gl.createProgram();
|
|
37
|
+
if (!shaderProgram)
|
|
38
|
+
return;
|
|
39
|
+
this.gl.attachShader(shaderProgram, vertexShader);
|
|
40
|
+
this.gl.attachShader(shaderProgram, fragmentShader);
|
|
41
|
+
this.gl.linkProgram(shaderProgram);
|
|
42
|
+
if (!this.gl.getProgramParameter(shaderProgram, this.gl.LINK_STATUS)) {
|
|
43
|
+
throw this.gl.getProgramInfoLog(shaderProgram);
|
|
44
|
+
}
|
|
45
|
+
this.gl.useProgram(shaderProgram);
|
|
46
|
+
// Vertex coordinates, clockwise from bottom-left.
|
|
47
|
+
const vertexBuffer = this.gl.createBuffer();
|
|
48
|
+
this.gl.bindBuffer(this.gl.ARRAY_BUFFER, vertexBuffer);
|
|
49
|
+
this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array([-1.0, -1.0, -1.0, +1.0, +1.0, +1.0, +1.0, -1.0]), this.gl.STATIC_DRAW);
|
|
50
|
+
const xyLocation = this.gl.getAttribLocation(shaderProgram, 'xy');
|
|
51
|
+
this.gl.vertexAttribPointer(xyLocation, 2, this.gl.FLOAT, false, 0, 0);
|
|
52
|
+
this.gl.enableVertexAttribArray(xyLocation);
|
|
53
|
+
// Create one texture to upload frames to.
|
|
54
|
+
const texture = this.gl.createTexture();
|
|
55
|
+
this.gl.bindTexture(this.gl.TEXTURE_2D, texture);
|
|
56
|
+
this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MAG_FILTER, this.gl.NEAREST);
|
|
57
|
+
this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MIN_FILTER, this.gl.NEAREST);
|
|
58
|
+
this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_S, this.gl.CLAMP_TO_EDGE);
|
|
59
|
+
this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_T, this.gl.CLAMP_TO_EDGE);
|
|
60
|
+
}
|
|
61
|
+
drawFrame(frame, _codecConfig) {
|
|
62
|
+
if (!this.offscreenCanvas || !frame)
|
|
63
|
+
return;
|
|
64
|
+
this.offscreenCanvas.width = _codecConfig.codedWidth;
|
|
65
|
+
this.offscreenCanvas.height = _codecConfig.codedHeight;
|
|
66
|
+
this.updateRenderMode();
|
|
67
|
+
this.rotateCanvas({
|
|
68
|
+
rotation: _codecConfig.rotation,
|
|
69
|
+
});
|
|
70
|
+
if (!this.gl)
|
|
71
|
+
return;
|
|
72
|
+
if (this.gl) {
|
|
73
|
+
// Upload the frame.
|
|
74
|
+
this.gl.texImage2D(this.gl.TEXTURE_2D, 0, this.gl.RGBA, this.gl.RGBA, this.gl.UNSIGNED_BYTE, frame);
|
|
75
|
+
frame.close();
|
|
76
|
+
// Configure and clear the drawing area.
|
|
77
|
+
this.gl.viewport(0, 0, this.gl.drawingBufferWidth, this.gl.drawingBufferHeight);
|
|
78
|
+
this.gl.clearColor(0.0, 0.0, 0.0, 0.0);
|
|
79
|
+
this.gl.clear(this.gl.COLOR_BUFFER_BIT);
|
|
80
|
+
// Draw the frame.
|
|
81
|
+
this.gl.drawArrays(this.gl.TRIANGLE_FAN, 0, 4);
|
|
82
|
+
}
|
|
83
|
+
super.drawFrame();
|
|
84
|
+
this.getFps();
|
|
85
|
+
}
|
|
86
|
+
rotateCanvas({ rotation }) {
|
|
87
|
+
if (!this.offscreenCanvas || !this.canvas)
|
|
88
|
+
return;
|
|
89
|
+
this.canvas.style.transform += ` rotateZ(${rotation}deg)`;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
exports.WebCodecsRenderer = WebCodecsRenderer;
|
|
93
|
+
WebCodecsRenderer.vertexShaderSource = `
|
|
94
|
+
attribute vec2 xy;
|
|
95
|
+
varying highp vec2 uv;
|
|
96
|
+
void main(void) {
|
|
97
|
+
gl_Position = vec4(xy, 0.0, 1.0);
|
|
98
|
+
// Map vertex coordinates (-1 to +1) to UV coordinates (0 to 1).
|
|
99
|
+
// UV coordinates are Y-flipped relative to vertex coordinates.
|
|
100
|
+
uv = vec2((1.0 + xy.x) / 2.0, (1.0 - xy.y) / 2.0);
|
|
101
|
+
}
|
|
102
|
+
`;
|
|
103
|
+
WebCodecsRenderer.fragmentShaderSource = `
|
|
104
|
+
varying highp vec2 uv;
|
|
105
|
+
uniform sampler2D texture;
|
|
106
|
+
void main(void) {
|
|
107
|
+
gl_FragColor = texture2D(texture, uv);
|
|
108
|
+
}
|
|
109
|
+
`;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.WebCodecsRendererCache = void 0;
|
|
7
|
+
const AgoraSdk_1 = __importDefault(require("../AgoraSdk"));
|
|
8
|
+
const index_1 = require("../Decoder/index");
|
|
9
|
+
const AgoraBase_1 = require("../Private/AgoraBase");
|
|
10
|
+
const IrisApiEngine_1 = require("../Private/internal/IrisApiEngine");
|
|
11
|
+
const Types_1 = require("../Types");
|
|
12
|
+
const Utils_1 = require("../Utils");
|
|
13
|
+
const IRendererCache_1 = require("./IRendererCache");
|
|
14
|
+
class WebCodecsRendererCache extends IRendererCache_1.IRendererCache {
|
|
15
|
+
constructor(context) {
|
|
16
|
+
super(context);
|
|
17
|
+
this._firstFrame = true;
|
|
18
|
+
this._engine = (0, AgoraSdk_1.default)();
|
|
19
|
+
this._decoder = new index_1.WebCodecsDecoder(this.renderers, this.onDecoderError.bind(this), context);
|
|
20
|
+
this.draw();
|
|
21
|
+
}
|
|
22
|
+
onDecoderError(e) {
|
|
23
|
+
(0, Utils_1.logInfo)('webCodecsDecoder decode failed, fallback to native decoder', e);
|
|
24
|
+
Utils_1.AgoraEnv.AgoraRendererManager?.handleWebCodecsFallback(this.cacheContext);
|
|
25
|
+
}
|
|
26
|
+
onEncodedVideoFrameReceived(...[data, buffer]) {
|
|
27
|
+
let _data;
|
|
28
|
+
try {
|
|
29
|
+
_data = JSON.parse(data) ?? {};
|
|
30
|
+
}
|
|
31
|
+
catch (e) {
|
|
32
|
+
_data = {};
|
|
33
|
+
}
|
|
34
|
+
if (Object.keys(_data).length === 0 ||
|
|
35
|
+
!this._decoder ||
|
|
36
|
+
this.cacheContext.uid !== _data.uid)
|
|
37
|
+
return;
|
|
38
|
+
if (this._firstFrame) {
|
|
39
|
+
for (let renderer of this.renderers) {
|
|
40
|
+
if (renderer.rendererType !== Types_1.RendererType.WEBCODECSRENDERER) {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
renderer.bind(renderer.context.view);
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
this._decoder.decoderConfigure(_data.videoEncodedFrameInfo);
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
(0, Utils_1.logInfo)(error);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
this._firstFrame = false;
|
|
53
|
+
}
|
|
54
|
+
if (this.shouldFallback(_data.videoEncodedFrameInfo)) {
|
|
55
|
+
Utils_1.AgoraEnv.AgoraRendererManager?.handleWebCodecsFallback(this.cacheContext);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
this._decoder.decodeFrame(buffer, _data.videoEncodedFrameInfo, new Date().getTime());
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
draw() {
|
|
62
|
+
if ((0, IRendererCache_1.isUseConnection)(this.cacheContext)) {
|
|
63
|
+
this._engine?.setRemoteVideoSubscriptionOptionsEx(this.cacheContext.uid, {
|
|
64
|
+
type: AgoraBase_1.VideoStreamType.VideoStreamHigh,
|
|
65
|
+
encodedFrameOnly: true,
|
|
66
|
+
}, {
|
|
67
|
+
channelId: this.cacheContext.channelId,
|
|
68
|
+
localUid: this.cacheContext.localUid,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
this._engine?.setRemoteVideoSubscriptionOptions(this.cacheContext.uid, {
|
|
73
|
+
type: AgoraBase_1.VideoStreamType.VideoStreamHigh,
|
|
74
|
+
encodedFrameOnly: true,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
IrisApiEngine_1.AgoraElectronBridge.OnEvent(`call_back_with_encoded_video_frame_${this.cacheContext.uid}`, (...params) => {
|
|
78
|
+
try {
|
|
79
|
+
this.onEncodedVideoFrameReceived(...params);
|
|
80
|
+
}
|
|
81
|
+
catch (e) {
|
|
82
|
+
console.error(e);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
shouldFallback(frameInfo) {
|
|
87
|
+
let shouldFallback = false;
|
|
88
|
+
if (!frameInfo.codecType) {
|
|
89
|
+
shouldFallback = true;
|
|
90
|
+
(0, Utils_1.logInfo)('codecType is not supported, fallback to native decoder');
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
const mapping = Utils_1.AgoraEnv.CapabilityManager?.frameCodecMapping[frameInfo.codecType];
|
|
94
|
+
if (mapping === undefined) {
|
|
95
|
+
shouldFallback = true;
|
|
96
|
+
(0, Utils_1.logInfo)('codecType is not supported, fallback to native decoder');
|
|
97
|
+
}
|
|
98
|
+
else if (mapping.minWidth >= frameInfo.width &&
|
|
99
|
+
mapping.minHeight >= frameInfo.height &&
|
|
100
|
+
mapping.maxWidth <= frameInfo.width &&
|
|
101
|
+
mapping.maxHeight <= frameInfo.height) {
|
|
102
|
+
shouldFallback = true;
|
|
103
|
+
(0, Utils_1.logInfo)('frame size is not supported, fallback to native decoder');
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return shouldFallback;
|
|
107
|
+
}
|
|
108
|
+
release() {
|
|
109
|
+
IrisApiEngine_1.AgoraElectronBridge.UnEvent(`call_back_with_encoded_video_frame_${this.cacheContext.uid}`);
|
|
110
|
+
this._decoder?.release();
|
|
111
|
+
this._decoder = null;
|
|
112
|
+
super.release();
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
exports.WebCodecsRendererCache = WebCodecsRendererCache;
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WebGLRenderer = void 0;
|
|
4
|
+
const Types_1 = require("../../Types");
|
|
5
|
+
const Utils_1 = require("../../Utils");
|
|
6
|
+
const IRenderer_1 = require("../IRenderer");
|
|
7
|
+
const createProgramFromSources = require('./webgl-utils').createProgramFromSources;
|
|
8
|
+
const vertexShaderSource = `
|
|
9
|
+
attribute vec2 a_position;
|
|
10
|
+
attribute vec2 a_texCoord;
|
|
11
|
+
uniform vec2 u_resolution;
|
|
12
|
+
varying vec2 v_texCoord;
|
|
13
|
+
void main() {
|
|
14
|
+
vec2 zeroToOne = a_position / u_resolution;
|
|
15
|
+
vec2 zeroToTwo = zeroToOne * 2.0;
|
|
16
|
+
vec2 clipSpace = zeroToTwo - 1.0;
|
|
17
|
+
gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1);
|
|
18
|
+
v_texCoord = a_texCoord;
|
|
19
|
+
}`;
|
|
20
|
+
const yuvShaderSource = `
|
|
21
|
+
precision mediump float;
|
|
22
|
+
uniform sampler2D Ytex;
|
|
23
|
+
uniform sampler2D Utex;
|
|
24
|
+
uniform sampler2D Vtex;
|
|
25
|
+
uniform sampler2D Atex;
|
|
26
|
+
uniform bool hasAlpha;
|
|
27
|
+
varying vec2 v_texCoord;
|
|
28
|
+
void main(void) {
|
|
29
|
+
float nx,ny,r,g,b,y,u,v,a;
|
|
30
|
+
mediump vec4 txl,ux,vx;
|
|
31
|
+
nx=v_texCoord[0];
|
|
32
|
+
ny=v_texCoord[1];
|
|
33
|
+
y=texture2D(Ytex,vec2(nx,ny)).r;
|
|
34
|
+
u=texture2D(Utex,vec2(nx,ny)).r;
|
|
35
|
+
v=texture2D(Vtex,vec2(nx,ny)).r;
|
|
36
|
+
if (hasAlpha) {
|
|
37
|
+
a=texture2D(Atex,vec2(nx,ny)).r;
|
|
38
|
+
} else {
|
|
39
|
+
a=1.0;
|
|
40
|
+
}
|
|
41
|
+
y=1.1643*(y-0.0625);
|
|
42
|
+
u=u-0.5;
|
|
43
|
+
v=v-0.5;
|
|
44
|
+
r=y+1.5958*v;
|
|
45
|
+
g=y-0.39173*u-0.81290*v;
|
|
46
|
+
b=y+2.017*u;
|
|
47
|
+
gl_FragColor=vec4(r,g,b,a);
|
|
48
|
+
}`;
|
|
49
|
+
class WebGLRenderer extends IRenderer_1.IRenderer {
|
|
50
|
+
constructor(fallback) {
|
|
51
|
+
super();
|
|
52
|
+
this.handleContextLost = (event) => {
|
|
53
|
+
event.preventDefault();
|
|
54
|
+
(0, Utils_1.logWarn)('webglcontextlost', event);
|
|
55
|
+
this.releaseTextures();
|
|
56
|
+
this.fallback?.call(null, this, new Error('Browser not support! No WebGL detected.'));
|
|
57
|
+
};
|
|
58
|
+
this.handleContextRestored = (event) => {
|
|
59
|
+
event.preventDefault();
|
|
60
|
+
(0, Utils_1.logWarn)('webglcontextrestored', event);
|
|
61
|
+
// Setup GLSL program
|
|
62
|
+
this.program = createProgramFromSources(this.gl, [
|
|
63
|
+
vertexShaderSource,
|
|
64
|
+
yuvShaderSource,
|
|
65
|
+
]);
|
|
66
|
+
this.gl?.useProgram(this.program);
|
|
67
|
+
this.initTextures();
|
|
68
|
+
};
|
|
69
|
+
this.gl = null;
|
|
70
|
+
this.rendererType = Types_1.RendererType.WEBGL;
|
|
71
|
+
this.program = null;
|
|
72
|
+
this.yTexture = null;
|
|
73
|
+
this.uTexture = null;
|
|
74
|
+
this.vTexture = null;
|
|
75
|
+
this.aTexture = null;
|
|
76
|
+
this.hasAlpha = null;
|
|
77
|
+
this.texCoordBuffer = null;
|
|
78
|
+
this.surfaceBuffer = null;
|
|
79
|
+
this.fallback = fallback;
|
|
80
|
+
}
|
|
81
|
+
bind(view) {
|
|
82
|
+
super.bind(view);
|
|
83
|
+
this.canvas?.addEventListener('webglcontextlost', this.handleContextLost, false);
|
|
84
|
+
this.canvas?.addEventListener('webglcontextrestored', this.handleContextRestored, false);
|
|
85
|
+
const getContext = (contextNames = ['webgl2', 'webgl', 'experimental-webgl']) => {
|
|
86
|
+
for (let i = 0; i < contextNames.length; i++) {
|
|
87
|
+
const contextName = contextNames[i];
|
|
88
|
+
const context = this.canvas?.getContext(contextName, {
|
|
89
|
+
depth: true,
|
|
90
|
+
stencil: true,
|
|
91
|
+
alpha: true,
|
|
92
|
+
antialias: false,
|
|
93
|
+
premultipliedAlpha: true,
|
|
94
|
+
preserveDrawingBuffer: !Utils_1.AgoraEnv.encodeAlpha,
|
|
95
|
+
powerPreference: 'default',
|
|
96
|
+
failIfMajorPerformanceCaveat: false,
|
|
97
|
+
});
|
|
98
|
+
if (context) {
|
|
99
|
+
return context;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return null;
|
|
103
|
+
};
|
|
104
|
+
this.gl ?? (this.gl = getContext());
|
|
105
|
+
if (!this.gl) {
|
|
106
|
+
this.fallback?.call(null, this, new Error('Browser not support! No WebGL detected.'));
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
// Set clear color to black, fully opaque
|
|
110
|
+
this.gl.clearColor(0.0, 0.0, 0.0, 0.0);
|
|
111
|
+
// Enable depth testing
|
|
112
|
+
this.gl.enable(this.gl.DEPTH_TEST);
|
|
113
|
+
// Near things obscure far things
|
|
114
|
+
this.gl.depthFunc(this.gl.LEQUAL);
|
|
115
|
+
// Enable blending
|
|
116
|
+
this.gl.enable(this.gl.BLEND);
|
|
117
|
+
// Set blending function
|
|
118
|
+
this.gl.blendFunc(this.gl.SRC_ALPHA, this.gl.ONE_MINUS_SRC_ALPHA);
|
|
119
|
+
// Clear the color as well as the depth buffer.
|
|
120
|
+
this.gl.clear(this.gl.COLOR_BUFFER_BIT |
|
|
121
|
+
this.gl.DEPTH_BUFFER_BIT |
|
|
122
|
+
this.gl.STENCIL_BUFFER_BIT);
|
|
123
|
+
// Setup GLSL program
|
|
124
|
+
this.program = createProgramFromSources(this.gl, [
|
|
125
|
+
vertexShaderSource,
|
|
126
|
+
yuvShaderSource,
|
|
127
|
+
]);
|
|
128
|
+
this.gl.useProgram(this.program);
|
|
129
|
+
this.initTextures();
|
|
130
|
+
}
|
|
131
|
+
unbind() {
|
|
132
|
+
this.canvas?.removeEventListener('webglcontextlost', this.handleContextLost, false);
|
|
133
|
+
this.canvas?.removeEventListener('webglcontextrestored', this.handleContextRestored, false);
|
|
134
|
+
this.releaseTextures();
|
|
135
|
+
this.gl = null;
|
|
136
|
+
super.unbind();
|
|
137
|
+
}
|
|
138
|
+
drawFrame({ width, height, yStride, uStride, vStride, yBuffer, uBuffer, vBuffer, rotation, alphaBuffer, }) {
|
|
139
|
+
this.rotateCanvas({ width, height, rotation });
|
|
140
|
+
this.updateRenderMode();
|
|
141
|
+
if (!this.gl || !this.program)
|
|
142
|
+
return;
|
|
143
|
+
const left = 0, top = 0, right = yStride - width, bottom = 0;
|
|
144
|
+
this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.texCoordBuffer);
|
|
145
|
+
const xWidth = width + left + right;
|
|
146
|
+
const xHeight = height + top + bottom;
|
|
147
|
+
this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array([
|
|
148
|
+
left / xWidth,
|
|
149
|
+
bottom / xHeight,
|
|
150
|
+
1 - right / xWidth,
|
|
151
|
+
bottom / xHeight,
|
|
152
|
+
left / xWidth,
|
|
153
|
+
1 - top / xHeight,
|
|
154
|
+
left / xWidth,
|
|
155
|
+
1 - top / xHeight,
|
|
156
|
+
1 - right / xWidth,
|
|
157
|
+
bottom / xHeight,
|
|
158
|
+
1 - right / xWidth,
|
|
159
|
+
1 - top / xHeight,
|
|
160
|
+
]), this.gl.STATIC_DRAW);
|
|
161
|
+
this.gl.enableVertexAttribArray(this.texCoordLocation);
|
|
162
|
+
this.gl.vertexAttribPointer(this.texCoordLocation, 2, this.gl.FLOAT, false, 0, 0);
|
|
163
|
+
this.gl.pixelStorei(this.gl.UNPACK_ALIGNMENT, 1);
|
|
164
|
+
const activeTexture = (textureIndex, { texture, stride, height, pixels }) => {
|
|
165
|
+
if (!this.gl)
|
|
166
|
+
return;
|
|
167
|
+
this.gl.activeTexture(textureIndex);
|
|
168
|
+
this.gl.bindTexture(this.gl.TEXTURE_2D, texture);
|
|
169
|
+
this.gl.texImage2D(this.gl.TEXTURE_2D, 0, this.gl.LUMINANCE, stride, height, 0, this.gl.LUMINANCE, this.gl.UNSIGNED_BYTE, pixels);
|
|
170
|
+
};
|
|
171
|
+
const textures = {
|
|
172
|
+
[this.gl.TEXTURE0]: {
|
|
173
|
+
texture: this.yTexture,
|
|
174
|
+
stride: yStride,
|
|
175
|
+
height: height,
|
|
176
|
+
pixels: yBuffer,
|
|
177
|
+
},
|
|
178
|
+
[this.gl.TEXTURE1]: {
|
|
179
|
+
texture: this.uTexture,
|
|
180
|
+
stride: uStride,
|
|
181
|
+
height: height / 2,
|
|
182
|
+
pixels: uBuffer,
|
|
183
|
+
},
|
|
184
|
+
[this.gl.TEXTURE2]: {
|
|
185
|
+
texture: this.vTexture,
|
|
186
|
+
stride: vStride,
|
|
187
|
+
height: height / 2,
|
|
188
|
+
pixels: vBuffer,
|
|
189
|
+
},
|
|
190
|
+
};
|
|
191
|
+
if (alphaBuffer) {
|
|
192
|
+
textures[this.gl.TEXTURE3] = {
|
|
193
|
+
texture: this.aTexture,
|
|
194
|
+
stride: width,
|
|
195
|
+
height: height,
|
|
196
|
+
pixels: alphaBuffer,
|
|
197
|
+
};
|
|
198
|
+
this.gl.uniform1i(this.hasAlpha, 1);
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
this.gl.uniform1i(this.hasAlpha, 0);
|
|
202
|
+
}
|
|
203
|
+
for (const textureIndex in textures) {
|
|
204
|
+
if (textures.hasOwnProperty(textureIndex)) {
|
|
205
|
+
activeTexture(+textureIndex, textures[textureIndex]);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
this.gl.drawArrays(this.gl.TRIANGLES, 0, 6);
|
|
209
|
+
super.drawFrame();
|
|
210
|
+
}
|
|
211
|
+
rotateCanvas({ width, height, rotation }) {
|
|
212
|
+
super.rotateCanvas({ width, height, rotation });
|
|
213
|
+
if (!this.gl || !this.program)
|
|
214
|
+
return;
|
|
215
|
+
this.gl.viewport(0, 0, width, height);
|
|
216
|
+
this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.surfaceBuffer);
|
|
217
|
+
this.gl.enableVertexAttribArray(this.positionLocation);
|
|
218
|
+
this.gl.vertexAttribPointer(this.positionLocation, 2, this.gl.FLOAT, false, 0, 0);
|
|
219
|
+
// 4 vertex, 1(x1,y1), 2(x2,y1), 3(x2,y2), 4(x1,y2)
|
|
220
|
+
// 0: 1,2,4/4,2,3
|
|
221
|
+
// 90: 2,3,1/1,3,4
|
|
222
|
+
// 180: 3,4,2/2,4,1
|
|
223
|
+
// 270: 4,1,3/3,1,2
|
|
224
|
+
const p1 = { x: 0, y: 0 };
|
|
225
|
+
const p2 = { x: width, y: 0 };
|
|
226
|
+
const p3 = { x: width, y: height };
|
|
227
|
+
const p4 = { x: 0, y: height };
|
|
228
|
+
let pp1 = p1, pp2 = p2, pp3 = p3, pp4 = p4;
|
|
229
|
+
switch (rotation) {
|
|
230
|
+
case 0:
|
|
231
|
+
break;
|
|
232
|
+
case 90:
|
|
233
|
+
pp1 = p2;
|
|
234
|
+
pp2 = p3;
|
|
235
|
+
pp3 = p4;
|
|
236
|
+
pp4 = p1;
|
|
237
|
+
break;
|
|
238
|
+
case 180:
|
|
239
|
+
pp1 = p3;
|
|
240
|
+
pp2 = p4;
|
|
241
|
+
pp3 = p1;
|
|
242
|
+
pp4 = p2;
|
|
243
|
+
break;
|
|
244
|
+
case 270:
|
|
245
|
+
pp1 = p4;
|
|
246
|
+
pp2 = p1;
|
|
247
|
+
pp3 = p2;
|
|
248
|
+
pp4 = p3;
|
|
249
|
+
break;
|
|
250
|
+
default:
|
|
251
|
+
}
|
|
252
|
+
this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array([
|
|
253
|
+
pp1.x,
|
|
254
|
+
pp1.y,
|
|
255
|
+
pp2.x,
|
|
256
|
+
pp2.y,
|
|
257
|
+
pp4.x,
|
|
258
|
+
pp4.y,
|
|
259
|
+
pp4.x,
|
|
260
|
+
pp4.y,
|
|
261
|
+
pp2.x,
|
|
262
|
+
pp2.y,
|
|
263
|
+
pp3.x,
|
|
264
|
+
pp3.y,
|
|
265
|
+
]), this.gl.STATIC_DRAW);
|
|
266
|
+
const resolutionLocation = this.gl.getUniformLocation(this.program, 'u_resolution');
|
|
267
|
+
this.gl.uniform2f(resolutionLocation, width, height);
|
|
268
|
+
}
|
|
269
|
+
initTextures() {
|
|
270
|
+
if (!this.gl || !this.program)
|
|
271
|
+
return;
|
|
272
|
+
this.positionLocation = this.gl.getAttribLocation(this.program, 'a_position');
|
|
273
|
+
this.texCoordLocation = this.gl.getAttribLocation(this.program, 'a_texCoord');
|
|
274
|
+
this.hasAlpha = this.gl.getUniformLocation(this.program, 'hasAlpha');
|
|
275
|
+
this.surfaceBuffer = this.gl.createBuffer();
|
|
276
|
+
this.texCoordBuffer = this.gl.createBuffer();
|
|
277
|
+
const createTexture = (texture, textureIndex, textureName) => {
|
|
278
|
+
if (!this.gl || !this.program)
|
|
279
|
+
return null;
|
|
280
|
+
// Create a texture.
|
|
281
|
+
this.gl.activeTexture(texture);
|
|
282
|
+
const textureObj = this.gl.createTexture();
|
|
283
|
+
this.gl.bindTexture(this.gl.TEXTURE_2D, textureObj);
|
|
284
|
+
// Set the parameters so we can render any size
|
|
285
|
+
this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_S, this.gl.CLAMP_TO_EDGE);
|
|
286
|
+
this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_T, this.gl.CLAMP_TO_EDGE);
|
|
287
|
+
this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MIN_FILTER, this.gl.NEAREST);
|
|
288
|
+
this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MAG_FILTER, this.gl.NEAREST);
|
|
289
|
+
this.gl.uniform1i(this.gl.getUniformLocation(this.program, textureName), textureIndex); /* Bind Ytex to texture unit index */
|
|
290
|
+
return textureObj;
|
|
291
|
+
};
|
|
292
|
+
this.yTexture = createTexture(this.gl.TEXTURE0, 0, 'Ytex');
|
|
293
|
+
this.uTexture = createTexture(this.gl.TEXTURE1, 1, 'Utex');
|
|
294
|
+
this.vTexture = createTexture(this.gl.TEXTURE2, 2, 'Vtex');
|
|
295
|
+
this.aTexture = createTexture(this.gl.TEXTURE3, 3, 'Atex');
|
|
296
|
+
}
|
|
297
|
+
releaseTextures() {
|
|
298
|
+
this.gl?.deleteProgram(this.program);
|
|
299
|
+
this.program = null;
|
|
300
|
+
this.positionLocation = undefined;
|
|
301
|
+
this.texCoordLocation = undefined;
|
|
302
|
+
this.gl?.deleteTexture(this.yTexture);
|
|
303
|
+
this.gl?.deleteTexture(this.uTexture);
|
|
304
|
+
this.gl?.deleteTexture(this.vTexture);
|
|
305
|
+
this.yTexture = null;
|
|
306
|
+
this.uTexture = null;
|
|
307
|
+
this.vTexture = null;
|
|
308
|
+
this.gl?.deleteBuffer(this.texCoordBuffer);
|
|
309
|
+
this.gl?.deleteBuffer(this.surfaceBuffer);
|
|
310
|
+
this.texCoordBuffer = null;
|
|
311
|
+
this.surfaceBuffer = null;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
exports.WebGLRenderer = WebGLRenderer;
|