trtc-electron-sdk 10.3.8-beta.2 → 10.3.100-alpha.0

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.
@@ -24,7 +24,7 @@ class Canvas3DRGBARenderer {
24
24
  1, 1, 0.0,
25
25
  -1, 1, 0.0
26
26
  ];
27
- this.vertexIndice = [
27
+ this.vertexIndices = [
28
28
  0, 1, 2,
29
29
  0, 2, 3
30
30
  ];
@@ -37,7 +37,7 @@ class Canvas3DRGBARenderer {
37
37
  }
38
38
  _initGL() {
39
39
  try {
40
- this.gl = this.canvas.getContext('webgl', { alpha: true, premultipliedAlpha: false }); //|| canvas.getContext("experimental-webgl", { antialias: false });
40
+ this.gl = this.canvas.getContext('webgl', { alpha: true, premultipliedAlpha: false });
41
41
  }
42
42
  catch (e) {
43
43
  return false;
@@ -103,22 +103,21 @@ class Canvas3DRGBARenderer {
103
103
  _initTexture() {
104
104
  this.texture = this.gl.createTexture();
105
105
  this.gl.bindTexture(this.gl.TEXTURE_2D, this.texture);
106
- // c++ addon 层拷贝数据时翻转,这里不做翻转
107
- this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL, true);
106
+ // this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL, true);
108
107
  this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MIN_FILTER, this.gl.LINEAR);
109
108
  this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MAG_FILTER, this.gl.LINEAR);
110
109
  this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_S, this.gl.CLAMP_TO_EDGE);
111
110
  this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_T, this.gl.CLAMP_TO_EDGE);
112
111
  }
113
- _initTextureAttr() {
112
+ _initTextureAttribute() {
114
113
  // vertex data
115
114
  const vertexBuffer = this.gl.createBuffer();
116
115
  this.gl.bindBuffer(this.gl.ARRAY_BUFFER, vertexBuffer);
117
116
  this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array(this.vertex), this.gl.STATIC_DRAW);
118
- // indice data
119
- const vertexIndiceBuffer = this.gl.createBuffer();
120
- this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, vertexIndiceBuffer);
121
- this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(this.vertexIndice), 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);
122
121
  // set position attribute
123
122
  const aVertexPosition = this.gl.getAttribLocation(this.glProgram, 'aPos');
124
123
  this.gl.vertexAttribPointer(aVertexPosition, 3, this.gl.FLOAT, false, 0, 0);
@@ -143,7 +142,8 @@ class Canvas3DRGBARenderer {
143
142
  height: '100%',
144
143
  display: 'flex',
145
144
  justifyContent: 'center',
146
- alignItems: 'center'
145
+ alignItems: 'center',
146
+ willChange: 'transform',
147
147
  });
148
148
  this.container = container;
149
149
  element.appendChild(this.container);
@@ -169,7 +169,7 @@ class Canvas3DRGBARenderer {
169
169
  }
170
170
  } while (false);
171
171
  if (ret) {
172
- this._initTextureAttr();
172
+ this._initTextureAttribute();
173
173
  this._initTexture();
174
174
  }
175
175
  }
@@ -202,7 +202,7 @@ class Canvas3DRGBARenderer {
202
202
  const { width, height, transform } = calcCanvasStyle(options);
203
203
  this.canvas.width = width;
204
204
  this.canvas.height = height;
205
- this.canvas.style.transform = transform;
205
+ this.canvas.style.transform = `${transform} rotateX(180deg)`;
206
206
  }
207
207
  drawFrame(imageData) {
208
208
  if (!this.ready) {
@@ -226,7 +226,7 @@ class Canvas3DRGBARenderer {
226
226
  });
227
227
  try {
228
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, imageData.data // new Uint8Array(imageData.data)
229
+ this.gl.texImage2D(this.gl.TEXTURE_2D, 0, this.gl.RGBA, contentWidth, contentHeight, 0, this.gl.RGBA, this.gl.UNSIGNED_BYTE, imageData.data // .slice(0) new Uint8Array(imageData.data)
230
230
  );
231
231
  this.gl.drawElements(this.gl.TRIANGLES, 6, this.gl.UNSIGNED_SHORT, 0);
232
232
  }
@@ -92,7 +92,7 @@ class RGBRenderer {
92
92
  containerHeight: this.container.clientHeight,
93
93
  isNeedRotate
94
94
  });
