trtc-electron-sdk 10.2.0-beta.1 → 10.3.8-beta.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.
Files changed (2) hide show
  1. package/liteav/trtc.js +52 -42
  2. package/package.json +1 -1
package/liteav/trtc.js CHANGED
@@ -1040,13 +1040,16 @@ class TRTCCloud extends events_1.EventEmitter {
1040
1040
  */
1041
1041
  handleOnScreenCaptureStarted() {
1042
1042
  this.isScreenCapturing = true;
1043
- screenVideoBuffer.userId = '';
1044
- screenVideoBuffer.streamType = this.screenCaptureStreamType;
1045
- screenVideoBuffer.buffer = (0, util_1.allocBuffer)(DEFAULT_VIDEO_WIDTH * DEFAULT_VIDEO_HEIGHT * this.pixelLength, screenVideoBuffer.userId, screenVideoBuffer.streamType);
1046
- screenVideoBuffer.pixelFormat = this.pixelformate;
1047
- screenVideoBuffer.width = DEFAULT_VIDEO_WIDTH;
1048
- screenVideoBuffer.height = DEFAULT_VIDEO_HEIGHT;
1049
- this.rtcCloud.setSubVideoBuffer('', screenVideoBuffer.buffer, screenVideoBuffer.streamType, screenVideoBuffer.width, screenVideoBuffer.height, screenVideoBuffer.pixelFormat);
1043
+ // 只有在 Buffer 为 null 时才新建,否则只能在 onVideoSizeChange 事件中重新申请 Buffer
1044
+ if (!screenVideoBuffer.buffer) {
1045
+ screenVideoBuffer.userId = '';
1046
+ screenVideoBuffer.streamType = this.screenCaptureStreamType;
1047
+ screenVideoBuffer.buffer = (0, util_1.allocBuffer)(DEFAULT_VIDEO_WIDTH * DEFAULT_VIDEO_HEIGHT * this.pixelLength, screenVideoBuffer.userId, screenVideoBuffer.streamType);
1048
+ screenVideoBuffer.pixelFormat = this.pixelformate;
1049
+ screenVideoBuffer.width = DEFAULT_VIDEO_WIDTH;
1050
+ screenVideoBuffer.height = DEFAULT_VIDEO_HEIGHT;
1051
+ this.rtcCloud.setSubVideoBuffer('', screenVideoBuffer.buffer, screenVideoBuffer.streamType, screenVideoBuffer.width, screenVideoBuffer.height, screenVideoBuffer.pixelFormat);
1052
+ }
1050
1053
  this.fire('onScreenCaptureStarted');
1051
1054
  }
1052
1055
  /**
@@ -1171,10 +1174,7 @@ class TRTCCloud extends events_1.EventEmitter {
1171
1174
  this.fire('onSystemAudioLoopbackError', errCode);
1172
1175
  }
1173
1176
  handleOnVideoSizeChange(userId, streamType, width, height) {
1174
- if (this.renderMode === 6) {
1175
- return;
1176
- }
1177
- if (userId) {
1177
+ if (userId && userId !== CAMERA_DEVICE_TEST_ID) {
1178
1178
  if (streamType !== trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSub) {
1179
1179
  const videoBufferInfo = remoteVideoBufferMap.get(userId);
1180
1180
  if (videoBufferInfo) {
@@ -1185,9 +1185,6 @@ class TRTCCloud extends events_1.EventEmitter {
1185
1185
  videoBufferInfo.pixelFormat = this.pixelformate;
1186
1186
  this.rtcCloud.setRemoteVideoBuffer(userId, videoBufferInfo.buffer, streamType, width, height, videoBufferInfo.pixelFormat);
1187
1187
  }
1188
- else {
1189
- // 宽高尺寸未变,不用重新分配Buffer
1190
- }
1191
1188
  }
1192
1189
  else {
1193
1190
  console.error(`trtc:onVideoSizeChange error: ${userId} ${streamType} buffer not exist`);
@@ -1217,17 +1214,8 @@ class TRTCCloud extends events_1.EventEmitter {
1217
1214
  }
1218
1215
  }
1219
1216
  else {
1220
- // 本地摄像头
1221
- if (localVideoBuffer.buffer) {
1222
- if (localVideoBuffer.width !== width || localVideoBuffer.height !== height) {
1223
- localVideoBuffer.buffer = (0, util_1.allocBuffer)(width * height * this.pixelLength, localVideoBuffer.userId, streamType);
1224
- localVideoBuffer.width = width;
1225
- localVideoBuffer.height = height;
1226
- localVideoBuffer.pixelFormat = this.pixelformate;
1227
- this.rtcCloud.setLocalVideoBuffer(localVideoBuffer.buffer, width, height, localVideoBuffer.pixelFormat);
1228
- }
1229
- }
1230
- else if (cameraTestVideoBuffer.buffer) {
1217
+ if (userId === CAMERA_DEVICE_TEST_ID) {
1218
+ // 摄像头检测
1231
1219
  if (cameraTestVideoBuffer.width !== width || cameraTestVideoBuffer.height !== height) {
1232
1220
  cameraTestVideoBuffer.buffer = (0, util_1.allocBuffer)(width * height * this.pixelLength, cameraTestVideoBuffer.userId, streamType);
1233
1221
  cameraTestVideoBuffer.width = width;
@@ -1236,6 +1224,16 @@ class TRTCCloud extends events_1.EventEmitter {
1236
1224
  this.rtcCloud.setCameraTestVideoBuffer(cameraTestVideoBuffer.buffer, width, height, cameraTestVideoBuffer.pixelFormat);
1237
1225
  }
1238
1226
  }
1227
+ else {
1228
+ // 本地摄像头
1229
+ if (localVideoBuffer.width !== width || localVideoBuffer.height !== height) {
1230
+ localVideoBuffer.buffer = (0, util_1.allocBuffer)(width * height * this.pixelLength, localVideoBuffer.userId, streamType);
1231
+ localVideoBuffer.width = width;
1232
+ localVideoBuffer.height = height;
1233
+ localVideoBuffer.pixelFormat = this.pixelformate;
1234
+ this.rtcCloud.setLocalVideoBuffer(localVideoBuffer.buffer, width, height, localVideoBuffer.pixelFormat);
1235
+ }
1236
+ }
1239
1237
  }
1240
1238
  }
1241
1239
  }
@@ -1602,12 +1600,15 @@ class TRTCCloud extends events_1.EventEmitter {
1602
1600
  }
1603
1601
  // view 为 null 时,可能启动了自定义渲染,所以 Buffer 还是要创建,否则自定义渲染就拿不到数据;
1604
1602
  // view 非 null 时,当然必须创建 Buffer
1605
- localVideoBuffer.streamType = trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig;
1606
- localVideoBuffer.buffer = (0, util_1.allocBuffer)(DEFAULT_VIDEO_WIDTH * DEFAULT_VIDEO_HEIGHT * this.pixelLength, localVideoBuffer.userId, localVideoBuffer.streamType);
1607
- localVideoBuffer.pixelFormat = this.pixelformate;
1608
- localVideoBuffer.width = DEFAULT_VIDEO_WIDTH;
1609
- localVideoBuffer.height = DEFAULT_VIDEO_HEIGHT;
1610
- this.rtcCloud.setLocalVideoBuffer(localVideoBuffer.buffer, localVideoBuffer.width, localVideoBuffer.height, localVideoBuffer.pixelFormat);
1603
+ // 只有在 Buffer 为 null 时才新建,否则只能在 onVideoSizeChange 事件中重新申请 Buffer
1604
+ if (!localVideoBuffer.buffer) {
1605
+ localVideoBuffer.streamType = trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig;
1606
+ localVideoBuffer.buffer = (0, util_1.allocBuffer)(DEFAULT_VIDEO_WIDTH * DEFAULT_VIDEO_HEIGHT * this.pixelLength, localVideoBuffer.userId, localVideoBuffer.streamType);
1607
+ localVideoBuffer.pixelFormat = this.pixelformate;
1608
+ localVideoBuffer.width = DEFAULT_VIDEO_WIDTH;
1609
+ localVideoBuffer.height = DEFAULT_VIDEO_HEIGHT;
1610
+ this.rtcCloud.setLocalVideoBuffer(localVideoBuffer.buffer, localVideoBuffer.width, localVideoBuffer.height, localVideoBuffer.pixelFormat);
1611
+ }
1611
1612
  this.rtcCloud.startLocalPreview();
1612
1613
  this.addLocalVideoRenderCallback();
1613
1614
  }
@@ -1680,13 +1681,19 @@ class TRTCCloud extends events_1.EventEmitter {
1680
1681
  pixelFormat: this.pixelformate,
1681
1682
  };
1682
1683
  if (streamType !== trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSub) {
1683
- remoteVideoBufferMap.set(userId, videoBufferInfo);
1684
- this.rtcCloud.setRemoteVideoBuffer(userId, videoBufferInfo.buffer, videoBufferInfo.streamType, videoBufferInfo.width, videoBufferInfo.height, videoBufferInfo.pixelFormat);
1684
+ if (!remoteVideoBufferMap.get(userId)) {
1685
+ // Buffer 不存在时才新建,否则只能在 onVideoSizeChange 事件中重新申请 Buffer
1686
+ remoteVideoBufferMap.set(userId, videoBufferInfo);
1687
+ this.rtcCloud.setRemoteVideoBuffer(userId, videoBufferInfo.buffer, videoBufferInfo.streamType, videoBufferInfo.width, videoBufferInfo.height, videoBufferInfo.pixelFormat);
1688
+ }
1685
1689
  }
1686
1690
  else {
1687
1691
  // 远端屏幕分享
1688
- Object.assign(screenVideoBuffer, videoBufferInfo);
1689
- this.rtcCloud.setSubVideoBuffer(screenVideoBuffer.userId, screenVideoBuffer.buffer, screenVideoBuffer.streamType, screenVideoBuffer.width, screenVideoBuffer.height, screenVideoBuffer.pixelFormat);
1692
+ // Buffer 为 null 时才新建,否则只能在 onVideoSizeChange 事件中重新申请 Buffer
1693
+ if (!screenVideoBuffer.buffer) {
1694
+ Object.assign(screenVideoBuffer, videoBufferInfo);
1695
+ this.rtcCloud.setSubVideoBuffer(screenVideoBuffer.userId, screenVideoBuffer.buffer, screenVideoBuffer.streamType, screenVideoBuffer.width, screenVideoBuffer.height, screenVideoBuffer.pixelFormat);
1696
+ }
1690
1697
  }
1691
1698
  this.addRemoteVideoRenderCallback(userId);
1692
1699
  this.rtcCloud.startRemoteView(userId, streamType);
@@ -3236,13 +3243,16 @@ class TRTCCloud extends events_1.EventEmitter {
3236
3243
  const renderer = this.streams.get(key);
3237
3244
  renderer.setContentMode(trtc_define_1.TRTCVideoFillMode.TRTCVideoFillMode_Fill);
3238
3245
  }
3239
- const streamType = trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig;
3240
- cameraTestVideoBuffer.streamType = streamType;
3241
- cameraTestVideoBuffer.pixelFormat = this.pixelformate;
3242
- cameraTestVideoBuffer.buffer = (0, util_1.allocBuffer)(DEFAULT_VIDEO_WIDTH * DEFAULT_VIDEO_HEIGHT * this.pixelLength, cameraTestVideoBuffer.userId, streamType);
3243
- cameraTestVideoBuffer.width = DEFAULT_VIDEO_WIDTH;
3244
- cameraTestVideoBuffer.height = DEFAULT_VIDEO_HEIGHT;
3245
- this.rtcCloud.setCameraTestVideoBuffer(cameraTestVideoBuffer.buffer, cameraTestVideoBuffer.width, cameraTestVideoBuffer.height, cameraTestVideoBuffer.pixelFormat);
3246
+ // Buffer 为 null 时才新建,否则只能在 onVideoSizeChange 事件中重新申请 Buffer
3247
+ if (!cameraTestVideoBuffer.buffer) {
3248
+ const streamType = trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig;
3249
+ cameraTestVideoBuffer.streamType = streamType;
3250
+ cameraTestVideoBuffer.pixelFormat = this.pixelformate;
3251
+ cameraTestVideoBuffer.buffer = (0, util_1.allocBuffer)(DEFAULT_VIDEO_WIDTH * DEFAULT_VIDEO_HEIGHT * this.pixelLength, cameraTestVideoBuffer.userId, streamType);
3252
+ cameraTestVideoBuffer.width = DEFAULT_VIDEO_WIDTH;
3253
+ cameraTestVideoBuffer.height = DEFAULT_VIDEO_HEIGHT;
3254
+ this.rtcCloud.setCameraTestVideoBuffer(cameraTestVideoBuffer.buffer, cameraTestVideoBuffer.width, cameraTestVideoBuffer.height, cameraTestVideoBuffer.pixelFormat);
3255
+ }
3246
3256
  this.rtcCloud.startCameraDeviceTest((id, type, width, height, timestamp, rotation) => {
3247
3257
  if (this.enableRenderFrame) {
3248
3258
  this._onRenderFrame(id, type, width, height, timestamp, rotation, cameraTestVideoBuffer.buffer);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trtc-electron-sdk",
3
- "version": "10.2.0-beta.1",
3
+ "version": "10.3.8-beta.0",
4
4
  "description": "trtc electron sdk",
5
5
  "main": "./liteav/trtc.js",
6
6
  "types": "./liteav/trtc.d.ts",