trtc-electron-sdk 9.9.8-beta.0 → 10.0.100-beta.2
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/Canvas3DRGBARenderer/index.js +240 -0
- package/liteav/Render/RGBRenderer/index.js +39 -71
- package/liteav/Render/SoftwareRenderer/index.js +15 -52
- package/liteav/Render/index.d.ts +1 -0
- package/liteav/Render/index.js +3 -1
- package/liteav/Render/util.d.ts +14 -1
- package/liteav/Render/util.js +65 -2
- package/liteav/trtc.d.ts +19 -28
- package/liteav/trtc.js +53 -66
- package/liteav/trtc_define.d.ts +11 -35
- package/liteav/trtc_define.js +16 -40
- package/package.json +1 -1
- package/scripts/publish-doc.js +1 -1
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const EventEmitter = require('events').EventEmitter;
|
|
4
|
+
const isEqual = require('lodash.isequal');
|
|
5
|
+
const { calcCanvasStyle } = require('../util');
|
|
6
|
+
class Canvas3DRGBARenderer {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.cacheCanvasOpts = {};
|
|
9
|
+
this.event = new EventEmitter();
|
|
10
|
+
this.ready = false;
|
|
11
|
+
this.contentMode = 1;
|
|
12
|
+
this.container = null;
|
|
13
|
+
this.canvas = null;
|
|
14
|
+
this.element = null;
|
|
15
|
+
this.gl = null;
|
|
16
|
+
this.glProgram = null;
|
|
17
|
+
this.vShader = null;
|
|
18
|
+
this.fShader = null;
|
|
19
|
+
this.samplerUniform = null;
|
|
20
|
+
this.texture = null;
|
|
21
|
+
this.vertex = [
|
|
22
|
+
-1, -1, 0,
|
|
23
|
+
1, -1, 0.0,
|
|
24
|
+
1, 1, 0.0,
|
|
25
|
+
-1, 1, 0.0
|
|
26
|
+
];
|
|
27
|
+
this.vertexIndices = [
|
|
28
|
+
0, 1, 2,
|
|
29
|
+
0, 2, 3
|
|
30
|
+
];
|
|
31
|
+
this.triangleTexCoords = [
|
|
32
|
+
0.0, 0.0,
|
|
33
|
+
1.0, 0.0,
|
|
34
|
+
1.0, 1.0,
|
|
35
|
+
0.0, 1.0
|
|
36
|
+
];
|
|
37
|
+
}
|
|
38
|
+
_initGL() {
|
|
39
|
+
try {
|
|
40
|
+
this.gl = this.canvas.getContext('webgl', { alpha: true, premultipliedAlpha: false });
|
|
41
|
+
}
|
|
42
|
+
catch (e) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
if (this.gl) {
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
_initShaders() {
|
|
53
|
+
const VSHADER_SOURCE = 'attribute vec3 aPos; ' +
|
|
54
|
+
'attribute vec2 aVertexTextureCoord; ' +
|
|
55
|
+
'varying mediump vec2 vTextureCoord; ' +
|
|
56
|
+
'void main(void){ ' +
|
|
57
|
+
' gl_Position = vec4(aPos, 1); ' +
|
|
58
|
+
' vTextureCoord = aVertexTextureCoord;' +
|
|
59
|
+
'}';
|
|
60
|
+
const FSHADER_SOURCE = 'varying mediump vec2 vTextureCoord; ' +
|
|
61
|
+
'uniform sampler2D uSampler; ' +
|
|
62
|
+
'void main(void) { ' +
|
|
63
|
+
' gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.s, vTextureCoord.t)); ' +
|
|
64
|
+
'}';
|
|
65
|
+
// compile shaders
|
|
66
|
+
const vertexShader = this._makeShader(VSHADER_SOURCE, this.gl.VERTEX_SHADER);
|
|
67
|
+
const fragmentShader = this._makeShader(FSHADER_SOURCE, this.gl.FRAGMENT_SHADER);
|
|
68
|
+
this.vShader = vertexShader;
|
|
69
|
+
this.fShader = fragmentShader;
|
|
70
|
+
if (!vertexShader || !fragmentShader) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
// create program
|
|
74
|
+
this.glProgram = this.gl.createProgram();
|
|
75
|
+
// attach and link shaders to the program
|
|
76
|
+
this.gl.attachShader(this.glProgram, vertexShader);
|
|
77
|
+
this.gl.attachShader(this.glProgram, fragmentShader);
|
|
78
|
+
this.gl.linkProgram(this.glProgram);
|
|
79
|
+
if (!this.gl.getProgramParameter(this.glProgram, this.gl.LINK_STATUS)) {
|
|
80
|
+
console.log('Unable to initialize the shader program.');
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
this.gl.useProgram(this.glProgram);
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
_makeShader(src, type) {
|
|
89
|
+
//compile the vertex shader
|
|
90
|
+
const shader = this.gl.createShader(type);
|
|
91
|
+
this.gl.shaderSource(shader, src);
|
|
92
|
+
this.gl.compileShader(shader);
|
|
93
|
+
if (!this.gl.getShaderParameter(shader, this.gl.COMPILE_STATUS)) {
|
|
94
|
+
console.log(`Error compiling shader: ${this.gl.getShaderInfoLog(shader)}`);
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
return shader;
|
|
98
|
+
}
|
|
99
|
+
_initUniforms() {
|
|
100
|
+
this.samplerUniform = this.gl.getUniformLocation(this.glProgram, 'uSampler');
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
_initTexture() {
|
|
104
|
+
this.texture = this.gl.createTexture();
|
|
105
|
+
this.gl.bindTexture(this.gl.TEXTURE_2D, this.texture);
|
|
106
|
+
// this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL, true);
|
|
107
|
+
this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MIN_FILTER, this.gl.LINEAR);
|
|
108
|
+
this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MAG_FILTER, this.gl.LINEAR);
|
|
109
|
+
this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_S, this.gl.CLAMP_TO_EDGE);
|
|
110
|
+
this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_T, this.gl.CLAMP_TO_EDGE);
|
|
111
|
+
}
|
|
112
|
+
_initTextureAttribute() {
|
|
113
|
+
// vertex data
|
|
114
|
+
const vertexBuffer = this.gl.createBuffer();
|
|
115
|
+
this.gl.bindBuffer(this.gl.ARRAY_BUFFER, vertexBuffer);
|
|
116
|
+
this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array(this.vertex), this.gl.STATIC_DRAW);
|
|
117
|
+
// indices data
|
|
118
|
+
const vertexIndicesBuffer = this.gl.createBuffer();
|
|
119
|
+
this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, vertexIndicesBuffer);
|
|
120
|
+
this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(this.vertexIndices), this.gl.STATIC_DRAW);
|
|
121
|
+
// set position attribute
|
|
122
|
+
const aVertexPosition = this.gl.getAttribLocation(this.glProgram, 'aPos');
|
|
123
|
+
this.gl.vertexAttribPointer(aVertexPosition, 3, this.gl.FLOAT, false, 0, 0);
|
|
124
|
+
this.gl.enableVertexAttribArray(aVertexPosition);
|
|
125
|
+
// texture coordinate data
|
|
126
|
+
const trianglesTexCoordBuffer = this.gl.createBuffer();
|
|
127
|
+
this.gl.bindBuffer(this.gl.ARRAY_BUFFER, trianglesTexCoordBuffer);
|
|
128
|
+
this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array(this.triangleTexCoords), this.gl.STATIC_DRAW);
|
|
129
|
+
// set texture coordinate attribute
|
|
130
|
+
const vertexTexCoordAttribute = this.gl.getAttribLocation(this.glProgram, 'aVertexTextureCoord');
|
|
131
|
+
this.gl.enableVertexAttribArray(vertexTexCoordAttribute);
|
|
132
|
+
this.gl.vertexAttribPointer(vertexTexCoordAttribute, 2, this.gl.FLOAT, false, 0, 0);
|
|
133
|
+
}
|
|
134
|
+
getView() {
|
|
135
|
+
return this.element;
|
|
136
|
+
}
|
|
137
|
+
bind(element) {
|
|
138
|
+
this.element = element;
|
|
139
|
+
const container = document.createElement('div');
|
|
140
|
+
Object.assign(container.style, {
|
|
141
|
+
width: '100%',
|
|
142
|
+
height: '100%',
|
|
143
|
+
display: 'flex',
|
|
144
|
+
justifyContent: 'center',
|
|
145
|
+
alignItems: 'center',
|
|
146
|
+
willChange: 'transform',
|
|
147
|
+
});
|
|
148
|
+
this.container = container;
|
|
149
|
+
element.appendChild(this.container);
|
|
150
|
+
this.canvas = document.createElement('canvas');
|
|
151
|
+
this.container.appendChild(this.canvas);
|
|
152
|
+
// init webgl & context
|
|
153
|
+
let ret = false;
|
|
154
|
+
do {
|
|
155
|
+
ret = this._initGL();
|
|
156
|
+
if (!ret) {
|
|
157
|
+
console.log('initGL failed');
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
ret = this._initShaders();
|
|
161
|
+
if (!ret) {
|
|
162
|
+
console.log('initShaders failed');
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
ret = this._initUniforms();
|
|
166
|
+
if (!ret) {
|
|
167
|
+
console.log('initUniforms failed');
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
} while (false);
|
|
171
|
+
if (ret) {
|
|
172
|
+
this._initTextureAttribute();
|
|
173
|
+
this._initTexture();
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
unbind() {
|
|
177
|
+
this.texture = null;
|
|
178
|
+
this.samplerUniform = null;
|
|
179
|
+
this.vShader = null;
|
|
180
|
+
this.fShader = null;
|
|
181
|
+
this.glProgram = null;
|
|
182
|
+
this.gl = null;
|
|
183
|
+
this.container && this.container.removeChild(this.canvas);
|
|
184
|
+
this.element && this.element.removeChild(this.container);
|
|
185
|
+
this.container = null;
|
|
186
|
+
this.element = null;
|
|
187
|
+
}
|
|
188
|
+
updateCanvas(options = {
|
|
189
|
+
contentWidth: 0,
|
|
190
|
+
contentHeight: 0,
|
|
191
|
+
rotation: 0,
|
|
192
|
+
mirrorView: false,
|
|
193
|
+
contentMode: 0,
|
|
194
|
+
containerWidth: 0,
|
|
195
|
+
containerHeight: 0,
|
|
196
|
+
isNeedRotate: true
|
|
197
|
+
}) {
|
|
198
|
+
if (isEqual(this.cacheCanvasOpts, options)) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
this.cacheCanvasOpts = Object.assign({}, options);
|
|
202
|
+
const { width, height, transform } = calcCanvasStyle(options);
|
|
203
|
+
this.canvas.width = width;
|
|
204
|
+
this.canvas.height = height;
|
|
205
|
+
this.canvas.style.transform = `${transform} rotateX(180deg)`;
|
|
206
|
+
}
|
|
207
|
+
drawFrame(imageData) {
|
|
208
|
+
if (!this.ready) {
|
|
209
|
+
this.ready = true;
|
|
210
|
+
this.event.emit('ready');
|
|
211
|
+
}
|
|
212
|
+
const mirror = false;
|
|
213
|
+
const contentWidth = imageData.width;
|
|
214
|
+
const contentHeight = imageData.height;
|
|
215
|
+
const rotation = imageData.rotation;
|
|
216
|
+
const isNeedRotate = imageData.isNeedRotate;
|
|
217
|
+
this.updateCanvas({
|
|
218
|
+
contentWidth,
|
|
219
|
+
contentHeight,
|
|
220
|
+
rotation,
|
|
221
|
+
mirrorView: mirror,
|
|
222
|
+
contentMode: this.contentMode,
|
|
223
|
+
containerWidth: this.container.clientWidth,
|
|
224
|
+
containerHeight: this.container.clientHeight,
|
|
225
|
+
isNeedRotate
|
|
226
|
+
});
|
|
227
|
+
try {
|
|
228
|
+
this.gl.viewport(0, 0, contentWidth, contentHeight);
|
|
229
|
+
this.gl.texImage2D(this.gl.TEXTURE_2D, 0, this.gl.RGBA, contentWidth, contentHeight, 0, this.gl.RGBA, this.gl.UNSIGNED_BYTE, new Uint8Array(imageData.data));
|
|
230
|
+
this.gl.drawElements(this.gl.TRIANGLES, 6, this.gl.UNSIGNED_SHORT, 0);
|
|
231
|
+
}
|
|
232
|
+
catch (error) {
|
|
233
|
+
console.error(error);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
setContentMode(mode = 0) {
|
|
237
|
+
this.contentMode = mode;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
exports.default = Canvas3DRGBARenderer;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const EventEmitter = require('events').EventEmitter;
|
|
4
4
|
const isEqual = require('lodash.isequal');
|
|
5
|
-
const {
|
|
5
|
+
const { calcCanvasStyle } = require('../util');
|
|
6
6
|
/* contentMode
|
|
7
7
|
* - 0: Cropped mode. Uniformly scale the video until it fills the visible boundaries (cropped). One dimension of the video may have clipped contents.
|
|
8
8
|
* - 1: Fit mode. Uniformly scale the video until one of its dimension fits the boundary (zoomed to fit). Areas that are not filled due to the disparity
|
|
@@ -21,33 +21,6 @@ class RGBRenderer {
|
|
|
21
21
|
getView() {
|
|
22
22
|
return this.element;
|
|
23
23
|
}
|
|
24
|
-
_calcZoom(vertical = false, contentMode = 0, width, height, clientWidth, clientHeight) {
|
|
25
|
-
let localRatio = clientWidth / clientHeight;
|
|
26
|
-
let tempRatio = width / height;
|
|
27
|
-
if (isNaN(localRatio) || isNaN(tempRatio)) {
|
|
28
|
-
return 1;
|
|
29
|
-
}
|
|
30
|
-
if (!contentMode) {
|
|
31
|
-
if (vertical) {
|
|
32
|
-
return localRatio > tempRatio ?
|
|
33
|
-
clientHeight / height : clientWidth / width;
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
return localRatio < tempRatio ?
|
|
37
|
-
clientHeight / height : clientWidth / width;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
if (vertical) {
|
|
42
|
-
return localRatio < tempRatio ?
|
|
43
|
-
clientHeight / height : clientWidth / width;
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
return localRatio > tempRatio ?
|
|
47
|
-
clientHeight / height : clientWidth / width;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
24
|
bind(element) {
|
|
52
25
|
this.element = element;
|
|
53
26
|
let container = document.createElement('div');
|
|
@@ -73,64 +46,59 @@ class RGBRenderer {
|
|
|
73
46
|
refreshCanvas() {
|
|
74
47
|
}
|
|
75
48
|
updateCanvas(options = {
|
|
76
|
-
|
|
77
|
-
|
|
49
|
+
contentWidth: 0,
|
|
50
|
+
contentHeight: 0,
|
|
78
51
|
rotation: 0,
|
|
79
52
|
mirrorView: false,
|
|
80
53
|
contentMode: 0,
|
|
81
|
-
|
|
82
|
-
|
|
54
|
+
containerWidth: 0,
|
|
55
|
+
containerHeight: 0,
|
|
83
56
|
isNeedRotate: true
|
|
84
57
|
}) {
|
|
85
58
|
if (isEqual(this.cacheCanvasOpts, options)) {
|
|
86
59
|
return;
|
|
87
60
|
}
|
|
88
61
|
this.cacheCanvasOpts = Object.assign({}, options);
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
if (isKeepWidthHeight) {
|
|
94
|
-
this.canvas.width = options.width;
|
|
95
|
-
this.canvas.height = options.height;
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
this.canvas.height = options.width;
|
|
99
|
-
this.canvas.width = options.height;
|
|
100
|
-
}
|
|
101
|
-
this.canvas.style.zoom = this._calcZoom(!isKeepWidthHeight, options.contentMode, options.width, options.height, options.clientWidth, options.clientHeight);
|
|
102
|
-
if (options.mirrorView) {
|
|
103
|
-
this.canvas.style.transform = 'rotateY(180deg)';
|
|
104
|
-
}
|
|
62
|
+
const { width, height, transform } = calcCanvasStyle(options);
|
|
63
|
+
this.canvas.width = width;
|
|
64
|
+
this.canvas.height = height;
|
|
65
|
+
this.canvas.style.transform = transform;
|
|
105
66
|
}
|
|
106
67
|
drawFrame(imageData) {
|
|
107
68
|
if (!this.ready) {
|
|
108
69
|
this.ready = true;
|
|
109
70
|
this.event.emit('ready');
|
|
110
71
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
72
|
+
try {
|
|
73
|
+
let mirror = false;
|
|
74
|
+
let contentWidth = imageData.width;
|
|
75
|
+
let contentHeight = imageData.height;
|
|
76
|
+
const isNeedRotate = imageData.isNeedRotate;
|
|
77
|
+
let left = 0;
|
|
78
|
+
let top = 0;
|
|
79
|
+
let right = 0;
|
|
80
|
+
let bottom = 0;
|
|
81
|
+
let rotation = imageData.rotation;
|
|
82
|
+
let ts = imageData.timestamp;
|
|
83
|
+
let width = contentWidth + left + right;
|
|
84
|
+
let height = contentHeight + top + bottom;
|
|
85
|
+
this.updateCanvas({
|
|
86
|
+
contentWidth: width,
|
|
87
|
+
contentHeight: height,
|
|
88
|
+
rotation,
|
|
89
|
+
mirrorView: mirror,
|
|
90
|
+
contentMode: this.contentMode,
|
|
91
|
+
containerWidth: this.container.clientWidth,
|
|
92
|
+
containerHeight: this.container.clientHeight,
|
|
93
|
+
isNeedRotate
|
|
94
|
+
});
|
|
95
|
+
let ctx = this.canvas.getContext("2d");
|
|
96
|
+
let newImage = new ImageData(new Uint8ClampedArray(imageData.data), width, height);
|
|
97
|
+
ctx.putImageData(newImage, 0, 0);
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
console.error('RGBRenderer.drawFrame error:', error);
|
|
101
|
+
}
|
|
134
102
|
}
|
|
135
103
|
setContentMode(mode = 0) {
|
|
136
104
|
this.contentMode = mode;
|
|
@@ -4,7 +4,7 @@ const EventEmitter = require('events').EventEmitter;
|
|
|
4
4
|
const isEqual = require('lodash.isequal');
|
|
5
5
|
const YUVBuffer = require('yuv-buffer');
|
|
6
6
|
const YUVCanvas = require('yuv-canvas');
|
|
7
|
-
const {
|
|
7
|
+
const { calcCanvasStyle } = require('../util');
|
|
8
8
|
/* contentMode
|
|
9
9
|
* - 0: Cropped mode. Uniformly scale the video until it fills the visible boundaries (cropped).
|
|
10
10
|
* One dimension of the video may have clipped contents.
|
|
@@ -25,33 +25,6 @@ class Renderer {
|
|
|
25
25
|
getView() {
|
|
26
26
|
return this.element;
|
|
27
27
|
}
|
|
28
|
-
_calcZoom(vertical = false, contentMode = 0, width, height, clientWidth, clientHeight) {
|
|
29
|
-
const localRatio = clientWidth / clientHeight;
|
|
30
|
-
const tempRatio = width / height;
|
|
31
|
-
if (isNaN(localRatio) || isNaN(tempRatio)) {
|
|
32
|
-
return 1;
|
|
33
|
-
}
|
|
34
|
-
if (!contentMode) {
|
|
35
|
-
if (vertical) {
|
|
36
|
-
return localRatio > tempRatio
|
|
37
|
-
? clientHeight / height : clientWidth / width;
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
return localRatio < tempRatio
|
|
41
|
-
? clientHeight / height : clientWidth / width;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
if (vertical) {
|
|
46
|
-
return localRatio < tempRatio
|
|
47
|
-
? clientHeight / height : clientWidth / width;
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
return localRatio > tempRatio
|
|
51
|
-
? clientHeight / height : clientWidth / width;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
28
|
bind(element) {
|
|
56
29
|
this.element = element;
|
|
57
30
|
const container = document.createElement('div');
|
|
@@ -78,35 +51,23 @@ class Renderer {
|
|
|
78
51
|
refreshCanvas() {
|
|
79
52
|
}
|
|
80
53
|
updateCanvas(options = {
|
|
81
|
-
|
|
82
|
-
|
|
54
|
+
contentWidth: 0,
|
|
55
|
+
contentHeight: 0,
|
|
83
56
|
rotation: 0,
|
|
84
57
|
mirrorView: false,
|
|
85
58
|
contentMode: 0,
|
|
86
|
-
|
|
87
|
-
|
|
59
|
+
containerWidth: 0,
|
|
60
|
+
containerHeight: 0,
|
|
88
61
|
isNeedRotate: true
|
|
89
62
|
}) {
|
|
90
63
|
if (isEqual(this.cacheCanvasOpts, options)) {
|
|
91
64
|
return;
|
|
92
65
|
}
|
|
93
66
|
this.cacheCanvasOpts = Object.assign({}, options);
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
if (isNeedKeepWidthAndHeight(options.rotation, options.isNeedRotate)) {
|
|
99
|
-
this.canvas.width = options.width;
|
|
100
|
-
this.canvas.height = options.height;
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
this.canvas.height = options.width;
|
|
104
|
-
this.canvas.width = options.height;
|
|
105
|
-
}
|
|
106
|
-
this.canvas.style.zoom = this._calcZoom(!isKeepWidthHeight, options.contentMode, options.width, options.height, options.clientWidth, options.clientHeight);
|
|
107
|
-
if (options.mirrorView) {
|
|
108
|
-
this.canvas.style.transform = 'rotateY(180deg)';
|
|
109
|
-
}
|
|
67
|
+
const { width, height, transform } = calcCanvasStyle(options);
|
|
68
|
+
this.canvas.width = width;
|
|
69
|
+
this.canvas.height = height;
|
|
70
|
+
this.canvas.style.transform = transform;
|
|
110
71
|
}
|
|
111
72
|
_adjustImageData(imageData) {
|
|
112
73
|
const { width, height, yUint8Array, uUint8Array, vUint8Array } = imageData;
|
|
@@ -151,7 +112,7 @@ class Renderer {
|
|
|
151
112
|
this.event.emit('ready');
|
|
152
113
|
}
|
|
153
114
|
imageData = this._adjustImageData(imageData);
|
|
154
|
-
const mirror =
|
|
115
|
+
const mirror = false;
|
|
155
116
|
const contentWidth = imageData.width;
|
|
156
117
|
const contentHeight = imageData.height;
|
|
157
118
|
const left = 0;
|
|
@@ -164,11 +125,13 @@ class Renderer {
|
|
|
164
125
|
const width = contentWidth + left + right;
|
|
165
126
|
const height = contentHeight + top + bottom;
|
|
166
127
|
this.updateCanvas({
|
|
167
|
-
width,
|
|
128
|
+
contentWidth: width,
|
|
129
|
+
contentHeight: height,
|
|
130
|
+
rotation,
|
|
168
131
|
mirrorView: mirror,
|
|
169
132
|
contentMode: this.contentMode,
|
|
170
|
-
|
|
171
|
-
|
|
133
|
+
containerWidth: this.container.clientWidth,
|
|
134
|
+
containerHeight: this.container.clientHeight,
|
|
172
135
|
isNeedRotate
|
|
173
136
|
});
|
|
174
137
|
const format = YUVBuffer.format({
|
package/liteav/Render/index.d.ts
CHANGED
package/liteav/Render/index.js
CHANGED
|
@@ -9,6 +9,7 @@ const GlRenderer_1 = __importDefault(require("./GlRenderer"));
|
|
|
9
9
|
const SoftwareRenderer_1 = __importDefault(require("./SoftwareRenderer"));
|
|
10
10
|
// @ts-ignore
|
|
11
11
|
const RGBRenderer_1 = __importDefault(require("./RGBRenderer"));
|
|
12
|
+
const Canvas3DRGBARenderer_1 = __importDefault(require("./Canvas3DRGBARenderer"));
|
|
12
13
|
class GlRenderer {
|
|
13
14
|
constructor() {
|
|
14
15
|
// @ts-ignore
|
|
@@ -51,5 +52,6 @@ exports.default = {
|
|
|
51
52
|
CustomRenderer,
|
|
52
53
|
GlRenderer,
|
|
53
54
|
SoftwareRenderer: SoftwareRenderer_1.default,
|
|
54
|
-
RGBRenderer: RGBRenderer_1.default
|
|
55
|
+
RGBRenderer: RGBRenderer_1.default,
|
|
56
|
+
Canvas3DRGBARenderer: Canvas3DRGBARenderer_1.default,
|
|
55
57
|
};
|
package/liteav/Render/util.d.ts
CHANGED
|
@@ -14,5 +14,18 @@ export declare class Config {
|
|
|
14
14
|
setDebugMode(enable: boolean): void;
|
|
15
15
|
getDebugMode(): boolean;
|
|
16
16
|
}
|
|
17
|
-
export declare function isNeedKeepWidthAndHeight(rotation: number, isNeedRotate: boolean): boolean;
|
|
18
17
|
export declare const config: Config;
|
|
18
|
+
export declare function isNeedKeepWidthAndHeight(rotation: number, isNeedRotate: boolean): boolean;
|
|
19
|
+
export declare function calcScaleRate(vertical: boolean, contentMode: number, contentWidth: number, contentHeight: number, containerWidth: number, containerHeight: number): number;
|
|
20
|
+
export declare function calcCanvasStyle(options?: {
|
|
21
|
+
contentWidth: number;
|
|
22
|
+
contentHeight: number;
|
|
23
|
+
rotation: number;
|
|
24
|
+
mirrorView: boolean;
|
|
25
|
+
contentMode: number;
|
|
26
|
+
containerWidth: number;
|
|
27
|
+
containerHeight: number;
|
|
28
|
+
isNeedRotate: boolean;
|
|
29
|
+
}): {
|
|
30
|
+
[x: string]: any;
|
|
31
|
+
};
|
package/liteav/Render/util.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.calcCanvasStyle = exports.calcScaleRate = exports.isNeedKeepWidthAndHeight = exports.config = exports.Config = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* 配置对象, 可用来打开 debug 模式
|
|
6
6
|
*
|
|
@@ -23,9 +23,72 @@ class Config {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
exports.Config = Config;
|
|
26
|
+
exports.config = new Config();
|
|
26
27
|
function isNeedKeepWidthAndHeight(rotation, isNeedRotate) {
|
|
27
28
|
// 需保持宽高不做变化
|
|
28
29
|
return rotation === 0 || rotation === 180 || !isNeedRotate;
|
|
29
30
|
}
|
|
30
31
|
exports.isNeedKeepWidthAndHeight = isNeedKeepWidthAndHeight;
|
|
31
|
-
|
|
32
|
+
function calcScaleRate(vertical = false, contentMode = 0, contentWidth, contentHeight, containerWidth, containerHeight) {
|
|
33
|
+
const containerRatio = containerWidth / containerHeight;
|
|
34
|
+
const contentRatio = contentWidth / contentHeight;
|
|
35
|
+
if (isNaN(containerRatio) || isNaN(contentRatio)) {
|
|
36
|
+
return 1;
|
|
37
|
+
}
|
|
38
|
+
if (!contentMode) {
|
|
39
|
+
if (vertical) {
|
|
40
|
+
return containerRatio > contentRatio
|
|
41
|
+
? containerHeight / contentHeight : containerWidth / contentWidth;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
return containerRatio < contentRatio
|
|
45
|
+
? containerHeight / contentHeight : containerWidth / contentWidth;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
if (vertical) {
|
|
50
|
+
return containerRatio < contentRatio
|
|
51
|
+
? containerHeight / contentHeight : containerWidth / contentWidth;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
return containerRatio > contentRatio
|
|
55
|
+
? containerHeight / contentHeight : containerWidth / contentWidth;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.calcScaleRate = calcScaleRate;
|
|
60
|
+
function calcCanvasStyle(options = {
|
|
61
|
+
contentWidth: 0,
|
|
62
|
+
contentHeight: 0,
|
|
63
|
+
rotation: 0,
|
|
64
|
+
mirrorView: false,
|
|
65
|
+
contentMode: 0,
|
|
66
|
+
containerWidth: 0,
|
|
67
|
+
containerHeight: 0,
|
|
68
|
+
isNeedRotate: true
|
|
69
|
+
}) {
|
|
70
|
+
if ([0, 90, 180, 270].indexOf(options.rotation) === -1) {
|
|
71
|
+
throw new Error('Invalid value for rotation. Only support 0, 90, 180, 270');
|
|
72
|
+
}
|
|
73
|
+
const style = {
|
|
74
|
+
width: 0,
|
|
75
|
+
height: 0,
|
|
76
|
+
transform: ''
|
|
77
|
+
};
|
|
78
|
+
const isKeepWidthHeight = isNeedKeepWidthAndHeight(options.rotation, options.isNeedRotate);
|
|
79
|
+
if (isNeedKeepWidthAndHeight(options.rotation, options.isNeedRotate)) {
|
|
80
|
+
style.width = options.contentWidth;
|
|
81
|
+
style.height = options.contentHeight;
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
style.height = options.contentWidth;
|
|
85
|
+
style.width = options.contentHeight;
|
|
86
|
+
}
|
|
87
|
+
const scale = calcScaleRate(!isKeepWidthHeight, options.contentMode, style.width, style.height, options.containerWidth, options.containerHeight);
|
|
88
|
+
style.transform = `scale(${scale})`;
|
|
89
|
+
if (options.mirrorView) {
|
|
90
|
+
style.transform = `${style.transform} rotateY(180deg)`;
|
|
91
|
+
}
|
|
92
|
+
return style;
|
|
93
|
+
}
|
|
94
|
+
exports.calcCanvasStyle = calcCanvasStyle;
|
package/liteav/trtc.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
|
-
import { AudioMusicParam, Rect, TRTCAppScene, TRTCAudioEffectParam, TRTCAudioQuality, TRTCBeautyStyle, TRTCDeviceState, TRTCDeviceType, TRTCLogLevel, TRTCRenderParams, TRTCRoleType, TRTCSwitchRoomParam, TRTCVideoBufferType, TRTCVideoFillMode, TRTCVideoFrame, TRTCVideoPixelFormat, TRTCVideoRotation, TRTCVideoStreamType, TRTCWaterMarkSrcType, PluginInfo, TRTCAudioRecordingParams, TRTCScreenCaptureSourceInfo, TRTCScreenCaptureProperty
|
|
3
|
+
import { AudioMusicParam, Rect, TRTCAppScene, TRTCAudioEffectParam, TRTCAudioQuality, TRTCBeautyStyle, TRTCDeviceState, TRTCDeviceType, TRTCLogLevel, TRTCRenderParams, TRTCRoleType, TRTCSwitchRoomParam, TRTCVideoBufferType, TRTCVideoFillMode, TRTCVideoFrame, TRTCVideoPixelFormat, TRTCVideoRotation, TRTCVideoStreamType, TRTCWaterMarkSrcType, PluginInfo, TRTCAudioRecordingParams, TRTCScreenCaptureSourceInfo, TRTCScreenCaptureProperty } from './trtc_define';
|
|
4
4
|
export * from './trtc_define';
|
|
5
5
|
export * from './trtc_code';
|
|
6
6
|
/**
|
|
@@ -335,15 +335,6 @@ declare class TRTCCloud extends EventEmitter {
|
|
|
335
335
|
* @param {Number} totalCount - 需要测速的服务器总数量
|
|
336
336
|
*/
|
|
337
337
|
bindOnSpeedTest(): void;
|
|
338
|
-
/**
|
|
339
|
-
* 5.5 网速测试的结果回调
|
|
340
|
-
*
|
|
341
|
-
* 该统计回调由 startSpeedTest 触发。
|
|
342
|
-
*
|
|
343
|
-
* @event TRTCCallback#onSpeedTestResult
|
|
344
|
-
* @param {TRTCSpeedTestResult} result 网速测试数据数据,包括丢包、往返延迟、上下行的带宽速率。
|
|
345
|
-
*/
|
|
346
|
-
bindOnSpeedTestResult(): void;
|
|
347
338
|
/**
|
|
348
339
|
* 6.1 摄像头准备就绪
|
|
349
340
|
*
|
|
@@ -1161,10 +1152,9 @@ declare class TRTCCloud extends EventEmitter {
|
|
|
1161
1152
|
* 我们在 Demo 中有一个音量大小的提示条,就是基于这个接口实现的。
|
|
1162
1153
|
* 如希望打开此功能,请在 startLocalAudio() 之前调用。
|
|
1163
1154
|
*
|
|
1164
|
-
* @param {Number} interval
|
|
1165
|
-
* @param {Boolean} enableVad - true: 打开人声检测;false: 关闭人声检测。目前仅 windows 支持。
|
|
1155
|
+
* @param {Number} interval - 设置 onUserVoiceVolume 回调的触发间隔,单位为ms,最小间隔为100ms,如果小于等于0则会关闭回调,建议设置为300ms
|
|
1166
1156
|
*/
|
|
1167
|
-
enableAudioVolumeEvaluation(interval: number
|
|
1157
|
+
enableAudioVolumeEvaluation(interval: number): void;
|
|
1168
1158
|
/**
|
|
1169
1159
|
* 4.12 开始录音
|
|
1170
1160
|
*
|
|
@@ -1794,6 +1784,13 @@ declare class TRTCCloud extends EventEmitter {
|
|
|
1794
1784
|
* @param {Number} volume - 音量大小,100为正常音量,取值范围为0 - 100;默认值:100
|
|
1795
1785
|
*/
|
|
1796
1786
|
setMusicPublishVolume(id: number, volume: number): void;
|
|
1787
|
+
/**
|
|
1788
|
+
* 11.22 调整背景音乐的变速效果
|
|
1789
|
+
*
|
|
1790
|
+
* @param {Number} id - 音乐 ID
|
|
1791
|
+
* @param {Number} speedRate - 速度,默认值是1.0f,范围是:[0.5 ~ 2] 之间的浮点数;
|
|
1792
|
+
*/
|
|
1793
|
+
setMusicSpeedRate(id: number, speedRate: number): void;
|
|
1797
1794
|
/**
|
|
1798
1795
|
* 12.1 废弃接口: 播放音效
|
|
1799
1796
|
*
|
|
@@ -1864,21 +1861,13 @@ declare class TRTCCloud extends EventEmitter {
|
|
|
1864
1861
|
* 测速结果将会用于优化 SDK 接下来的服务器选择策略,因此推荐您在用户首次通话前先进行一次测速,这将有助于我们选择最佳的服务器。
|
|
1865
1862
|
* 同时,如果测试结果非常不理想,您可以通过醒目的 UI 提示用户选择更好的网络。
|
|
1866
1863
|
*
|
|
1867
|
-
*
|
|
1868
|
-
* 1. 测速过程将产生少量的基础服务费用,详见 [计费概述 > 基础服务](https://cloud.tencent.com/document/product/647/17157#.E5.9F.BA.E7.A1.80.E6.9C.8D.E5.8A.A1) 文档说明。
|
|
1869
|
-
* 2. 请在进入房间前进行网速测试,在房间中网速测试会影响正常的音视频传输效果,而且由于干扰过多,网速测试结果也不准确。
|
|
1870
|
-
* 3. 同一时间只允许一项网速测试任务运行。
|
|
1871
|
-
*
|
|
1872
|
-
* @param {TRTCSpeedTestParams} params - 测速参数
|
|
1873
|
-
* @param {Number} params.sdkAppId - 应用标识
|
|
1874
|
-
* @param {String} params.userId - 用户标识
|
|
1875
|
-
* @param {String} params.userSig - 用户签名
|
|
1876
|
-
* @param {Number} params.expectedUpBandwidth - 预期的上行带宽(kbps,取值范围: 10 ~ 5000,为 0 时不测试)。
|
|
1877
|
-
* @param {Number} params.expectedDownBandwidth - 预期的下行带宽(kbps,取值范围: 10 ~ 5000,为 0 时不测试)。
|
|
1864
|
+
* 注意:测速本身会消耗一定的流量,所以也会产生少量额外的流量费用。
|
|
1878
1865
|
*
|
|
1879
|
-
* @
|
|
1866
|
+
* @param {Number} sdkAppId - 应用标识
|
|
1867
|
+
* @param {String} userId - 用户标识
|
|
1868
|
+
* @param {String} userSig - 用户签名
|
|
1880
1869
|
*/
|
|
1881
|
-
startSpeedTest(
|
|
1870
|
+
startSpeedTest(sdkAppId: number, userId: string, userSig: string): void;
|
|
1882
1871
|
/**
|
|
1883
1872
|
* 13.2 停止网络测速
|
|
1884
1873
|
*/
|
|
@@ -1994,8 +1983,10 @@ declare class TRTCCloud extends EventEmitter {
|
|
|
1994
1983
|
/**
|
|
1995
1984
|
* 选择绘制的模式 (webgl/yuvcanvs/)
|
|
1996
1985
|
* @param {Number} mode -
|
|
1997
|
-
* - 1
|
|
1998
|
-
* - 2
|
|
1986
|
+
* - 1 YUV WebGL
|
|
1987
|
+
* - 2 YUV Canvas 2D
|
|
1988
|
+
* - 3 RGBA Canvas 2D
|
|
1989
|
+
* - 4 RGBA WebGL
|
|
1999
1990
|
*/
|
|
2000
1991
|
setRenderMode(mode?: number): void;
|
|
2001
1992
|
initPluginManager(): void;
|
package/liteav/trtc.js
CHANGED
|
@@ -106,7 +106,7 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
106
106
|
this.firstVideoFrameList = [];
|
|
107
107
|
this.playStreamType = trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig;
|
|
108
108
|
this.pixelformate = trtc_define_1.TRTCVideoPixelFormat.TRTCVideoPixelFormat_I420;
|
|
109
|
-
this.renderMode = this._isSupportWebGL() ?
|
|
109
|
+
this.renderMode = this._isSupportWebGL() ? 4 : 3;
|
|
110
110
|
this.isExternalRenderEnabled = false;
|
|
111
111
|
this.localFillMode = trtc_define_1.TRTCVideoFillMode.TRTCVideoFillMode_Fit;
|
|
112
112
|
this.localRotation = trtc_define_1.TRTCVideoRotation.TRTCVideoRotation0;
|
|
@@ -346,7 +346,6 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
346
346
|
this.bindOnNetworkQuality();
|
|
347
347
|
this.bindOnStatistics();
|
|
348
348
|
this.bindOnSpeedTest();
|
|
349
|
-
this.bindOnSpeedTestResult();
|
|
350
349
|
this.bindOnUserVoiceVolume();
|
|
351
350
|
this.bindOnRecvCustomCmdMsg();
|
|
352
351
|
this.bindOnMissCustomCmdMsg();
|
|
@@ -509,15 +508,15 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
509
508
|
* @param {Number} reason - 离开原因,0表示用户主动退出房间,1表示用户超时退出,2表示被踢出房间。
|
|
510
509
|
*/
|
|
511
510
|
handleOnRemoteUserLeaveRoom(userId, reason) {
|
|
512
|
-
const streamTypeList = [
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
];
|
|
517
|
-
streamTypeList.forEach(streamType => {
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
});
|
|
511
|
+
// const streamTypeList = [
|
|
512
|
+
// TRTCVideoStreamType.TRTCVideoStreamTypeBig,
|
|
513
|
+
// TRTCVideoStreamType.TRTCVideoStreamTypeSub,
|
|
514
|
+
// TRTCVideoStreamType.TRTCVideoStreamTypeSmall
|
|
515
|
+
// ];
|
|
516
|
+
// streamTypeList.forEach(streamType => {
|
|
517
|
+
// const key = this.getKey(userId, streamType);
|
|
518
|
+
// this._destroyRender(key, null);
|
|
519
|
+
// });
|
|
521
520
|
this.fire('onRemoteUserLeaveRoom', userId, reason);
|
|
522
521
|
}
|
|
523
522
|
/**
|
|
@@ -726,19 +725,6 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
726
725
|
this.fire('onSpeedTest', currentResult, finishedCount, totalCount);
|
|
727
726
|
});
|
|
728
727
|
}
|
|
729
|
-
/**
|
|
730
|
-
* 5.5 网速测试的结果回调
|
|
731
|
-
*
|
|
732
|
-
* 该统计回调由 startSpeedTest 触发。
|
|
733
|
-
*
|
|
734
|
-
* @event TRTCCallback#onSpeedTestResult
|
|
735
|
-
* @param {TRTCSpeedTestResult} result 网速测试数据数据,包括丢包、往返延迟、上下行的带宽速率。
|
|
736
|
-
*/
|
|
737
|
-
bindOnSpeedTestResult() {
|
|
738
|
-
this.rtcCloud.onEvent('onSpeedTestResult', (result) => {
|
|
739
|
-
this.fire('onSpeedTestResult', result);
|
|
740
|
-
});
|
|
741
|
-
}
|
|
742
728
|
/////////////////////////////////////////////////////////////////////////////////
|
|
743
729
|
//
|
|
744
730
|
// (六)硬件设备事件回调
|
|
@@ -1945,11 +1931,10 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
1945
1931
|
* 我们在 Demo 中有一个音量大小的提示条,就是基于这个接口实现的。
|
|
1946
1932
|
* 如希望打开此功能,请在 startLocalAudio() 之前调用。
|
|
1947
1933
|
*
|
|
1948
|
-
* @param {Number} interval
|
|
1949
|
-
* @param {Boolean} enableVad - true: 打开人声检测;false: 关闭人声检测。目前仅 windows 支持。
|
|
1934
|
+
* @param {Number} interval - 设置 onUserVoiceVolume 回调的触发间隔,单位为ms,最小间隔为100ms,如果小于等于0则会关闭回调,建议设置为300ms
|
|
1950
1935
|
*/
|
|
1951
|
-
enableAudioVolumeEvaluation(interval
|
|
1952
|
-
this.rtcCloud.enableAudioVolumeEvaluation(interval
|
|
1936
|
+
enableAudioVolumeEvaluation(interval) {
|
|
1937
|
+
this.rtcCloud.enableAudioVolumeEvaluation(interval);
|
|
1953
1938
|
}
|
|
1954
1939
|
/**
|
|
1955
1940
|
* 4.12 开始录音
|
|
@@ -2876,6 +2861,15 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
2876
2861
|
setMusicPublishVolume(id, volume) {
|
|
2877
2862
|
this.rtcCloud.setMusicPublishVolume(id, volume);
|
|
2878
2863
|
}
|
|
2864
|
+
/**
|
|
2865
|
+
* 11.22 调整背景音乐的变速效果
|
|
2866
|
+
*
|
|
2867
|
+
* @param {Number} id - 音乐 ID
|
|
2868
|
+
* @param {Number} speedRate - 速度,默认值是1.0f,范围是:[0.5 ~ 2] 之间的浮点数;
|
|
2869
|
+
*/
|
|
2870
|
+
setMusicSpeedRate(id, speedRate) {
|
|
2871
|
+
this.rtcCloud.setMusicSpeedRate(id, speedRate);
|
|
2872
|
+
}
|
|
2879
2873
|
/////////////////////////////////////////////////////////////////////////////////
|
|
2880
2874
|
//
|
|
2881
2875
|
// (十二)音效相关接口函数
|
|
@@ -2983,31 +2977,14 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
2983
2977
|
* 测速结果将会用于优化 SDK 接下来的服务器选择策略,因此推荐您在用户首次通话前先进行一次测速,这将有助于我们选择最佳的服务器。
|
|
2984
2978
|
* 同时,如果测试结果非常不理想,您可以通过醒目的 UI 提示用户选择更好的网络。
|
|
2985
2979
|
*
|
|
2986
|
-
*
|
|
2987
|
-
* 1. 测速过程将产生少量的基础服务费用,详见 [计费概述 > 基础服务](https://cloud.tencent.com/document/product/647/17157#.E5.9F.BA.E7.A1.80.E6.9C.8D.E5.8A.A1) 文档说明。
|
|
2988
|
-
* 2. 请在进入房间前进行网速测试,在房间中网速测试会影响正常的音视频传输效果,而且由于干扰过多,网速测试结果也不准确。
|
|
2989
|
-
* 3. 同一时间只允许一项网速测试任务运行。
|
|
2990
|
-
*
|
|
2991
|
-
* @param {TRTCSpeedTestParams} params - 测速参数
|
|
2992
|
-
* @param {Number} params.sdkAppId - 应用标识
|
|
2993
|
-
* @param {String} params.userId - 用户标识
|
|
2994
|
-
* @param {String} params.userSig - 用户签名
|
|
2995
|
-
* @param {Number} params.expectedUpBandwidth - 预期的上行带宽(kbps,取值范围: 10 ~ 5000,为 0 时不测试)。
|
|
2996
|
-
* @param {Number} params.expectedDownBandwidth - 预期的下行带宽(kbps,取值范围: 10 ~ 5000,为 0 时不测试)。
|
|
2980
|
+
* 注意:测速本身会消耗一定的流量,所以也会产生少量额外的流量费用。
|
|
2997
2981
|
*
|
|
2998
|
-
* @
|
|
2982
|
+
* @param {Number} sdkAppId - 应用标识
|
|
2983
|
+
* @param {String} userId - 用户标识
|
|
2984
|
+
* @param {String} userSig - 用户签名
|
|
2999
2985
|
*/
|
|
3000
|
-
startSpeedTest(
|
|
3001
|
-
|
|
3002
|
-
return this.rtcCloud.startSpeedTest(params.sdkAppId, params.userId, params.userSig, params.expectedUpBandwidth, params.expectedDownBandwidth);
|
|
3003
|
-
}
|
|
3004
|
-
if (userId !== undefined && userSig !== undefined) {
|
|
3005
|
-
const sdkAppId = params;
|
|
3006
|
-
const speedTestParams = new trtc_define_1.TRTCSpeedTestParams(sdkAppId, userId, userSig);
|
|
3007
|
-
return this.rtcCloud.startSpeedTest(speedTestParams.sdkAppId, speedTestParams.userId, speedTestParams.userSig, speedTestParams.expectedUpBandwidth, speedTestParams.expectedDownBandwidth);
|
|
3008
|
-
}
|
|
3009
|
-
console.error('startSpeedTest, param is error');
|
|
3010
|
-
return -1;
|
|
2986
|
+
startSpeedTest(sdkAppId, userId, userSig) {
|
|
2987
|
+
this.rtcCloud.startSpeedTest(sdkAppId, userId, userSig);
|
|
3011
2988
|
}
|
|
3012
2989
|
/**
|
|
3013
2990
|
* 13.2 停止网络测速
|
|
@@ -3185,8 +3162,8 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
3185
3162
|
}
|
|
3186
3163
|
///------------------------内部方法-----------------------------
|
|
3187
3164
|
addLocalVideoRenderCallback() {
|
|
3188
|
-
if (this.isExternalRenderEnabled || this.renderMode === 3) {
|
|
3189
|
-
this.pixelformate = trtc_define_1.TRTCVideoPixelFormat.
|
|
3165
|
+
if (this.isExternalRenderEnabled || this.renderMode === 3 || this.renderMode === 4) {
|
|
3166
|
+
this.pixelformate = trtc_define_1.TRTCVideoPixelFormat.TRTCVideoPixelFormat_RGBA32;
|
|
3190
3167
|
}
|
|
3191
3168
|
else {
|
|
3192
3169
|
this.pixelformate = trtc_define_1.TRTCVideoPixelFormat.TRTCVideoPixelFormat_I420;
|
|
@@ -3198,8 +3175,8 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
3198
3175
|
}, this.pixelformate);
|
|
3199
3176
|
}
|
|
3200
3177
|
addRemoteVideoRenderCallback(userid) {
|
|
3201
|
-
if (this.isExternalRenderEnabled || this.renderMode === 3) {
|
|
3202
|
-
this.pixelformate = trtc_define_1.TRTCVideoPixelFormat.
|
|
3178
|
+
if (this.isExternalRenderEnabled || this.renderMode === 3 || this.renderMode === 4) {
|
|
3179
|
+
this.pixelformate = trtc_define_1.TRTCVideoPixelFormat.TRTCVideoPixelFormat_RGBA32;
|
|
3203
3180
|
}
|
|
3204
3181
|
else {
|
|
3205
3182
|
this.pixelformate = trtc_define_1.TRTCVideoPixelFormat.TRTCVideoPixelFormat_I420;
|
|
@@ -3216,10 +3193,15 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
3216
3193
|
/**
|
|
3217
3194
|
* 选择绘制的模式 (webgl/yuvcanvs/)
|
|
3218
3195
|
* @param {Number} mode -
|
|
3219
|
-
* - 1
|
|
3220
|
-
* - 2
|
|
3196
|
+
* - 1 YUV WebGL
|
|
3197
|
+
* - 2 YUV Canvas 2D
|
|
3198
|
+
* - 3 RGBA Canvas 2D
|
|
3199
|
+
* - 4 RGBA WebGL
|
|
3221
3200
|
*/
|
|
3222
3201
|
setRenderMode(mode = 1) {
|
|
3202
|
+
if ([1, 2, 3, 4].indexOf(mode) === -1) {
|
|
3203
|
+
throw new Error(`render mode '${mode}' not supported, please check API doc: https://web.sdk.qcloud.com/trtc/electron/doc/en-us/trtc_electron_sdk/TRTCCloud.html#setRenderMode`);
|
|
3204
|
+
}
|
|
3223
3205
|
if (this.renderMode !== mode) {
|
|
3224
3206
|
this.renderMode = mode;
|
|
3225
3207
|
// 遍历原有的renderer,改为新的渲染模式
|
|
@@ -3231,6 +3213,7 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
3231
3213
|
let view = value.getView();
|
|
3232
3214
|
this._initRender(key, view);
|
|
3233
3215
|
});
|
|
3216
|
+
console.debug('Render mode change to:', this.renderMode);
|
|
3234
3217
|
}
|
|
3235
3218
|
}
|
|
3236
3219
|
//----------------------------------//
|
|
@@ -3330,7 +3313,6 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
3330
3313
|
});
|
|
3331
3314
|
}
|
|
3332
3315
|
if (uid.length == 0 || uid === CAMERA_DEVICE_TEST_ID) {
|
|
3333
|
-
// 本地预览或者摄像头测试
|
|
3334
3316
|
if (this.isExternalRenderEnabled) {
|
|
3335
3317
|
this.fire(CUSTOM_VIDEO_DATA, {
|
|
3336
3318
|
uid: '', type, rotation, timestamp,
|
|
@@ -3345,6 +3327,7 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
3345
3327
|
data: {}
|
|
3346
3328
|
});
|
|
3347
3329
|
}
|
|
3330
|
+
// 本地预览
|
|
3348
3331
|
if (uid.length == 0) {
|
|
3349
3332
|
this._onRealRender('local_video', type, width, height, timestamp, rotation, data); //本地社视频返回的是空
|
|
3350
3333
|
//回调local view 给用户数据,本地数据
|
|
@@ -3354,6 +3337,7 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
3354
3337
|
}
|
|
3355
3338
|
}
|
|
3356
3339
|
}
|
|
3340
|
+
// 摄像头测试
|
|
3357
3341
|
if (uid === CAMERA_DEVICE_TEST_ID) {
|
|
3358
3342
|
this._onRealRender(CAMERA_DEVICE_TEST_VIEW, type, width, height, timestamp, rotation, data); //摄像头测试
|
|
3359
3343
|
}
|
|
@@ -3401,13 +3385,13 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
3401
3385
|
return;
|
|
3402
3386
|
}
|
|
3403
3387
|
const realRotation = rotation * 90; //ratation是0, 1, 2, 3. 绘制内部使用0, 90, 180, 270
|
|
3404
|
-
if (this.renderMode === 3) {
|
|
3388
|
+
if (this.renderMode === 3 || this.renderMode === 4) {
|
|
3405
3389
|
renderer.drawFrame({
|
|
3406
3390
|
width: width,
|
|
3407
3391
|
height: height,
|
|
3408
3392
|
rotation: realRotation,
|
|
3409
3393
|
timestamp: timestamp,
|
|
3410
|
-
data:
|
|
3394
|
+
data: data,
|
|
3411
3395
|
isNeedRotate
|
|
3412
3396
|
});
|
|
3413
3397
|
}
|
|
@@ -3446,6 +3430,9 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
3446
3430
|
else if (this.renderMode === 3) {
|
|
3447
3431
|
renderer = new Render_1.default.RGBRenderer();
|
|
3448
3432
|
}
|
|
3433
|
+
else if (this.renderMode === 4) {
|
|
3434
|
+
renderer = new Render_1.default.Canvas3DRGBARenderer();
|
|
3435
|
+
}
|
|
3449
3436
|
else {
|
|
3450
3437
|
console.warn('Unknown render mode, fallback to 1');
|
|
3451
3438
|
renderer = new Render_1.default.GlRenderer();
|
|
@@ -3562,15 +3549,15 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
3562
3549
|
}
|
|
3563
3550
|
_BGRA2RGBA(data, width, height) {
|
|
3564
3551
|
const bgraData = new Uint8ClampedArray(data.slice(0));
|
|
3565
|
-
const
|
|
3552
|
+
const rgbaData = new Uint8ClampedArray(data.slice(0));
|
|
3566
3553
|
// 将 BGRA8888 转成 RGBA8888
|
|
3567
3554
|
for (let i = 0; i < width * height; i++) {
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3555
|
+
rgbaData[4 * i] = bgraData[4 * i + 2];
|
|
3556
|
+
rgbaData[4 * i + 1] = bgraData[4 * i + 1];
|
|
3557
|
+
rgbaData[4 * i + 2] = bgraData[4 * i];
|
|
3558
|
+
rgbaData[4 * i + 3] = bgraData[4 * i + 3];
|
|
3572
3559
|
}
|
|
3573
|
-
return
|
|
3560
|
+
return rgbaData;
|
|
3574
3561
|
}
|
|
3575
3562
|
_isMacPlatform() {
|
|
3576
3563
|
return process.platform == 'darwin';
|
package/liteav/trtc_define.d.ts
CHANGED
|
@@ -61,7 +61,8 @@ export declare enum TRTCBeautyStyle {
|
|
|
61
61
|
export declare enum TRTCVideoPixelFormat {
|
|
62
62
|
TRTCVideoPixelFormat_Unknown = 0,
|
|
63
63
|
TRTCVideoPixelFormat_I420 = 1,
|
|
64
|
-
TRTCVideoPixelFormat_BGRA32 = 3
|
|
64
|
+
TRTCVideoPixelFormat_BGRA32 = 3,
|
|
65
|
+
TRTCVideoPixelFormat_RGBA32 = 5
|
|
65
66
|
}
|
|
66
67
|
export declare enum TRTCVideoBufferType {
|
|
67
68
|
TRTCVideoBufferType_Unknown = 0,
|
|
@@ -372,33 +373,12 @@ export declare class TRTCQualityInfo {
|
|
|
372
373
|
*
|
|
373
374
|
* @param {String} userId - 说话者的 userId,字符编码格式是 UTF-8
|
|
374
375
|
* @param {Number} volume - 说话者的音量, 取值范围0 - 100
|
|
375
|
-
* @param {Number} vad - 是否检测到人声。0:非人声 1:人声 -1: 不支持检测 (mac 平台暂不支持)
|
|
376
376
|
*
|
|
377
377
|
*/
|
|
378
378
|
export declare class TRTCVolumeInfo {
|
|
379
379
|
userId: string;
|
|
380
380
|
volume: number;
|
|
381
|
-
|
|
382
|
-
constructor(userId?: string, volume?: number, vad?: number);
|
|
383
|
-
}
|
|
384
|
-
/**
|
|
385
|
-
* 5.7 测速参数
|
|
386
|
-
*
|
|
387
|
-
* 您可以在用户进入房间前通过 [startSpeedTest]{@link TRTCCloud#startSpeedTest} 接口测试网速(注意:请不要在通话中调用)。
|
|
388
|
-
*
|
|
389
|
-
* @param {Number} sdkAppId - 应用标识
|
|
390
|
-
* @param {String} userId - 用户标识
|
|
391
|
-
* @param {String} userSig - 用户签名
|
|
392
|
-
* @param {Number} expectedUpBandwidth - 预期的上行带宽(kbps,取值范围: 10 ~ 5000,为 0 时不测试)。
|
|
393
|
-
* @param {Number} expectedDownBandwidth - 预期的下行带宽(kbps,取值范围: 10 ~ 5000,为 0 时不测试)。
|
|
394
|
-
*/
|
|
395
|
-
export declare class TRTCSpeedTestParams {
|
|
396
|
-
sdkAppId: number;
|
|
397
|
-
userId: string;
|
|
398
|
-
userSig: string;
|
|
399
|
-
expectedUpBandwidth: number;
|
|
400
|
-
expectedDownBandwidth: number;
|
|
401
|
-
constructor(sdkAppId?: number, userId?: string, userSig?: string, expectedUpBandwidth?: number, expectedDownBandwidth?: number);
|
|
381
|
+
constructor(userId?: string, volume?: number);
|
|
402
382
|
}
|
|
403
383
|
/**
|
|
404
384
|
* 5.8 网络测速结果
|
|
@@ -412,28 +392,20 @@ export declare class TRTCSpeedTestParams {
|
|
|
412
392
|
* - downLostRate 是指下行丢包率,例如0.2代表从服务器每收取10个数据包,可能有2个会在中途丢失。
|
|
413
393
|
* - rtt 是指当前设备到腾讯云服务器的一次网络往返时间,正常数值在10ms - 100ms之间。
|
|
414
394
|
*
|
|
415
|
-
* @param {Boolean} success - 测试是否成功, 9.3 版本新增字段
|
|
416
|
-
* @param {String} errMsg - 带宽测试错误信息, 9.3 版本新增字段
|
|
417
395
|
* @param {String} ip - 服务器 IP 地址
|
|
418
396
|
* @param {TRTCQuality} quality - 网络质量,内部通过评估算法测算出的网络质量,loss 越低,rtt 越小,得分也就越高
|
|
419
397
|
* @param {Number} upLostRate - 上行丢包率,范围是[0 - 1.0],例如0.3代表每向服务器发送10个数据包,可能有3个会在中途丢失。
|
|
420
398
|
* @param {Number} downLostRate - 下行丢包率,范围是[0 - 1.0],例如0.2代表从服务器每收取10个数据包,可能有2个会在中途丢失。
|
|
421
399
|
* @param {Number} rtt - 延迟(毫秒),代表 SDK 跟服务器一来一回之间所消耗的时间,这个值越小越好,正常数值在10ms - 100ms之间。
|
|
422
|
-
* @param {Number} availableUpBandwidth - 上行带宽(kbps,-1:无效值)。
|
|
423
|
-
* @param {Number} availableDownBandwidth - 下行带宽(kbps,-1:无效值)。
|
|
424
400
|
*
|
|
425
401
|
*/
|
|
426
402
|
export declare class TRTCSpeedTestResult {
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
ip: string;
|
|
430
|
-
quality: TRTCQuality;
|
|
403
|
+
ip: null | string;
|
|
404
|
+
quality: number;
|
|
431
405
|
upLostRate: number;
|
|
432
406
|
downLostRate: number;
|
|
433
407
|
rtt: number;
|
|
434
|
-
|
|
435
|
-
availableDownBandwidth: number;
|
|
436
|
-
constructor(success?: boolean, errMsg?: string, ip?: string, quality?: TRTCQuality, upLostRate?: number, downLostRate?: number, rtt?: number, availableUpBandwidth?: number, availableDownBandwidth?: number);
|
|
408
|
+
constructor();
|
|
437
409
|
}
|
|
438
410
|
/**
|
|
439
411
|
* 记录矩形的四个点坐标
|
|
@@ -680,6 +652,9 @@ export declare class TRTCRemoteStatistics {
|
|
|
680
652
|
* @param {Number} rtt - 延迟(毫秒),代表 SDK 跟服务器一来一回之间所消耗的时间,这个值越小越好。
|
|
681
653
|
* 一般低于50ms的 rtt 是比较理想的情况,而高于100ms的 rtt 会引入较大的通话延时。
|
|
682
654
|
* 由于数据上下行共享一条网络连接,所以 local 和 remote 的 rtt 相同。
|
|
655
|
+
* @param {Number} gatewayRtt - 延迟(毫秒),指 SDK 到本地路由器网关一次网络往返时间,该值越小越好。
|
|
656
|
+
* 一般低于 50ms 的 gatewayRtt 相对理想,而高于 200ms 的 gatewayRtt 会引入较大的通话延时。
|
|
657
|
+
* 当网络为蜂窝网非 WiFi 类型时,该值无效。
|
|
683
658
|
* @param {Number} receivedBytes - 总接收字节数(包含信令和音视频)
|
|
684
659
|
* @param {Number} sentBytes - 总发送字节总数(包含信令和音视频)
|
|
685
660
|
* @param {TRTCLocalStatistics[]} localStatisticsArray - 自己本地的音视频统计信息,由于可能有大画面、小画面以及辅路画面等多路的情况,所以是一个数组
|
|
@@ -694,13 +669,14 @@ export declare class TRTCStatistics {
|
|
|
694
669
|
appCpu: number;
|
|
695
670
|
systemCpu: number;
|
|
696
671
|
rtt: number;
|
|
672
|
+
gatewayRtt: number;
|
|
697
673
|
receivedBytes: number;
|
|
698
674
|
sentBytes: number;
|
|
699
675
|
localStatisticsArray: TRTCLocalStatistics[];
|
|
700
676
|
localStatisticsArraySize: number;
|
|
701
677
|
remoteStatisticsArray: TRTCRemoteStatistics[];
|
|
702
678
|
remoteStatisticsArraySize: number;
|
|
703
|
-
constructor(upLoss?: number, downLoss?: number, appCpu?: number, systemCpu?: number, rtt?: number, receivedBytes?: number, sentBytes?: number, localStatisticsArray?: TRTCLocalStatistics[], localStatisticsArraySize?: number, remoteStatisticsArray?: TRTCRemoteStatistics[], remoteStatisticsArraySize?: number);
|
|
679
|
+
constructor(upLoss?: number, downLoss?: number, appCpu?: number, systemCpu?: number, rtt?: number, gatewayRtt?: number, receivedBytes?: number, sentBytes?: number, localStatisticsArray?: TRTCLocalStatistics[], localStatisticsArraySize?: number, remoteStatisticsArray?: TRTCRemoteStatistics[], remoteStatisticsArraySize?: number);
|
|
704
680
|
}
|
|
705
681
|
/**
|
|
706
682
|
* 音乐参数
|
package/liteav/trtc_define.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.TRTCSwitchRoomParam = exports.AudioMusicParam = exports.TRTCStatistics = exports.TRTCRemoteStatistics = exports.TRTCLocalStatistics = exports.TRTCAudioEffectParam = exports.TRTCAudioRecordingParams = exports.TRTCPublishCDNParam = exports.TRTCTranscodingConfig = exports.TRTCAudioRecordingContent = exports.TRTCMixInputType = exports.TRTCTranscodingConfigMode = exports.TRTCMixUser = exports.Rect = exports.TRTCSpeedTestResult = exports.
|
|
9
|
+
exports.TRTCSwitchRoomParam = exports.AudioMusicParam = exports.TRTCStatistics = exports.TRTCRemoteStatistics = exports.TRTCLocalStatistics = exports.TRTCAudioEffectParam = exports.TRTCAudioRecordingParams = exports.TRTCPublishCDNParam = exports.TRTCTranscodingConfig = exports.TRTCAudioRecordingContent = exports.TRTCMixInputType = exports.TRTCTranscodingConfigMode = exports.TRTCMixUser = exports.Rect = exports.TRTCSpeedTestResult = exports.TRTCVolumeInfo = exports.TRTCQualityInfo = exports.TRTCNetworkQosParam = exports.TRTCRenderParams = exports.TRTCVideoEncParam = exports.TRTCParams = exports.TRTCWaterMarkSrcType = exports.TRTCDeviceType = exports.TRTCDeviceState = exports.TRTCLogLevel = exports.TRTCVideoFrame = exports.TRTCDeviceInfo = exports.TRTCScreenCaptureProperty = exports.TRTCScreenCaptureSourceInfo = exports.TRTCImageBuffer = exports.TRTCAudioQuality = exports.TRTCScreenCaptureSourceType = exports.TRTCAudioFrameFormat = exports.TRTCVideoQosPreference = exports.TRTCQosControlMode = exports.TRTCRoleType = exports.TRTCAppScene = exports.TRTCVideoMirrorType = exports.TRTCVideoBufferType = exports.TRTCVideoPixelFormat = exports.TRTCBeautyStyle = exports.TRTCVideoRotation = exports.TRTCVideoFillMode = exports.TRTCQuality = exports.TRTCVideoStreamType = exports.TRTCVideoResolutionMode = exports.TRTCVideoResolution = void 0;
|
|
10
10
|
/////////////////////////////////////////////////////////////////////////////////
|
|
11
11
|
//
|
|
12
12
|
// 【(一)视频相关枚举值定义】
|
|
@@ -257,6 +257,8 @@ const TRTCVideoPixelFormat_HACK_JSDOC = {
|
|
|
257
257
|
// TRTCVideoPixelFormat_Texture_2D: 2,
|
|
258
258
|
/** BGRA32 */
|
|
259
259
|
TRTCVideoPixelFormat_BGRA32: 3,
|
|
260
|
+
/** RGBA32 */
|
|
261
|
+
TRTCVideoPixelFormat_RGBA32: 5,
|
|
260
262
|
};
|
|
261
263
|
var TRTCVideoPixelFormat;
|
|
262
264
|
(function (TRTCVideoPixelFormat) {
|
|
@@ -264,6 +266,7 @@ var TRTCVideoPixelFormat;
|
|
|
264
266
|
TRTCVideoPixelFormat[TRTCVideoPixelFormat["TRTCVideoPixelFormat_I420"] = 1] = "TRTCVideoPixelFormat_I420";
|
|
265
267
|
// TRTCVideoPixelFormat_Texture_2D= 2,
|
|
266
268
|
TRTCVideoPixelFormat[TRTCVideoPixelFormat["TRTCVideoPixelFormat_BGRA32"] = 3] = "TRTCVideoPixelFormat_BGRA32";
|
|
269
|
+
TRTCVideoPixelFormat[TRTCVideoPixelFormat["TRTCVideoPixelFormat_RGBA32"] = 5] = "TRTCVideoPixelFormat_RGBA32";
|
|
267
270
|
})(TRTCVideoPixelFormat = exports.TRTCVideoPixelFormat || (exports.TRTCVideoPixelFormat = {}));
|
|
268
271
|
;
|
|
269
272
|
/**
|
|
@@ -875,39 +878,16 @@ exports.TRTCQualityInfo = TRTCQualityInfo;
|
|
|
875
878
|
*
|
|
876
879
|
* @param {String} userId - 说话者的 userId,字符编码格式是 UTF-8
|
|
877
880
|
* @param {Number} volume - 说话者的音量, 取值范围0 - 100
|
|
878
|
-
* @param {Number} vad - 是否检测到人声。0:非人声 1:人声 -1: 不支持检测 (mac 平台暂不支持)
|
|
879
881
|
*
|
|
880
882
|
*/
|
|
881
883
|
class TRTCVolumeInfo {
|
|
882
|
-
constructor(userId = '', volume = 0
|
|
884
|
+
constructor(userId = '', volume = 0) {
|
|
883
885
|
this.userId = userId;
|
|
884
886
|
this.volume = volume;
|
|
885
|
-
this.vad = vad;
|
|
886
887
|
}
|
|
887
888
|
}
|
|
888
889
|
exports.TRTCVolumeInfo = TRTCVolumeInfo;
|
|
889
890
|
;
|
|
890
|
-
/**
|
|
891
|
-
* 5.7 测速参数
|
|
892
|
-
*
|
|
893
|
-
* 您可以在用户进入房间前通过 [startSpeedTest]{@link TRTCCloud#startSpeedTest} 接口测试网速(注意:请不要在通话中调用)。
|
|
894
|
-
*
|
|
895
|
-
* @param {Number} sdkAppId - 应用标识
|
|
896
|
-
* @param {String} userId - 用户标识
|
|
897
|
-
* @param {String} userSig - 用户签名
|
|
898
|
-
* @param {Number} expectedUpBandwidth - 预期的上行带宽(kbps,取值范围: 10 ~ 5000,为 0 时不测试)。
|
|
899
|
-
* @param {Number} expectedDownBandwidth - 预期的下行带宽(kbps,取值范围: 10 ~ 5000,为 0 时不测试)。
|
|
900
|
-
*/
|
|
901
|
-
class TRTCSpeedTestParams {
|
|
902
|
-
constructor(sdkAppId = 0, userId = '', userSig = '', expectedUpBandwidth = 0, expectedDownBandwidth = 0) {
|
|
903
|
-
this.sdkAppId = sdkAppId;
|
|
904
|
-
this.userId = userId;
|
|
905
|
-
this.userSig = userSig;
|
|
906
|
-
this.expectedUpBandwidth = expectedUpBandwidth;
|
|
907
|
-
this.expectedDownBandwidth = expectedDownBandwidth;
|
|
908
|
-
}
|
|
909
|
-
}
|
|
910
|
-
exports.TRTCSpeedTestParams = TRTCSpeedTestParams;
|
|
911
891
|
/**
|
|
912
892
|
* 5.8 网络测速结果
|
|
913
893
|
*
|
|
@@ -920,28 +900,20 @@ exports.TRTCSpeedTestParams = TRTCSpeedTestParams;
|
|
|
920
900
|
* - downLostRate 是指下行丢包率,例如0.2代表从服务器每收取10个数据包,可能有2个会在中途丢失。
|
|
921
901
|
* - rtt 是指当前设备到腾讯云服务器的一次网络往返时间,正常数值在10ms - 100ms之间。
|
|
922
902
|
*
|
|
923
|
-
* @param {Boolean} success - 测试是否成功, 9.3 版本新增字段
|
|
924
|
-
* @param {String} errMsg - 带宽测试错误信息, 9.3 版本新增字段
|
|
925
903
|
* @param {String} ip - 服务器 IP 地址
|
|
926
904
|
* @param {TRTCQuality} quality - 网络质量,内部通过评估算法测算出的网络质量,loss 越低,rtt 越小,得分也就越高
|
|
927
905
|
* @param {Number} upLostRate - 上行丢包率,范围是[0 - 1.0],例如0.3代表每向服务器发送10个数据包,可能有3个会在中途丢失。
|
|
928
906
|
* @param {Number} downLostRate - 下行丢包率,范围是[0 - 1.0],例如0.2代表从服务器每收取10个数据包,可能有2个会在中途丢失。
|
|
929
907
|
* @param {Number} rtt - 延迟(毫秒),代表 SDK 跟服务器一来一回之间所消耗的时间,这个值越小越好,正常数值在10ms - 100ms之间。
|
|
930
|
-
* @param {Number} availableUpBandwidth - 上行带宽(kbps,-1:无效值)。
|
|
931
|
-
* @param {Number} availableDownBandwidth - 下行带宽(kbps,-1:无效值)。
|
|
932
908
|
*
|
|
933
909
|
*/
|
|
934
910
|
class TRTCSpeedTestResult {
|
|
935
|
-
constructor(
|
|
936
|
-
this.
|
|
937
|
-
this.
|
|
938
|
-
this.
|
|
939
|
-
this.
|
|
940
|
-
this.
|
|
941
|
-
this.downLostRate = downLostRate;
|
|
942
|
-
this.rtt = rtt;
|
|
943
|
-
this.availableUpBandwidth = availableUpBandwidth;
|
|
944
|
-
this.availableDownBandwidth = availableDownBandwidth;
|
|
911
|
+
constructor() {
|
|
912
|
+
this.ip = null;
|
|
913
|
+
this.quality = TRTCQuality.TRTCQuality_Unknown;
|
|
914
|
+
this.upLostRate = 0.0;
|
|
915
|
+
this.downLostRate = 0.0;
|
|
916
|
+
this.rtt = 0;
|
|
945
917
|
}
|
|
946
918
|
}
|
|
947
919
|
exports.TRTCSpeedTestResult = TRTCSpeedTestResult;
|
|
@@ -1296,6 +1268,9 @@ exports.TRTCRemoteStatistics = TRTCRemoteStatistics;
|
|
|
1296
1268
|
* @param {Number} rtt - 延迟(毫秒),代表 SDK 跟服务器一来一回之间所消耗的时间,这个值越小越好。
|
|
1297
1269
|
* 一般低于50ms的 rtt 是比较理想的情况,而高于100ms的 rtt 会引入较大的通话延时。
|
|
1298
1270
|
* 由于数据上下行共享一条网络连接,所以 local 和 remote 的 rtt 相同。
|
|
1271
|
+
* @param {Number} gatewayRtt - 延迟(毫秒),指 SDK 到本地路由器网关一次网络往返时间,该值越小越好。
|
|
1272
|
+
* 一般低于 50ms 的 gatewayRtt 相对理想,而高于 200ms 的 gatewayRtt 会引入较大的通话延时。
|
|
1273
|
+
* 当网络为蜂窝网非 WiFi 类型时,该值无效。
|
|
1299
1274
|
* @param {Number} receivedBytes - 总接收字节数(包含信令和音视频)
|
|
1300
1275
|
* @param {Number} sentBytes - 总发送字节总数(包含信令和音视频)
|
|
1301
1276
|
* @param {TRTCLocalStatistics[]} localStatisticsArray - 自己本地的音视频统计信息,由于可能有大画面、小画面以及辅路画面等多路的情况,所以是一个数组
|
|
@@ -1305,12 +1280,13 @@ exports.TRTCRemoteStatistics = TRTCRemoteStatistics;
|
|
|
1305
1280
|
*
|
|
1306
1281
|
*/
|
|
1307
1282
|
class TRTCStatistics {
|
|
1308
|
-
constructor(upLoss = 0, downLoss = 0, appCpu = 0, systemCpu = 0, rtt = 0, receivedBytes = 0, sentBytes = 0, localStatisticsArray = [], localStatisticsArraySize = 0, remoteStatisticsArray = [], remoteStatisticsArraySize = 0) {
|
|
1283
|
+
constructor(upLoss = 0, downLoss = 0, appCpu = 0, systemCpu = 0, rtt = 0, gatewayRtt = 0, receivedBytes = 0, sentBytes = 0, localStatisticsArray = [], localStatisticsArraySize = 0, remoteStatisticsArray = [], remoteStatisticsArraySize = 0) {
|
|
1309
1284
|
this.upLoss = upLoss;
|
|
1310
1285
|
this.downLoss = downLoss;
|
|
1311
1286
|
this.appCpu = appCpu;
|
|
1312
1287
|
this.systemCpu = systemCpu;
|
|
1313
1288
|
this.rtt = rtt;
|
|
1289
|
+
this.gatewayRtt = gatewayRtt;
|
|
1314
1290
|
this.receivedBytes = receivedBytes;
|
|
1315
1291
|
this.sentBytes = sentBytes;
|
|
1316
1292
|
this.localStatisticsArray = localStatisticsArray;
|
package/package.json
CHANGED
package/scripts/publish-doc.js
CHANGED
|
@@ -34,7 +34,7 @@ const cos = new COS({
|
|
|
34
34
|
|
|
35
35
|
const bucket = 'sdk-web-1252463788';
|
|
36
36
|
const region = 'ap-hongkong';
|
|
37
|
-
const keyPrefix = 'trtc/electron/doc/zh-cn/trtc_electron_sdk
|
|
37
|
+
const keyPrefix = 'trtc/electron/doc/zh-cn/trtc_electron_sdk';
|
|
38
38
|
const docPath = path.join(__dirname, '../_doc');
|
|
39
39
|
|
|
40
40
|
function walkSync(dir, filelist) {
|