agora-electron-sdk 4.2.6 → 4.3.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 +20 -0
- package/js/Private/AgoraBase.js +139 -174
- package/js/Private/AgoraMediaBase.js +49 -20
- package/js/Private/AgoraMediaPlayerTypes.js +32 -23
- package/js/Private/IAgoraH265Transcoder.js +39 -0
- package/js/Private/IAgoraMediaStreamingSource.js +32 -32
- package/js/Private/IAgoraMusicContentCenter.js +19 -19
- package/js/Private/IAgoraRhythmPlayer.js +9 -9
- package/js/Private/IAgoraRtcEngine.js +12 -12
- package/js/Private/IAgoraSpatialAudio.js +3 -31
- package/js/Private/extension/IAgoraH265TranscoderExtension.js +2 -0
- package/js/Private/impl/AgoraMediaBaseImpl.js +26 -2
- package/js/Private/impl/IAgoraH265TranscoderImpl.js +119 -0
- package/js/Private/impl/IAgoraMediaEngineImpl.js +13 -13
- package/js/Private/impl/IAgoraMediaPlayerImpl.js +92 -74
- package/js/Private/impl/IAgoraMediaPlayerSourceImpl.js +12 -2
- package/js/Private/impl/IAgoraMediaRecorderImpl.js +2 -2
- package/js/Private/impl/IAgoraMusicContentCenterImpl.js +20 -20
- package/js/Private/impl/IAgoraRtcEngineExImpl.js +66 -84
- package/js/Private/impl/IAgoraRtcEngineImpl.js +456 -440
- package/js/Private/impl/IAgoraSpatialAudioImpl.js +157 -181
- package/js/Private/impl/IAudioDeviceManagerImpl.js +22 -22
- package/js/Private/internal/AgoraH265TranscoderInternal.js +86 -0
- package/js/Private/internal/AgoraMediaBaseInternal.js +34 -0
- package/js/Private/internal/IrisApiEngine.js +35 -20
- package/js/Private/internal/LocalSpatialAudioEngineInternal.js +0 -39
- package/js/Private/internal/MediaPlayerInternal.js +22 -21
- package/js/Private/internal/MusicContentCenterInternal.js +1 -4
- package/js/Private/internal/RtcEngineExInternal.js +101 -134
- package/js/Private/ti/AgoraMediaBase-ti.js +1 -1
- package/js/Private/ti/IAgoraH265Transcoder-ti.js +40 -0
- package/js/Private/ti/IAgoraMediaPlayerSource-ti.js +4 -2
- package/js/Private/ti/IAgoraMusicContentCenter-ti.js +5 -5
- package/js/Private/ti/IAgoraRtcEngine-ti.js +12 -11
- package/js/Renderer/AgoraView.js +28 -14
- package/js/Renderer/IRenderer.js +65 -17
- package/js/Renderer/IRendererManager.js +230 -0
- package/js/Renderer/RendererCache.js +170 -0
- package/js/Renderer/RendererManager.js +49 -460
- package/js/Renderer/WebGLRenderer/index.js +82 -234
- package/js/Renderer/YUVCanvasRenderer/index.js +27 -147
- package/js/Types.js +6 -6
- package/js/Utils.js +37 -88
- package/package.json +4 -3
- package/scripts/clean.js +12 -0
- package/scripts/synclib.js +8 -2
- package/ts/Private/AgoraBase.ts +225 -201
- package/ts/Private/AgoraMediaBase.ts +63 -25
- package/ts/Private/AgoraMediaPlayerTypes.ts +67 -24
- package/ts/Private/IAgoraH265Transcoder.ts +73 -0
- package/ts/Private/IAgoraLog.ts +1 -0
- package/ts/Private/IAgoraMediaEngine.ts +12 -7
- package/ts/Private/IAgoraMediaPlayer.ts +47 -21
- package/ts/Private/IAgoraMediaPlayerSource.ts +27 -6
- package/ts/Private/IAgoraMediaStreamingSource.ts +38 -37
- package/ts/Private/IAgoraMusicContentCenter.ts +20 -20
- package/ts/Private/IAgoraRhythmPlayer.ts +7 -6
- package/ts/Private/IAgoraRtcEngine.ts +407 -364
- package/ts/Private/IAgoraRtcEngineEx.ts +25 -61
- package/ts/Private/IAgoraSpatialAudio.ts +80 -191
- package/ts/Private/IAudioDeviceManager.ts +27 -14
- package/ts/Private/extension/IAgoraH265TranscoderExtension.ts +39 -0
- package/ts/Private/impl/AgoraMediaBaseImpl.ts +25 -1
- package/ts/Private/impl/IAgoraH265TranscoderImpl.ts +152 -0
- package/ts/Private/impl/IAgoraMediaEngineImpl.ts +13 -13
- package/ts/Private/impl/IAgoraMediaPlayerImpl.ts +110 -81
- package/ts/Private/impl/IAgoraMediaPlayerSourceImpl.ts +17 -2
- package/ts/Private/impl/IAgoraMediaRecorderImpl.ts +2 -2
- package/ts/Private/impl/IAgoraMusicContentCenterImpl.ts +21 -21
- package/ts/Private/impl/IAgoraRtcEngineExImpl.ts +71 -106
- package/ts/Private/impl/IAgoraRtcEngineImpl.ts +589 -572
- package/ts/Private/impl/IAgoraSpatialAudioImpl.ts +211 -218
- package/ts/Private/impl/IAudioDeviceManagerImpl.ts +22 -22
- package/ts/Private/internal/AgoraH265TranscoderInternal.ts +97 -0
- package/ts/Private/internal/AgoraMediaBaseInternal.ts +15 -0
- package/ts/Private/internal/IrisApiEngine.ts +42 -27
- package/ts/Private/internal/LocalSpatialAudioEngineInternal.ts +1 -86
- package/ts/Private/internal/MediaPlayerInternal.ts +20 -29
- package/ts/Private/internal/MusicContentCenterInternal.ts +1 -5
- package/ts/Private/internal/RtcEngineExInternal.ts +91 -204
- package/ts/Private/ti/AgoraMediaBase-ti.ts +1 -1
- package/ts/Private/ti/IAgoraH265Transcoder-ti.ts +16 -0
- package/ts/Private/ti/IAgoraMediaPlayerSource-ti.ts +4 -2
- package/ts/Private/ti/IAgoraMusicContentCenter-ti.ts +5 -5
- package/ts/Private/ti/IAgoraRtcEngine-ti.ts +12 -11
- package/ts/Renderer/AgoraView.ts +29 -19
- package/ts/Renderer/IRenderer.ts +71 -22
- package/ts/Renderer/IRendererManager.ts +273 -19
- package/ts/Renderer/RendererCache.ts +167 -0
- package/ts/Renderer/RendererManager.ts +62 -607
- package/ts/Renderer/WebGLRenderer/index.ts +117 -295
- package/ts/Renderer/YUVCanvasRenderer/index.ts +45 -198
- package/ts/Types.ts +17 -194
- package/ts/Utils.ts +36 -100
- package/types/Private/AgoraBase.d.ts +219 -200
- package/types/Private/AgoraBase.d.ts.map +1 -1
- package/types/Private/AgoraMediaBase.d.ts +63 -27
- package/types/Private/AgoraMediaBase.d.ts.map +1 -1
- package/types/Private/AgoraMediaPlayerTypes.d.ts +65 -24
- package/types/Private/AgoraMediaPlayerTypes.d.ts.map +1 -1
- package/types/Private/IAgoraH265Transcoder.d.ts +28 -0
- package/types/Private/IAgoraH265Transcoder.d.ts.map +1 -0
- package/types/Private/IAgoraLog.d.ts.map +1 -1
- package/types/Private/IAgoraMediaEngine.d.ts +11 -6
- package/types/Private/IAgoraMediaEngine.d.ts.map +1 -1
- package/types/Private/IAgoraMediaPlayer.d.ts +42 -20
- package/types/Private/IAgoraMediaPlayer.d.ts.map +1 -1
- package/types/Private/IAgoraMediaPlayerSource.d.ts +23 -6
- package/types/Private/IAgoraMediaPlayerSource.d.ts.map +1 -1
- package/types/Private/IAgoraMediaStreamingSource.d.ts.map +1 -1
- package/types/Private/IAgoraMusicContentCenter.d.ts +19 -19
- package/types/Private/IAgoraMusicContentCenter.d.ts.map +1 -1
- package/types/Private/IAgoraRhythmPlayer.d.ts +6 -6
- package/types/Private/IAgoraRhythmPlayer.d.ts.map +1 -1
- package/types/Private/IAgoraRtcEngine.d.ts +329 -293
- package/types/Private/IAgoraRtcEngine.d.ts.map +1 -1
- package/types/Private/IAgoraRtcEngineEx.d.ts +21 -53
- package/types/Private/IAgoraRtcEngineEx.d.ts.map +1 -1
- package/types/Private/IAgoraSpatialAudio.d.ts +56 -167
- package/types/Private/IAgoraSpatialAudio.d.ts.map +1 -1
- package/types/Private/IAudioDeviceManager.d.ts +27 -14
- package/types/Private/IAudioDeviceManager.d.ts.map +1 -1
- package/types/Private/extension/IAgoraH265TranscoderExtension.d.ts +24 -0
- package/types/Private/extension/IAgoraH265TranscoderExtension.d.ts.map +1 -0
- package/types/Private/impl/AgoraMediaBaseImpl.d.ts +5 -1
- package/types/Private/impl/AgoraMediaBaseImpl.d.ts.map +1 -1
- package/types/Private/impl/IAgoraH265TranscoderImpl.d.ts +15 -0
- package/types/Private/impl/IAgoraH265TranscoderImpl.d.ts.map +1 -0
- package/types/Private/impl/IAgoraMediaPlayerImpl.d.ts +6 -4
- package/types/Private/impl/IAgoraMediaPlayerImpl.d.ts.map +1 -1
- package/types/Private/impl/IAgoraMediaPlayerSourceImpl.d.ts.map +1 -1
- package/types/Private/impl/IAgoraRtcEngineExImpl.d.ts +2 -4
- package/types/Private/impl/IAgoraRtcEngineExImpl.d.ts.map +1 -1
- package/types/Private/impl/IAgoraRtcEngineImpl.d.ts +30 -25
- package/types/Private/impl/IAgoraRtcEngineImpl.d.ts.map +1 -1
- package/types/Private/impl/IAgoraSpatialAudioImpl.d.ts +20 -22
- package/types/Private/impl/IAgoraSpatialAudioImpl.d.ts.map +1 -1
- 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/IrisApiEngine.d.ts +5 -2
- package/types/Private/internal/IrisApiEngine.d.ts.map +1 -1
- package/types/Private/internal/LocalSpatialAudioEngineInternal.d.ts +0 -15
- package/types/Private/internal/LocalSpatialAudioEngineInternal.d.ts.map +1 -1
- package/types/Private/internal/MediaPlayerInternal.d.ts.map +1 -1
- package/types/Private/internal/MusicContentCenterInternal.d.ts +0 -1
- package/types/Private/internal/MusicContentCenterInternal.d.ts.map +1 -1
- package/types/Private/internal/RtcEngineExInternal.d.ts +7 -13
- package/types/Private/internal/RtcEngineExInternal.d.ts.map +1 -1
- 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/IAgoraMediaPlayerSource-ti.d.ts.map +1 -1
- package/types/Private/ti/IAgoraRtcEngine-ti.d.ts.map +1 -1
- package/types/Renderer/AgoraView.d.ts +4 -4
- package/types/Renderer/AgoraView.d.ts.map +1 -1
- package/types/Renderer/IRenderer.d.ts +11 -9
- package/types/Renderer/IRenderer.d.ts.map +1 -1
- package/types/Renderer/IRendererManager.d.ts +50 -12
- package/types/Renderer/IRendererManager.d.ts.map +1 -1
- package/types/Renderer/RendererCache.d.ts +36 -0
- package/types/Renderer/RendererCache.d.ts.map +1 -0
- package/types/Renderer/RendererManager.d.ts +13 -139
- package/types/Renderer/RendererManager.d.ts.map +1 -1
- package/types/Renderer/WebGLRenderer/index.d.ts +3 -18
- package/types/Renderer/WebGLRenderer/index.d.ts.map +1 -1
- package/types/Renderer/YUVCanvasRenderer/index.d.ts +4 -10
- package/types/Renderer/YUVCanvasRenderer/index.d.ts.map +1 -1
- package/types/Types.d.ts +11 -187
- package/types/Types.d.ts.map +1 -1
- package/types/Utils.d.ts +3 -20
- package/types/Utils.d.ts.map +1 -1
|
@@ -1,217 +1,64 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import { RenderModeType } from '../../Private/AgoraMediaBase';
|
|
4
|
-
import { CanvasOptions, ShareVideoFrame } from '../../Types';
|
|
1
|
+
import { VideoFrame } from '../../Private/AgoraMediaBase';
|
|
5
2
|
import { IRenderer } from '../IRenderer';
|
|
6
3
|
|
|
7
4
|
const YUVBuffer = require('yuv-buffer');
|
|
8
5
|
const YUVCanvas = require('yuv-canvas');
|
|
9
6
|
|
|
10
7
|
export class YUVCanvasRenderer extends IRenderer {
|
|
11
|
-
private
|
|
12
|
-
private _yuvCanvasSink?: any;
|
|
13
|
-
private _videoFrame: ShareVideoFrame;
|
|
14
|
-
|
|
15
|
-
constructor() {
|
|
16
|
-
super();
|
|
17
|
-
this._videoFrame = {
|
|
18
|
-
rotation: 0,
|
|
19
|
-
width: 0,
|
|
20
|
-
height: 0,
|
|
21
|
-
yStride: 0,
|
|
22
|
-
yBuffer: new Uint8Array(0),
|
|
23
|
-
uBuffer: new Uint8Array(0),
|
|
24
|
-
vBuffer: new Uint8Array(0),
|
|
25
|
-
};
|
|
26
|
-
}
|
|
8
|
+
private frameSink?: any;
|
|
27
9
|
|
|
28
10
|
public override bind(element: HTMLElement) {
|
|
29
11
|
super.bind(element);
|
|
30
|
-
this.
|
|
12
|
+
this.frameSink = YUVCanvas.attach(this.canvas, {
|
|
31
13
|
webGL: false,
|
|
32
14
|
});
|
|
33
15
|
}
|
|
34
16
|
|
|
35
|
-
public override
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
let options: CanvasOptions = {
|
|
75
|
-
frameWidth,
|
|
76
|
-
frameHeight,
|
|
77
|
-
rotation: frame.rotation ? frame.rotation : 0,
|
|
78
|
-
contentMode: this.contentMode,
|
|
79
|
-
clientWidth: this.container.clientWidth,
|
|
80
|
-
clientHeight: this.container.clientHeight,
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
this.updateCanvas(options);
|
|
84
|
-
|
|
85
|
-
let format = YUVBuffer.format({
|
|
86
|
-
width: frameWidth,
|
|
87
|
-
height: frameHeight,
|
|
88
|
-
chromaWidth: frameWidth / 2,
|
|
89
|
-
chromaHeight: frameHeight / 2,
|
|
90
|
-
cropLeft: frame.yStride - frameWidth,
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
let yuvBufferFrame = YUVBuffer.frame(
|
|
94
|
-
format,
|
|
95
|
-
{
|
|
96
|
-
bytes: this._videoFrame.yBuffer,
|
|
97
|
-
stride: frame.yStride,
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
bytes: this._videoFrame.uBuffer,
|
|
101
|
-
stride: frame.yStride / 2,
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
bytes: this._videoFrame.vBuffer,
|
|
105
|
-
stride: frame.yStride / 2,
|
|
106
|
-
}
|
|
17
|
+
public override drawFrame({
|
|
18
|
+
width,
|
|
19
|
+
height,
|
|
20
|
+
yStride,
|
|
21
|
+
uStride,
|
|
22
|
+
vStride,
|
|
23
|
+
yBuffer,
|
|
24
|
+
uBuffer,
|
|
25
|
+
vBuffer,
|
|
26
|
+
rotation,
|
|
27
|
+
}: VideoFrame) {
|
|
28
|
+
this.rotateCanvas({ width, height, rotation });
|
|
29
|
+
this.updateRenderMode();
|
|
30
|
+
|
|
31
|
+
if (!this.frameSink) return;
|
|
32
|
+
|
|
33
|
+
this.frameSink.drawFrame(
|
|
34
|
+
YUVBuffer.frame(
|
|
35
|
+
YUVBuffer.format({
|
|
36
|
+
width,
|
|
37
|
+
height,
|
|
38
|
+
chromaWidth: width! / 2,
|
|
39
|
+
chromaHeight: height! / 2,
|
|
40
|
+
cropLeft: yStride! - width!,
|
|
41
|
+
}),
|
|
42
|
+
{
|
|
43
|
+
bytes: yBuffer,
|
|
44
|
+
stride: yStride,
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
bytes: uBuffer,
|
|
48
|
+
stride: uStride,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
bytes: vBuffer,
|
|
52
|
+
stride: vStride,
|
|
53
|
+
}
|
|
54
|
+
)
|
|
107
55
|
);
|
|
108
|
-
this._yuvCanvasSink.drawFrame(yuvBufferFrame);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
public override refreshCanvas() {
|
|
112
|
-
if (this._cacheCanvasOptions) {
|
|
113
|
-
this.zoom(
|
|
114
|
-
this._cacheCanvasOptions.rotation === 90 ||
|
|
115
|
-
this._cacheCanvasOptions.rotation === 270,
|
|
116
|
-
this._cacheCanvasOptions.contentMode,
|
|
117
|
-
this._cacheCanvasOptions.frameWidth,
|
|
118
|
-
this._cacheCanvasOptions.frameHeight,
|
|
119
|
-
this._cacheCanvasOptions.clientWidth,
|
|
120
|
-
this._cacheCanvasOptions.clientHeight
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
private updateCanvas(
|
|
126
|
-
options: CanvasOptions = {
|
|
127
|
-
frameWidth: 0,
|
|
128
|
-
frameHeight: 0,
|
|
129
|
-
rotation: 0,
|
|
130
|
-
contentMode: RenderModeType.RenderModeHidden,
|
|
131
|
-
clientWidth: 0,
|
|
132
|
-
clientHeight: 0,
|
|
133
|
-
}
|
|
134
|
-
) {
|
|
135
|
-
if (this._cacheCanvasOptions) {
|
|
136
|
-
if (isEqual(this._cacheCanvasOptions, options)) {
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
this._cacheCanvasOptions = Object.assign({}, options);
|
|
142
|
-
|
|
143
|
-
if (this.canvas) {
|
|
144
|
-
if (options.rotation === 0 || options.rotation === 180) {
|
|
145
|
-
this.canvas.width = options.frameWidth;
|
|
146
|
-
this.canvas.height = options.frameHeight;
|
|
147
|
-
Object.assign(this.canvas.style, {
|
|
148
|
-
'width': options.frameWidth + 'px',
|
|
149
|
-
'height': options.frameHeight + 'px',
|
|
150
|
-
'object-fit': 'cover',
|
|
151
|
-
});
|
|
152
|
-
} else if (options.rotation === 90 || options.rotation === 270) {
|
|
153
|
-
this.canvas.height = options.frameWidth;
|
|
154
|
-
this.canvas.width = options.frameHeight;
|
|
155
|
-
} else {
|
|
156
|
-
throw new Error(
|
|
157
|
-
'Invalid value for rotation. Only support 0, 90, 180, 270'
|
|
158
|
-
);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
let transformItems = [];
|
|
162
|
-
transformItems.push(`rotateZ(${options.rotation}deg)`);
|
|
163
|
-
|
|
164
|
-
let scale = this.zoom(
|
|
165
|
-
options.rotation === 90 || options.rotation === 270,
|
|
166
|
-
options.contentMode,
|
|
167
|
-
options.frameWidth,
|
|
168
|
-
options.frameHeight,
|
|
169
|
-
options.clientWidth,
|
|
170
|
-
options.clientHeight
|
|
171
|
-
);
|
|
172
|
-
|
|
173
|
-
this.canvas.style.transform = `scale(${scale.toString()})`;
|
|
174
|
-
|
|
175
|
-
if (transformItems.length > 0) {
|
|
176
|
-
this.canvas.style.transform += ` ${transformItems.join(' ')}`;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
56
|
}
|
|
180
57
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
contentMode: RenderModeType = RenderModeType.RenderModeFit,
|
|
184
|
-
width: number,
|
|
185
|
-
height: number,
|
|
186
|
-
clientWidth: number,
|
|
187
|
-
clientHeight: number
|
|
188
|
-
): number {
|
|
189
|
-
let localRatio = clientWidth / clientHeight;
|
|
190
|
-
let tempRatio = width / height;
|
|
191
|
-
if (isNaN(localRatio) || isNaN(tempRatio)) {
|
|
192
|
-
return 1;
|
|
193
|
-
}
|
|
58
|
+
protected override rotateCanvas({ width, height, rotation }: VideoFrame) {
|
|
59
|
+
super.rotateCanvas({ width, height, rotation });
|
|
194
60
|
|
|
195
|
-
if (
|
|
196
|
-
|
|
197
|
-
return clientHeight / clientWidth < width / height
|
|
198
|
-
? clientWidth / height
|
|
199
|
-
: clientHeight / width;
|
|
200
|
-
} else {
|
|
201
|
-
return clientWidth / clientHeight > width / height
|
|
202
|
-
? clientWidth / width
|
|
203
|
-
: clientHeight / height;
|
|
204
|
-
}
|
|
205
|
-
} else {
|
|
206
|
-
if (vertical) {
|
|
207
|
-
return clientHeight / clientWidth < width / height
|
|
208
|
-
? clientHeight / width
|
|
209
|
-
: clientWidth / height;
|
|
210
|
-
} else {
|
|
211
|
-
return clientWidth / clientHeight > width / height
|
|
212
|
-
? clientHeight / height
|
|
213
|
-
: clientWidth / width;
|
|
214
|
-
}
|
|
215
|
-
}
|
|
61
|
+
if (!this.canvas) return;
|
|
62
|
+
this.canvas.style.transform += ` rotateZ(${rotation}deg)`;
|
|
216
63
|
}
|
|
217
64
|
}
|
package/ts/Types.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { VideoCanvas } from './Private/AgoraBase';
|
|
2
|
+
import { VideoFrame } from './Private/AgoraMediaBase';
|
|
3
|
+
import { RtcConnection } from './Private/IAgoraRtcEngineEx';
|
|
4
|
+
import { IRendererManager } from './Renderer';
|
|
3
5
|
|
|
4
6
|
/**
|
|
5
7
|
* @ignore
|
|
@@ -36,51 +38,7 @@ export interface AgoraEnvType extends AgoraEnvOptions {
|
|
|
36
38
|
/**
|
|
37
39
|
* @ignore
|
|
38
40
|
*/
|
|
39
|
-
export
|
|
40
|
-
/**
|
|
41
|
-
* @ignore
|
|
42
|
-
*/
|
|
43
|
-
frameWidth: number;
|
|
44
|
-
/**
|
|
45
|
-
* @ignore
|
|
46
|
-
*/
|
|
47
|
-
frameHeight: number;
|
|
48
|
-
/**
|
|
49
|
-
* @ignore
|
|
50
|
-
*/
|
|
51
|
-
rotation: number;
|
|
52
|
-
/**
|
|
53
|
-
* @ignore
|
|
54
|
-
*/
|
|
55
|
-
contentMode: RenderModeType;
|
|
56
|
-
/**
|
|
57
|
-
* @ignore
|
|
58
|
-
*/
|
|
59
|
-
clientWidth: number;
|
|
60
|
-
/**
|
|
61
|
-
* @ignore
|
|
62
|
-
*/
|
|
63
|
-
clientHeight: number;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* @ignore
|
|
68
|
-
*/
|
|
69
|
-
export interface RendererOptions {
|
|
70
|
-
/**
|
|
71
|
-
* @ignore
|
|
72
|
-
*/
|
|
73
|
-
contentMode?: RenderModeType;
|
|
74
|
-
/**
|
|
75
|
-
* @ignore
|
|
76
|
-
*/
|
|
77
|
-
mirror?: boolean;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* @ignore
|
|
82
|
-
*/
|
|
83
|
-
export enum RENDER_MODE {
|
|
41
|
+
export enum RendererType {
|
|
84
42
|
/**
|
|
85
43
|
* @ignore
|
|
86
44
|
*/
|
|
@@ -91,129 +49,14 @@ export enum RENDER_MODE {
|
|
|
91
49
|
SOFTWARE = 2,
|
|
92
50
|
}
|
|
93
51
|
|
|
94
|
-
export type
|
|
52
|
+
export type RENDER_MODE = RendererType;
|
|
95
53
|
|
|
96
|
-
export type
|
|
54
|
+
export type RendererContext = VideoCanvas & RtcConnection;
|
|
97
55
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* @ignore
|
|
104
|
-
*/
|
|
105
|
-
videoSourceType?: VideoSourceType;
|
|
106
|
-
/**
|
|
107
|
-
* @ignore
|
|
108
|
-
*/
|
|
109
|
-
channelId?: Channel;
|
|
110
|
-
/**
|
|
111
|
-
* @ignore
|
|
112
|
-
*/
|
|
113
|
-
uid?: number;
|
|
114
|
-
/**
|
|
115
|
-
* @ignore
|
|
116
|
-
*/
|
|
117
|
-
view?: HTMLElement;
|
|
118
|
-
/**
|
|
119
|
-
* @ignore
|
|
120
|
-
*/
|
|
121
|
-
rendererOptions?: RendererOptions;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* @ignore
|
|
126
|
-
*/
|
|
127
|
-
export interface FormatRendererVideoConfig {
|
|
128
|
-
/**
|
|
129
|
-
* @ignore
|
|
130
|
-
*/
|
|
131
|
-
videoSourceType: VideoSourceType;
|
|
132
|
-
/**
|
|
133
|
-
* @ignore
|
|
134
|
-
*/
|
|
135
|
-
channelId: Channel;
|
|
136
|
-
/**
|
|
137
|
-
* @ignore
|
|
138
|
-
*/
|
|
139
|
-
uid: number;
|
|
140
|
-
/**
|
|
141
|
-
* @ignore
|
|
142
|
-
*/
|
|
143
|
-
view?: HTMLElement;
|
|
144
|
-
/**
|
|
145
|
-
* @ignore
|
|
146
|
-
*/
|
|
147
|
-
rendererOptions: RendererOptions;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* @ignore
|
|
152
|
-
*/
|
|
153
|
-
export interface VideoFrameCacheConfig {
|
|
154
|
-
/**
|
|
155
|
-
* @ignore
|
|
156
|
-
*/
|
|
157
|
-
uid: number;
|
|
158
|
-
/**
|
|
159
|
-
* @ignore
|
|
160
|
-
*/
|
|
161
|
-
channelId: string;
|
|
162
|
-
/**
|
|
163
|
-
* @ignore
|
|
164
|
-
*/
|
|
165
|
-
videoSourceType: VideoSourceType;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* @ignore
|
|
170
|
-
*/
|
|
171
|
-
export interface ShareVideoFrame {
|
|
172
|
-
/**
|
|
173
|
-
* @ignore
|
|
174
|
-
*/
|
|
175
|
-
width: number;
|
|
176
|
-
/**
|
|
177
|
-
* @ignore
|
|
178
|
-
*/
|
|
179
|
-
height: number;
|
|
180
|
-
/**
|
|
181
|
-
* @ignore
|
|
182
|
-
*/
|
|
183
|
-
yStride: number;
|
|
184
|
-
/**
|
|
185
|
-
* @ignore
|
|
186
|
-
*/
|
|
187
|
-
yBuffer: Buffer | Uint8Array;
|
|
188
|
-
/**
|
|
189
|
-
* @ignore
|
|
190
|
-
*/
|
|
191
|
-
uBuffer: Buffer | Uint8Array;
|
|
192
|
-
/**
|
|
193
|
-
* @ignore
|
|
194
|
-
*/
|
|
195
|
-
vBuffer: Buffer | Uint8Array;
|
|
196
|
-
/**
|
|
197
|
-
* @ignore
|
|
198
|
-
*/
|
|
199
|
-
mirror?: boolean;
|
|
200
|
-
/**
|
|
201
|
-
* @ignore
|
|
202
|
-
*/
|
|
203
|
-
rotation?: number;
|
|
204
|
-
/**
|
|
205
|
-
* @ignore
|
|
206
|
-
*/
|
|
207
|
-
uid?: number;
|
|
208
|
-
/**
|
|
209
|
-
* @ignore
|
|
210
|
-
*/
|
|
211
|
-
channelId?: string;
|
|
212
|
-
/**
|
|
213
|
-
* @ignore
|
|
214
|
-
*/
|
|
215
|
-
videoSourceType?: VideoSourceType;
|
|
216
|
-
}
|
|
56
|
+
export type RendererCacheContext = Pick<
|
|
57
|
+
RendererContext,
|
|
58
|
+
'channelId' | 'uid' | 'sourceType'
|
|
59
|
+
>;
|
|
217
60
|
|
|
218
61
|
/**
|
|
219
62
|
* @ignore
|
|
@@ -260,20 +103,18 @@ export interface AgoraElectronBridge {
|
|
|
260
103
|
|
|
261
104
|
ReleaseRenderer(): void;
|
|
262
105
|
|
|
263
|
-
EnableVideoFrameCache(
|
|
106
|
+
EnableVideoFrameCache(context: RendererCacheContext): void;
|
|
264
107
|
|
|
265
|
-
DisableVideoFrameCache(
|
|
108
|
+
DisableVideoFrameCache(context: RendererCacheContext): void;
|
|
266
109
|
|
|
267
110
|
GetBuffer(ptr: number, length: number): Buffer;
|
|
268
111
|
|
|
269
|
-
GetVideoFrame(
|
|
112
|
+
GetVideoFrame(
|
|
113
|
+
context: RendererCacheContext,
|
|
114
|
+
videoFrame: VideoFrame
|
|
115
|
+
): {
|
|
270
116
|
ret: number;
|
|
271
117
|
isNewFrame: boolean;
|
|
272
|
-
yStride: number;
|
|
273
|
-
width: number;
|
|
274
|
-
height: number;
|
|
275
|
-
rotation: number;
|
|
276
|
-
timestamp: number;
|
|
277
118
|
};
|
|
278
119
|
|
|
279
120
|
sendMsg: (
|
|
@@ -283,21 +124,3 @@ export interface AgoraElectronBridge {
|
|
|
283
124
|
bufferCount?: number
|
|
284
125
|
) => Result;
|
|
285
126
|
}
|
|
286
|
-
|
|
287
|
-
/**
|
|
288
|
-
* @ignore
|
|
289
|
-
*/
|
|
290
|
-
export interface RenderConfig {
|
|
291
|
-
/**
|
|
292
|
-
* @ignore
|
|
293
|
-
*/
|
|
294
|
-
renders: IRenderer[];
|
|
295
|
-
/**
|
|
296
|
-
* @ignore
|
|
297
|
-
*/
|
|
298
|
-
shareVideoFrame: ShareVideoFrame;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
export type UidMap = Map<number, RenderConfig>;
|
|
302
|
-
export type ChannelIdMap = Map<Channel, UidMap>;
|
|
303
|
-
export type RenderMap = Map<VideoSourceType, ChannelIdMap>;
|
package/ts/Utils.ts
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
AgoraEnvType,
|
|
4
|
-
FormatRendererVideoConfig,
|
|
5
|
-
RendererVideoConfig,
|
|
6
|
-
} from './Types';
|
|
1
|
+
import { AgoraEnvType } from './Types';
|
|
7
2
|
|
|
8
3
|
/**
|
|
9
4
|
* @ignore
|
|
@@ -14,15 +9,6 @@ export const TAG = '[Agora]: ';
|
|
|
14
9
|
*/
|
|
15
10
|
export const DEBUG_TAG = '[Agora Debug]: ';
|
|
16
11
|
|
|
17
|
-
/**
|
|
18
|
-
* @ignore
|
|
19
|
-
*/
|
|
20
|
-
export const deprecate = (originApi?: string, replaceApi?: string) =>
|
|
21
|
-
logError(
|
|
22
|
-
`${TAG} This method ${originApi} will be deprecated soon. `,
|
|
23
|
-
replaceApi ? `Please use ${replaceApi} instead` : ''
|
|
24
|
-
);
|
|
25
|
-
|
|
26
12
|
/**
|
|
27
13
|
* @ignore
|
|
28
14
|
*/
|
|
@@ -50,7 +36,7 @@ export const logInfo = (msg: string, ...optParams: any[]) => {
|
|
|
50
36
|
if (!AgoraEnv.enableLogging) {
|
|
51
37
|
return;
|
|
52
38
|
}
|
|
53
|
-
console.
|
|
39
|
+
console.info(`${TAG} ${msg}`, ...optParams);
|
|
54
40
|
};
|
|
55
41
|
|
|
56
42
|
/**
|
|
@@ -60,23 +46,7 @@ export const logDebug = (msg: string, ...optParams: any[]) => {
|
|
|
60
46
|
if (!AgoraEnv.enableLogging || !AgoraEnv.enableDebugLogging) {
|
|
61
47
|
return;
|
|
62
48
|
}
|
|
63
|
-
console.
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* @ignore
|
|
68
|
-
*/
|
|
69
|
-
export const parseJSON = (jsonString: string) => {
|
|
70
|
-
if (jsonString === '') {
|
|
71
|
-
return jsonString;
|
|
72
|
-
}
|
|
73
|
-
let obj;
|
|
74
|
-
try {
|
|
75
|
-
obj = JSON.parse(jsonString);
|
|
76
|
-
} catch (error) {
|
|
77
|
-
logError('parseJSON', error);
|
|
78
|
-
}
|
|
79
|
-
return obj || jsonString;
|
|
49
|
+
console.debug(`${DEBUG_TAG} ${msg}`, ...optParams);
|
|
80
50
|
};
|
|
81
51
|
|
|
82
52
|
/**
|
|
@@ -93,71 +63,6 @@ export const objsKeysToLowerCase = (array: Array<any>) => {
|
|
|
93
63
|
});
|
|
94
64
|
};
|
|
95
65
|
|
|
96
|
-
/**
|
|
97
|
-
* @ignore
|
|
98
|
-
*/
|
|
99
|
-
export const formatConfigByVideoSourceType = (
|
|
100
|
-
videoSourceType?: VideoSourceType,
|
|
101
|
-
originChannelId = '',
|
|
102
|
-
originUid = 0
|
|
103
|
-
): {
|
|
104
|
-
uid: number;
|
|
105
|
-
channelId: string;
|
|
106
|
-
videoSourceType: VideoSourceType;
|
|
107
|
-
} => {
|
|
108
|
-
if (videoSourceType === undefined || videoSourceType === null) {
|
|
109
|
-
throw new Error(`must set videoSourceType:${videoSourceType}`);
|
|
110
|
-
}
|
|
111
|
-
let uid = originUid;
|
|
112
|
-
let channelId = originChannelId;
|
|
113
|
-
|
|
114
|
-
switch (videoSourceType) {
|
|
115
|
-
case VideoSourceType.VideoSourceCamera:
|
|
116
|
-
case VideoSourceType.VideoSourceCameraPrimary:
|
|
117
|
-
case VideoSourceType.VideoSourceScreen:
|
|
118
|
-
case VideoSourceType.VideoSourceScreenSecondary:
|
|
119
|
-
case VideoSourceType.VideoSourceTranscoded:
|
|
120
|
-
channelId = '';
|
|
121
|
-
uid = 0;
|
|
122
|
-
break;
|
|
123
|
-
case VideoSourceType.VideoSourceRemote:
|
|
124
|
-
if (!uid || !channelId) {
|
|
125
|
-
throw new Error(`must set uid:${uid} and channelId:${channelId}`);
|
|
126
|
-
}
|
|
127
|
-
break;
|
|
128
|
-
case VideoSourceType.VideoSourceMediaPlayer:
|
|
129
|
-
channelId = '';
|
|
130
|
-
if (!uid) {
|
|
131
|
-
throw new Error(`must set mediaPlayerId:${uid}`);
|
|
132
|
-
}
|
|
133
|
-
break;
|
|
134
|
-
default:
|
|
135
|
-
break;
|
|
136
|
-
}
|
|
137
|
-
return { uid, channelId, videoSourceType };
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* @ignore
|
|
142
|
-
*/
|
|
143
|
-
export const getDefaultRendererVideoConfig = (
|
|
144
|
-
config: RendererVideoConfig
|
|
145
|
-
): FormatRendererVideoConfig => {
|
|
146
|
-
const rendererOptions = Object.assign(
|
|
147
|
-
{},
|
|
148
|
-
AgoraEnv.AgoraRendererManager?.defaultRenderConfig?.rendererOptions,
|
|
149
|
-
config.rendererOptions
|
|
150
|
-
);
|
|
151
|
-
|
|
152
|
-
const { uid, channelId, videoSourceType } = formatConfigByVideoSourceType(
|
|
153
|
-
config.videoSourceType,
|
|
154
|
-
config.channelId,
|
|
155
|
-
config.uid
|
|
156
|
-
);
|
|
157
|
-
|
|
158
|
-
return { ...config, uid, channelId, videoSourceType, rendererOptions };
|
|
159
|
-
};
|
|
160
|
-
|
|
161
66
|
/**
|
|
162
67
|
* @ignore
|
|
163
68
|
*/
|
|
@@ -187,7 +92,38 @@ function copyProperties<T>(target: T, source: any) {
|
|
|
187
92
|
}
|
|
188
93
|
}
|
|
189
94
|
|
|
190
|
-
|
|
95
|
+
/**
|
|
96
|
+
* @ignore
|
|
97
|
+
*/
|
|
98
|
+
export function isSupportWebGL(): boolean {
|
|
99
|
+
let flag = false;
|
|
100
|
+
const canvas: HTMLCanvasElement = document.createElement('canvas');
|
|
101
|
+
try {
|
|
102
|
+
const getContext = (
|
|
103
|
+
contextNames = ['webgl2', 'webgl', 'experimental-webgl']
|
|
104
|
+
): WebGLRenderingContext | WebGLRenderingContext | null => {
|
|
105
|
+
for (let i = 0; i < contextNames.length; i++) {
|
|
106
|
+
const contextName = contextNames[i]!;
|
|
107
|
+
const context = canvas?.getContext(contextName);
|
|
108
|
+
if (context) {
|
|
109
|
+
return context as WebGLRenderingContext | WebGLRenderingContext;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return null;
|
|
113
|
+
};
|
|
114
|
+
let gl = getContext();
|
|
115
|
+
flag = !!gl;
|
|
116
|
+
gl?.getExtension('WEBGL_lose_context')?.loseContext();
|
|
117
|
+
gl = null;
|
|
118
|
+
logInfo('Your browser support webGL');
|
|
119
|
+
} catch (e) {
|
|
120
|
+
logWarn('Your browser may not support webGL');
|
|
121
|
+
flag = false;
|
|
122
|
+
}
|
|
123
|
+
return flag;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const AgoraNode = require('../build/Release/agora_node_ext');
|
|
191
127
|
|
|
192
128
|
/**
|
|
193
129
|
* @ignore
|
|
@@ -196,5 +132,5 @@ export const AgoraEnv: AgoraEnvType = {
|
|
|
196
132
|
enableLogging: true,
|
|
197
133
|
enableDebugLogging: false,
|
|
198
134
|
webEnvReady: true,
|
|
199
|
-
AgoraElectronBridge: new
|
|
135
|
+
AgoraElectronBridge: new AgoraNode.AgoraElectronBridge(),
|
|
200
136
|
};
|