trtc-electron-sdk 13.3.119-beta.2 → 13.3.119-beta.3
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.
|
@@ -144,6 +144,7 @@ export declare class TRTCMediaMixingManager implements ITRTCMediaMixingManager {
|
|
|
144
144
|
private serverStatus;
|
|
145
145
|
private serverMode;
|
|
146
146
|
private addMediaSourceTimers;
|
|
147
|
+
private screenCaptureRectRestartCounts;
|
|
147
148
|
private webRenderer;
|
|
148
149
|
private pixelFormat;
|
|
149
150
|
private pixelLength;
|
|
@@ -532,6 +533,65 @@ export declare class TRTCMediaMixingManager implements ITRTCMediaMixingManager {
|
|
|
532
533
|
* setter call.
|
|
533
534
|
*/
|
|
534
535
|
private _isSameCaptureParams;
|
|
536
|
+
/**
|
|
537
|
+
* @private
|
|
538
|
+
* Strip `captureRect` from a screen param so that the remaining object maps
|
|
539
|
+
* 1:1 onto the native `TRTCScreenCaptureProperty` structure.
|
|
540
|
+
*
|
|
541
|
+
* The capture region travels with the media source payload of
|
|
542
|
+
* add/updateMediaSource (and is consumed by the native `startScreenSource`),
|
|
543
|
+
* not through `setScreenCaptureProperty`. Keeping it out of the property
|
|
544
|
+
* object avoids both sending a field the native setter ignores and a false
|
|
545
|
+
* "changed" verdict from `_isSameCaptureParams`.
|
|
546
|
+
*/
|
|
547
|
+
private _omitCaptureRect;
|
|
548
|
+
/**
|
|
549
|
+
* @private
|
|
550
|
+
* Whether the capture region actually changed between two screen params.
|
|
551
|
+
*
|
|
552
|
+
* An absent `captureRect` means "leave the current capture region alone", so
|
|
553
|
+
* it never counts as a change. This mirrors the cpp-side diff, which only
|
|
554
|
+
* restarts the capture when a region is explicitly provided AND differs from
|
|
555
|
+
* the one currently applied.
|
|
556
|
+
*/
|
|
557
|
+
private _isScreenCaptureRectChanged;
|
|
558
|
+
private _screenCaptureRectRestartKey;
|
|
559
|
+
/**
|
|
560
|
+
* @private
|
|
561
|
+
* Record that one screen-capture restart has been requested for this source,
|
|
562
|
+
* so the resulting `onMediaSourceAdded` echo can be recognized and skipped.
|
|
563
|
+
*/
|
|
564
|
+
private _markScreenCaptureRectRestart;
|
|
565
|
+
/**
|
|
566
|
+
* @private
|
|
567
|
+
* Consume one pending restart marker. Returns true when the incoming
|
|
568
|
+
* notification is an echo of a capture-region restart we triggered ourselves.
|
|
569
|
+
*/
|
|
570
|
+
private _consumeScreenCaptureRectRestart;
|
|
571
|
+
/**
|
|
572
|
+
* @private
|
|
573
|
+
* Drop any pending restart markers for this source.
|
|
574
|
+
*
|
|
575
|
+
* Called whenever a source is added or removed: a marker only makes sense for
|
|
576
|
+
* the lifetime of one particular capture session. Should the native layer ever
|
|
577
|
+
* fail to echo a restart, a stale marker left behind would otherwise swallow
|
|
578
|
+
* the genuine insertion notification of a later re-add.
|
|
579
|
+
*/
|
|
580
|
+
private _clearScreenCaptureRectRestart;
|
|
581
|
+
/**
|
|
582
|
+
* @private
|
|
583
|
+
* Validate and normalize `screen.captureRect` in place.
|
|
584
|
+
*
|
|
585
|
+
* A rect is accepted when it is either all-zero (meaning "capture the whole
|
|
586
|
+
* target", matching the native default) or a well-formed region with a
|
|
587
|
+
* positive width and height. Anything else is dropped with a warning so that
|
|
588
|
+
* a malformed value never reaches the native layer and never disturbs the
|
|
589
|
+
* currently applied capture region.
|
|
590
|
+
*
|
|
591
|
+
* Only applies to kScreen sources; `captureRect` on any other source type is
|
|
592
|
+
* meaningless and is removed as well.
|
|
593
|
+
*/
|
|
594
|
+
private _normalizeScreenCaptureRect;
|
|
535
595
|
private previewInNativeWindow;
|
|
536
596
|
private previewInWebElement;
|
|
537
597
|
private previewInNone;
|
|
@@ -8,12 +8,24 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
11
22
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
23
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
24
|
};
|
|
14
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
26
|
exports.TRTCMediaMixingManager = exports.TRTCMediaMixingEvent = void 0;
|
|
16
27
|
const events_1 = require("events");
|
|
28
|
+
const lodash_isequal_1 = __importDefault(require("lodash.isequal"));
|
|
17
29
|
const trtc_define_1 = require("../../trtc_define");
|
|
18
30
|
const types_1 = require("./types");
|
|
19
31
|
const utils_1 = require("../../utils");
|
|
@@ -107,6 +119,22 @@ const TRTCOnlineVideoParam_HACK_JSDOC = null;
|
|
|
107
119
|
* @property {Number} playoutVolume 播放音量,取值 0 - 100
|
|
108
120
|
*/
|
|
109
121
|
const TRTCVideoFileParam_HACK_JSDOC = null;
|
|
122
|
+
/**
|
|
123
|
+
* 屏幕/窗口采集参数
|
|
124
|
+
*
|
|
125
|
+
* 继承 `TRTCScreenCaptureProperty` 的全部属性,并额外支持指定采集区域。
|
|
126
|
+
*
|
|
127
|
+
* @typedef {Object} TRTCMediaMixingScreenParam
|
|
128
|
+
* @property {Boolean} enableCaptureMouse 是否采集目标内容的同时采集鼠标,可选属性,默认 true
|
|
129
|
+
* @property {Boolean} enableHighLight 是否高亮正在共享的窗口,可选属性,默认 true
|
|
130
|
+
* @property {Boolean} enableHighPerformance 是否开启高性能模式(仅分享屏幕时生效),可选属性,默认 true
|
|
131
|
+
* @property {Number} highLightColor 高亮边框颜色,RGB 格式,可选属性,传 0 使用默认颜色
|
|
132
|
+
* @property {Number} highLightWidth 高亮边框宽度,可选属性,传 0 使用默认宽度
|
|
133
|
+
* @property {Boolean} enableCaptureChildWindow 窗口采集时是否采集子窗口,可选属性,默认 false
|
|
134
|
+
* @property {Rect} captureRect 采集区域,单位:像素,可选属性。不传或传入全零表示采集完整画面;
|
|
135
|
+
* 传入合法区域(`right > left` 且 `bottom > top`)表示仅采集指定区域,非法区域会被忽略。
|
|
136
|
+
*/
|
|
137
|
+
const TRTCMediaMixingScreenParam_HACK_JSDOC = null;
|
|
110
138
|
/**
|
|
111
139
|
* 媒体源数据
|
|
112
140
|
*
|
|
@@ -121,7 +149,7 @@ const TRTCVideoFileParam_HACK_JSDOC = null;
|
|
|
121
149
|
* @property {TRTCVideoFillMode} fillMode 媒体源显示模式,可选属性,默认 `TRTCVideoFillMode_Fit`
|
|
122
150
|
* @property {TRTCVideoMirrorType} mirrorType 媒体源是否镜像,可选属性,默认不镜像
|
|
123
151
|
* @property {TRTCCameraCaptureParams} camera 摄像头采集参数,仅在 sourceType 为 kCamera 时生效,可选属性
|
|
124
|
-
* @property {
|
|
152
|
+
* @property {TRTCMediaMixingScreenParam} screen 屏幕/窗口采集参数,仅在 sourceType 为 kScreen 时生效,可选属性
|
|
125
153
|
* @property {TRTCVideoFileParam} localVideo 本地视频文件播放参数,仅在 sourceType 为 kVideoFile 时生效,可选属性
|
|
126
154
|
* @property {TRTCOnlineVideoParam} onlineVideo 在线视频播放参数,仅在 sourceType 为 kOnlineVideo 时生效,可选属性
|
|
127
155
|
*/
|
|
@@ -344,6 +372,17 @@ class TRTCMediaMixingManager {
|
|
|
344
372
|
// state machine stuck after a previous failure), which would otherwise leave
|
|
345
373
|
// the returned Promise pending forever and the UI stuck on "loading".
|
|
346
374
|
this.addMediaSourceTimers = new Map();
|
|
375
|
+
// Number of screen-capture restarts we have deliberately triggered per
|
|
376
|
+
// source, keyed by `${sourceType}-${sourceId}`.
|
|
377
|
+
//
|
|
378
|
+
// Changing `screen.captureRect` can only take effect by re-invoking the
|
|
379
|
+
// native `startScreenSource`, which makes the underlying SDK emit another
|
|
380
|
+
// `onScreenSourceStarted` -> `SM_OnSourceInserted`. That notification is an
|
|
381
|
+
// echo of an already-added source, not a new insertion, so it must not be
|
|
382
|
+
// mistaken for one. We count the restarts we asked for and swallow exactly
|
|
383
|
+
// that many successful notifications. A counter (rather than a flag) keeps
|
|
384
|
+
// rapid successive updates correct, since every restart echoes back once.
|
|
385
|
+
this.screenCaptureRectRestartCounts = new Map();
|
|
347
386
|
this.webRenderer = null;
|
|
348
387
|
this.pixelFormat = trtc_define_1.TRTCVideoPixelFormat.TRTCVideoPixelFormat_BGRA32;
|
|
349
388
|
this.pixelLength = 4;
|
|
@@ -430,6 +469,7 @@ class TRTCMediaMixingManager {
|
|
|
430
469
|
// callbacks touching a destroyed instance.
|
|
431
470
|
this.addMediaSourceTimers.forEach(timer => clearTimeout(timer));
|
|
432
471
|
this.addMediaSourceTimers.clear();
|
|
472
|
+
this.screenCaptureRectRestartCounts.clear();
|
|
433
473
|
this.paramsStore = null;
|
|
434
474
|
this.trtcParamsStore = null;
|
|
435
475
|
});
|
|
@@ -570,6 +610,7 @@ class TRTCMediaMixingManager {
|
|
|
570
610
|
});
|
|
571
611
|
}
|
|
572
612
|
const newMediaSource = (0, utils_1.safelyParse)(JSON.stringify(mediaSource));
|
|
613
|
+
this._normalizeScreenCaptureRect(newMediaSource);
|
|
573
614
|
if (newMediaSource.isSelected) {
|
|
574
615
|
const oldSelectedIndex = this.findSelectedMediaSource();
|
|
575
616
|
if (oldSelectedIndex !== -1) {
|
|
@@ -636,6 +677,9 @@ class TRTCMediaMixingManager {
|
|
|
636
677
|
// extra camera restart on first add. Other source types are handled in
|
|
637
678
|
// the onMediaSourceAdded callback once the C++ layer reports success.
|
|
638
679
|
this._applyCameraParamsBeforeAdd(newMediaSource);
|
|
680
|
+
// A fresh capture session starts here, so no restart echo can still be
|
|
681
|
+
// outstanding from a previous one.
|
|
682
|
+
this._clearScreenCaptureRectRestart(newMediaSource.sourceType, newMediaSource.sourceId);
|
|
639
683
|
this.nodeMediaMixingPlugin.addMediaSource(newMediaSource);
|
|
640
684
|
(_a = this.mediaMixingDesigner) === null || _a === void 0 ? void 0 : _a.addMedia({
|
|
641
685
|
id: `${newMediaSource.sourceType}__${newMediaSource.sourceId}`,
|
|
@@ -699,6 +743,7 @@ class TRTCMediaMixingManager {
|
|
|
699
743
|
}
|
|
700
744
|
jsRemoveMediaSource(mediaSource, index) {
|
|
701
745
|
var _a;
|
|
746
|
+
this._clearScreenCaptureRectRestart(mediaSource.sourceType, mediaSource.sourceId);
|
|
702
747
|
(_a = this.mediaMixingDesigner) === null || _a === void 0 ? void 0 : _a.removeMedia({
|
|
703
748
|
id: `${mediaSource.sourceType}__${mediaSource.sourceId}`,
|
|
704
749
|
rect: mediaSource.rect,
|
|
@@ -714,7 +759,7 @@ class TRTCMediaMixingManager {
|
|
|
714
759
|
* @returns {Promise<void>}
|
|
715
760
|
*/
|
|
716
761
|
updateMediaSource(mediaSource) {
|
|
717
|
-
var _a;
|
|
762
|
+
var _a, _b;
|
|
718
763
|
return __awaiter(this, void 0, void 0, function* () {
|
|
719
764
|
logger_1.default.log(`${this.logPrefix}updateMediaSource:`, mediaSource);
|
|
720
765
|
const index = this.findMediaSourceIndex(mediaSource);
|
|
@@ -725,15 +770,36 @@ class TRTCMediaMixingManager {
|
|
|
725
770
|
});
|
|
726
771
|
}
|
|
727
772
|
const newMediaSource = Object.assign(Object.assign({}, this.sourceList[index]), (0, utils_1.safelyParse)(JSON.stringify(mediaSource)));
|
|
773
|
+
this._normalizeScreenCaptureRect(newMediaSource);
|
|
728
774
|
if (mediaSource.isSelected) {
|
|
729
775
|
const oldSelectedIndex = this.findSelectedMediaSource();
|
|
730
776
|
if (oldSelectedIndex !== -1 && oldSelectedIndex !== index) {
|
|
731
777
|
yield this.unselectMediaSource(oldSelectedIndex);
|
|
732
778
|
}
|
|
733
779
|
}
|
|
734
|
-
|
|
780
|
+
// The cpp layer re-invokes `startScreenSource` when the capture region
|
|
781
|
+
// changes, which echoes back one extra `SM_OnSourceInserted`. Record it
|
|
782
|
+
// before the call so the echo can be recognized instead of being handled
|
|
783
|
+
// as a brand-new insertion.
|
|
784
|
+
const captureRectChanged = newMediaSource.sourceType === types_1.TRTCMediaSourceType.kScreen
|
|
785
|
+
&& this._isScreenCaptureRectChanged(newMediaSource.screen, (_a = this.sourceList[index]) === null || _a === void 0 ? void 0 : _a.screen);
|
|
786
|
+
if (captureRectChanged) {
|
|
787
|
+
this._markScreenCaptureRectRestart(newMediaSource.sourceType, newMediaSource.sourceId);
|
|
788
|
+
}
|
|
789
|
+
try {
|
|
790
|
+
yield this.nodeMediaMixingPlugin.updateMediaSource(newMediaSource);
|
|
791
|
+
}
|
|
792
|
+
catch (err) {
|
|
793
|
+
// The native call failed before the capture restart could happen, so
|
|
794
|
+
// the expected echo will never arrive. Roll the marker back, otherwise
|
|
795
|
+
// the stale one would swallow a genuine insertion notification later.
|
|
796
|
+
if (captureRectChanged) {
|
|
797
|
+
this._clearScreenCaptureRectRestart(newMediaSource.sourceType, newMediaSource.sourceId);
|
|
798
|
+
}
|
|
799
|
+
throw err;
|
|
800
|
+
}
|
|
735
801
|
this._applyMediaSourceParams(newMediaSource, this.sourceList[index]);
|
|
736
|
-
(
|
|
802
|
+
(_b = this.mediaMixingDesigner) === null || _b === void 0 ? void 0 : _b.updateMedia({
|
|
737
803
|
id: `${mediaSource.sourceType}__${mediaSource.sourceId}`,
|
|
738
804
|
rect: mediaSource.rect,
|
|
739
805
|
isSelected: mediaSource.isSelected || false,
|
|
@@ -1338,6 +1404,19 @@ class TRTCMediaMixingManager {
|
|
|
1338
1404
|
clearTimeout(timer);
|
|
1339
1405
|
this.addMediaSourceTimers.delete(promiseKey);
|
|
1340
1406
|
}
|
|
1407
|
+
// Deduplicate the echo of a capture-region restart that we triggered from
|
|
1408
|
+
// updateMediaSource: the source is already tracked and its params are
|
|
1409
|
+
// already applied, so re-running the add bookkeeping would only issue a
|
|
1410
|
+
// redundant setScreenCaptureProperty. Failures are deliberately NOT
|
|
1411
|
+
// swallowed - they still need to reach the caller through the normal
|
|
1412
|
+
// error path below.
|
|
1413
|
+
if (data.errCode === 0 && this._consumeScreenCaptureRectRestart(data.sourceType, data.sourceId)) {
|
|
1414
|
+
logger_1.default.log(`${this.logPrefix}screen capture rect restarted for sourceId:${data.sourceId}, skip duplicated onMediaSourceAdded`);
|
|
1415
|
+
return;
|
|
1416
|
+
}
|
|
1417
|
+
if (data.errCode !== 0) {
|
|
1418
|
+
this._clearScreenCaptureRectRestart(data.sourceType, data.sourceId);
|
|
1419
|
+
}
|
|
1341
1420
|
let flag = false;
|
|
1342
1421
|
if (data.errCode === 0) {
|
|
1343
1422
|
const addedIndex = this.findMediaSourceIndex({
|
|
@@ -1508,6 +1587,11 @@ class TRTCMediaMixingManager {
|
|
|
1508
1587
|
if ((_a = this.paramsStore) === null || _a === void 0 ? void 0 : _a.streamLayout) {
|
|
1509
1588
|
this.setStreamLayout(this.paramsStore.streamLayout);
|
|
1510
1589
|
}
|
|
1590
|
+
// The restarted media server holds no capture session yet, so every
|
|
1591
|
+
// source below is a genuine insertion. Drop restart markers left over
|
|
1592
|
+
// from before the crash, otherwise a stale one would swallow a recovery
|
|
1593
|
+
// notification and skip re-applying that source's capture params.
|
|
1594
|
+
this.screenCaptureRectRestartCounts.clear();
|
|
1511
1595
|
this.sourceList.forEach((item) => {
|
|
1512
1596
|
this._applyCameraParamsBeforeAdd(item);
|
|
1513
1597
|
this.nodeMediaMixingPlugin.addMediaSource(item);
|
|
@@ -1597,11 +1681,15 @@ class TRTCMediaMixingManager {
|
|
|
1597
1681
|
this.setCameraCaptureParam(mediaSource.sourceId, mediaSource.camera);
|
|
1598
1682
|
}
|
|
1599
1683
|
break;
|
|
1600
|
-
case types_1.TRTCMediaSourceType.kScreen:
|
|
1601
|
-
|
|
1602
|
-
|
|
1684
|
+
case types_1.TRTCMediaSourceType.kScreen: {
|
|
1685
|
+
const nextProperty = this._omitCaptureRect(mediaSource.screen);
|
|
1686
|
+
const prevProperty = this._omitCaptureRect(oldMediaSource === null || oldMediaSource === void 0 ? void 0 : oldMediaSource.screen);
|
|
1687
|
+
if (nextProperty && Object.keys(nextProperty).length > 0
|
|
1688
|
+
&& !this._isSameCaptureParams(nextProperty, prevProperty)) {
|
|
1689
|
+
this.setScreenCaptureProperty(mediaSource.sourceId, nextProperty);
|
|
1603
1690
|
}
|
|
1604
1691
|
break;
|
|
1692
|
+
}
|
|
1605
1693
|
case types_1.TRTCMediaSourceType.kOnlineVideo:
|
|
1606
1694
|
if (mediaSource.onlineVideo && !this._isSameCaptureParams(mediaSource.onlineVideo, oldMediaSource === null || oldMediaSource === void 0 ? void 0 : oldMediaSource.onlineVideo)) {
|
|
1607
1695
|
this.setOnlineVideoParam(mediaSource.sourceId, mediaSource.onlineVideo);
|
|
@@ -1651,6 +1739,122 @@ class TRTCMediaMixingManager {
|
|
|
1651
1739
|
return false;
|
|
1652
1740
|
}
|
|
1653
1741
|
}
|
|
1742
|
+
/**
|
|
1743
|
+
* @private
|
|
1744
|
+
* Strip `captureRect` from a screen param so that the remaining object maps
|
|
1745
|
+
* 1:1 onto the native `TRTCScreenCaptureProperty` structure.
|
|
1746
|
+
*
|
|
1747
|
+
* The capture region travels with the media source payload of
|
|
1748
|
+
* add/updateMediaSource (and is consumed by the native `startScreenSource`),
|
|
1749
|
+
* not through `setScreenCaptureProperty`. Keeping it out of the property
|
|
1750
|
+
* object avoids both sending a field the native setter ignores and a false
|
|
1751
|
+
* "changed" verdict from `_isSameCaptureParams`.
|
|
1752
|
+
*/
|
|
1753
|
+
_omitCaptureRect(param) {
|
|
1754
|
+
if (!param) {
|
|
1755
|
+
return undefined;
|
|
1756
|
+
}
|
|
1757
|
+
const { captureRect } = param, rest = __rest(param, ["captureRect"]);
|
|
1758
|
+
return rest;
|
|
1759
|
+
}
|
|
1760
|
+
/**
|
|
1761
|
+
* @private
|
|
1762
|
+
* Whether the capture region actually changed between two screen params.
|
|
1763
|
+
*
|
|
1764
|
+
* An absent `captureRect` means "leave the current capture region alone", so
|
|
1765
|
+
* it never counts as a change. This mirrors the cpp-side diff, which only
|
|
1766
|
+
* restarts the capture when a region is explicitly provided AND differs from
|
|
1767
|
+
* the one currently applied.
|
|
1768
|
+
*/
|
|
1769
|
+
_isScreenCaptureRectChanged(next, prev) {
|
|
1770
|
+
const nextRect = next === null || next === void 0 ? void 0 : next.captureRect;
|
|
1771
|
+
if (nextRect === undefined || nextRect === null) {
|
|
1772
|
+
return false;
|
|
1773
|
+
}
|
|
1774
|
+
return !(0, lodash_isequal_1.default)(nextRect, prev === null || prev === void 0 ? void 0 : prev.captureRect);
|
|
1775
|
+
}
|
|
1776
|
+
_screenCaptureRectRestartKey(sourceType, sourceId) {
|
|
1777
|
+
return `${sourceType}-${sourceId}`;
|
|
1778
|
+
}
|
|
1779
|
+
/**
|
|
1780
|
+
* @private
|
|
1781
|
+
* Record that one screen-capture restart has been requested for this source,
|
|
1782
|
+
* so the resulting `onMediaSourceAdded` echo can be recognized and skipped.
|
|
1783
|
+
*/
|
|
1784
|
+
_markScreenCaptureRectRestart(sourceType, sourceId) {
|
|
1785
|
+
const key = this._screenCaptureRectRestartKey(sourceType, sourceId);
|
|
1786
|
+
this.screenCaptureRectRestartCounts.set(key, (this.screenCaptureRectRestartCounts.get(key) || 0) + 1);
|
|
1787
|
+
}
|
|
1788
|
+
/**
|
|
1789
|
+
* @private
|
|
1790
|
+
* Consume one pending restart marker. Returns true when the incoming
|
|
1791
|
+
* notification is an echo of a capture-region restart we triggered ourselves.
|
|
1792
|
+
*/
|
|
1793
|
+
_consumeScreenCaptureRectRestart(sourceType, sourceId) {
|
|
1794
|
+
const key = this._screenCaptureRectRestartKey(sourceType, sourceId);
|
|
1795
|
+
const count = this.screenCaptureRectRestartCounts.get(key) || 0;
|
|
1796
|
+
if (count <= 0) {
|
|
1797
|
+
return false;
|
|
1798
|
+
}
|
|
1799
|
+
if (count === 1) {
|
|
1800
|
+
this.screenCaptureRectRestartCounts.delete(key);
|
|
1801
|
+
}
|
|
1802
|
+
else {
|
|
1803
|
+
this.screenCaptureRectRestartCounts.set(key, count - 1);
|
|
1804
|
+
}
|
|
1805
|
+
return true;
|
|
1806
|
+
}
|
|
1807
|
+
/**
|
|
1808
|
+
* @private
|
|
1809
|
+
* Drop any pending restart markers for this source.
|
|
1810
|
+
*
|
|
1811
|
+
* Called whenever a source is added or removed: a marker only makes sense for
|
|
1812
|
+
* the lifetime of one particular capture session. Should the native layer ever
|
|
1813
|
+
* fail to echo a restart, a stale marker left behind would otherwise swallow
|
|
1814
|
+
* the genuine insertion notification of a later re-add.
|
|
1815
|
+
*/
|
|
1816
|
+
_clearScreenCaptureRectRestart(sourceType, sourceId) {
|
|
1817
|
+
this.screenCaptureRectRestartCounts.delete(this._screenCaptureRectRestartKey(sourceType, sourceId));
|
|
1818
|
+
}
|
|
1819
|
+
/**
|
|
1820
|
+
* @private
|
|
1821
|
+
* Validate and normalize `screen.captureRect` in place.
|
|
1822
|
+
*
|
|
1823
|
+
* A rect is accepted when it is either all-zero (meaning "capture the whole
|
|
1824
|
+
* target", matching the native default) or a well-formed region with a
|
|
1825
|
+
* positive width and height. Anything else is dropped with a warning so that
|
|
1826
|
+
* a malformed value never reaches the native layer and never disturbs the
|
|
1827
|
+
* currently applied capture region.
|
|
1828
|
+
*
|
|
1829
|
+
* Only applies to kScreen sources; `captureRect` on any other source type is
|
|
1830
|
+
* meaningless and is removed as well.
|
|
1831
|
+
*/
|
|
1832
|
+
_normalizeScreenCaptureRect(mediaSource) {
|
|
1833
|
+
const screen = mediaSource.screen;
|
|
1834
|
+
if (!screen || screen.captureRect === undefined || screen.captureRect === null) {
|
|
1835
|
+
return;
|
|
1836
|
+
}
|
|
1837
|
+
if (mediaSource.sourceType !== types_1.TRTCMediaSourceType.kScreen) {
|
|
1838
|
+
logger_1.default.warn(`${this.logPrefix}screen.captureRect is only supported for kScreen source, ignored. sourceType:${mediaSource.sourceType}`);
|
|
1839
|
+
delete screen.captureRect;
|
|
1840
|
+
return;
|
|
1841
|
+
}
|
|
1842
|
+
const { left, top, right, bottom } = screen.captureRect;
|
|
1843
|
+
const isValidNumber = [left, top, right, bottom].every(item => typeof item === 'number' && Number.isInteger(item) && item >= -2147483648 && item <= 2147483647);
|
|
1844
|
+
if (!isValidNumber) {
|
|
1845
|
+
logger_1.default.warn(`${this.logPrefix}screen.captureRect must contain int32 integers, ignored:`, screen.captureRect);
|
|
1846
|
+
delete screen.captureRect;
|
|
1847
|
+
return;
|
|
1848
|
+
}
|
|
1849
|
+
const isFullTarget = left === 0 && top === 0 && right === 0 && bottom === 0;
|
|
1850
|
+
if (isFullTarget) {
|
|
1851
|
+
return;
|
|
1852
|
+
}
|
|
1853
|
+
if (left < 0 || top < 0 || right <= left || bottom <= top) {
|
|
1854
|
+
logger_1.default.warn(`${this.logPrefix}screen.captureRect is invalid, ignored:`, screen.captureRect);
|
|
1855
|
+
delete screen.captureRect;
|
|
1856
|
+
}
|
|
1857
|
+
}
|
|
1654
1858
|
previewInNativeWindow(viewOrRegion) {
|
|
1655
1859
|
var _a;
|
|
1656
1860
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -46,6 +46,9 @@ export declare type TRTCOnlineVideoParam = {
|
|
|
46
46
|
export declare type TRTCVideoFileParam = {
|
|
47
47
|
playoutVolume: number;
|
|
48
48
|
};
|
|
49
|
+
export declare type TRTCMediaMixingScreenParam = TRTCScreenCaptureProperty & {
|
|
50
|
+
captureRect?: Rect;
|
|
51
|
+
};
|
|
49
52
|
export declare type TRTCMediaSource = {
|
|
50
53
|
sourceType: TRTCMediaSourceType;
|
|
51
54
|
sourceId: string;
|
|
@@ -57,7 +60,7 @@ export declare type TRTCMediaSource = {
|
|
|
57
60
|
fillMode?: TRTCVideoFillMode;
|
|
58
61
|
mirrorType?: TRTCVideoMirrorType;
|
|
59
62
|
camera?: TRTCCameraCaptureParams;
|
|
60
|
-
screen?:
|
|
63
|
+
screen?: TRTCMediaMixingScreenParam;
|
|
61
64
|
localVideo?: TRTCVideoFileParam;
|
|
62
65
|
onlineVideo?: TRTCOnlineVideoParam;
|
|
63
66
|
};
|