trtc-electron-sdk 10.3.8-beta.12 → 10.3.8-beta.13
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/Render/util.d.ts +1 -0
- package/liteav/Render/util.js +5 -1
- package/liteav/trtc.d.ts +29 -2
- package/liteav/trtc.js +236 -69
- package/liteav/trtc_define.d.ts +1 -0
- package/package.json +1 -1
package/liteav/Render/util.d.ts
CHANGED
package/liteav/Render/util.js
CHANGED
|
@@ -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
|
*
|
|
@@ -135,3 +135,7 @@ function allocBuffer(length, userId, streamType) {
|
|
|
135
135
|
return null;
|
|
136
136
|
}
|
|
137
137
|
exports.allocBuffer = allocBuffer;
|
|
138
|
+
function generateUniqueId() {
|
|
139
|
+
return Date.now() * 1000 + Math.floor(Math.random() * 1000);
|
|
140
|
+
}
|
|
141
|
+
exports.generateUniqueId = generateUniqueId;
|
package/liteav/trtc.d.ts
CHANGED
|
@@ -866,6 +866,19 @@ declare class TRTCCloud extends EventEmitter {
|
|
|
866
866
|
* 3.2 停止本地摄像头采集和预览
|
|
867
867
|
*/
|
|
868
868
|
stopLocalPreview(): void;
|
|
869
|
+
/**
|
|
870
|
+
* 3.3 修改本地摄像头预览的 HTML 元素
|
|
871
|
+
*
|
|
872
|
+
* 本接口用于切换显示区域的交互场景中,修改本地摄像头预览的 HTML 元素。
|
|
873
|
+
*
|
|
874
|
+
* 注意:必须在调用 [startLocalPreview()]{@link TRTCCloud#startLocalPreview} 接口开启本地摄像头采集后,调用本接口才会生效。
|
|
875
|
+
* - 如果用户调用 `startLocalPreview(view)` 接口开启了摄像头采集,则通过此接口可以修改摄像头采集视频渲染的 HTML 元素。
|
|
876
|
+
* - 如果用户调用 `startLocalPreview(null)` 接口开启了摄像头采集,但未开启本地预览,支持调用此接口开启预览。
|
|
877
|
+
*
|
|
878
|
+
* @param {HTMLElement|null} view - 接收本地摄像头采集视频渲染的 HTML 元素,传入 `null` 结束本地摄像头采集视频的预览。
|
|
879
|
+
* - 传入的 HTML 元素必须是块元素,比如:`div`
|
|
880
|
+
*/
|
|
881
|
+
updateLocalView(view: HTMLElement | null): void;
|
|
869
882
|
/**
|
|
870
883
|
* 3.3 暂停/恢复发布本地的视频流
|
|
871
884
|
*
|
|
@@ -901,6 +914,20 @@ declare class TRTCCloud extends EventEmitter {
|
|
|
901
914
|
* @param {TRTCVideoStreamType} streamType - 视频流类型
|
|
902
915
|
*/
|
|
903
916
|
stopRemoteView(userId: string, streamType?: TRTCVideoStreamType): void;
|
|
917
|
+
/**
|
|
918
|
+
* 3.7 修改远端视频渲染的 HTML 元素
|
|
919
|
+
*
|
|
920
|
+
* 本接口用于切换显示区域的交互场景中,修改远端视频渲染的 HTML 元素。
|
|
921
|
+
*
|
|
922
|
+
* 注意:必须调用 [startRemoteView()]{@link TRTCCloud#startRemoteView} 订阅了远端视频流之后,调用此接口才会生效。
|
|
923
|
+
*
|
|
924
|
+
* @param {String} userId - 远端视频流的用户 ID
|
|
925
|
+
* @param {HTMLElement|null} view - 接受远端视频流渲染的 HTML 元素,传入 null 结束远端视频的渲染
|
|
926
|
+
* - 传入的 HTML 元素必须时块元素,例如:div
|
|
927
|
+
* @param {TRTCVideoStreamType} streamType - 视频流类型
|
|
928
|
+
*
|
|
929
|
+
*/
|
|
930
|
+
updateRemoteView(userId: string, view: HTMLElement | null, streamType: TRTCVideoStreamType): void;
|
|
904
931
|
/**
|
|
905
932
|
* 3.6 停止显示所有远端视频画面,同时不再拉取该远端用户的视频数据流
|
|
906
933
|
*
|
|
@@ -1067,11 +1094,11 @@ declare class TRTCCloud extends EventEmitter {
|
|
|
1067
1094
|
* 如果该 userId 没有开启双路编码模式,则此操作无效。
|
|
1068
1095
|
*
|
|
1069
1096
|
* @param {String} userId - 用户 ID
|
|
1070
|
-
* @param {TRTCVideoStreamType}
|
|
1097
|
+
* @param {TRTCVideoStreamType} streamType - 视频流类型,即选择看大画面还是小画面,默认为 TRTCVideoStreamTypeBig
|
|
1071
1098
|
* - TRTCVideoStreamTypeBig : 大画面视频流
|
|
1072
1099
|
* - TRTCVideoStreamTypeSmall: 小画面视频流
|
|
1073
1100
|
*/
|
|
1074
|
-
setRemoteVideoStreamType(userId: string,
|
|
1101
|
+
setRemoteVideoStreamType(userId: string, streamType: TRTCVideoStreamType): void;
|
|
1075
1102
|
/**
|
|
1076
1103
|
* 3.22 视频画面截图
|
|
1077
1104
|
*
|
package/liteav/trtc.js
CHANGED
|
@@ -19,9 +19,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
20
|
const events_1 = require("events");
|
|
21
21
|
const Render_1 = __importDefault(require("./Render"));
|
|
22
|
-
const util_1 = require("./Render/util");
|
|
23
22
|
// @ts-ignore
|
|
24
23
|
const yuv_buffer_1 = __importDefault(require("yuv-buffer"));
|
|
24
|
+
const util_1 = require("./Render/util");
|
|
25
25
|
// @ts-ignore
|
|
26
26
|
const YCbCr_1 = __importDefault(require("yuv-canvas/src/YCbCr"));
|
|
27
27
|
const trtc_define_1 = require("./trtc_define");
|
|
@@ -36,6 +36,7 @@ const CAMERA_DEVICE_TEST_ID = 'camera_device_test';
|
|
|
36
36
|
const DEFAULT_VIDEO_WIDTH = 8;
|
|
37
37
|
const DEFAULT_VIDEO_HEIGHT = 8;
|
|
38
38
|
const localVideoBuffer = {
|
|
39
|
+
id: 0,
|
|
39
40
|
userId: '',
|
|
40
41
|
buffer: null,
|
|
41
42
|
streamType: trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig,
|
|
@@ -44,6 +45,7 @@ const localVideoBuffer = {
|
|
|
44
45
|
pixelFormat: trtc_define_1.TRTCVideoPixelFormat.TRTCVideoPixelFormat_I420,
|
|
45
46
|
};
|
|
46
47
|
const screenVideoBuffer = {
|
|
48
|
+
id: 0,
|
|
47
49
|
userId: '',
|
|
48
50
|
buffer: null,
|
|
49
51
|
streamType: trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSub,
|
|
@@ -52,6 +54,7 @@ const screenVideoBuffer = {
|
|
|
52
54
|
pixelFormat: trtc_define_1.TRTCVideoPixelFormat.TRTCVideoPixelFormat_I420,
|
|
53
55
|
};
|
|
54
56
|
const cameraTestVideoBuffer = {
|
|
57
|
+
id: 0,
|
|
55
58
|
userId: CAMERA_DEVICE_TEST_ID,
|
|
56
59
|
buffer: null,
|
|
57
60
|
streamType: trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig,
|
|
@@ -622,10 +625,16 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
622
625
|
return !(userId === item.uid && item.type !== trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSub);
|
|
623
626
|
});
|
|
624
627
|
}
|
|
625
|
-
const
|
|
626
|
-
if (
|
|
627
|
-
|
|
628
|
-
|
|
628
|
+
const remoteUserVideoBuffers = remoteVideoBufferMap.get(userId);
|
|
629
|
+
if (remoteUserVideoBuffers) {
|
|
630
|
+
if (remoteUserVideoBuffers.big) {
|
|
631
|
+
this.rtcCloud.setRemoteVideoBuffer(userId, remoteUserVideoBuffers.big.buffer, remoteUserVideoBuffers.big.streamType, 0, 0, remoteUserVideoBuffers.big.pixelFormat, remoteUserVideoBuffers.big.id);
|
|
632
|
+
remoteUserVideoBuffers.big.buffer = null;
|
|
633
|
+
}
|
|
634
|
+
if (remoteUserVideoBuffers.small) {
|
|
635
|
+
this.rtcCloud.setRemoteVideoBuffer(userId, remoteUserVideoBuffers.small.buffer, remoteUserVideoBuffers.small.streamType, 0, 0, remoteUserVideoBuffers.small.pixelFormat, remoteUserVideoBuffers.small.id);
|
|
636
|
+
remoteUserVideoBuffers.small.buffer = null;
|
|
637
|
+
}
|
|
629
638
|
remoteVideoBufferMap.delete(userId);
|
|
630
639
|
}
|
|
631
640
|
}
|
|
@@ -648,8 +657,9 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
648
657
|
});
|
|
649
658
|
}
|
|
650
659
|
if (screenVideoBuffer.buffer && screenVideoBuffer.userId === userId) {
|
|
651
|
-
this.rtcCloud.setSubVideoBuffer(userId, screenVideoBuffer.buffer, screenVideoBuffer.streamType, 0, 0, screenVideoBuffer.pixelFormat);
|
|
660
|
+
this.rtcCloud.setSubVideoBuffer(userId, screenVideoBuffer.buffer, screenVideoBuffer.streamType, 0, 0, screenVideoBuffer.pixelFormat, screenVideoBuffer.id);
|
|
652
661
|
screenVideoBuffer.buffer = null;
|
|
662
|
+
screenVideoBuffer.id = 0;
|
|
653
663
|
screenVideoBuffer.userId = '';
|
|
654
664
|
}
|
|
655
665
|
}
|
|
@@ -1087,10 +1097,11 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
1087
1097
|
screenVideoBuffer.userId = '';
|
|
1088
1098
|
screenVideoBuffer.streamType = this.screenCaptureStreamType;
|
|
1089
1099
|
screenVideoBuffer.buffer = (0, util_1.allocBuffer)(DEFAULT_VIDEO_WIDTH * DEFAULT_VIDEO_HEIGHT * this.pixelLength, screenVideoBuffer.userId, screenVideoBuffer.streamType);
|
|
1100
|
+
screenVideoBuffer.id = (0, util_1.generateUniqueId)();
|
|
1090
1101
|
screenVideoBuffer.pixelFormat = this.pixelformate;
|
|
1091
1102
|
screenVideoBuffer.width = DEFAULT_VIDEO_WIDTH;
|
|
1092
1103
|
screenVideoBuffer.height = DEFAULT_VIDEO_HEIGHT;
|
|
1093
|
-
this.rtcCloud.setSubVideoBuffer('', screenVideoBuffer.buffer, screenVideoBuffer.streamType, screenVideoBuffer.width, screenVideoBuffer.height, screenVideoBuffer.pixelFormat);
|
|
1104
|
+
this.rtcCloud.setSubVideoBuffer('', screenVideoBuffer.buffer, screenVideoBuffer.streamType, screenVideoBuffer.width, screenVideoBuffer.height, screenVideoBuffer.pixelFormat, screenVideoBuffer.id);
|
|
1094
1105
|
console.debug('trtc:onScreenCaptureStarted alloc add screenVideoBuffer', screenVideoBuffer);
|
|
1095
1106
|
}
|
|
1096
1107
|
this.fire('onScreenCaptureStarted');
|
|
@@ -1123,8 +1134,9 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
1123
1134
|
console.debug('trtc:onScreenCaptureStopped', reason);
|
|
1124
1135
|
if (this.isScreenCapturing) {
|
|
1125
1136
|
if (screenVideoBuffer.buffer) {
|
|
1126
|
-
this.rtcCloud.setSubVideoBuffer('', screenVideoBuffer.buffer, screenVideoBuffer.streamType, 0, 0, screenVideoBuffer.pixelFormat);
|
|
1137
|
+
this.rtcCloud.setSubVideoBuffer('', screenVideoBuffer.buffer, screenVideoBuffer.streamType, 0, 0, screenVideoBuffer.pixelFormat, screenVideoBuffer.id);
|
|
1127
1138
|
screenVideoBuffer.buffer = null;
|
|
1139
|
+
screenVideoBuffer.id = 0;
|
|
1128
1140
|
console.debug('trtc:onScreenCaptureStopped delete screenVideoBuffer', screenVideoBuffer);
|
|
1129
1141
|
}
|
|
1130
1142
|
this.isScreenCapturing = false;
|
|
@@ -1222,14 +1234,27 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
1222
1234
|
console.debug('trtc:handleVideoSizeChange', userId, streamType, width, height);
|
|
1223
1235
|
if (userId && userId !== CAMERA_DEVICE_TEST_ID) {
|
|
1224
1236
|
if (streamType !== trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSub) {
|
|
1225
|
-
const
|
|
1226
|
-
if (
|
|
1227
|
-
if (
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1237
|
+
const remoteUserVideoBuffers = remoteVideoBufferMap.get(userId);
|
|
1238
|
+
if (remoteUserVideoBuffers) {
|
|
1239
|
+
if (streamType === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig && remoteUserVideoBuffers.big) {
|
|
1240
|
+
if (remoteUserVideoBuffers.big.width !== width || remoteUserVideoBuffers.big.height !== height) {
|
|
1241
|
+
remoteUserVideoBuffers.big.buffer = (0, util_1.allocBuffer)(width * height * this.pixelLength, userId, streamType);
|
|
1242
|
+
remoteUserVideoBuffers.big.id = (0, util_1.generateUniqueId)();
|
|
1243
|
+
remoteUserVideoBuffers.big.width = width;
|
|
1244
|
+
remoteUserVideoBuffers.big.height = height;
|
|
1245
|
+
remoteUserVideoBuffers.big.pixelFormat = this.pixelformate;
|
|
1246
|
+
this.rtcCloud.setRemoteVideoBuffer(userId, remoteUserVideoBuffers.big.buffer, streamType, width, height, remoteUserVideoBuffers.big.pixelFormat, remoteUserVideoBuffers.big.id);
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
else if (streamType === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSmall && remoteUserVideoBuffers.small) {
|
|
1250
|
+
if (remoteUserVideoBuffers.small.width !== width || remoteUserVideoBuffers.small.height !== height) {
|
|
1251
|
+
remoteUserVideoBuffers.small.buffer = (0, util_1.allocBuffer)(width * height * this.pixelLength, userId, streamType);
|
|
1252
|
+
remoteUserVideoBuffers.small.id = (0, util_1.generateUniqueId)();
|
|
1253
|
+
remoteUserVideoBuffers.small.width = width;
|
|
1254
|
+
remoteUserVideoBuffers.small.height = height;
|
|
1255
|
+
remoteUserVideoBuffers.small.pixelFormat = this.pixelformate;
|
|
1256
|
+
this.rtcCloud.setRemoteVideoBuffer(userId, remoteUserVideoBuffers.small.buffer, streamType, width, height, remoteUserVideoBuffers.small.pixelFormat, remoteUserVideoBuffers.small.id);
|
|
1257
|
+
}
|
|
1233
1258
|
}
|
|
1234
1259
|
}
|
|
1235
1260
|
else {
|
|
@@ -1240,10 +1265,11 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
1240
1265
|
// 远端用户屏幕分享
|
|
1241
1266
|
if (screenVideoBuffer.width !== width || screenVideoBuffer.height !== height) {
|
|
1242
1267
|
screenVideoBuffer.buffer = (0, util_1.allocBuffer)(width * height * this.pixelLength, userId, streamType);
|
|
1268
|
+
screenVideoBuffer.id = (0, util_1.generateUniqueId)();
|
|
1243
1269
|
screenVideoBuffer.width = width;
|
|
1244
1270
|
screenVideoBuffer.height = height;
|
|
1245
1271
|
screenVideoBuffer.pixelFormat = this.pixelformate;
|
|
1246
|
-
this.rtcCloud.setSubVideoBuffer(userId, screenVideoBuffer.buffer, streamType, width, height, screenVideoBuffer.pixelFormat);
|
|
1272
|
+
this.rtcCloud.setSubVideoBuffer(userId, screenVideoBuffer.buffer, streamType, width, height, screenVideoBuffer.pixelFormat, screenVideoBuffer.id);
|
|
1247
1273
|
}
|
|
1248
1274
|
}
|
|
1249
1275
|
}
|
|
@@ -1253,10 +1279,11 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
1253
1279
|
// 本地屏幕分享
|
|
1254
1280
|
if (screenVideoBuffer.width !== width || screenVideoBuffer.height !== height) {
|
|
1255
1281
|
screenVideoBuffer.buffer = (0, util_1.allocBuffer)(width * height * this.pixelLength, screenVideoBuffer.userId, streamType);
|
|
1282
|
+
screenVideoBuffer.id = (0, util_1.generateUniqueId)();
|
|
1256
1283
|
screenVideoBuffer.width = width;
|
|
1257
1284
|
screenVideoBuffer.height = height;
|
|
1258
1285
|
screenVideoBuffer.pixelFormat = this.pixelformate;
|
|
1259
|
-
this.rtcCloud.setSubVideoBuffer('', screenVideoBuffer.buffer, screenVideoBuffer.streamType, width, height, screenVideoBuffer.pixelFormat);
|
|
1286
|
+
this.rtcCloud.setSubVideoBuffer('', screenVideoBuffer.buffer, screenVideoBuffer.streamType, width, height, screenVideoBuffer.pixelFormat, screenVideoBuffer.id);
|
|
1260
1287
|
}
|
|
1261
1288
|
}
|
|
1262
1289
|
else {
|
|
@@ -1264,20 +1291,22 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
1264
1291
|
// 摄像头检测
|
|
1265
1292
|
if (cameraTestVideoBuffer.width !== width || cameraTestVideoBuffer.height !== height) {
|
|
1266
1293
|
cameraTestVideoBuffer.buffer = (0, util_1.allocBuffer)(width * height * this.pixelLength, cameraTestVideoBuffer.userId, streamType);
|
|
1294
|
+
cameraTestVideoBuffer.id = (0, util_1.generateUniqueId)();
|
|
1267
1295
|
cameraTestVideoBuffer.width = width;
|
|
1268
1296
|
cameraTestVideoBuffer.height = height;
|
|
1269
1297
|
cameraTestVideoBuffer.pixelFormat = this.pixelformate;
|
|
1270
|
-
this.rtcCloud.setCameraTestVideoBuffer(cameraTestVideoBuffer.buffer, width, height, cameraTestVideoBuffer.pixelFormat);
|
|
1298
|
+
this.rtcCloud.setCameraTestVideoBuffer(cameraTestVideoBuffer.buffer, width, height, cameraTestVideoBuffer.pixelFormat, cameraTestVideoBuffer.id);
|
|
1271
1299
|
}
|
|
1272
1300
|
}
|
|
1273
1301
|
else {
|
|
1274
1302
|
// 本地摄像头
|
|
1275
1303
|
if (localVideoBuffer.width !== width || localVideoBuffer.height !== height) {
|
|
1276
1304
|
localVideoBuffer.buffer = (0, util_1.allocBuffer)(width * height * this.pixelLength, localVideoBuffer.userId, streamType);
|
|
1305
|
+
localVideoBuffer.id = (0, util_1.generateUniqueId)();
|
|
1277
1306
|
localVideoBuffer.width = width;
|
|
1278
1307
|
localVideoBuffer.height = height;
|
|
1279
1308
|
localVideoBuffer.pixelFormat = this.pixelformate;
|
|
1280
|
-
this.rtcCloud.setLocalVideoBuffer(localVideoBuffer.buffer, width, height, localVideoBuffer.pixelFormat);
|
|
1309
|
+
this.rtcCloud.setLocalVideoBuffer(localVideoBuffer.buffer, width, height, localVideoBuffer.pixelFormat, localVideoBuffer.id);
|
|
1281
1310
|
}
|
|
1282
1311
|
}
|
|
1283
1312
|
}
|
|
@@ -1352,22 +1381,31 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
1352
1381
|
this._destroyRender(key, null);
|
|
1353
1382
|
});
|
|
1354
1383
|
remoteVideoBufferMap.forEach((value, key) => {
|
|
1355
|
-
|
|
1356
|
-
|
|
1384
|
+
if (value.big) {
|
|
1385
|
+
this.rtcCloud.setRemoteVideoBuffer(key, value.big.buffer, value.big.streamType, 0, 0, value.big.pixelFormat, value.big.id);
|
|
1386
|
+
value.big.buffer = null;
|
|
1387
|
+
}
|
|
1388
|
+
if (value.small) {
|
|
1389
|
+
this.rtcCloud.setRemoteVideoBuffer(key, value.small.buffer, value.small.streamType, 0, 0, value.small.pixelFormat, value.small.id);
|
|
1390
|
+
value.small.buffer = null;
|
|
1391
|
+
}
|
|
1357
1392
|
});
|
|
1358
1393
|
remoteVideoBufferMap.clear();
|
|
1359
1394
|
if (localVideoBuffer.buffer) {
|
|
1360
|
-
this.rtcCloud.setLocalVideoBuffer(localVideoBuffer.buffer, 0, 0, localVideoBuffer.pixelFormat);
|
|
1395
|
+
this.rtcCloud.setLocalVideoBuffer(localVideoBuffer.buffer, 0, 0, localVideoBuffer.pixelFormat, localVideoBuffer.id);
|
|
1361
1396
|
localVideoBuffer.buffer = null;
|
|
1397
|
+
localVideoBuffer.id = 0;
|
|
1362
1398
|
}
|
|
1363
1399
|
if (screenVideoBuffer.buffer) {
|
|
1364
|
-
this.rtcCloud.setSubVideoBuffer(screenVideoBuffer.userId, screenVideoBuffer.buffer, screenVideoBuffer.streamType, 0, 0, screenVideoBuffer.pixelFormat);
|
|
1400
|
+
this.rtcCloud.setSubVideoBuffer(screenVideoBuffer.userId, screenVideoBuffer.buffer, screenVideoBuffer.streamType, 0, 0, screenVideoBuffer.pixelFormat, screenVideoBuffer.id);
|
|
1365
1401
|
screenVideoBuffer.buffer = null;
|
|
1402
|
+
screenVideoBuffer.id = 0;
|
|
1366
1403
|
screenVideoBuffer.userId = '';
|
|
1367
1404
|
}
|
|
1368
1405
|
if (cameraTestVideoBuffer.buffer) {
|
|
1369
|
-
this.rtcCloud.setCameraTestVideoBuffer(cameraTestVideoBuffer.buffer, 0, 0, cameraTestVideoBuffer.pixelFormat);
|
|
1406
|
+
this.rtcCloud.setCameraTestVideoBuffer(cameraTestVideoBuffer.buffer, 0, 0, cameraTestVideoBuffer.pixelFormat, cameraTestVideoBuffer.id);
|
|
1370
1407
|
cameraTestVideoBuffer.buffer = null;
|
|
1408
|
+
cameraTestVideoBuffer.id = 0;
|
|
1371
1409
|
}
|
|
1372
1410
|
this.rtcCloud.exitRoom();
|
|
1373
1411
|
}
|
|
@@ -1652,10 +1690,11 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
1652
1690
|
if (!localVideoBuffer.buffer) {
|
|
1653
1691
|
localVideoBuffer.streamType = trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig;
|
|
1654
1692
|
localVideoBuffer.buffer = (0, util_1.allocBuffer)(DEFAULT_VIDEO_WIDTH * DEFAULT_VIDEO_HEIGHT * this.pixelLength, localVideoBuffer.userId, localVideoBuffer.streamType);
|
|
1693
|
+
localVideoBuffer.id = (0, util_1.generateUniqueId)();
|
|
1655
1694
|
localVideoBuffer.pixelFormat = this.pixelformate;
|
|
1656
1695
|
localVideoBuffer.width = DEFAULT_VIDEO_WIDTH;
|
|
1657
1696
|
localVideoBuffer.height = DEFAULT_VIDEO_HEIGHT;
|
|
1658
|
-
this.rtcCloud.setLocalVideoBuffer(localVideoBuffer.buffer, localVideoBuffer.width, localVideoBuffer.height, localVideoBuffer.pixelFormat);
|
|
1697
|
+
this.rtcCloud.setLocalVideoBuffer(localVideoBuffer.buffer, localVideoBuffer.width, localVideoBuffer.height, localVideoBuffer.pixelFormat, localVideoBuffer.id);
|
|
1659
1698
|
}
|
|
1660
1699
|
this.rtcCloud.startLocalPreview();
|
|
1661
1700
|
this.addLocalVideoRenderCallback();
|
|
@@ -1675,8 +1714,35 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
1675
1714
|
return !('' === item.uid && item.type === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig);
|
|
1676
1715
|
});
|
|
1677
1716
|
if (localVideoBuffer.buffer) {
|
|
1678
|
-
this.rtcCloud.setLocalVideoBuffer(localVideoBuffer.buffer, 0, 0, localVideoBuffer.pixelFormat);
|
|
1717
|
+
this.rtcCloud.setLocalVideoBuffer(localVideoBuffer.buffer, 0, 0, localVideoBuffer.pixelFormat, localVideoBuffer.id);
|
|
1679
1718
|
localVideoBuffer.buffer = null;
|
|
1719
|
+
localVideoBuffer.id = 0;
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
/**
|
|
1723
|
+
* 3.3 修改本地摄像头预览的 HTML 元素
|
|
1724
|
+
*
|
|
1725
|
+
* 本接口用于切换显示区域的交互场景中,修改本地摄像头预览的 HTML 元素。
|
|
1726
|
+
*
|
|
1727
|
+
* 注意:必须在调用 [startLocalPreview()]{@link TRTCCloud#startLocalPreview} 接口开启本地摄像头采集后,调用本接口才会生效。
|
|
1728
|
+
* - 如果用户调用 `startLocalPreview(view)` 接口开启了摄像头采集,则通过此接口可以修改摄像头采集视频渲染的 HTML 元素。
|
|
1729
|
+
* - 如果用户调用 `startLocalPreview(null)` 接口开启了摄像头采集,但未开启本地预览,支持调用此接口开启预览。
|
|
1730
|
+
*
|
|
1731
|
+
* @param {HTMLElement|null} view - 接收本地摄像头采集视频渲染的 HTML 元素,传入 `null` 结束本地摄像头采集视频的预览。
|
|
1732
|
+
* - 传入的 HTML 元素必须是块元素,比如:`div`
|
|
1733
|
+
*/
|
|
1734
|
+
updateLocalView(view) {
|
|
1735
|
+
let key = this.getKey('local_video', trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig);
|
|
1736
|
+
if (view !== null && view instanceof HTMLElement) {
|
|
1737
|
+
this._initRender(key, view);
|
|
1738
|
+
}
|
|
1739
|
+
else if (view === null) {
|
|
1740
|
+
if (this.streams.has(String(key))) {
|
|
1741
|
+
this._destroyRender(key, null);
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
else {
|
|
1745
|
+
console.error('trtc:updateLocalView() called with wrong parameter', view);
|
|
1680
1746
|
}
|
|
1681
1747
|
}
|
|
1682
1748
|
/**
|
|
@@ -1730,16 +1796,33 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
1730
1796
|
const videoBufferInfo = {
|
|
1731
1797
|
userId: userId,
|
|
1732
1798
|
buffer: (0, util_1.allocBuffer)(DEFAULT_VIDEO_WIDTH * DEFAULT_VIDEO_HEIGHT * this.pixelLength, userId, streamType),
|
|
1799
|
+
id: (0, util_1.generateUniqueId)(),
|
|
1733
1800
|
streamType: streamType,
|
|
1734
1801
|
width: DEFAULT_VIDEO_WIDTH,
|
|
1735
1802
|
height: DEFAULT_VIDEO_HEIGHT,
|
|
1736
1803
|
pixelFormat: this.pixelformate,
|
|
1737
1804
|
};
|
|
1738
1805
|
if (streamType !== trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSub) {
|
|
1739
|
-
|
|
1806
|
+
const remoteUserVideoBuffers = remoteVideoBufferMap.get(userId);
|
|
1807
|
+
if (!remoteUserVideoBuffers) {
|
|
1740
1808
|
// Buffer 不存在时才新建,否则只能在 handleVideoSizeChange 事件中重新申请 Buffer
|
|
1741
|
-
|
|
1742
|
-
|
|
1809
|
+
if (streamType === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig) {
|
|
1810
|
+
remoteVideoBufferMap.set(userId, { big: videoBufferInfo });
|
|
1811
|
+
}
|
|
1812
|
+
else if (streamType === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSmall) {
|
|
1813
|
+
remoteVideoBufferMap.set(userId, { small: videoBufferInfo });
|
|
1814
|
+
}
|
|
1815
|
+
this.rtcCloud.setRemoteVideoBuffer(userId, videoBufferInfo.buffer, videoBufferInfo.streamType, videoBufferInfo.width, videoBufferInfo.height, videoBufferInfo.pixelFormat, videoBufferInfo.id);
|
|
1816
|
+
}
|
|
1817
|
+
else {
|
|
1818
|
+
if (streamType === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig && !remoteUserVideoBuffers.big) {
|
|
1819
|
+
remoteUserVideoBuffers.big = videoBufferInfo;
|
|
1820
|
+
this.rtcCloud.setRemoteVideoBuffer(userId, videoBufferInfo.buffer, videoBufferInfo.streamType, videoBufferInfo.width, videoBufferInfo.height, videoBufferInfo.pixelFormat, videoBufferInfo.id);
|
|
1821
|
+
}
|
|
1822
|
+
else if (streamType === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSmall && !remoteUserVideoBuffers.small) {
|
|
1823
|
+
remoteUserVideoBuffers.small = videoBufferInfo;
|
|
1824
|
+
this.rtcCloud.setRemoteVideoBuffer(userId, videoBufferInfo.buffer, videoBufferInfo.streamType, videoBufferInfo.width, videoBufferInfo.height, videoBufferInfo.pixelFormat, videoBufferInfo.id);
|
|
1825
|
+
}
|
|
1743
1826
|
}
|
|
1744
1827
|
}
|
|
1745
1828
|
else {
|
|
@@ -1747,7 +1830,7 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
1747
1830
|
// Buffer 为 null 时才新建,否则只能在 handleVideoSizeChange 事件中重新申请 Buffer
|
|
1748
1831
|
if (!screenVideoBuffer.buffer) {
|
|
1749
1832
|
Object.assign(screenVideoBuffer, videoBufferInfo);
|
|
1750
|
-
this.rtcCloud.setSubVideoBuffer(screenVideoBuffer.userId, screenVideoBuffer.buffer, screenVideoBuffer.streamType, screenVideoBuffer.width, screenVideoBuffer.height, screenVideoBuffer.pixelFormat);
|
|
1833
|
+
this.rtcCloud.setSubVideoBuffer(screenVideoBuffer.userId, screenVideoBuffer.buffer, screenVideoBuffer.streamType, screenVideoBuffer.width, screenVideoBuffer.height, screenVideoBuffer.pixelFormat, screenVideoBuffer.id);
|
|
1751
1834
|
}
|
|
1752
1835
|
}
|
|
1753
1836
|
this.addRemoteVideoRenderCallback(userId);
|
|
@@ -1772,18 +1855,65 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
1772
1855
|
let key = this.getKey(userId, streamType);
|
|
1773
1856
|
this._destroyRender(key, null);
|
|
1774
1857
|
this.rtcCloud.stopRemoteView(userId, streamType);
|
|
1775
|
-
const
|
|
1776
|
-
if (
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1858
|
+
const remoteUserVideoBuffers = remoteVideoBufferMap.get(userId);
|
|
1859
|
+
if (remoteUserVideoBuffers && streamType !== trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSub) {
|
|
1860
|
+
if (streamType === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig && remoteUserVideoBuffers.big) {
|
|
1861
|
+
this.rtcCloud.setRemoteVideoBuffer(userId, remoteUserVideoBuffers.big.buffer, remoteUserVideoBuffers.big.streamType, 0, 0, remoteUserVideoBuffers.big.pixelFormat, remoteUserVideoBuffers.big.id);
|
|
1862
|
+
remoteUserVideoBuffers.big.buffer = null;
|
|
1863
|
+
remoteUserVideoBuffers.big = undefined;
|
|
1864
|
+
}
|
|
1865
|
+
else if (streamType === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSmall && remoteUserVideoBuffers.small) {
|
|
1866
|
+
this.rtcCloud.setRemoteVideoBuffer(userId, remoteUserVideoBuffers.small.buffer, remoteUserVideoBuffers.small.streamType, 0, 0, remoteUserVideoBuffers.small.pixelFormat, remoteUserVideoBuffers.small.id);
|
|
1867
|
+
remoteUserVideoBuffers.small.buffer = null;
|
|
1868
|
+
remoteUserVideoBuffers.small = undefined;
|
|
1869
|
+
}
|
|
1870
|
+
if (!remoteUserVideoBuffers.big && !remoteUserVideoBuffers.small) {
|
|
1871
|
+
remoteVideoBufferMap.delete(userId);
|
|
1872
|
+
}
|
|
1780
1873
|
}
|
|
1781
1874
|
else if (screenVideoBuffer.userId === userId && screenVideoBuffer.streamType === streamType) {
|
|
1782
|
-
this.rtcCloud.setSubVideoBuffer(userId, screenVideoBuffer.buffer, screenVideoBuffer.streamType, 0, 0, screenVideoBuffer.pixelFormat);
|
|
1875
|
+
this.rtcCloud.setSubVideoBuffer(userId, screenVideoBuffer.buffer, screenVideoBuffer.streamType, 0, 0, screenVideoBuffer.pixelFormat, screenVideoBuffer.id);
|
|
1783
1876
|
screenVideoBuffer.buffer = null;
|
|
1877
|
+
screenVideoBuffer.id = 0;
|
|
1784
1878
|
screenVideoBuffer.userId = '';
|
|
1785
1879
|
}
|
|
1786
1880
|
}
|
|
1881
|
+
/**
|
|
1882
|
+
* 3.7 修改远端视频渲染的 HTML 元素
|
|
1883
|
+
*
|
|
1884
|
+
* 本接口用于切换显示区域的交互场景中,修改远端视频渲染的 HTML 元素。
|
|
1885
|
+
*
|
|
1886
|
+
* 注意:必须调用 [startRemoteView()]{@link TRTCCloud#startRemoteView} 订阅了远端视频流之后,调用此接口才会生效。
|
|
1887
|
+
*
|
|
1888
|
+
* @param {String} userId - 远端视频流的用户 ID
|
|
1889
|
+
* @param {HTMLElement|null} view - 接受远端视频流渲染的 HTML 元素,传入 null 结束远端视频的渲染
|
|
1890
|
+
* - 传入的 HTML 元素必须时块元素,例如:div
|
|
1891
|
+
* @param {TRTCVideoStreamType} streamType - 视频流类型
|
|
1892
|
+
*
|
|
1893
|
+
*/
|
|
1894
|
+
updateRemoteView(userId, view, streamType) {
|
|
1895
|
+
if (streamType === undefined) {
|
|
1896
|
+
streamType = this.priorRemoteVideoStreamType;
|
|
1897
|
+
}
|
|
1898
|
+
let bindStreamType = streamType;
|
|
1899
|
+
if (bindStreamType === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSmall) {
|
|
1900
|
+
// 如果拉取小流, 绑定 render 时也采用大流, 防止大小流切换后无法找到对应 render 进行渲染
|
|
1901
|
+
// 这里的逻辑和 _onRenderFrame 里, 获取 render 是不论小流还是大流, 都采用大流取获取 render 有关
|
|
1902
|
+
bindStreamType = trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig;
|
|
1903
|
+
}
|
|
1904
|
+
const key = this.getKey(userId, bindStreamType);
|
|
1905
|
+
if (view !== null && view instanceof HTMLElement) {
|
|
1906
|
+
this._initRender(key, view);
|
|
1907
|
+
}
|
|
1908
|
+
else if (view === null) {
|
|
1909
|
+
if (this.streams.has(String(key))) {
|
|
1910
|
+
this._destroyRender(key, null);
|
|
1911
|
+
}
|
|
1912
|
+
}
|
|
1913
|
+
else {
|
|
1914
|
+
console.error('trtc:updateRemoteView() called with wrong view parameter', view);
|
|
1915
|
+
}
|
|
1916
|
+
}
|
|
1787
1917
|
/**
|
|
1788
1918
|
* 3.6 停止显示所有远端视频画面,同时不再拉取该远端用户的视频数据流
|
|
1789
1919
|
*
|
|
@@ -1798,13 +1928,20 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
1798
1928
|
});
|
|
1799
1929
|
this.rtcCloud.stopAllRemoteView();
|
|
1800
1930
|
remoteVideoBufferMap.forEach((value, key) => {
|
|
1801
|
-
|
|
1802
|
-
|
|
1931
|
+
if (value.big) {
|
|
1932
|
+
this.rtcCloud.setRemoteVideoBuffer(key, value.big.buffer, value.big.streamType, 0, 0, value.big.pixelFormat, value.big.id);
|
|
1933
|
+
value.big.buffer = null;
|
|
1934
|
+
}
|
|
1935
|
+
if (value.small) {
|
|
1936
|
+
this.rtcCloud.setRemoteVideoBuffer(key, value.small.buffer, value.small.streamType, 0, 0, value.small.pixelFormat, value.small.id);
|
|
1937
|
+
value.small.buffer = null;
|
|
1938
|
+
}
|
|
1803
1939
|
});
|
|
1804
1940
|
remoteVideoBufferMap.clear();
|
|
1805
1941
|
if (screenVideoBuffer.buffer && !this.isScreenCapturing) {
|
|
1806
|
-
this.rtcCloud.setSubVideoBuffer(screenVideoBuffer.userId, screenVideoBuffer.buffer, screenVideoBuffer.streamType, 0, 0, screenVideoBuffer.pixelFormat);
|
|
1942
|
+
this.rtcCloud.setSubVideoBuffer(screenVideoBuffer.userId, screenVideoBuffer.buffer, screenVideoBuffer.streamType, 0, 0, screenVideoBuffer.pixelFormat, screenVideoBuffer.id);
|
|
1807
1943
|
screenVideoBuffer.buffer = null;
|
|
1944
|
+
screenVideoBuffer.id = 0;
|
|
1808
1945
|
screenVideoBuffer.userId = '';
|
|
1809
1946
|
}
|
|
1810
1947
|
}
|
|
@@ -2062,12 +2199,36 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
2062
2199
|
* 如果该 userId 没有开启双路编码模式,则此操作无效。
|
|
2063
2200
|
*
|
|
2064
2201
|
* @param {String} userId - 用户 ID
|
|
2065
|
-
* @param {TRTCVideoStreamType}
|
|
2202
|
+
* @param {TRTCVideoStreamType} streamType - 视频流类型,即选择看大画面还是小画面,默认为 TRTCVideoStreamTypeBig
|
|
2066
2203
|
* - TRTCVideoStreamTypeBig : 大画面视频流
|
|
2067
2204
|
* - TRTCVideoStreamTypeSmall: 小画面视频流
|
|
2068
2205
|
*/
|
|
2069
|
-
setRemoteVideoStreamType(userId,
|
|
2070
|
-
|
|
2206
|
+
setRemoteVideoStreamType(userId, streamType) {
|
|
2207
|
+
const remoteUserVideoBuffers = remoteVideoBufferMap.get(userId);
|
|
2208
|
+
if (remoteUserVideoBuffers) {
|
|
2209
|
+
const videoBufferInfo = {
|
|
2210
|
+
userId: userId,
|
|
2211
|
+
buffer: (0, util_1.allocBuffer)(DEFAULT_VIDEO_WIDTH * DEFAULT_VIDEO_HEIGHT * this.pixelLength, userId, streamType),
|
|
2212
|
+
id: (0, util_1.generateUniqueId)(),
|
|
2213
|
+
streamType: streamType,
|
|
2214
|
+
width: DEFAULT_VIDEO_WIDTH,
|
|
2215
|
+
height: DEFAULT_VIDEO_HEIGHT,
|
|
2216
|
+
pixelFormat: this.pixelformate,
|
|
2217
|
+
};
|
|
2218
|
+
if (streamType === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig && !remoteUserVideoBuffers.big) {
|
|
2219
|
+
remoteUserVideoBuffers.big = videoBufferInfo;
|
|
2220
|
+
this.rtcCloud.setRemoteVideoBuffer(userId, videoBufferInfo.buffer, videoBufferInfo.streamType, videoBufferInfo.width, videoBufferInfo.height, videoBufferInfo.pixelFormat, videoBufferInfo.id);
|
|
2221
|
+
}
|
|
2222
|
+
else if (streamType === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSmall && !remoteUserVideoBuffers.small) {
|
|
2223
|
+
remoteUserVideoBuffers.small = videoBufferInfo;
|
|
2224
|
+
this.rtcCloud.setRemoteVideoBuffer(userId, videoBufferInfo.buffer, videoBufferInfo.streamType, videoBufferInfo.width, videoBufferInfo.height, videoBufferInfo.pixelFormat, videoBufferInfo.id);
|
|
2225
|
+
}
|
|
2226
|
+
else {
|
|
2227
|
+
videoBufferInfo.buffer = null;
|
|
2228
|
+
videoBufferInfo.id = 0;
|
|
2229
|
+
}
|
|
2230
|
+
}
|
|
2231
|
+
this.rtcCloud.setRemoteVideoStreamType(userId, streamType);
|
|
2071
2232
|
}
|
|
2072
2233
|
/**
|
|
2073
2234
|
* 3.22 视频画面截图
|
|
@@ -3325,14 +3486,20 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
3325
3486
|
cameraTestVideoBuffer.streamType = streamType;
|
|
3326
3487
|
cameraTestVideoBuffer.pixelFormat = this.pixelformate;
|
|
3327
3488
|
cameraTestVideoBuffer.buffer = (0, util_1.allocBuffer)(DEFAULT_VIDEO_WIDTH * DEFAULT_VIDEO_HEIGHT * this.pixelLength, cameraTestVideoBuffer.userId, streamType);
|
|
3489
|
+
cameraTestVideoBuffer.id = (0, util_1.generateUniqueId)();
|
|
3328
3490
|
cameraTestVideoBuffer.width = DEFAULT_VIDEO_WIDTH;
|
|
3329
3491
|
cameraTestVideoBuffer.height = DEFAULT_VIDEO_HEIGHT;
|
|
3330
|
-
this.rtcCloud.setCameraTestVideoBuffer(cameraTestVideoBuffer.buffer, cameraTestVideoBuffer.width, cameraTestVideoBuffer.height, cameraTestVideoBuffer.pixelFormat);
|
|
3492
|
+
this.rtcCloud.setCameraTestVideoBuffer(cameraTestVideoBuffer.buffer, cameraTestVideoBuffer.width, cameraTestVideoBuffer.height, cameraTestVideoBuffer.pixelFormat, cameraTestVideoBuffer.id);
|
|
3331
3493
|
}
|
|
3332
|
-
this.rtcCloud.startCameraDeviceTest((id, type, width, height, timestamp, rotation, valid) => {
|
|
3494
|
+
this.rtcCloud.startCameraDeviceTest((id, type, width, height, timestamp, rotation, valid, bufferId) => {
|
|
3333
3495
|
if (this.enableRenderFrame) {
|
|
3334
|
-
if (valid === 1
|
|
3335
|
-
|
|
3496
|
+
if (valid === 1) {
|
|
3497
|
+
if (cameraTestVideoBuffer.id === bufferId) {
|
|
3498
|
+
this._onRenderFrame(id, type, width, height, timestamp, rotation, cameraTestVideoBuffer.buffer);
|
|
3499
|
+
}
|
|
3500
|
+
else {
|
|
3501
|
+
console.log('trtc:camera video buffer reallocated');
|
|
3502
|
+
}
|
|
3336
3503
|
}
|
|
3337
3504
|
else {
|
|
3338
3505
|
this.handleVideoSizeChange(id, type, width, height);
|
|
@@ -3355,8 +3522,9 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
3355
3522
|
return !('' === item.uid && item.type === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig);
|
|
3356
3523
|
});
|
|
3357
3524
|
if (cameraTestVideoBuffer.buffer) {
|
|
3358
|
-
this.rtcCloud.setCameraTestVideoBuffer(cameraTestVideoBuffer.buffer, 0, 0, cameraTestVideoBuffer.pixelFormat);
|
|
3525
|
+
this.rtcCloud.setCameraTestVideoBuffer(cameraTestVideoBuffer.buffer, 0, 0, cameraTestVideoBuffer.pixelFormat, cameraTestVideoBuffer.id);
|
|
3359
3526
|
cameraTestVideoBuffer.buffer = null;
|
|
3527
|
+
cameraTestVideoBuffer.id = 0;
|
|
3360
3528
|
}
|
|
3361
3529
|
}
|
|
3362
3530
|
/**
|
|
@@ -3499,21 +3667,17 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
3499
3667
|
console.error('trtc: not supported renderMode:', this.renderMode);
|
|
3500
3668
|
return;
|
|
3501
3669
|
}
|
|
3502
|
-
this.rtcCloud.addLocalVideoRenderCallback((id, type, width, height, timestamp, rotation, valid) => {
|
|
3670
|
+
this.rtcCloud.addLocalVideoRenderCallback((id, type, width, height, timestamp, rotation, valid, bufferId) => {
|
|
3503
3671
|
if (this.enableRenderFrame) {
|
|
3504
3672
|
if (valid === 1) {
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
targetBuffer = screenVideoBuffer;
|
|
3508
|
-
}
|
|
3509
|
-
else {
|
|
3510
|
-
targetBuffer = localVideoBuffer;
|
|
3673
|
+
if (this.isScreenCapturing && this.screenCaptureStreamType === type && screenVideoBuffer.id === bufferId) {
|
|
3674
|
+
this._onRenderFrame(id, type, width, height, timestamp, rotation, screenVideoBuffer.buffer);
|
|
3511
3675
|
}
|
|
3512
|
-
if (
|
|
3513
|
-
this._onRenderFrame(id, type, width, height, timestamp, rotation,
|
|
3676
|
+
else if (localVideoBuffer.id === bufferId) {
|
|
3677
|
+
this._onRenderFrame(id, type, width, height, timestamp, rotation, localVideoBuffer.buffer);
|
|
3514
3678
|
}
|
|
3515
3679
|
else {
|
|
3516
|
-
|
|
3680
|
+
console.log(`trtc: ${id} ${type} video buffer reallocated`);
|
|
3517
3681
|
}
|
|
3518
3682
|
}
|
|
3519
3683
|
else {
|
|
@@ -3539,22 +3703,25 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
3539
3703
|
console.error('trtc: not supported renderMode:', this.renderMode);
|
|
3540
3704
|
return;
|
|
3541
3705
|
}
|
|
3542
|
-
this.rtcCloud.addRemoteVideoRenderCallback(userId, (id, type, width, height, timestamp, rotation, valid) => {
|
|
3706
|
+
this.rtcCloud.addRemoteVideoRenderCallback(userId, (id, type, width, height, timestamp, rotation, valid, bufferId) => {
|
|
3543
3707
|
if (this.enableRenderFrame) {
|
|
3544
3708
|
if (valid === 1) {
|
|
3545
|
-
const
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3709
|
+
const remoteUserVideoBuffers = remoteVideoBufferMap.get(id);
|
|
3710
|
+
if (remoteUserVideoBuffers && type !== trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSub) {
|
|
3711
|
+
// 大流和小流
|
|
3712
|
+
if (type === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig && remoteUserVideoBuffers.big && remoteUserVideoBuffers.big.id === bufferId) {
|
|
3713
|
+
this._onRenderFrame(id, type, width, height, timestamp, rotation, remoteUserVideoBuffers.big.buffer);
|
|
3714
|
+
}
|
|
3715
|
+
else if (type === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSmall && remoteUserVideoBuffers.small && remoteUserVideoBuffers.small.id === bufferId) {
|
|
3716
|
+
this._onRenderFrame(id, type, width, height, timestamp, rotation, remoteUserVideoBuffers.small.buffer);
|
|
3717
|
+
}
|
|
3552
3718
|
}
|
|
3553
|
-
if (
|
|
3554
|
-
|
|
3719
|
+
else if (screenVideoBuffer.id === bufferId) {
|
|
3720
|
+
// 辅流
|
|
3721
|
+
this._onRenderFrame(id, type, width, height, timestamp, rotation, screenVideoBuffer.buffer);
|
|
3555
3722
|
}
|
|
3556
3723
|
else {
|
|
3557
|
-
|
|
3724
|
+
console.log(`trtc: ${id} ${type} video buffer reallocated`);
|
|
3558
3725
|
}
|
|
3559
3726
|
}
|
|
3560
3727
|
else {
|
package/liteav/trtc_define.d.ts
CHANGED