trtc-electron-sdk 12.2.115-beta.15 → 12.2.115-beta.17
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/base/PromiseStore.d.ts +2 -2
- package/liteav/base/PromiseStore.js +4 -6
- package/liteav/extensions/MediaMixingManager/MediaMixingManager.d.ts +2 -1
- package/liteav/extensions/MediaMixingManager/MediaMixingManager.js +42 -10
- package/liteav/extensions/MediaMixingManager/StreamLayout/BaseStreamLayoutManager.d.ts +4 -0
- package/liteav/extensions/MediaMixingManager/StreamLayout/BaseStreamLayoutManager.js +7 -0
- package/liteav/extensions/MediaMixingManager/StreamLayout/NoneStreamLayoutManager.js +11 -2
- package/liteav/extensions/MediaMixingManager/StreamLayout/types.d.ts +4 -0
- package/package.json +1 -1
|
@@ -3,8 +3,8 @@ declare class PromiseStore {
|
|
|
3
3
|
private promiseStore;
|
|
4
4
|
constructor();
|
|
5
5
|
addPromise(key: string, resolve: (data: void | PromiseLike<void>) => void, reject: (reason?: any) => void): void;
|
|
6
|
-
resolvePromise(key: string, value: void | PromiseLike<void>):
|
|
7
|
-
rejectPromise(key: string, reason?: any):
|
|
6
|
+
resolvePromise(key: string, value: void | PromiseLike<void>): boolean;
|
|
7
|
+
rejectPromise(key: string, reason?: any): boolean;
|
|
8
8
|
destroy(): void;
|
|
9
9
|
}
|
|
10
10
|
export default PromiseStore;
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const logger_1 = __importDefault(require("../logger"));
|
|
7
3
|
class PromiseStore {
|
|
8
4
|
constructor() {
|
|
9
5
|
this.logPrefix = '[PromiseStore]';
|
|
@@ -27,9 +23,10 @@ class PromiseStore {
|
|
|
27
23
|
resolve(value);
|
|
28
24
|
});
|
|
29
25
|
this.promiseStore.delete(key);
|
|
26
|
+
return true;
|
|
30
27
|
}
|
|
31
28
|
else {
|
|
32
|
-
|
|
29
|
+
return false;
|
|
33
30
|
}
|
|
34
31
|
}
|
|
35
32
|
rejectPromise(key, reason) {
|
|
@@ -40,9 +37,10 @@ class PromiseStore {
|
|
|
40
37
|
reject(reason);
|
|
41
38
|
});
|
|
42
39
|
this.promiseStore.delete(key);
|
|
40
|
+
return true;
|
|
43
41
|
}
|
|
44
42
|
else {
|
|
45
|
-
|
|
43
|
+
return false;
|
|
46
44
|
}
|
|
47
45
|
}
|
|
48
46
|
destroy() {
|
|
@@ -46,8 +46,9 @@ export declare enum TRTCMediaMixingEvent {
|
|
|
46
46
|
* @description 错误事件
|
|
47
47
|
*
|
|
48
48
|
* @event TRTCMediaMixingEvent#onError
|
|
49
|
-
* @param {TRTCMediaMixingErrorCode}
|
|
49
|
+
* @param {TRTCMediaMixingErrorCode} errorCode 错误码
|
|
50
50
|
* @param {String} errorMessage 错误信息
|
|
51
|
+
* @param {TRTCMediaSource|undefined} 错误涉及的媒体源,可能为空
|
|
51
52
|
*
|
|
52
53
|
*/
|
|
53
54
|
onError = "onError",
|
|
@@ -189,8 +189,9 @@ var TRTCMediaMixingEvent;
|
|
|
189
189
|
* @description 错误事件
|
|
190
190
|
*
|
|
191
191
|
* @event TRTCMediaMixingEvent#onError
|
|
192
|
-
* @param {TRTCMediaMixingErrorCode}
|
|
192
|
+
* @param {TRTCMediaMixingErrorCode} errorCode 错误码
|
|
193
193
|
* @param {String} errorMessage 错误信息
|
|
194
|
+
* @param {TRTCMediaSource|undefined} 错误涉及的媒体源,可能为空
|
|
194
195
|
*
|
|
195
196
|
*/
|
|
196
197
|
TRTCMediaMixingEvent["onError"] = "onError";
|
|
@@ -443,11 +444,16 @@ class TRTCMediaMixingManager {
|
|
|
443
444
|
this.windowID = realWindowID;
|
|
444
445
|
if (realWindowID !== 0 && viewOrRegion !== null) {
|
|
445
446
|
if (viewOrRegion instanceof HTMLElement) {
|
|
446
|
-
this.
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
447
|
+
if (this.view !== viewOrRegion) {
|
|
448
|
+
this.destroyDesigner();
|
|
449
|
+
this.view = viewOrRegion;
|
|
450
|
+
this.setDisplayRect();
|
|
451
|
+
this.initResizeObserver();
|
|
452
|
+
this.createDesigner();
|
|
453
|
+
}
|
|
454
|
+
else {
|
|
455
|
+
this.setDisplayRect();
|
|
456
|
+
}
|
|
451
457
|
}
|
|
452
458
|
else {
|
|
453
459
|
// Rect
|
|
@@ -606,12 +612,16 @@ class TRTCMediaMixingManager {
|
|
|
606
612
|
* @returns {Promise<void>}
|
|
607
613
|
*/
|
|
608
614
|
updatePublishParams(params) {
|
|
609
|
-
var _a;
|
|
615
|
+
var _a, _b;
|
|
610
616
|
return __awaiter(this, void 0, void 0, function* () {
|
|
611
617
|
logger_1.default.log(`${this.logPrefix}updatePublishParams:`, params);
|
|
612
618
|
this.publishParams = params;
|
|
613
619
|
this.updateMixingVideoSize(params.videoEncoderParams);
|
|
614
|
-
(_a = this.
|
|
620
|
+
(_a = this.streamLayoutManager) === null || _a === void 0 ? void 0 : _a.updateOptions({
|
|
621
|
+
width: this.mixingVideoWidth,
|
|
622
|
+
height: this.mixingVideoHeight
|
|
623
|
+
});
|
|
624
|
+
(_b = this.mediaMixingDesigner) === null || _b === void 0 ? void 0 : _b.updateOptions({
|
|
615
625
|
width: this.mixingVideoWidth,
|
|
616
626
|
height: this.mixingVideoHeight
|
|
617
627
|
});
|
|
@@ -891,6 +901,17 @@ class TRTCMediaMixingManager {
|
|
|
891
901
|
canExceedContainer: true,
|
|
892
902
|
});
|
|
893
903
|
this.listenDesignerEvent();
|
|
904
|
+
if (this.sourceList.length >= 1) {
|
|
905
|
+
this.sourceList.forEach((mediaSource => {
|
|
906
|
+
var _a;
|
|
907
|
+
(_a = this.mediaMixingDesigner) === null || _a === void 0 ? void 0 : _a.addMedia({
|
|
908
|
+
id: `${mediaSource.sourceType}__${mediaSource.sourceId}`,
|
|
909
|
+
rect: mediaSource.rect,
|
|
910
|
+
isSelected: mediaSource.isSelected || false,
|
|
911
|
+
origin: mediaSource
|
|
912
|
+
});
|
|
913
|
+
}));
|
|
914
|
+
}
|
|
894
915
|
}
|
|
895
916
|
}
|
|
896
917
|
destroyDesigner() {
|
|
@@ -1029,6 +1050,7 @@ class TRTCMediaMixingManager {
|
|
|
1029
1050
|
}
|
|
1030
1051
|
}
|
|
1031
1052
|
onMediaSourceAddedOrRemoved(key, data) {
|
|
1053
|
+
var _a;
|
|
1032
1054
|
let promiseKey;
|
|
1033
1055
|
if (key === "onMediaSourceAdded") {
|
|
1034
1056
|
promiseKey = `${promiseKeys.addMediaSource}-${data.sourceType}-${data.sourceId}`;
|
|
@@ -1037,15 +1059,25 @@ class TRTCMediaMixingManager {
|
|
|
1037
1059
|
// 'onMediaSourceRemoved'
|
|
1038
1060
|
promiseKey = `${promiseKeys.removeMediaSource}-${data.sourceType}-${data.sourceId}`;
|
|
1039
1061
|
}
|
|
1062
|
+
let flag = false;
|
|
1040
1063
|
if (data.errCode === 0) {
|
|
1041
|
-
this.promiseStore.resolvePromise(promiseKey, undefined);
|
|
1064
|
+
flag = this.promiseStore.resolvePromise(promiseKey, undefined);
|
|
1042
1065
|
}
|
|
1043
1066
|
else {
|
|
1044
|
-
this.promiseStore.rejectPromise(promiseKey, {
|
|
1067
|
+
flag = this.promiseStore.rejectPromise(promiseKey, {
|
|
1045
1068
|
code: data.errCode,
|
|
1046
1069
|
message: data.errMsg,
|
|
1047
1070
|
});
|
|
1048
1071
|
}
|
|
1072
|
+
if (data.errCode !== 0 && !flag) {
|
|
1073
|
+
// event triggered internally, not by method invoked by user
|
|
1074
|
+
const index = this.findMediaSourceIndex(data);
|
|
1075
|
+
let mediaSource = undefined;
|
|
1076
|
+
if (index !== -1) {
|
|
1077
|
+
mediaSource = Object.assign({}, this.sourceList[index]);
|
|
1078
|
+
}
|
|
1079
|
+
(_a = this.eventEmitter) === null || _a === void 0 ? void 0 : _a.emit(TRTCMediaMixingEvent.onError, data.errCode, data.errMsg, mediaSource);
|
|
1080
|
+
}
|
|
1049
1081
|
}
|
|
1050
1082
|
onMediaSourceSizeChanged(data) {
|
|
1051
1083
|
var _a;
|
|
@@ -18,6 +18,10 @@ declare class BaseStreamLayoutManager implements ITRTCStreamLayoutManager {
|
|
|
18
18
|
constructor(nativeStreamLayoutManager: INativeStreamLayoutManager, context: TRTCStreamLayoutContext);
|
|
19
19
|
setLayout(layout: TRTCStreamLayout): void;
|
|
20
20
|
getLayoutMode(): TRTCStreamLayoutMode;
|
|
21
|
+
updateOptions(options: {
|
|
22
|
+
width: number;
|
|
23
|
+
height: number;
|
|
24
|
+
}): void;
|
|
21
25
|
destroy(): void;
|
|
22
26
|
protected refreshLayout(): void;
|
|
23
27
|
private onResize;
|
|
@@ -41,6 +41,13 @@ class BaseStreamLayoutManager {
|
|
|
41
41
|
getLayoutMode() {
|
|
42
42
|
return this.layout.layoutMode;
|
|
43
43
|
}
|
|
44
|
+
updateOptions(options) {
|
|
45
|
+
if (this.context && (this.context.mixingVideoSize.width !== options.width || this.context.mixingVideoSize.height !== options.height)) {
|
|
46
|
+
this.context.mixingVideoSize.width = options.width;
|
|
47
|
+
this.context.mixingVideoSize.height = options.height;
|
|
48
|
+
this.refreshLayout();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
44
51
|
destroy() {
|
|
45
52
|
this.layout = {
|
|
46
53
|
layoutMode: types_1.TRTCStreamLayoutMode.None,
|
|
@@ -17,10 +17,19 @@ class NoneStreamLayoutManager extends BaseStreamLayoutManager_1.default {
|
|
|
17
17
|
this.refreshLayout();
|
|
18
18
|
}
|
|
19
19
|
refreshLayout() {
|
|
20
|
-
var _a;
|
|
20
|
+
var _a, _b;
|
|
21
21
|
if (this.context && this.layout.userList) {
|
|
22
22
|
this.centerLiveOwner();
|
|
23
|
-
(
|
|
23
|
+
if (this.layout.userList.length === 1 && this.layout.userList[0].rect && this.displayArea.width !== 0 && this.displayArea.height !== 0 && window.devicePixelRatio !== 0) {
|
|
24
|
+
const workingArea = this.layout.userList[0].rect;
|
|
25
|
+
(_a = this.context.mediaMixingDesigner) === null || _a === void 0 ? void 0 : _a.setWorkingArea({
|
|
26
|
+
left: workingArea.left / this.displayArea.width / window.devicePixelRatio,
|
|
27
|
+
top: workingArea.top / this.displayArea.height / window.devicePixelRatio,
|
|
28
|
+
right: workingArea.right / this.displayArea.width / window.devicePixelRatio,
|
|
29
|
+
bottom: workingArea.bottom / this.displayArea.height / window.devicePixelRatio,
|
|
30
|
+
}, this.layout.userList[0].fillMode);
|
|
31
|
+
}
|
|
32
|
+
(_b = this.nativeStreamLayoutManager) === null || _b === void 0 ? void 0 : _b.setStreamLayout(this.layout.userList);
|
|
24
33
|
}
|
|
25
34
|
else {
|
|
26
35
|
logger_1.default.error(`${this.logPrefix}setLayout context is null or no user`);
|
|
@@ -14,6 +14,10 @@ export interface TRTCStreamLayoutContext {
|
|
|
14
14
|
export interface ITRTCStreamLayoutManager {
|
|
15
15
|
setLayout(layout: TRTCStreamLayout): void;
|
|
16
16
|
getLayoutMode(): TRTCStreamLayoutMode;
|
|
17
|
+
updateOptions(options: {
|
|
18
|
+
width: number;
|
|
19
|
+
height: number;
|
|
20
|
+
}): void;
|
|
17
21
|
destroy(): void;
|
|
18
22
|
}
|
|
19
23
|
export interface ITRTCStreamLayoutEvent {
|