trtc-electron-sdk 13.3.801 → 13.3.802-beta.1

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.
@@ -54,6 +54,8 @@ export declare enum TRTCMediaMixingEvent {
54
54
  onError = "onError",
55
55
  /**
56
56
  * @description 设备插入事件
57
+ * @deprecated
58
+ * @private
57
59
  *
58
60
  * @event TRTCMediaMixingEvent#onSourcePlugged
59
61
  * @param {TRTCPhoneMirrorParam} source 投屏手机状态信息
@@ -62,6 +64,8 @@ export declare enum TRTCMediaMixingEvent {
62
64
  onSourcePlugged = "onSourcePlugged",
63
65
  /**
64
66
  * @description 设备链接事件
67
+ * @deprecated
68
+ * @private
65
69
  *
66
70
  * @event TRTCMediaMixingEvent#onSourceConnected
67
71
  * @param {TRTCPhoneMirrorParam} source 投屏手机状态信息
@@ -70,6 +74,8 @@ export declare enum TRTCMediaMixingEvent {
70
74
  onSourceConnected = "onSourceConnected",
71
75
  /**
72
76
  * @description 设备断开链接事件
77
+ * @deprecated
78
+ * @private
73
79
  *
74
80
  * @event TRTCMediaMixingEvent#onSourceDisconnected
75
81
  * @param {TRTCPhoneMirrorParam} source 投屏手机状态信息
@@ -78,6 +84,8 @@ export declare enum TRTCMediaMixingEvent {
78
84
  onSourceDisconnected = "onSourceDisconnected",
79
85
  /**
80
86
  * @description 设备拔出事件
87
+ * @deprecated
88
+ * @private
81
89
  *
82
90
  * @event TRTCMediaMixingEvent#onSourceUnplugged
83
91
  * @param {TRTCPhoneMirrorParam} source 投屏手机状态信息
@@ -95,6 +103,13 @@ export declare enum TRTCMediaMixingEvent {
95
103
  * @param {Number} size.height 媒体源最新高度
96
104
  */
97
105
  onMediaSourceSizeChanged = "onMediaSourceSizeChanged",
106
+ /**
107
+ * @description 本地混流服务丢失事件
108
+ * @deprecated
109
+ * @private
110
+ *
111
+ * @event TRTCMediaMixingEvent#onMediaMixingServerLost
112
+ */
98
113
  onMediaMixingServerLost = "onMediaMixingServerLost"
99
114
  }
