trtc-electron-sdk 12.2.115-beta.5 → 12.2.115-beta.7
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/MediaMixingDesigner/index.d.ts +10 -7
- package/liteav/MediaMixingDesigner/index.js +78 -67
- package/liteav/extensions/MediaMixingManager/StreamLayout/CustomStreamLayoutManager.d.ts +15 -0
- package/liteav/extensions/MediaMixingManager/StreamLayout/CustomStreamLayoutManager.js +36 -0
- package/liteav/extensions/MediaMixingManager/StreamLayout/FloatStreamLayoutManager.d.ts +15 -0
- package/liteav/extensions/MediaMixingManager/StreamLayout/FloatStreamLayoutManager.js +36 -0
- package/liteav/extensions/MediaMixingManager/StreamLayout/GridStreamLayoutManager.d.ts +15 -0
- package/liteav/extensions/MediaMixingManager/StreamLayout/GridStreamLayoutManager.js +36 -0
- package/liteav/extensions/MediaMixingManager/StreamLayout/NoneStreamLayoutManager.d.ts +16 -0
- package/liteav/extensions/MediaMixingManager/StreamLayout/NoneStreamLayoutManager.js +73 -0
- package/liteav/extensions/MediaMixingManager/StreamLayout/index.d.ts +7 -0
- package/liteav/extensions/MediaMixingManager/StreamLayout/index.js +42 -0
- package/liteav/extensions/MediaMixingManager/StreamLayout/types.d.ts +13 -0
- package/liteav/extensions/MediaMixingManager/StreamLayout/types.js +2 -0
- package/liteav/extensions/MediaMixingManager/index.d.ts +204 -38
- package/liteav/extensions/MediaMixingManager/index.js +453 -36
- package/liteav/extensions/MediaMixingManager/types.d.ts +88 -0
- package/liteav/extensions/MediaMixingManager/types.js +28 -0
- package/liteav/trtc.d.ts +18 -0
- package/liteav/trtc.js +18 -0
- package/liteav/trtc_define.d.ts +2 -2
- package/liteav/trtc_define.js +1 -1
- package/package.json +2 -2
- package/scripts/download.js +153 -169
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Rect, TRTCVideoFillMode } from "../trtc_define";
|
|
2
2
|
export declare type TRTCMediaInfo = {
|
|
3
3
|
id: string;
|
|
4
4
|
rect: Rect;
|
|
@@ -9,8 +9,6 @@ export declare type TRTCMediaInfo = {
|
|
|
9
9
|
declare class TRTCMediaMixingDesigner {
|
|
10
10
|
private logPrefix;
|
|
11
11
|
private container;
|
|
12
|
-
private videoResolution;
|
|
13
|
-
private resMode;
|
|
14
12
|
private mixingVideoWidth;
|
|
15
13
|
private mixingVideoHeight;
|
|
16
14
|
private canExceedContainer;
|
|
@@ -33,16 +31,20 @@ declare class TRTCMediaMixingDesigner {
|
|
|
33
31
|
private mousedownTop;
|
|
34
32
|
private eventButton;
|
|
35
33
|
private resizeObserver;
|
|
34
|
+
private relativeWorkingArea;
|
|
35
|
+
private absoluteWorkingArea;
|
|
36
|
+
private fillMode;
|
|
36
37
|
constructor(options: {
|
|
37
38
|
view: HTMLElement;
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
width: number;
|
|
40
|
+
height: number;
|
|
40
41
|
canExceedContainer: boolean;
|
|
41
42
|
});
|
|
42
43
|
updateOptions(options: {
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
width: number;
|
|
45
|
+
height: number;
|
|
45
46
|
}): void;
|
|
47
|
+
setWorkingArea(relative: Rect | null | undefined, fillMode?: TRTCVideoFillMode): void;
|
|
46
48
|
addMedia(media: TRTCMediaInfo): void;
|
|
47
49
|
removeMedia(media: TRTCMediaInfo): void;
|
|
48
50
|
updateMedia(media: TRTCMediaInfo): void;
|
|
@@ -54,6 +56,7 @@ declare class TRTCMediaMixingDesigner {
|
|
|
54
56
|
private initContainerMouseEventHander;
|
|
55
57
|
private initContainerResizeObserver;
|
|
56
58
|
private onPreviewAreaResize;
|
|
59
|
+
private updateWorkingArea;
|
|
57
60
|
private updatePreviewProperty;
|
|
58
61
|
private updateOverlay;
|
|
59
62
|
private onMove;
|
|
@@ -5,26 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const events_1 = require("events");
|
|
7
7
|
const trtc_define_1 = require("../trtc_define");
|
|
8
|
-
const utils_1 = require("../utils");
|
|
9
8
|
const logger_1 = __importDefault(require("../logger"));
|
|
10
9
|
const Movable_1 = __importDefault(require("./Movable"));
|
|
11
10
|
const Resizable_1 = __importDefault(require("./Resizable"));
|
|
12
11
|
const MIN_MOVE_DISTANCE = 5; // minimum moving distance
|
|
13
|
-
const initResolutionMap = () => {
|
|
14
|
-
const map = new Map();
|
|
15
|
-
for (const key in trtc_define_1.TRTCVideoResolution) {
|
|
16
|
-
if (isNaN(Number(key))) {
|
|
17
|
-
const value = trtc_define_1.TRTCVideoResolution[key];
|
|
18
|
-
const tmp = key.split('_');
|
|
19
|
-
map.set(value, {
|
|
20
|
-
width: parseInt(tmp[1]),
|
|
21
|
-
height: parseInt(tmp[2]),
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return map;
|
|
26
|
-
};
|
|
27
|
-
const resolutionMap = initResolutionMap();
|
|
28
12
|
class TRTCMediaMixingDesigner {
|
|
29
13
|
constructor(options) {
|
|
30
14
|
this.logPrefix = '[TRTCMediaMixingDesigner]';
|
|
@@ -48,19 +32,12 @@ class TRTCMediaMixingDesigner {
|
|
|
48
32
|
this.resizeObserver = null;
|
|
49
33
|
this.container = options.view;
|
|
50
34
|
this.container.style.position = 'absolute';
|
|
51
|
-
this.
|
|
52
|
-
this.
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
this.mixingVideoHeight = height;
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
this.mixingVideoWidth = height;
|
|
61
|
-
this.mixingVideoHeight = width;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
35
|
+
this.relativeWorkingArea = { left: 0, top: 0, right: 1, bottom: 1 };
|
|
36
|
+
this.absoluteWorkingArea = {};
|
|
37
|
+
this.fillMode = trtc_define_1.TRTCVideoFillMode.TRTCVideoFillMode_Fit;
|
|
38
|
+
this.updateWorkingArea();
|
|
39
|
+
this.mixingVideoWidth = options.width;
|
|
40
|
+
this.mixingVideoHeight = options.height;
|
|
64
41
|
this.updatePreviewProperty();
|
|
65
42
|
this.canExceedContainer = options.canExceedContainer || false;
|
|
66
43
|
this.eventEmitter = new events_1.EventEmitter();
|
|
@@ -75,24 +52,25 @@ class TRTCMediaMixingDesigner {
|
|
|
75
52
|
this.initContainerResizeObserver();
|
|
76
53
|
}
|
|
77
54
|
updateOptions(options) {
|
|
78
|
-
if (
|
|
79
|
-
this.
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
}
|
|
55
|
+
if (this.mixingVideoWidth !== options.width || this.mixingVideoHeight !== options.height) {
|
|
56
|
+
this.mixingVideoWidth = options.width;
|
|
57
|
+
this.mixingVideoHeight = options.height;
|
|
58
|
+
this.updatePreviewProperty();
|
|
59
|
+
this.updateOverlay();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
setWorkingArea(relative, fillMode = trtc_define_1.TRTCVideoFillMode.TRTCVideoFillMode_Fit) {
|
|
63
|
+
logger_1.default.log(`${this.logPrefix}setWorkingArea:`, JSON.stringify(relative), `fillMode:${fillMode}`);
|
|
64
|
+
if (relative) {
|
|
65
|
+
this.relativeWorkingArea = Object.assign({}, relative);
|
|
66
|
+
this.fillMode = fillMode;
|
|
67
|
+
this.updateWorkingArea();
|
|
93
68
|
this.updatePreviewProperty();
|
|
94
69
|
this.updateOverlay();
|
|
95
70
|
}
|
|
71
|
+
else {
|
|
72
|
+
logger_1.default.error(`${this.logPrefix}setWorkingArea invalid parameter:`, relative);
|
|
73
|
+
}
|
|
96
74
|
}
|
|
97
75
|
addMedia(media) {
|
|
98
76
|
this.mediaList.unshift(media);
|
|
@@ -194,43 +172,73 @@ class TRTCMediaMixingDesigner {
|
|
|
194
172
|
logger_1.default.log(`${this.logPrefix}onPreviewAreaResize:`, entries);
|
|
195
173
|
for (const entry of entries) {
|
|
196
174
|
if (entry.target === this.container) {
|
|
175
|
+
this.updateWorkingArea();
|
|
197
176
|
this.updatePreviewProperty();
|
|
198
177
|
this.updateOverlay();
|
|
199
178
|
break;
|
|
200
179
|
}
|
|
201
180
|
}
|
|
202
181
|
}
|
|
182
|
+
updateWorkingArea() {
|
|
183
|
+
if (this.relativeWorkingArea && this.container) {
|
|
184
|
+
const containerRect = this.container.getBoundingClientRect();
|
|
185
|
+
this.absoluteWorkingArea = {
|
|
186
|
+
left: this.relativeWorkingArea.left * containerRect.width,
|
|
187
|
+
top: this.relativeWorkingArea.top * containerRect.height,
|
|
188
|
+
right: this.relativeWorkingArea.right * containerRect.width,
|
|
189
|
+
bottom: this.relativeWorkingArea.bottom * containerRect.height,
|
|
190
|
+
width: (this.relativeWorkingArea.right - this.relativeWorkingArea.left) * containerRect.width,
|
|
191
|
+
height: (this.relativeWorkingArea.bottom - this.relativeWorkingArea.top) * containerRect.height,
|
|
192
|
+
};
|
|
193
|
+
logger_1.default.log(`${this.logPrefix}updateWorkingArea absolute working area:`, JSON.stringify(this.absoluteWorkingArea));
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
logger_1.default.error(`${this.logPrefix}updateWorkingArea no data:`, this.relativeWorkingArea, this.container);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
203
199
|
updatePreviewProperty() {
|
|
204
|
-
if (this.
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
200
|
+
if (this.absoluteWorkingArea) {
|
|
201
|
+
if (this.mixingVideoWidth <= 0 || this.mixingVideoHeight <= 0) {
|
|
202
|
+
logger_1.default.error(`${this.logPrefix}updatePreviewProperty failed, mixingVideoWidth or mixingVideoHeight is zero`);
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
const workingAreaWidth = this.absoluteWorkingArea.width;
|
|
206
|
+
const workingAreaHeight = this.absoluteWorkingArea.height;
|
|
207
|
+
const widthScale = workingAreaWidth / this.mixingVideoWidth;
|
|
208
|
+
const heightScale = workingAreaHeight / this.mixingVideoHeight;
|
|
209
|
+
if (this.fillMode === trtc_define_1.TRTCVideoFillMode.TRTCVideoFillMode_Fill) {
|
|
210
|
+
this.previewScale = widthScale > heightScale ? widthScale : heightScale;
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
this.fillMode = trtc_define_1.TRTCVideoFillMode.TRTCVideoFillMode_Fit;
|
|
214
|
+
this.previewScale = widthScale > heightScale ? heightScale : widthScale;
|
|
215
|
+
}
|
|
210
216
|
this.previewWidth = this.mixingVideoWidth * this.previewScale;
|
|
211
217
|
this.previewHeight = this.mixingVideoHeight * this.previewScale;
|
|
212
|
-
this.previewLeft = (
|
|
213
|
-
this.previewTop = (
|
|
218
|
+
this.previewLeft = (workingAreaWidth - this.previewWidth) / 2;
|
|
219
|
+
this.previewTop = (workingAreaHeight - this.previewHeight) / 2;
|
|
220
|
+
logger_1.default.debug(`${this.logPrefix}updatePreviewProperty: fillMode: ${this.fillMode} previewScale: ${this.previewScale}, previewWidth: ${this.previewWidth}, previewHeight: ${this.previewHeight}, previewLeft: ${this.previewLeft}, previewTop: ${this.previewTop}`);
|
|
214
221
|
}
|
|
215
222
|
else {
|
|
216
|
-
logger_1.default.error(`${this.logPrefix}
|
|
223
|
+
logger_1.default.error(`${this.logPrefix}updatePreviewProperty failed, no HTML element to display`);
|
|
217
224
|
}
|
|
218
225
|
}
|
|
219
226
|
updateOverlay() {
|
|
220
227
|
if (this.moveAndResizeOverlay) {
|
|
221
|
-
let left = `${this.previewLeft}px`;
|
|
222
|
-
let top = `${this.previewTop}px`;
|
|
228
|
+
let left = `${this.absoluteWorkingArea.left + this.previewLeft}px`;
|
|
229
|
+
let top = `${this.absoluteWorkingArea.top + this.previewTop}px`;
|
|
223
230
|
let width = '0px';
|
|
224
231
|
let height = '0px';
|
|
225
232
|
if (this.selectedMediaIndex >= 0) {
|
|
233
|
+
logger_1.default.debug(`${this.logPrefix}updateOverlay: selected media:`, this.mediaList[this.selectedMediaIndex].rect);
|
|
226
234
|
const selectedPreviewRect = {
|
|
227
235
|
left: this.mediaList[this.selectedMediaIndex].rect.left * this.previewScale,
|
|
228
236
|
top: this.mediaList[this.selectedMediaIndex].rect.top * this.previewScale,
|
|
229
237
|
right: this.mediaList[this.selectedMediaIndex].rect.right * this.previewScale,
|
|
230
238
|
bottom: this.mediaList[this.selectedMediaIndex].rect.bottom * this.previewScale
|
|
231
239
|
};
|
|
232
|
-
left = `${
|
|
233
|
-
top = `${
|
|
240
|
+
left = `${this.absoluteWorkingArea.left + this.previewLeft + selectedPreviewRect.left}px`;
|
|
241
|
+
top = `${this.absoluteWorkingArea.top + this.previewTop + selectedPreviewRect.top}px`;
|
|
234
242
|
width = `${selectedPreviewRect.right - selectedPreviewRect.left}px`;
|
|
235
243
|
height = `${selectedPreviewRect.bottom - selectedPreviewRect.top}px`;
|
|
236
244
|
}
|
|
@@ -238,6 +246,7 @@ class TRTCMediaMixingDesigner {
|
|
|
238
246
|
this.moveAndResizeOverlay.style.top = top;
|
|
239
247
|
this.moveAndResizeOverlay.style.width = width;
|
|
240
248
|
this.moveAndResizeOverlay.style.height = height;
|
|
249
|
+
logger_1.default.debug(`${this.logPrefix}updateOverlay: ${left} ${top} ${width} ${height}`);
|
|
241
250
|
}
|
|
242
251
|
}
|
|
243
252
|
onMove(left, top) {
|
|
@@ -247,10 +256,10 @@ class TRTCMediaMixingDesigner {
|
|
|
247
256
|
if (target && this.moveAndResizeOverlay) {
|
|
248
257
|
// calc new preview rect
|
|
249
258
|
const newPreviewRect = {
|
|
250
|
-
left: left - this.previewLeft,
|
|
251
|
-
top: top - this.previewTop,
|
|
252
|
-
right: left - this.previewLeft + this.moveAndResizeOverlay.offsetWidth,
|
|
253
|
-
bottom: top - this.previewTop + this.moveAndResizeOverlay.offsetHeight,
|
|
259
|
+
left: left - this.absoluteWorkingArea.left - this.previewLeft,
|
|
260
|
+
top: top - this.absoluteWorkingArea.top - this.previewTop,
|
|
261
|
+
right: left - this.absoluteWorkingArea.left - this.previewLeft + this.moveAndResizeOverlay.offsetWidth,
|
|
262
|
+
bottom: top - this.absoluteWorkingArea.top - this.previewTop + this.moveAndResizeOverlay.offsetHeight,
|
|
254
263
|
};
|
|
255
264
|
this.doAdsorption(newPreviewRect);
|
|
256
265
|
// calc new mixing rect
|
|
@@ -260,6 +269,8 @@ class TRTCMediaMixingDesigner {
|
|
|
260
269
|
right: Math.round(newPreviewRect.right / this.previewScale),
|
|
261
270
|
bottom: Math.round(newPreviewRect.bottom / this.previewScale),
|
|
262
271
|
};
|
|
272
|
+
logger_1.default.debug(`${this.logPrefix}onMove new preview rect: ${JSON.stringify(newPreviewRect)}`);
|
|
273
|
+
logger_1.default.debug(`${this.logPrefix}onMove new rect in mixing: ${JSON.stringify(newRectInMixing)}`);
|
|
263
274
|
(_a = this.eventEmitter) === null || _a === void 0 ? void 0 : _a.emit('onSourceMoved', Object.assign({}, target), newRectInMixing);
|
|
264
275
|
}
|
|
265
276
|
else {
|
|
@@ -292,10 +303,10 @@ class TRTCMediaMixingDesigner {
|
|
|
292
303
|
if (target) {
|
|
293
304
|
// calc new preview rect
|
|
294
305
|
const newPreviewRect = {
|
|
295
|
-
left: left - this.previewLeft,
|
|
296
|
-
top: top - this.previewTop,
|
|
297
|
-
right: left - this.previewLeft + width,
|
|
298
|
-
bottom: top - this.previewTop + height,
|
|
306
|
+
left: left - this.absoluteWorkingArea.left - this.previewLeft,
|
|
307
|
+
top: top - this.absoluteWorkingArea.top - this.previewTop,
|
|
308
|
+
right: left - this.absoluteWorkingArea.left - this.previewLeft + width,
|
|
309
|
+
bottom: top - this.absoluteWorkingArea.top - this.previewTop + height,
|
|
299
310
|
};
|
|
300
311
|
// calc new mixing rect
|
|
301
312
|
const newRectInMixing = {
|
|
@@ -335,8 +346,8 @@ class TRTCMediaMixingDesigner {
|
|
|
335
346
|
// calc click point coordinates in mix video image
|
|
336
347
|
logger_1.default.log(`${this.logPrefix}onContainerMousedown mix video image clicked`);
|
|
337
348
|
const containerBounds = this.container.getBoundingClientRect();
|
|
338
|
-
const xInPreviewImage = event.clientX - containerBounds.
|
|
339
|
-
const yInPreviewImage = event.clientY - containerBounds.
|
|
349
|
+
const xInPreviewImage = event.clientX - containerBounds.left - this.absoluteWorkingArea.left - this.previewLeft;
|
|
350
|
+
const yInPreviewImage = event.clientY - containerBounds.top - this.absoluteWorkingArea.top - this.previewTop;
|
|
340
351
|
const xInImage = xInPreviewImage / this.previewScale;
|
|
341
352
|
const yInImage = yInPreviewImage / this.previewScale;
|
|
342
353
|
logger_1.default.log(`${this.logPrefix}onContainerMousedown click point coordinates in mix video:`, xInPreviewImage, yInPreviewImage, xInImage, yInImage);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TRTCStreamLayout, TRTCStreamLayoutMode } from "../types";
|
|
2
|
+
import { ITRTCStreamLayoutManager, INativeStreamLayoutManager } from "./types";
|
|
3
|
+
declare class CustomStreamLayoutManager implements ITRTCStreamLayoutManager {
|
|
4
|
+
private logPrefix;
|
|
5
|
+
private layoutMode;
|
|
6
|
+
private nativeStreamLayoutManager;
|
|
7
|
+
private layout;
|
|
8
|
+
private context;
|
|
9
|
+
constructor(nativeStreamLayoutManager: INativeStreamLayoutManager, context?: Record<string, any>);
|
|
10
|
+
setLayout(layout: TRTCStreamLayout): void;
|
|
11
|
+
getLayoutMode(): TRTCStreamLayoutMode;
|
|
12
|
+
setContext(context: Record<string, any>): void;
|
|
13
|
+
destroy(): void;
|
|
14
|
+
}
|
|
15
|
+
export default CustomStreamLayoutManager;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const types_1 = require("../types");
|
|
7
|
+
const logger_1 = __importDefault(require("../../../logger"));
|
|
8
|
+
class CustomStreamLayoutManager {
|
|
9
|
+
constructor(nativeStreamLayoutManager, context) {
|
|
10
|
+
this.logPrefix = "[TRTCCustomStreamLayoutManager]";
|
|
11
|
+
this.layoutMode = types_1.TRTCStreamLayoutMode.Custom;
|
|
12
|
+
this.nativeStreamLayoutManager = nativeStreamLayoutManager;
|
|
13
|
+
this.layout = null;
|
|
14
|
+
this.context = context;
|
|
15
|
+
}
|
|
16
|
+
setLayout(layout) {
|
|
17
|
+
this.layout = layout;
|
|
18
|
+
if (layout.userList) {
|
|
19
|
+
this.nativeStreamLayoutManager.setStreamLayout(layout.userList);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
logger_1.default.error(`${this.logPrefix}setLayout invalid parameter, no 'userList'`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
getLayoutMode() {
|
|
26
|
+
return this.layoutMode;
|
|
27
|
+
}
|
|
28
|
+
setContext(context) {
|
|
29
|
+
this.context = context;
|
|
30
|
+
}
|
|
31
|
+
destroy() {
|
|
32
|
+
this.layout = null;
|
|
33
|
+
this.context = null;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.default = CustomStreamLayoutManager;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TRTCStreamLayout, TRTCStreamLayoutMode } from "../types";
|
|
2
|
+
import { ITRTCStreamLayoutManager, INativeStreamLayoutManager } from "./types";
|
|
3
|
+
declare class FloatStreamLayoutManager implements ITRTCStreamLayoutManager {
|
|
4
|
+
private logPrefix;
|
|
5
|
+
private layoutMode;
|
|
6
|
+
private nativeStreamLayoutManager;
|
|
7
|
+
private layout;
|
|
8
|
+
private context;
|
|
9
|
+
constructor(nativeStreamLayoutManager: INativeStreamLayoutManager, context?: Record<string, any>);
|
|
10
|
+
setLayout(layout: TRTCStreamLayout): void;
|
|
11
|
+
getLayoutMode(): TRTCStreamLayoutMode;
|
|
12
|
+
setContext(context: Record<string, any>): void;
|
|
13
|
+
destroy(): void;
|
|
14
|
+
}
|
|
15
|
+
export default FloatStreamLayoutManager;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const types_1 = require("../types");
|
|
7
|
+
const logger_1 = __importDefault(require("../../../logger"));
|
|
8
|
+
class FloatStreamLayoutManager {
|
|
9
|
+
constructor(nativeStreamLayoutManager, context) {
|
|
10
|
+
this.logPrefix = "[TRTCFloatStreamLayoutManager]";
|
|
11
|
+
this.layoutMode = types_1.TRTCStreamLayoutMode.Float;
|
|
12
|
+
this.nativeStreamLayoutManager = nativeStreamLayoutManager;
|
|
13
|
+
this.layout = null;
|
|
14
|
+
this.context = context;
|
|
15
|
+
}
|
|
16
|
+
setLayout(layout) {
|
|
17
|
+
this.layout = layout;
|
|
18
|
+
if (layout.userList) {
|
|
19
|
+
this.nativeStreamLayoutManager.setStreamLayout(layout.userList);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
logger_1.default.error(`${this.logPrefix}setLayout invalid parameter, no 'userList'`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
getLayoutMode() {
|
|
26
|
+
return this.layoutMode;
|
|
27
|
+
}
|
|
28
|
+
setContext(context) {
|
|
29
|
+
this.context = context;
|
|
30
|
+
}
|
|
31
|
+
destroy() {
|
|
32
|
+
this.layout = null;
|
|
33
|
+
this.context = null;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.default = FloatStreamLayoutManager;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TRTCStreamLayout, TRTCStreamLayoutMode } from "../types";
|
|
2
|
+
import { ITRTCStreamLayoutManager, INativeStreamLayoutManager } from "./types";
|
|
3
|
+
declare class GridStreamLayoutManager implements ITRTCStreamLayoutManager {
|
|
4
|
+
private logPrefix;
|
|
5
|
+
private layoutMode;
|
|
6
|
+
private nativeStreamLayoutManager;
|
|
7
|
+
private layout;
|
|
8
|
+
private context;
|
|
9
|
+
constructor(nativeStreamLayoutManager: INativeStreamLayoutManager, context?: Record<string, any>);
|
|
10
|
+
setLayout(layout: TRTCStreamLayout): void;
|
|
11
|
+
getLayoutMode(): TRTCStreamLayoutMode;
|
|
12
|
+
setContext(context: Record<string, any>): void;
|
|
13
|
+
destroy(): void;
|
|
14
|
+
}
|
|
15
|
+
export default GridStreamLayoutManager;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const types_1 = require("../types");
|
|
7
|
+
const logger_1 = __importDefault(require("../../../logger"));
|
|
8
|
+
class GridStreamLayoutManager {
|
|
9
|
+
constructor(nativeStreamLayoutManager, context) {
|
|
10
|
+
this.logPrefix = "[TRTCGridStreamLayoutManager]";
|
|
11
|
+
this.layoutMode = types_1.TRTCStreamLayoutMode.Grid;
|
|
12
|
+
this.nativeStreamLayoutManager = nativeStreamLayoutManager;
|
|
13
|
+
this.layout = null;
|
|
14
|
+
this.context = context;
|
|
15
|
+
}
|
|
16
|
+
setLayout(layout) {
|
|
17
|
+
this.layout = layout;
|
|
18
|
+
if (layout.userList) {
|
|
19
|
+
this.nativeStreamLayoutManager.setStreamLayout(layout.userList);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
logger_1.default.error(`${this.logPrefix}setLayout invalid parameter, no 'userList'`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
getLayoutMode() {
|
|
26
|
+
return this.layoutMode;
|
|
27
|
+
}
|
|
28
|
+
setContext(context) {
|
|
29
|
+
this.context = context;
|
|
30
|
+
}
|
|
31
|
+
destroy() {
|
|
32
|
+
this.layout = null;
|
|
33
|
+
this.context = null;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.default = GridStreamLayoutManager;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { TRTCStreamLayout, TRTCStreamLayoutMode } from "../types";
|
|
2
|
+
import { ITRTCStreamLayoutManager, INativeStreamLayoutManager } from "./types";
|
|
3
|
+
declare class NoneStreamLayoutManager implements ITRTCStreamLayoutManager {
|
|
4
|
+
private logPrefix;
|
|
5
|
+
private layoutMode;
|
|
6
|
+
private nativeStreamLayoutManager;
|
|
7
|
+
private layout;
|
|
8
|
+
private context;
|
|
9
|
+
constructor(nativeStreamLayoutManager: INativeStreamLayoutManager, context?: Record<string, any>);
|
|
10
|
+
setLayout(layout: TRTCStreamLayout): void;
|
|
11
|
+
getLayoutMode(): TRTCStreamLayoutMode;
|
|
12
|
+
setContext(context: Record<string, any>): void;
|
|
13
|
+
destroy(): void;
|
|
14
|
+
private centerLiveOwner;
|
|
15
|
+
}
|
|
16
|
+
export default NoneStreamLayoutManager;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const types_1 = require("../types");
|
|
7
|
+
const trtc_define_1 = require("../../../trtc_define");
|
|
8
|
+
const logger_1 = __importDefault(require("../../../logger"));
|
|
9
|
+
class NoneStreamLayoutManager {
|
|
10
|
+
constructor(nativeStreamLayoutManager, context) {
|
|
11
|
+
this.logPrefix = "[TRTCNoneStreamLayoutManager]";
|
|
12
|
+
this.layoutMode = types_1.TRTCStreamLayoutMode.None;
|
|
13
|
+
this.nativeStreamLayoutManager = nativeStreamLayoutManager;
|
|
14
|
+
this.layout = null;
|
|
15
|
+
this.context = context;
|
|
16
|
+
}
|
|
17
|
+
setLayout(layout) {
|
|
18
|
+
var _a;
|
|
19
|
+
this.layout = layout || { layoutMode: types_1.TRTCStreamLayoutMode.None, userList: [] };
|
|
20
|
+
if (this.context && this.layout.userList) {
|
|
21
|
+
this.centerLiveOwner();
|
|
22
|
+
(_a = this.nativeStreamLayoutManager) === null || _a === void 0 ? void 0 : _a.setStreamLayout(this.layout.userList);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
logger_1.default.error(`${this.logPrefix}setLayout context is null or no user`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
getLayoutMode() {
|
|
29
|
+
return this.layoutMode;
|
|
30
|
+
}
|
|
31
|
+
setContext(context) {
|
|
32
|
+
this.context = context;
|
|
33
|
+
}
|
|
34
|
+
destroy() {
|
|
35
|
+
this.layout = null;
|
|
36
|
+
this.context = null;
|
|
37
|
+
}
|
|
38
|
+
centerLiveOwner() {
|
|
39
|
+
if (this.context && this.layout) {
|
|
40
|
+
const layoutPixelWidth = this.context.layoutPixelRect.width;
|
|
41
|
+
const layoutPixelHeight = this.context.layoutPixelRect.height;
|
|
42
|
+
const mixingVideoWidth = this.context.mixingVideoSize.width;
|
|
43
|
+
const mixingVideoHeight = this.context.mixingVideoSize.height;
|
|
44
|
+
// Live Owner(local user)
|
|
45
|
+
let scaleRate;
|
|
46
|
+
if (mixingVideoWidth === 0 || mixingVideoHeight === 0) {
|
|
47
|
+
scaleRate = 1;
|
|
48
|
+
logger_1.default.error(`${this.logPrefix}centerLiveOwner mixingVideoSize is 0, use default scaleRate '1'`);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
scaleRate = Math.min(layoutPixelWidth / mixingVideoWidth, layoutPixelHeight / mixingVideoHeight);
|
|
52
|
+
}
|
|
53
|
+
const previewWidth = mixingVideoWidth * scaleRate;
|
|
54
|
+
const previewHeight = mixingVideoHeight * scaleRate;
|
|
55
|
+
const previewLeft = (layoutPixelWidth - previewWidth) / 2;
|
|
56
|
+
const previewTop = (layoutPixelHeight - previewHeight) / 2;
|
|
57
|
+
const previewRight = previewLeft + previewWidth;
|
|
58
|
+
const previewBottom = previewTop + previewHeight;
|
|
59
|
+
this.layout.userList = [{
|
|
60
|
+
userId: '',
|
|
61
|
+
rect: {
|
|
62
|
+
left: previewLeft,
|
|
63
|
+
top: previewTop,
|
|
64
|
+
right: previewRight,
|
|
65
|
+
bottom: previewBottom,
|
|
66
|
+
},
|
|
67
|
+
fillMode: trtc_define_1.TRTCVideoFillMode.TRTCVideoFillMode_Fit,
|
|
68
|
+
zOrder: 0
|
|
69
|
+
}];
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.default = NoneStreamLayoutManager;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TRTCStreamLayoutMode } from '../types';
|
|
2
|
+
import { ITRTCStreamLayoutManager, INativeStreamLayoutManager } from './types';
|
|
3
|
+
export * from './types';
|
|
4
|
+
declare function create(layoutMode: TRTCStreamLayoutMode, nativeStreamLayoutManager: INativeStreamLayoutManager): ITRTCStreamLayoutManager;
|
|
5
|
+
export declare const StreamLayoutFactory: {
|
|
6
|
+
create: typeof create;
|
|
7
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
|
+
};
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.StreamLayoutFactory = void 0;
|
|
17
|
+
const FloatStreamLayoutManager_1 = __importDefault(require("./FloatStreamLayoutManager"));
|
|
18
|
+
const GridStreamLayoutManager_1 = __importDefault(require("./GridStreamLayoutManager"));
|
|
19
|
+
const CustomStreamLayoutManager_1 = __importDefault(require("./CustomStreamLayoutManager"));
|
|
20
|
+
const NoneStreamLayoutManager_1 = __importDefault(require("./NoneStreamLayoutManager"));
|
|
21
|
+
const types_1 = require("../types");
|
|
22
|
+
__exportStar(require("./types"), exports);
|
|
23
|
+
function create(layoutMode, nativeStreamLayoutManager) {
|
|
24
|
+
let layoutManager;
|
|
25
|
+
if (layoutMode === types_1.TRTCStreamLayoutMode.Custom) {
|
|
26
|
+
layoutManager = new CustomStreamLayoutManager_1.default(nativeStreamLayoutManager);
|
|
27
|
+
}
|
|
28
|
+
else if (layoutMode === types_1.TRTCStreamLayoutMode.Float) {
|
|
29
|
+
layoutManager = new FloatStreamLayoutManager_1.default(nativeStreamLayoutManager);
|
|
30
|
+
}
|
|
31
|
+
else if (layoutMode === types_1.TRTCStreamLayoutMode.Grid) {
|
|
32
|
+
layoutManager = new GridStreamLayoutManager_1.default(nativeStreamLayoutManager);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
// layoutMode === TRTCStreamLayoutMode.None
|
|
36
|
+
layoutManager = new NoneStreamLayoutManager_1.default(nativeStreamLayoutManager);
|
|
37
|
+
}
|
|
38
|
+
return layoutManager;
|
|
39
|
+
}
|
|
40
|
+
exports.StreamLayoutFactory = {
|
|
41
|
+
create: create,
|
|
42
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TRTCStreamInfo, TRTCStreamLayout, TRTCStreamLayoutMode } from '../types';
|
|
2
|
+
export interface INativeStreamLayoutManager {
|
|
3
|
+
setStreamLayout: (streamList: Array<TRTCStreamInfo>) => void;
|
|
4
|
+
}
|
|
5
|
+
export interface ITRTCStreamLayoutManager {
|
|
6
|
+
setLayout(layout: TRTCStreamLayout): void;
|
|
7
|
+
getLayoutMode(): TRTCStreamLayoutMode;
|
|
8
|
+
destroy(): void;
|
|
9
|
+
setContext(context: Record<string, any>): void;
|
|
10
|
+
}
|
|
11
|
+
export interface ITRTCStreamLayoutEvent {
|
|
12
|
+
onStreamLayoutChanged(streams: Array<TRTCStreamInfo>): void;
|
|
13
|
+
}
|