95
- let newImage = new ImageData(new Uint8ClampedArray(imageData.data.buffer || imageData.data), width, height);
95
+ let newImage = new ImageData(new Uint8ClampedArray(imageData.data.slice(0)), width, height);
96
96
  const tempCanvas = document.createElement('canvas');
97
97
  tempCanvas.width = imageData.width;
98
98
  tempCanvas.height = imageData.height;
@@ -50,9 +50,6 @@ declare const _default: {
50
50
  GlRenderer: typeof GlRenderer;
51
51
  SoftwareRenderer: any;
52
52
  RGBRenderer: any;
53
- I420VideoRenderer: any;
54
- BGRAVideoRenderer: any;
55
- RGBAVideoRenderer: any;
56
53
  Canvas3DRGBARenderer: any;
57
54
  };
58
55
  export default _default;
@@ -9,9 +9,6 @@ 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 I420VideoRenderer_1 = __importDefault(require("./I420VideoRenderer"));
13
- const BGRAVideoRenderer_1 = __importDefault(require("./BGRAVideoRenderer"));
14
- const RGBAVideoRenderer_1 = __importDefault(require("./RGBAVideoRenderer"));
15
12
  const Canvas3DRGBARenderer_1 = __importDefault(require("./Canvas3DRGBARenderer"));
