trtc-electron-sdk 10.6.404-beta.0 → 10.6.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
@@ -1102,11 +1102,11 @@ declare class TRTCCloud extends EventEmitter {
1102
1102
  * 如果该 userId 没有开启双路编码模式,则此操作无效。
1103
1103
  *
1104
1104
  * @param {String} userId - 用户 ID
1105
- * @param {TRTCVideoStreamType} type - 视频流类型,即选择看大画面还是小画面,默认为 TRTCVideoStreamTypeBig
1105
+ * @param {TRTCVideoStreamType} streamType - 视频流类型,即选择看大画面还是小画面,默认为 TRTCVideoStreamTypeBig
1106
1106
  * - TRTCVideoStreamTypeBig : 大画面视频流
1107
1107
  * - TRTCVideoStreamTypeSmall: 小画面视频流
1108
1108
  */
1109
- setRemoteVideoStreamType(userId: string, type: TRTCVideoStreamType): void;
1109
+ setRemoteVideoStreamType(userId: string, streamType: TRTCVideoStreamType): void;
1110
1110
  /**
1111
1111
  * 3.22 视频画面截图
1112
1112
  *
package/liteav/trtc.js CHANGED
@@ -631,10 +631,16 @@ class TRTCCloud extends events_1.EventEmitter {
631
631
  return !(userId === item.uid && item.type !== trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSub);
632
632
  });
633
633
  }
634
- const videoBufferInfo = remoteVideoBufferMap.get(userId);
635
- if (videoBufferInfo) {
636
- this.rtcCloud.setRemoteVideoBuffer(userId, videoBufferInfo.buffer, videoBufferInfo.streamType, 0, 0, videoBufferInfo.pixelFormat);
637
- videoBufferInfo.buffer = null;
634
+ const remoteUserVideoBuffers = remoteVideoBufferMap.get(userId);
635
+ if (remoteUserVideoBuffers) {
636
+ if (remoteUserVideoBuffers.big) {
637
+ this.rtcCloud.setRemoteVideoBuffer(userId, remoteUserVideoBuffers.big.buffer, remoteUserVideoBuffers.big.streamType, 0, 0, remoteUserVideoBuffers.big.pixelFormat);
638
+ remoteUserVideoBuffers.big.buffer = null;
639
+ }
640
+ if (remoteUserVideoBuffers.small) {
641
+ this.rtcCloud.setRemoteVideoBuffer(userId, remoteUserVideoBuffers.small.buffer, remoteUserVideoBuffers.small.streamType, 0, 0, remoteUserVideoBuffers.small.pixelFormat);
642
+ remoteUserVideoBuffers.small.buffer = null;
643
+ }
638
644
  remoteVideoBufferMap.delete(userId);
639
645
  }
640
646
  }
@@ -1271,14 +1277,25 @@ class TRTCCloud extends events_1.EventEmitter {
1271
1277
  console.debug('trtc:handleVideoSizeChange', userId, streamType, width, height);
1272
1278
  if (userId && userId !== CAMERA_DEVICE_TEST_ID) {
1273
1279
  if (streamType !== trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSub) {
1274
- const videoBufferInfo = remoteVideoBufferMap.get(userId);
1275
- if (videoBufferInfo) {
1276
- if (videoBufferInfo.width !== width || videoBufferInfo.height !== height) {
1277
- videoBufferInfo.buffer = (0, util_1.allocBuffer)(width * height * this.pixelLength, userId, streamType);
1278
- videoBufferInfo.width = width;
1279
- videoBufferInfo.height = height;
1280
- videoBufferInfo.pixelFormat = this.pixelformate;
1281
- this.rtcCloud.setRemoteVideoBuffer(userId, videoBufferInfo.buffer, streamType, width, height, videoBufferInfo.pixelFormat);
1280
+ const remoteUserVideoBuffers = remoteVideoBufferMap.get(userId);
1281
+ if (remoteUserVideoBuffers) {
1282
+ if (streamType === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig && remoteUserVideoBuffers.big) {
1283
+ if (remoteUserVideoBuffers.big.width !== width || remoteUserVideoBuffers.big.height !== height) {
1284
+ remoteUserVideoBuffers.big.buffer = (0, util_1.allocBuffer)(width * height * this.pixelLength, userId, streamType);
1285
+ remoteUserVideoBuffers.big.width = width;
1286
+ remoteUserVideoBuffers.big.height = height;
1287
+ remoteUserVideoBuffers.big.pixelFormat = this.pixelformate;
1288
+ this.rtcCloud.setRemoteVideoBuffer(userId, remoteUserVideoBuffers.big.buffer, streamType, width, height, remoteUserVideoBuffers.big.pixelFormat);
1289
+ }
1290
+ }
1291
+ else if (streamType === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSmall && remoteUserVideoBuffers.small) {
1292
+ if (remoteUserVideoBuffers.small.width !== width || remoteUserVideoBuffers.small.height !== height) {
1293
+ remoteUserVideoBuffers.small.buffer = (0, util_1.allocBuffer)(width * height * this.pixelLength, userId, streamType);
1294
+ remoteUserVideoBuffers.small.width = width;
1295
+ remoteUserVideoBuffers.small.height = height;
1296
+ remoteUserVideoBuffers.small.pixelFormat = this.pixelformate;
1297
+ this.rtcCloud.setRemoteVideoBuffer(userId, remoteUserVideoBuffers.small.buffer, streamType, width, height, remoteUserVideoBuffers.small.pixelFormat);
1298
+ }
1282
1299
  }
1283
1300
  }
1284
1301
  else {
@@ -1401,8 +1418,14 @@ class TRTCCloud extends events_1.EventEmitter {
1401
1418
  this._destroyRender(key, null);
1402
1419
  });
1403
1420
  remoteVideoBufferMap.forEach((value, key) => {
1404
- this.rtcCloud.setRemoteVideoBuffer(key, value.buffer, value.streamType, 0, 0, value.pixelFormat);
1405
- value.buffer = null;
1421
+ if (value.big) {
1422
+ this.rtcCloud.setRemoteVideoBuffer(key, value.big.buffer, value.big.streamType, 0, 0, value.big.pixelFormat);
1423
+ value.big.buffer = null;
1424
+ }
1425
+ if (value.small) {
1426
+ this.rtcCloud.setRemoteVideoBuffer(key, value.small.buffer, value.small.streamType, 0, 0, value.small.pixelFormat);
1427
+ value.small.buffer = null;
1428
+ }
1406
1429
  });
1407
1430
  remoteVideoBufferMap.clear();
1408
1431
  if (localVideoBuffer.buffer) {
@@ -1789,11 +1812,27 @@ class TRTCCloud extends events_1.EventEmitter {
1789
1812
  pixelFormat: this.pixelformate,
1790
1813
  };
1791
1814
  if (streamType !== trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSub) {
1792
- if (!remoteVideoBufferMap.get(userId)) {
1815
+ const remoteUserVideoBuffers = remoteVideoBufferMap.get(userId);
1816
+ if (!remoteUserVideoBuffers) {
1793
1817
  // Buffer 不存在时才新建,否则只能在 handleVideoSizeChange 事件中重新申请 Buffer
1794
- remoteVideoBufferMap.set(userId, videoBufferInfo);
1818
+ if (streamType === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig) {
1819
+ remoteVideoBufferMap.set(userId, { big: videoBufferInfo });
1820
+ }
1821
+ else if (streamType === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSmall) {
1822
+ remoteVideoBufferMap.set(userId, { small: videoBufferInfo });
1823
+ }
1795
1824
  this.rtcCloud.setRemoteVideoBuffer(userId, videoBufferInfo.buffer, videoBufferInfo.streamType, videoBufferInfo.width, videoBufferInfo.height, videoBufferInfo.pixelFormat);
1796
1825
  }
1826
+ else {
1827
+ if (streamType === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig && !remoteUserVideoBuffers.big) {
1828
+ remoteUserVideoBuffers.big = videoBufferInfo;
1829
+ this.rtcCloud.setRemoteVideoBuffer(userId, videoBufferInfo.buffer, videoBufferInfo.streamType, videoBufferInfo.width, videoBufferInfo.height, videoBufferInfo.pixelFormat);
1830
+ }
1831
+ else if (streamType === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSmall && !remoteUserVideoBuffers.small) {
1832
+ remoteUserVideoBuffers.small = videoBufferInfo;
1833
+ this.rtcCloud.setRemoteVideoBuffer(userId, videoBufferInfo.buffer, videoBufferInfo.streamType, videoBufferInfo.width, videoBufferInfo.height, videoBufferInfo.pixelFormat);
1834
+ }
1835
+ }
1797
1836
  }
1798
1837
  else {
1799
1838
  // 远端屏幕分享
@@ -1825,11 +1864,21 @@ class TRTCCloud extends events_1.EventEmitter {
1825
1864
  let key = this.getKey(userId, streamType);
1826
1865
  this._destroyRender(key, null);
1827
1866
  this.rtcCloud.stopRemoteView(userId, streamType);
1828
- const videoBufferInfo = remoteVideoBufferMap.get(userId);
1829
- if (videoBufferInfo && videoBufferInfo.streamType === streamType) {
1830
- this.rtcCloud.setRemoteVideoBuffer(userId, videoBufferInfo.buffer, videoBufferInfo.streamType, 0, 0, videoBufferInfo.pixelFormat);
1831
- videoBufferInfo.buffer = null;
1832
- remoteVideoBufferMap.delete(userId);
1867
+ const remoteUserVideoBuffers = remoteVideoBufferMap.get(userId);
1868
+ if (remoteUserVideoBuffers && streamType !== trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSub) {
1869
+ if (streamType === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig && remoteUserVideoBuffers.big) {
1870
+ this.rtcCloud.setRemoteVideoBuffer(userId, remoteUserVideoBuffers.big.buffer, remoteUserVideoBuffers.big.streamType, 0, 0, remoteUserVideoBuffers.big.pixelFormat);
1871
+ remoteUserVideoBuffers.big.buffer = null;
1872
+ remoteUserVideoBuffers.big = undefined;
1873
+ }
1874
+ else if (streamType === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSmall && remoteUserVideoBuffers.small) {
1875
+ this.rtcCloud.setRemoteVideoBuffer(userId, remoteUserVideoBuffers.small.buffer, remoteUserVideoBuffers.small.streamType, 0, 0, remoteUserVideoBuffers.small.pixelFormat);
1876
+ remoteUserVideoBuffers.small.buffer = null;
1877
+ remoteUserVideoBuffers.small = undefined;
1878
+ }
1879
+ if (!remoteUserVideoBuffers.big && !remoteUserVideoBuffers.small) {
1880
+ remoteVideoBufferMap.delete(userId);
1881
+ }
1833
1882
  }
1834
1883
  else if (screenVideoBuffer.userId === userId && screenVideoBuffer.streamType === streamType) {
1835
1884
  this.rtcCloud.setSubVideoBuffer(userId, screenVideoBuffer.buffer, screenVideoBuffer.streamType, 0, 0, screenVideoBuffer.pixelFormat);
@@ -1851,8 +1900,14 @@ class TRTCCloud extends events_1.EventEmitter {
1851
1900
  });
1852
1901
  this.rtcCloud.stopAllRemoteView();
1853
1902
  remoteVideoBufferMap.forEach((value, key) => {
1854
- this.rtcCloud.setRemoteVideoBuffer(key, value.buffer, value.streamType, 0, 0, value.pixelFormat);
1855
- value.buffer = null;
1903
+ if (value.big) {
1904
+ this.rtcCloud.setRemoteVideoBuffer(key, value.big.buffer, value.big.streamType, 0, 0, value.big.pixelFormat);
1905
+ value.big.buffer = null;
1906
+ }
1907
+ if (value.small) {
1908
+ this.rtcCloud.setRemoteVideoBuffer(key, value.small.buffer, value.small.streamType, 0, 0, value.small.pixelFormat);
1909
+ value.small.buffer = null;
1910
+ }
1856
1911
  });
1857
1912
  remoteVideoBufferMap.clear();
1858
1913
  if (screenVideoBuffer.buffer && !this.isScreenCapturing) {
@@ -2115,12 +2170,34 @@ class TRTCCloud extends events_1.EventEmitter {
2115
2170
  * 如果该 userId 没有开启双路编码模式,则此操作无效。
2116
2171
  *
2117
2172
  * @param {String} userId - 用户 ID
2118
- * @param {TRTCVideoStreamType} type - 视频流类型,即选择看大画面还是小画面,默认为 TRTCVideoStreamTypeBig
2173
+ * @param {TRTCVideoStreamType} streamType - 视频流类型,即选择看大画面还是小画面,默认为 TRTCVideoStreamTypeBig
2119
2174
  * - TRTCVideoStreamTypeBig : 大画面视频流
2120
2175
  * - TRTCVideoStreamTypeSmall: 小画面视频流
2121
2176
  */
2122
- setRemoteVideoStreamType(userId, type) {
2123
- this.rtcCloud.setRemoteVideoStreamType(userId, type);
2177
+ setRemoteVideoStreamType(userId, streamType) {
2178
+ const remoteUserVideoBuffers = remoteVideoBufferMap.get(userId);
2179
+ if (remoteUserVideoBuffers) {
2180
+ const videoBufferInfo = {
2181
+ userId: userId,
2182
+ buffer: (0, util_1.allocBuffer)(DEFAULT_VIDEO_WIDTH * DEFAULT_VIDEO_HEIGHT * this.pixelLength, userId, streamType),
2183
+ streamType: streamType,
2184
+ width: DEFAULT_VIDEO_WIDTH,
2185
+ height: DEFAULT_VIDEO_HEIGHT,
2186
+ pixelFormat: this.pixelformate,
2187
+ };
2188
+ if (streamType === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig && !remoteUserVideoBuffers.big) {
2189
+ remoteUserVideoBuffers.big = videoBufferInfo;
2190
+ this.rtcCloud.setRemoteVideoBuffer(userId, videoBufferInfo.buffer, videoBufferInfo.streamType, videoBufferInfo.width, videoBufferInfo.height, videoBufferInfo.pixelFormat);
2191
+ }
2192
+ else if (streamType === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSmall && !remoteUserVideoBuffers.small) {
2193
+ remoteUserVideoBuffers.small = videoBufferInfo;
2194
+ this.rtcCloud.setRemoteVideoBuffer(userId, videoBufferInfo.buffer, videoBufferInfo.streamType, videoBufferInfo.width, videoBufferInfo.height, videoBufferInfo.pixelFormat);
2195
+ }
2196
+ else {
2197
+ videoBufferInfo.buffer = null;
2198
+ }
2199
+ }
2200
+ this.rtcCloud.setRemoteVideoStreamType(userId, streamType);
2124
2201
  }
2125
2202
  /**
2126
2203
  * 3.22 视频画面截图
@@ -3668,9 +3745,14 @@ class TRTCCloud extends events_1.EventEmitter {
3668
3745
  this.rtcCloud.addRemoteVideoRenderCallback(userId, (id, type, width, height, timestamp, rotation, valid) => {
3669
3746
  if (this.enableRenderFrame) {
3670
3747
  if (valid === 1) {
3671
- const videoBufferInfo = remoteVideoBufferMap.get(id);
3672
- if (videoBufferInfo && videoBufferInfo.streamType === type) {
3673
- this._onRenderFrame(id, type, width, height, timestamp, rotation, videoBufferInfo.buffer);
3748
+ const remoteUserVideoBuffers = remoteVideoBufferMap.get(id);
3749
+ if (remoteUserVideoBuffers && type !== trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSub) {
3750
+ if (type === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig && remoteUserVideoBuffers.big) {
3751
+ this._onRenderFrame(id, type, width, height, timestamp, rotation, remoteUserVideoBuffers.big.buffer);
3752
+ }
3753
+ else if (type === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSmall && remoteUserVideoBuffers.small) {
3754
+ this._onRenderFrame(id, type, width, height, timestamp, rotation, remoteUserVideoBuffers.small.buffer);
3755
+ }
3674
3756
  }
3675
3757
  else {
3676
3758
  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.6.404-beta.0",
3
+ "version": "10.6.404",
4
4
  "description": "trtc electron sdk",
5
5
  "main": "./liteav/trtc.js",
6
6
  "types": "./liteav/trtc.d.ts",
@@ -14,6 +14,7 @@
14
14
  "rimraf": "^3.0.2",
15
15
  "semver": "^6.0.0",
16
16
  "signale": "^1.4.0",
17
+ "yuv-buffer": "^1.0.0",
17
18
  "yuv-canvas": "^1.2.6"
18
19
  },
19
20
  "devDependencies": {