trtc-electron-sdk 12.2.115-beta.2 → 12.2.115-beta.21
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 +12 -8
- package/liteav/MediaMixingDesigner/index.js +135 -79
- package/liteav/base/DevicePixelRatioObserver.d.ts +12 -0
- package/liteav/base/DevicePixelRatioObserver.js +32 -0
- package/liteav/base/PromiseStore.d.ts +10 -0
- package/liteav/base/PromiseStore.js +58 -0
- package/liteav/constant.d.ts +1 -0
- package/liteav/constant.js +4 -0
- package/liteav/extensions/MediaMixingManager/MediaMixingManager.d.ts +429 -0
- package/liteav/extensions/MediaMixingManager/MediaMixingManager.js +1290 -0
- package/liteav/extensions/MediaMixingManager/MediaMixingService.d.ts +60 -0
- package/liteav/extensions/MediaMixingManager/MediaMixingService.js +80 -0
- package/liteav/extensions/MediaMixingManager/StreamLayout/BaseStreamLayoutManager.d.ts +32 -0
- package/liteav/extensions/MediaMixingManager/StreamLayout/BaseStreamLayoutManager.js +114 -0
- package/liteav/extensions/MediaMixingManager/StreamLayout/CustomStreamLayoutManager.d.ts +11 -0
- package/liteav/extensions/MediaMixingManager/StreamLayout/CustomStreamLayoutManager.js +135 -0
- package/liteav/extensions/MediaMixingManager/StreamLayout/NoneStreamLayoutManager.d.ts +11 -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 +34 -0
- package/liteav/extensions/MediaMixingManager/StreamLayout/types.d.ts +25 -0
- package/liteav/extensions/MediaMixingManager/StreamLayout/types.js +2 -0
- package/liteav/extensions/MediaMixingManager/index.d.ts +4 -227
- package/liteav/extensions/MediaMixingManager/index.js +30 -589
- package/liteav/extensions/MediaMixingManager/types.d.ts +107 -0
- package/liteav/extensions/MediaMixingManager/types.js +26 -0
- package/liteav/trtc.d.ts +67 -13
- package/liteav/trtc.js +159 -61
- package/liteav/trtc_define.d.ts +29 -3
- package/liteav/trtc_define.js +97 -29
- package/liteav/utils.d.ts +27 -0
- package/liteav/utils.js +85 -1
- package/package.json +2 -2
- package/scripts/download.js +153 -169
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Rect, TRTCVideoFillMode } from "../trtc_define";
|
|
2
2
|
export declare type TRTCMediaInfo = {
|
|
3
3
|
id: string;
|
|
4
4
|
rect: Rect;
|
|
5
5
|
isSelected: boolean;
|
|
6
|
-
zOrder
|
|
6
|
+
zOrder: number;
|
|
7
7
|
origin: any;
|
|
8
8
|
};
|
|
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,19 +31,24 @@ 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;
|
|
51
|
+
removeAllMedia(): void;
|
|
49
52
|
on(event: string, func: (...args: any[]) => void): void;
|
|
50
53
|
off(event: string, func: (...args: any[]) => void): void;
|
|
51
54
|
destroy(): void;
|
|
@@ -54,6 +57,7 @@ declare class TRTCMediaMixingDesigner {
|
|
|
54
57
|
private initContainerMouseEventHander;
|
|
55
58
|
private initContainerResizeObserver;
|
|
56
59
|
private onPreviewAreaResize;
|
|
60
|
+
private updateWorkingArea;
|
|
57
61
|
private updatePreviewProperty;
|
|
58
62
|
private updateOverlay;
|
|
59
63
|
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,29 +52,44 @@ class TRTCMediaMixingDesigner {
|
|
|
75
52
|
this.initContainerResizeObserver();
|
|
76
53
|
}
|
|
77
54
|
updateOptions(options) {
|
|
78
|
-
if (
|
|
79
|
-
this.
|
|
80
|
-
|
|
81
|
-
if (resolutionMap.has(options.videoResolution)) {
|
|
82
|
-
const { width, height } = resolutionMap.get(options.videoResolution);
|
|
83
|
-
if (this.resMode === trtc_define_1.TRTCVideoResolutionMode.TRTCVideoResolutionModeLandscape) {
|
|
84
|
-
this.mixingVideoWidth = width;
|
|
85
|
-
this.mixingVideoHeight = height;
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
this.mixingVideoWidth = height;
|
|
89
|
-
this.mixingVideoHeight = width;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
55
|
+
if (this.mixingVideoWidth !== options.width || this.mixingVideoHeight !== options.height) {
|
|
56
|
+
this.mixingVideoWidth = options.width;
|
|
57
|
+
this.mixingVideoHeight = options.height;
|
|
93
58
|
this.updatePreviewProperty();
|
|
94
59
|
this.updateOverlay();
|
|
95
60
|
}
|
|
96
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();
|
|
68
|
+
this.updatePreviewProperty();
|
|
69
|
+
this.updateOverlay();
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
logger_1.default.error(`${this.logPrefix}setWorkingArea invalid parameter:`, relative);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
97
75
|
addMedia(media) {
|
|
98
|
-
|
|
76
|
+
// sort by zOrder desc
|
|
77
|
+
const length = this.mediaList.length;
|
|
78
|
+
let insertIndex = -1;
|
|
79
|
+
for (let i = 0; i < length; i++) {
|
|
80
|
+
if (media.zOrder >= this.mediaList[i].zOrder) {
|
|
81
|
+
insertIndex = i;
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (insertIndex >= 0) {
|
|
86
|
+
this.mediaList.splice(insertIndex, 0, media);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
this.mediaList.push(media);
|
|
90
|
+
}
|
|
99
91
|
if (media.isSelected) {
|
|
100
|
-
this.selectedMediaIndex = 0;
|
|
92
|
+
this.selectedMediaIndex = insertIndex >= 0 ? insertIndex : (this.mediaList.length - 1);
|
|
101
93
|
this.updateOverlay();
|
|
102
94
|
}
|
|
103
95
|
}
|
|
@@ -112,15 +104,24 @@ class TRTCMediaMixingDesigner {
|
|
|
112
104
|
}
|
|
113
105
|
}
|
|
114
106
|
updateMedia(media) {
|
|
115
|
-
|
|
107
|
+
let targetIndex = this.mediaList.findIndex(item => item.id === media.id);
|
|
116
108
|
if (targetIndex !== -1) {
|
|
109
|
+
const isZOrderChanged = media.zOrder !== this.mediaList[targetIndex].zOrder;
|
|
117
110
|
this.mediaList[targetIndex] = Object.assign({}, this.mediaList[targetIndex], media);
|
|
111
|
+
if (isZOrderChanged) {
|
|
112
|
+
this.mediaList.sort((a, b) => b.zOrder - a.zOrder);
|
|
113
|
+
targetIndex = this.mediaList.findIndex(item => item.id === media.id);
|
|
114
|
+
}
|
|
118
115
|
if (media.isSelected) {
|
|
119
116
|
this.selectedMediaIndex = targetIndex;
|
|
120
117
|
this.updateOverlay();
|
|
121
118
|
}
|
|
122
119
|
}
|
|
123
120
|
}
|
|
121
|
+
removeAllMedia() {
|
|
122
|
+
this.mediaList = [];
|
|
123
|
+
this.selectedMediaIndex = -1;
|
|
124
|
+
}
|
|
124
125
|
on(event, func) {
|
|
125
126
|
var _a;
|
|
126
127
|
(_a = this.eventEmitter) === null || _a === void 0 ? void 0 : _a.on(event, func);
|
|
@@ -194,50 +195,98 @@ class TRTCMediaMixingDesigner {
|
|
|
194
195
|
logger_1.default.log(`${this.logPrefix}onPreviewAreaResize:`, entries);
|
|
195
196
|
for (const entry of entries) {
|
|
196
197
|
if (entry.target === this.container) {
|
|
198
|
+
this.updateWorkingArea();
|
|
197
199
|
this.updatePreviewProperty();
|
|
198
200
|
this.updateOverlay();
|
|
199
201
|
break;
|
|
200
202
|
}
|
|
201
203
|
}
|
|
202
204
|
}
|
|
205
|
+
updateWorkingArea() {
|
|
206
|
+
if (this.relativeWorkingArea && this.container) {
|
|
207
|
+
const containerRect = this.container.getBoundingClientRect();
|
|
208
|
+
this.absoluteWorkingArea = {
|
|
209
|
+
left: this.relativeWorkingArea.left * containerRect.width,
|
|
210
|
+
top: this.relativeWorkingArea.top * containerRect.height,
|
|
211
|
+
right: this.relativeWorkingArea.right * containerRect.width,
|
|
212
|
+
bottom: this.relativeWorkingArea.bottom * containerRect.height,
|
|
213
|
+
width: (this.relativeWorkingArea.right - this.relativeWorkingArea.left) * containerRect.width,
|
|
214
|
+
height: (this.relativeWorkingArea.bottom - this.relativeWorkingArea.top) * containerRect.height,
|
|
215
|
+
};
|
|
216
|
+
logger_1.default.log(`${this.logPrefix}updateWorkingArea absolute working area:`, JSON.stringify(this.absoluteWorkingArea));
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
logger_1.default.error(`${this.logPrefix}updateWorkingArea no data:`, this.relativeWorkingArea, this.container);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
203
222
|
updatePreviewProperty() {
|
|
204
|
-
if (this.
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
223
|
+
if (this.absoluteWorkingArea) {
|
|
224
|
+
if (this.mixingVideoWidth <= 0 || this.mixingVideoHeight <= 0) {
|
|
225
|
+
logger_1.default.error(`${this.logPrefix}updatePreviewProperty failed, mixingVideoWidth or mixingVideoHeight is zero`);
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
const workingAreaWidth = this.absoluteWorkingArea.width;
|
|
229
|
+
const workingAreaHeight = this.absoluteWorkingArea.height;
|
|
230
|
+
const widthScale = workingAreaWidth / this.mixingVideoWidth;
|
|
231
|
+
const heightScale = workingAreaHeight / this.mixingVideoHeight;
|
|
232
|
+
if (this.fillMode === trtc_define_1.TRTCVideoFillMode.TRTCVideoFillMode_Fill) {
|
|
233
|
+
this.previewScale = widthScale > heightScale ? widthScale : heightScale;
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
this.fillMode = trtc_define_1.TRTCVideoFillMode.TRTCVideoFillMode_Fit;
|
|
237
|
+
this.previewScale = widthScale > heightScale ? heightScale : widthScale;
|
|
238
|
+
}
|
|
210
239
|
this.previewWidth = this.mixingVideoWidth * this.previewScale;
|
|
211
240
|
this.previewHeight = this.mixingVideoHeight * this.previewScale;
|
|
212
|
-
this.previewLeft = (
|
|
213
|
-
this.previewTop = (
|
|
241
|
+
this.previewLeft = (workingAreaWidth - this.previewWidth) / 2;
|
|
242
|
+
this.previewTop = (workingAreaHeight - this.previewHeight) / 2;
|
|
243
|
+
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
244
|
}
|
|
215
245
|
else {
|
|
216
|
-
logger_1.default.error(`${this.logPrefix}
|
|
246
|
+
logger_1.default.error(`${this.logPrefix}updatePreviewProperty failed, no HTML element to display`);
|
|
217
247
|
}
|
|
218
248
|
}
|
|
219
249
|
updateOverlay() {
|
|
220
250
|
if (this.moveAndResizeOverlay) {
|
|
221
|
-
let left =
|
|
222
|
-
let top =
|
|
223
|
-
let width =
|
|
224
|
-
let height =
|
|
251
|
+
let left = this.absoluteWorkingArea.left + this.previewLeft;
|
|
252
|
+
let top = this.absoluteWorkingArea.top + this.previewTop;
|
|
253
|
+
let width = 0;
|
|
254
|
+
let height = 0;
|
|
225
255
|
if (this.selectedMediaIndex >= 0) {
|
|
256
|
+
logger_1.default.debug(`${this.logPrefix}updateOverlay: selected media:`, this.mediaList[this.selectedMediaIndex].rect);
|
|
226
257
|
const selectedPreviewRect = {
|
|
227
258
|
left: this.mediaList[this.selectedMediaIndex].rect.left * this.previewScale,
|
|
228
259
|
top: this.mediaList[this.selectedMediaIndex].rect.top * this.previewScale,
|
|
229
260
|
right: this.mediaList[this.selectedMediaIndex].rect.right * this.previewScale,
|
|
230
261
|
bottom: this.mediaList[this.selectedMediaIndex].rect.bottom * this.previewScale
|
|
231
262
|
};
|
|
232
|
-
left =
|
|
233
|
-
top =
|
|
234
|
-
width =
|
|
235
|
-
height =
|
|
263
|
+
left = this.absoluteWorkingArea.left + this.previewLeft + selectedPreviewRect.left;
|
|
264
|
+
top = this.absoluteWorkingArea.top + this.previewTop + selectedPreviewRect.top;
|
|
265
|
+
width = selectedPreviewRect.right - selectedPreviewRect.left;
|
|
266
|
+
height = selectedPreviewRect.bottom - selectedPreviewRect.top;
|
|
236
267
|
}
|
|
237
|
-
|
|
238
|
-
this.
|
|
239
|
-
|
|
240
|
-
|
|
268
|
+
let renderScale = 1;
|
|
269
|
+
if (this.container) {
|
|
270
|
+
const containerLayoutWidth = this.container.offsetWidth;
|
|
271
|
+
const containerRenderWidth = Math.round(this.container.getBoundingClientRect().width);
|
|
272
|
+
if (containerLayoutWidth !== containerRenderWidth) {
|
|
273
|
+
logger_1.default.warn(`${this.logPrefix}updateOverlay container layout width: ${containerLayoutWidth} container render width: ${containerRenderWidth}`);
|
|
274
|
+
renderScale = containerRenderWidth / containerLayoutWidth;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
this.moveAndResizeOverlay.style.left = `${left}px`;
|
|
278
|
+
this.moveAndResizeOverlay.style.top = `${top}px`;
|
|
279
|
+
this.moveAndResizeOverlay.style.width = `${width}px`;
|
|
280
|
+
this.moveAndResizeOverlay.style.height = `${height}px`;
|
|
281
|
+
if (renderScale !== 1) {
|
|
282
|
+
this.moveAndResizeOverlay.style.transform = `scale(${1 / renderScale})`;
|
|
283
|
+
this.moveAndResizeOverlay.style.transformOrigin = `-${left}px -${top}px`; // Why?
|
|
284
|
+
}
|
|
285
|
+
else {
|
|
286
|
+
this.moveAndResizeOverlay.style.transform = 'none';
|
|
287
|
+
this.moveAndResizeOverlay.style.transformOrigin = 'none';
|
|
288
|
+
}
|
|
289
|
+
logger_1.default.debug(`${this.logPrefix}updateOverlay: ${left} ${top} ${width} ${height} ${renderScale}`);
|
|
241
290
|
}
|
|
242
291
|
}
|
|
243
292
|
onMove(left, top) {
|
|
@@ -247,10 +296,10 @@ class TRTCMediaMixingDesigner {
|
|
|
247
296
|
if (target && this.moveAndResizeOverlay) {
|
|
248
297
|
// calc new preview rect
|
|
249
298
|
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,
|
|
299
|
+
left: left - this.absoluteWorkingArea.left - this.previewLeft,
|
|
300
|
+
top: top - this.absoluteWorkingArea.top - this.previewTop,
|
|
301
|
+
right: left - this.absoluteWorkingArea.left - this.previewLeft + this.moveAndResizeOverlay.offsetWidth,
|
|
302
|
+
bottom: top - this.absoluteWorkingArea.top - this.previewTop + this.moveAndResizeOverlay.offsetHeight,
|
|
254
303
|
};
|
|
255
304
|
this.doAdsorption(newPreviewRect);
|
|
256
305
|
// calc new mixing rect
|
|
@@ -260,6 +309,8 @@ class TRTCMediaMixingDesigner {
|
|
|
260
309
|
right: Math.round(newPreviewRect.right / this.previewScale),
|
|
261
310
|
bottom: Math.round(newPreviewRect.bottom / this.previewScale),
|
|
262
311
|
};
|
|
312
|
+
logger_1.default.debug(`${this.logPrefix}onMove new preview rect: ${JSON.stringify(newPreviewRect)}`);
|
|
313
|
+
logger_1.default.debug(`${this.logPrefix}onMove new rect in mixing: ${JSON.stringify(newRectInMixing)}`);
|
|
263
314
|
(_a = this.eventEmitter) === null || _a === void 0 ? void 0 : _a.emit('onSourceMoved', Object.assign({}, target), newRectInMixing);
|
|
264
315
|
}
|
|
265
316
|
else {
|
|
@@ -292,10 +343,10 @@ class TRTCMediaMixingDesigner {
|
|
|
292
343
|
if (target) {
|
|
293
344
|
// calc new preview rect
|
|
294
345
|
const newPreviewRect = {
|
|
295
|
-
left: left - this.previewLeft,
|
|
296
|
-
top: top - this.previewTop,
|
|
297
|
-
right: left - this.previewLeft + width,
|
|
298
|
-
bottom: top - this.previewTop + height,
|
|
346
|
+
left: left - this.absoluteWorkingArea.left - this.previewLeft,
|
|
347
|
+
top: top - this.absoluteWorkingArea.top - this.previewTop,
|
|
348
|
+
right: left - this.absoluteWorkingArea.left - this.previewLeft + width,
|
|
349
|
+
bottom: top - this.absoluteWorkingArea.top - this.previewTop + height,
|
|
299
350
|
};
|
|
300
351
|
// calc new mixing rect
|
|
301
352
|
const newRectInMixing = {
|
|
@@ -335,8 +386,8 @@ class TRTCMediaMixingDesigner {
|
|
|
335
386
|
// calc click point coordinates in mix video image
|
|
336
387
|
logger_1.default.log(`${this.logPrefix}onContainerMousedown mix video image clicked`);
|
|
337
388
|
const containerBounds = this.container.getBoundingClientRect();
|
|
338
|
-
const xInPreviewImage = event.clientX - containerBounds.
|
|
339
|
-
const yInPreviewImage = event.clientY - containerBounds.
|
|
389
|
+
const xInPreviewImage = event.clientX - containerBounds.left - this.absoluteWorkingArea.left - this.previewLeft;
|
|
390
|
+
const yInPreviewImage = event.clientY - containerBounds.top - this.absoluteWorkingArea.top - this.previewTop;
|
|
340
391
|
const xInImage = xInPreviewImage / this.previewScale;
|
|
341
392
|
const yInImage = yInPreviewImage / this.previewScale;
|
|
342
393
|
logger_1.default.log(`${this.logPrefix}onContainerMousedown click point coordinates in mix video:`, xInPreviewImage, yInPreviewImage, xInImage, yInImage);
|
|
@@ -459,7 +510,12 @@ class TRTCMediaMixingDesigner {
|
|
|
459
510
|
var _a;
|
|
460
511
|
logger_1.default.log(`${this.logPrefix}onRightButtonClicked:`, event.target, event.currentTarget, event.buttons);
|
|
461
512
|
event.preventDefault();
|
|
462
|
-
(_a = this.eventEmitter) === null || _a === void 0 ? void 0 : _a.emit('onRightButtonClicked', Object.assign({}, this.mediaList[this.selectedMediaIndex])
|
|
513
|
+
(_a = this.eventEmitter) === null || _a === void 0 ? void 0 : _a.emit('onRightButtonClicked', Object.assign({}, this.mediaList[this.selectedMediaIndex]), {
|
|
514
|
+
windowX: event.clientX,
|
|
515
|
+
windowY: event.clientY,
|
|
516
|
+
screenX: event.screenX,
|
|
517
|
+
screenY: event.screenY
|
|
518
|
+
});
|
|
463
519
|
}
|
|
464
520
|
}
|
|
465
521
|
exports.default = TRTCMediaMixingDesigner;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
declare class DevicePixelRatioObserver {
|
|
2
|
+
private mediaQueryString;
|
|
3
|
+
private mediaQuery;
|
|
4
|
+
private eventEmitter;
|
|
5
|
+
constructor();
|
|
6
|
+
destroy(): void;
|
|
7
|
+
on(event: string, func: (...args: any[]) => void): void;
|
|
8
|
+
off(event: string, func: (...args: any[]) => void): void;
|
|
9
|
+
private onPixelRatioChanged;
|
|
10
|
+
}
|
|
11
|
+
declare const devicePixelRationObserver: DevicePixelRatioObserver;
|
|
12
|
+
export default devicePixelRationObserver;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const events_1 = require("events");
|
|
4
|
+
class DevicePixelRatioObserver {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.mediaQueryString = `(resolution: ${window.devicePixelRatio}dppx)`;
|
|
7
|
+
this.mediaQuery = window.matchMedia(this.mediaQueryString);
|
|
8
|
+
this.eventEmitter = new events_1.EventEmitter();
|
|
9
|
+
this.onPixelRatioChanged = this.onPixelRatioChanged.bind(this);
|
|
10
|
+
this.mediaQuery.addEventListener('change', this.onPixelRatioChanged);
|
|
11
|
+
}
|
|
12
|
+
destroy() {
|
|
13
|
+
var _a;
|
|
14
|
+
(_a = this.mediaQuery) === null || _a === void 0 ? void 0 : _a.removeEventListener('change', this.onPixelRatioChanged);
|
|
15
|
+
this.mediaQuery = null;
|
|
16
|
+
this.eventEmitter = null;
|
|
17
|
+
}
|
|
18
|
+
on(event, func) {
|
|
19
|
+
var _a;
|
|
20
|
+
(_a = this.eventEmitter) === null || _a === void 0 ? void 0 : _a.on(event, func);
|
|
21
|
+
}
|
|
22
|
+
off(event, func) {
|
|
23
|
+
var _a;
|
|
24
|
+
(_a = this.eventEmitter) === null || _a === void 0 ? void 0 : _a.off(event, func);
|
|
25
|
+
}
|
|
26
|
+
onPixelRatioChanged() {
|
|
27
|
+
var _a;
|
|
28
|
+
(_a = this.eventEmitter) === null || _a === void 0 ? void 0 : _a.emit('change');
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const devicePixelRationObserver = new DevicePixelRatioObserver();
|
|
32
|
+
exports.default = devicePixelRationObserver;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare class PromiseStore {
|
|
2
|
+
private logPrefix;
|
|
3
|
+
private promiseStore;
|
|
4
|
+
constructor();
|
|
5
|
+
addPromise(key: string, resolve: (data: void | PromiseLike<void>) => void, reject: (reason?: any) => void): void;
|
|
6
|
+
resolvePromise(key: string, value: void | PromiseLike<void>): boolean;
|
|
7
|
+
rejectPromise(key: string, reason?: any): boolean;
|
|
8
|
+
destroy(): void;
|
|
9
|
+
}
|
|
10
|
+
export default PromiseStore;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class PromiseStore {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.logPrefix = '[PromiseStore]';
|
|
6
|
+
this.promiseStore = new Map();
|
|
7
|
+
}
|
|
8
|
+
addPromise(key, resolve, reject) {
|
|
9
|
+
if (!this.promiseStore.has(key)) {
|
|
10
|
+
this.promiseStore.set(key, []);
|
|
11
|
+
}
|
|
12
|
+
const storedPromises = this.promiseStore.get(key);
|
|
13
|
+
storedPromises === null || storedPromises === void 0 ? void 0 : storedPromises.push({
|
|
14
|
+
resolve,
|
|
15
|
+
reject
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
resolvePromise(key, value) {
|
|
19
|
+
var _a;
|
|
20
|
+
const storedPromises = (_a = this.promiseStore) === null || _a === void 0 ? void 0 : _a.get(key);
|
|
21
|
+
if (storedPromises) {
|
|
22
|
+
storedPromises.forEach(({ resolve }) => {
|
|
23
|
+
resolve(value);
|
|
24
|
+
});
|
|
25
|
+
this.promiseStore.delete(key);
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
rejectPromise(key, reason) {
|
|
33
|
+
var _a;
|
|
34
|
+
const storedPromises = (_a = this.promiseStore) === null || _a === void 0 ? void 0 : _a.get(key);
|
|
35
|
+
if (storedPromises) {
|
|
36
|
+
storedPromises.forEach(({ reject }) => {
|
|
37
|
+
reject(reason);
|
|
38
|
+
});
|
|
39
|
+
this.promiseStore.delete(key);
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
destroy() {
|
|
47
|
+
this.promiseStore.forEach((value) => {
|
|
48
|
+
value.forEach(({ reject }) => {
|
|
49
|
+
reject({
|
|
50
|
+
code: Number.NEGATIVE_INFINITY,
|
|
51
|
+
message: 'Instance destroyed, reject all pending promises',
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
this.promiseStore.clear();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.default = PromiseStore;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const LOCAL_USER_ID = "";
|