100
115
  declare enum TRTCMediaMixingServerMode {
@@ -241,13 +256,6 @@ export declare class TRTCMediaMixingManager implements ITRTCMediaMixingManager {
241
256
  * @returns {Promise<void>}
242
257
  */
243
258
  addMediaSource(mediaSource: TRTCMediaSource): Promise<void>;
244
- /**
245
- * Returns the per-sourceType timeout (ms) used by addMediaSource. The
246
- * defaults are intentionally larger than the cpp-layer timeout in
247
- * SourceManagerProxy so that, in the normal case, the cpp side resolves the
248
- * promise first. This JS timer is the last-resort safety net in case the
249
- * cpp side itself fails to emit any callback (older builds, ipc lost, etc.).
250
- */
251
259
  private getAddMediaSourceTimeoutMs;
252
260
  /**
253
261
  * 删除本地混流媒体源
@@ -265,12 +273,17 @@ export declare class TRTCMediaMixingManager implements ITRTCMediaMixingManager {
265
273
  updateMediaSource(mediaSource: TRTCMediaSource): Promise<void>;
266
274
  /**
267
275
  * 设置摄像头采集参数
276
+ *
277
+ * @deprecated 请使用 `addMediaSource` 或 `updateMediaSource` 代替
278
+ *
268
279
  * @param cameraID {string} - 摄像头 ID
269
280
  * @param params {TRTCCameraCaptureParams} - 摄像头采集参数
270
281
  */
271
282
  setCameraCaptureParam(cameraID: string, params: TRTCCameraCaptureParams): void;
272
283
  /**
273
284
  * 设置手机投屏参数
285
+ *
286
+ * @deprecated
274
287
  * @private
275
288
  * @param phoneMirrorSourceId {string} - 手机投屏媒体源 ID
276
289
  * @param param {TRTCPhoneMirrorParam} - 手机投屏参数
@@ -278,18 +291,27 @@ export declare class TRTCMediaMixingManager implements ITRTCMediaMixingManager {
278
291
  setPhoneMirrorParam(phoneMirrorSourceId: string, param: TRTCPhoneMirrorParam): void;
279
292
  /**
280
293
  * 设置屏幕采集参数
294
+ *
295
+ * @deprecated 请使用 `addMediaSource` 或 `updateMediaSource` 代替
296
+ *
281
297
  * @param screenOrWindowID {String} - 屏幕 ID 或 窗口 ID
282
298
  * @param property {TRTCScreenCaptureProperty} - 屏幕采集属性
283
299
  */
284
300
  setScreenCaptureProperty(screenOrWindowID: string, property: TRTCScreenCaptureProperty): void;
285
301
  /**
286
302
  * 设置在线视频源播放参数
303
+ *
304
+ * @deprecated 请使用 `addMediaSource` 或 `updateMediaSource` 代替
305
+ *
287
306
  * @param url {string} - 在线视频源 URL
288
307
  * @param param {TRTCOnlineVideoParam} - 在线视频源播放参数
289
308
  */
290
309
  setOnlineVideoParam(url: string, param: TRTCOnlineVideoParam): void;
291
310
  /**
292
311
  * 设置视频文件播放参数
312
+ *
313
+ * @deprecated 请使用 `addMediaSource` 或 `updateMediaSource` 代替
314
+ *
293
315
  * @param videoFilePath {string} - 视频文件路径
294
316
  * @param param {TRTCVideoFileParam} - 视频文件播放参数
295
317
  */
@@ -458,6 +480,58 @@ export declare class TRTCMediaMixingManager implements ITRTCMediaMixingManager {
458
480
  private onCallExperimentalAPIFinish;
459
481
  private recoverMediaMixingServer;
460
482
  private onDevicePixelRatioChange;
483
+ /**
484
+ * @private
485
+ * Apply camera capture params BEFORE native addMediaSource.
486
+ *
487
+ * Calling setCameraCaptureParam after the camera has already been added
488
+ * triggers an extra camera restart (the camera first starts with default
489
+ * params and then restarts with the new ones). To avoid this we set
490
+ * camera params up-front for the add path. For all other source types
491
+ * the corresponding setters are dispatched in the post-add callback
492
+ * (`onMediaSourceAdded` -> `_applyMediaSourceParams`).
493
+ */
494
+ private _applyCameraParamsBeforeAdd;
495
+ /**
496
+ * @private
497
+ * Apply capture params from TRTCMediaSource to the native plugin.
498
+ *
499
+ * This method is called after media source is added or updated. To avoid
500
+ * costly side-effects of native setters (e.g. setCameraCaptureParam will
501
+ * restart the camera), the setter is invoked only when params are actually
502
+ * provided AND differ from the previous value carried by `oldMediaSource`.
503
+ *
504
+ * Camera handling differs by phase:
505
+ * - Add path (oldMediaSource is undefined): camera params have been set
506
+ * before native addMediaSource via `_applyCameraParamsBeforeAdd`, so
507
+ * this method skips kCamera to avoid duplicate setter invocation.
508
+ * - Update path (oldMediaSource is provided): kCamera goes through the
509
+ * same diff check as other types and is dispatched only when changed.
510
+ *
511
+ * @param mediaSource - The new media source carrying capture params.
512
+ * @param oldMediaSource - The previous media source (omit for the add path
513
+ * where no previous params exist; in that case the
514
+ * setter is always invoked when params are present).
515
+ */
516
+ private _applyMediaSourceParams;
517
+ /**
518
+ * @private
519
+ * Shallow-but-stable equality check on capture param objects via JSON.
520
+ *
521
+ * Returns true when both sides represent the "same" params, false otherwise.
522
+ * Semantics:
523
+ * - both empty (undefined / null) → true (no change requested)
524
+ * - exactly one side empty → false (first-time apply or transition)
525
+ * - both non-empty → byte-equal after JSON.stringify
526
+ *
527
+ * Note: JSON.stringify is sensitive to key ordering. Capture param objects
528
+ * carried by `TRTCMediaSource` are constructed by the SDK via
529
+ * `JSON.parse(JSON.stringify(...))` flow, so key order is stable in
530
+ * practice; for caller-supplied literal objects with unstable key order,
531
+ * the comparison may yield a false-negative and trigger an unnecessary
532
+ * setter call.
533
+ */
534
+ private _isSameCaptureParams;
461
535
  private previewInNativeWindow;
462
536
  private previewInWebElement;
463
537
  private previewInNone;
@@ -92,6 +92,21 @@ const TRTCMediaSourceType_HACK_JSDOC = {
92
92
  *
93
93
  */
94
94
  const TRTCPhoneMirrorParam_HACK_JSDOC = null;
95
+ /**
96
+ * 在线视频播放参数
97
+ *
98
+ * @typedef {Object} TRTCOnlineVideoParam
99
+ * @property {Number} networkCacheSizeKB 网络缓存大小,单位 KB
100
+ * @property {Number} playoutVolume 播放音量,取值 0 - 100
101
+ */
102
+ const TRTCOnlineVideoParam_HACK_JSDOC = null;
103
+ /**
104
+ * 本地视频文件播放参数
105
+ *
106
+ * @typedef {Object} TRTCVideoFileParam
107
+ * @property {Number} playoutVolume 播放音量,取值 0 - 100
108
+ */
109
+ const TRTCVideoFileParam_HACK_JSDOC = null;
95
110
  /**
96
111
  * 媒体源数据
97
112
  *
@@ -99,12 +114,16 @@ const TRTCPhoneMirrorParam_HACK_JSDOC = null;
99
114
  * @property {TRTCMediaSourceType} sourceType 媒体源类型
100
115
  * @property {String} sourceId 媒体源唯一 ID
101
116
  * @property {Number} zOrder 媒体源展示层级,取值 0 - 15
117
+ * @property {Boolean} enableGreenScreen 是否开启绿幕(仅在 sourceType 为 kCamera 时生效),可选属性
102
118
  * @property {Rect} rect 媒体源显示区域
103
119
  * @property {Boolean} isSelected 媒体源是否选中,可选属性,默认:false
104
120
  * @property {TRTCVideoRotation} rotation 媒体源选中角度,可选属性
105
121
  * @property {TRTCVideoFillMode} fillMode 媒体源显示模式,可选属性,默认 `TRTCVideoFillMode_Fit`
106
122
  * @property {TRTCVideoMirrorType} mirrorType 媒体源是否镜像,可选属性,默认不镜像
107
- * @property {TRTCPhoneMirrorConnectionParam} connectionParam 手机投屏类型媒体源,连接参数
123
+ * @property {TRTCCameraCaptureParams} camera 摄像头采集参数,仅在 sourceType 为 kCamera 时生效,可选属性
124
+ * @property {TRTCScreenCaptureProperty} screen 屏幕/窗口采集属性,仅在 sourceType 为 kScreen 时生效,可选属性
125
+ * @property {TRTCVideoFileParam} localVideo 本地视频文件播放参数,仅在 sourceType 为 kVideoFile 时生效,可选属性
126
+ * @property {TRTCOnlineVideoParam} onlineVideo 在线视频播放参数,仅在 sourceType 为 kOnlineVideo 时生效,可选属性
108
127
  */
109
128
  const TRTCMediaSource_HACK_JSDOC = null;
110
129
  /**
@@ -133,20 +152,20 @@ const TRTCStreamLayoutMode_HACK_JSDOC = {
133
152
  * 单路连麦视频流布局信息
134
153
  *
135
154
  * 本地混流高性能渲染模式下,单路视频流布局信息
136
- * @typedef {Object} TRTCStreamInfo
155
+ * @typedef {Object} TRTCUserStream
137
156
  * @property {String} userId 用户 ID,本地用户需填空字符长
138
157
  * @property {TRTCVideoFillMode} fillMode 视频填充模式
139
158
  * @property {Rect} rect 视频流显示区域
140
159
  * @property {Number} zOrder 视频流展示层级,取值 0 - 15
141
160
  */
142
- const TRTCStreamInfo_HACK_JSDOC = null;
161
+ const TRTCUserStream_HACK_JSDOC = null;
143
162
  /**
144
163
  * 连麦视频流布局信息
145
164
  *
146
165
  * 本地混流高性能渲染模式下,所有视频流布局信息
147
166
  * @typedef {Object} TRTCStreamLayout
148
167
  * @property {TRTCStreamLayoutMode} layoutMode 布局模式
149
- * @property {Array<TRTCStreamInfo>} userList 非必填,用户视频流布局
168
+ * @property {Array<TRTCUserStream>} userList 非必填,用户视频流布局
150
169
  */
151
170
  const TRTCStreamLayout_HACK_JSDOC = null;
152
171
  const initResolutionMap = () => {
@@ -217,6 +236,8 @@ var TRTCMediaMixingEvent;
217
236
  TRTCMediaMixingEvent["onError"] = "onError";
218
237
  /**
219
238
  * @description 设备插入事件
239
+ * @deprecated
240
+ * @private
220
241
  *
221
242
  * @event TRTCMediaMixingEvent#onSourcePlugged
222
243
  * @param {TRTCPhoneMirrorParam} source 投屏手机状态信息
@@ -225,6 +246,8 @@ var TRTCMediaMixingEvent;
225
246
  TRTCMediaMixingEvent["onSourcePlugged"] = "onSourcePlugged";
226
247
  /**
227
248
  * @description 设备链接事件
249
+ * @deprecated
250
+ * @private
228
251
  *
229
252
  * @event TRTCMediaMixingEvent#onSourceConnected
230
253
  * @param {TRTCPhoneMirrorParam} source 投屏手机状态信息
@@ -233,6 +256,8 @@ var TRTCMediaMixingEvent;
233
256
  TRTCMediaMixingEvent["onSourceConnected"] = "onSourceConnected";
234
257
  /**
235
258
  * @description 设备断开链接事件
259
+ * @deprecated
260
+ * @private
236
261
  *
237
262
  * @event TRTCMediaMixingEvent#onSourceDisconnected
238
263
  * @param {TRTCPhoneMirrorParam} source 投屏手机状态信息
@@ -241,6 +266,8 @@ var TRTCMediaMixingEvent;
241
266
  TRTCMediaMixingEvent["onSourceDisconnected"] = "onSourceDisconnected";
242
267
  /**
243
268
  * @description 设备拔出事件
269
+ * @deprecated
270
+ * @private
244
271
  *
245
272
  * @event TRTCMediaMixingEvent#onSourceUnplugged
246
273
  * @param {TRTCPhoneMirrorParam} source 投屏手机状态信息
@@ -258,6 +285,13 @@ var TRTCMediaMixingEvent;
258
285
  * @param {Number} size.height 媒体源最新高度
259
286
  */
260
287
  TRTCMediaMixingEvent["onMediaSourceSizeChanged"] = "onMediaSourceSizeChanged";
288
+ /**
289
+ * @description 本地混流服务丢失事件
290
+ * @deprecated
291
+ * @private
292
+ *
293
+ * @event TRTCMediaMixingEvent#onMediaMixingServerLost
294
+ */
261
295
  TRTCMediaMixingEvent["onMediaMixingServerLost"] = "onMediaMixingServerLost";
262
296
  })(TRTCMediaMixingEvent = exports.TRTCMediaMixingEvent || (exports.TRTCMediaMixingEvent = {}));
263
297
  const promiseKeys = {
@@ -598,6 +632,10 @@ class TRTCMediaMixingManager {
598
632
  }
599
633
  }, timeoutMs);
600
634
  this.addMediaSourceTimers.set(key, timer);
635
+ // Apply camera capture params BEFORE native addMediaSource to avoid an
636
+ // extra camera restart on first add. Other source types are handled in
637
+ // the onMediaSourceAdded callback once the C++ layer reports success.
638
+ this._applyCameraParamsBeforeAdd(newMediaSource);
601
639
  this.nodeMediaMixingPlugin.addMediaSource(newMediaSource);
602
640
  (_a = this.mediaMixingDesigner) === null || _a === void 0 ? void 0 : _a.addMedia({
603
641
  id: `${newMediaSource.sourceType}__${newMediaSource.sourceId}`,
@@ -610,13 +648,6 @@ class TRTCMediaMixingManager {
610
648
  });
611
649
  });
612
650
  }
