trtc-electron-sdk 10.7.404 → 10.7.405-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.
@@ -44,3 +44,4 @@ export declare function calcVideoStyle(options?: {
44
44
  };
45
45
  export declare const config: Config;
46
46
  export declare function allocBuffer(length: number, userId?: string, streamType?: TRTCVideoStreamType): Buffer;
47
+ export declare function generateUniqueId(): number;
@@ -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.generateUniqueId = exports.allocBuffer = exports.config = exports.calcVideoStyle = exports.calcCanvasStyle = exports.calcScaleRate = exports.isNeedKeepWidthAndHeight = exports.Config = void 0;
4
4
  /**
5
5
  * 配置对象, 可用来打开 debug 模式
6
6
  *
@@ -134,3 +134,7 @@ function allocBuffer(length, userId, streamType) {
134
134
  return null;
135
135
  }
136
136
  exports.allocBuffer = allocBuffer;
137
+ function generateUniqueId() {
138
+ return Date.now() * 1000 + Math.floor(Math.random() * 1000);
139
+ }
140
+ exports.generateUniqueId = generateUniqueId;
package/liteav/trtc.d.ts CHANGED
@@ -23,12 +23,17 @@ declare class TRTCCloud extends EventEmitter {
23
23
  private firstVideoFrameList;
24
24
  private playStreamType;
25
25
  private localFillMode;
26
+ private remoteFillModeMap;
26
27
  private imageData;
27
28
  private localVideoCallback;
28
29
  private remoteVideoCallback;
29
30
  private isExternalRenderEnabled;
30
31
  private pixelformate;
31
32
  private pixelLength;
33
+ private enableRenderFrame;
34
+ private screenCaptureStreamType;
35
+ private isScreenCapturing;
36
+ private vodPlayers;
32
37
  private localRotation;
33
38
  private localMirrorType;
34
39
  private remoteMainStreamFillMode;
@@ -41,10 +46,6 @@ declare class TRTCCloud extends EventEmitter {
41
46
  private audioQuality;
42
47
  private bgmId;
43
48
  private playAudioEffectIdList;
44
- private enableRenderFrame;
45
- private screenCaptureStreamType;
46
- private isScreenCapturing;
47
- private vodPlayers;
48
49
  constructor();
49
50
  /**
50
51
  * 创建 TRTCCloud 对象单例
@@ -902,7 +903,20 @@ declare class TRTCCloud extends EventEmitter {
902
903
  */
903
904
  stopLocalPreview(): void;
904
905
  /**
905
- * 3.3 暂停/恢复发布本地的视频流
906
+ * 3.3 修改本地摄像头预览的 HTML 元素
907
+ *
908
+ * 本接口用于切换显示区域的交互场景中,修改本地摄像头预览的 HTML 元素。
909
+ *
910
+ * 注意:必须在调用 [startLocalPreview()]{@link TRTCCloud#startLocalPreview} 接口开启本地摄像头采集后,调用本接口才会生效。
911
+ * - 如果用户调用 `startLocalPreview(view)` 接口开启了摄像头采集,则通过此接口可以修改摄像头采集视频渲染的 HTML 元素。
912
+ * - 如果用户调用 `startLocalPreview(null)` 接口开启了摄像头采集,但未开启本地预览,支持调用此接口开启预览。
913
+ *
914
+ * @param {HTMLElement|null} view - 接收本地摄像头采集视频渲染的 HTML 元素,传入 `null` 结束本地摄像头采集视频的预览。
915
+ * - 传入的 HTML 元素必须是块元素,比如:`div`
916
+ */
917
+ updateLocalView(view: HTMLElement | null): void;
918
+ /**
919
+ * 3.4 暂停/恢复发布本地的视频流
906
920
  *
907
921
  * 该接口可以暂停(或恢复)发布本地的视频画面,暂停之后,同一房间中的其他用户将无法继续看到自己画面。
908
922
  * 该接口在指定 TRTCVideoStreamTypeBig 时等效于 start/stopLocalPreview 这两个接口,但具有更好的响应速度。
@@ -916,7 +930,7 @@ declare class TRTCCloud extends EventEmitter {
916
930
  */
917
931
  muteLocalVideo(mute: boolean, streamType?: TRTCVideoStreamType): void;
918
932
  /**
919
- * 3.4 开始显示远端视频画面
933
+ * 3.5 开始显示远端视频画面
920
934
  *
921
935
  * 在收到 SDK 的 onUserVideoAvailable(userId, 1) 通知时,可以获知该远程用户开启了视频,
922
936
  * 此后调用 startRemoteView(userId) 接口加载该用户的远程画面时,可以用 loading 动画优化加载过程中的等待体验。
@@ -928,7 +942,7 @@ declare class TRTCCloud extends EventEmitter {
928
942
  */
929
943
  startRemoteView(userId: string, view: HTMLElement, streamType?: TRTCVideoStreamType): void;
930
944
  /**
931
- * 3.5 停止显示远端视频画面,同时不再拉取该远端用户的视频数据流
945
+ * 3.6 停止显示远端视频画面,同时不再拉取该远端用户的视频数据流
932
946
  *
933
947
  * 调用此接口后,SDK 会停止接收该用户的远程视频流,同时会清理相关的视频显示资源。
934
948
  *
@@ -937,14 +951,28 @@ declare class TRTCCloud extends EventEmitter {
937
951
  */
938
952
  stopRemoteView(userId: string, streamType?: TRTCVideoStreamType): void;
939
953
  /**
940
- * 3.6 停止显示所有远端视频画面,同时不再拉取该远端用户的视频数据流
954
+ * 3.7 修改远端视频渲染的 HTML 元素
955
+ *
956
+ * 本接口用于切换显示区域的交互场景中,修改远端视频渲染的 HTML 元素。
957
+ *
958
+ * 注意:必须调用 [startRemoteView()]{@link TRTCCloud#startRemoteView} 订阅了远端视频流之后,调用此接口才会生效。
959
+ *
960
+ * @param {String} userId - 远端视频流的用户 ID
961
+ * @param {HTMLElement|null} view - 接受远端视频流渲染的 HTML 元素,传入 null 结束远端视频的渲染
962
+ * - 传入的 HTML 元素必须时块元素,例如:div
963
+ * @param {TRTCVideoStreamType} streamType - 视频流类型
964
+ *
965
+ */
966
+ updateRemoteView(userId: string, view: HTMLElement | null, streamType: TRTCVideoStreamType): void;
967
+ /**
968
+ * 3.8 停止显示所有远端视频画面,同时不再拉取该远端用户的视频数据流
941
969
  *
942
970
  * 注意:如果有屏幕分享的画面在显示,则屏幕分享的画面也会一并被关闭。
943
971
  *
944
972
  */
945
973
  stopAllRemoteView(): void;
946
974
  /**
947
- * 3.7 暂停接收指定的远端视频流
975
+ * 3.9 暂停接收指定的远端视频流
948
976
  *
949
977
  * 该接口仅停止接收远程用户的视频流,但并不释放显示资源,所以视频画面会冻屏在 mute 前的最后一帧。
950
978
  *
@@ -954,13 +982,13 @@ declare class TRTCCloud extends EventEmitter {
954
982
  */
955
983
  muteRemoteVideoStream(userId: string, mute: boolean, streamType?: TRTCVideoStreamType): void;
956
984
  /**
957
- * 3.8 停止接收所有远端视频流
985
+ * 3.10 停止接收所有远端视频流
958
986
  *
959
987
  * @param {Boolean} mute - 是否停止接收
960
988
  */
961
989
  muteAllRemoteVideoStreams(mute: boolean): void;
962
990
  /**
963
- * 3.9 设置视频编码器相关参数
991
+ * 3.11 设置视频编码器相关参数
964
992
  *
965
993
  * 该设置决定了远端用户看到的画面质量(同时也是云端录制出的视频文件的画面质量)
966
994
  *
@@ -975,7 +1003,7 @@ declare class TRTCCloud extends EventEmitter {
975
1003
  */
976
1004
  setVideoEncoderParam(params: any): void;
977
1005
  /**
978
- * 3.10 设置网络流控相关参数
1006
+ * 3.12 设置网络流控相关参数
979
1007
  *
980
1008
  * 该设置决定了 SDK 在各种网络环境下的调控策略(例如弱网下是“保清晰”还是“保流畅”)
981
1009
  *
@@ -989,7 +1017,7 @@ declare class TRTCCloud extends EventEmitter {
989
1017
  */
990
1018
  setNetworkQosParam(params: any): void;
991
1019
  /**
992
- * 3.11 设置本地图像(主流)的渲染参数
1020
+ * 3.13 设置本地图像(主流)的渲染参数
993
1021
  *
994
1022
  * @param {TRTCRenderParams} params - 本地图像的参数
995
1023
  * @param {TRTCVideoRotation} params.rotation - 视频画面旋转方向
@@ -998,7 +1026,7 @@ declare class TRTCCloud extends EventEmitter {
998
1026
  */
999
1027
  setLocalRenderParams(params: TRTCRenderParams): void;
1000
1028
  /**
1001
- * 3.12 废弃接口: 设置本地图像的渲染模式
1029
+ * 3.14 废弃接口: 设置本地图像的渲染模式
1002
1030
  *
1003
1031
  * @deprecated 从 TRTCSDK 8.0 后该接口已被废弃,请使用 setLocalRenderParams 接口替代。
1004
1032
  * @param {TRTCVideoFillMode} mode - 填充(画面可能会被拉伸裁剪)或适应(画面可能会有黑边),默认值:TRTCVideoFillMode_Fit
@@ -1007,7 +1035,7 @@ declare class TRTCCloud extends EventEmitter {
1007
1035
  */
1008
1036
  setLocalViewFillMode(mode: TRTCVideoFillMode): void;
1009
1037
  /**
1010
- * 3.13 设置远端画面的渲染模式
1038
+ * 3.15 设置远端画面的渲染模式
1011
1039
  *
1012
1040
  * @param {String} userId - 用户 ID
1013
1041
  * @param {TRTCVideoStreamType} streamType - 视频流类型
@@ -1018,7 +1046,7 @@ declare class TRTCCloud extends EventEmitter {
1018
1046
  */
1019
1047
  setRemoteRenderParams(userId: string, streamType: TRTCVideoStreamType, params: TRTCRenderParams): void;
1020
1048
  /**
1021
- * 3.14 废弃接口: 设置远端图像的渲染模式
1049
+ * 3.16 废弃接口: 设置远端图像的渲染模式
1022
1050
  *
1023
1051
  * @deprecated 从 TRTCSDK 8.0 后该接口已被废弃,请使用 setRemoteRenderParams 接口替代。
1024
1052
  * @param {String} userId - 用户 ID
@@ -1028,7 +1056,7 @@ declare class TRTCCloud extends EventEmitter {
1028
1056
  */
1029
1057
  setRemoteViewFillMode(userId: string, mode: TRTCVideoFillMode): void;
1030
1058
  /**
1031
- * 3.15 废弃接口: 设置本地图像的顺时针旋转角度
1059
+ * 3.17 废弃接口: 设置本地图像的顺时针旋转角度
1032
1060
  *
1033
1061
  * @deprecated 从 TRTCSDK 8.0 后该接口已被废弃,请使用 setLocalRenderParams 接口替代。
1034
1062
  * @param {TRTCVideoRotation} rotation - 支持 TRTCVideoRotation90 、 TRTCVideoRotation180 、 TRTCVideoRotation270 旋转角度,默认值:TRTCVideoRotation0
@@ -1039,7 +1067,7 @@ declare class TRTCCloud extends EventEmitter {
1039
1067
  */
1040
1068
  setLocalViewRotation(rotation: TRTCVideoRotation): void;
1041
1069
  /**
1042
- * 3.16 废弃接口: 设置远端图像的顺时针旋转角度
1070
+ * 3.17 废弃接口: 设置远端图像的顺时针旋转角度
1043
1071
  *
1044
1072
  * @deprecated 从 TRTCSDK 8.0 后该接口已被废弃,请使用 setRemoteRenderParams 接口替代。
1045
1073
  * @param {String} userId - 用户 ID
@@ -1051,7 +1079,7 @@ declare class TRTCCloud extends EventEmitter {
1051
1079
  */
1052
1080
  setRemoteViewRotation(userId: string, rotation: TRTCVideoRotation): void;
1053
1081
  /**
1054
- * 3.17 设置视频编码输出的(也就是远端用户观看到的,以及服务器录制下来的)画面方向
1082
+ * 3.19 设置视频编码输出的(也就是远端用户观看到的,以及服务器录制下来的)画面方向
1055
1083
  *
1056
1084
  * @param {TRTCVideoRotation} rotation - 目前支持 TRTCVideoRotation0 和 TRTCVideoRotation180 两个旋转角度,默认值:TRTCVideoRotation0
1057
1085
  * - TRTCVideoRotation0 : 顺时针旋转0度
@@ -1059,14 +1087,14 @@ declare class TRTCCloud extends EventEmitter {
1059
1087
  */
1060
1088
  setVideoEncoderRotation(rotation: TRTCVideoRotation): void;
1061
1089
  /**
1062
- * 3.18 废弃接口: 设置本地摄像头预览画面的镜像模式
1090
+ * 3.20 废弃接口: 设置本地摄像头预览画面的镜像模式
1063
1091
  *
1064
1092
  * @deprecated 从 TRTCSDK 8.0 后该接口已被废弃,请使用 setLocalRenderParams 接口替代。
1065
1093
  * @param {Boolean} mirror - 镜像模式, windows 默认值: false(非镜像模式), mac 默认值: true(镜像模式)
1066
1094
  */
1067
1095
  setLocalViewMirror(mirror: boolean): void;
1068
1096
  /**
1069
- * 3.19 设置编码器输出的画面镜像模式
1097
+ * 3.21 设置编码器输出的画面镜像模式
1070
1098
  *
1071
1099
  * 该接口不改变本地摄像头的预览画面,但会改变另一端用户看到的(以及服务器录制的)画面效果。
1072
1100
  *
@@ -1074,7 +1102,7 @@ declare class TRTCCloud extends EventEmitter {
1074
1102
  */
1075
1103
  setVideoEncoderMirror(mirror: boolean): void;
1076
1104
  /**
1077
- * 3.20 开启大小画面双路编码模式
1105
+ * 3.22 开启大小画面双路编码模式
1078
1106
  *
1079
1107
  * 如果当前用户是房间中的主要角色(例如主播、老师、主持人等),并且使用 PC 或者 Mac 环境,可以开启该模式。
1080
1108
  * 开启该模式后,当前用户会同时输出【高清】和【低清】两路视频流(但只有一路音频流)。
@@ -1096,7 +1124,7 @@ declare class TRTCCloud extends EventEmitter {
1096
1124
  */
1097
1125
  enableSmallVideoStream(enable: boolean, params: any): void;
1098
1126
  /**
1099
- * 3.21 选定观看指定 userId 的大画面或小画面
1127
+ * 3.23 选定观看指定 userId 的大画面或小画面
1100
1128
  *
1101
1129
  * 此功能需要该 userId 通过 enableSmallVideoStream 提前开启双路编码模式。
1102
1130
  * 如果该 userId 没有开启双路编码模式,则此操作无效。
@@ -1108,7 +1136,7 @@ declare class TRTCCloud extends EventEmitter {
1108
1136
  */
1109
1137
  setRemoteVideoStreamType(userId: string, streamType: TRTCVideoStreamType): void;
1110
1138
  /**
1111
- * 3.22 视频画面截图
1139
+ * 3.24 视频画面截图
1112
1140
  *
1113
1141
  * 调用截图接口后,您会收到来自 TRTCCallback 中的 [onSnapshotComplete]{@link TRTCCallback#event:onSnapshotComplete} 回调:
1114
1142
  * 截取本地、远程主路和远端辅流的视频画面,并通过 HBITMAP 对象返回给您。
@@ -1119,7 +1147,7 @@ declare class TRTCCloud extends EventEmitter {
1119
1147
  */
1120
1148
  snapshotVideo(userId: string, type: TRTCVideoStreamType): void;
1121
1149
  /**
1122
- * 3.23 废弃接口: 设定观看方优先选择的视频质量
1150
+ * 3.25 废弃接口: 设定观看方优先选择的视频质量
1123
1151
  *
1124
1152
  * 低端设备推荐优先选择低清晰度的小画面。
1125
1153
  * 如果对方没有开启双路视频模式,则此操作无效。
@@ -1132,7 +1160,7 @@ declare class TRTCCloud extends EventEmitter {
1132
1160
  */
1133
1161
  setPriorRemoteVideoStreamType(type: TRTCVideoStreamType): void;
1134
1162
  /**
1135
- * 3.24 开启本地媒体录制
1163
+ * 3.26 开启本地媒体录制
1136
1164
  *
1137
1165
  * 开启后把直播过程中的音视和视频内容录制到本地的一个文件中。
1138
1166
  *
@@ -1149,7 +1177,7 @@ declare class TRTCCloud extends EventEmitter {
1149
1177
  interval: number;
1150
1178
  }): void;
1151
1179
  /**
1152
- * 3.25 停止本地媒体录制
1180
+ * 3.27 停止本地媒体录制
1153
1181
  *
1154
1182
  * 如果录制任务在退出房间前尚未通过本接口停止,则退出房间后录音任务会自动被停止。
1155
1183
  */
@@ -2185,8 +2213,8 @@ declare class TRTCCloud extends EventEmitter {
2185
2213
  _getRenderer(uid: string, type: TRTCVideoStreamType): any;
2186
2214
  _onRenderFrame(uid: string, type: TRTCVideoStreamType, width: number, height: number, timestamp: number, rotation: number, data: any): void;
2187
2215
  _onRealRender(uid: string, type: TRTCVideoStreamType, width: number, height: number, timestamp: number, rotation: number, data: any): void;
2188
- _initRender(key: string, view: HTMLElement): void;
2189
- _destroyRender(key: string, onFailure: ((err: Error) => void) | null): void;
2216
+ private _initRender;
2217
+ private _destroyRender;
2190
2218
  /**
2191
2219
  * 写文件
2192
2220
  * path, path
package/liteav/trtc.js CHANGED
@@ -37,6 +37,7 @@ const CAMERA_DEVICE_TEST_ID = 'camera_device_test';
37
37
  const DEFAULT_VIDEO_WIDTH = 640;
38
38
  const DEFAULT_VIDEO_HEIGHT = 360;
39
39
  const localVideoBuffer = {
40
+ id: 0,
40
41
  userId: '',
41
42
  buffer: null,
42
43
  streamType: trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig,
@@ -45,6 +46,7 @@ const localVideoBuffer = {
45
46
  pixelFormat: trtc_define_1.TRTCVideoPixelFormat.TRTCVideoPixelFormat_I420,
46
47
  };
47
48
  const screenVideoBuffer = {
49
+ id: 0,
48
50
  userId: '',
49
51
  buffer: null,
50
52
  streamType: trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSub,
@@ -53,6 +55,7 @@ const screenVideoBuffer = {
53
55
  pixelFormat: trtc_define_1.TRTCVideoPixelFormat.TRTCVideoPixelFormat_I420,
54
56
  };
55
57
  const cameraTestVideoBuffer = {
58
+ id: 0,
56
59
  userId: CAMERA_DEVICE_TEST_ID,
57
60
  buffer: null,
58
61
  streamType: trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig,
@@ -156,6 +159,7 @@ let oriRtcCloud = null;
156
159
  *
157
160
  */
158
161
  class TRTCCloud extends events_1.EventEmitter {
162
+ // 兼容 8.0 以下版本, 记录内部状态变量 --end
159
163
  constructor() {
160
164
  super();
161
165
  const componentNO = getComponentNO();
@@ -170,6 +174,7 @@ class TRTCCloud extends events_1.EventEmitter {
170
174
  this.pixelLength = 1.5;
171
175
  this.isExternalRenderEnabled = false;
172
176
  this.localFillMode = trtc_define_1.TRTCVideoFillMode.TRTCVideoFillMode_Fit;
177
+ this.remoteFillModeMap = new Map();
173
178
  this.localRotation = trtc_define_1.TRTCVideoRotation.TRTCVideoRotation0;
174
179
  this.localMirrorType = trtc_define_1.TRTCVideoMirrorType.TRTCVideoMirrorType_Disable;
175
180
  this.remoteMainStreamFillMode = trtc_define_1.TRTCVideoFillMode.TRTCVideoFillMode_Fit;
@@ -250,6 +255,7 @@ class TRTCCloud extends events_1.EventEmitter {
250
255
  destroy() {
251
256
  this.firstVideoFrameList = [];
252
257
  this.playAudioEffectIdList = [];
258
+ this.remoteFillModeMap.clear();
253
259
  this.rtcCloud.destroy();
254
260
  }
255
261
  /////////////////////////////////////////////////////////////////////////////////
@@ -634,11 +640,11 @@ class TRTCCloud extends events_1.EventEmitter {
634
640
  const remoteUserVideoBuffers = remoteVideoBufferMap.get(userId);
635
641
  if (remoteUserVideoBuffers) {
636
642
  if (remoteUserVideoBuffers.big) {
637
- this.rtcCloud.setRemoteVideoBuffer(userId, remoteUserVideoBuffers.big.buffer, remoteUserVideoBuffers.big.streamType, 0, 0, remoteUserVideoBuffers.big.pixelFormat);
643
+ this.rtcCloud.setRemoteVideoBuffer(userId, remoteUserVideoBuffers.big.buffer, remoteUserVideoBuffers.big.streamType, 0, 0, remoteUserVideoBuffers.big.pixelFormat, remoteUserVideoBuffers.big.id);
638
644
  remoteUserVideoBuffers.big.buffer = null;
639
645
  }
640
646
  if (remoteUserVideoBuffers.small) {
641
- this.rtcCloud.setRemoteVideoBuffer(userId, remoteUserVideoBuffers.small.buffer, remoteUserVideoBuffers.small.streamType, 0, 0, remoteUserVideoBuffers.small.pixelFormat);
647
+ this.rtcCloud.setRemoteVideoBuffer(userId, remoteUserVideoBuffers.small.buffer, remoteUserVideoBuffers.small.streamType, 0, 0, remoteUserVideoBuffers.small.pixelFormat, remoteUserVideoBuffers.small.id);
642
648
  remoteUserVideoBuffers.small.buffer = null;
643
649
  }
644
650
  remoteVideoBufferMap.delete(userId);
@@ -663,8 +669,9 @@ class TRTCCloud extends events_1.EventEmitter {
663
669
  });
664
670
  }
665
671
  if (screenVideoBuffer.buffer && screenVideoBuffer.userId === userId) {
666
- this.rtcCloud.setSubVideoBuffer(userId, screenVideoBuffer.buffer, screenVideoBuffer.streamType, 0, 0, screenVideoBuffer.pixelFormat);
672
+ this.rtcCloud.setSubVideoBuffer(userId, screenVideoBuffer.buffer, screenVideoBuffer.streamType, 0, 0, screenVideoBuffer.pixelFormat, screenVideoBuffer.id);
667
673
  screenVideoBuffer.buffer = null;
674
+ screenVideoBuffer.id = 0;
668
675
  screenVideoBuffer.userId = '';
669
676
  }
670
677
  }
@@ -1101,10 +1108,11 @@ class TRTCCloud extends events_1.EventEmitter {
1101
1108
  screenVideoBuffer.userId = '';
1102
1109
  screenVideoBuffer.streamType = this.screenCaptureStreamType;
1103
1110
  screenVideoBuffer.buffer = (0, util_1.allocBuffer)(DEFAULT_VIDEO_WIDTH * DEFAULT_VIDEO_HEIGHT * this.pixelLength, screenVideoBuffer.userId, screenVideoBuffer.streamType);
1111
+ screenVideoBuffer.id = (0, util_1.generateUniqueId)();
1104
1112
  screenVideoBuffer.pixelFormat = this.pixelformate;
1105
1113
  screenVideoBuffer.width = DEFAULT_VIDEO_WIDTH;
1106
1114
  screenVideoBuffer.height = DEFAULT_VIDEO_HEIGHT;
1107
- this.rtcCloud.setSubVideoBuffer('', screenVideoBuffer.buffer, screenVideoBuffer.streamType, screenVideoBuffer.width, screenVideoBuffer.height, screenVideoBuffer.pixelFormat);
1115
+ this.rtcCloud.setSubVideoBuffer('', screenVideoBuffer.buffer, screenVideoBuffer.streamType, screenVideoBuffer.width, screenVideoBuffer.height, screenVideoBuffer.pixelFormat, screenVideoBuffer.id);
1108
1116
  }
1109
1117
  this.fire('onScreenCaptureStarted');
1110
1118
  }
@@ -1135,8 +1143,9 @@ class TRTCCloud extends events_1.EventEmitter {
1135
1143
  handleOnScreenCaptureStopped(reason) {
1136
1144
  if (this.isScreenCapturing) {
1137
1145
  if (screenVideoBuffer.buffer) {
1138
- this.rtcCloud.setSubVideoBuffer('', screenVideoBuffer.buffer, screenVideoBuffer.streamType, 0, 0, screenVideoBuffer.pixelFormat);
1146
+ this.rtcCloud.setSubVideoBuffer('', screenVideoBuffer.buffer, screenVideoBuffer.streamType, 0, 0, screenVideoBuffer.pixelFormat, screenVideoBuffer.id);
1139
1147
  screenVideoBuffer.buffer = null;
1148
+ screenVideoBuffer.id = 0;
1140
1149
  }
1141
1150
  this.isScreenCapturing = false;
1142
1151
  }
@@ -1282,19 +1291,21 @@ class TRTCCloud extends events_1.EventEmitter {
1282
1291
  if (streamType === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig && remoteUserVideoBuffers.big) {
1283
1292
  if (remoteUserVideoBuffers.big.width !== width || remoteUserVideoBuffers.big.height !== height) {
1284
1293
  remoteUserVideoBuffers.big.buffer = (0, util_1.allocBuffer)(width * height * this.pixelLength, userId, streamType);
1294
+ remoteUserVideoBuffers.big.id = (0, util_1.generateUniqueId)();
1285
1295
  remoteUserVideoBuffers.big.width = width;
1286
1296
  remoteUserVideoBuffers.big.height = height;
1287
1297
  remoteUserVideoBuffers.big.pixelFormat = this.pixelformate;
1288
- this.rtcCloud.setRemoteVideoBuffer(userId, remoteUserVideoBuffers.big.buffer, streamType, width, height, remoteUserVideoBuffers.big.pixelFormat);
1298
+ this.rtcCloud.setRemoteVideoBuffer(userId, remoteUserVideoBuffers.big.buffer, streamType, width, height, remoteUserVideoBuffers.big.pixelFormat, remoteUserVideoBuffers.big.id);
1289
1299
  }
1290
1300
  }
1291
1301
  else if (streamType === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSmall && remoteUserVideoBuffers.small) {
1292
1302
  if (remoteUserVideoBuffers.small.width !== width || remoteUserVideoBuffers.small.height !== height) {
1293
1303
  remoteUserVideoBuffers.small.buffer = (0, util_1.allocBuffer)(width * height * this.pixelLength, userId, streamType);
1304
+ remoteUserVideoBuffers.small.id = (0, util_1.generateUniqueId)();
1294
1305
  remoteUserVideoBuffers.small.width = width;
1295
1306
  remoteUserVideoBuffers.small.height = height;
1296
1307
  remoteUserVideoBuffers.small.pixelFormat = this.pixelformate;
1297
- this.rtcCloud.setRemoteVideoBuffer(userId, remoteUserVideoBuffers.small.buffer, streamType, width, height, remoteUserVideoBuffers.small.pixelFormat);
1308
+ this.rtcCloud.setRemoteVideoBuffer(userId, remoteUserVideoBuffers.small.buffer, streamType, width, height, remoteUserVideoBuffers.small.pixelFormat, remoteUserVideoBuffers.small.id);
1298
1309
  }
1299
1310
  }
1300
1311
  }
@@ -1306,10 +1317,11 @@ class TRTCCloud extends events_1.EventEmitter {
1306
1317
  // 远端用户屏幕分享
1307
1318
  if (screenVideoBuffer.width !== width || screenVideoBuffer.height !== height) {
1308
1319
  screenVideoBuffer.buffer = (0, util_1.allocBuffer)(width * height * this.pixelLength, userId, streamType);
1320
+ screenVideoBuffer.id = (0, util_1.generateUniqueId)();
1309
1321
  screenVideoBuffer.width = width;
1310
1322
  screenVideoBuffer.height = height;
1311
1323
  screenVideoBuffer.pixelFormat = this.pixelformate;
1312
- this.rtcCloud.setSubVideoBuffer(userId, screenVideoBuffer.buffer, streamType, width, height, screenVideoBuffer.pixelFormat);
1324
+ this.rtcCloud.setSubVideoBuffer(userId, screenVideoBuffer.buffer, streamType, width, height, screenVideoBuffer.pixelFormat, screenVideoBuffer.id);
1313
1325
  }
1314
1326
  }
1315
1327
  }
@@ -1319,10 +1331,11 @@ class TRTCCloud extends events_1.EventEmitter {
1319
1331
  // 本地屏幕分享
1320
1332
  if (screenVideoBuffer.width !== width || screenVideoBuffer.height !== height) {
1321
1333
  screenVideoBuffer.buffer = (0, util_1.allocBuffer)(width * height * this.pixelLength, screenVideoBuffer.userId, streamType);
1334
+ screenVideoBuffer.id = (0, util_1.generateUniqueId)();
1322
1335
  screenVideoBuffer.width = width;
1323
1336
  screenVideoBuffer.height = height;
1324
1337
  screenVideoBuffer.pixelFormat = this.pixelformate;
1325
- this.rtcCloud.setSubVideoBuffer('', screenVideoBuffer.buffer, screenVideoBuffer.streamType, width, height, screenVideoBuffer.pixelFormat);
1338
+ this.rtcCloud.setSubVideoBuffer('', screenVideoBuffer.buffer, screenVideoBuffer.streamType, width, height, screenVideoBuffer.pixelFormat, screenVideoBuffer.id);
1326
1339
  }
1327
1340
  }
1328
1341
  else {
@@ -1330,20 +1343,22 @@ class TRTCCloud extends events_1.EventEmitter {
1330
1343
  // 摄像头检测
1331
1344
  if (cameraTestVideoBuffer.width !== width || cameraTestVideoBuffer.height !== height) {
1332
1345
  cameraTestVideoBuffer.buffer = (0, util_1.allocBuffer)(width * height * this.pixelLength, cameraTestVideoBuffer.userId, streamType);
1346
+ cameraTestVideoBuffer.id = (0, util_1.generateUniqueId)();
1333
1347
  cameraTestVideoBuffer.width = width;
1334
1348
  cameraTestVideoBuffer.height = height;
1335
1349
  cameraTestVideoBuffer.pixelFormat = this.pixelformate;
1336
- this.rtcCloud.setCameraTestVideoBuffer(cameraTestVideoBuffer.buffer, width, height, cameraTestVideoBuffer.pixelFormat);
1350
+ this.rtcCloud.setCameraTestVideoBuffer(cameraTestVideoBuffer.buffer, width, height, cameraTestVideoBuffer.pixelFormat, cameraTestVideoBuffer.id);
1337
1351
  }
1338
1352
  }
1339
1353
  else {
1340
1354
  // 本地摄像头
1341
1355
  if (localVideoBuffer.width !== width || localVideoBuffer.height !== height) {
1342
1356
  localVideoBuffer.buffer = (0, util_1.allocBuffer)(width * height * this.pixelLength, localVideoBuffer.userId, streamType);
1357
+ localVideoBuffer.id = (0, util_1.generateUniqueId)();
1343
1358
  localVideoBuffer.width = width;
1344
1359
  localVideoBuffer.height = height;
1345
1360
  localVideoBuffer.pixelFormat = this.pixelformate;
1346
- this.rtcCloud.setLocalVideoBuffer(localVideoBuffer.buffer, width, height, localVideoBuffer.pixelFormat);
1361
+ this.rtcCloud.setLocalVideoBuffer(localVideoBuffer.buffer, width, height, localVideoBuffer.pixelFormat, localVideoBuffer.id);
1347
1362
  }
1348
1363
  }
1349
1364
  }
@@ -1419,27 +1434,30 @@ class TRTCCloud extends events_1.EventEmitter {
1419
1434
  });
1420
1435
  remoteVideoBufferMap.forEach((value, key) => {
1421
1436
  if (value.big) {
1422
- this.rtcCloud.setRemoteVideoBuffer(key, value.big.buffer, value.big.streamType, 0, 0, value.big.pixelFormat);
1437
+ this.rtcCloud.setRemoteVideoBuffer(key, value.big.buffer, value.big.streamType, 0, 0, value.big.pixelFormat, value.big.id);
1423
1438
  value.big.buffer = null;
1424
1439
  }
1425
1440
  if (value.small) {
1426
- this.rtcCloud.setRemoteVideoBuffer(key, value.small.buffer, value.small.streamType, 0, 0, value.small.pixelFormat);
1441
+ this.rtcCloud.setRemoteVideoBuffer(key, value.small.buffer, value.small.streamType, 0, 0, value.small.pixelFormat, value.small.id);
1427
1442
  value.small.buffer = null;
1428
1443
  }
1429
1444
  });
1430
1445
  remoteVideoBufferMap.clear();
1431
1446
  if (localVideoBuffer.buffer) {
1432
- this.rtcCloud.setLocalVideoBuffer(localVideoBuffer.buffer, 0, 0, localVideoBuffer.pixelFormat);
1447
+ this.rtcCloud.setLocalVideoBuffer(localVideoBuffer.buffer, 0, 0, localVideoBuffer.pixelFormat, localVideoBuffer.id);
1433
1448
  localVideoBuffer.buffer = null;
1449
+ localVideoBuffer.id = 0;
1434
1450
  }
1435
1451
  if (screenVideoBuffer.buffer) {
1436
- this.rtcCloud.setSubVideoBuffer(screenVideoBuffer.userId, screenVideoBuffer.buffer, screenVideoBuffer.streamType, 0, 0, screenVideoBuffer.pixelFormat);
1452
+ this.rtcCloud.setSubVideoBuffer(screenVideoBuffer.userId, screenVideoBuffer.buffer, screenVideoBuffer.streamType, 0, 0, screenVideoBuffer.pixelFormat, screenVideoBuffer.id);
1437
1453
  screenVideoBuffer.buffer = null;
1454
+ screenVideoBuffer.id = 0;
1438
1455
  screenVideoBuffer.userId = '';
1439
1456
  }
1440
1457
  if (cameraTestVideoBuffer.buffer) {
1441
- this.rtcCloud.setCameraTestVideoBuffer(cameraTestVideoBuffer.buffer, 0, 0, cameraTestVideoBuffer.pixelFormat);
1458
+ this.rtcCloud.setCameraTestVideoBuffer(cameraTestVideoBuffer.buffer, 0, 0, cameraTestVideoBuffer.pixelFormat, cameraTestVideoBuffer.id);
1442
1459
  cameraTestVideoBuffer.buffer = null;
1460
+ cameraTestVideoBuffer.id = 0;
1443
1461
  }
1444
1462
  this.rtcCloud.exitRoom();
1445
1463
  }
@@ -1728,10 +1746,11 @@ class TRTCCloud extends events_1.EventEmitter {
1728
1746
  if (!localVideoBuffer.buffer) {
1729
1747
  localVideoBuffer.streamType = trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig;
1730
1748
  localVideoBuffer.buffer = (0, util_1.allocBuffer)(DEFAULT_VIDEO_WIDTH * DEFAULT_VIDEO_HEIGHT * this.pixelLength, localVideoBuffer.userId, localVideoBuffer.streamType);
1749
+ localVideoBuffer.id = (0, util_1.generateUniqueId)();
1731
1750
  localVideoBuffer.pixelFormat = this.pixelformate;
1732
1751
  localVideoBuffer.width = DEFAULT_VIDEO_WIDTH;
1733
1752
  localVideoBuffer.height = DEFAULT_VIDEO_HEIGHT;
1734
- this.rtcCloud.setLocalVideoBuffer(localVideoBuffer.buffer, localVideoBuffer.width, localVideoBuffer.height, localVideoBuffer.pixelFormat);
1753
+ this.rtcCloud.setLocalVideoBuffer(localVideoBuffer.buffer, localVideoBuffer.width, localVideoBuffer.height, localVideoBuffer.pixelFormat, localVideoBuffer.id);
1735
1754
  }
1736
1755
  this.rtcCloud.startLocalPreview();
1737
1756
  this.addLocalVideoRenderCallback();
@@ -1751,12 +1770,39 @@ class TRTCCloud extends events_1.EventEmitter {
1751
1770
  return !('' === item.uid && item.type === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig);
1752
1771
  });
1753
1772
  if (localVideoBuffer.buffer) {
1754
- this.rtcCloud.setLocalVideoBuffer(localVideoBuffer.buffer, 0, 0, localVideoBuffer.pixelFormat);
1773
+ this.rtcCloud.setLocalVideoBuffer(localVideoBuffer.buffer, 0, 0, localVideoBuffer.pixelFormat, localVideoBuffer.id);
1755
1774
  localVideoBuffer.buffer = null;
1775
+ localVideoBuffer.id = 0;
1756
1776
  }
1757
1777
  }
1758
1778
  /**
1759
- * 3.3 暂停/恢复发布本地的视频流
1779
+ * 3.3 修改本地摄像头预览的 HTML 元素
1780
+ *
1781
+ * 本接口用于切换显示区域的交互场景中,修改本地摄像头预览的 HTML 元素。
1782
+ *
1783
+ * 注意:必须在调用 [startLocalPreview()]{@link TRTCCloud#startLocalPreview} 接口开启本地摄像头采集后,调用本接口才会生效。
1784
+ * - 如果用户调用 `startLocalPreview(view)` 接口开启了摄像头采集,则通过此接口可以修改摄像头采集视频渲染的 HTML 元素。
1785
+ * - 如果用户调用 `startLocalPreview(null)` 接口开启了摄像头采集,但未开启本地预览,支持调用此接口开启预览。
1786
+ *
1787
+ * @param {HTMLElement|null} view - 接收本地摄像头采集视频渲染的 HTML 元素,传入 `null` 结束本地摄像头采集视频的预览。
1788
+ * - 传入的 HTML 元素必须是块元素,比如:`div`
1789
+ */
1790
+ updateLocalView(view) {
1791
+ let key = this.getKey('local_video', trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig);
1792
+ if (view !== null && view instanceof HTMLElement) {
1793
+ this._initRender(key, view);
1794
+ }
1795
+ else if (view === null) {
1796
+ if (this.streams.has(String(key))) {
1797
+ this._destroyRender(key, null);
1798
+ }
1799
+ }
1800
+ else {
1801
+ console.error('trtc:updateLocalView() called with wrong parameter', view);
1802
+ }
1803
+ }
1804
+ /**
1805
+ * 3.4 暂停/恢复发布本地的视频流
1760
1806
  *
1761
1807
  * 该接口可以暂停(或恢复)发布本地的视频画面,暂停之后,同一房间中的其他用户将无法继续看到自己画面。
1762
1808
  * 该接口在指定 TRTCVideoStreamTypeBig 时等效于 start/stopLocalPreview 这两个接口,但具有更好的响应速度。
@@ -1776,7 +1822,7 @@ class TRTCCloud extends events_1.EventEmitter {
1776
1822
  this.rtcCloud.muteLocalVideo(newStreamType, mute);
1777
1823
  }
1778
1824
  /**
1779
- * 3.4 开始显示远端视频画面
1825
+ * 3.5 开始显示远端视频画面
1780
1826
  *
1781
1827
  * 在收到 SDK 的 onUserVideoAvailable(userId, 1) 通知时,可以获知该远程用户开启了视频,
1782
1828
  * 此后调用 startRemoteView(userId) 接口加载该用户的远程画面时,可以用 loading 动画优化加载过程中的等待体验。
@@ -1806,6 +1852,7 @@ class TRTCCloud extends events_1.EventEmitter {
1806
1852
  const videoBufferInfo = {
1807
1853
  userId: userId,
1808
1854
  buffer: (0, util_1.allocBuffer)(DEFAULT_VIDEO_WIDTH * DEFAULT_VIDEO_HEIGHT * this.pixelLength, userId, streamType),
1855
+ id: (0, util_1.generateUniqueId)(),
1809
1856
  streamType: streamType,
1810
1857
  width: DEFAULT_VIDEO_WIDTH,
1811
1858
  height: DEFAULT_VIDEO_HEIGHT,
@@ -1821,16 +1868,16 @@ class TRTCCloud extends events_1.EventEmitter {
1821
1868
  else if (streamType === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSmall) {
1822
1869
  remoteVideoBufferMap.set(userId, { small: videoBufferInfo });
1823
1870
  }
1824
- this.rtcCloud.setRemoteVideoBuffer(userId, videoBufferInfo.buffer, videoBufferInfo.streamType, videoBufferInfo.width, videoBufferInfo.height, videoBufferInfo.pixelFormat);
1871
+ this.rtcCloud.setRemoteVideoBuffer(userId, videoBufferInfo.buffer, videoBufferInfo.streamType, videoBufferInfo.width, videoBufferInfo.height, videoBufferInfo.pixelFormat, videoBufferInfo.id);
1825
1872
  }
1826
1873
  else {
1827
1874
  if (streamType === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig && !remoteUserVideoBuffers.big) {
1828
1875
  remoteUserVideoBuffers.big = videoBufferInfo;
1829
- this.rtcCloud.setRemoteVideoBuffer(userId, videoBufferInfo.buffer, videoBufferInfo.streamType, videoBufferInfo.width, videoBufferInfo.height, videoBufferInfo.pixelFormat);
1876
+ this.rtcCloud.setRemoteVideoBuffer(userId, videoBufferInfo.buffer, videoBufferInfo.streamType, videoBufferInfo.width, videoBufferInfo.height, videoBufferInfo.pixelFormat, videoBufferInfo.id);
1830
1877
  }
1831
1878
  else if (streamType === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSmall && !remoteUserVideoBuffers.small) {
1832
1879
  remoteUserVideoBuffers.small = videoBufferInfo;
1833
- this.rtcCloud.setRemoteVideoBuffer(userId, videoBufferInfo.buffer, videoBufferInfo.streamType, videoBufferInfo.width, videoBufferInfo.height, videoBufferInfo.pixelFormat);
1880
+ this.rtcCloud.setRemoteVideoBuffer(userId, videoBufferInfo.buffer, videoBufferInfo.streamType, videoBufferInfo.width, videoBufferInfo.height, videoBufferInfo.pixelFormat, videoBufferInfo.id);
1834
1881
  }
1835
1882
  }
1836
1883
  }
@@ -1839,7 +1886,7 @@ class TRTCCloud extends events_1.EventEmitter {
1839
1886
  // Buffer 为 null 时才新建,否则只能在 handleVideoSizeChange 事件中重新申请 Buffer
1840
1887
  if (!screenVideoBuffer.buffer) {
1841
1888
  Object.assign(screenVideoBuffer, videoBufferInfo);
1842
- this.rtcCloud.setSubVideoBuffer(screenVideoBuffer.userId, screenVideoBuffer.buffer, screenVideoBuffer.streamType, screenVideoBuffer.width, screenVideoBuffer.height, screenVideoBuffer.pixelFormat);
1889
+ this.rtcCloud.setSubVideoBuffer(screenVideoBuffer.userId, screenVideoBuffer.buffer, screenVideoBuffer.streamType, screenVideoBuffer.width, screenVideoBuffer.height, screenVideoBuffer.pixelFormat, screenVideoBuffer.id);
1843
1890
  }
1844
1891
  }
1845
1892
  this.addRemoteVideoRenderCallback(userId);
@@ -1850,7 +1897,7 @@ class TRTCCloud extends events_1.EventEmitter {
1850
1897
  }
1851
1898
  }
1852
1899
  /**
1853
- * 3.5 停止显示远端视频画面,同时不再拉取该远端用户的视频数据流
1900
+ * 3.6 停止显示远端视频画面,同时不再拉取该远端用户的视频数据流
1854
1901
  *
1855
1902
  * 调用此接口后,SDK 会停止接收该用户的远程视频流,同时会清理相关的视频显示资源。
1856
1903
  *
@@ -1867,12 +1914,12 @@ class TRTCCloud extends events_1.EventEmitter {
1867
1914
  const remoteUserVideoBuffers = remoteVideoBufferMap.get(userId);
1868
1915
  if (remoteUserVideoBuffers && streamType !== trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSub) {
1869
1916
  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);
1917
+ this.rtcCloud.setRemoteVideoBuffer(userId, remoteUserVideoBuffers.big.buffer, remoteUserVideoBuffers.big.streamType, 0, 0, remoteUserVideoBuffers.big.pixelFormat, remoteUserVideoBuffers.big.id);
1871
1918
  remoteUserVideoBuffers.big.buffer = null;
1872
1919
  remoteUserVideoBuffers.big = undefined;
1873
1920
  }
1874
1921
  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);
1922
+ this.rtcCloud.setRemoteVideoBuffer(userId, remoteUserVideoBuffers.small.buffer, remoteUserVideoBuffers.small.streamType, 0, 0, remoteUserVideoBuffers.small.pixelFormat, remoteUserVideoBuffers.small.id);
1876
1923
  remoteUserVideoBuffers.small.buffer = null;
1877
1924
  remoteUserVideoBuffers.small = undefined;
1878
1925
  }
@@ -1881,13 +1928,50 @@ class TRTCCloud extends events_1.EventEmitter {
1881
1928
  }
1882
1929
  }
1883
1930
  else if (screenVideoBuffer.userId === userId && screenVideoBuffer.streamType === streamType) {
1884
- this.rtcCloud.setSubVideoBuffer(userId, screenVideoBuffer.buffer, screenVideoBuffer.streamType, 0, 0, screenVideoBuffer.pixelFormat);
1931
+ this.rtcCloud.setSubVideoBuffer(userId, screenVideoBuffer.buffer, screenVideoBuffer.streamType, 0, 0, screenVideoBuffer.pixelFormat, screenVideoBuffer.id);
1885
1932
  screenVideoBuffer.buffer = null;
1933
+ screenVideoBuffer.id = 0;
1886
1934
  screenVideoBuffer.userId = '';
1887
1935
  }
1888
1936
  }
1889
1937
  /**
1890
- * 3.6 停止显示所有远端视频画面,同时不再拉取该远端用户的视频数据流
1938
+ * 3.7 修改远端视频渲染的 HTML 元素
1939
+ *
1940
+ * 本接口用于切换显示区域的交互场景中,修改远端视频渲染的 HTML 元素。
1941
+ *
1942
+ * 注意:必须调用 [startRemoteView()]{@link TRTCCloud#startRemoteView} 订阅了远端视频流之后,调用此接口才会生效。
1943
+ *
1944
+ * @param {String} userId - 远端视频流的用户 ID
1945
+ * @param {HTMLElement|null} view - 接受远端视频流渲染的 HTML 元素,传入 null 结束远端视频的渲染
1946
+ * - 传入的 HTML 元素必须时块元素,例如:div
1947
+ * @param {TRTCVideoStreamType} streamType - 视频流类型
1948
+ *
1949
+ */
1950
+ updateRemoteView(userId, view, streamType) {
1951
+ if (streamType === undefined) {
1952
+ streamType = this.priorRemoteVideoStreamType;
1953
+ }
1954
+ let bindStreamType = streamType;
1955
+ if (bindStreamType === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSmall) {
1956
+ // 如果拉取小流, 绑定 render 时也采用大流, 防止大小流切换后无法找到对应 render 进行渲染
1957
+ // 这里的逻辑和 _onRenderFrame 里, 获取 render 是不论小流还是大流, 都采用大流取获取 render 有关
1958
+ bindStreamType = trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig;
1959
+ }
1960
+ const key = this.getKey(userId, bindStreamType);
1961
+ if (view !== null && view instanceof HTMLElement) {
1962
+ this._initRender(key, view);
1963
+ }
1964
+ else if (view === null) {
1965
+ if (this.streams.has(String(key))) {
1966
+ this._destroyRender(key, null);
1967
+ }
1968
+ }
1969
+ else {
1970
+ console.error('trtc:updateRemoteView() called with wrong view parameter', view);
1971
+ }
1972
+ }
1973
+ /**
1974
+ * 3.8 停止显示所有远端视频画面,同时不再拉取该远端用户的视频数据流
1891
1975
  *
1892
1976
  * 注意:如果有屏幕分享的画面在显示,则屏幕分享的画面也会一并被关闭。
1893
1977
  *
@@ -1901,23 +1985,24 @@ class TRTCCloud extends events_1.EventEmitter {
1901
1985
  this.rtcCloud.stopAllRemoteView();
1902
1986
  remoteVideoBufferMap.forEach((value, key) => {
1903
1987
  if (value.big) {
1904
- this.rtcCloud.setRemoteVideoBuffer(key, value.big.buffer, value.big.streamType, 0, 0, value.big.pixelFormat);
1988
+ this.rtcCloud.setRemoteVideoBuffer(key, value.big.buffer, value.big.streamType, 0, 0, value.big.pixelFormat, value.big.id);
1905
1989
  value.big.buffer = null;
1906
1990
  }
1907
1991
  if (value.small) {
1908
- this.rtcCloud.setRemoteVideoBuffer(key, value.small.buffer, value.small.streamType, 0, 0, value.small.pixelFormat);
1992
+ this.rtcCloud.setRemoteVideoBuffer(key, value.small.buffer, value.small.streamType, 0, 0, value.small.pixelFormat, value.small.id);
1909
1993
  value.small.buffer = null;
1910
1994
  }
1911
1995
  });
1912
1996
  remoteVideoBufferMap.clear();
1913
1997
  if (screenVideoBuffer.buffer && !this.isScreenCapturing) {
1914
- this.rtcCloud.setSubVideoBuffer(screenVideoBuffer.userId, screenVideoBuffer.buffer, screenVideoBuffer.streamType, 0, 0, screenVideoBuffer.pixelFormat);
1998
+ this.rtcCloud.setSubVideoBuffer(screenVideoBuffer.userId, screenVideoBuffer.buffer, screenVideoBuffer.streamType, 0, 0, screenVideoBuffer.pixelFormat, screenVideoBuffer.id);
1915
1999
  screenVideoBuffer.buffer = null;
2000
+ screenVideoBuffer.id = 0;
1916
2001
  screenVideoBuffer.userId = '';
1917
2002
  }
1918
2003
  }
1919
2004
  /**
1920
- * 3.7 暂停接收指定的远端视频流
2005
+ * 3.9 暂停接收指定的远端视频流
1921
2006
  *
1922
2007
  * 该接口仅停止接收远程用户的视频流,但并不释放显示资源,所以视频画面会冻屏在 mute 前的最后一帧。
1923
2008
  *
@@ -1933,7 +2018,7 @@ class TRTCCloud extends events_1.EventEmitter {
1933
2018
  this.rtcCloud.muteRemoteVideoStream(userId, newStreamType, mute);
1934
2019
  }
1935
2020
  /**
1936
- * 3.8 停止接收所有远端视频流
2021
+ * 3.10 停止接收所有远端视频流
1937
2022
  *
1938
2023
  * @param {Boolean} mute - 是否停止接收
1939
2024
  */
@@ -1941,7 +2026,7 @@ class TRTCCloud extends events_1.EventEmitter {
1941
2026
  this.rtcCloud.muteAllRemoteVideoStreams(mute);
1942
2027
  }
1943
2028
  /**
1944
- * 3.9 设置视频编码器相关参数
2029
+ * 3.11 设置视频编码器相关参数
1945
2030
  *
1946
2031
  * 该设置决定了远端用户看到的画面质量(同时也是云端录制出的视频文件的画面质量)
1947
2032
  *
@@ -1963,7 +2048,7 @@ class TRTCCloud extends events_1.EventEmitter {
1963
2048
  }
1964
2049
  }
1965
2050
  /**
1966
- * 3.10 设置网络流控相关参数
2051
+ * 3.12 设置网络流控相关参数
1967
2052
  *
1968
2053
  * 该设置决定了 SDK 在各种网络环境下的调控策略(例如弱网下是“保清晰”还是“保流畅”)
1969
2054
  *
@@ -1984,7 +2069,7 @@ class TRTCCloud extends events_1.EventEmitter {
1984
2069
  }
1985
2070
  }
1986
2071
  /**
1987
- * 3.11 设置本地图像(主流)的渲染参数
2072
+ * 3.13 设置本地图像(主流)的渲染参数
1988
2073
  *
1989
2074
  * @param {TRTCRenderParams} params - 本地图像的参数
1990
2075
  * @param {TRTCVideoRotation} params.rotation - 视频画面旋转方向
@@ -1999,7 +2084,7 @@ class TRTCCloud extends events_1.EventEmitter {
1999
2084
  this.rtcCloud.setLocalRenderParams(params.rotation, params.fillMode, params.mirrorType);
2000
2085
  }
2001
2086
  /**
2002
- * 3.12 废弃接口: 设置本地图像的渲染模式
2087
+ * 3.14 废弃接口: 设置本地图像的渲染模式
2003
2088
  *
2004
2089
  * @deprecated 从 TRTCSDK 8.0 后该接口已被废弃,请使用 setLocalRenderParams 接口替代。
2005
2090
  * @param {TRTCVideoFillMode} mode - 填充(画面可能会被拉伸裁剪)或适应(画面可能会有黑边),默认值:TRTCVideoFillMode_Fit
@@ -2007,18 +2092,15 @@ class TRTCCloud extends events_1.EventEmitter {
2007
2092
  * - TRTCVideoFillMode_Fit: 图像长边填满屏幕,短边区域会被填充黑色,但画面的内容肯定是完整的。
2008
2093
  */
2009
2094
  setLocalViewFillMode(mode) {
2095
+ this.localFillMode = mode;
2010
2096
  const key = this.getKey('local_video', trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig);
2011
2097
  if (this.streams.has(key)) {
2012
2098
  const renderer = this.streams.get(key);
2013
- this.localFillMode = mode;
2014
2099
  renderer.setContentMode(mode);
2015
2100
  }
2016
- else {
2017
- console.warn('trtc:api setLocalViewFillMode failed. the local stream does not exist.');
2018
- }
2019
2101
  }
2020
2102
  /**
2021
- * 3.13 设置远端画面的渲染模式
2103
+ * 3.15 设置远端画面的渲染模式
2022
2104
  *
2023
2105
  * @param {String} userId - 用户 ID
2024
2106
  * @param {TRTCVideoStreamType} streamType - 视频流类型
@@ -2043,7 +2125,7 @@ class TRTCCloud extends events_1.EventEmitter {
2043
2125
  this.rtcCloud.setRemoteRenderParams(userId, streamType, params.rotation, params.fillMode, params.mirrorType);
2044
2126
  }
2045
2127
  /**
2046
- * 3.14 废弃接口: 设置远端图像的渲染模式
2128
+ * 3.16 废弃接口: 设置远端图像的渲染模式
2047
2129
  *
2048
2130
  * @deprecated 从 TRTCSDK 8.0 后该接口已被废弃,请使用 setRemoteRenderParams 接口替代。
2049
2131
  * @param {String} userId - 用户 ID
@@ -2052,18 +2134,16 @@ class TRTCCloud extends events_1.EventEmitter {
2052
2134
  * - TRTCVideoFillMode_Fit: 图像长边填满屏幕,短边区域会被填充黑色,但画面的内容肯定是完整的。
2053
2135
  */
2054
2136
  setRemoteViewFillMode(userId, mode) {
2055
- let key = this.getKey(userId, trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig);
2137
+ const key = this.getKey(userId, trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig);
2138
+ this.remoteFillModeMap.set(key, mode);
2139
+ this.remoteMainStreamFillMode = mode;
2056
2140
  if (this.streams.has(key)) {
2057
- this.remoteMainStreamFillMode = mode;
2058
2141
  const renderer = this.streams.get(key);
2059
2142
  renderer.setContentMode(mode);
2060
2143
  }
2061
- else {
2062
- console.error('trtc:api setRemoteViewFillMode failed. the remote stream does not exist.');
2063
- }
2064
2144
  }
2065
2145
  /**
2066
- * 3.15 废弃接口: 设置本地图像的顺时针旋转角度
2146
+ * 3.17 废弃接口: 设置本地图像的顺时针旋转角度
2067
2147
  *
2068
2148
  * @deprecated 从 TRTCSDK 8.0 后该接口已被废弃,请使用 setLocalRenderParams 接口替代。
2069
2149
  * @param {TRTCVideoRotation} rotation - 支持 TRTCVideoRotation90 、 TRTCVideoRotation180 、 TRTCVideoRotation270 旋转角度,默认值:TRTCVideoRotation0
@@ -2081,7 +2161,7 @@ class TRTCCloud extends events_1.EventEmitter {
2081
2161
  this.setLocalRenderParams(params);
2082
2162
  }
2083
2163
  /**
2084
- * 3.16 废弃接口: 设置远端图像的顺时针旋转角度
2164
+ * 3.17 废弃接口: 设置远端图像的顺时针旋转角度
2085
2165
  *
2086
2166
  * @deprecated 从 TRTCSDK 8.0 后该接口已被废弃,请使用 setRemoteRenderParams 接口替代。
2087
2167
  * @param {String} userId - 用户 ID
@@ -2101,7 +2181,7 @@ class TRTCCloud extends events_1.EventEmitter {
2101
2181
  this.setRemoteRenderParams(userId, streamType, params);
2102
2182
  }
2103
2183
  /**
2104
- * 3.17 设置视频编码输出的(也就是远端用户观看到的,以及服务器录制下来的)画面方向
2184
+ * 3.19 设置视频编码输出的(也就是远端用户观看到的,以及服务器录制下来的)画面方向
2105
2185
  *
2106
2186
  * @param {TRTCVideoRotation} rotation - 目前支持 TRTCVideoRotation0 和 TRTCVideoRotation180 两个旋转角度,默认值:TRTCVideoRotation0
2107
2187
  * - TRTCVideoRotation0 : 顺时针旋转0度
@@ -2111,7 +2191,7 @@ class TRTCCloud extends events_1.EventEmitter {
2111
2191
  this.rtcCloud.setVideoEncoderRotation(rotation);
2112
2192
  }
2113
2193
  /**
2114
- * 3.18 废弃接口: 设置本地摄像头预览画面的镜像模式
2194
+ * 3.20 废弃接口: 设置本地摄像头预览画面的镜像模式
2115
2195
  *
2116
2196
  * @deprecated 从 TRTCSDK 8.0 后该接口已被废弃,请使用 setLocalRenderParams 接口替代。
2117
2197
  * @param {Boolean} mirror - 镜像模式, windows 默认值: false(非镜像模式), mac 默认值: true(镜像模式)
@@ -2125,7 +2205,7 @@ class TRTCCloud extends events_1.EventEmitter {
2125
2205
  this.setLocalRenderParams(params);
2126
2206
  }
2127
2207
  /**
2128
- * 3.19 设置编码器输出的画面镜像模式
2208
+ * 3.21 设置编码器输出的画面镜像模式
2129
2209
  *
2130
2210
  * 该接口不改变本地摄像头的预览画面,但会改变另一端用户看到的(以及服务器录制的)画面效果。
2131
2211
  *
@@ -2135,7 +2215,7 @@ class TRTCCloud extends events_1.EventEmitter {
2135
2215
  this.rtcCloud.setVideoEncoderMirror(mirror);
2136
2216
  }
2137
2217
  /**
2138
- * 3.20 开启大小画面双路编码模式
2218
+ * 3.22 开启大小画面双路编码模式
2139
2219
  *
2140
2220
  * 如果当前用户是房间中的主要角色(例如主播、老师、主持人等),并且使用 PC 或者 Mac 环境,可以开启该模式。
2141
2221
  * 开启该模式后,当前用户会同时输出【高清】和【低清】两路视频流(但只有一路音频流)。
@@ -2164,7 +2244,7 @@ class TRTCCloud extends events_1.EventEmitter {
2164
2244
  }
2165
2245
  }
2166
2246
  /**
2167
- * 3.21 选定观看指定 userId 的大画面或小画面
2247
+ * 3.23 选定观看指定 userId 的大画面或小画面
2168
2248
  *
2169
2249
  * 此功能需要该 userId 通过 enableSmallVideoStream 提前开启双路编码模式。
2170
2250
  * 如果该 userId 没有开启双路编码模式,则此操作无效。
@@ -2180,6 +2260,7 @@ class TRTCCloud extends events_1.EventEmitter {
2180
2260
  const videoBufferInfo = {
2181
2261
  userId: userId,
2182
2262
  buffer: (0, util_1.allocBuffer)(DEFAULT_VIDEO_WIDTH * DEFAULT_VIDEO_HEIGHT * this.pixelLength, userId, streamType),
2263
+ id: (0, util_1.generateUniqueId)(),
2183
2264
  streamType: streamType,
2184
2265
  width: DEFAULT_VIDEO_WIDTH,
2185
2266
  height: DEFAULT_VIDEO_HEIGHT,
@@ -2187,20 +2268,21 @@ class TRTCCloud extends events_1.EventEmitter {
2187
2268
  };
2188
2269
  if (streamType === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig && !remoteUserVideoBuffers.big) {
2189
2270
  remoteUserVideoBuffers.big = videoBufferInfo;
2190
- this.rtcCloud.setRemoteVideoBuffer(userId, videoBufferInfo.buffer, videoBufferInfo.streamType, videoBufferInfo.width, videoBufferInfo.height, videoBufferInfo.pixelFormat);
2271
+ this.rtcCloud.setRemoteVideoBuffer(userId, videoBufferInfo.buffer, videoBufferInfo.streamType, videoBufferInfo.width, videoBufferInfo.height, videoBufferInfo.pixelFormat, videoBufferInfo.id);
2191
2272
  }
2192
2273
  else if (streamType === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSmall && !remoteUserVideoBuffers.small) {
2193
2274
  remoteUserVideoBuffers.small = videoBufferInfo;
2194
- this.rtcCloud.setRemoteVideoBuffer(userId, videoBufferInfo.buffer, videoBufferInfo.streamType, videoBufferInfo.width, videoBufferInfo.height, videoBufferInfo.pixelFormat);
2275
+ this.rtcCloud.setRemoteVideoBuffer(userId, videoBufferInfo.buffer, videoBufferInfo.streamType, videoBufferInfo.width, videoBufferInfo.height, videoBufferInfo.pixelFormat, videoBufferInfo.id);
2195
2276
  }
2196
2277
  else {
2197
2278
  videoBufferInfo.buffer = null;
2279
+ videoBufferInfo.id = 0;
2198
2280
  }
2199
2281
  }
2200
2282
  this.rtcCloud.setRemoteVideoStreamType(userId, streamType);
2201
2283
  }
2202
2284
  /**
2203
- * 3.22 视频画面截图
2285
+ * 3.24 视频画面截图
2204
2286
  *
2205
2287
  * 调用截图接口后,您会收到来自 TRTCCallback 中的 [onSnapshotComplete]{@link TRTCCallback#event:onSnapshotComplete} 回调:
2206
2288
  * 截取本地、远程主路和远端辅流的视频画面,并通过 HBITMAP 对象返回给您。
@@ -2213,7 +2295,7 @@ class TRTCCloud extends events_1.EventEmitter {
2213
2295
  this.rtcCloud.snapshotVideo(userId, type);
2214
2296
  }
2215
2297
  /**
2216
- * 3.23 废弃接口: 设定观看方优先选择的视频质量
2298
+ * 3.25 废弃接口: 设定观看方优先选择的视频质量
2217
2299
  *
2218
2300
  * 低端设备推荐优先选择低清晰度的小画面。
2219
2301
  * 如果对方没有开启双路视频模式,则此操作无效。
@@ -2228,7 +2310,7 @@ class TRTCCloud extends events_1.EventEmitter {
2228
2310
  this.priorRemoteVideoStreamType = type;
2229
2311
  }
2230
2312
  /**
2231
- * 3.24 开启本地媒体录制
2313
+ * 3.26 开启本地媒体录制
2232
2314
  *
2233
2315
  * 开启后把直播过程中的音视和视频内容录制到本地的一个文件中。
2234
2316
  *
@@ -2254,7 +2336,7 @@ class TRTCCloud extends events_1.EventEmitter {
2254
2336
  }
2255
2337
  ;
2256
2338
  /**
2257
- * 3.25 停止本地媒体录制
2339
+ * 3.27 停止本地媒体录制
2258
2340
  *
2259
2341
  * 如果录制任务在退出房间前尚未通过本接口停止,则退出房间后录音任务会自动被停止。
2260
2342
  */
@@ -2710,14 +2792,12 @@ class TRTCCloud extends events_1.EventEmitter {
2710
2792
  */
2711
2793
  setRemoteSubStreamViewFillMode(userId, mode) {
2712
2794
  let key = this.getKey(userId, trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSub);
2795
+ this.remoteFillModeMap.set(key, mode);
2796
+ this.remoteSubStreamFillMode = mode;
2713
2797
  if (this.streams.has(key)) {
2714
2798
  const renderer = this.streams.get(key);
2715
- this.remoteSubStreamFillMode = mode;
2716
2799
  renderer.setContentMode(mode);
2717
2800
  }
2718
- else {
2719
- console.error('trtc:api setRemoteSubStreamViewFillMode failed. the remote sub stream does not exist.');
2720
- }
2721
2801
  }
2722
2802
  /**
2723
2803
  * 8.4 废弃接口: 设置辅路画面(TRTCVideoStreamTypeSub,一般用于屏幕分享)的顺时针旋转角度
@@ -3568,14 +3648,20 @@ class TRTCCloud extends events_1.EventEmitter {
3568
3648
  cameraTestVideoBuffer.streamType = streamType;
3569
3649
  cameraTestVideoBuffer.pixelFormat = this.pixelformate;
3570
3650
  cameraTestVideoBuffer.buffer = (0, util_1.allocBuffer)(DEFAULT_VIDEO_WIDTH * DEFAULT_VIDEO_HEIGHT * this.pixelLength, cameraTestVideoBuffer.userId, streamType);
3651
+ cameraTestVideoBuffer.id = (0, util_1.generateUniqueId)();
3571
3652
  cameraTestVideoBuffer.width = DEFAULT_VIDEO_WIDTH;
3572
3653
  cameraTestVideoBuffer.height = DEFAULT_VIDEO_HEIGHT;
3573
- this.rtcCloud.setCameraTestVideoBuffer(cameraTestVideoBuffer.buffer, cameraTestVideoBuffer.width, cameraTestVideoBuffer.height, cameraTestVideoBuffer.pixelFormat);
3654
+ this.rtcCloud.setCameraTestVideoBuffer(cameraTestVideoBuffer.buffer, cameraTestVideoBuffer.width, cameraTestVideoBuffer.height, cameraTestVideoBuffer.pixelFormat, cameraTestVideoBuffer.id);
3574
3655
  }
3575
- this.rtcCloud.startCameraDeviceTest((id, type, width, height, timestamp, rotation, valid) => {
3656
+ this.rtcCloud.startCameraDeviceTest((id, type, width, height, timestamp, rotation, valid, bufferId) => {
3576
3657
  if (this.enableRenderFrame) {
3577
3658
  if (valid === 1) {
3578
- this._onRenderFrame(id, type, width, height, timestamp, rotation, cameraTestVideoBuffer.buffer);
3659
+ if (cameraTestVideoBuffer.id === bufferId) {
3660
+ this._onRenderFrame(id, type, width, height, timestamp, rotation, cameraTestVideoBuffer.buffer);
3661
+ }
3662
+ else {
3663
+ console.log('trtc:camera video buffer reallocated');
3664
+ }
3579
3665
  }
3580
3666
  else {
3581
3667
  this.handleVideoSizeChange(id, type, width, height);
@@ -3598,8 +3684,9 @@ class TRTCCloud extends events_1.EventEmitter {
3598
3684
  return !('' === item.uid && item.type === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig);
3599
3685
  });
3600
3686
  if (cameraTestVideoBuffer.buffer) {
3601
- this.rtcCloud.setCameraTestVideoBuffer(cameraTestVideoBuffer.buffer, 0, 0, cameraTestVideoBuffer.pixelFormat);
3687
+ this.rtcCloud.setCameraTestVideoBuffer(cameraTestVideoBuffer.buffer, 0, 0, cameraTestVideoBuffer.pixelFormat, cameraTestVideoBuffer.id);
3602
3688
  cameraTestVideoBuffer.buffer = null;
3689
+ cameraTestVideoBuffer.id = 0;
3603
3690
  }
3604
3691
  }
3605
3692
  /**
@@ -3725,15 +3812,18 @@ class TRTCCloud extends events_1.EventEmitter {
3725
3812
  /////////////////////////////////////////////////////////////////////////////////
3726
3813
  ///------------------------内部方法-----------------------------
3727
3814
  addLocalVideoRenderCallback() {
3728
- this.rtcCloud.addLocalVideoRenderCallback((id, type, width, height, timestamp, rotation, valid) => {
3815
+ this.rtcCloud.addLocalVideoRenderCallback((id, type, width, height, timestamp, rotation, valid, bufferId) => {
3729
3816
  if (this.enableRenderFrame) {
3730
3817
  if (valid === 1) {
3731
- if (this.isScreenCapturing && this.screenCaptureStreamType === type) {
3818
+ if (this.isScreenCapturing && this.screenCaptureStreamType === type && screenVideoBuffer.id === bufferId) {
3732
3819
  this._onRenderFrame(id, type, width, height, timestamp, rotation, screenVideoBuffer.buffer);
3733
3820
  }
3734
- else {
3821
+ else if (localVideoBuffer.id === bufferId) {
3735
3822
  this._onRenderFrame(id, type, width, height, timestamp, rotation, localVideoBuffer.buffer);
3736
3823
  }
3824
+ else {
3825
+ console.log(`trtc: ${id} ${type} video buffer reallocated`);
3826
+ }
3737
3827
  }
3738
3828
  else {
3739
3829
  this.handleVideoSizeChange(id, type, width, height);
@@ -3742,21 +3832,26 @@ class TRTCCloud extends events_1.EventEmitter {
3742
3832
  }, this.pixelformate);
3743
3833
  }
3744
3834
  addRemoteVideoRenderCallback(userId) {
3745
- this.rtcCloud.addRemoteVideoRenderCallback(userId, (id, type, width, height, timestamp, rotation, valid) => {
3835
+ this.rtcCloud.addRemoteVideoRenderCallback(userId, (id, type, width, height, timestamp, rotation, valid, bufferId) => {
3746
3836
  if (this.enableRenderFrame) {
3747
3837
  if (valid === 1) {
3748
3838
  const remoteUserVideoBuffers = remoteVideoBufferMap.get(id);
3749
3839
  if (remoteUserVideoBuffers && type !== trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSub) {
3750
- if (type === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig && remoteUserVideoBuffers.big) {
3840
+ // 大流和小流
3841
+ if (type === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig && remoteUserVideoBuffers.big && remoteUserVideoBuffers.big.id === bufferId) {
3751
3842
  this._onRenderFrame(id, type, width, height, timestamp, rotation, remoteUserVideoBuffers.big.buffer);
3752
3843
  }
3753
- else if (type === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSmall && remoteUserVideoBuffers.small) {
3844
+ else if (type === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSmall && remoteUserVideoBuffers.small && remoteUserVideoBuffers.small.id === bufferId) {
3754
3845
  this._onRenderFrame(id, type, width, height, timestamp, rotation, remoteUserVideoBuffers.small.buffer);
3755
3846
  }
3756
3847
  }
3757
- else {
3848
+ else if (screenVideoBuffer.id === bufferId) {
3849
+ // 辅流
3758
3850
  this._onRenderFrame(id, type, width, height, timestamp, rotation, screenVideoBuffer.buffer);
3759
3851
  }
3852
+ else {
3853
+ console.log(`trtc: ${id} ${type} video buffer reallocated`);
3854
+ }
3760
3855
  }
3761
3856
  else {
3762
3857
  this.handleVideoSizeChange(id, type, width, height);
@@ -3765,7 +3860,7 @@ class TRTCCloud extends events_1.EventEmitter {
3765
3860
  }, this.pixelformate);
3766
3861
  }
3767
3862
  //----------------------------------//
3768
- // Render
3863
+ // Render Mode API
3769
3864
  //----------------------------------//
3770
3865
  /**
3771
3866
  * 废弃接口:选择绘制的模式 (webgl/yuvcanvs/)
@@ -3780,7 +3875,7 @@ class TRTCCloud extends events_1.EventEmitter {
3780
3875
  console.warn('trtc:setRenderMode() interface is deprecated and do not need any more');
3781
3876
  }
3782
3877
  //----------------------------------//
3783
- // plugin apis
3878
+ // plugin API -- start
3784
3879
  //----------------------------------//
3785
3880
  initPluginManager() {
3786
3881
  this.rtcCloud.initializePluginManager();
@@ -3822,7 +3917,10 @@ class TRTCCloud extends events_1.EventEmitter {
3822
3917
  this.rtcCloud.setPluginCallback(pluginCb);
3823
3918
  }
3824
3919
  //----------------------------------//
3825
- // vod apis
3920
+ // plugin API -- end
3921
+ //----------------------------------//
3922
+ //----------------------------------//
3923
+ // Vod API -- start
3826
3924
  //----------------------------------//
3827
3925
  createVodPlayer(mediaFilePath, repeat) {
3828
3926
  const nativeVodPlayer = this.rtcCloud.createVodPlayer(mediaFilePath, repeat);
@@ -3840,6 +3938,9 @@ class TRTCCloud extends events_1.EventEmitter {
3840
3938
  this.rtcCloud.destroyVodPlayer(vodPlayer.key);
3841
3939
  delete this.vodPlayers[vodPlayer.key];
3842
3940
  }
3941
+ //----------------------------------//
3942
+ // Vod API -- end
3943
+ //----------------------------------//
3843
3944
  getKey(uid, type) {
3844
3945
  return String(uid) + '_' + String(type);
3845
3946
  }
@@ -3956,6 +4057,12 @@ class TRTCCloud extends events_1.EventEmitter {
3956
4057
  // 只有本地视频, 才设置 local fill mode
3957
4058
  this.setLocalViewFillMode(this.localFillMode);
3958
4059
  }
4060
+ else if (this.remoteFillModeMap.has(key)) {
4061
+ const fillMode = this.remoteFillModeMap.get(key);
4062
+ if (fillMode !== undefined) {
4063
+ renderer.setContentMode(fillMode);
4064
+ }
4065
+ }
3959
4066
  }
3960
4067
  _destroyRender(key, onFailure) {
3961
4068
  if (!this.streams.has(String(key))) {
@@ -773,6 +773,7 @@ export interface PluginInfo {
773
773
  getParameter: (paramKey: string) => string;
774
774
  }
775
775
  export interface VideoBufferInfo {
776
+ id: number;
776
777
  userId: string;
777
778
  buffer: Buffer | null;
778
779
  streamType: TRTCVideoStreamType;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trtc-electron-sdk",
3
- "version": "10.7.404",
3
+ "version": "10.7.405-beta.0",
4
4
  "description": "trtc electron sdk",
5
5
  "main": "./liteav/trtc.js",
6
6
  "types": "./liteav/trtc.d.ts",