16
13
  class GlRenderer {
17
14
  constructor() {
@@ -56,8 +53,5 @@ exports.default = {
56
53
  GlRenderer,
57
54
  SoftwareRenderer: SoftwareRenderer_1.default,
58
55
  RGBRenderer: RGBRenderer_1.default,
59
- I420VideoRenderer: I420VideoRenderer_1.default,
60
- BGRAVideoRenderer: BGRAVideoRenderer_1.default,
61
- RGBAVideoRenderer: RGBAVideoRenderer_1.default,
62
56
  Canvas3DRGBARenderer: Canvas3DRGBARenderer_1.default,
63
57
  };
@@ -16,6 +16,7 @@ export declare class Config {
16
16
  setDebugMode(enable: boolean): void;
17
17
  getDebugMode(): boolean;
18
18
  }
19
+ export declare const config: Config;
19
20
  export declare function isNeedKeepWidthAndHeight(rotation: number, isNeedRotate: boolean): boolean;
20
21
  export declare function calcScaleRate(vertical: boolean, contentMode: number, contentWidth: number, contentHeight: number, containerWidth: number, containerHeight: number): number;
21
22
  export declare function calcCanvasStyle(options?: {
@@ -30,17 +31,4 @@ export declare function calcCanvasStyle(options?: {
30
31
  }): {
31
32
  [x: string]: any;
32
33
  };
33
- export declare function calcVideoStyle(options?: {
34
- contentWidth: number;
35
- contentHeight: number;
36
- rotation: number;
37
- mirrorView: boolean;
38
- contentMode: number;
39
- containerWidth: number;
40
- containerHeight: number;
41
- isNeedRotate: boolean;
42
- }): {
43
- [x: string]: any;
44
- };
45
- export declare const config: Config;
46
34
  export declare function allocBuffer(length: number, userId?: string, streamType?: TRTCVideoStreamType): Buffer;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.allocBuffer = exports.config = exports.calcVideoStyle = exports.calcCanvasStyle = exports.calcScaleRate = exports.isNeedKeepWidthAndHeight = exports.Config = void 0;
3
+ exports.allocBuffer = exports.calcCanvasStyle = exports.calcScaleRate = exports.isNeedKeepWidthAndHeight = exports.config = exports.Config = void 0;
4
4
  /**
5
5
  * 配置对象, 可用来打开 debug 模式
6
6
  *
@@ -23,6 +23,7 @@ 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;
@@ -91,42 +92,6 @@ function calcCanvasStyle(options = {
91
92
  return style;
92
93
  }
93
94
  exports.calcCanvasStyle = calcCanvasStyle;
94
- function calcVideoStyle(options = {
95
- contentWidth: 0,
96
- contentHeight: 0,
97
- rotation: 0,
98
- mirrorView: false,
99
- contentMode: 0,
100
- containerWidth: 0,
101
- containerHeight: 0,
102
- isNeedRotate: true
103
- }) {
104
- if ([0, 90, 180, 270].indexOf(options.rotation) === -1) {
105
- throw new Error('Invalid value for rotation. Only support 0, 90, 180, 270');
106
- }
107
- let width = 0;
108
- let height = 0;
109
- const isKeepWidthHeight = isNeedKeepWidthAndHeight(options.rotation, options.isNeedRotate);
110
- if (isNeedKeepWidthAndHeight(options.rotation, options.isNeedRotate)) {
111
- width = options.contentWidth;
112
- height = options.contentHeight;
113
- }
114
- else {
115
- height = options.contentWidth;
116
- width = options.contentHeight;
117
- }
118
- const scale = calcScaleRate(!isKeepWidthHeight, options.contentMode, width, height, options.containerWidth, options.containerHeight);
119
- const style = {
120
- width: `${width * scale}px`,
121
- height: `${height * scale}px`,
122
- };
123
- if (options.mirrorView) {
124
- style.transform = 'rotateY(180deg)';
125
- }
126
- return style;
127
- }
128
- exports.calcVideoStyle = calcVideoStyle;
129
- exports.config = new Config();
130
95
  function allocBuffer(length, userId, streamType) {
131
96
  console.debug('trtc:alloc buffer:', length, userId, streamType);
132
97
  if (length >= 1) {
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, TRTCSpeedTestParams } from './trtc_define';
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
  /**
@@ -337,15 +337,6 @@ declare class TRTCCloud extends EventEmitter {
337
337
  * @param {Number} totalCount - 需要测速的服务器总数量
338
338
  */
339
339
  bindOnSpeedTest(): void;
340
- /**
341
- * 5.5 网速测试的结果回调
342
- *
343
- * 该统计回调由 startSpeedTest 触发。
344
- *
345
- * @event TRTCCallback#onSpeedTestResult
346
- * @param {TRTCSpeedTestResult} result 网速测试数据数据,包括丢包、往返延迟、上下行的带宽速率。
347
- */
348
- bindOnSpeedTestResult(): void;
349
340
  /**
350
341
  * 6.1 摄像头准备就绪
351
342
  *
@@ -1796,6 +1787,13 @@ declare class TRTCCloud extends EventEmitter {
1796
1787
  * @param {Number} volume - 音量大小,100为正常音量,取值范围为0 - 100;默认值:100
1797
1788
  */
1798
1789
  setMusicPublishVolume(id: number, volume: number): void;
1790
+ /**
1791
+ * 11.22 调整背景音乐的变速效果
1792
+ *
1793
+ * @param {Number} id - 音乐 ID
1794
+ * @param {Number} speedRate - 速度,默认值是1.0f,范围是:[0.5 ~ 2] 之间的浮点数;
1795
+ */
1796
+ setMusicSpeedRate(id: number, speedRate: number): void;
1799
1797
  /**
1800
1798
  * 12.1 废弃接口: 播放音效
1801
1799
  *
@@ -1866,35 +1864,19 @@ declare class TRTCCloud extends EventEmitter {
1866
1864
  * 测速结果将会用于优化 SDK 接下来的服务器选择策略,因此推荐您在用户首次通话前先进行一次测速,这将有助于我们选择最佳的服务器。
1867
1865
  * 同时,如果测试结果非常不理想,您可以通过醒目的 UI 提示用户选择更好的网络。
1868
1866
  *
1869
- * 注意:
1870
- * 1. 测速过程将产生少量的基础服务费用,详见 [计费概述 > 基础服务](https://cloud.tencent.com/document/product/647/17157#.E5.9F.BA.E7.A1.80.E6.9C.8D.E5.8A.A1) 文档说明。
1871
- * 2. 请在进入房间前进行网速测试,在房间中网速测试会影响正常的音视频传输效果,而且由于干扰过多,网速测试结果也不准确。
1872
- * 3. 同一时间只允许一项网速测试任务运行。
1873
- *
1874
- * @param {TRTCSpeedTestParams} params - 测速参数
1875
- * @param {Number} params.sdkAppId - 应用标识
1876
- * @param {String} params.userId - 用户标识
1877
- * @param {String} params.userSig - 用户签名
1878
- * @param {Number} params.expectedUpBandwidth - 预期的上行带宽(kbps,取值范围: 10 ~ 5000,为 0 时不测试)。
1879
- * @param {Number} params.expectedDownBandwidth - 预期的下行带宽(kbps,取值范围: 10 ~ 5000,为 0 时不测试)。
1867
+ * 注意:测速本身会消耗一定的流量,所以也会产生少量额外的流量费用。
1880
1868
  *
1881
- * @return 接口调用结果,< 0:失败
1869
+ * @param {Number} sdkAppId - 应用标识
1870
+ * @param {String} userId - 用户标识
1871
+ * @param {String} userSig - 用户签名
1882
1872
  */
1883
- startSpeedTest(params: TRTCSpeedTestParams | number, userId?: string, userSig?: string): any;
1873
+ startSpeedTest(sdkAppId: number, userId: string, userSig: string): void;
1884
1874
  /**
1885
1875
  * 13.2 停止网络测速
1886
1876
  */
1887
1877
  stopSpeedTest(): void;
1888
1878
  /**
1889
- * 13.3 设置 SDK 使用的音频设备根据跟随系统默认设备
1890
- *
1891
- * @param {TRTCDeviceType} deviceType - 设备类型
1892
- * @param {Boolean} enable - 是否跟随系统默认的音频设备。 true:跟随, 当系统默认音频设备发生改变时,SDK 立即切换音频设备; false:不跟随, 只有当 SDK 使用的音频设备被移除后或插入新的音频设备为系统默认设备时,SDK 才切换至系统默认的音频设备。
1893
- *
1894
- */
1895
- enableFollowingDefaultAudioDevice(deviceType: TRTCDeviceType, enable: boolean): void;
1896
- /**
1897
- * 13.4 开始进行摄像头测试
1879
+ * 13.3 开始进行摄像头测试
1898
1880
  *
1899
1881
  * 会触发 onFirstVideoFrame 回调接口
1900
1882
  *
@@ -1904,11 +1886,11 @@ declare class TRTCCloud extends EventEmitter {
1904
1886
  */
1905
1887
  startCameraDeviceTest(view: HTMLElement): void;
1906
1888
  /**
1907
- * 13.5 停止摄像头测试
1889
+ * 13.4 停止摄像头测试
1908
1890
  */
1909
1891
  stopCameraDeviceTest(): void;
1910
1892
  /**
1911
- * 13.6 开始进行麦克风测试
1893
+ * 13.5 开始进行麦克风测试
1912
1894
  *
1913
1895
  * 回调接口 onTestMicVolume 获取测试数据
1914
1896
  *
@@ -1918,11 +1900,11 @@ declare class TRTCCloud extends EventEmitter {
1918
1900
  */
1919
1901
  startMicDeviceTest(interval: number): void;
1920
1902
  /**
1921
- * 13.7 停止麦克风测试
1903
+ * 13.6 停止麦克风测试
1922
1904
  */
1923
1905
  stopMicDeviceTest(): void;
1924
1906
  /**
1925
- * 13.8 开始进行扬声器测试
1907
+ * 13.7 开始进行扬声器测试
1926
1908
  *
1927
1909
  * 回调接口 onTestSpeakerVolume 获取测试数据
1928
1910
  *
@@ -1932,7 +1914,7 @@ declare class TRTCCloud extends EventEmitter {
1932
1914
  */
1933
1915
  startSpeakerDeviceTest(testAudioFilePath: string): void;
1934
1916
  /**
1935
- * 13.9 停止扬声器测试
1917
+ * 13.8 停止扬声器测试
1936
1918
  */
1937
1919
  stopSpeakerDeviceTest(): void;
1938
1920
  /**
@@ -2004,8 +1986,10 @@ declare class TRTCCloud extends EventEmitter {
2004
1986
  /**
2005
1987
  * 选择绘制的模式 (webgl/yuvcanvs/)
2006
1988
  * @param {Number} mode -
2007
- * - 1 webgl
2008
- * - 2 yuvcanvs
1989
+ * - 1 YUV WebGL
1990
+ * - 2 YUV Canvas 2D
1991
+ * - 3 RGBA Canvas 2D
1992
+ * - 4 RGBA WebGL
2009
1993
  */
2010
1994
  setRenderMode(mode?: number): void;
2011
1995
  initPluginManager(): void;