613
- /**
614
- * Returns the per-sourceType timeout (ms) used by addMediaSource. The
615
- * defaults are intentionally larger than the cpp-layer timeout in
616
- * SourceManagerProxy so that, in the normal case, the cpp side resolves the
617
- * promise first. This JS timer is the last-resort safety net in case the
618
- * cpp side itself fails to emit any callback (older builds, ipc lost, etc.).
619
- */
620
651
  getAddMediaSourceTimeoutMs(sourceType) {
621
652
  switch (sourceType) {
622
653
  case types_1.TRTCMediaSourceType.kOnlineVideo:
@@ -701,6 +732,7 @@ class TRTCMediaMixingManager {
701
732
  }
702
733
  }
703
734
  yield this.nodeMediaMixingPlugin.updateMediaSource(newMediaSource);
735
+ this._applyMediaSourceParams(newMediaSource, this.sourceList[index]);
704
736
  (_a = this.mediaMixingDesigner) === null || _a === void 0 ? void 0 : _a.updateMedia({
705
737
  id: `${mediaSource.sourceType}__${mediaSource.sourceId}`,
706
738
  rect: mediaSource.rect,
@@ -713,6 +745,9 @@ class TRTCMediaMixingManager {
713
745
  }
714
746
  /**
715
747
  * 设置摄像头采集参数
748
+ *
749
+ * @deprecated 请使用 `addMediaSource` 或 `updateMediaSource` 代替
750
+ *
716
751
  * @param cameraID {string} - 摄像头 ID
717
752
  * @param params {TRTCCameraCaptureParams} - 摄像头采集参数
718
753
  */
@@ -731,6 +766,8 @@ class TRTCMediaMixingManager {
731
766
  }
732
767
  /**
733
768
  * 设置手机投屏参数
769
+ *
770
+ * @deprecated
734
771
  * @private
735
772
  * @param phoneMirrorSourceId {string} - 手机投屏媒体源 ID
736
773
  * @param param {TRTCPhoneMirrorParam} - 手机投屏参数
@@ -740,6 +777,9 @@ class TRTCMediaMixingManager {
740
777
  }
741
778
  /**
742
779
  * 设置屏幕采集参数
780
+ *
781
+ * @deprecated 请使用 `addMediaSource` 或 `updateMediaSource` 代替
782
+ *
743
783
  * @param screenOrWindowID {String} - 屏幕 ID 或 窗口 ID
744
784
  * @param property {TRTCScreenCaptureProperty} - 屏幕采集属性
745
785
  */
@@ -748,6 +788,9 @@ class TRTCMediaMixingManager {
748
788
  }
749
789
  /**
750
790
  * 设置在线视频源播放参数
791
+ *
792
+ * @deprecated 请使用 `addMediaSource` 或 `updateMediaSource` 代替
793
+ *
751
794
  * @param url {string} - 在线视频源 URL
752
795
  * @param param {TRTCOnlineVideoParam} - 在线视频源播放参数
753
796
  */
@@ -756,6 +799,9 @@ class TRTCMediaMixingManager {
756
799
  }
757
800
  /**
758
801
  * 设置视频文件播放参数
802
+ *
803
+ * @deprecated 请使用 `addMediaSource` 或 `updateMediaSource` 代替
804
+ *
759
805
  * @param videoFilePath {string} - 视频文件路径
760
806
  * @param param {TRTCVideoFileParam} - 视频文件播放参数
761
807
  */
@@ -1294,6 +1340,13 @@ class TRTCMediaMixingManager {
1294
1340
  }
1295
1341
  let flag = false;
1296
1342
  if (data.errCode === 0) {
1343
+ const addedIndex = this.findMediaSourceIndex({
1344
+ sourceId: data.sourceId,
1345
+ sourceType: data.sourceType,
1346
+ });
1347
+ if (addedIndex !== -1) {
1348
+ this._applyMediaSourceParams(this.sourceList[addedIndex]);
1349
+ }
1297
1350
  flag = this.promiseStore.resolvePromise(promiseKey, undefined);
1298
1351
  }
1299
1352
  else {
@@ -1456,6 +1509,7 @@ class TRTCMediaMixingManager {
1456
1509
  this.setStreamLayout(this.paramsStore.streamLayout);
1457
1510
  }
1458
1511
  this.sourceList.forEach((item) => {
1512
+ this._applyCameraParamsBeforeAdd(item);
1459
1513
  this.nodeMediaMixingPlugin.addMediaSource(item);
1460
1514
  });
1461
1515
  if (((_b = this.trtcParamsStore) === null || _b === void 0 ? void 0 : _b.enterRoomParams) && ((_c = this.trtcParamsStore) === null || _c === void 0 ? void 0 : _c.enterRoomScene)) {
@@ -1497,7 +1551,108 @@ class TRTCMediaMixingManager {
1497
1551
  logger_1.default.debug(`${this.logPrefix}onDevicePixelRatioChange:`, window.devicePixelRatio);
1498
1552
  this.setDisplayRect();
1499
1553
  }
1554
+ /**
1555
+ * @private
1556
+ * Apply camera capture params BEFORE native addMediaSource.
1557
+ *
1558
+ * Calling setCameraCaptureParam after the camera has already been added
1559
+ * triggers an extra camera restart (the camera first starts with default
1560
+ * params and then restarts with the new ones). To avoid this we set
1561
+ * camera params up-front for the add path. For all other source types
1562
+ * the corresponding setters are dispatched in the post-add callback
1563
+ * (`onMediaSourceAdded` -> `_applyMediaSourceParams`).
1564
+ */
1565
+ _applyCameraParamsBeforeAdd(mediaSource) {
1566
+ if (mediaSource.sourceType === types_1.TRTCMediaSourceType.kCamera && mediaSource.camera) {
1567
+ this.setCameraCaptureParam(mediaSource.sourceId, mediaSource.camera);
1568
+ }
1569
+ }
1570
+ /**
1571
+ * @private
1572
+ * Apply capture params from TRTCMediaSource to the native plugin.
1573
+ *
1574
+ * This method is called after media source is added or updated. To avoid
1575
+ * costly side-effects of native setters (e.g. setCameraCaptureParam will
1576
+ * restart the camera), the setter is invoked only when params are actually
1577
+ * provided AND differ from the previous value carried by `oldMediaSource`.
1578
+ *
1579
+ * Camera handling differs by phase:
1580
+ * - Add path (oldMediaSource is undefined): camera params have been set
1581
+ * before native addMediaSource via `_applyCameraParamsBeforeAdd`, so
1582
+ * this method skips kCamera to avoid duplicate setter invocation.
1583
+ * - Update path (oldMediaSource is provided): kCamera goes through the
1584
+ * same diff check as other types and is dispatched only when changed.
1585
+ *
1586
+ * @param mediaSource - The new media source carrying capture params.
1587
+ * @param oldMediaSource - The previous media source (omit for the add path
1588
+ * where no previous params exist; in that case the
1589
+ * setter is always invoked when params are present).
1590
+ */
1591
+ _applyMediaSourceParams(mediaSource, oldMediaSource) {
1592
+ switch (mediaSource.sourceType) {
1593
+ case types_1.TRTCMediaSourceType.kCamera:
1594
+ // Skip kCamera on the add path to avoid an extra camera restart;
1595
+ // it has been handled by `_applyCameraParamsBeforeAdd` already.
1596
+ if (oldMediaSource && mediaSource.camera && !this._isSameCaptureParams(mediaSource.camera, oldMediaSource.camera)) {
1597
+ this.setCameraCaptureParam(mediaSource.sourceId, mediaSource.camera);
1598
+ }
1599
+ break;
1600
+ case types_1.TRTCMediaSourceType.kScreen:
1601
+ if (mediaSource.screen && !this._isSameCaptureParams(mediaSource.screen, oldMediaSource === null || oldMediaSource === void 0 ? void 0 : oldMediaSource.screen)) {
1602
+ this.setScreenCaptureProperty(mediaSource.sourceId, mediaSource.screen);
1603
+ }
1604
+ break;
1605
+ case types_1.TRTCMediaSourceType.kOnlineVideo:
1606
+ if (mediaSource.onlineVideo && !this._isSameCaptureParams(mediaSource.onlineVideo, oldMediaSource === null || oldMediaSource === void 0 ? void 0 : oldMediaSource.onlineVideo)) {
1607
+ this.setOnlineVideoParam(mediaSource.sourceId, mediaSource.onlineVideo);
1608
+ }
1609
+ break;
1610
+ case types_1.TRTCMediaSourceType.kVideoFile:
1611
+ if (mediaSource.localVideo && !this._isSameCaptureParams(mediaSource.localVideo, oldMediaSource === null || oldMediaSource === void 0 ? void 0 : oldMediaSource.localVideo)) {
1612
+ this.setVideoFileParam(mediaSource.sourceId, mediaSource.localVideo);
1613
+ }
1614
+ break;
1615
+ }
1616
+ }
1617
+ /**
1618
+ * @private
1619
+ * Shallow-but-stable equality check on capture param objects via JSON.
1620
+ *
1621
+ * Returns true when both sides represent the "same" params, false otherwise.
1622
+ * Semantics:
1623
+ * - both empty (undefined / null) → true (no change requested)
1624
+ * - exactly one side empty → false (first-time apply or transition)
1625
+ * - both non-empty → byte-equal after JSON.stringify
1626
+ *
1627
+ * Note: JSON.stringify is sensitive to key ordering. Capture param objects
1628
+ * carried by `TRTCMediaSource` are constructed by the SDK via
1629
+ * `JSON.parse(JSON.stringify(...))` flow, so key order is stable in
1630
+ * practice; for caller-supplied literal objects with unstable key order,
1631
+ * the comparison may yield a false-negative and trigger an unnecessary
1632
+ * setter call.
1633
+ */
1634
+ _isSameCaptureParams(next, prev) {
1635
+ if (next === prev) {
1636
+ return true;
1637
+ }
1638
+ const nextEmpty = next === undefined || next === null;
1639
+ const prevEmpty = prev === undefined || prev === null;
1640
+ if (nextEmpty && prevEmpty) {
1641
+ return true;
1642
+ }
1643
+ if (nextEmpty || prevEmpty) {
1644
+ return false;
1645
+ }
1646
+ try {
1647
+ return JSON.stringify(next) === JSON.stringify(prev);
1648
+ }
1649
+ catch (err) {
1650
+ logger_1.default.warn(`${this.logPrefix}_isSameCaptureParams: stringify failed, treat as different.`, err);
1651
+ return false;
1652
+ }
1653
+ }
1500
1654
  previewInNativeWindow(viewOrRegion) {
1655
+ var _a;
1501
1656
  return __awaiter(this, void 0, void 0, function* () {
1502
1657
  if (this.serverMode === TRTCMediaMixingServerMode.Embedded && (this.serverStatus === TRTCMediaMixingServerStatus.Started || this.serverStatus === TRTCMediaMixingServerStatus.Starting)) {
1503
1658
  try {
@@ -1530,9 +1685,15 @@ class TRTCMediaMixingManager {
1530
1685
  this.destroyDesigner();
1531
1686
  this.nodeMediaMixingPlugin.setDisplayParams(this.windowID, viewOrRegion);
1532
1687
  }
1688
+ if (!((_a = this.paramsStore) === null || _a === void 0 ? void 0 : _a.streamLayout)) {
1689
+ this.setStreamLayout({
1690
+ layoutMode: types_1.TRTCStreamLayoutMode.None,
1691
+ });
1692
+ }
1533
1693
  });
1534
1694
  }
1535
1695
  previewInWebElement(viewOrRegion) {
1696
+ var _a;
1536
1697
  return __awaiter(this, void 0, void 0, function* () {
1537
1698
  if (this.serverMode === TRTCMediaMixingServerMode.Independent && (this.serverStatus === TRTCMediaMixingServerStatus.Started || this.serverStatus === TRTCMediaMixingServerStatus.Starting)) {
1538
1699
  try {
@@ -1559,6 +1720,11 @@ class TRTCMediaMixingManager {
1559
1720
  this.createDesigner();
1560
1721
  }
1561
1722
  }
1723
+ if (!((_a = this.paramsStore) === null || _a === void 0 ? void 0 : _a.streamLayout)) {
1724
+ this.setStreamLayout({
1725
+ layoutMode: types_1.TRTCStreamLayoutMode.None,
1726
+ });
1727
+ }
1562
1728
  }
1563
1729
  else {
1564
1730
  // neither native window nor web element, stop preview
@@ -1567,12 +1733,16 @@ class TRTCMediaMixingManager {
1567
1733
  });
1568
1734
  }
1569
1735
  previewInNone() {
1736
+ var _a;
1570
1737
  this.destroyResizeObserver();
1571
1738
  this.destroyLayoutManager();
1572
1739
  this.destroyDesigner();
1573
1740
  this.destroyWebRenderer();
1574
1741
  this.view = null;
1575
1742
  this.nodeMediaMixingPlugin.setDisplayParams(this.windowID, { left: 0, right: 0, top: 0, bottom: 0 });
1743
+ if ((_a = this.paramsStore) === null || _a === void 0 ? void 0 : _a.streamLayout) {
1744
+ this.paramsStore.streamLayout = null;
1745
+ }
1576
1746
  }
1577
1747
  createWebRenderer(view) {
1578
1748
  if (this.view === view) {
@@ -39,6 +39,13 @@ export declare type TRTCPhoneMirrorParam = {
39
39
  frameRate: number;
40
40
  bitrateKbps: number;
41
41
  };
42
+ export declare type TRTCOnlineVideoParam = {
43
+ networkCacheSizeKB: number;
44
+ playoutVolume: number;
45
+ };
46
+ export declare type TRTCVideoFileParam = {
47
+ playoutVolume: number;
48
+ };
42
49
  export declare type TRTCMediaSource = {
43
50
  sourceType: TRTCMediaSourceType;
44
51
  sourceId: string;
@@ -49,6 +56,10 @@ export declare type TRTCMediaSource = {
49
56
  rotation?: TRTCVideoRotation;
50
57
  fillMode?: TRTCVideoFillMode;
51
58
  mirrorType?: TRTCVideoMirrorType;
59
+ camera?: TRTCCameraCaptureParams;
60
+ screen?: TRTCScreenCaptureProperty;
61
+ localVideo?: TRTCVideoFileParam;
62
+ onlineVideo?: TRTCOnlineVideoParam;
52
63
  };
53
64
  export declare type TRTCMediaMixingEncParam = {
54
65
  videoEncoderParams: TRTCVideoEncParam;
@@ -83,20 +94,10 @@ export declare type TRTCStreamLayout = {
83
94
  };
84
95
  streams?: Array<TRTCStreamInfo>;
85
96
  };
86
- export declare type TRTCOnlineVideoParam = {
87
- networkCacheSizeKB: number;
88
- playoutVolume: number;
89
- };
90
- export declare type TRTCVideoFileParam = {
91
- playoutVolume: number;
92
- };
93
97
  export interface ITRTCMediaMixingManager {
94
98
  addMediaSource(mediaSource: TRTCMediaSource): Promise<void>;
95
99
  removeMediaSource(mediaSource: TRTCMediaSource): Promise<void>;
96
100
  updateMediaSource(mediaSource: TRTCMediaSource): Promise<void>;
97
- setCameraCaptureParam(cameraID: string, param: TRTCCameraCaptureParams): void;
98
- setPhoneMirrorParam(phoneMirrorSourceId: string, param: TRTCPhoneMirrorParam): void;
99
- setScreenCaptureProperty(screenWindowID: string, property: TRTCScreenCaptureProperty): void;
100
101
  startPublish(): Promise<void>;
101
102
  stopPublish(): Promise<void>;
102
103
  updatePublishParams(params: TRTCMediaMixingEncParam): Promise<void>;
package/liteav/trtc.js CHANGED
@@ -5434,6 +5434,10 @@ class TRTCCloud extends events_1.EventEmitter {
5434
5434
  try {
5435
5435
  const json = JSON.parse(jsonStr);
5436
5436
  const { api, params } = json;
5437
+ if (this._isMacPlatform() && api === 'TuikitLog') {
5438
+ this.logger.info(`TuikitLog: ${jsonStr}`);
5439
+ return;
5440
+ }
5437
5441
  if (this[api] && typeof this[api] === 'function') {
5438
5442
  this[api](params);
5439
5443
  }
@@ -110,7 +110,6 @@ export declare class TRTCVodPlayer implements IVodPlayer {
110
110
  private nativeVodPlayer;
111
111
  private videoRender;
112
112
  private mediaFilePath;
113
- private isStarted;
114
113
  private isDestroyed;
115
114
  private isRenderPrepared;
116
115
  private _setBufferRetryCount;
@@ -109,7 +109,6 @@ class TRTCVodPlayer {
109
109
  this._dataRenderCallback = this._dataRenderCallback.bind(this);
110
110
  this.nativeVodPlayer = new NodeTRTCEngine.NodeVodPlayer(mediaFilePath, repeat);
111
111
  this.mediaFilePath = mediaFilePath;
112
- this.isStarted = false;
113
112
  this.isDestroyed = false;
114
113
  this.isRenderPrepared = false;
115
114
  this._setBufferRetryCount = 0;
@@ -232,10 +231,6 @@ class TRTCVodPlayer {
232
231
  this.logger.warn('preload: player already destroyed');
233
232
  return;
234
233
  }
235
- if (this.isStarted) {
236
- this.logger.warn('preload: already started, ignored');
237
- return;
238
- }
239
234
  this.logger.info(`preload mediaFile: ${this.mediaFilePath}`);
240
235
  this._prepareRender();
241
236
  (_a = this.nativeVodPlayer) === null || _a === void 0 ? void 0 : _a.preload();
@@ -251,20 +246,16 @@ class TRTCVodPlayer {
251
246
  * @note 可以先调用 {@link preload} 预加载完成后再调用 start,也可以跳过 preload 直接调用 start。
252
247
  */
253
248
  start() {
254
- var _a;
249
+ var _a, _b;
255
250
  if (this.isDestroyed) {
256
251
  this.logger.warn('start: player already destroyed');
257
252
  return;
258
253
  }
259
254
  this.logger.info(`start mediaFile: ${this.mediaFilePath}`);
260
- if (this.isStarted) {
261
- this.logger.warn('start: already started, ignored');
262
- return;
263
- }
264
255
  this._prepareRender();
265
256
  this.attachTRTC();
266
257
  (_a = this.nativeVodPlayer) === null || _a === void 0 ? void 0 : _a.start();
267
- this.isStarted = true;
258
+ (_b = this.nativeVodPlayer) === null || _b === void 0 ? void 0 : _b.resume();
268
259
  }
269
260
  /**
270
261
  * 停止播放
@@ -276,14 +267,8 @@ class TRTCVodPlayer {
276
267
  return;
277
268
  }
278
269
  this.logger.info('stop');
279
- if (!this.isStarted && !this.isRenderPrepared) {
280
- return;
281
- }
282
- if (this.isStarted) {
283
- this.isStarted = false;
284
- (_a = this.nativeVodPlayer) === null || _a === void 0 ? void 0 : _a.stop();
285
- this.detachTRTC();
286
- }
270
+ (_a = this.nativeVodPlayer) === null || _a === void 0 ? void 0 : _a.stop();
271
+ this.detachTRTC();
287
272
  this._teardownRender();
288
273
  }
289
274
  /**
@@ -297,10 +282,6 @@ class TRTCVodPlayer {
297
282
  this.logger.warn('pause: player already destroyed');
298
283
  return;
299
284
  }
300
- if (!this.isStarted) {
301
- this.logger.warn('pause: player not started, ignored');
302
- return;
303
- }
304
285
  this.logger.info('pause');
305
286
  (_a = this.nativeVodPlayer) === null || _a === void 0 ? void 0 : _a.pause();
306
287
  }
@@ -310,17 +291,14 @@ class TRTCVodPlayer {
310
291
  * @note 仅在 {@link start} 之后调用才有效;未播放时调用会被忽略并打 warn 日志。
311
292
  */
312
293
  resume() {
313
- var _a;
294
+ var _a, _b;
314
295
  if (this.isDestroyed) {
315
296
  this.logger.warn('resume: player already destroyed');
316
297
  return;
317
298
  }
318
- if (!this.isStarted) {
319
- this.logger.warn('resume: player not started, ignored');
320
- return;
321
- }
322
299
  this.logger.info('resume');
323
- (_a = this.nativeVodPlayer) === null || _a === void 0 ? void 0 : _a.resume();
300
+ (_a = this.nativeVodPlayer) === null || _a === void 0 ? void 0 : _a.start();
301
+ (_b = this.nativeVodPlayer) === null || _b === void 0 ? void 0 : _b.resume();
324
302
  }
325
303
  /**
326
304
  * 跳转到指定播放位置(seek)
@@ -335,7 +313,7 @@ class TRTCVodPlayer {
335
313
  this.logger.warn('seek: player already destroyed');
336
314
  return;
337
315
  }
338
- if (!this.isStarted && !this.isRenderPrepared) {
316
+ if (!this.isRenderPrepared) {
339
317
  this.logger.warn(`seek: player not preloaded or started, ignored (msPos=${msPos})`);
340
318
  return;
341
319
  }
@@ -370,7 +348,7 @@ class TRTCVodPlayer {
370
348
  this.logger.warn('switchSource: newMediaFile is empty, ignored');
371
349
  return;
372
350
  }
373
- if (!this.isStarted && !this.isRenderPrepared) {
351
+ if (!this.isRenderPrepared) {
374
352
  this.logger.warn(`switchSource: player not preloaded or started, ignored (newMediaFile=${newMediaFile})`);
375
353
  return;
376
354
  }
@@ -698,14 +676,8 @@ class TRTCVodPlayer {
698
676
  var _a;
699
677
  (_a = this.nativeVodPlayer) === null || _a === void 0 ? void 0 : _a.setEventCallback((args) => {
700
678
  const event = args[0];
701
- if ((event === TRTCVodPlayerEvent.onVodPlayerStopped || event === TRTCVodPlayerEvent.onVodPlayerError) && this.isStarted) {
702
- this.isStarted = false;
703
- }
704
679
  switch (event) {
705
680
  case TRTCVodPlayerEvent.onVodPlayerStarted:
706
- if (!this.isStarted) {
707
- this.isStarted = true;
708
- }
709
681
  this.fire(TRTCVodPlayerEvent.onVodPlayerStarted, args[1].msLength);
710
682
  break;
711
683
  case TRTCVodPlayerEvent.onVodPlayerLoaded: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trtc-electron-sdk",
3
- "version": "13.3.801",
3
+ "version": "13.3.802-beta.1",
4
4
  "description": "trtc electron sdk",
5
5
  "main": "./liteav/index.js",
6
6
  "types": "./liteav/index.d.ts",