trtc-electron-sdk 12.9.708-beta.0 → 13.0.119-beta.0
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/Resizable.js +0 -1
- package/liteav/MediaMixingDesigner/index.js +25 -45
- package/liteav/extensions/DeviceManager/index.js +4 -0
- package/liteav/extensions/MediaMixingManager/MediaMixingManager.d.ts +1 -0
- package/liteav/extensions/MediaMixingManager/MediaMixingManager.js +44 -35
- package/liteav/trtc.d.ts +1 -3
- package/liteav/trtc.js +3 -4
- package/liteav/utils.d.ts +4 -0
- package/liteav/utils.js +37 -1
- package/package.json +1 -1
- package/scripts/copy-sdk.js +8 -0
|
@@ -227,7 +227,6 @@ class Resizable {
|
|
|
227
227
|
this.originLeft = window.parseInt(resizeTargetStyle.left);
|
|
228
228
|
this.originWidth = this.resizeTarget.offsetWidth;
|
|
229
229
|
this.originHeight = this.resizeTarget.offsetHeight;
|
|
230
|
-
logger_1.default.debug("resize origin:", this.originTop, this.originLeft, this.originWidth, this.originHeight);
|
|
231
230
|
}
|
|
232
231
|
else {
|
|
233
232
|
logger_1.default.error(`${this.logPrefix}mouseDown 'resizeTarget' is null`);
|
|
@@ -63,7 +63,6 @@ class TRTCMediaMixingDesigner {
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
setWorkingArea(relative, fillMode = trtc_define_1.TRTCVideoFillMode.TRTCVideoFillMode_Fit) {
|
|
66
|
-
logger_1.default.log(`${this.logPrefix}setWorkingArea:`, JSON.stringify(relative), `fillMode:${fillMode}`);
|
|
67
66
|
if (relative) {
|
|
68
67
|
this.relativeWorkingArea = Object.assign({}, relative);
|
|
69
68
|
this.fillMode = fillMode;
|
|
@@ -159,7 +158,7 @@ class TRTCMediaMixingDesigner {
|
|
|
159
158
|
(_a = this.eventEmitter) === null || _a === void 0 ? void 0 : _a.off(event, func);
|
|
160
159
|
}
|
|
161
160
|
destroy() {
|
|
162
|
-
var _a, _b, _c, _d
|
|
161
|
+
var _a, _b, _c, _d;
|
|
163
162
|
if (this.resizeObserver) {
|
|
164
163
|
if (this.container) {
|
|
165
164
|
this.resizeObserver.unobserve(this.container);
|
|
@@ -172,9 +171,9 @@ class TRTCMediaMixingDesigner {
|
|
|
172
171
|
this.movableHandler = null;
|
|
173
172
|
this.resizableHandler = null;
|
|
174
173
|
(_c = this.container) === null || _c === void 0 ? void 0 : _c.removeEventListener('contextmenu', this.onRightButtonClicked, false);
|
|
175
|
-
|
|
174
|
+
document.removeEventListener("mousedown", this.onContainerMousedown, false);
|
|
176
175
|
if (this.moveAndResizeOverlay) {
|
|
177
|
-
(
|
|
176
|
+
(_d = this.container) === null || _d === void 0 ? void 0 : _d.removeChild(this.moveAndResizeOverlay);
|
|
178
177
|
this.moveAndResizeOverlay = null;
|
|
179
178
|
}
|
|
180
179
|
this.container = null;
|
|
@@ -205,7 +204,7 @@ class TRTCMediaMixingDesigner {
|
|
|
205
204
|
this.onContainerMousedown = this.onContainerMousedown.bind(this);
|
|
206
205
|
this.onContainerMousemove = this.onContainerMousemove.bind(this);
|
|
207
206
|
this.onContainerMouseup = this.onContainerMouseup.bind(this);
|
|
208
|
-
|
|
207
|
+
document.addEventListener("mousedown", this.onContainerMousedown, false);
|
|
209
208
|
this.onRightButtonClicked = this.onRightButtonClicked.bind(this);
|
|
210
209
|
this.container.addEventListener('contextmenu', this.onRightButtonClicked, false);
|
|
211
210
|
}
|
|
@@ -221,7 +220,6 @@ class TRTCMediaMixingDesigner {
|
|
|
221
220
|
}
|
|
222
221
|
}
|
|
223
222
|
onPreviewAreaResize(entries) {
|
|
224
|
-
logger_1.default.log(`${this.logPrefix}onPreviewAreaResize:`, entries);
|
|
225
223
|
for (const entry of entries) {
|
|
226
224
|
if (entry.target === this.container) {
|
|
227
225
|
this.updateWorkingArea();
|
|
@@ -242,7 +240,6 @@ class TRTCMediaMixingDesigner {
|
|
|
242
240
|
width: (this.relativeWorkingArea.right - this.relativeWorkingArea.left) * containerRect.width,
|
|
243
241
|
height: (this.relativeWorkingArea.bottom - this.relativeWorkingArea.top) * containerRect.height,
|
|
244
242
|
};
|
|
245
|
-
logger_1.default.log(`${this.logPrefix}updateWorkingArea absolute working area:`, JSON.stringify(this.absoluteWorkingArea));
|
|
246
243
|
}
|
|
247
244
|
else {
|
|
248
245
|
logger_1.default.error(`${this.logPrefix}updateWorkingArea no data:`, this.relativeWorkingArea, this.container);
|
|
@@ -269,7 +266,6 @@ class TRTCMediaMixingDesigner {
|
|
|
269
266
|
this.previewHeight = this.mixingVideoHeight * this.previewScale;
|
|
270
267
|
this.previewLeft = (workingAreaWidth - this.previewWidth) / 2;
|
|
271
268
|
this.previewTop = (workingAreaHeight - this.previewHeight) / 2;
|
|
272
|
-
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}`);
|
|
273
269
|
}
|
|
274
270
|
else {
|
|
275
271
|
logger_1.default.error(`${this.logPrefix}updatePreviewProperty failed, no HTML element to display`);
|
|
@@ -282,7 +278,6 @@ class TRTCMediaMixingDesigner {
|
|
|
282
278
|
let width = 0;
|
|
283
279
|
let height = 0;
|
|
284
280
|
if (this.selectedMediaIndex >= 0) {
|
|
285
|
-
logger_1.default.debug(`${this.logPrefix}updateOverlay: selected media:`, this.mediaList[this.selectedMediaIndex].rect);
|
|
286
281
|
this.moveAndResizeOverlay.style.display = 'block';
|
|
287
282
|
const selectedPreviewRect = {
|
|
288
283
|
left: this.mediaList[this.selectedMediaIndex].rect.left * this.previewScale,
|
|
@@ -319,12 +314,10 @@ class TRTCMediaMixingDesigner {
|
|
|
319
314
|
this.moveAndResizeOverlay.style.transform = 'none';
|
|
320
315
|
this.moveAndResizeOverlay.style.transformOrigin = 'none';
|
|
321
316
|
}
|
|
322
|
-
logger_1.default.debug(`${this.logPrefix}updateOverlay: ${left} ${top} ${width} ${height} ${renderScale}`);
|
|
323
317
|
}
|
|
324
318
|
}
|
|
325
319
|
onMove(left, top) {
|
|
326
320
|
var _a;
|
|
327
|
-
logger_1.default.log(`${this.logPrefix}onMove: ${left} ${top}`);
|
|
328
321
|
const target = this.mediaList[this.selectedMediaIndex];
|
|
329
322
|
if (target && this.moveAndResizeOverlay) {
|
|
330
323
|
// calc new preview rect
|
|
@@ -342,8 +335,6 @@ class TRTCMediaMixingDesigner {
|
|
|
342
335
|
right: Math.round(newPreviewRect.right / this.previewScale),
|
|
343
336
|
bottom: Math.round(newPreviewRect.bottom / this.previewScale),
|
|
344
337
|
};
|
|
345
|
-
logger_1.default.debug(`${this.logPrefix}onMove new preview rect: ${JSON.stringify(newPreviewRect)}`);
|
|
346
|
-
logger_1.default.debug(`${this.logPrefix}onMove new rect in mixing: ${JSON.stringify(newRectInMixing)}`);
|
|
347
338
|
(_a = this.eventEmitter) === null || _a === void 0 ? void 0 : _a.emit('onSourceMoved', Object.assign({}, target), newRectInMixing);
|
|
348
339
|
}
|
|
349
340
|
else {
|
|
@@ -371,7 +362,6 @@ class TRTCMediaMixingDesigner {
|
|
|
371
362
|
}
|
|
372
363
|
onResize(left, top, width, height) {
|
|
373
364
|
var _a;
|
|
374
|
-
logger_1.default.log(`${this.logPrefix}onResize: ${left} ${top} ${width} ${height}`);
|
|
375
365
|
const target = this.mediaList[this.selectedMediaIndex];
|
|
376
366
|
if (target) {
|
|
377
367
|
// calc new preview rect
|
|
@@ -412,40 +402,38 @@ class TRTCMediaMixingDesigner {
|
|
|
412
402
|
(_a = this.eventEmitter) === null || _a === void 0 ? void 0 : _a.emit('onSourceSelected', media ? Object.assign({}, media) : null);
|
|
413
403
|
}
|
|
414
404
|
onContainerMousedown(event) {
|
|
415
|
-
logger_1.default.log(`${this.logPrefix}onContainerMousedown event:`, event, event.target, event.currentTarget);
|
|
416
405
|
const target = event.target;
|
|
417
406
|
this.eventButton = event.button;
|
|
418
407
|
if (target && this.container) {
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
408
|
+
if (this.container.contains(target)) {
|
|
409
|
+
// calc click point coordinates in mix video image
|
|
410
|
+
const containerBounds = this.container.getBoundingClientRect();
|
|
411
|
+
const xInPreviewImage = event.clientX - containerBounds.left - this.absoluteWorkingArea.left - this.previewLeft;
|
|
412
|
+
const yInPreviewImage = event.clientY - containerBounds.top - this.absoluteWorkingArea.top - this.previewTop;
|
|
413
|
+
const xInImage = xInPreviewImage / this.previewScale;
|
|
414
|
+
const yInImage = yInPreviewImage / this.previewScale;
|
|
415
|
+
for (let i = 0; i < this.mediaList.length; i++) {
|
|
416
|
+
const item = this.mediaList[i];
|
|
417
|
+
if (item.rect &&
|
|
418
|
+
xInImage >= item.rect.left &&
|
|
419
|
+
xInImage <= item.rect.right &&
|
|
420
|
+
yInImage >= item.rect.top &&
|
|
421
|
+
yInImage <= item.rect.bottom) {
|
|
422
|
+
this.clickedMediaSources.push(item);
|
|
423
|
+
if (this.mediaList[this.selectedMediaIndex]) {
|
|
424
|
+
if (item.id === this.mediaList[this.selectedMediaIndex].id) {
|
|
425
|
+
this.oldSelectedIndex = this.clickedMediaSources.length - 1;
|
|
426
|
+
}
|
|
438
427
|
}
|
|
439
428
|
}
|
|
440
429
|
}
|
|
430
|
+
this.mousedownLeft = event.screenX;
|
|
431
|
+
this.mousedownTop = event.screenY;
|
|
441
432
|
}
|
|
442
|
-
this.mousedownLeft = event.screenX;
|
|
443
|
-
this.mousedownTop = event.screenY;
|
|
444
433
|
if (this.clickedMediaSources.length > 0) {
|
|
445
434
|
if (this.eventButton === 2 && this.oldSelectedIndex === -1) {
|
|
446
435
|
// select first media source
|
|
447
436
|
this.newSelected = this.clickedMediaSources[0];
|
|
448
|
-
logger_1.default.log(`${this.logPrefix}onContainerMousedown find clicked media source:`, this.newSelected);
|
|
449
437
|
// mediaSourcesStore.setSelectedMediaKey(newSelected);
|
|
450
438
|
this.emitOnSelect(this.newSelected);
|
|
451
439
|
this.clickedMediaSources.splice(0, this.clickedMediaSources.length);
|
|
@@ -457,7 +445,6 @@ class TRTCMediaMixingDesigner {
|
|
|
457
445
|
}
|
|
458
446
|
else {
|
|
459
447
|
this.newSelected = null;
|
|
460
|
-
logger_1.default.log(`${this.logPrefix}onContainerMousedown find clicked media source:`, this.newSelected);
|
|
461
448
|
this.emitOnSelect(null);
|
|
462
449
|
this.mousedownLeft = null;
|
|
463
450
|
this.mousedownTop = null;
|
|
@@ -475,14 +462,12 @@ class TRTCMediaMixingDesigner {
|
|
|
475
462
|
if (Math.abs(leftMovedDistance) >= MIN_MOVE_DISTANCE || Math.abs(topMovedDistance) >= MIN_MOVE_DISTANCE) {
|
|
476
463
|
if (this.oldSelectedIndex >= 0) {
|
|
477
464
|
// move or resize old selected media source
|
|
478
|
-
logger_1.default.log(`${this.logPrefix}onContainerMousemove move or resize old selected media source, clear data:`, this.clickedMediaSources, this.oldSelectedIndex);
|
|
479
465
|
this.clickedMediaSources.splice(0, this.clickedMediaSources.length);
|
|
480
466
|
this.oldSelectedIndex = -1;
|
|
481
467
|
}
|
|
482
468
|
else if (this.clickedMediaSources.length > 0) {
|
|
483
469
|
// select first media source
|
|
484
470
|
this.newSelected = this.clickedMediaSources[0];
|
|
485
|
-
logger_1.default.log(`${this.logPrefix}onContainerMousemove find clicked media source:`, this.newSelected);
|
|
486
471
|
this.emitOnSelect(this.newSelected);
|
|
487
472
|
this.clickedMediaSources.splice(0, this.clickedMediaSources.length);
|
|
488
473
|
// 支持 mousedown 选中媒体源和 mousemove 移动媒体源同时触发
|
|
@@ -499,7 +484,6 @@ class TRTCMediaMixingDesigner {
|
|
|
499
484
|
onContainerMouseup(event) {
|
|
500
485
|
document.removeEventListener("mousemove", this.onContainerMousemove, false);
|
|
501
486
|
document.removeEventListener("mouseup", this.onContainerMouseup, false);
|
|
502
|
-
logger_1.default.log(`${this.logPrefix}onContainerMouseup data:`, this.clickedMediaSources, this.oldSelectedIndex);
|
|
503
487
|
const target = event.target;
|
|
504
488
|
if (target && this.container) {
|
|
505
489
|
if (this.clickedMediaSources.length > 0) {
|
|
@@ -508,7 +492,6 @@ class TRTCMediaMixingDesigner {
|
|
|
508
492
|
// select next zOrder media source
|
|
509
493
|
const newSelectedIndex = (this.oldSelectedIndex + 1) % this.clickedMediaSources.length;
|
|
510
494
|
this.newSelected = this.clickedMediaSources[newSelectedIndex];
|
|
511
|
-
logger_1.default.log(`${this.logPrefix}onContainerMouseup find clicked media source:`, this.newSelected);
|
|
512
495
|
this.emitOnSelect(this.newSelected);
|
|
513
496
|
}
|
|
514
497
|
else {
|
|
@@ -519,7 +502,6 @@ class TRTCMediaMixingDesigner {
|
|
|
519
502
|
else {
|
|
520
503
|
// select first media source
|
|
521
504
|
this.newSelected = this.clickedMediaSources[0];
|
|
522
|
-
logger_1.default.log(`${this.logPrefix}onContainerMouseup find clicked media source:`, this.newSelected);
|
|
523
505
|
this.emitOnSelect(this.newSelected);
|
|
524
506
|
}
|
|
525
507
|
}
|
|
@@ -529,7 +511,6 @@ class TRTCMediaMixingDesigner {
|
|
|
529
511
|
}
|
|
530
512
|
else {
|
|
531
513
|
// un-select current media source
|
|
532
|
-
logger_1.default.log(`${this.logPrefix}onContainerMouseup click outside of mixing video image`);
|
|
533
514
|
this.emitOnSelect(null);
|
|
534
515
|
}
|
|
535
516
|
this.mousedownLeft = null;
|
|
@@ -541,7 +522,6 @@ class TRTCMediaMixingDesigner {
|
|
|
541
522
|
}
|
|
542
523
|
onRightButtonClicked(event) {
|
|
543
524
|
var _a;
|
|
544
|
-
logger_1.default.log(`${this.logPrefix}onRightButtonClicked:`, event.target, event.currentTarget, event.buttons);
|
|
545
525
|
event.preventDefault();
|
|
546
526
|
(_a = this.eventEmitter) === null || _a === void 0 ? void 0 : _a.emit('onRightButtonClicked', Object.assign({}, this.mediaList[this.selectedMediaIndex]), {
|
|
547
527
|
windowX: event.clientX,
|
|
@@ -7,6 +7,7 @@ exports.TRTCDeviceManager = void 0;
|
|
|
7
7
|
const events_1 = require("events");
|
|
8
8
|
const trtc_define_1 = require("../../trtc_define");
|
|
9
9
|
const logger_1 = __importDefault(require("../../logger"));
|
|
10
|
+
const utils_1 = require("../../utils");
|
|
10
11
|
const NodeTRTCEngine = require('../../../build/Release/trtc_electron_sdk.node');
|
|
11
12
|
/**
|
|
12
13
|
* 设备管理器
|
|
@@ -456,6 +457,9 @@ class TRTCDeviceManager {
|
|
|
456
457
|
// ****** 这一部分接口暴露不合理,暂时通过 TRTCMediaMixingManager 暴露给用户 **************/
|
|
457
458
|
startCameraDeviceTest(windowID, rect) {
|
|
458
459
|
logger_1.default.debug(`${this.logPrefix}startCameraDeviceTest`, windowID, rect);
|
|
460
|
+
if (!(0, utils_1.isWindows)()) {
|
|
461
|
+
return Promise.resolve(0);
|
|
462
|
+
}
|
|
459
463
|
let newWindowID = 0;
|
|
460
464
|
if (windowID instanceof Uint8Array) {
|
|
461
465
|
for (let i = windowID.length - 1; i >= 0; i--) {
|
|
@@ -262,6 +262,7 @@ export declare class TRTCMediaMixingManager implements ITRTCMediaMixingManager {
|
|
|
262
262
|
setCameraCaptureParam(cameraID: string, params: TRTCCameraCaptureParams): void;
|
|
263
263
|
/**
|
|
264
264
|
* 设置手机投屏参数
|
|
265
|
+
* @private
|
|
265
266
|
* @param phoneMirrorSourceId {string} - 手机投屏媒体源 ID
|
|
266
267
|
* @param param {TRTCPhoneMirrorParam} - 手机投屏参数
|
|
267
268
|
*/
|
|
@@ -73,6 +73,10 @@ const TRTCMediaSourceType_HACK_JSDOC = {
|
|
|
73
73
|
kImage: 2,
|
|
74
74
|
/** 手机投屏 */
|
|
75
75
|
kPhoneMirror: 4,
|
|
76
|
+
/** 在线视频 */
|
|
77
|
+
kOnlineVideo: 5,
|
|
78
|
+
/** 本地视频文件 */
|
|
79
|
+
kVideoFile: 6,
|
|
76
80
|
};
|
|
77
81
|
/**
|
|
78
82
|
* 手机投屏媒体源参数
|
|
@@ -320,7 +324,7 @@ class TRTCMediaMixingManager {
|
|
|
320
324
|
mirrorType: trtc_define_1.TRTCVideoMirrorType.TRTCVideoMirrorType_Auto,
|
|
321
325
|
};
|
|
322
326
|
if (this.autoControlServer) {
|
|
323
|
-
this.startMediaMixingServer()
|
|
327
|
+
this.startMediaMixingServer('', TRTCMediaMixingServerMode.Embedded)
|
|
324
328
|
.then(() => {
|
|
325
329
|
logger_1.default.info(`${this.logPrefix}startMediaMixingServer success.`);
|
|
326
330
|
})
|
|
@@ -494,7 +498,7 @@ class TRTCMediaMixingManager {
|
|
|
494
498
|
else {
|
|
495
499
|
realWindowID = windowID;
|
|
496
500
|
}
|
|
497
|
-
this.windowID = realWindowID;
|
|
501
|
+
this.windowID = (0, utils_1.isWindows)() ? realWindowID : 0;
|
|
498
502
|
if (this.windowID !== 0 && viewOrRegion !== null) {
|
|
499
503
|
yield this.previewInNativeWindow(viewOrRegion);
|
|
500
504
|
}
|
|
@@ -512,34 +516,36 @@ class TRTCMediaMixingManager {
|
|
|
512
516
|
* @returns {Promise<void>}
|
|
513
517
|
*/
|
|
514
518
|
addMediaSource(mediaSource) {
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
const newMediaSource = (0, utils_1.safelyParse)(JSON.stringify(mediaSource));
|
|
524
|
-
if (newMediaSource.isSelected) {
|
|
525
|
-
const oldSelectedIndex = this.findSelectedMediaSource();
|
|
526
|
-
if (oldSelectedIndex !== -1) {
|
|
527
|
-
this.unselectMediaSource(oldSelectedIndex);
|
|
519
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
520
|
+
logger_1.default.log(`${this.logPrefix}addMediaSource:`, mediaSource);
|
|
521
|
+
const index = this.findMediaSourceIndex(mediaSource);
|
|
522
|
+
if (index !== -1) {
|
|
523
|
+
return Promise.reject({
|
|
524
|
+
code: types_1.TRTCMediaMixingErrorCode.InvalidParams,
|
|
525
|
+
message: "Media source already existed"
|
|
526
|
+
});
|
|
528
527
|
}
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
528
|
+
const newMediaSource = (0, utils_1.safelyParse)(JSON.stringify(mediaSource));
|
|
529
|
+
if (newMediaSource.isSelected) {
|
|
530
|
+
const oldSelectedIndex = this.findSelectedMediaSource();
|
|
531
|
+
if (oldSelectedIndex !== -1) {
|
|
532
|
+
yield this.unselectMediaSource(oldSelectedIndex);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
return new Promise((resolve, reject) => {
|
|
536
|
+
var _a;
|
|
537
|
+
const key = `${promiseKeys.addMediaSource}-${newMediaSource.sourceType}-${newMediaSource.sourceId}`;
|
|
538
|
+
this.promiseStore.addPromise(key, resolve, reject);
|
|
539
|
+
this.nodeMediaMixingPlugin.addMediaSource(newMediaSource);
|
|
540
|
+
(_a = this.mediaMixingDesigner) === null || _a === void 0 ? void 0 : _a.addMedia({
|
|
541
|
+
id: `${newMediaSource.sourceType}__${newMediaSource.sourceId}`,
|
|
542
|
+
rect: newMediaSource.rect,
|
|
543
|
+
isSelected: newMediaSource.isSelected || false,
|
|
544
|
+
zOrder: newMediaSource.zOrder,
|
|
545
|
+
origin: newMediaSource
|
|
546
|
+
});
|
|
547
|
+
this.sourceList.push(newMediaSource);
|
|
541
548
|
});
|
|
542
|
-
this.sourceList.push(newMediaSource);
|
|
543
549
|
});
|
|
544
550
|
}
|
|
545
551
|
/**
|
|
@@ -612,7 +618,7 @@ class TRTCMediaMixingManager {
|
|
|
612
618
|
if (mediaSource.isSelected) {
|
|
613
619
|
const oldSelectedIndex = this.findSelectedMediaSource();
|
|
614
620
|
if (oldSelectedIndex !== -1 && oldSelectedIndex !== index) {
|
|
615
|
-
this.unselectMediaSource(oldSelectedIndex);
|
|
621
|
+
yield this.unselectMediaSource(oldSelectedIndex);
|
|
616
622
|
}
|
|
617
623
|
}
|
|
618
624
|
yield this.nodeMediaMixingPlugin.updateMediaSource(newMediaSource);
|
|
@@ -646,6 +652,7 @@ class TRTCMediaMixingManager {
|
|
|
646
652
|
}
|
|
647
653
|
/**
|
|
648
654
|
* 设置手机投屏参数
|
|
655
|
+
* @private
|
|
649
656
|
* @param phoneMirrorSourceId {string} - 手机投屏媒体源 ID
|
|
650
657
|
* @param param {TRTCPhoneMirrorParam} - 手机投屏参数
|
|
651
658
|
*/
|
|
@@ -1468,7 +1475,6 @@ class TRTCMediaMixingManager {
|
|
|
1468
1475
|
else {
|
|
1469
1476
|
// neither native window nor web element, stop preview
|
|
1470
1477
|
this.previewInNone();
|
|
1471
|
-
this.destroyWebRenderer();
|
|
1472
1478
|
}
|
|
1473
1479
|
});
|
|
1474
1480
|
}
|
|
@@ -1476,6 +1482,7 @@ class TRTCMediaMixingManager {
|
|
|
1476
1482
|
this.destroyResizeObserver();
|
|
1477
1483
|
this.destroyLayoutManager();
|
|
1478
1484
|
this.destroyDesigner();
|
|
1485
|
+
this.destroyWebRenderer();
|
|
1479
1486
|
this.view = null;
|
|
1480
1487
|
this.nodeMediaMixingPlugin.setDisplayParams(this.windowID, { left: 0, right: 0, top: 0, bottom: 0 });
|
|
1481
1488
|
}
|
|
@@ -1531,11 +1538,13 @@ class TRTCMediaMixingManager {
|
|
|
1531
1538
|
this.nodeMediaMixingPlugin.setVideoFrameRenderBuffer(this.videoRenderBuffer.userId, this.videoRenderBuffer.buffer, this.videoRenderBuffer.streamType, this.videoRenderBuffer.width, this.videoRenderBuffer.height, this.videoRenderBuffer.pixelFormat, this.videoRenderBuffer.id);
|
|
1532
1539
|
}
|
|
1533
1540
|
destroyWebRendererBuffer() {
|
|
1534
|
-
this.videoRenderBuffer.
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1541
|
+
if (this.videoRenderBuffer.buffer !== null || this.videoRenderBuffer.id !== 0) {
|
|
1542
|
+
this.videoRenderBuffer.width = 0;
|
|
1543
|
+
this.videoRenderBuffer.height = 0;
|
|
1544
|
+
this.nodeMediaMixingPlugin.setVideoFrameRenderBuffer(this.videoRenderBuffer.userId, this.videoRenderBuffer.buffer, this.videoRenderBuffer.streamType, this.videoRenderBuffer.width, this.videoRenderBuffer.height, this.videoRenderBuffer.pixelFormat, this.videoRenderBuffer.id);
|
|
1545
|
+
this.videoRenderBuffer.buffer = null;
|
|
1546
|
+
this.videoRenderBuffer.id = 0;
|
|
1547
|
+
}
|
|
1539
1548
|
}
|
|
1540
1549
|
webRendererCallback(args) {
|
|
1541
1550
|
const [id, type, width, height, timestamp, rotation, valid, bufferId] = args;
|
package/liteav/trtc.d.ts
CHANGED
|
@@ -1272,8 +1272,6 @@ declare class TRTCCloud extends EventEmitter {
|
|
|
1272
1272
|
/**
|
|
1273
1273
|
* 设置摄像头采集偏好
|
|
1274
1274
|
*
|
|
1275
|
-
* 注意:目前只支持 `Windows` 系统
|
|
1276
|
-
*
|
|
1277
1275
|
* @param {TRTCCameraCaptureParams} params - 摄像头采集参数
|
|
1278
1276
|
*/
|
|
1279
1277
|
setCameraCaptureParams(params: TRTCCameraCaptureParams): void;
|
|
@@ -1369,7 +1367,7 @@ declare class TRTCCloud extends EventEmitter {
|
|
|
1369
1367
|
* @param {TRTCVideoResolutionMode} params.resMode - 分辨率模式(横屏分辨率 - 竖屏分辨率)
|
|
1370
1368
|
* - TRTCVideoResolutionModeLandscape: 横屏分辨率
|
|
1371
1369
|
* - TRTCVideoResolutionModePortrait : 竖屏分辨率
|
|
1372
|
-
* @param {Number} params.videoFps -
|
|
1370
|
+
* @param {Number} params.videoFps - 视频编码帧率
|
|
1373
1371
|
* @param {Number} params.videoBitrate - 视频上行码率
|
|
1374
1372
|
* @param {Number} params.minVideoBitrate - 视频最小码率
|
|
1375
1373
|
* @param {Boolean} params.enableAdjustRes - 是否允许动态调整分辨率,默认值:关闭。
|
package/liteav/trtc.js
CHANGED
|
@@ -30,6 +30,7 @@ const yuv_buffer_1 = __importDefault(require("./Renderer/yuv-buffer"));
|
|
|
30
30
|
const YCbCr_1 = __importDefault(require("yuv-canvas/src/YCbCr"));
|
|
31
31
|
const LocalMediaTranscoder_1 = __importDefault(require("./LocalMediaTranscoder"));
|
|
32
32
|
const trtc_define_1 = require("./trtc_define");
|
|
33
|
+
const utils_1 = require("./utils");
|
|
33
34
|
const validate_util_1 = require("./validate-util");
|
|
34
35
|
const logger_1 = __importStar(require("./logger"));
|
|
35
36
|
const LocalVideoRenderController_1 = __importDefault(require("./VideoRenderControl/LocalVideoRenderController"));
|
|
@@ -2301,8 +2302,6 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
2301
2302
|
/**
|
|
2302
2303
|
* 设置摄像头采集偏好
|
|
2303
2304
|
*
|
|
2304
|
-
* 注意:目前只支持 `Windows` 系统
|
|
2305
|
-
*
|
|
2306
2305
|
* @param {TRTCCameraCaptureParams} params - 摄像头采集参数
|
|
2307
2306
|
*/
|
|
2308
2307
|
setCameraCaptureParams(params) {
|
|
@@ -2542,7 +2541,7 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
2542
2541
|
* @param {TRTCVideoResolutionMode} params.resMode - 分辨率模式(横屏分辨率 - 竖屏分辨率)
|
|
2543
2542
|
* - TRTCVideoResolutionModeLandscape: 横屏分辨率
|
|
2544
2543
|
* - TRTCVideoResolutionModePortrait : 竖屏分辨率
|
|
2545
|
-
* @param {Number} params.videoFps -
|
|
2544
|
+
* @param {Number} params.videoFps - 视频编码帧率
|
|
2546
2545
|
* @param {Number} params.videoBitrate - 视频上行码率
|
|
2547
2546
|
* @param {Number} params.minVideoBitrate - 视频最小码率
|
|
2548
2547
|
* @param {Boolean} params.enableAdjustRes - 是否允许动态调整分辨率,默认值:关闭。
|
|
@@ -5276,7 +5275,7 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
5276
5275
|
return rgbaData;
|
|
5277
5276
|
}
|
|
5278
5277
|
_isMacPlatform() {
|
|
5279
|
-
return
|
|
5278
|
+
return (0, utils_1.isMacOS)();
|
|
5280
5279
|
}
|
|
5281
5280
|
_setRemoteVideoBuffer(userId, streamType) {
|
|
5282
5281
|
const videoBufferInfo = new trtc_define_1.VideoBufferInfo({
|
package/liteav/utils.d.ts
CHANGED
|
@@ -35,3 +35,7 @@ export declare function throttle<T extends (...args: any[]) => any>(func: T, wai
|
|
|
35
35
|
leading?: boolean;
|
|
36
36
|
trailing?: boolean;
|
|
37
37
|
}): (...args: Parameters<T>) => void;
|
|
38
|
+
export declare function getOS(): string;
|
|
39
|
+
export declare function isMacOS(): boolean;
|
|
40
|
+
export declare function isWindows(): boolean;
|
|
41
|
+
export declare function isLinux(): boolean;
|
package/liteav/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.throttle = exports.debounce = exports.convertUint8ArrayToNumber = exports.safelyParse = exports.isNullOrUndefined = exports.isUndefined = exports.isNull = void 0;
|
|
3
|
+
exports.isLinux = exports.isWindows = exports.isMacOS = exports.getOS = exports.throttle = exports.debounce = exports.convertUint8ArrayToNumber = exports.safelyParse = exports.isNullOrUndefined = exports.isUndefined = exports.isNull = void 0;
|
|
4
4
|
function isNull(val) {
|
|
5
5
|
return val === null;
|
|
6
6
|
}
|
|
@@ -131,3 +131,39 @@ function throttle(func, wait, options = {}) {
|
|
|
131
131
|
};
|
|
132
132
|
}
|
|
133
133
|
exports.throttle = throttle;
|
|
134
|
+
function getOS() {
|
|
135
|
+
var _a, _b;
|
|
136
|
+
let os = '';
|
|
137
|
+
if (process && process.platform) {
|
|
138
|
+
os = process.platform;
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
// @ts-ignore
|
|
142
|
+
const platform = ((_b = (_a = window.navigator) === null || _a === void 0 ? void 0 : _a.userAgentData) === null || _b === void 0 ? void 0 : _b.platform) || window.navigator.platform;
|
|
143
|
+
const macosPlatforms = ['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K', 'macOS'];
|
|
144
|
+
const windowsPlatforms = ['Win32', 'Win64', 'Windows', 'WinCE'];
|
|
145
|
+
if (macosPlatforms.indexOf(platform) !== -1) {
|
|
146
|
+
os = 'darwin';
|
|
147
|
+
}
|
|
148
|
+
else if (windowsPlatforms.indexOf(platform) !== -1) {
|
|
149
|
+
os = 'win32';
|
|
150
|
+
}
|
|
151
|
+
else if (/Linux/.test(platform)) {
|
|
152
|
+
os = 'linux';
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return os;
|
|
156
|
+
}
|
|
157
|
+
exports.getOS = getOS;
|
|
158
|
+
function isMacOS() {
|
|
159
|
+
return getOS() === 'darwin';
|
|
160
|
+
}
|
|
161
|
+
exports.isMacOS = isMacOS;
|
|
162
|
+
function isWindows() {
|
|
163
|
+
return getOS() === 'win32';
|
|
164
|
+
}
|
|
165
|
+
exports.isWindows = isWindows;
|
|
166
|
+
function isLinux() {
|
|
167
|
+
return getOS() === 'linux';
|
|
168
|
+
}
|
|
169
|
+
exports.isLinux = isLinux;
|
package/package.json
CHANGED
package/scripts/copy-sdk.js
CHANGED
|
@@ -56,6 +56,14 @@ if (process.platform === "win32") {
|
|
|
56
56
|
path.resolve(SDK_CPP_PATH, `src/remote-liteav/sdk/mac/Frameworks/${process.arch}/TXSoundTouch.framework`),
|
|
57
57
|
path.resolve(SDK_JS_PATH, `build/mac-framework/${process.arch}/TXSoundTouch.framework`)
|
|
58
58
|
);
|
|
59
|
+
copySync(
|
|
60
|
+
path.resolve(SDK_CPP_PATH, `src/remote-liteav/sdk/mac/Frameworks/${process.arch}/TXLiteAVSDK_TRTC_Mac.framework`),
|
|
61
|
+
path.resolve(SDK_JS_PATH, `build/mac-framework/${process.arch}/TXLiteAVSDK_TRTC_Mac.framework`)
|
|
62
|
+
);
|
|
63
|
+
copySync(
|
|
64
|
+
path.resolve(SDK_CPP_PATH, `src/remote-liteav/out/Release-macos/${process.arch}/liblive_kit_engine.dylib`),
|
|
65
|
+
path.resolve(SDK_JS_PATH, `build/mac-framework/${process.arch}/liblive_kit_engine.dylib`)
|
|
66
|
+
);
|
|
59
67
|
} else {
|
|
60
68
|
// linux
|
|
61
69
|
let soPrefix = ""
|