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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/liteav/MediaMixingDesigner/index.d.ts +12 -8
  2. package/liteav/MediaMixingDesigner/index.js +135 -79
  3. package/liteav/base/DevicePixelRatioObserver.d.ts +12 -0
  4. package/liteav/base/DevicePixelRatioObserver.js +32 -0
  5. package/liteav/base/PromiseStore.d.ts +10 -0
  6. package/liteav/base/PromiseStore.js +58 -0
  7. package/liteav/constant.d.ts +1 -0
  8. package/liteav/constant.js +4 -0
  9. package/liteav/extensions/MediaMixingManager/MediaMixingManager.d.ts +429 -0
  10. package/liteav/extensions/MediaMixingManager/MediaMixingManager.js +1290 -0
  11. package/liteav/extensions/MediaMixingManager/MediaMixingService.d.ts +60 -0
  12. package/liteav/extensions/MediaMixingManager/MediaMixingService.js +80 -0
  13. package/liteav/extensions/MediaMixingManager/StreamLayout/BaseStreamLayoutManager.d.ts +32 -0
  14. package/liteav/extensions/MediaMixingManager/StreamLayout/BaseStreamLayoutManager.js +114 -0
  15. package/liteav/extensions/MediaMixingManager/StreamLayout/CustomStreamLayoutManager.d.ts +11 -0
  16. package/liteav/extensions/MediaMixingManager/StreamLayout/CustomStreamLayoutManager.js +135 -0
  17. package/liteav/extensions/MediaMixingManager/StreamLayout/NoneStreamLayoutManager.d.ts +11 -0
  18. package/liteav/extensions/MediaMixingManager/StreamLayout/NoneStreamLayoutManager.js +73 -0
  19. package/liteav/extensions/MediaMixingManager/StreamLayout/index.d.ts +7 -0
  20. package/liteav/extensions/MediaMixingManager/StreamLayout/index.js +34 -0
  21. package/liteav/extensions/MediaMixingManager/StreamLayout/types.d.ts +25 -0
  22. package/liteav/extensions/MediaMixingManager/StreamLayout/types.js +2 -0
  23. package/liteav/extensions/MediaMixingManager/index.d.ts +4 -227
  24. package/liteav/extensions/MediaMixingManager/index.js +30 -589
  25. package/liteav/extensions/MediaMixingManager/types.d.ts +107 -0
  26. package/liteav/extensions/MediaMixingManager/types.js +26 -0
  27. package/liteav/trtc.d.ts +67 -13
  28. package/liteav/trtc.js +159 -61
  29. package/liteav/trtc_define.d.ts +29 -3
  30. package/liteav/trtc_define.js +97 -29
  31. package/liteav/utils.d.ts +27 -0
  32. package/liteav/utils.js +85 -1
  33. package/package.json +2 -2
  34. package/scripts/download.js +153 -169
