trtc-electron-sdk 9.8.8-alpha.3 → 9.8.8-alpha.4

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.
@@ -77,7 +77,7 @@ class Canvas3DRGBARenderer {
77
77
  this.gl.attachShader(this.glProgram, fragmentShader);
78
78
  this.gl.linkProgram(this.glProgram);
79
79
  if (!this.gl.getProgramParameter(this.glProgram, this.gl.LINK_STATUS)) {
80
- console.log('Unable to initialize the shader program.');
80
+ console.log('trtc:Unable to initialize the shader program.');
81
81
  return false;
82
82
  }
83
83
  else {
@@ -91,7 +91,7 @@ class Canvas3DRGBARenderer {
91
91
  this.gl.shaderSource(shader, src);
92
92
  this.gl.compileShader(shader);
93
93
  if (!this.gl.getShaderParameter(shader, this.gl.COMPILE_STATUS)) {
94
- console.log(`Error compiling shader: ${this.gl.getShaderInfoLog(shader)}`);
94
+ console.log(`trtc:Error compiling shader: ${this.gl.getShaderInfoLog(shader)}`);
95
95
  return null;
96
96
  }
97
97
  return shader;
@@ -154,17 +154,17 @@ class Canvas3DRGBARenderer {
154
154
  do {
155
155
  ret = this._initGL();
156
156
  if (!ret) {
157
- console.log('initGL failed');
157
+ console.log('trtc:init WebGL failed');
158
158
  break;
159
159
  }
160
160
  ret = this._initShaders();
161
161
  if (!ret) {
162
- console.log('initShaders failed');
162
+ console.log('trtc:init WebGL Shader failed');
163
163
  break;
164
164
  }
165
165
  ret = this._initUniforms();
166
166
  if (!ret) {
167
- console.log('initUniforms failed');
167
+ console.log('trtc:int WebGL Uniform failed');
168
168
  break;
169
169
  }
170
170
  } while (false);
@@ -226,11 +226,12 @@ 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, 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 // new Uint8Array(imageData.data)
230
+ );
230
231
  this.gl.drawElements(this.gl.TRIANGLES, 6, this.gl.UNSIGNED_SHORT, 0);
231
232
  }
232
233
  catch (error) {
233
- console.error(error);
234
+ console.error('trtc:', error);
234
235
  }
235
236
  }
236
237
  setContentMode(mode = 0) {
@@ -48,7 +48,7 @@ const TrtcRender = function () {
48
48
  gl.getExtension('WEBGL_lose_context').loseContext();
49
49
  }
50
50
  catch (err) {
51
- console.warn(err);
51
+ console.warn('trtc:', err);
52
52
  }
53
53
  program = undefined;
54
54
  positionLocation = undefined;
@@ -69,7 +69,7 @@ const TrtcRender = function () {
69
69
  that.view && that.view.removeChild(that.container);
70
70
  }
71
71
  catch (e) {
72
- console.warn(e);
72
+ console.warn('trtc:', e);
73
73
  }
74
74
  that.canvas = undefined;
75
75
  that.container = undefined;
@@ -83,7 +83,7 @@ const TrtcRender = function () {
83
83
  };
84
84
  that.renderImage = function (image) {
85
85
  if (!gl) {
86
- console.log('!gl');
86
+ console.log('trtc:no gl');
87
87
  return;
88
88
  }
89
89
  if (image.width != that.initWidth
@@ -93,7 +93,7 @@ const TrtcRender = function () {
93
93
  const view = that.view;
94
94
  that.unbind();
95
95
  initCanvas(view, image.mirror, image.width, image.height, image.rotation, image.isNeedRotate, e => {
96
- console.error(`init canvas ${image.width}*${image.height} rotation ${image.rotation} failed. ${e}`);
96
+ console.error(`trtc:init canvas ${image.width}*${image.height} rotation ${image.rotation} failed. ${e}`);
97
97
  });
98
98
  }
99
99
  gl.bindBuffer(gl.ARRAY_BUFFER, texCoordBuffer);
@@ -175,7 +175,7 @@ const TrtcRender = function () {
175
175
  if (config.getDebugMode()) {
176
176
  e = gl.getError();
177
177
  if (e != gl.NO_ERROR) {
178
- console.log('upload y plane ', width, height, yplane.byteLength, ' error', e);
178
+ console.log('trtc:upload y plane ', width, height, yplane.byteLength, ' error', e);
179
179
  }
180
180
  }
181
181
  gl.activeTexture(gl.TEXTURE1);
@@ -184,7 +184,7 @@ const TrtcRender = function () {
184
184
  if (config.getDebugMode()) {
185
185
  e = gl.getError();
186
186
  if (e != gl.NO_ERROR) {
187
- console.log('upload u plane ', width, height, uplane.byteLength, ' error', e);
187
+ console.log('trtc:upload u plane ', width, height, uplane.byteLength, ' error', e);
188
188
  }
189
189
  }
190
190
  gl.activeTexture(gl.TEXTURE2);
@@ -194,7 +194,7 @@ const TrtcRender = function () {
194
194
  if (config.getDebugMode()) {
195
195
  e = gl.getError();
196
196
  if (e != gl.NO_ERROR) {
197
- console.log('upload v plane ', width, height, vplane.byteLength, ' error', e);
197
+ console.log('trtc:upload v plane ', width, height, vplane.byteLength, ' error', e);
198
198
  }
199
199
  }
200
200
  }
@@ -273,7 +273,7 @@ const TrtcRender = function () {
273
273
  }) || that.canvas.getContext('experimental-webgl');
274
274
  }
275
275
  catch (e) {
276
- console.log(e);
276
+ console.log('trtc:', e);
277
277
  }
278
278
  if (!gl) {
279
279
  gl = undefined;
@@ -361,9 +361,9 @@ const TrtcRender = function () {
361
361
  }
362
362
  }
363
363
  catch (e) {
364
- console.log(`updateCanvas error ${that.canvas}`);
365
- console.log(that);
366
- console.error(e);
364
+ console.log(`trtc:updateCanvas error ${that.canvas}`);
365
+ console.log('trtc:', that);
366
+ console.error('trtc:', e);
367
367
  return false;
368
368
  }
369
369
  return true;
@@ -51,10 +51,10 @@
51
51
  function error(msg) {
52
52
  if (topWindow.console) {
53
53
  if (topWindow.console.error) {
54
- topWindow.console.error(msg);
54
+ topWindow.console.error('trtc:', msg);
55
55
  }
56
56
  else if (topWindow.console.log) {
57
- topWindow.console.log(msg);
57
+ topWindow.console.log('trtc:', msg);
58
58
  }
59
59
  }
60
60
  }
@@ -102,7 +102,7 @@ class RGBRenderer {
102
102
  ctx.drawImage(tempCanvas, 0, 0);
103
103
  }
104
104
  catch (error) {
105
- console.error('RGBRenderer.drawFrame error:', error);
105
+ console.error('trtc:RGBRenderer.drawFrame error:', error);
106
106
  }
107
107
  }
108
108
  setContentMode(mode = 0) {
@@ -1,3 +1,5 @@
1
+ /// <reference types="node" />
2
+ import { TRTCVideoStreamType } from "../trtc_define";
1
3
  /**
2
4
  * 配置对象, 可用来打开 debug 模式
3
5
  *
@@ -41,3 +43,4 @@ export declare function calcVideoStyle(options?: {
41
43
  [x: string]: any;
42
44
  };
43
45
  export declare const config: Config;
46
+ 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.config = exports.calcVideoStyle = exports.calcCanvasStyle = exports.calcScaleRate = exports.isNeedKeepWidthAndHeight = exports.Config = void 0;
3
+ exports.allocBuffer = exports.config = exports.calcVideoStyle = exports.calcCanvasStyle = exports.calcScaleRate = exports.isNeedKeepWidthAndHeight = exports.Config = void 0;
4
4
  /**
5
5
  * 配置对象, 可用来打开 debug 模式
6
6
  *
@@ -127,3 +127,11 @@ function calcVideoStyle(options = {
127
127
  }
128
128
  exports.calcVideoStyle = calcVideoStyle;
129
129
  exports.config = new Config();
130
+ function allocBuffer(length, userId, streamType) {
131
+ console.debug('trtc:alloc buffer:', length, userId, streamType);
132
+ if (length >= 1) {
133
+ return Buffer.alloc(length);
134
+ }
135
+ return null;
136
+ }
137
+ exports.allocBuffer = allocBuffer;
package/liteav/trtc.d.ts CHANGED
@@ -27,6 +27,7 @@ declare class TRTCCloud extends EventEmitter {
27
27
  private remoteVideoCallback;
28
28
  private isExternalRenderEnabled;
29
29
  private pixelformate;
30
+ private pixelLength;
30
31
  private localRotation;
31
32
  private localMirrorType;
32
33
  private remoteMainStreamFillMode;
@@ -41,6 +42,7 @@ declare class TRTCCloud extends EventEmitter {
41
42
  private playAudioEffectIdList;
42
43
  private enableRenderFrame;
43
44
  private screenCaptureStreamType;
45
+ private isScreenCapturing;
44
46
  constructor();
45
47
  /**
46
48
  * 创建 TRTCCloud 对象单例
@@ -596,6 +598,7 @@ declare class TRTCCloud extends EventEmitter {
596
598
  * - ERR_AUDIO_PLUGIN_INSTALL_FAILED (-1332) :安装音频驱动插件失败
597
599
  */
598
600
  handleOnSystemAudioLoopbackError(errCode: number): void;
601
+ handleOnVideoSizeChange(userId: string, streamType: number, width: number, height: number): void;
599
602
  /**
600
603
  * 1.1 进入房间
601
604
  *
@@ -2017,8 +2020,8 @@ declare class TRTCCloud extends EventEmitter {
2017
2020
  */
2018
2021
  _isSupportWebGL(): boolean;
2019
2022
  _getRenderer(uid: string, type: TRTCVideoStreamType): any;
2020
- _onRenderFrame(uid: string, type: TRTCVideoStreamType, width: number, height: number, timestamp: number, rotation: number, data: any): void;
2021
- _onRealRender(uid: string, type: TRTCVideoStreamType, width: number, height: number, timestamp: number, rotation: number, data: any): void;
2023
+ _onRenderFrame(uid: string, type: TRTCVideoStreamType, width: number, height: number, timestamp: number, rotation: number, data: any, length: number): void;
2024
+ _onRealRender(uid: string, type: TRTCVideoStreamType, width: number, height: number, timestamp: number, rotation: number, data: any, length: number): void;
2022
2025
  _initRender(key: string, view: HTMLElement): void;
2023
2026
  _destroyRender(key: string, onFailure: ((err: Error) => void) | null): void;
2024
2027
  /**
package/liteav/trtc.js CHANGED
@@ -33,6 +33,25 @@ __exportStar(require("./trtc_code"), exports);
33
33
  const CUSTOM_VIDEO_DATA = 'onVideoData';
34
34
  const CAMERA_DEVICE_TEST_VIEW = 'camera_device_test_view';
35
35
  const CAMERA_DEVICE_TEST_ID = 'camera_device_test';
36
+ const DEFAULT_VIDEO_WIDTH = 640;
37
+ const DEFAULT_VIDEO_HEIGHT = 360;
38
+ const localVideoBuffer = {
39
+ userId: '',
40
+ buffer: null,
41
+ streamType: trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig,
42
+ width: DEFAULT_VIDEO_WIDTH,
43
+ height: DEFAULT_VIDEO_HEIGHT,
44
+ pixelFormat: trtc_define_1.TRTCVideoPixelFormat.TRTCVideoPixelFormat_I420,
45
+ };
46
+ const screenVideoBuffer = {
47
+ userId: '',
48
+ buffer: null,
49
+ streamType: trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSub,
50
+ width: DEFAULT_VIDEO_WIDTH,
51
+ height: DEFAULT_VIDEO_HEIGHT,
52
+ pixelFormat: trtc_define_1.TRTCVideoPixelFormat.TRTCVideoPixelFormat_I420,
53
+ };
54
+ const remoteVideoBufferMap = new Map();
36
55
  const SDK_LOG_LEVEL = 2;
37
56
  let genSecFunc = function (instance, key) {
38
57
  return function () {
@@ -44,7 +63,7 @@ let genSecFunc = function (instance, key) {
44
63
  return result;
45
64
  }
46
65
  catch (err) {
47
- console.warn(err);
66
+ console.warn('trtc:', err);
48
67
  }
49
68
  };
50
69
  };
@@ -116,6 +135,7 @@ class TRTCCloud extends events_1.EventEmitter {
116
135
  this.firstVideoFrameList = [];
117
136
  this.playStreamType = trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig;
118
137
  this.pixelformate = trtc_define_1.TRTCVideoPixelFormat.TRTCVideoPixelFormat_I420;
138
+ this.pixelLength = 1.5;
119
139
  this.renderMode = this._isSupportWebGL() ? 1 : 2;
120
140
  this.isExternalRenderEnabled = false;
121
141
  this.localFillMode = trtc_define_1.TRTCVideoFillMode.TRTCVideoFillMode_Fit;
@@ -134,8 +154,9 @@ class TRTCCloud extends events_1.EventEmitter {
134
154
  this.playAudioEffectIdList = [];
135
155
  this.enableRenderFrame = true;
136
156
  this.screenCaptureStreamType = trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSub;
157
+ this.isScreenCapturing = false;
137
158
  this.initEventHandler();
138
- console.log('constructor render:' + this.renderMode + '|sdk version:' + pkg.version +
159
+ console.log('trtc:constructor render:' + this.renderMode + '|sdk version:' + pkg.version +
139
160
  '|native sdk version:' + this.rtcCloud.getSDKVersion());
140
161
  //视频数据回调
141
162
  this.imageData = null;
@@ -205,7 +226,7 @@ class TRTCCloud extends events_1.EventEmitter {
205
226
  */
206
227
  initEventHandler() {
207
228
  this.rtcCloud.onEvent('apierror', (funcName) => {
208
- console.error(`api ${funcName} failed. this is an error
229
+ console.error(`trtc:api ${funcName} failed. this is an error
209
230
  thrown by c++ addon layer. it often means sth is
210
231
  going wrong with this function call and it refused
211
232
  to do what is asked. kindly check your parameter types
@@ -349,6 +370,8 @@ class TRTCCloud extends events_1.EventEmitter {
349
370
  case 'onSystemAudioLoopbackError':
350
371
  this.handleOnSystemAudioLoopbackError(int32_1);
351
372
  break;
373
+ case 'onVideoSizeChange':
374
+ this.handleOnVideoSizeChange(string_1, int32_1, int32_2, int32_3);
352
375
  default:
353
376
  break;
354
377
  }
@@ -550,6 +573,12 @@ class TRTCCloud extends events_1.EventEmitter {
550
573
  this.firstVideoFrameList = this.firstVideoFrameList.filter(function (item) {
551
574
  return !(userId === item.uid && item.type !== trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSub);
552
575
  });
576
+ const videoBufferInfo = remoteVideoBufferMap.get(userId);
577
+ if (videoBufferInfo) {
578
+ this.rtcCloud.setRemoteVideoBuffer(userId, videoBufferInfo.buffer, videoBufferInfo.streamType, 0, 0, videoBufferInfo.pixelFormat);
579
+ videoBufferInfo.buffer = null;
580
+ remoteVideoBufferMap.delete(userId);
581
+ }
553
582
  }
554
583
  }
555
584
  this.fire('onUserVideoAvailable', userId, available);
@@ -569,6 +598,10 @@ class TRTCCloud extends events_1.EventEmitter {
569
598
  this.firstVideoFrameList = this.firstVideoFrameList.filter(function (item) {
570
599
  return !(userId === item.uid && item.type === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSub);
571
600
  });
601
+ if (screenVideoBuffer.buffer && screenVideoBuffer.userId === userId) {
602
+ this.rtcCloud.setSubVideoBuffer(userId, screenVideoBuffer.buffer, screenVideoBuffer.streamType, 0, 0, screenVideoBuffer.pixelFormat);
603
+ screenVideoBuffer.buffer = null;
604
+ }
572
605
  }
573
606
  }
574
607
  this.fire('onUserSubStreamAvailable', userId, available);
@@ -998,6 +1031,14 @@ class TRTCCloud extends events_1.EventEmitter {
998
1031
  * @event TRTCCallback#onScreenCaptureStarted
999
1032
  */
1000
1033
  handleOnScreenCaptureStarted() {
1034
+ this.isScreenCapturing = true;
1035
+ screenVideoBuffer.userId = '';
1036
+ screenVideoBuffer.streamType = this.screenCaptureStreamType;
1037
+ screenVideoBuffer.buffer = (0, util_1.allocBuffer)(DEFAULT_VIDEO_WIDTH * DEFAULT_VIDEO_HEIGHT * this.pixelLength, screenVideoBuffer.userId, screenVideoBuffer.streamType); /// Buffer.alloc(DEFAULT_VIDEO_WIDTH * DEFAULT_VIDEO_HEIGHT * this.pixelLength);
1038
+ screenVideoBuffer.pixelFormat = this.pixelformate;
1039
+ screenVideoBuffer.width = DEFAULT_VIDEO_WIDTH;
1040
+ screenVideoBuffer.height = DEFAULT_VIDEO_HEIGHT;
1041
+ this.rtcCloud.setSubVideoBuffer('', screenVideoBuffer.buffer, screenVideoBuffer.streamType, screenVideoBuffer.width, screenVideoBuffer.height, screenVideoBuffer.pixelFormat);
1001
1042
  this.fire('onScreenCaptureStarted');
1002
1043
  }
1003
1044
  /**
@@ -1025,6 +1066,13 @@ class TRTCCloud extends events_1.EventEmitter {
1025
1066
  * @param {Number} reason - 停止原因,0:表示用户主动停止;1:表示屏幕分享窗口被关闭
1026
1067
  */
1027
1068
  handleOnScreenCaptureStopped(reason) {
1069
+ if (this.isScreenCapturing) {
1070
+ if (screenVideoBuffer.buffer) {
1071
+ this.rtcCloud.setSubVideoBuffer('', screenVideoBuffer.buffer, screenVideoBuffer.streamType, 0, 0, screenVideoBuffer.pixelFormat);
1072
+ screenVideoBuffer.buffer = null;
1073
+ }
1074
+ this.isScreenCapturing = false;
1075
+ }
1028
1076
  this.fire('onScreenCaptureStoped', reason);
1029
1077
  // 兼容旧版的单词拼写错误,避免旧版用户升级后无法触发回调
1030
1078
  this.fire('onScreenCaptureStopped', reason);
@@ -1114,6 +1162,64 @@ class TRTCCloud extends events_1.EventEmitter {
1114
1162
  handleOnSystemAudioLoopbackError(errCode) {
1115
1163
  this.fire('onSystemAudioLoopbackError', errCode);
1116
1164
  }
1165
+ handleOnVideoSizeChange(userId, streamType, width, height) {
1166
+ if (this.renderMode === 6) {
1167
+ return;
1168
+ }
1169
+ if (userId) {
1170
+ if (streamType !== trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSub) {
1171
+ const videoBufferInfo = remoteVideoBufferMap.get(userId);
1172
+ if (videoBufferInfo) {
1173
+ if (videoBufferInfo.width !== width || videoBufferInfo.height !== height) {
1174
+ videoBufferInfo.buffer = (0, util_1.allocBuffer)(width * height * this.pixelLength, userId, streamType); // Buffer.alloc(width * height * this.pixelLength);
1175
+ videoBufferInfo.width = width;
1176
+ videoBufferInfo.height = height;
1177
+ videoBufferInfo.pixelFormat = this.pixelformate;
1178
+ this.rtcCloud.setRemoteVideoBuffer(userId, videoBufferInfo.buffer, streamType, width, height, videoBufferInfo.pixelFormat);
1179
+ }
1180
+ else {
1181
+ // 宽高尺寸未变,不用重新分配Buffer
1182
+ }
1183
+ }
1184
+ else {
1185
+ console.error(`trtc:onVideoSizeChange error: ${userId} ${streamType} buffer not exist`);
1186
+ }
1187
+ }
1188
+ else {
1189
+ // 远端用户屏幕分享
1190
+ if (screenVideoBuffer.width !== width || screenVideoBuffer.height !== height) {
1191
+ screenVideoBuffer.buffer = (0, util_1.allocBuffer)(width * height * this.pixelLength, userId, streamType); // Buffer.alloc(width * height * this.pixelLength);
1192
+ screenVideoBuffer.width = width;
1193
+ screenVideoBuffer.height = height;
1194
+ screenVideoBuffer.pixelFormat = this.pixelformate;
1195
+ this.rtcCloud.setSubVideoBuffer(userId, screenVideoBuffer.buffer, streamType, width, height, screenVideoBuffer.pixelFormat);
1196
+ }
1197
+ }
1198
+ }
1199
+ else {
1200
+ // 本地用户
1201
+ if (this.isScreenCapturing && this.screenCaptureStreamType === streamType) {
1202
+ // 本地屏幕分享
1203
+ if (screenVideoBuffer.width !== width || screenVideoBuffer.height !== height) {
1204
+ screenVideoBuffer.buffer = (0, util_1.allocBuffer)(width * height * this.pixelLength, screenVideoBuffer.userId, streamType); // Buffer.alloc(width * height * this.pixelLength);
1205
+ screenVideoBuffer.width = width;
1206
+ screenVideoBuffer.height = height;
1207
+ screenVideoBuffer.pixelFormat = this.pixelformate;
1208
+ this.rtcCloud.setSubVideoBuffer('', screenVideoBuffer.buffer, screenVideoBuffer.streamType, width, height, screenVideoBuffer.pixelFormat);
1209
+ }
1210
+ }
1211
+ else {
1212
+ // 本地摄像头
1213
+ if (localVideoBuffer.width !== width || localVideoBuffer.height !== height) {
1214
+ localVideoBuffer.buffer = (0, util_1.allocBuffer)(width * height * this.pixelLength, localVideoBuffer.userId, streamType); // Buffer.alloc(width * height * this.pixelLength);
1215
+ localVideoBuffer.width = width;
1216
+ localVideoBuffer.height = height;
1217
+ localVideoBuffer.pixelFormat = this.pixelformate;
1218
+ this.rtcCloud.setLocalVideoBuffer(localVideoBuffer.buffer, width, height, localVideoBuffer.pixelFormat);
1219
+ }
1220
+ }
1221
+ }
1222
+ }
1117
1223
  /////////////////////////////////////////////////////////////////////////////////
1118
1224
  //
1119
1225
  // (一)房间相关接口函数
@@ -1166,7 +1272,7 @@ class TRTCCloud extends events_1.EventEmitter {
1166
1272
  this.rtcCloud.enterRoom(params.sdkAppId, params.roomId, params.strRoomId, params.userId, params.userSig, params.privateMapKey, params.businessInfo, params.role, params.userDefineRecordId, params.streamId === '' ? null : params.streamId, scene);
1167
1273
  }
1168
1274
  else {
1169
- console.error('enterRoom, params is not instanceof TRTCParams!');
1275
+ console.error('trtc:enterRoom, params is not instanceof TRTCParams!');
1170
1276
  }
1171
1277
  }
1172
1278
  /**
@@ -1182,6 +1288,20 @@ class TRTCCloud extends events_1.EventEmitter {
1182
1288
  this.streams.forEach((value, key, map) => {
1183
1289
  this._destroyRender(key, null);
1184
1290
  });
1291
+ remoteVideoBufferMap.forEach((value, key) => {
1292
+ this.rtcCloud.setRemoteVideoBuffer(key, value.buffer, value.streamType, 0, 0, value.pixelFormat);
1293
+ value.buffer = null;
1294
+ });
1295
+ remoteVideoBufferMap.clear();
1296
+ if (localVideoBuffer.buffer) {
1297
+ this.rtcCloud.setLocalVideoBuffer(localVideoBuffer.buffer, 0, 0, localVideoBuffer.pixelFormat);
1298
+ localVideoBuffer.buffer = null;
1299
+ }
1300
+ if (screenVideoBuffer.buffer) {
1301
+ this.rtcCloud.setSubVideoBuffer(screenVideoBuffer.userId, screenVideoBuffer.buffer, screenVideoBuffer.streamType, 0, 0, screenVideoBuffer.pixelFormat);
1302
+ screenVideoBuffer.buffer = null;
1303
+ screenVideoBuffer.userId = '';
1304
+ }
1185
1305
  this.rtcCloud.exitRoom();
1186
1306
  }
1187
1307
  /**
@@ -1332,7 +1452,7 @@ class TRTCCloud extends events_1.EventEmitter {
1332
1452
  this.rtcCloud.startPublishCDNStream(param.appId, param.bizId, param.url);
1333
1453
  }
1334
1454
  else {
1335
- console.error('startPublishCDNStream, param is not instanceof TRTCPublishCDNParam!');
1455
+ console.error('trtc:startPublishCDNStream, param is not instanceof TRTCPublishCDNParam!');
1336
1456
  }
1337
1457
  }
1338
1458
  /**
@@ -1435,7 +1555,7 @@ class TRTCCloud extends events_1.EventEmitter {
1435
1555
  this.rtcCloud.setMixTranscodingConfig(configMode, config.appId, config.bizId, config.videoWidth, config.videoHeight, config.videoBitrate, config.videoFramerate, config.videoGOP, config.audioSampleRate, config.audioBitrate, config.audioChannels, config.backgroundColor, config.backgroundImage, config.streamId, config.mixUsersArray);
1436
1556
  }
1437
1557
  else {
1438
- console.error('setMixTranscodingConfig, config is not instanceof TRTCTranscodingConfig!');
1558
+ console.error('trtc:setMixTranscodingConfig, config is not instanceof TRTCTranscodingConfig!');
1439
1559
  }
1440
1560
  }
1441
1561
  /////////////////////////////////////////////////////////////////////////////////
@@ -1456,12 +1576,18 @@ class TRTCCloud extends events_1.EventEmitter {
1456
1576
  if (view !== null) {
1457
1577
  let key = this.getKey('local_video', trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig);
1458
1578
  this._initRender(key, view);
1579
+ localVideoBuffer.streamType = trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig;
1580
+ localVideoBuffer.buffer = (0, util_1.allocBuffer)(DEFAULT_VIDEO_WIDTH * DEFAULT_VIDEO_HEIGHT * this.pixelLength, localVideoBuffer.userId, localVideoBuffer.streamType); // Buffer.alloc(DEFAULT_VIDEO_WIDTH * DEFAULT_VIDEO_HEIGHT * this.pixelLength);
1581
+ localVideoBuffer.pixelFormat = this.pixelformate;
1582
+ localVideoBuffer.width = DEFAULT_VIDEO_WIDTH;
1583
+ localVideoBuffer.height = DEFAULT_VIDEO_HEIGHT;
1584
+ this.rtcCloud.setLocalVideoBuffer(localVideoBuffer.buffer, localVideoBuffer.width, localVideoBuffer.height, localVideoBuffer.pixelFormat);
1459
1585
  }
1460
1586
  this.rtcCloud.startLocalPreview();
1461
1587
  this.addLocalVideoRenderCallback(trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig);
1462
1588
  }
1463
1589
  else {
1464
- console.error('startLocalPreview, view is undefined!');
1590
+ console.error('trtc:startLocalPreview, view is undefined!');
1465
1591
  }
1466
1592
  }
1467
1593
  /**
@@ -1474,6 +1600,10 @@ class TRTCCloud extends events_1.EventEmitter {
1474
1600
  this.firstVideoFrameList = this.firstVideoFrameList.filter(function (item) {
1475
1601
  return !('' === item.uid && item.type === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig);
1476
1602
  });
1603
+ if (localVideoBuffer.buffer) {
1604
+ this.rtcCloud.setLocalVideoBuffer(localVideoBuffer.buffer, 0, 0, localVideoBuffer.pixelFormat);
1605
+ localVideoBuffer.buffer = null;
1606
+ }
1477
1607
  }
1478
1608
  /**
1479
1609
  * 3.3 是否屏蔽自己的视频画面
@@ -1513,12 +1643,29 @@ class TRTCCloud extends events_1.EventEmitter {
1513
1643
  }
1514
1644
  const key = this.getKey(userId, bindStreamType);
1515
1645
  this._initRender(key, view);
1646
+ const videoBufferInfo = {
1647
+ userId: userId,
1648
+ buffer: (0, util_1.allocBuffer)(DEFAULT_VIDEO_WIDTH * DEFAULT_VIDEO_HEIGHT * this.pixelLength, userId, streamType),
1649
+ streamType: streamType,
1650
+ width: DEFAULT_VIDEO_WIDTH,
1651
+ height: DEFAULT_VIDEO_HEIGHT,
1652
+ pixelFormat: this.pixelformate,
1653
+ };
1654
+ if (streamType !== trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSub) {
1655
+ remoteVideoBufferMap.set(userId, videoBufferInfo);
1656
+ this.rtcCloud.setRemoteVideoBuffer(userId, videoBufferInfo.buffer, videoBufferInfo.streamType, videoBufferInfo.width, videoBufferInfo.height, videoBufferInfo.pixelFormat);
1657
+ }
1658
+ else {
1659
+ // 远端屏幕分享
1660
+ Object.assign(screenVideoBuffer, videoBufferInfo);
1661
+ this.rtcCloud.setSubVideoBuffer(screenVideoBuffer.userId, screenVideoBuffer.buffer, screenVideoBuffer.streamType, screenVideoBuffer.width, screenVideoBuffer.height, screenVideoBuffer.pixelFormat);
1662
+ }
1516
1663
  }
1517
1664
  this.addRemoteVideoRenderCallback(userId, streamType);
1518
1665
  this.rtcCloud.startRemoteView(userId, streamType);
1519
1666
  }
1520
1667
  else {
1521
- console.error('startRemoteView, view is undefined!');
1668
+ console.error('trtc:startRemoteView, view is undefined!');
1522
1669
  }
1523
1670
  }
1524
1671
  /**
@@ -1536,6 +1683,17 @@ class TRTCCloud extends events_1.EventEmitter {
1536
1683
  let key = this.getKey(userId, streamType);
1537
1684
  this._destroyRender(key, null);
1538
1685
  this.rtcCloud.stopRemoteView(userId, streamType);
1686
+ const videoBufferInfo = remoteVideoBufferMap.get(userId);
1687
+ if (videoBufferInfo && videoBufferInfo.streamType === streamType) {
1688
+ this.rtcCloud.setRemoteVideoBuffer(userId, videoBufferInfo.buffer, videoBufferInfo.streamType, 0, 0, videoBufferInfo.pixelFormat);
1689
+ videoBufferInfo.buffer = null;
1690
+ remoteVideoBufferMap.delete(userId);
1691
+ }
1692
+ else if (screenVideoBuffer.userId === userId && screenVideoBuffer.streamType === streamType) {
1693
+ this.rtcCloud.setSubVideoBuffer(userId, screenVideoBuffer.buffer, screenVideoBuffer.streamType, 0, 0, screenVideoBuffer.pixelFormat);
1694
+ screenVideoBuffer.buffer = null;
1695
+ screenVideoBuffer.userId = '';
1696
+ }
1539
1697
  }
1540
1698
  /**
1541
1699
  * 3.6 停止显示所有远端视频画面,同时不再拉取该远端用户的视频数据流
@@ -1550,6 +1708,16 @@ class TRTCCloud extends events_1.EventEmitter {
1550
1708
  }
1551
1709
  });
1552
1710
  this.rtcCloud.stopAllRemoteView();
1711
+ remoteVideoBufferMap.forEach((value, key) => {
1712
+ this.rtcCloud.setRemoteVideoBuffer(key, value.buffer, value.streamType, 0, 0, value.pixelFormat);
1713
+ value.buffer = null;
1714
+ });
1715
+ remoteVideoBufferMap.clear();
1716
+ if (screenVideoBuffer.buffer && !this.isScreenCapturing) {
1717
+ this.rtcCloud.setSubVideoBuffer(screenVideoBuffer.userId, screenVideoBuffer.buffer, screenVideoBuffer.streamType, 0, 0, screenVideoBuffer.pixelFormat);
1718
+ screenVideoBuffer.buffer = null;
1719
+ screenVideoBuffer.userId = '';
1720
+ }
1553
1721
  }
1554
1722
  /**
1555
1723
  * 3.7 暂停接收指定的远端视频流
@@ -1594,7 +1762,7 @@ class TRTCCloud extends events_1.EventEmitter {
1594
1762
  this.rtcCloud.setVideoEncoderParam(params.videoResolution, params.resMode, params.videoFps, params.videoBitrate, params.minVideoBitrate, params.enableAdjustRes);
1595
1763
  }
1596
1764
  else {
1597
- console.error('setVideoEncoderParam, params is not instanceof TRTCVideoEncParam!');
1765
+ console.error('trtc:setVideoEncoderParam, params is not instanceof TRTCVideoEncParam!');
1598
1766
  }
1599
1767
  }
1600
1768
  /**
@@ -1615,7 +1783,7 @@ class TRTCCloud extends events_1.EventEmitter {
1615
1783
  this.rtcCloud.setNetworkQosParam(params.preference, params.controlMode);
1616
1784
  }
1617
1785
  else {
1618
- console.error('setNetworkQosParam, params is not instanceof TRTCNetworkQosParam!');
1786
+ console.error('trtc:setNetworkQosParam, params is not instanceof TRTCNetworkQosParam!');
1619
1787
  }
1620
1788
  }
1621
1789
  /**
@@ -1649,7 +1817,7 @@ class TRTCCloud extends events_1.EventEmitter {
1649
1817
  renderer.setContentMode(mode);
1650
1818
  }
1651
1819
  else {
1652
- console.error('api setLocalViewFillMode failed. the local stream is not exsit.');
1820
+ console.error('trtc:api setLocalViewFillMode failed. the local stream is not exsit.');
1653
1821
  }
1654
1822
  }
1655
1823
  /**
@@ -1694,7 +1862,7 @@ class TRTCCloud extends events_1.EventEmitter {
1694
1862
  renderer.setContentMode(mode);
1695
1863
  }
1696
1864
  else {
1697
- console.error('api setRemoteViewFillMode failed. the remote stream is not exsit.');
1865
+ console.error('trtc:api setRemoteViewFillMode failed. the remote stream is not exsit.');
1698
1866
  }
1699
1867
  }
1700
1868
  /**
@@ -1795,7 +1963,7 @@ class TRTCCloud extends events_1.EventEmitter {
1795
1963
  this.rtcCloud.enableSmallVideoStream(enable, params.videoResolution, params.resMode, params.videoFps, params.videoBitrate, params.minVideoBitrate, params.enableAdjustRes);
1796
1964
  }
1797
1965
  else {
1798
- console.error('enableSmallVideoStream, params is not instanceof TRTCVideoEncParam!');
1966
+ console.error('trtc:enableSmallVideoStream, params is not instanceof TRTCVideoEncParam!');
1799
1967
  }
1800
1968
  }
1801
1969
  /**
@@ -1987,7 +2155,7 @@ class TRTCCloud extends events_1.EventEmitter {
1987
2155
  const recordParams = new trtc_define_1.TRTCAudioRecordingParams(path);
1988
2156
  return this.rtcCloud.startAudioRecording(recordParams.filePath, recordParams.recordingContent);
1989
2157
  }
1990
- console.error('startAudioRecording, params is not instanceof TRTCAudioRecordingParams!');
2158
+ console.error('trtc:startAudioRecording, params is not instanceof TRTCAudioRecordingParams!');
1991
2159
  return -1;
1992
2160
  }
1993
2161
  /**
@@ -2290,7 +2458,7 @@ class TRTCCloud extends events_1.EventEmitter {
2290
2458
  renderer.setContentMode(mode);
2291
2459
  }
2292
2460
  else {
2293
- console.error('api setRemoteSubStreamViewFillMode failed. the remote sub stream is not exsit.');
2461
+ console.error('trtc:api setRemoteSubStreamViewFillMode failed. the remote sub stream is not exsit.');
2294
2462
  }
2295
2463
  }
2296
2464
  /**
@@ -2377,7 +2545,7 @@ class TRTCCloud extends events_1.EventEmitter {
2377
2545
  return this.rtcCloud.selectScreenCaptureTarget(selSource.type, selSource.sourceId, selSource.sourceName, selSource.isMinimizeWindow, deprecatedCaptureRect.left, deprecatedCaptureRect.top, deprecatedCaptureRect.right, deprecatedCaptureRect.bottom, selProperty.enableCaptureMouse, selProperty.enableHighLight, selProperty.enableHighPerformance, selProperty.highLightColor, selProperty.highLightWidth, selProperty.enableCaptureChildWindow);
2378
2546
  }
2379
2547
  else {
2380
- console.error('selectScreenCaptureTarget, sourceId or sourcename is undefined!');
2548
+ console.error('trtc:selectScreenCaptureTarget, sourceId or sourcename is undefined!');
2381
2549
  }
2382
2550
  }
2383
2551
  /**
@@ -2396,7 +2564,7 @@ class TRTCCloud extends events_1.EventEmitter {
2396
2564
  type = trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSub;
2397
2565
  }
2398
2566
  if (params && !(params instanceof trtc_define_1.TRTCVideoEncParam)) {
2399
- console.error('startScreenCapture, params is not instanceof TRTCVideoEncParam!');
2567
+ console.error('trtc:startScreenCapture, params is not instanceof TRTCVideoEncParam!');
2400
2568
  return;
2401
2569
  }
2402
2570
  this.screenCaptureStreamType = type;
@@ -2457,7 +2625,7 @@ class TRTCCloud extends events_1.EventEmitter {
2457
2625
  this.rtcCloud.setSubStreamEncoderParam(params.videoResolution, params.resMode, params.videoFps, params.videoBitrate, params.minVideoBitrate, params.enableAdjustRes);
2458
2626
  }
2459
2627
  else {
2460
- console.error('setSubStreamEncoderParam, params is not instanceof TRTCVideoEncParam!');
2628
+ console.error('trtc:setSubStreamEncoderParam, params is not instanceof TRTCVideoEncParam!');
2461
2629
  }
2462
2630
  }
2463
2631
  /**
@@ -2481,7 +2649,7 @@ class TRTCCloud extends events_1.EventEmitter {
2481
2649
  */
2482
2650
  addExcludedShareWindow(win) {
2483
2651
  if (isNaN(+win)) {
2484
- console.error('addExcludedShareWindow, win: ' + win + 'is not invalid!');
2652
+ console.error('trtc:addExcludedShareWindow, win: ' + win + 'is not invalid!');
2485
2653
  return;
2486
2654
  }
2487
2655
  this.rtcCloud.addExcludedShareWindow(win);
@@ -2494,7 +2662,7 @@ class TRTCCloud extends events_1.EventEmitter {
2494
2662
  */
2495
2663
  removeExcludedShareWindow(win) {
2496
2664
  if (isNaN(+win)) {
2497
- console.error('removeExcludedShareWindow, win: ' + win + 'is not invalid!');
2665
+ console.error('trtc:removeExcludedShareWindow, win: ' + win + 'is not invalid!');
2498
2666
  return;
2499
2667
  }
2500
2668
  this.rtcCloud.removeExcludedShareWindow(win);
@@ -2541,7 +2709,7 @@ class TRTCCloud extends events_1.EventEmitter {
2541
2709
  return 0;
2542
2710
  }
2543
2711
  else {
2544
- console.error('setLocalVideoRenderCallback, param is error!');
2712
+ console.error('trtc:setLocalVideoRenderCallback, param is error!');
2545
2713
  return -1;
2546
2714
  }
2547
2715
  }
@@ -2574,7 +2742,7 @@ class TRTCCloud extends events_1.EventEmitter {
2574
2742
  return 0;
2575
2743
  }
2576
2744
  else {
2577
- console.error('setRemoteVideoRenderCallback, userId is error!');
2745
+ console.error('trtc:setRemoteVideoRenderCallback, userId is error!');
2578
2746
  return -1;
2579
2747
  }
2580
2748
  }
@@ -3043,12 +3211,12 @@ class TRTCCloud extends events_1.EventEmitter {
3043
3211
  }
3044
3212
  this.rtcCloud.startCameraDeviceTest((id, type, width, height, timestamp, rotation, data) => {
3045
3213
  if (this.enableRenderFrame) {
3046
- this._onRenderFrame(id, type, width, height, timestamp, rotation, data);
3214
+ this._onRenderFrame(id, type, width, height, timestamp, rotation, data, 0);
3047
3215
  }
3048
3216
  });
3049
3217
  }
3050
3218
  else {
3051
- console.error('startCameraDeviceTest, view is undefined!');
3219
+ console.error('trtc:startCameraDeviceTest, view is undefined!');
3052
3220
  }
3053
3221
  }
3054
3222
  /**
@@ -3196,40 +3364,55 @@ class TRTCCloud extends events_1.EventEmitter {
3196
3364
  addLocalVideoRenderCallback(streamType) {
3197
3365
  if (this.isExternalRenderEnabled || this.renderMode === 3 || this.renderMode === 5) {
3198
3366
  this.pixelformate = trtc_define_1.TRTCVideoPixelFormat.TRTCVideoPixelFormat_BGRA32;
3367
+ this.pixelLength = 4;
3199
3368
  }
3200
3369
  else if (this.renderMode === 6) {
3201
3370
  this.pixelformate = trtc_define_1.TRTCVideoPixelFormat.TRTCVideoPixelFormat_H264;
3371
+ this.pixelLength = 1;
3202
3372
  }
3203
3373
  else if (this.renderMode === 7 || this.renderMode === 8 || this.renderMode === 9) {
3204
3374
  this.pixelformate = trtc_define_1.TRTCVideoPixelFormat.TRTCVideoPixelFormat_RGBA32;
3375
+ this.pixelLength = 4;
3205
3376
  }
3206
3377
  else {
3207
3378
  // this.renderMode = 1, 2, 4
3208
3379
  this.pixelformate = trtc_define_1.TRTCVideoPixelFormat.TRTCVideoPixelFormat_I420;
3380
+ this.pixelLength = 1.5;
3209
3381
  }
3210
- this.rtcCloud.addLocalVideoRenderCallback((id, type, width, height, timestamp, rotation, data) => {
3211
- if (this.enableRenderFrame) {
3212
- this._onRenderFrame(id, type, width, height, timestamp, rotation, data);
3382
+ this.rtcCloud.addLocalVideoRenderCallback((id, type, width, height, timestamp, rotation, length) => {
3383
+ if (this.isScreenCapturing && this.screenCaptureStreamType === type) {
3384
+ this._onRenderFrame(id, type, width, height, timestamp, rotation, screenVideoBuffer.buffer, length);
3385
+ }
3386
+ else {
3387
+ this._onRenderFrame(id, type, width, height, timestamp, rotation, localVideoBuffer.buffer, length);
3213
3388
  }
3214
3389
  }, this.pixelformate, streamType);
3215
3390
  }
3216
3391
  addRemoteVideoRenderCallback(userId, streamType) {
3217
3392
  if (this.isExternalRenderEnabled || this.renderMode === 3 || this.renderMode === 5) {
3218
3393
  this.pixelformate = trtc_define_1.TRTCVideoPixelFormat.TRTCVideoPixelFormat_BGRA32;
3394
+ this.pixelLength = 4;
3219
3395
  }
3220
3396
  else if (this.renderMode === 6) {
3221
3397
  this.pixelformate = trtc_define_1.TRTCVideoPixelFormat.TRTCVideoPixelFormat_H264;
3398
+ this.pixelLength = 1;
3222
3399
  }
3223
3400
  else if (this.renderMode === 7 || this.renderMode === 8 || this.renderMode === 9) {
3224
3401
  this.pixelformate = trtc_define_1.TRTCVideoPixelFormat.TRTCVideoPixelFormat_RGBA32;
3402
+ this.pixelLength = 4;
3225
3403
  }
3226
3404
  else {
3227
3405
  // this.renderMode = 1, 2, 4
3228
3406
  this.pixelformate = trtc_define_1.TRTCVideoPixelFormat.TRTCVideoPixelFormat_I420;
3407
+ this.pixelLength = 1.5;
3229
3408
  }
3230
- this.rtcCloud.addRemoteVideoRenderCallback(userId, (id, type, width, height, timestamp, rotation, data) => {
3231
- if (this.enableRenderFrame) {
3232
- this._onRenderFrame(id, type, width, height, timestamp, rotation, data);
3409
+ this.rtcCloud.addRemoteVideoRenderCallback(userId, (id, type, width, height, timestamp, rotation, length) => {
3410
+ const videoBufferInfo = remoteVideoBufferMap.get(id);
3411
+ if (videoBufferInfo && videoBufferInfo.streamType === type) {
3412
+ this._onRenderFrame(id, type, width, height, timestamp, rotation, videoBufferInfo.buffer, length);
3413
+ }
3414
+ else {
3415
+ this._onRenderFrame(id, type, width, height, timestamp, rotation, screenVideoBuffer.buffer, length);
3233
3416
  }
3234
3417
  }, this.pixelformate, streamType);
3235
3418
  }
@@ -3257,9 +3440,26 @@ class TRTCCloud extends events_1.EventEmitter {
3257
3440
  this.streams.forEach((value, key, map) => {
3258
3441
  oldStreams.set(key, value);
3259
3442
  });
3443
+ this.renderMode = mode;
3444
+ if (this.isExternalRenderEnabled || this.renderMode === 3 || this.renderMode === 5) {
3445
+ this.pixelformate = trtc_define_1.TRTCVideoPixelFormat.TRTCVideoPixelFormat_BGRA32;
3446
+ this.pixelLength = 4;
3447
+ }
3448
+ else if (this.renderMode === 6) {
3449
+ this.pixelformate = trtc_define_1.TRTCVideoPixelFormat.TRTCVideoPixelFormat_H264;
3450
+ this.pixelLength = 1;
3451
+ }
3452
+ else if (this.renderMode === 7 || this.renderMode === 8 || this.renderMode === 9) {
3453
+ this.pixelformate = trtc_define_1.TRTCVideoPixelFormat.TRTCVideoPixelFormat_RGBA32;
3454
+ this.pixelLength = 4;
3455
+ }
3456
+ else {
3457
+ // this.renderMode = 1, 2, 4
3458
+ this.pixelformate = trtc_define_1.TRTCVideoPixelFormat.TRTCVideoPixelFormat_I420;
3459
+ this.pixelLength = 1.5;
3460
+ }
3260
3461
  if (renderModePixelFormatMap.get(mode) === renderModePixelFormatMap.get(this.renderMode)) {
3261
3462
  // 渲染模式切换不需要改变低层编码格式
3262
- this.renderMode = mode;
3263
3463
  oldStreams.forEach((value, key, map) => {
3264
3464
  let view = value.getView();
3265
3465
  this._initRender(key, view);
@@ -3267,7 +3467,6 @@ class TRTCCloud extends events_1.EventEmitter {
3267
3467
  }
3268
3468
  else {
3269
3469
  // 渲染模式切换需要改变低层编码格式
3270
- this.renderMode = mode;
3271
3470
  oldStreams.forEach((value, key, map) => {
3272
3471
  const view = value.getView();
3273
3472
  // this._destroyRender(key, null);
@@ -3311,7 +3510,7 @@ class TRTCCloud extends events_1.EventEmitter {
3311
3510
  }
3312
3511
  });
3313
3512
  }
3314
- console.debug('Render mode changed to:', this.renderMode);
3513
+ console.debug('trtc:Render mode changed to:', this.renderMode);
3315
3514
  }
3316
3515
  }
3317
3516
  //----------------------------------//
@@ -3360,7 +3559,7 @@ class TRTCCloud extends events_1.EventEmitter {
3360
3559
  return String(uid) + '_' + String(type);
3361
3560
  }
3362
3561
  setEnableRenderFrame(enable) {
3363
- console.log('setEnableRenderFrame:' + enable);
3562
+ console.debug('trtc:setEnableRenderFrame:' + enable);
3364
3563
  this.enableRenderFrame = enable;
3365
3564
  }
3366
3565
  /**
@@ -3397,7 +3596,7 @@ class TRTCCloud extends events_1.EventEmitter {
3397
3596
  let key = this.getKey(uid, type);
3398
3597
  return this.streams.get(key);
3399
3598
  }
3400
- _onRenderFrame(uid, type, width, height, timestamp, rotation, data) {
3599
+ _onRenderFrame(uid, type, width, height, timestamp, rotation, data, length) {
3401
3600
  // 由于 mac 监听自定义渲染回调后不会回调 onFirstVideoFrame ,所以在这里自己实现回调 onFirstVideoFrame
3402
3601
  if (this._isMacPlatform()) {
3403
3602
  setImmediate(() => {
@@ -3427,7 +3626,7 @@ class TRTCCloud extends events_1.EventEmitter {
3427
3626
  });
3428
3627
  }
3429
3628
  if (uid.length == 0) {
3430
- this._onRealRender('local_video', type, width, height, timestamp, rotation, data); //本地社视频返回的是空
3629
+ this._onRealRender('local_video', type, width, height, timestamp, rotation, data, length); //本地社视频返回的是空
3431
3630
  //回调local view 给用户数据,本地数据
3432
3631
  if (type == trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig) {
3433
3632
  if (this.localVideoCallback !== null && this.localVideoCallback.callback !== null) {
@@ -3436,7 +3635,7 @@ class TRTCCloud extends events_1.EventEmitter {
3436
3635
  }
3437
3636
  }
3438
3637
  if (uid === CAMERA_DEVICE_TEST_ID) {
3439
- this._onRealRender(CAMERA_DEVICE_TEST_VIEW, type, width, height, timestamp, rotation, data); //摄像头测试
3638
+ this._onRealRender(CAMERA_DEVICE_TEST_VIEW, type, width, height, timestamp, rotation, data, length); //摄像头测试
3440
3639
  }
3441
3640
  }
3442
3641
  else {
@@ -3458,7 +3657,7 @@ class TRTCCloud extends events_1.EventEmitter {
3458
3657
  if (streamType === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSmall) {
3459
3658
  streamType = trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig;
3460
3659
  }
3461
- this._onRealRender(uid, streamType, width, height, timestamp, rotation, data);
3660
+ this._onRealRender(uid, streamType, width, height, timestamp, rotation, data, length);
3462
3661
  }
3463
3662
  //回调远程给用户数据
3464
3663
  let remoteCallback = this.remoteVideoCallback.get(uid);
@@ -3471,7 +3670,7 @@ class TRTCCloud extends events_1.EventEmitter {
3471
3670
  }
3472
3671
  data = null;
3473
3672
  }
3474
- _onRealRender(uid, type, width, height, timestamp, rotation, data) {
3673
+ _onRealRender(uid, type, width, height, timestamp, rotation, data, length) {
3475
3674
  const renderer = this._getRenderer(uid, type);
3476
3675
  let isNeedRotate = true;
3477
3676
  if (uid === 'local_video' && this._isMacPlatform() && type !== trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSub) {
@@ -3492,7 +3691,18 @@ class TRTCCloud extends events_1.EventEmitter {
3492
3691
  isNeedRotate
3493
3692
  });
3494
3693
  }
3495
- else if (this.renderMode === 4 || this.renderMode === 5 || this.renderMode === 6 || this.renderMode === 8 || this.renderMode === 9) {
3694
+ else if (this.renderMode === 6) {
3695
+ renderer.drawFrame({
3696
+ width,
3697
+ height,
3698
+ data,
3699
+ timestamp,
3700
+ rotation: realRotation,
3701
+ isNeedRotate,
3702
+ length,
3703
+ });
3704
+ }
3705
+ else if (this.renderMode === 4 || this.renderMode === 5 || this.renderMode === 8 || this.renderMode === 9) {
3496
3706
  renderer.drawFrame({
3497
3707
  width,
3498
3708
  height,
@@ -3515,9 +3725,9 @@ class TRTCCloud extends events_1.EventEmitter {
3515
3725
  else {
3516
3726
  let ylen = width * height;
3517
3727
  let ulen = width * height / 4;
3518
- let ydata = new Uint8Array(data, 0, ylen);
3519
- let udata = new Uint8Array(data, ylen, ulen);
3520
- let vdata = new Uint8Array(data, ylen + ulen, ulen);
3728
+ let ydata = new Uint8Array(data.buffer, 0, ylen);
3729
+ let udata = new Uint8Array(data.buffer, ylen, ulen);
3730
+ let vdata = new Uint8Array(data.buffer, ylen + ulen, ulen);
3521
3731
  renderer.drawFrame({
3522
3732
  width: width,
3523
3733
  height: height,
@@ -3566,7 +3776,7 @@ class TRTCCloud extends events_1.EventEmitter {
3566
3776
  renderer = new Render_1.default.Canvas3DRGBARenderer(); // RGBA canvas 3D
3567
3777
  }
3568
3778
  else {
3569
- console.warn('Unknown render mode, fallback to 1');
3779
+ console.warn('trtc:Unknown render mode, fallback to 1');
3570
3780
  renderer = new Render_1.default.GlRenderer();
3571
3781
  }
3572
3782
  view.innerHTML = ''; // 事先清空一下,避免画面叠加
@@ -3606,7 +3816,7 @@ class TRTCCloud extends events_1.EventEmitter {
3606
3816
  throw err;
3607
3817
  }
3608
3818
  else {
3609
- console.log(' write file ok, path:' + path);
3819
+ console.warn('trtc:write file ok, path:' + path);
3610
3820
  }
3611
3821
  });
3612
3822
  }
@@ -4,6 +4,7 @@
4
4
  * @description 分辨率、质量等级等枚举和常量值的定义
5
5
  *
6
6
  */
7
+ /// <reference types="node" />
7
8
  export declare enum TRTCVideoResolution {
8
9
  TRTCVideoResolution_120_120 = 1,
9
10
  TRTCVideoResolution_160_160 = 3,
@@ -761,3 +762,11 @@ export interface PluginInfo {
761
762
  setParameter: (param: string) => number;
762
763
  getParameter: (paramKey: string) => string;
763
764
  }
765
+ export interface VideoBufferInfo {
766
+ userId: string;
767
+ buffer: Buffer | null;
768
+ streamType: TRTCVideoStreamType;
769
+ width: number;
770
+ height: number;
771
+ pixelFormat: TRTCVideoPixelFormat;
772
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trtc-electron-sdk",
3
- "version": "9.8.8-alpha.3",
3
+ "version": "9.8.8-alpha.4",
4
4
  "description": "trtc electron sdk",
5
5
  "main": "./liteav/trtc.js",
6
6
  "types": "./liteav/trtc.d.ts",