trtc-electron-sdk 12.2.115-beta.22 → 12.2.115-beta.26
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/extensions/MediaMixingManager/MediaMixingManager.d.ts +4 -1
- package/liteav/extensions/MediaMixingManager/MediaMixingManager.js +60 -40
- package/liteav/extensions/MediaMixingManager/StreamLayout/CustomStreamLayoutManager.js +5 -4
- package/liteav/extensions/MediaMixingManager/StreamLayout/NoneStreamLayoutManager.js +6 -5
- package/liteav/trtc.js +3 -0
- package/package.json +1 -1
|
@@ -234,6 +234,7 @@ export declare class TRTCMediaMixingManager implements ITRTCMediaMixingManager {
|
|
|
234
234
|
* @returns {Promise<void>}
|
|
235
235
|
*/
|
|
236
236
|
removeMediaSource(mediaSource: TRTCMediaSource): Promise<void>;
|
|
237
|
+
private syncRemoveMediaSource;
|
|
237
238
|
/**
|
|
238
239
|
* 更新本地混流媒体源
|
|
239
240
|
* @param mediaSource {TRTCMediaSource} - 媒体源信息
|
|
@@ -373,6 +374,7 @@ export declare class TRTCMediaMixingManager implements ITRTCMediaMixingManager {
|
|
|
373
374
|
* @returns {Promise<void>}
|
|
374
375
|
*/
|
|
375
376
|
stopMediaMixingServer(): Promise<void>;
|
|
377
|
+
callExperimentalAPI(jsonStr: string): void;
|
|
376
378
|
/**
|
|
377
379
|
* 注册事件监听
|
|
378
380
|
*
|
|
@@ -387,7 +389,8 @@ export declare class TRTCMediaMixingManager implements ITRTCMediaMixingManager {
|
|
|
387
389
|
* @param func {Function} - 事件回调函数
|
|
388
390
|
*/
|
|
389
391
|
off(event: TRTCMediaMixingEvent, func: (...args: any[]) => void): void;
|
|
390
|
-
private
|
|
392
|
+
private createResizeObserver;
|
|
393
|
+
private destroyResizeObserver;
|
|
391
394
|
private onPreviewAreaResize;
|
|
392
395
|
private onVisibilityChange;
|
|
393
396
|
private setDisplayRect;
|
|
@@ -316,10 +316,8 @@ class TRTCMediaMixingManager {
|
|
|
316
316
|
return __awaiter(this, void 0, void 0, function* () {
|
|
317
317
|
DevicePixelRatioObserver_1.default.off('change', this.onDevicePixelRatioChange);
|
|
318
318
|
document.removeEventListener('visibilitychange', this.onVisibilityChange);
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
this.resizeObserver.disconnect();
|
|
322
|
-
}
|
|
319
|
+
this.destroyResizeObserver();
|
|
320
|
+
this.destroyLayoutManager();
|
|
323
321
|
this.view = null;
|
|
324
322
|
this.windowID = 0;
|
|
325
323
|
this.destroyDesigner();
|
|
@@ -453,7 +451,7 @@ class TRTCMediaMixingManager {
|
|
|
453
451
|
this.destroyDesigner();
|
|
454
452
|
this.view = viewOrRegion;
|
|
455
453
|
this.setDisplayRect();
|
|
456
|
-
this.
|
|
454
|
+
this.createResizeObserver();
|
|
457
455
|
this.createDesigner();
|
|
458
456
|
}
|
|
459
457
|
else {
|
|
@@ -471,8 +469,10 @@ class TRTCMediaMixingManager {
|
|
|
471
469
|
}
|
|
472
470
|
}
|
|
473
471
|
else {
|
|
472
|
+
this.destroyResizeObserver();
|
|
474
473
|
this.destroyLayoutManager();
|
|
475
474
|
this.destroyDesigner();
|
|
475
|
+
this.view = null;
|
|
476
476
|
this.nodeMediaMixingPlugin.setDisplayParams(realWindowID, { left: 0, right: 0, top: 0, bottom: 0 });
|
|
477
477
|
}
|
|
478
478
|
}
|
|
@@ -518,6 +518,7 @@ class TRTCMediaMixingManager {
|
|
|
518
518
|
* @returns {Promise<void>}
|
|
519
519
|
*/
|
|
520
520
|
removeMediaSource(mediaSource) {
|
|
521
|
+
var _a;
|
|
521
522
|
logger_1.default.log(`${this.logPrefix}removeMediaSource:`, mediaSource);
|
|
522
523
|
const index = this.findMediaSourceIndex(mediaSource);
|
|
523
524
|
if (index === -1) {
|
|
@@ -526,11 +527,37 @@ class TRTCMediaMixingManager {
|
|
|
526
527
|
message: "Not existing media source to remove"
|
|
527
528
|
});
|
|
528
529
|
}
|
|
529
|
-
|
|
530
|
-
const
|
|
531
|
-
|
|
530
|
+
else {
|
|
531
|
+
const mediaSourceToDelete = this.sourceList[index];
|
|
532
|
+
if ((_a = mediaSourceToDelete === null || mediaSourceToDelete === void 0 ? void 0 : mediaSourceToDelete.control) === null || _a === void 0 ? void 0 : _a.isAddFailed) {
|
|
533
|
+
this.syncRemoveMediaSource(mediaSource, index);
|
|
534
|
+
return Promise.resolve();
|
|
535
|
+
}
|
|
536
|
+
else {
|
|
537
|
+
return new Promise((resolve, reject) => {
|
|
538
|
+
const key = `${promiseKeys.removeMediaSource}-${mediaSource.sourceType}-${mediaSource.sourceId}`;
|
|
539
|
+
this.promiseStore.addPromise(key, resolve, reject);
|
|
540
|
+
this.syncRemoveMediaSource(mediaSource, index);
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
syncRemoveMediaSource(mediaSource, index) {
|
|
546
|
+
var _a;
|
|
547
|
+
try {
|
|
532
548
|
this.nodeMediaMixingPlugin.removeMediaSource(mediaSource);
|
|
533
|
-
|
|
549
|
+
(_a = this.mediaMixingDesigner) === null || _a === void 0 ? void 0 : _a.removeMedia({
|
|
550
|
+
id: `${mediaSource.sourceType}__${mediaSource.sourceId}`,
|
|
551
|
+
rect: mediaSource.rect,
|
|
552
|
+
isSelected: mediaSource.isSelected || false,
|
|
553
|
+
zOrder: mediaSource.zOrder,
|
|
554
|
+
origin: (0, utils_1.safelyParse)(JSON.stringify(mediaSource))
|
|
555
|
+
});
|
|
556
|
+
this.sourceList.splice(index, 1);
|
|
557
|
+
}
|
|
558
|
+
catch (error) {
|
|
559
|
+
logger_1.default.warn(`${this.logPrefix}removeMediaSource exception:`, error);
|
|
560
|
+
}
|
|
534
561
|
}
|
|
535
562
|
/**
|
|
536
563
|
* 更新本地混流媒体源
|
|
@@ -744,7 +771,7 @@ class TRTCMediaMixingManager {
|
|
|
744
771
|
*/
|
|
745
772
|
setStreamLayout(layout) {
|
|
746
773
|
var _a, _b, _c;
|
|
747
|
-
logger_1.default.
|
|
774
|
+
logger_1.default.debug(`${this.logPrefix}setStreamLayout:`, JSON.stringify(layout));
|
|
748
775
|
if (this.paramsStore) {
|
|
749
776
|
try {
|
|
750
777
|
this.paramsStore.streamLayout = JSON.parse(JSON.stringify(layout));
|
|
@@ -753,8 +780,8 @@ class TRTCMediaMixingManager {
|
|
|
753
780
|
this.paramsStore.streamLayout = undefined;
|
|
754
781
|
}
|
|
755
782
|
}
|
|
756
|
-
this.createOrUpdateLayoutManager(layout);
|
|
757
783
|
if (this.view) {
|
|
784
|
+
this.createOrUpdateLayoutManager(layout);
|
|
758
785
|
const viewRect = this.view.getBoundingClientRect();
|
|
759
786
|
if ((_a = layout.userList) === null || _a === void 0 ? void 0 : _a.length) {
|
|
760
787
|
const localUser = layout.userList.filter(user => user.userId === constant_1.LOCAL_USER_ID)[0];
|
|
@@ -767,7 +794,6 @@ class TRTCMediaMixingManager {
|
|
|
767
794
|
bottom: workingArea.bottom / viewRect.height,
|
|
768
795
|
}, localUser.fillMode);
|
|
769
796
|
}
|
|
770
|
-
logger_1.default.log(`${this.logPrefix}setStreamLayout transfer layout to pixel unit:`, JSON.stringify(layout));
|
|
771
797
|
}
|
|
772
798
|
}
|
|
773
799
|
else {
|
|
@@ -836,6 +862,10 @@ class TRTCMediaMixingManager {
|
|
|
836
862
|
});
|
|
837
863
|
});
|
|
838
864
|
}
|
|
865
|
+
callExperimentalAPI(jsonStr) {
|
|
866
|
+
logger_1.default.debug(`${this.logPrefix}callExperimentalAPI:${jsonStr}`);
|
|
867
|
+
this.nodeMediaMixingPlugin.callExperimentalAPI(jsonStr);
|
|
868
|
+
}
|
|
839
869
|
/**
|
|
840
870
|
* 注册事件监听
|
|
841
871
|
*
|
|
@@ -856,12 +886,20 @@ class TRTCMediaMixingManager {
|
|
|
856
886
|
var _a;
|
|
857
887
|
(_a = this.eventEmitter) === null || _a === void 0 ? void 0 : _a.off(event, func);
|
|
858
888
|
}
|
|
859
|
-
|
|
889
|
+
createResizeObserver() {
|
|
860
890
|
if (this.view) {
|
|
861
891
|
this.resizeObserver = new ResizeObserver(this.onPreviewAreaResize);
|
|
862
892
|
this.resizeObserver.observe(this.view);
|
|
863
893
|
}
|
|
864
894
|
}
|
|
895
|
+
destroyResizeObserver() {
|
|
896
|
+
if (this.resizeObserver) {
|
|
897
|
+
if (this.view) {
|
|
898
|
+
this.resizeObserver.unobserve(this.view);
|
|
899
|
+
}
|
|
900
|
+
this.resizeObserver.disconnect();
|
|
901
|
+
}
|
|
902
|
+
}
|
|
865
903
|
onPreviewAreaResize(entries) {
|
|
866
904
|
logger_1.default.log(`${this.logPrefix}onPreviewAreaResize:`, entries);
|
|
867
905
|
for (const entry of entries) {
|
|
@@ -889,6 +927,7 @@ class TRTCMediaMixingManager {
|
|
|
889
927
|
top: clientRect.top * window.devicePixelRatio,
|
|
890
928
|
bottom: clientRect.bottom * window.devicePixelRatio,
|
|
891
929
|
};
|
|
930
|
+
logger_1.default.debug(`${this.logPrefix}setDisplayRect:`, this.windowID, rect);
|
|
892
931
|
this.nodeMediaMixingPlugin.setDisplayParams(this.windowID, rect);
|
|
893
932
|
}
|
|
894
933
|
}
|
|
@@ -1078,7 +1117,7 @@ class TRTCMediaMixingManager {
|
|
|
1078
1117
|
}
|
|
1079
1118
|
}
|
|
1080
1119
|
onMediaSourceAdded(data) {
|
|
1081
|
-
var _a
|
|
1120
|
+
var _a;
|
|
1082
1121
|
const promiseKey = `${promiseKeys.addMediaSource}-${data.sourceType}-${data.sourceId}`;
|
|
1083
1122
|
let flag = false;
|
|
1084
1123
|
if (data.errCode === 0) {
|
|
@@ -1091,14 +1130,10 @@ class TRTCMediaMixingManager {
|
|
|
1091
1130
|
});
|
|
1092
1131
|
if (newSourceIndex !== -1) {
|
|
1093
1132
|
const newMediaSource = this.sourceList[newSourceIndex];
|
|
1094
|
-
(
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
zOrder: newMediaSource.zOrder,
|
|
1099
|
-
origin: newMediaSource
|
|
1100
|
-
});
|
|
1101
|
-
this.sourceList.splice(newSourceIndex, 1);
|
|
1133
|
+
if (!newMediaSource.control) {
|
|
1134
|
+
newMediaSource.control = {};
|
|
1135
|
+
}
|
|
1136
|
+
newMediaSource.control.isAddFailed = true;
|
|
1102
1137
|
}
|
|
1103
1138
|
flag = this.promiseStore.rejectPromise(promiseKey, {
|
|
1104
1139
|
code: data.errCode,
|
|
@@ -1112,29 +1147,14 @@ class TRTCMediaMixingManager {
|
|
|
1112
1147
|
if (index !== -1) {
|
|
1113
1148
|
mediaSource = Object.assign({}, this.sourceList[index]);
|
|
1114
1149
|
}
|
|
1115
|
-
(
|
|
1150
|
+
(_a = this.eventEmitter) === null || _a === void 0 ? void 0 : _a.emit(TRTCMediaMixingEvent.onError, data.errCode, data.errMsg, mediaSource);
|
|
1116
1151
|
}
|
|
1117
1152
|
}
|
|
1118
1153
|
onMediaSourceRemoved(data) {
|
|
1119
|
-
var _a
|
|
1154
|
+
var _a;
|
|
1120
1155
|
const promiseKey = `${promiseKeys.removeMediaSource}-${data.sourceType}-${data.sourceId}`;
|
|
1121
1156
|
let flag = false;
|
|
1122
1157
|
if (data.errCode === 0) {
|
|
1123
|
-
const sourceIndex = this.findMediaSourceIndex({
|
|
1124
|
-
sourceId: data.sourceId,
|
|
1125
|
-
sourceType: data.sourceType
|
|
1126
|
-
});
|
|
1127
|
-
if (sourceIndex !== -1) {
|
|
1128
|
-
const mediaSource = this.sourceList[sourceIndex];
|
|
1129
|
-
(_a = this.mediaMixingDesigner) === null || _a === void 0 ? void 0 : _a.removeMedia({
|
|
1130
|
-
id: `${mediaSource.sourceType}__${mediaSource.sourceId}`,
|
|
1131
|
-
rect: mediaSource.rect,
|
|
1132
|
-
isSelected: mediaSource.isSelected || false,
|
|
1133
|
-
zOrder: mediaSource.zOrder,
|
|
1134
|
-
origin: (0, utils_1.safelyParse)(JSON.stringify(mediaSource))
|
|
1135
|
-
});
|
|
1136
|
-
this.sourceList.splice(sourceIndex, 1);
|
|
1137
|
-
}
|
|
1138
1158
|
flag = this.promiseStore.resolvePromise(promiseKey, undefined);
|
|
1139
1159
|
}
|
|
1140
1160
|
else {
|
|
@@ -1150,7 +1170,7 @@ class TRTCMediaMixingManager {
|
|
|
1150
1170
|
if (index !== -1) {
|
|
1151
1171
|
mediaSource = Object.assign({}, this.sourceList[index]);
|
|
1152
1172
|
}
|
|
1153
|
-
(
|
|
1173
|
+
(_a = this.eventEmitter) === null || _a === void 0 ? void 0 : _a.emit(TRTCMediaMixingEvent.onError, data.errCode, data.errMsg, mediaSource);
|
|
1154
1174
|
}
|
|
1155
1175
|
}
|
|
1156
1176
|
onMediaSourceSizeChanged(data) {
|
|
@@ -28,10 +28,10 @@ class CustomStreamLayoutManager extends BaseStreamLayoutManager_1.default {
|
|
|
28
28
|
transferredUserList = this.layout.userList.map((user) => {
|
|
29
29
|
if (user.rect) {
|
|
30
30
|
return Object.assign(Object.assign({}, user), { rect: {
|
|
31
|
-
left: user.rect.left * window.devicePixelRatio,
|
|
32
|
-
right: user.rect.right * window.devicePixelRatio,
|
|
33
|
-
top: user.rect.top * window.devicePixelRatio,
|
|
34
|
-
bottom: user.rect.bottom * window.devicePixelRatio,
|
|
31
|
+
left: Math.round(user.rect.left * window.devicePixelRatio),
|
|
32
|
+
right: Math.round(user.rect.right * window.devicePixelRatio),
|
|
33
|
+
top: Math.round(user.rect.top * window.devicePixelRatio),
|
|
34
|
+
bottom: Math.round(user.rect.bottom * window.devicePixelRatio),
|
|
35
35
|
} });
|
|
36
36
|
}
|
|
37
37
|
else {
|
|
@@ -39,6 +39,7 @@ class CustomStreamLayoutManager extends BaseStreamLayoutManager_1.default {
|
|
|
39
39
|
}
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
|
+
logger_1.default.debug(`${this.logPrefix}refreshLayout:`, JSON.stringify(transferredUserList));
|
|
42
43
|
this.nativeStreamLayoutManager.setStreamLayout(transferredUserList);
|
|
43
44
|
}
|
|
44
45
|
else if (this.layout.size && this.layout.streams) {
|
|
@@ -29,6 +29,7 @@ class NoneStreamLayoutManager extends BaseStreamLayoutManager_1.default {
|
|
|
29
29
|
bottom: workingArea.bottom / this.displayArea.height / window.devicePixelRatio,
|
|
30
30
|
}, this.layout.userList[0].fillMode);
|
|
31
31
|
}
|
|
32
|
+
logger_1.default.debug(`${this.logPrefix}refreshLayout:`, JSON.stringify(this.layout.userList));
|
|
32
33
|
(_b = this.nativeStreamLayoutManager) === null || _b === void 0 ? void 0 : _b.setStreamLayout(this.layout.userList);
|
|
33
34
|
}
|
|
34
35
|
else {
|
|
@@ -59,12 +60,12 @@ class NoneStreamLayoutManager extends BaseStreamLayoutManager_1.default {
|
|
|
59
60
|
this.layout.userList = [{
|
|
60
61
|
userId: '',
|
|
61
62
|
rect: {
|
|
62
|
-
left: previewLeft,
|
|
63
|
-
top: previewTop,
|
|
64
|
-
right: previewRight,
|
|
65
|
-
bottom: previewBottom,
|
|
63
|
+
left: Math.round(previewLeft),
|
|
64
|
+
top: Math.round(previewTop),
|
|
65
|
+
right: Math.round(previewRight),
|
|
66
|
+
bottom: Math.round(previewBottom),
|
|
66
67
|
},
|
|
67
|
-
fillMode: trtc_define_1.TRTCVideoFillMode.
|
|
68
|
+
fillMode: trtc_define_1.TRTCVideoFillMode.TRTCVideoFillMode_Fill,
|
|
68
69
|
zOrder: 0
|
|
69
70
|
}];
|
|
70
71
|
}
|
package/liteav/trtc.js
CHANGED
|
@@ -5197,6 +5197,9 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
5197
5197
|
return process.platform == 'darwin';
|
|
5198
5198
|
}
|
|
5199
5199
|
_setRemoteVideoBuffer(userId, streamType) {
|
|
5200
|
+
if (TRTCCloud.isIPCMode) {
|
|
5201
|
+
return;
|
|
5202
|
+
}
|
|
5200
5203
|
const videoBufferInfo = new trtc_define_1.VideoBufferInfo({
|
|
5201
5204
|
userId: userId,
|
|
5202
5205
|
id: (0, util_1.generateUniqueId)(),
|