trtc-electron-sdk 10.3.404-beta.0 → 10.3.404

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/trtc.d.ts CHANGED
@@ -1066,11 +1066,11 @@ declare class TRTCCloud extends EventEmitter {
1066
1066
  * 如果该 userId 没有开启双路编码模式,则此操作无效。
1067
1067
  *
1068
1068
  * @param {String} userId - 用户 ID
1069
- * @param {TRTCVideoStreamType} type - 视频流类型,即选择看大画面还是小画面,默认为 TRTCVideoStreamTypeBig
1069
+ * @param {TRTCVideoStreamType} streamType - 视频流类型,即选择看大画面还是小画面,默认为 TRTCVideoStreamTypeBig
1070
1070
  * - TRTCVideoStreamTypeBig : 大画面视频流
1071
1071
  * - TRTCVideoStreamTypeSmall: 小画面视频流
1072
1072
  */
1073
- setRemoteVideoStreamType(userId: string, type: TRTCVideoStreamType): void;
1073
+ setRemoteVideoStreamType(userId: string, streamType: TRTCVideoStreamType): void;
1074
1074
  /**
1075
1075
  * 3.22 视频画面截图
1076
1076
  *
package/liteav/trtc.js CHANGED
@@ -619,10 +619,16 @@ class TRTCCloud extends events_1.EventEmitter {
619
619
  return !(userId === item.uid && item.type !== trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSub);
620
620
  });
621
621
  }
622
- const videoBufferInfo = remoteVideoBufferMap.get(userId);
623
- if (videoBufferInfo) {
624
- this.rtcCloud.setRemoteVideoBuffer(userId, videoBufferInfo.buffer, videoBufferInfo.streamType, 0, 0, videoBufferInfo.pixelFormat);
625
- videoBufferInfo.buffer = null;
622
+ const remoteUserVideoBuffers = remoteVideoBufferMap.get(userId);
623
+ if (remoteUserVideoBuffers) {
624
+ if (remoteUserVideoBuffers.big) {
625
+ this.rtcCloud.setRemoteVideoBuffer(userId, remoteUserVideoBuffers.big.buffer, remoteUserVideoBuffers.big.streamType, 0, 0, remoteUserVideoBuffers.big.pixelFormat);
626
+ remoteUserVideoBuffers.big.buffer = null;
627
+ }
628
+ if (remoteUserVideoBuffers.small) {
629
+ this.rtcCloud.setRemoteVideoBuffer(userId, remoteUserVideoBuffers.small.buffer, remoteUserVideoBuffers.small.streamType, 0, 0, remoteUserVideoBuffers.small.pixelFormat);
630
+ remoteUserVideoBuffers.small.buffer = null;
631
+ }
626
632
  remoteVideoBufferMap.delete(userId);
627
633
  }
628
634
  }
@@ -1215,14 +1221,25 @@ class TRTCCloud extends events_1.EventEmitter {
1215
1221
  console.debug('trtc:handleVideoSizeChange', userId, streamType, width, height);
1216
1222
  if (userId && userId !== CAMERA_DEVICE_TEST_ID) {
1217
1223
  if (streamType !== trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSub) {
1218
- const videoBufferInfo = remoteVideoBufferMap.get(userId);
1219
- if (videoBufferInfo) {
1220
- if (videoBufferInfo.width !== width || videoBufferInfo.height !== height) {
1221
- videoBufferInfo.buffer = (0, util_1.allocBuffer)(width * height * this.pixelLength, userId, streamType);
1222
- videoBufferInfo.width = width;
1223
- videoBufferInfo.height = height;
1224
- videoBufferInfo.pixelFormat = this.pixelformate;
1225
- this.rtcCloud.setRemoteVideoBuffer(userId, videoBufferInfo.buffer, streamType, width, height, videoBufferInfo.pixelFormat);
1224
+ const remoteUserVideoBuffers = remoteVideoBufferMap.get(userId);
1225
+ if (remoteUserVideoBuffers) {
1226
+ if (streamType === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig && remoteUserVideoBuffers.big) {
1227
+ if (remoteUserVideoBuffers.big.width !== width || remoteUserVideoBuffers.big.height !== height) {
1228
+ remoteUserVideoBuffers.big.buffer = (0, util_1.allocBuffer)(width * height * this.pixelLength, userId, streamType);
1229
+ remoteUserVideoBuffers.big.width = width;
1230
+ remoteUserVideoBuffers.big.height = height;
1231
+ remoteUserVideoBuffers.big.pixelFormat = this.pixelformate;
1232
+ this.rtcCloud.setRemoteVideoBuffer(userId, remoteUserVideoBuffers.big.buffer, streamType, width, height, remoteUserVideoBuffers.big.pixelFormat);
1233
+ }
1234
+ }
1235
+ else if (streamType === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSmall && remoteUserVideoBuffers.small) {
1236
+ if (remoteUserVideoBuffers.small.width !== width || remoteUserVideoBuffers.small.height !== height) {
1237
+ remoteUserVideoBuffers.small.buffer = (0, util_1.allocBuffer)(width * height * this.pixelLength, userId, streamType);
1238
+ remoteUserVideoBuffers.small.width = width;
1239
+ remoteUserVideoBuffers.small.height = height;
1240
+ remoteUserVideoBuffers.small.pixelFormat = this.pixelformate;
1241
+ this.rtcCloud.setRemoteVideoBuffer(userId, remoteUserVideoBuffers.small.buffer, streamType, width, height, remoteUserVideoBuffers.small.pixelFormat);
1242
+ }
1226
1243
  }
1227
1244
  }
1228
1245
  else {
@@ -1345,8 +1362,14 @@ class TRTCCloud extends events_1.EventEmitter {
1345
1362
  this._destroyRender(key, null);
1346
1363
  });
1347
1364
  remoteVideoBufferMap.forEach((value, key) => {
1348
- this.rtcCloud.setRemoteVideoBuffer(key, value.buffer, value.streamType, 0, 0, value.pixelFormat);
1349
- value.buffer = null;
1365
+ if (value.big) {
1366
+ this.rtcCloud.setRemoteVideoBuffer(key, value.big.buffer, value.big.streamType, 0, 0, value.big.pixelFormat);
1367
+ value.big.buffer = null;
1368
+ }
1369
+ if (value.small) {
1370
+ this.rtcCloud.setRemoteVideoBuffer(key, value.small.buffer, value.small.streamType, 0, 0, value.small.pixelFormat);
1371
+ value.small.buffer = null;
1372
+ }
1350
1373
  });
1351
1374
  remoteVideoBufferMap.clear();
1352
1375
  if (localVideoBuffer.buffer) {
@@ -1729,11 +1752,27 @@ class TRTCCloud extends events_1.EventEmitter {
1729
1752
  pixelFormat: this.pixelformate,
1730
1753
  };
1731
1754
  if (streamType !== trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSub) {
1732
- if (!remoteVideoBufferMap.get(userId)) {
1755
+ const remoteUserVideoBuffers = remoteVideoBufferMap.get(userId);
1756
+ if (!remoteUserVideoBuffers) {
1733
1757
  // Buffer 不存在时才新建,否则只能在 handleVideoSizeChange 事件中重新申请 Buffer
1734
- remoteVideoBufferMap.set(userId, videoBufferInfo);
1758
+ if (streamType === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig) {
1759
+ remoteVideoBufferMap.set(userId, { big: videoBufferInfo });
1760
+ }
1761
+ else if (streamType === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSmall) {
1762
+ remoteVideoBufferMap.set(userId, { small: videoBufferInfo });
1763
+ }
1735
1764
  this.rtcCloud.setRemoteVideoBuffer(userId, videoBufferInfo.buffer, videoBufferInfo.streamType, videoBufferInfo.width, videoBufferInfo.height, videoBufferInfo.pixelFormat);
1736
1765
  }
1766
+ else {
1767
+ if (streamType === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig && !remoteUserVideoBuffers.big) {
1768
+ remoteUserVideoBuffers.big = videoBufferInfo;
1769
+ this.rtcCloud.setRemoteVideoBuffer(userId, videoBufferInfo.buffer, videoBufferInfo.streamType, videoBufferInfo.width, videoBufferInfo.height, videoBufferInfo.pixelFormat);
1770
+ }
1771
+ else if (streamType === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSmall && !remoteUserVideoBuffers.small) {
1772
+ remoteUserVideoBuffers.small = videoBufferInfo;
1773
+ this.rtcCloud.setRemoteVideoBuffer(userId, videoBufferInfo.buffer, videoBufferInfo.streamType, videoBufferInfo.width, videoBufferInfo.height, videoBufferInfo.pixelFormat);
1774
+ }
1775
+ }
1737
1776
  }
1738
1777
  else {
1739
1778
  // 远端屏幕分享
@@ -1765,11 +1804,21 @@ class TRTCCloud extends events_1.EventEmitter {
1765
1804
  let key = this.getKey(userId, streamType);
1766
1805
  this._destroyRender(key, null);
1767
1806
  this.rtcCloud.stopRemoteView(userId, streamType);
1768
- const videoBufferInfo = remoteVideoBufferMap.get(userId);
1769
- if (videoBufferInfo && videoBufferInfo.streamType === streamType) {
1770
- this.rtcCloud.setRemoteVideoBuffer(userId, videoBufferInfo.buffer, videoBufferInfo.streamType, 0, 0, videoBufferInfo.pixelFormat);
1771
- videoBufferInfo.buffer = null;
1772
- remoteVideoBufferMap.delete(userId);
1807
+ const remoteUserVideoBuffers = remoteVideoBufferMap.get(userId);
1808
+ if (remoteUserVideoBuffers && streamType !== trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSub) {
1809
+ if (streamType === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig && remoteUserVideoBuffers.big) {
1810
+ this.rtcCloud.setRemoteVideoBuffer(userId, remoteUserVideoBuffers.big.buffer, remoteUserVideoBuffers.big.streamType, 0, 0, remoteUserVideoBuffers.big.pixelFormat);
1811
+ remoteUserVideoBuffers.big.buffer = null;
1812
+ remoteUserVideoBuffers.big = undefined;
1813
+ }
1814
+ else if (streamType === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSmall && remoteUserVideoBuffers.small) {
1815
+ this.rtcCloud.setRemoteVideoBuffer(userId, remoteUserVideoBuffers.small.buffer, remoteUserVideoBuffers.small.streamType, 0, 0, remoteUserVideoBuffers.small.pixelFormat);
1816
+ remoteUserVideoBuffers.small.buffer = null;
1817
+ remoteUserVideoBuffers.small = undefined;
1818
+ }
1819
+ if (!remoteUserVideoBuffers.big && !remoteUserVideoBuffers.small) {
1820
+ remoteVideoBufferMap.delete(userId);
1821
+ }
1773
1822
  }
1774
1823
  else if (screenVideoBuffer.userId === userId && screenVideoBuffer.streamType === streamType) {
1775
1824
  this.rtcCloud.setSubVideoBuffer(userId, screenVideoBuffer.buffer, screenVideoBuffer.streamType, 0, 0, screenVideoBuffer.pixelFormat);
@@ -1791,8 +1840,14 @@ class TRTCCloud extends events_1.EventEmitter {
1791
1840
  });
1792
1841
  this.rtcCloud.stopAllRemoteView();
1793
1842
  remoteVideoBufferMap.forEach((value, key) => {
1794
- this.rtcCloud.setRemoteVideoBuffer(key, value.buffer, value.streamType, 0, 0, value.pixelFormat);
1795
- value.buffer = null;
1843
+ if (value.big) {
1844
+ this.rtcCloud.setRemoteVideoBuffer(key, value.big.buffer, value.big.streamType, 0, 0, value.big.pixelFormat);
1845
+ value.big.buffer = null;
1846
+ }
1847
+ if (value.small) {
1848
+ this.rtcCloud.setRemoteVideoBuffer(key, value.small.buffer, value.small.streamType, 0, 0, value.small.pixelFormat);
1849
+ value.small.buffer = null;
1850
+ }
1796
1851
  });
1797
1852
  remoteVideoBufferMap.clear();
1798
1853
  if (screenVideoBuffer.buffer && !this.isScreenCapturing) {
@@ -2055,12 +2110,34 @@ class TRTCCloud extends events_1.EventEmitter {
2055
2110
  * 如果该 userId 没有开启双路编码模式,则此操作无效。
2056
2111
  *
2057
2112
  * @param {String} userId - 用户 ID
2058
- * @param {TRTCVideoStreamType} type - 视频流类型,即选择看大画面还是小画面,默认为 TRTCVideoStreamTypeBig
2113
+ * @param {TRTCVideoStreamType} streamType - 视频流类型,即选择看大画面还是小画面,默认为 TRTCVideoStreamTypeBig
2059
2114
  * - TRTCVideoStreamTypeBig : 大画面视频流
2060
2115
  * - TRTCVideoStreamTypeSmall: 小画面视频流
2061
2116
  */
2062
- setRemoteVideoStreamType(userId, type) {
2063
- this.rtcCloud.setRemoteVideoStreamType(userId, type);
2117
+ setRemoteVideoStreamType(userId, streamType) {
2118
+ const remoteUserVideoBuffers = remoteVideoBufferMap.get(userId);
2119
+ if (remoteUserVideoBuffers) {
2120
+ const videoBufferInfo = {
2121
+ userId: userId,
2122
+ buffer: (0, util_1.allocBuffer)(DEFAULT_VIDEO_WIDTH * DEFAULT_VIDEO_HEIGHT * this.pixelLength, userId, streamType),
2123
+ streamType: streamType,
2124
+ width: DEFAULT_VIDEO_WIDTH,
2125
+ height: DEFAULT_VIDEO_HEIGHT,
2126
+ pixelFormat: this.pixelformate,
2127
+ };
2128
+ if (streamType === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig && !remoteUserVideoBuffers.big) {
2129
+ remoteUserVideoBuffers.big = videoBufferInfo;
2130
+ this.rtcCloud.setRemoteVideoBuffer(userId, videoBufferInfo.buffer, videoBufferInfo.streamType, videoBufferInfo.width, videoBufferInfo.height, videoBufferInfo.pixelFormat);
2131
+ }
2132
+ else if (streamType === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSmall && !remoteUserVideoBuffers.small) {
2133
+ remoteUserVideoBuffers.small = videoBufferInfo;
2134
+ this.rtcCloud.setRemoteVideoBuffer(userId, videoBufferInfo.buffer, videoBufferInfo.streamType, videoBufferInfo.width, videoBufferInfo.height, videoBufferInfo.pixelFormat);
2135
+ }
2136
+ else {
2137
+ videoBufferInfo.buffer = null;
2138
+ }
2139
+ }
2140
+ this.rtcCloud.setRemoteVideoStreamType(userId, streamType);
2064
2141
  }
2065
2142
  /**
2066
2143
  * 3.22 视频画面截图
@@ -3493,9 +3570,14 @@ class TRTCCloud extends events_1.EventEmitter {
3493
3570
  this.rtcCloud.addRemoteVideoRenderCallback(userId, (id, type, width, height, timestamp, rotation, valid) => {
3494
3571
  if (this.enableRenderFrame) {
3495
3572
  if (valid === 1) {
3496
- const videoBufferInfo = remoteVideoBufferMap.get(id);
3497
- if (videoBufferInfo && videoBufferInfo.streamType === type) {
3498
- this._onRenderFrame(id, type, width, height, timestamp, rotation, videoBufferInfo.buffer);
3573
+ const remoteUserVideoBuffers = remoteVideoBufferMap.get(id);
3574
+ if (remoteUserVideoBuffers && type !== trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSub) {
3575
+ if (type === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig && remoteUserVideoBuffers.big) {
3576
+ this._onRenderFrame(id, type, width, height, timestamp, rotation, remoteUserVideoBuffers.big.buffer);
3577
+ }
3578
+ else if (type === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSmall && remoteUserVideoBuffers.small) {
3579
+ this._onRenderFrame(id, type, width, height, timestamp, rotation, remoteUserVideoBuffers.small.buffer);
3580
+ }
3499
3581
  }
3500
3582
  else {
3501
3583
  this._onRenderFrame(id, type, width, height, timestamp, rotation, screenVideoBuffer.buffer);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trtc-electron-sdk",
3
- "version": "10.3.404-beta.0",
3
+ "version": "10.3.404",
4
4
  "description": "trtc electron sdk",
5
5
  "main": "./liteav/trtc.js",
6
6
  "types": "./liteav/trtc.d.ts",