trtc-electron-sdk 12.2.115-beta.21 → 12.2.115-beta.26

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.
@@ -234,6 +234,7 @@ export declare class TRTCMediaMixingManager implements ITRTCMediaMixingManager {
234
234
  * @returns {Promise<void>}
235
235
  */
236
236
  removeMediaSource(mediaSource: TRTCMediaSource): Promise<void>;
237
+ private syncRemoveMediaSource;
237
238
  /**
238
239
  * 更新本地混流媒体源
239
240
  * @param mediaSource {TRTCMediaSource} - 媒体源信息
@@ -373,6 +374,7 @@ export declare class TRTCMediaMixingManager implements ITRTCMediaMixingManager {
373
374
  * @returns {Promise<void>}
374
375
  */
375
376
  stopMediaMixingServer(): Promise<void>;
377
+ callExperimentalAPI(jsonStr: string): void;
376
378
  /**
377
379
  * 注册事件监听
378
380
  *
@@ -387,7 +389,8 @@ export declare class TRTCMediaMixingManager implements ITRTCMediaMixingManager {
387
389
  * @param func {Function} - 事件回调函数
388
390
  */
389
391
  off(event: TRTCMediaMixingEvent, func: (...args: any[]) => void): void;
390
- private initResizeObserver;
392
+ private createResizeObserver;
393
+ private destroyResizeObserver;
391
394
  private onPreviewAreaResize;
392
395
  private onVisibilityChange;
393
396
  private setDisplayRect;
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.TRTCMediaMixingManager = exports.TRTCMediaMixingEvent = void 0;
16
16
  const events_1 = require("events");
17
17
  const trtc_define_1 = require("../../trtc_define");
18
+ const types_1 = require("./types");
18
19
  const utils_1 = require("../../utils");
19
20
  const constant_1 = require("../../constant");
20
21
  const index_1 = __importDefault(require("../../MediaMixingDesigner/index"));
@@ -315,10 +316,8 @@ class TRTCMediaMixingManager {
315
316
  return __awaiter(this, void 0, void 0, function* () {
316
317
  DevicePixelRatioObserver_1.default.off('change', this.onDevicePixelRatioChange);
317
318
  document.removeEventListener('visibilitychange', this.onVisibilityChange);
318
- if (this.resizeObserver && this.view) {
319
- this.resizeObserver.unobserve(this.view);
320
- this.resizeObserver.disconnect();
321
- }
319
+ this.destroyResizeObserver();
320
+ this.destroyLayoutManager();
322
321
  this.view = null;
323
322
  this.windowID = 0;
324
323
  this.destroyDesigner();
@@ -452,7 +451,7 @@ class TRTCMediaMixingManager {
452
451
  this.destroyDesigner();
453
452
  this.view = viewOrRegion;
454
453
  this.setDisplayRect();
455
- this.initResizeObserver();
454
+ this.createResizeObserver();
456
455
  this.createDesigner();
457
456
  }
458
457
  else {
@@ -470,8 +469,10 @@ class TRTCMediaMixingManager {
470
469
  }
471
470
  }
472
471
  else {
472
+ this.destroyResizeObserver();
473
473
  this.destroyLayoutManager();
474
474
  this.destroyDesigner();
475
+ this.view = null;
475
476
  this.nodeMediaMixingPlugin.setDisplayParams(realWindowID, { left: 0, right: 0, top: 0, bottom: 0 });
476
477
  }
477
478
  }
@@ -484,7 +485,10 @@ class TRTCMediaMixingManager {
484
485
  logger_1.default.log(`${this.logPrefix}addMediaSource:`, mediaSource);
485
486
  const index = this.findMediaSourceIndex(mediaSource);
486
487
  if (index !== -1) {
487
- throw new Error("Media source already existed");
488
+ return Promise.reject({
489
+ code: types_1.TRTCMediaMixingErrorCode.InvalidParams,
490
+ message: "Media source already existed"
491
+ });
488
492
  }
489
493
  const newMediaSource = (0, utils_1.safelyParse)(JSON.stringify(mediaSource));
490
494
  if (newMediaSource.isSelected) {
@@ -514,16 +518,46 @@ class TRTCMediaMixingManager {
514
518
  * @returns {Promise<void>}
515
519
  */
516
520
  removeMediaSource(mediaSource) {
521
+ var _a;
517
522
  logger_1.default.log(`${this.logPrefix}removeMediaSource:`, mediaSource);
518
523
  const index = this.findMediaSourceIndex(mediaSource);
519
524
  if (index === -1) {
520
- throw new Error("Not existing media source to remove");
525
+ return Promise.reject({
526
+ code: types_1.TRTCMediaMixingErrorCode.NotFoundSource,
527
+ message: "Not existing media source to remove"
528
+ });
521
529
  }
522
- return new Promise((resolve, reject) => {
523
- const key = `${promiseKeys.removeMediaSource}-${mediaSource.sourceType}-${mediaSource.sourceId}`;
524
- this.promiseStore.addPromise(key, resolve, reject);
530
+ else {
531
+ const mediaSourceToDelete = this.sourceList[index];
532
+ if ((_a = mediaSourceToDelete === null || mediaSourceToDelete === void 0 ? void 0 : mediaSourceToDelete.control) === null || _a === void 0 ? void 0 : _a.isAddFailed) {
533
+ this.syncRemoveMediaSource(mediaSource, index);
534
+ return Promise.resolve();
535
+ }
536
+ else {
537
+ return new Promise((resolve, reject) => {
538
+ const key = `${promiseKeys.removeMediaSource}-${mediaSource.sourceType}-${mediaSource.sourceId}`;
539
+ this.promiseStore.addPromise(key, resolve, reject);
540
+ this.syncRemoveMediaSource(mediaSource, index);
541
+ });
542
+ }
543
+ }
544
+ }
545
+ syncRemoveMediaSource(mediaSource, index) {
546
+ var _a;
547
+ try {
525
548
  this.nodeMediaMixingPlugin.removeMediaSource(mediaSource);
526
- });
549
+ (_a = this.mediaMixingDesigner) === null || _a === void 0 ? void 0 : _a.removeMedia({
550
+ id: `${mediaSource.sourceType}__${mediaSource.sourceId}`,
551
+ rect: mediaSource.rect,
552
+ isSelected: mediaSource.isSelected || false,
553
+ zOrder: mediaSource.zOrder,
554
+ origin: (0, utils_1.safelyParse)(JSON.stringify(mediaSource))
555
+ });
556
+ this.sourceList.splice(index, 1);
557
+ }
558
+ catch (error) {
559
+ logger_1.default.warn(`${this.logPrefix}removeMediaSource exception:`, error);
560
+ }
527
561
  }
528
562
  /**
529
563
  * 更新本地混流媒体源
@@ -536,7 +570,10 @@ class TRTCMediaMixingManager {
536
570
  logger_1.default.log(`${this.logPrefix}updateMediaSource:`, mediaSource);
537
571
  const index = this.findMediaSourceIndex(mediaSource);
538
572
  if (index === -1) {
539
- throw new Error("Not existing media source to update");
573
+ return Promise.reject({
574
+ code: types_1.TRTCMediaMixingErrorCode.NotFoundSource,
575
+ message: "Not existing media source to update"
576
+ });
540
577
  }
541
578
  const newMediaSource = Object.assign(Object.assign({}, this.sourceList[index]), (0, utils_1.safelyParse)(JSON.stringify(mediaSource)));
542
579
  if (mediaSource.isSelected) {
@@ -734,7 +771,7 @@ class TRTCMediaMixingManager {
734
771
  */
735
772
  setStreamLayout(layout) {
736
773
  var _a, _b, _c;
737
- logger_1.default.log(`${this.logPrefix}setStreamLayout:`, layout);
774
+ logger_1.default.debug(`${this.logPrefix}setStreamLayout:`, JSON.stringify(layout));
738
775
  if (this.paramsStore) {
739
776
  try {
740
777
  this.paramsStore.streamLayout = JSON.parse(JSON.stringify(layout));
@@ -743,8 +780,8 @@ class TRTCMediaMixingManager {
743
780
  this.paramsStore.streamLayout = undefined;
744
781
  }
745
782
  }
746
- this.createOrUpdateLayoutManager(layout);
747
783
  if (this.view) {
784
+ this.createOrUpdateLayoutManager(layout);
748
785
  const viewRect = this.view.getBoundingClientRect();
749
786
  if ((_a = layout.userList) === null || _a === void 0 ? void 0 : _a.length) {
750
787
  const localUser = layout.userList.filter(user => user.userId === constant_1.LOCAL_USER_ID)[0];
@@ -757,7 +794,6 @@ class TRTCMediaMixingManager {
757
794
  bottom: workingArea.bottom / viewRect.height,
758
795
  }, localUser.fillMode);
759
796
  }
760
- logger_1.default.log(`${this.logPrefix}setStreamLayout transfer layout to pixel unit:`, JSON.stringify(layout));
761
797
  }
762
798
  }
763
799
  else {
@@ -826,6 +862,10 @@ class TRTCMediaMixingManager {
826
862
  });
827
863
  });
828
864
  }
865
+ callExperimentalAPI(jsonStr) {
866
+ logger_1.default.debug(`${this.logPrefix}callExperimentalAPI:${jsonStr}`);
867
+ this.nodeMediaMixingPlugin.callExperimentalAPI(jsonStr);
868
+ }
829
869
  /**
830
870
  * 注册事件监听
831
871
  *
@@ -846,12 +886,20 @@ class TRTCMediaMixingManager {
846
886
  var _a;
847
887
  (_a = this.eventEmitter) === null || _a === void 0 ? void 0 : _a.off(event, func);
848
888
  }
849
- initResizeObserver() {
889
+ createResizeObserver() {
850
890
  if (this.view) {
851
891
  this.resizeObserver = new ResizeObserver(this.onPreviewAreaResize);
852
892
  this.resizeObserver.observe(this.view);
853
893
  }
854
894
  }
895
+ destroyResizeObserver() {
896
+ if (this.resizeObserver) {
897
+ if (this.view) {
898
+ this.resizeObserver.unobserve(this.view);
899
+ }
900
+ this.resizeObserver.disconnect();
901
+ }
902
+ }
855
903
  onPreviewAreaResize(entries) {
856
904
  logger_1.default.log(`${this.logPrefix}onPreviewAreaResize:`, entries);
857
905
  for (const entry of entries) {
@@ -879,6 +927,7 @@ class TRTCMediaMixingManager {
879
927
  top: clientRect.top * window.devicePixelRatio,
880
928
  bottom: clientRect.bottom * window.devicePixelRatio,
881
929
  };
930
+ logger_1.default.debug(`${this.logPrefix}setDisplayRect:`, this.windowID, rect);
882
931
  this.nodeMediaMixingPlugin.setDisplayParams(this.windowID, rect);
883
932
  }
884
933
  }
@@ -1068,7 +1117,7 @@ class TRTCMediaMixingManager {
1068
1117
  }
1069
1118
  }
1070
1119
  onMediaSourceAdded(data) {
1071
- var _a, _b;
1120
+ var _a;
1072
1121
  const promiseKey = `${promiseKeys.addMediaSource}-${data.sourceType}-${data.sourceId}`;
1073
1122
  let flag = false;
1074
1123
  if (data.errCode === 0) {
@@ -1081,14 +1130,10 @@ class TRTCMediaMixingManager {
1081
1130
  });
1082
1131
  if (newSourceIndex !== -1) {
1083
1132
  const newMediaSource = this.sourceList[newSourceIndex];
1084
- (_a = this.mediaMixingDesigner) === null || _a === void 0 ? void 0 : _a.removeMedia({
1085
- id: `${newMediaSource.sourceType}__${newMediaSource.sourceId}`,
1086
- rect: newMediaSource.rect,
1087
- isSelected: newMediaSource.isSelected || false,
1088
- zOrder: newMediaSource.zOrder,
1089
- origin: newMediaSource
1090
- });
1091
- this.sourceList.splice(newSourceIndex, 1);
1133
+ if (!newMediaSource.control) {
1134
+ newMediaSource.control = {};
1135
+ }
1136
+ newMediaSource.control.isAddFailed = true;
1092
1137
  }
1093
1138
  flag = this.promiseStore.rejectPromise(promiseKey, {
1094
1139
  code: data.errCode,
@@ -1102,29 +1147,14 @@ class TRTCMediaMixingManager {
1102
1147
  if (index !== -1) {
1103
1148
  mediaSource = Object.assign({}, this.sourceList[index]);
1104
1149
  }
1105
- (_b = this.eventEmitter) === null || _b === void 0 ? void 0 : _b.emit(TRTCMediaMixingEvent.onError, data.errCode, data.errMsg, mediaSource);
1150
+ (_a = this.eventEmitter) === null || _a === void 0 ? void 0 : _a.emit(TRTCMediaMixingEvent.onError, data.errCode, data.errMsg, mediaSource);
1106
1151
  }
1107
1152
  }
1108
1153
  onMediaSourceRemoved(data) {
1109
- var _a, _b;
1154
+ var _a;
1110
1155
  const promiseKey = `${promiseKeys.removeMediaSource}-${data.sourceType}-${data.sourceId}`;
1111
1156
  let flag = false;
1112
1157
  if (data.errCode === 0) {
1113
- const sourceIndex = this.findMediaSourceIndex({
1114
- sourceId: data.sourceId,
1115
- sourceType: data.sourceType
1116
- });
1117
- if (sourceIndex !== -1) {
1118
- const mediaSource = this.sourceList[sourceIndex];
1119
- (_a = this.mediaMixingDesigner) === null || _a === void 0 ? void 0 : _a.removeMedia({
1120
- id: `${mediaSource.sourceType}__${mediaSource.sourceId}`,
1121
- rect: mediaSource.rect,
1122
- isSelected: mediaSource.isSelected || false,
1123
- zOrder: mediaSource.zOrder,
1124
- origin: (0, utils_1.safelyParse)(JSON.stringify(mediaSource))
1125
- });
1126
- this.sourceList.splice(sourceIndex, 1);
1127
- }
1128
1158
  flag = this.promiseStore.resolvePromise(promiseKey, undefined);
1129
1159
  }
1130
1160
  else {
@@ -1140,7 +1170,7 @@ class TRTCMediaMixingManager {
1140
1170
  if (index !== -1) {
1141
1171
  mediaSource = Object.assign({}, this.sourceList[index]);
1142
1172
  }
1143
- (_b = this.eventEmitter) === null || _b === void 0 ? void 0 : _b.emit(TRTCMediaMixingEvent.onError, data.errCode, data.errMsg, mediaSource);
1173
+ (_a = this.eventEmitter) === null || _a === void 0 ? void 0 : _a.emit(TRTCMediaMixingEvent.onError, data.errCode, data.errMsg, mediaSource);
1144
1174
  }
1145
1175
  }
1146
1176
  onMediaSourceSizeChanged(data) {
@@ -28,10 +28,10 @@ class CustomStreamLayoutManager extends BaseStreamLayoutManager_1.default {
28
28
  transferredUserList = this.layout.userList.map((user) => {
29
29
  if (user.rect) {
30
30
  return Object.assign(Object.assign({}, user), { rect: {
31
- left: user.rect.left * window.devicePixelRatio,
32
- right: user.rect.right * window.devicePixelRatio,
33
- top: user.rect.top * window.devicePixelRatio,
34
- bottom: user.rect.bottom * window.devicePixelRatio,
31
+ left: Math.round(user.rect.left * window.devicePixelRatio),
32
+ right: Math.round(user.rect.right * window.devicePixelRatio),
33
+ top: Math.round(user.rect.top * window.devicePixelRatio),
34
+ bottom: Math.round(user.rect.bottom * window.devicePixelRatio),
35
35
  } });
36
36
  }
37
37
  else {
@@ -39,6 +39,7 @@ class CustomStreamLayoutManager extends BaseStreamLayoutManager_1.default {
39
39
  }
40
40
  });
41
41
  }
42
+ logger_1.default.debug(`${this.logPrefix}refreshLayout:`, JSON.stringify(transferredUserList));
42
43
  this.nativeStreamLayoutManager.setStreamLayout(transferredUserList);
43
44
  }
44
45
  else if (this.layout.size && this.layout.streams) {
@@ -29,6 +29,7 @@ class NoneStreamLayoutManager extends BaseStreamLayoutManager_1.default {
29
29
  bottom: workingArea.bottom / this.displayArea.height / window.devicePixelRatio,
30
30
  }, this.layout.userList[0].fillMode);
31
31
  }
32
+ logger_1.default.debug(`${this.logPrefix}refreshLayout:`, JSON.stringify(this.layout.userList));
32
33
  (_b = this.nativeStreamLayoutManager) === null || _b === void 0 ? void 0 : _b.setStreamLayout(this.layout.userList);
33
34
  }
34
35
  else {
@@ -59,12 +60,12 @@ class NoneStreamLayoutManager extends BaseStreamLayoutManager_1.default {
59
60
  this.layout.userList = [{
60
61
  userId: '',
61
62
  rect: {
62
- left: previewLeft,
63
- top: previewTop,
64
- right: previewRight,
65
- bottom: previewBottom,
63
+ left: Math.round(previewLeft),
64
+ top: Math.round(previewTop),
65
+ right: Math.round(previewRight),
66
+ bottom: Math.round(previewBottom),
66
67
  },
67
- fillMode: trtc_define_1.TRTCVideoFillMode.TRTCVideoFillMode_Fit,
68
+ fillMode: trtc_define_1.TRTCVideoFillMode.TRTCVideoFillMode_Fill,
68
69
  zOrder: 0
69
70
  }];
70
71
  }
package/liteav/trtc.d.ts CHANGED
@@ -1984,7 +1984,7 @@ declare class TRTCCloud extends EventEmitter {
1984
1984
  * true // enable highlight
1985
1985
  * );
1986
1986
  */
1987
- selectScreenCaptureTarget(source: TRTCScreenCaptureSourceInfo | number, captureRect: Rect | string, property: TRTCScreenCaptureProperty | string, deprecatedCaptureRect?: Rect, captureMouse?: boolean, highlightWindow?: boolean): any;
1987
+ selectScreenCaptureTarget(source: TRTCScreenCaptureSourceInfo | number, captureRect: Rect | string, property: TRTCScreenCaptureProperty | string, deprecatedCaptureRect?: Rect, captureMouse?: boolean, highlightWindow?: boolean): void;
1988
1988
  /**
1989
1989
  * 启动屏幕分享,支持选择使用主路或辅路进行屏幕分享。
1990
1990
  *
package/liteav/trtc.js CHANGED
@@ -5197,6 +5197,9 @@ class TRTCCloud extends events_1.EventEmitter {
5197
5197
  return process.platform == 'darwin';
5198
5198
  }
5199
5199
  _setRemoteVideoBuffer(userId, streamType) {
5200
+ if (TRTCCloud.isIPCMode) {
5201
+ return;
5202
+ }
5200
5203
  const videoBufferInfo = new trtc_define_1.VideoBufferInfo({
5201
5204
  userId: userId,
5202
5205
  id: (0, util_1.generateUniqueId)(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trtc-electron-sdk",
3
- "version": "12.2.115-beta.21",
3
+ "version": "12.2.115-beta.26",
4
4
  "description": "trtc electron sdk",
5
5
  "main": "./liteav/index.js",
6
6
  "types": "./liteav/index.d.ts",