@@ -0,0 +1,107 @@
1
+ import { TRTCVideoRotation, TRTCVideoFillMode, TRTCVideoMirrorType, TRTCVideoEncParam, TRTCCameraCaptureParams, Rect, TRTCScreenCaptureProperty } from '../../trtc_define';
2
+ export declare enum TRTCMediaMixingErrorCode {
3
+ Success = 0,
4
+ Error = -1,
5
+ InvalidParams = -2,
6
+ NotFoundSource = -3,
7
+ ImageSourceLoadFailed = -4,
8
+ CameraNotAuthorized = -5,
9
+ CameraIsOccupied = -6,
10
+ CameraDisconnected = -7
11
+ }
12
+ export declare enum TRTCMediaSourceType {
13
+ kCamera = 0,
14
+ kScreen = 1,
15
+ kImage = 2,
16
+ kPhoneMirror = 4
17
+ }
18
+ export declare type TRTCPhoneMirrorParam = {
19
+ platformType: number;
20
+ connectType: number;
21
+ deviceId: string;
22
+ deviceName: string;
23
+ placeholderImagePath: string;
24
+ frameRate: number;
25
+ bitrateKbps: number;
26
+ };
27
+ export declare type TRTCMediaSource = {
28
+ sourceType: TRTCMediaSourceType;
29
+ sourceId: string;
30
+ zOrder: number;
31
+ enableGreenScreen?: boolean;
32
+ rect: Rect;
33
+ isSelected?: boolean;
34
+ rotation?: TRTCVideoRotation;
35
+ fillMode?: TRTCVideoFillMode;
36
+ mirrorType?: TRTCVideoMirrorType;
37
+ };
38
+ export declare type TRTCMediaMixingEncParam = {
39
+ videoEncoderParams: TRTCVideoEncParam;
40
+ canvasColor: number;
41
+ selectedBorderColor?: number | 0xFFFF00;
42
+ };
43
+ export declare enum TRTCStreamLayoutMode {
44
+ Custom = "Custom",
45
+ None = "None"
46
+ }
47
+ export declare type TRTCUserStream = {
48
+ userId: string;
49
+ fillMode?: TRTCVideoFillMode;
50
+ rect?: Rect;
51
+ zOrder?: number;
52
+ };
53
+ export declare type TRTCStreamInfo = {
54
+ userId: string;
55
+ x: number;
56
+ y: number;
57
+ w: number;
58
+ h: number;
59
+ zOrder?: number;
60
+ fillMode?: TRTCVideoFillMode;
61
+ };
62
+ export declare type TRTCStreamLayout = {
63
+ layoutMode: TRTCStreamLayoutMode;
64
+ userList?: Array<TRTCUserStream>;
65
+ size?: {
66
+ width: number;
67
+ height: number;
68
+ };
69
+ streams?: Array<TRTCStreamInfo>;
70
+ };
71
+ export interface ITRTCMediaMixingManager {
72
+ addMediaSource(mediaSource: TRTCMediaSource): Promise<void>;
73
+ removeMediaSource(mediaSource: TRTCMediaSource): Promise<void>;
74
+ updateMediaSource(mediaSource: TRTCMediaSource): Promise<void>;
75
+ setCameraCaptureParam(cameraID: string, param: TRTCCameraCaptureParams): void;
76
+ setPhoneMirrorParam(phoneMirrorSourceId: string, param: TRTCPhoneMirrorParam): void;
77
+ setScreenCaptureProperty(screenWindowID: string, property: TRTCScreenCaptureProperty): void;
78
+ startPublish(): Promise<void>;
79
+ stopPublish(): Promise<void>;
80
+ updatePublishParams(params: TRTCMediaMixingEncParam): Promise<void>;
81
+ /**
82
+ * @deprecated
83
+ */
84
+ setDisplayParams(windowID: number | Uint8Array, regionOrView: HTMLElement | Rect | null): void;
85
+ bindPreviewArea(windowID: Uint8Array, view: HTMLElement | Rect | null): void;
86
+ setStreamLayout(options: TRTCStreamLayout): void;
87
+ destroy(): void;
88
+ on(event: string, func: (...args: any[]) => void): void;
89
+ off(event: string, func: (...args: any[]) => void): void;
90
+ }
91
+ export interface ITRTCMediaMixingEvent {
92
+ onSourceSelected(mediaSource: TRTCMediaSource | null): void;
93
+ onSourceMoved(mediaSource: TRTCMediaSource, rect: Rect): void;
94
+ onSourceResized(mediaSource: TRTCMediaSource, rect: Rect): void;
95
+ onRightButtonClicked(mediaSource: TRTCMediaSource | null): void;
96
+ onSourcePlugged(source: TRTCMediaSource | TRTCPhoneMirrorParam, detail: string): void;
97
+ onSourceConnected(source: TRTCMediaSource | TRTCPhoneMirrorParam, detail: string): void;
98
+ onSourceDisconnected(source: TRTCMediaSource | TRTCPhoneMirrorParam, detail: string): void;
99
+ onSourceUnplugged(source: TRTCMediaSource | TRTCPhoneMirrorParam, detail: string): void;
100
+ }
101
+ export interface ITRTCMediaMixingService {
102
+ startMediaMixingServer(path: string): Promise<void>;
103
+ stopMediaMixingServer(): Promise<void>;
104
+ }
105
+ export interface ITRTCMediaMixingServiceEvent {
106
+ onMediaMixingServerLost(): void;
107
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TRTCStreamLayoutMode = exports.TRTCMediaSourceType = exports.TRTCMediaMixingErrorCode = void 0;
4
+ var TRTCMediaMixingErrorCode;
5
+ (function (TRTCMediaMixingErrorCode) {
6
+ TRTCMediaMixingErrorCode[TRTCMediaMixingErrorCode["Success"] = 0] = "Success";
7
+ TRTCMediaMixingErrorCode[TRTCMediaMixingErrorCode["Error"] = -1] = "Error";
8
+ TRTCMediaMixingErrorCode[TRTCMediaMixingErrorCode["InvalidParams"] = -2] = "InvalidParams";
9
+ TRTCMediaMixingErrorCode[TRTCMediaMixingErrorCode["NotFoundSource"] = -3] = "NotFoundSource";
10
+ TRTCMediaMixingErrorCode[TRTCMediaMixingErrorCode["ImageSourceLoadFailed"] = -4] = "ImageSourceLoadFailed";
11
+ TRTCMediaMixingErrorCode[TRTCMediaMixingErrorCode["CameraNotAuthorized"] = -5] = "CameraNotAuthorized";
12
+ TRTCMediaMixingErrorCode[TRTCMediaMixingErrorCode["CameraIsOccupied"] = -6] = "CameraIsOccupied";
13
+ TRTCMediaMixingErrorCode[TRTCMediaMixingErrorCode["CameraDisconnected"] = -7] = "CameraDisconnected";
14
+ })(TRTCMediaMixingErrorCode = exports.TRTCMediaMixingErrorCode || (exports.TRTCMediaMixingErrorCode = {}));
15
+ var TRTCMediaSourceType;
16
+ (function (TRTCMediaSourceType) {
17
+ TRTCMediaSourceType[TRTCMediaSourceType["kCamera"] = 0] = "kCamera";
18
+ TRTCMediaSourceType[TRTCMediaSourceType["kScreen"] = 1] = "kScreen";
19
+ TRTCMediaSourceType[TRTCMediaSourceType["kImage"] = 2] = "kImage";
20
+ TRTCMediaSourceType[TRTCMediaSourceType["kPhoneMirror"] = 4] = "kPhoneMirror";
21
+ })(TRTCMediaSourceType = exports.TRTCMediaSourceType || (exports.TRTCMediaSourceType = {}));
22
+ var TRTCStreamLayoutMode;
23
+ (function (TRTCStreamLayoutMode) {
24
+ TRTCStreamLayoutMode["Custom"] = "Custom";
25
+ TRTCStreamLayoutMode["None"] = "None";
26
+ })(TRTCStreamLayoutMode = exports.TRTCStreamLayoutMode || (exports.TRTCStreamLayoutMode = {}));
package/liteav/trtc.d.ts CHANGED
@@ -3,7 +3,7 @@ import { EventEmitter } from 'events';
3
3
  import { TRTCConfig } from './Renderer/util';
4
4
  import TRTCLocalMediaTranscoder from './LocalMediaTranscoder';
5
5
  import { AudioMusicParam, Rect, TRTCAppScene, TRTCAudioEffectParam, TRTCAudioQuality, TRTCBeautyStyle, TRTCDeviceState, TRTCDeviceType, TRTCLogLevel, TRTCRenderParams, TRTCRoleType, TRTCSpeedTestResult, TRTCStatistics, TRTCSwitchRoomParam, TRTCVideoBufferType, TRTCVideoFillMode, TRTCAudioFrame, TRTCVideoPixelFormat, TRTCVideoRotation, TRTCVideoStreamType, TRTCVolumeInfo, TRTCWaterMarkSrcType, TRTCQualityInfo, TRTCPluginType, TRTCPluginInfo, TRTCVideoProcessPluginOptions, TRTCMediaEncryptDecryptPluginOptions, TRTCAudioRecordingParams, TRTCScreenCaptureSourceInfo, TRTCScreenCaptureProperty, TRTCSpeedTestParams, TRTCRecordType, TRTCDeviceInfo, TRTCCameraCaptureParams, TRTCImageBuffer, TRTCInitConfig, TRTCAudioParallelParams, TRTCVoiceReverbType, TRTCVoiceChangerType, TRTCMusicPlayObserver, TRTCAudioFrameCallback, TRTCAudioProcessPluginOptions, TRTCPublishTarget, TRTCStreamEncoderParam, TRTCStreamMixingConfig } from './trtc_define';
6
- import TRTCMediaMixingManager from './extensions/MediaMixingManager';
6
+ import TRTCMediaMixingManager, { TRTCMediaMixingService } from './extensions/MediaMixingManager';
7
7
  /**
8
8
  * 腾讯云视频通话功能的主要接口类
9
9
  *
@@ -20,6 +20,7 @@ declare class TRTCCloud extends EventEmitter {
20
20
  private logger;
21
21
  private id;
22
22
  private static isIPCMode;
23
+ private static ipcModeReferenceCount;
23
24
  private static sharedTRTCCloudInstance;
24
25
  private static subInstances;
25
26
  private stateStore;
@@ -46,6 +47,7 @@ declare class TRTCCloud extends EventEmitter {
46
47
  private deviceManager;
47
48
  private audioEffectManager;
48
49
  private pluginManager;
50
+ private mediaMixingService;
49
51
  private mediaMixingManager;
50
52
  private localRotation;
51
53
  private localMirrorType;
@@ -61,6 +63,7 @@ declare class TRTCCloud extends EventEmitter {
61
63
  private playAudioEffectIdList;
62
64
  private remoteVideoBufferMap;
63
65
  private localVideoBufferMap;
66
+ private paramsStore;
64
67
  /**
65
68
  * @param {TRTCInitConfig} [config] - 初始化参数,可选
66
69
  * @param {Record<string, any>} [config.networkProxy] - 网络代理参数,可选。为空时,默认不开启网络代理。
@@ -96,11 +99,11 @@ declare class TRTCCloud extends EventEmitter {
96
99
  * rtcCloud.startLocalAudio(); // 主实例开启麦克风采集
97
100
  *
98
101
  * const childRtcCloud = rtcCloud.createSubCloud();
99
- * childRtcCloud.startSystemAudioLoopback(); // 子实例开启系统音采集
102
+ * childRtcCloud?.startSystemAudioLoopback(); // 子实例开启系统音采集
100
103
  *
101
- * @returns {TRTCCloud}
104
+ * @returns {TRTCCloud|null}
102
105
  */
103
- createSubCloud(config?: TRTCInitConfig): TRTCCloud;
106
+ createSubCloud(config?: TRTCInitConfig): TRTCCloud | null;
104
107
  /**
105
108
  * 获取 TRTC 配置对象
106
109
  *
@@ -2897,6 +2900,33 @@ declare class TRTCCloud extends EventEmitter {
2897
2900
  private _RGBA2BGRA;
2898
2901
  private _isMacPlatform;
2899
2902
  private _setRemoteVideoBuffer;
2903
+ /**
2904
+ * 调用实验性 API 接口
2905
+ *
2906
+ * 注意:该接口用于调用一些实验性功能
2907
+ *
2908
+ * @param {String} jsonStr - 接口及参数描述的 JSON 字符串
2909
+ */
2910
+ callExperimentalAPI(jsonStr: string): void;
2911
+ /**
2912
+ * @private
2913
+ *
2914
+ * 开启/关闭视频渲染帧率控制
2915
+ *
2916
+ * @param {Record<string, unknown>} params - 参数
2917
+ *
2918
+ * @example
2919
+ * import TRTCCloud from "trtc-electron-sdk";
2920
+ *
2921
+ * const trtcCloud = TRTCCloud.getTRTCShareInstance();
2922
+ * trtcCloud.callExperimentalAPI(JSON.stringify({
2923
+ * api: "disableLocalRenderFPSOptimization",
2924
+ * params: {
2925
+ * disable: true
2926
+ * }
2927
+ * }));
2928
+ */
2929
+ private disableLocalRenderFPSOptimization;
2900
2930
  /**
2901
2931
  * 创建本地多媒体合图实例
2902
2932
  *
@@ -2944,20 +2974,44 @@ declare class TRTCCloud extends EventEmitter {
2944
2974
  * @returns {TRTCMediaMixingManager | null}
2945
2975
  */
2946
2976
  getMediaMixingManager(): TRTCMediaMixingManager | null;
2977
+ /**
2978
+ * 获取本地混流服务对象
2979
+ *
2980
+ * 本地混流服务对象管理底层服务对象的启动、关闭,并可监听服务丢失事件,用来实现服务重启、恢复
2981
+ * @returns {TRTCMediaMixingService | null}
2982
+ *
2983
+ * @example
2984
+ * import TRTCCloud, { TRTCMediaMixingServiceEvent } from 'trtc-electron-sdk';
2985
+ *
2986
+ * const trtcCloud = TRTCCloud.getTRTCShareInstance({
2987
+ * isIPCMode: true
2988
+ * });
2989
+ *
2990
+ * const mediaMixingService = trtcCloud.getMediaMixingService();
2991
+ * const mediaMixingManager = trtcCloud.getMediaMixingManager();
2992
+ *
2993
+ * // listen to server lost event
2994
+ * mediaMixingService.on(TRTCMediaMixingServiceEvent.onMediaMixingServerLost, () => {
2995
+ * // restart server
2996
+ * mediaMixingService.startMediaMixingServer("Your config of 'liteav_media_server.exe' file path");
2997
+ *
2998
+ * // recover media sources and layout
2999
+ * mediaMixingManager.addMediaSource(...);
3000
+ * mediaMixingManager.setStreamLayout(...);
3001
+ * });
3002
+ *
3003
+ * // start sevver
3004
+ * mediaMixingService.startMediaMixingServer("Your config of 'liteav_media_server.exe' file path");
3005
+ *
3006
+ * // stop server
3007
+ * mediaMixingService.stopMediaMixingServer();
3008
+ */
3009
+ getMediaMixingService(): TRTCMediaMixingService | null;
2947
3010
  /**
2948
3011
  * 获取插件管理器
2949
3012
  * @private
2950
3013
  * @returns {TRTCPluginManager}
2951
3014
  */
2952
3015
  private getPluginManager;
2953
- /**
2954
- * 调用实验性 API 接口
2955
- *
2956
- * 注意:该接口用于调用一些实验性功能
2957
- *
2958
- * @param {String} jsonStr - 接口及参数描述的 JSON 字符串
2959
- */
2960
- callExperimentalAPI(jsonStr: string): void;
2961
- private disableLocalRenderFPSOptimization;
2962
3016
  }
