trtc-electron-sdk 10.3.402 → 10.3.403
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/liteav/Render/I420VideoRenderer/index.js +0 -9
- package/liteav/Render/util.js +0 -1
- package/liteav/Renderer/Canvas2DRenderer/index.d.ts +24 -0
- package/liteav/Renderer/Canvas2DRenderer/index.js +213 -0
- package/liteav/Renderer/Canvas3DRenderer/I420Canvas3DRenderer.d.ts +23 -0
- package/liteav/Renderer/Canvas3DRenderer/I420Canvas3DRenderer.js +276 -0
- package/liteav/Renderer/Canvas3DRenderer/ICanvas3DRenderer.d.ts +4 -0
- package/liteav/Renderer/Canvas3DRenderer/ICanvas3DRenderer.js +2 -0
- package/liteav/Renderer/Canvas3DRenderer/RGBACanvas3DRenderer.d.ts +8 -0
- package/liteav/Renderer/Canvas3DRenderer/RGBACanvas3DRenderer.js +163 -0
- package/liteav/Renderer/Canvas3DRenderer/index.d.ts +27 -0
- package/liteav/Renderer/Canvas3DRenderer/index.js +201 -0
- package/liteav/Renderer/Canvas3DRenderer/webgl-utils.js +1337 -0
- package/liteav/Renderer/IRenderer.d.ts +6 -0
- package/liteav/Renderer/IRenderer.js +2 -0
- package/liteav/Renderer/VideoRenderer/index.d.ts +25 -0
- package/liteav/Renderer/VideoRenderer/index.js +148 -0
- package/liteav/Renderer/index.d.ts +3 -0
- package/liteav/Renderer/index.js +38 -0
- package/liteav/Renderer/types.d.ts +19 -0
- package/liteav/Renderer/types.js +2 -0
- package/liteav/Renderer/util.d.ts +52 -0
- package/liteav/Renderer/util.js +181 -0
- package/liteav/Renderer/yuv-buffer.d.ts +189 -0
- package/liteav/Renderer/yuv-buffer.js +264 -0
- package/liteav/trtc.d.ts +6 -9
- package/liteav/trtc.js +100 -265
- package/package.json +7 -8
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/*
|
|
4
|
+
Copyright (c) 2014-2016 Brion Vibber <brion@pobox.com>
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
7
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
8
|
+
the Software without restriction, including without limitation the rights to
|
|
9
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
10
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
11
|
+
subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
MPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
18
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
19
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
20
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
21
|
+
ONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Represents metadata about a YUV frame format.
|
|
25
|
+
* @typedef {Object} YUVFormat
|
|
26
|
+
* @property {number} width - width of encoded frame in luma pixels
|
|
27
|
+
* @property {number} height - height of encoded frame in luma pixels
|
|
28
|
+
* @property {number} chromaWidth - width of encoded frame in chroma pixels
|
|
29
|
+
* @property {number} chromaHeight - height of encoded frame in chroma pixels
|
|
30
|
+
* @property {number} cropLeft - upper-left X coordinate of visible crop region, in luma pixels
|
|
31
|
+
* @property {number} cropTop - upper-left Y coordinate of visible crop region, in luma pixels
|
|
32
|
+
* @property {number} cropWidth - width of visible crop region, in luma pixels
|
|
33
|
+
* @property {number} cropHeight - height of visible crop region, in luma pixels
|
|
34
|
+
* @property {number} displayWidth - final display width of visible region, in luma pixels
|
|
35
|
+
* @property {number} displayHeight - final display height of visible region, in luma pixels
|
|
36
|
+
*/
|
|
37
|
+
/**
|
|
38
|
+
* Represents underlying image data for a single luma or chroma plane.
|
|
39
|
+
* Cannot be interpreted without the format data from a frame buffer.
|
|
40
|
+
* @typedef {Object} YUVPlane
|
|
41
|
+
* @property {Uint8Array} bytes - typed array containing image data bytes
|
|
42
|
+
* @property {number} stride - byte distance between rows in data
|
|
43
|
+
*/
|
|
44
|
+
/**
|
|
45
|
+
* Represents a YUV image frame buffer, with enough format information
|
|
46
|
+
* to interpret the data usefully. Buffer objects use generic objects
|
|
47
|
+
* under the hood and can be transferred between worker threads using
|
|
48
|
+
* the structured clone algorithm.
|
|
49
|
+
*
|
|
50
|
+
* @typedef {Object} YUVFrame
|
|
51
|
+
* @property {YUVFormat} format
|
|
52
|
+
* @property {YUVPlane} y
|
|
53
|
+
* @property {YUVPlane} u
|
|
54
|
+
* @property {YUVPlane} v
|
|
55
|
+
*/
|
|
56
|
+
/**
|
|
57
|
+
* Holder namespace for utility functions and constants related to
|
|
58
|
+
* YUV frame and plane buffers.
|
|
59
|
+
*
|
|
60
|
+
* @namespace
|
|
61
|
+
*/
|
|
62
|
+
var YUVBuffer = {
|
|
63
|
+
/**
|
|
64
|
+
* Validate a plane dimension
|
|
65
|
+
* @param {number} dim - vertical or horizontal dimension
|
|
66
|
+
* @throws exception on zero, negative, or non-integer value
|
|
67
|
+
*/
|
|
68
|
+
validateDimension: function (dim) {
|
|
69
|
+
if (dim <= 0 || dim !== (dim | 0)) {
|
|
70
|
+
throw 'YUV plane dimensions must be a positive integer';
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
/**
|
|
74
|
+
* Validate a plane offset
|
|
75
|
+
* @param {number} dim - vertical or horizontal dimension
|
|
76
|
+
* @throws exception on negative or non-integer value
|
|
77
|
+
*/
|
|
78
|
+
validateOffset: function (dim) {
|
|
79
|
+
if (dim < 0 || dim !== (dim | 0)) {
|
|
80
|
+
throw 'YUV plane offsets must be a non-negative integer';
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
/**
|
|
84
|
+
* Validate and fill out a YUVFormat object structure.
|
|
85
|
+
*
|
|
86
|
+
* At least width and height fields are required; other fields will be
|
|
87
|
+
* derived if left missing or empty:
|
|
88
|
+
* - chromaWidth and chromaHeight will be copied from width and height as for a 4:4:4 layout
|
|
89
|
+
* - cropLeft and cropTop will be 0
|
|
90
|
+
* - cropWidth and cropHeight will be set to whatever of the frame is visible after cropTop and cropLeft are applied
|
|
91
|
+
* - displayWidth and displayHeight will be set to cropWidth and cropHeight.
|
|
92
|
+
*
|
|
93
|
+
* @param {YUVFormat} fields - input fields, must include width and height.
|
|
94
|
+
* @returns {YUVFormat} - validated structure, with all derivable fields filled out.
|
|
95
|
+
* @throws exception on invalid fields or missing width/height
|
|
96
|
+
*/
|
|
97
|
+
format: function (fields) {
|
|
98
|
+
var width = fields.width, height = fields.height, chromaWidth = fields.chromaWidth || width, chromaHeight = fields.chromaHeight || height, cropLeft = fields.cropLeft || 0, cropTop = fields.cropTop || 0, cropWidth = fields.cropWidth || width - cropLeft, cropHeight = fields.cropHeight || height - cropTop, displayWidth = fields.displayWidth || cropWidth, displayHeight = fields.displayHeight || cropHeight;
|
|
99
|
+
this.validateDimension(width);
|
|
100
|
+
this.validateDimension(height);
|
|
101
|
+
this.validateDimension(chromaWidth);
|
|
102
|
+
this.validateDimension(chromaHeight);
|
|
103
|
+
this.validateOffset(cropLeft);
|
|
104
|
+
this.validateOffset(cropTop);
|
|
105
|
+
this.validateDimension(cropWidth);
|
|
106
|
+
this.validateDimension(cropHeight);
|
|
107
|
+
this.validateDimension(displayWidth);
|
|
108
|
+
this.validateDimension(displayHeight);
|
|
109
|
+
return {
|
|
110
|
+
width: width,
|
|
111
|
+
height: height,
|
|
112
|
+
chromaWidth: chromaWidth,
|
|
113
|
+
chromaHeight: chromaHeight,
|
|
114
|
+
cropLeft: cropLeft,
|
|
115
|
+
cropTop: cropTop,
|
|
116
|
+
cropWidth: cropWidth,
|
|
117
|
+
cropHeight: cropHeight,
|
|
118
|
+
displayWidth: displayWidth,
|
|
119
|
+
displayHeight: displayHeight
|
|
120
|
+
};
|
|
121
|
+
},
|
|
122
|
+
// /**
|
|
123
|
+
// * Allocate a new YUVPlane object of the given size.
|
|
124
|
+
// * @param {number} stride - byte distance between rows
|
|
125
|
+
// * @param {number} rows - number of rows to allocate
|
|
126
|
+
// * @returns {YUVPlane} - freshly allocated planar buffer
|
|
127
|
+
// */
|
|
128
|
+
// allocPlane: function(stride: number, rows: number): YUVPlane {
|
|
129
|
+
// YUVBuffer.validateDimension(stride);
|
|
130
|
+
// YUVBuffer.validateDimension(rows);
|
|
131
|
+
// return {
|
|
132
|
+
// bytes: new Uint8Array(stride * rows),
|
|
133
|
+
// stride: stride
|
|
134
|
+
// }
|
|
135
|
+
// },
|
|
136
|
+
/**
|
|
137
|
+
* Pick a suitable stride for a custom-allocated thingy
|
|
138
|
+
* @param {number} width - width in bytes
|
|
139
|
+
* @returns {number} - new width in bytes at least as large
|
|
140
|
+
* @throws exception on invalid input width
|
|
141
|
+
*/
|
|
142
|
+
suitableStride: function (width) {
|
|
143
|
+
YUVBuffer.validateDimension(width);
|
|
144
|
+
var alignment = 4, remainder = width % alignment;
|
|
145
|
+
if (remainder == 0) {
|
|
146
|
+
return width;
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
return width + (alignment - remainder);
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
/**
|
|
153
|
+
* Allocate or extract a YUVPlane object from given dimensions/source.
|
|
154
|
+
* @param {number} width - width in pixels
|
|
155
|
+
* @param {number} height - height in pixels
|
|
156
|
+
* @param {Uint8Array} source - input byte array; optional (will create empty buffer if missing)
|
|
157
|
+
* @param {number} stride - row length in bytes; optional (will create a default if missing)
|
|
158
|
+
* @param {number} offset - offset into source array to extract; optional (will start at 0 if missing)
|
|
159
|
+
* @returns {YUVPlane} - freshly allocated planar buffer
|
|
160
|
+
*/
|
|
161
|
+
allocPlane: function (width, height, source, stride, offset) {
|
|
162
|
+
var size, bytes;
|
|
163
|
+
this.validateDimension(width);
|
|
164
|
+
this.validateDimension(height);
|
|
165
|
+
offset = offset || 0;
|
|
166
|
+
stride = stride || this.suitableStride(width);
|
|
167
|
+
this.validateDimension(stride);
|
|
168
|
+
if (stride < width) {
|
|
169
|
+
throw "Invalid input stride for YUV plane; must be larger than width";
|
|
170
|
+
}
|
|
171
|
+
size = stride * height;
|
|
172
|
+
if (source) {
|
|
173
|
+
if (source.length - offset < size) {
|
|
174
|
+
throw "Invalid input buffer for YUV plane; must be large enough for stride times height";
|
|
175
|
+
}
|
|
176
|
+
bytes = source; // source.slice(offset, offset + size);
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
bytes = new Uint8Array(size);
|
|
180
|
+
stride = stride || this.suitableStride(width);
|
|
181
|
+
}
|
|
182
|
+
return {
|
|
183
|
+
bytes: bytes,
|
|
184
|
+
stride: stride
|
|
185
|
+
};
|
|
186
|
+
},
|
|
187
|
+
/**
|
|
188
|
+
* Allocate a new YUVPlane object big enough for a luma plane in the given format
|
|
189
|
+
* @param {YUVFormat} format - target frame format
|
|
190
|
+
* @param {Uint8Array} source - input byte array; optional (will create empty buffer if missing)
|
|
191
|
+
* @param {number} stride - row length in bytes; optional (will create a default if missing)
|
|
192
|
+
* @param {number} offset - offset into source array to extract; optional (will start at 0 if missing)
|
|
193
|
+
* @returns {YUVPlane} - freshly allocated planar buffer
|
|
194
|
+
*/
|
|
195
|
+
lumaPlane: function (format, source, stride, offset) {
|
|
196
|
+
return this.allocPlane(format.width, format.height, source, stride, offset);
|
|
197
|
+
},
|
|
198
|
+
/**
|
|
199
|
+
* Allocate a new YUVPlane object big enough for a chroma plane in the given format,
|
|
200
|
+
* optionally copying data from an existing buffer.
|
|
201
|
+
*
|
|
202
|
+
* @param {YUVFormat} format - target frame format
|
|
203
|
+
* @param {Uint8Array} source - input byte array; optional (will create empty buffer if missing)
|
|
204
|
+
* @param {number} stride - row length in bytes; optional (will create a default if missing)
|
|
205
|
+
* @param {number} offset - offset into source array to extract; optional (will start at 0 if missing)
|
|
206
|
+
* @returns {YUVPlane} - freshly allocated planar buffer
|
|
207
|
+
*/
|
|
208
|
+
chromaPlane: function (format, source, stride, offset) {
|
|
209
|
+
return this.allocPlane(format.chromaWidth, format.chromaHeight, source, stride, offset);
|
|
210
|
+
},
|
|
211
|
+
/**
|
|
212
|
+
* Allocate a new YUVFrame object big enough for the given format
|
|
213
|
+
* @param {YUVFormat} format - target frame format
|
|
214
|
+
* @param {YUVPlane} y - optional Y plane; if missing, fresh one will be allocated
|
|
215
|
+
* @param {YUVPlane} u - optional U plane; if missing, fresh one will be allocated
|
|
216
|
+
* @param {YUVPlane} v - optional V plane; if missing, fresh one will be allocated
|
|
217
|
+
* @returns {YUVFrame} - freshly allocated frame buffer
|
|
218
|
+
*/
|
|
219
|
+
frame: function (format, y, u, v) {
|
|
220
|
+
y = y || this.lumaPlane(format);
|
|
221
|
+
u = u || this.chromaPlane(format);
|
|
222
|
+
v = v || this.chromaPlane(format);
|
|
223
|
+
return {
|
|
224
|
+
format: format,
|
|
225
|
+
y: y,
|
|
226
|
+
u: u,
|
|
227
|
+
v: v
|
|
228
|
+
};
|
|
229
|
+
},
|
|
230
|
+
/**
|
|
231
|
+
* Duplicate a plane using new buffer memory.
|
|
232
|
+
* @param {YUVPlane} plane - input plane to copy
|
|
233
|
+
* @returns {YUVPlane} - freshly allocated and filled planar buffer
|
|
234
|
+
*/
|
|
235
|
+
copyPlane: function (plane) {
|
|
236
|
+
return {
|
|
237
|
+
bytes: plane.bytes.slice(),
|
|
238
|
+
stride: plane.stride
|
|
239
|
+
};
|
|
240
|
+
},
|
|
241
|
+
/**
|
|
242
|
+
* Duplicate a frame using new buffer memory.
|
|
243
|
+
* @param {YUVFrame} frame - input frame to copyFrame
|
|
244
|
+
* @returns {YUVFrame} - freshly allocated and filled frame buffer
|
|
245
|
+
*/
|
|
246
|
+
copyFrame: function (frame) {
|
|
247
|
+
return {
|
|
248
|
+
format: frame.format,
|
|
249
|
+
y: this.copyPlane(frame.y),
|
|
250
|
+
u: this.copyPlane(frame.u),
|
|
251
|
+
v: this.copyPlane(frame.v)
|
|
252
|
+
};
|
|
253
|
+
},
|
|
254
|
+
/**
|
|
255
|
+
* List the backing buffers for the frame's planes for transfer between
|
|
256
|
+
* threads via Worker.postMessage.
|
|
257
|
+
* @param {YUVFrame} frame - input frame
|
|
258
|
+
* @returns {Array} - list of transferable objects
|
|
259
|
+
*/
|
|
260
|
+
transferables: function (frame) {
|
|
261
|
+
return [frame.y.bytes.buffer, frame.u.bytes.buffer, frame.v.bytes.buffer];
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
exports.default = YUVBuffer;
|
package/liteav/trtc.d.ts
CHANGED
|
@@ -20,7 +20,6 @@ declare class TRTCCloud extends EventEmitter {
|
|
|
20
20
|
private streams;
|
|
21
21
|
private firstVideoFrameList;
|
|
22
22
|
private playStreamType;
|
|
23
|
-
private renderMode;
|
|
24
23
|
private localFillMode;
|
|
25
24
|
private imageData;
|
|
26
25
|
private localVideoCallback;
|
|
@@ -608,7 +607,7 @@ declare class TRTCCloud extends EventEmitter {
|
|
|
608
607
|
* - ERR_AUDIO_PLUGIN_INSTALL_FAILED (-1332) :安装音频驱动插件失败
|
|
609
608
|
*/
|
|
610
609
|
handleOnSystemAudioLoopbackError(errCode: number): void;
|
|
611
|
-
|
|
610
|
+
handleVideoSizeChange(userId: string, streamType: number, width: number, height: number): void;
|
|
612
611
|
/**
|
|
613
612
|
* 1.1 进入房间
|
|
614
613
|
*
|
|
@@ -2019,7 +2018,10 @@ declare class TRTCCloud extends EventEmitter {
|
|
|
2019
2018
|
addLocalVideoRenderCallback(): void;
|
|
2020
2019
|
addRemoteVideoRenderCallback(userId: string): void;
|
|
2021
2020
|
/**
|
|
2022
|
-
*
|
|
2021
|
+
* 废弃接口:选择绘制的模式 (webgl/yuvcanvs/)
|
|
2022
|
+
*
|
|
2023
|
+
* @deprecated 从 10.3.403 版本该接口被废弃。SDK 内部会根据视频流数据,自动选择合适的渲染方式,可能的渲染方式有 WebGL、Canvas 2D、video 标签。调用该接口不再修改视频的渲染方式。
|
|
2024
|
+
*
|
|
2023
2025
|
* @param {Number} mode -
|
|
2024
2026
|
* - 1 webgl
|
|
2025
2027
|
* - 2 yuvcanvs
|
|
@@ -2038,12 +2040,6 @@ declare class TRTCCloud extends EventEmitter {
|
|
|
2038
2040
|
setPluginCallback(pluginCb: (pluginId: string, errorCode: number, msg: string) => void): void;
|
|
2039
2041
|
getKey(uid: string, type: TRTCVideoStreamType): string;
|
|
2040
2042
|
setEnableRenderFrame(enable: boolean): void;
|
|
2041
|
-
/**
|
|
2042
|
-
* 判断是否支持webGL
|
|
2043
|
-
* @returns {boolean}
|
|
2044
|
-
* @private
|
|
2045
|
-
*/
|
|
2046
|
-
_isSupportWebGL(): boolean;
|
|
2047
2043
|
_getRenderer(uid: string, type: TRTCVideoStreamType): any;
|
|
2048
2044
|
_onRenderFrame(uid: string, type: TRTCVideoStreamType, width: number, height: number, timestamp: number, rotation: number, data: any): void;
|
|
2049
2045
|
_onRealRender(uid: string, type: TRTCVideoStreamType, width: number, height: number, timestamp: number, rotation: number, data: any): void;
|
|
@@ -2064,6 +2060,7 @@ declare class TRTCCloud extends EventEmitter {
|
|
|
2064
2060
|
_initImageData(width: number, height: number): void;
|
|
2065
2061
|
_YUV2RGBA(width: number, height: number, buffer: ArrayBufferLike): Uint8ClampedArray;
|
|
2066
2062
|
_BGRA2RGBA(data: ArrayBuffer, width: number, height: number): Uint8ClampedArray;
|
|
2063
|
+
_RGBA2BGRA(data: ArrayBuffer, width: number, height: number): Uint8ClampedArray;
|
|
2067
2064
|
_isMacPlatform(): boolean;
|
|
2068
2065
|
}
|
|
2069
2066
|
export default TRTCCloud;
|