2963
3017
  export default TRTCCloud;
package/liteav/trtc.js CHANGED
@@ -36,7 +36,7 @@ const LocalVideoRenderController_1 = __importDefault(require("./VideoRenderContr
36
36
  const VideoRenderFPSMonitor_1 = require("./VideoRenderControl/VideoRenderFPSMonitor");
37
37
  const DeviceManager_1 = __importDefault(require("./extensions/DeviceManager"));
38
38
  const AudioEffectManager_1 = __importDefault(require("./extensions/AudioEffectManager"));
39
- const MediaMixingManager_1 = __importDefault(require("./extensions/MediaMixingManager"));
39
+ const MediaMixingManager_1 = __importStar(require("./extensions/MediaMixingManager"));
40
40
  const PluginManager_1 = __importDefault(require("./extensions/PluginManager"));
41
41
  const NodeTRTCEngine = require('../build/Release/trtc_electron_sdk.node');
42
42
  const pkg = require('../package.json');
@@ -160,6 +160,7 @@ class TRTCCloud extends events_1.EventEmitter {
160
160
  constructor(config) {
161
161
  var _a;
162
162
  super();
163
+ this.paramsStore = {};
163
164
  this.id = !TRTCCloud.sharedTRTCCloudInstance ? 1 : (2 + (((_a = TRTCCloud.subInstances) === null || _a === void 0 ? void 0 : _a.length) || 0));
164
165
  this.logger = new logger_1.Logger(`TRTC_${this.id}`);
165
166
  const componentNO = getComponentNO();
@@ -173,9 +174,11 @@ class TRTCCloud extends events_1.EventEmitter {
173
174
  const newConfig = Object.assign({ jsVersion: pkg.version, componentNO }, config);
174
175
  if (!TRTCCloud.isIPCMode) {
175
176
  this.rtcCloud = new NodeTRTCEngine.NodeTRTCCloud(newConfig);
177
+ TRTCCloud.ipcModeReferenceCount = 0;
176
178
  }
177
179
  else {
178
180
  this.rtcCloud = new NodeTRTCEngine.NodeRemoteTRTCCloud(newConfig);
181
+ TRTCCloud.ipcModeReferenceCount = 1;
179
182
  }
180
183
  this.stateStore = new Map();
181
184
  this.videoRendererMap = new Map();
@@ -241,15 +244,8 @@ class TRTCCloud extends events_1.EventEmitter {
241
244
  isIPCMode: TRTCCloud.isIPCMode,
242
245
  nodeTRTCCloud: this.rtcCloud,
243
246
  });
244
- if (TRTCCloud.isIPCMode) {
245
- this.mediaMixingManager = new MediaMixingManager_1.default({
246
- deviceManager: this.deviceManager,
247
- nodeTRTCCloud: this.rtcCloud,
248
- });
249
- }
250
- else {
251
- this.mediaMixingManager = null;
252
- }
247
+ this.mediaMixingService = null;
248
+ this.mediaMixingManager = null;
253
249
  if (!TRTCCloud.sharedTRTCCloudInstance) {
254
250
  TRTCCloud.sharedTRTCCloudInstance = this;
255
251
  }
@@ -304,16 +300,18 @@ class TRTCCloud extends events_1.EventEmitter {
304
300
  * rtcCloud.startLocalAudio(); // 主实例开启麦克风采集
305
301
  *
306
302
  * const childRtcCloud = rtcCloud.createSubCloud();
307
- * childRtcCloud.startSystemAudioLoopback(); // 子实例开启系统音采集
303
+ * childRtcCloud?.startSystemAudioLoopback(); // 子实例开启系统音采集
308
304
  *
309
- * @returns {TRTCCloud}
305
+ * @returns {TRTCCloud|null}
310
306
  */
311
307
  createSubCloud(config) {
312
308
  if (this !== TRTCCloud.sharedTRTCCloudInstance) {
313
- throw new Error("createSubCloud() can only be called on the main instance created by getTRTCShareInstance().");
309
+ this.logger.warn("createSubCloud() can only be called on the main instance created by getTRTCShareInstance().");
310
+ return null;
314
311
  }
315
312
  if (TRTCCloud.isIPCMode) {
316
- throw new Error("createSubCloud() is not supported when `isIPCMode` is true.");
313
+ TRTCCloud.ipcModeReferenceCount = TRTCCloud.ipcModeReferenceCount + 1;
314
+ return TRTCCloud.sharedTRTCCloudInstance;
317
315
  }
318
316
  return new TRTCCloud(config);
319
317
  }
@@ -352,7 +350,13 @@ class TRTCCloud extends events_1.EventEmitter {
352
350
  * 销毁当前实例,释放资源
353
351
  */
354
352
  destroy() {
355
- var _a;
353
+ var _a, _b;
354
+ if (TRTCCloud.isIPCMode) {
355
+ TRTCCloud.ipcModeReferenceCount = TRTCCloud.ipcModeReferenceCount - 1;
356
+ if (TRTCCloud.ipcModeReferenceCount > 0) {
357
+ return;
358
+ }
359
+ }
356
360
  if (this === TRTCCloud.sharedTRTCCloudInstance) {
357
361
  if (TRTCCloud.subInstances) {
358
362
  TRTCCloud.subInstances.forEach(sub => {
@@ -374,7 +378,11 @@ class TRTCCloud extends events_1.EventEmitter {
374
378
  this.deviceManager.destroy();
375
379
  this.audioEffectManager.destroy();
376
380
  this.pluginManager.destroy();
377
- (_a = this.mediaMixingManager) === null || _a === void 0 ? void 0 : _a.destroy();
381
+ (_a = this.mediaMixingService) === null || _a === void 0 ? void 0 : _a.destroy();
382
+ (_b = this.mediaMixingManager) === null || _b === void 0 ? void 0 : _b.destroy();
383
+ Object.keys(this.paramsStore).forEach(key => {
384
+ delete this.paramsStore[key];
385
+ });
378
386
  }
379
387
  /////////////////////////////////////////////////////////////////////////////////
380
388
  //
@@ -1586,8 +1594,9 @@ class TRTCCloud extends events_1.EventEmitter {
1586
1594
  */
1587
1595
  enterRoom(params, scene) {
1588
1596
  if (params instanceof trtc_define_1.TRTCParams) {
1589
- // params.streamId = params.streamId === '' ? null : params.streamId;
1590
1597
  this.rtcCloud.enterRoom(params, scene);
1598
+ this.paramsStore.enterRoomParams = params;
1599
+ this.paramsStore.enterRoomScene = scene;
1591
1600
  }
1592
1601
  else {
1593
1602
  this.logger.error('trtc:enterRoom, params is not instanceof TRTCParams!');
@@ -1637,6 +1646,8 @@ class TRTCCloud extends events_1.EventEmitter {
1637
1646
  this.localVideoBufferMap.cameraTest.id = 0;
1638
1647
  }
1639
1648
  this.rtcCloud.exitRoom();
1649
+ this.paramsStore.enterRoomParams = undefined;
1650
+ this.paramsStore.enterRoomScene = undefined;
1640
1651
  }
1641
1652
  /**
1642
1653
  * 切换房间
@@ -1663,6 +1674,9 @@ class TRTCCloud extends events_1.EventEmitter {
1663
1674
  * - TRTCRoleAudience: 观众,只能观看,不能上行视频和音频,一个房间里的观众人数没有上限。
1664
1675
  */
1665
1676
  switchRole(role) {
1677
+ if (this.paramsStore.enterRoomParams) {
1678
+ this.paramsStore.enterRoomParams.role = role;
1679
+ }
1666
1680
  this.rtcCloud.switchRole(role);
1667
1681
  }
1668
1682
  /**
@@ -5232,9 +5246,68 @@ class TRTCCloud extends events_1.EventEmitter {
5232
5246
  }
5233
5247
  videoBufferInfo.buffer && this.rtcCloud.setRemoteVideoBuffer(userId, videoBufferInfo.buffer, videoBufferInfo.streamType, videoBufferInfo.width, videoBufferInfo.height, videoBufferInfo.pixelFormat, videoBufferInfo.id);
5234
5248
  }
5235
- //-------------------------------------------------//
5236
- // Local media transcoding API begin
5237
- //-------------------------------------------------//
5249
+ /////////////////////////////////////////////////////////////////////////////////
5250
+ //
5251
+ // 实验接口
5252
+ //
5253
+ /////////////////////////////////////////////////////////////////////////////////
5254
+ /**
5255
+ * 调用实验性 API 接口
5256
+ *
5257
+ * 注意:该接口用于调用一些实验性功能
5258
+ *
5259
+ * @param {String} jsonStr - 接口及参数描述的 JSON 字符串
5260
+ */
5261
+ callExperimentalAPI(jsonStr) {
5262
+ try {
5263
+ const json = JSON.parse(jsonStr);
5264
+ const { api, params } = json;
5265
+ if (this[api] && typeof this[api] === 'function') {
5266
+ this[api](params);
5267
+ }
5268
+ else {
5269
+ this.rtcCloud.callExperimentalAPI(jsonStr);
5270
+ }
5271
+ }
5272
+ catch (error) {
5273
+ this.logger.warn(`callExperimentalAPI invalid JSON parameter`, error, jsonStr);
5274
+ }
5275
+ }
5276
+ /**
5277
+ * @private
5278
+ *
5279
+ * 开启/关闭视频渲染帧率控制
5280
+ *
5281
+ * @param {Record<string, unknown>} params - 参数
5282
+ *
5283
+ * @example
5284
+ * import TRTCCloud from "trtc-electron-sdk";
5285
+ *
5286
+ * const trtcCloud = TRTCCloud.getTRTCShareInstance();
5287
+ * trtcCloud.callExperimentalAPI(JSON.stringify({
5288
+ * api: "disableLocalRenderFPSOptimization",
5289
+ * params: {
5290
+ * disable: true
5291
+ * }
5292
+ * }));
5293
+ */
5294
+ disableLocalRenderFPSOptimization(params) {
5295
+ this.videoRenderFPS = 60;
5296
+ if (params.disable === true) {
5297
+ VideoRenderFPSMonitor_1.videoRenderFPSMonitor.stop();
5298
+ }
5299
+ else {
5300
+ VideoRenderFPSMonitor_1.videoRenderFPSMonitor.start();
5301
+ }
5302
+ if (!TRTCCloud.isIPCMode) {
5303
+ this.rtcCloud.setVideoRenderFPS(this.videoRenderFPS);
5304
+ }
5305
+ }
5306
+ /////////////////////////////////////////////////////////////////////////////////
5307
+ //
5308
+ // 本地混流合图
5309
+ //
5310
+ /////////////////////////////////////////////////////////////////////////////////
5238
5311
  /**
5239
5312
  * 创建本地多媒体合图实例
5240
5313
  *
@@ -5275,9 +5348,6 @@ class TRTCCloud extends events_1.EventEmitter {
5275
5348
  }
5276
5349
  }
5277
5350
  }
5278
- //-------------------------------------------------//
5279
- // Local media transocoding API end
5280
- //-------------------------------------------------//
5281
5351
  /**
5282
5352
  * 获取设备管理器
5283
5353
  * @private
@@ -5313,54 +5383,82 @@ class TRTCCloud extends events_1.EventEmitter {
5313
5383
  * @returns {TRTCMediaMixingManager | null}
5314
5384
  */
5315
5385
  getMediaMixingManager() {
5386
+ if (TRTCCloud.isIPCMode) {
5387
+ if (!this.mediaMixingManager) {
5388
+ this.mediaMixingManager = new MediaMixingManager_1.default({
5389
+ deviceManager: this.deviceManager,
5390
+ nodeTRTCCloud: this.rtcCloud,
5391
+ trtcParamsStore: this.paramsStore,
5392
+ autoControlServer: true,
5393
+ });
5394
+ }
5395
+ }
5396
+ else {
5397
+ this.mediaMixingManager = null;
5398
+ }
5316
5399
  return this.mediaMixingManager;
5317
5400
  }
5318
5401
  /**
5319
- * 获取插件管理器
5320
- * @private
5321
- * @returns {TRTCPluginManager}
5322
- */
5323
- getPluginManager() {
5324
- return this.pluginManager;
5325
- }
5326
- /////////////////////////////////////////////////////////////////////////////////
5327
- //
5328
- // 实验接口
5329
- //
5330
- /////////////////////////////////////////////////////////////////////////////////
5331
- /**
5332
- * 调用实验性 API 接口
5402
+ * 获取本地混流服务对象
5333
5403
  *
5334
- * 注意:该接口用于调用一些实验性功能
5404
+ * 本地混流服务对象管理底层服务对象的启动、关闭,并可监听服务丢失事件,用来实现服务重启、恢复
5405
+ * @returns {TRTCMediaMixingService | null}
5335
5406
  *
5336
- * @param {String} jsonStr - 接口及参数描述的 JSON 字符串
5407
+ * @example
5408
+ * import TRTCCloud, { TRTCMediaMixingServiceEvent } from 'trtc-electron-sdk';
5409
+ *
5410
+ * const trtcCloud = TRTCCloud.getTRTCShareInstance({
5411
+ * isIPCMode: true
5412
+ * });
5413
+ *
5414
+ * const mediaMixingService = trtcCloud.getMediaMixingService();
5415
+ * const mediaMixingManager = trtcCloud.getMediaMixingManager();
5416
+ *
5417
+ * // listen to server lost event
5418
+ * mediaMixingService.on(TRTCMediaMixingServiceEvent.onMediaMixingServerLost, () => {
5419
+ * // restart server
5420
+ * mediaMixingService.startMediaMixingServer("Your config of 'liteav_media_server.exe' file path");
5421
+ *
5422
+ * // recover media sources and layout
5423
+ * mediaMixingManager.addMediaSource(...);
5424
+ * mediaMixingManager.setStreamLayout(...);
5425
+ * });
5426
+ *
5427
+ * // start sevver
5428
+ * mediaMixingService.startMediaMixingServer("Your config of 'liteav_media_server.exe' file path");
5429
+ *
5430
+ * // stop server
5431
+ * mediaMixingService.stopMediaMixingServer();
5337
5432
  */
5338
- callExperimentalAPI(jsonStr) {
5339
- try {
5340
- const json = JSON.parse(jsonStr);
5341
- const { api, params } = json;
5342
- if (this[api] && typeof this[api] === 'function') {
5343
- this[api](params);
5344
- }
5345
- else {
5346
- this.rtcCloud.callExperimentalAPI(jsonStr);
5433
+ getMediaMixingService() {
5434
+ if (TRTCCloud.isIPCMode) {
5435
+ if (!this.mediaMixingService) {
5436
+ if (!this.mediaMixingManager) {
5437
+ this.mediaMixingManager = new MediaMixingManager_1.default({
5438
+ deviceManager: this.deviceManager,
5439
+ nodeTRTCCloud: this.rtcCloud,
5440
+ trtcParamsStore: this.paramsStore,
5441
+ autoControlServer: false,
5442
+ });
5443
+ this.mediaMixingService = new MediaMixingManager_1.TRTCMediaMixingService(this.mediaMixingManager);
5444
+ }
5445
+ else {
5446
+ this.mediaMixingService = null;
5447
+ }
5347
5448
  }
5348
5449
  }
5349
- catch (error) {
5350
- this.logger.warn(`callExperimentalAPI invalid JSON parameter`, error);
5351
- }
5352
- }
5353
- disableLocalRenderFPSOptimization(params) {
5354
- this.videoRenderFPS = 60;
5355
- if (params.disable === true) {
5356
- VideoRenderFPSMonitor_1.videoRenderFPSMonitor.stop();
5357
- }
5358
5450
  else {
5359
- VideoRenderFPSMonitor_1.videoRenderFPSMonitor.start();
5360
- }
5361
- if (!TRTCCloud.isIPCMode) {
5362
- this.rtcCloud.setVideoRenderFPS(this.videoRenderFPS);
5451
+ this.mediaMixingService = null;
5363
5452
  }
5453
+ return this.mediaMixingService;
5454
+ }
5455
+ /**
5456
+ * 获取插件管理器
5457
+ * @private
5458
+ * @returns {TRTCPluginManager}
5459
+ */
5460
+ getPluginManager() {
5461
+ return this.pluginManager;
5364
5462
  }
5365
5463
  }
5366
5464
  class VideoRenderCallback {
@@ -25,7 +25,8 @@ export declare enum TRTCVideoResolution {
25
25
  TRTCVideoResolution_640_360 = 108,
26
26
  TRTCVideoResolution_960_540 = 110,
27
27
  TRTCVideoResolution_1280_720 = 112,
28
- TRTCVideoResolution_1920_1080 = 114
28
+ TRTCVideoResolution_1920_1080 = 114,
29
+ TRTCVideoResolution_2560_1440 = 116
29
30
  }
30
31
  export declare enum TRTCVideoResolutionMode {
31
32
  TRTCVideoResolutionModeLandscape = 0,
@@ -234,7 +235,7 @@ export declare class TRTCVideoFrame {
234
235
  * 音频帧数据
235
236
  *
236
237
  * @param {TRTCAudioFrameFormat} audioFormat - 音频帧的格式
237
- * @param {ArrayBuffer} data - 音频数据
238
+ * @param {Buffer|ArrayBuffer} data - 音频数据
238
239
  * @param {Number} length - 音频数据的长度
239
240
  * @param {Number} sampleRate - 采样率
240
241
  * @param {Number} channel - 声道数
@@ -244,7 +245,7 @@ export declare class TRTCVideoFrame {
244
245
  */
245
246
  export declare class TRTCAudioFrame {
246
247
  audioFormat: TRTCAudioFrameFormat;
247
- data: ArrayBuffer | null;
248
+ data: Buffer | ArrayBuffer | null;
248
249
  length: number;
249
250
  sampleRate: number;
250
251
  channel: number;
@@ -280,6 +281,23 @@ export declare enum TRTCCameraCaptureMode {
280
281
  TRTCCameraResolutionStrategyHighQuality = 2,
281
282
  TRTCCameraCaptureManual = 3
282
283
  }
284
+ export declare enum TRTCVideoColorRange {
285
+ TRTCVideoColorRange_Auto = 0,
286
+ TRTCVideoColorRange_Limited = 1,
287
+ TRTCVideoColorRange_Full = 2
288
+ }
289
+ export declare enum TRTCVideoColorSpace {
290
+ TRTCVideoColorSpace_Auto = 0,
291
+ TRTCVideoColorSpace_BT601 = 1,
292
+ TRTCVideoColorSpace_BT709 = 2
293
+ }
294
+ export declare enum TRTCVideoEncodeComplexity {
295
+ TRTCVideoEncodeComplexity_Fastest = 0,
296
+ TRTCVideoEncodeComplexity_Fast = 1,
297
+ TRTCVideoEncodeComplexity_Medium = 2,
298
+ TRTCVideoEncodeComplexity_Slow = 3,
299
+ TRTCVideoEncodeComplexity_Slowest = 4
300
+ }
283
301
  export declare type TRTCCameraCaptureParams = {
284
302
  /** 摄像头采集偏好 */
285
303
  mode: TRTCCameraCaptureMode;
@@ -287,6 +305,8 @@ export declare type TRTCCameraCaptureParams = {
287
305
  width: number;
288
306
  /** 采集图像高度 */
289
307
  height: number;
308
+ colorSpace?: TRTCVideoColorSpace;
309
+ colorRange?: TRTCVideoColorRange;
290
310
  };
291
311
  export declare enum TRTCWaterMarkSrcType {
292
312
  TRTCWaterMarkSrcTypeFile = 0,
@@ -368,6 +388,9 @@ export declare class TRTCParams {
368
388
  * @param {Boolean} enableAdjustRes - 【字段含义】是否允许动态调整分辨率(开启后会对云端录制产生影响)<br>
369
389
  * 【推荐取值】该功能适用于不需要云端录制的场景,开启后 SDK 会根据当前网络情况,智能选择出一个合适的分辨率,避免出现“大分辨率+小码率”的低效编码模式。<br>
370
390
  * 【特别说明】默认值:关闭。如有云端录制的需求,请不要开启此功能,因为如果视频分辨率发生变化后,云端录制出的 MP4 在普通的播放器上无法正常播放。<br>
391
+ * @param {TRTCVideoColorSpace} [colorSpace] - 编码色彩空间
392
+ * @param {TRTCVideoColorRange} [colorRange] - 编码色彩范围
393
+ * @param {TRTCVideoEncodeComplexity} [complexity] - 编码复杂度
371
394
  */
372
395
  export declare class TRTCVideoEncParam {
373
396
  videoResolution: TRTCVideoResolution;
@@ -376,6 +399,9 @@ export declare class TRTCVideoEncParam {
376
399
  videoBitrate: number;
377
400
  minVideoBitrate: number;
378
401
  enableAdjustRes: boolean;
402
+ colorRange?: TRTCVideoColorRange;
403
+ colorSpace?: TRTCVideoColorSpace;
404
+ complexity?: TRTCVideoEncodeComplexity;
379
405
  constructor(videoResolution?: TRTCVideoResolution, resMode?: TRTCVideoResolutionMode, videoFps?: number, videoBitrate?: number, minVideoBitrate?: number, enableAdjustRes?: boolean);
380
406
  }
381
407
  /**