trtc-electron-sdk 12.1.608 → 12.2.701

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/liteav/trtc.js CHANGED
@@ -37,11 +37,19 @@ const validate_util_1 = require("./validate-util");
37
37
  const logger_1 = __importStar(require("./logger"));
38
38
  const LocalVideoRenderController_1 = __importDefault(require("./VideoRenderControl/LocalVideoRenderController"));
39
39
  const VideoRenderFPSMonitor_1 = require("./VideoRenderControl/VideoRenderFPSMonitor");
40
+ const DeviceManager_1 = __importDefault(require("./extensions/DeviceManager"));
41
+ const AudioEffectManager_1 = __importDefault(require("./extensions/AudioEffectManager"));
42
+ const MediaMixingManager_1 = __importDefault(require("./extensions/MediaMixingManager"));
43
+ const PluginManager_1 = __importDefault(require("./extensions/PluginManager"));
40
44
  const NodeTRTCEngine = require('../build/Release/trtc_electron_sdk.node');
41
45
  const pkg = require('../package.json');
42
46
  __exportStar(require("./trtc_define"), exports);
43
47
  __exportStar(require("./trtc_code"), exports);
44
48
  __exportStar(require("./vod_player"), exports);
49
+ __exportStar(require("./extensions/DeviceManager"), exports);
50
+ __exportStar(require("./extensions/AudioEffectManager"), exports);
51
+ __exportStar(require("./extensions/MediaMixingManager"), exports);
52
+ __exportStar(require("./extensions/PluginManager"), exports);
45
53
  // 监听该事件,返回自定义视频渲染数据 ( bgra 格式)
46
54
  const CUSTOM_VIDEO_DATA = 'onVideoData';
47
55
  const LOCAL_VIDEO_DATA = 'onLocalVideoData';
@@ -154,13 +162,33 @@ const getComponentNO = function () {
154
162
  *
155
163
  */
156
164
  class TRTCCloud extends events_1.EventEmitter {
165
+ /**
166
+ * 构造函数
167
+ * @param config {TRTCInitConfig} - 初始化参数,可选
168
+ * @param config.networkProxy {Record<string, any>} - 网络代理参数,可选。为空时,默认不开启网络代理。
169
+ * @param config.isIPCMode {Boolean} - 是否跨进程模式,跨进程模式支持本地混流且混流视频采用原生窗口渲染。默认:false,不开启。
170
+ */
157
171
  constructor(config) {
158
172
  var _a;
159
173
  super();
160
174
  this.id = !TRTCCloud.sharedTRTCCloudInstance ? 1 : (2 + (((_a = TRTCCloud.subInstances) === null || _a === void 0 ? void 0 : _a.length) || 0));
161
175
  this.logger = new logger_1.Logger(`TRTC_${this.id}`);
162
176
  const componentNO = getComponentNO();
163
- this.rtcCloud = new NodeTRTCEngine.NodeTRTCCloud(Object.assign({ jsVersion: pkg.version, componentNO }, config));
177
+ if (TRTCCloud.isIPCMode === null || TRTCCloud.isIPCMode === undefined) {
178
+ TRTCCloud.isIPCMode = (config === null || config === void 0 ? void 0 : config.isIPCMode) || false;
179
+ if (TRTCCloud.isIPCMode) {
180
+ NodeTRTCEngine.setRemoteTrtcWithAcrossProcessMode(TRTCCloud.isIPCMode);
181
+ }
182
+ logger_1.default.log(`TRTC use mode:${TRTCCloud.isIPCMode}`);
183
+ }
184
+ const newConfig = Object.assign({ jsVersion: pkg.version, componentNO }, config);
185
+ if (!TRTCCloud.isIPCMode) {
186
+ this.rtcCloud = new NodeTRTCEngine.NodeTRTCCloud(newConfig);
187
+ }
188
+ else {
189
+ this.rtcCloud = new NodeTRTCEngine.NodeRemoteTRTCCloud(newConfig);
190
+ }
191
+ this.stateStore = new Map();
164
192
  this.videoRendererMap = new Map();
165
193
  this.pixelFormat = trtc_define_1.TRTCVideoPixelFormat.TRTCVideoPixelFormat_I420;
166
194
  this.pixelLength = 1.5;
@@ -245,7 +273,9 @@ class TRTCCloud extends events_1.EventEmitter {
245
273
  }
246
274
  onFPSChanged(options) {
247
275
  this.videoRenderFPS = options.videoFPS !== -1 ? options.videoFPS : 60;
248
- this.rtcCloud.setVideoRenderFPS(this.videoRenderFPS);
276
+ if (!TRTCCloud.isIPCMode) {
277
+ this.rtcCloud.setVideoRenderFPS(this.videoRenderFPS);
278
+ }
249
279
  }
250
280
  /**
251
281
  * 创建子实例
@@ -319,6 +349,7 @@ class TRTCCloud extends events_1.EventEmitter {
319
349
  VideoRenderFPSMonitor_1.videoRenderFPSMonitor.off('videoRenderFPS', this.onFPSChanged);
320
350
  this.playAudioEffectIdList = [];
321
351
  this.remoteFillModeMap.clear();
352
+ // this.destroyLocalMediaTranscoder();
322
353
  this.rtcCloud.destroy();
323
354
  this.rtcCloud = null;
324
355
  }
@@ -1296,7 +1327,11 @@ class TRTCCloud extends events_1.EventEmitter {
1296
1327
  * 当您调用 [stopLocalRecording]{@link TRTCCloud#stopLocalRecording} 停止本地媒体录制任务时,SDK 会抛出该事件回调,用于通知您录制任务的最终结果。
1297
1328
  *
1298
1329
  * @event TRTCCallback#onLocalRecordComplete
1299
- * @param {number} errCode - 错误码 0:录制成功;-1:录制失败;-2:切换分辨率或横竖屏导致录制结束。
1330
+ * @param {number} errCode - 错误码
1331
+ * - 0:录制成功;
1332
+ * - -1:录制失败;
1333
+ * - -2:切换分辨率或横竖屏导致录制结束;
1334
+ * - -3:录制时间太短,或未采集到任何视频或音频数据,请检查录制时长,或是否已开启音、视频采集。
1300
1335
  * @param {string} storagePath - 录制文件存储路径
1301
1336
  */
1302
1337
  handleOnLocalRecordComplete(errCode, storagePath) {
@@ -1878,7 +1913,7 @@ class TRTCCloud extends events_1.EventEmitter {
1878
1913
  */
1879
1914
  setCameraCaptureParams(params) {
1880
1915
  if (params && (0, validate_util_1.isNumber)(params.mode) && (0, validate_util_1.isNumber)(params.width) && (0, validate_util_1.isNumber)(params.height)) {
1881
- this.rtcCloud.setCameraCaptureParam(params);
1916
+ this.getDeviceManager().setCameraCaptureParam(params);
1882
1917
  }
1883
1918
  else {
1884
1919
  this.logger.error('setCameraCaptureParams invalid params:', params);
@@ -2639,27 +2674,10 @@ class TRTCCloud extends events_1.EventEmitter {
2639
2674
  * var camera = cameralist[i];
2640
2675
  * console.info("camera deviceName: " + camera.deviceName + " deviceId:" + camera.deviceId);
2641
2676
  * }
2642
- * @return {TRTCDeviceInfo[]} 摄像头管理器列表
2677
+ * @return {Array<TRTCDeviceInfo>} 摄像头管理器列表
2643
2678
  */
2644
2679
  getCameraDevicesList() {
2645
- const deviceInfos = this.rtcCloud.getDevicesList(trtc_define_1.TRTCDeviceType.TRTCDeviceTypeCamera);
2646
- deviceInfos.forEach(item => {
2647
- try {
2648
- if (item.deviceProperties) {
2649
- const properties = JSON.parse(item.deviceProperties);
2650
- item.deviceProperties = properties;
2651
- }
2652
- else {
2653
- // 虚拟摄像头可能没有 deviceProperties 字段
2654
- item.deviceProperties = {};
2655
- }
2656
- }
2657
- catch (e) {
2658
- this.logger.warn('camera device properties parse error.', JSON.stringify(item));
2659
- item.deviceProperties = {};
2660
- }
2661
- });
2662
- return deviceInfos;
2680
+ return this.getDeviceManager().getDevicesList(trtc_define_1.TRTCDeviceType.TRTCDeviceTypeCamera);
2663
2681
  }
2664
2682
  /**
2665
2683
  * 设置要使用的摄像头
@@ -2667,7 +2685,7 @@ class TRTCCloud extends events_1.EventEmitter {
2667
2685
  * @param {String} deviceId - 从 getCameraDevicesList 中得到的设备 ID
2668
2686
  */
2669
2687
  setCurrentCameraDevice(deviceId) {
2670
- this.rtcCloud.setCurrentDevice(trtc_define_1.TRTCDeviceType.TRTCDeviceTypeCamera, deviceId);
2688
+ this.getDeviceManager().setCurrentDevice(trtc_define_1.TRTCDeviceType.TRTCDeviceTypeCamera, deviceId);
2671
2689
  }
2672
2690
  /**
2673
2691
  * 获取当前使用的摄像头
@@ -2675,7 +2693,13 @@ class TRTCCloud extends events_1.EventEmitter {
2675
2693
  * @return {TRTCDeviceInfo} 设备信息,能获取设备 ID 和设备名称
2676
2694
  */
2677
2695
  getCurrentCameraDevice() {
2678
- return this.rtcCloud.getCurrentDevice(trtc_define_1.TRTCDeviceType.TRTCDeviceTypeCamera);
2696
+ if (TRTCCloud.isIPCMode) {
2697
+ this.getDeviceManager().getCurrentDevice(trtc_define_1.TRTCDeviceType.TRTCDeviceTypeCamera);
2698
+ return this.stateStore.get('currentCamera');
2699
+ }
2700
+ else {
2701
+ return this.rtcCloud.getCurrentDevice(trtc_define_1.TRTCDeviceType.TRTCDeviceTypeCamera);
2702
+ }
2679
2703
  }
2680
2704
  /////////////////////////////////////////////////////////////////////////////////
2681
2705
  //
@@ -2691,10 +2715,10 @@ class TRTCCloud extends events_1.EventEmitter {
2691
2715
  * var mic = miclist[i];
2692
2716
  * console.info("mic deviceName: " + mic.deviceName + " deviceId:" + mic.deviceId);
2693
2717
  * }
2694
- * @return {TRTCDeviceInfo[]} 麦克风管理器列表
2718
+ * @return {Array<TRTCDeviceInfo>} 麦克风管理器列表
2695
2719
  */
2696
2720
  getMicDevicesList() {
2697
- return this.rtcCloud.getDevicesList(trtc_define_1.TRTCDeviceType.TRTCDeviceTypeMic);
2721
+ return this.getDeviceManager().getDevicesList(trtc_define_1.TRTCDeviceType.TRTCDeviceTypeMic);
2698
2722
  }
2699
2723
  /**
2700
2724
  * 获取当前选择的麦克风
@@ -2702,7 +2726,13 @@ class TRTCCloud extends events_1.EventEmitter {
2702
2726
  * @return {TRTCDeviceInfo} 设备信息,能获取设备 ID 和设备名称
2703
2727
  */
2704
2728
  getCurrentMicDevice() {
2705
- return this.rtcCloud.getCurrentDevice(trtc_define_1.TRTCDeviceType.TRTCDeviceTypeMic);
2729
+ if (TRTCCloud.isIPCMode) {
2730
+ this.getDeviceManager().getCurrentDevice(trtc_define_1.TRTCDeviceType.TRTCDeviceTypeMic);
2731
+ return this.stateStore.get('currentMic');
2732
+ }
2733
+ else {
2734
+ return this.rtcCloud.getCurrentDevice(trtc_define_1.TRTCDeviceType.TRTCDeviceTypeMic);
2735
+ }
2706
2736
  }
2707
2737
  /**
2708
2738
  * 设置要使用的麦克风
@@ -2712,7 +2742,7 @@ class TRTCCloud extends events_1.EventEmitter {
2712
2742
  * @param {String} micId - 从 getMicDevicesList 中得到的设备 ID
2713
2743
  */
2714
2744
  setCurrentMicDevice(micId) {
2715
- this.rtcCloud.setCurrentDevice(trtc_define_1.TRTCDeviceType.TRTCDeviceTypeMic, micId);
2745
+ this.getDeviceManager().setCurrentDevice(trtc_define_1.TRTCDeviceType.TRTCDeviceTypeMic, micId);
2716
2746
  }
2717
2747
  /**
2718
2748
  * 获取系统当前麦克风设备音量
@@ -2721,7 +2751,13 @@ class TRTCCloud extends events_1.EventEmitter {
2721
2751
  * @return {Number} 音量值,范围是0 - 100
2722
2752
  */
2723
2753
  getCurrentMicDeviceVolume() {
2724
- return this.rtcCloud.getCurrentDeviceVolume(trtc_define_1.TRTCDeviceType.TRTCDeviceTypeMic);
2754
+ if (TRTCCloud.isIPCMode) {
2755
+ this.getDeviceManager().getCurrentDeviceVolume(trtc_define_1.TRTCDeviceType.TRTCDeviceTypeMic);
2756
+ return this.stateStore.get('currentMicVolume');
2757
+ }
2758
+ else {
2759
+ return this.getDeviceManager().getCurrentDeviceVolume(trtc_define_1.TRTCDeviceType.TRTCDeviceTypeMic);
2760
+ }
2725
2761
  }
2726
2762
  /**
2727
2763
  * 设置系统当前麦克风设备的音量
@@ -2730,7 +2766,7 @@ class TRTCCloud extends events_1.EventEmitter {
2730
2766
  * @param {Number} volume - 麦克风音量值,范围0 - 100
2731
2767
  */
2732
2768
  setCurrentMicDeviceVolume(volume) {
2733
- this.rtcCloud.setCurrentDeviceVolume(trtc_define_1.TRTCDeviceType.TRTCDeviceTypeMic, volume);
2769
+ this.getDeviceManager().setCurrentDeviceVolume(trtc_define_1.TRTCDeviceType.TRTCDeviceTypeMic, volume);
2734
2770
  }
2735
2771
  /**
2736
2772
  * 设置系统当前麦克风设备的静音状态
@@ -2738,7 +2774,7 @@ class TRTCCloud extends events_1.EventEmitter {
2738
2774
  * @param {Boolean} mute 设置为 true 时,麦克风设备静音;设置为 false时,麦克风设备取消静音
2739
2775
  */
2740
2776
  setCurrentMicDeviceMute(mute) {
2741
- this.rtcCloud.setCurrentDeviceMute(trtc_define_1.TRTCDeviceType.TRTCDeviceTypeMic, mute);
2777
+ this.getDeviceManager().setCurrentDeviceMute(trtc_define_1.TRTCDeviceType.TRTCDeviceTypeMic, mute);
2742
2778
  }
2743
2779
  /**
2744
2780
  * 获取系统当前麦克风设备是否静音
@@ -2746,7 +2782,13 @@ class TRTCCloud extends events_1.EventEmitter {
2746
2782
  * @return {Boolean} 静音状态
2747
2783
  */
2748
2784
  getCurrentMicDeviceMute() {
2749
- return this.rtcCloud.getCurrentDeviceMute(trtc_define_1.TRTCDeviceType.TRTCDeviceTypeMic);
2785
+ if (TRTCCloud.isIPCMode) {
2786
+ this.getDeviceManager().getCurrentDeviceMute(trtc_define_1.TRTCDeviceType.TRTCDeviceTypeMic);
2787
+ return this.stateStore.get('isCurrentMicMute');
2788
+ }
2789
+ else {
2790
+ return this.rtcCloud.getCurrentDeviceMute(trtc_define_1.TRTCDeviceType.TRTCDeviceTypeMic);
2791
+ }
2750
2792
  }
2751
2793
  /**
2752
2794
  * 获取扬声器设备列表
@@ -2757,10 +2799,10 @@ class TRTCCloud extends events_1.EventEmitter {
2757
2799
  * var speaker = speakerlist[i];
2758
2800
  * console.info("mic deviceName: " + speaker.deviceName + " deviceId:" + speaker.deviceId);
2759
2801
  * }
2760
- * @return {TRTCDeviceInfo[]} 扬声器管理器列表
2802
+ * @return {Array<TRTCDeviceInfo>} 扬声器管理器列表
2761
2803
  */
2762
2804
  getSpeakerDevicesList() {
2763
- return this.rtcCloud.getDevicesList(trtc_define_1.TRTCDeviceType.TRTCDeviceTypeSpeaker);
2805
+ return this.getDeviceManager().getDevicesList(trtc_define_1.TRTCDeviceType.TRTCDeviceTypeSpeaker);
2764
2806
  }
2765
2807
  /**
2766
2808
  * 获取当前的扬声器设备
@@ -2768,7 +2810,13 @@ class TRTCCloud extends events_1.EventEmitter {
2768
2810
  * @return {TRTCDeviceInfo} 设备信息,能获取设备 ID 和设备名称
2769
2811
  */
2770
2812
  getCurrentSpeakerDevice() {
2771
- return this.rtcCloud.getCurrentDevice(trtc_define_1.TRTCDeviceType.TRTCDeviceTypeSpeaker);
2813
+ if (TRTCCloud.isIPCMode) {
2814
+ this.getDeviceManager().getCurrentDevice(trtc_define_1.TRTCDeviceType.TRTCDeviceTypeSpeaker);
2815
+ return this.stateStore.get('currentSpeaker');
2816
+ }
2817
+ else {
2818
+ return this.rtcCloud.getCurrentDevice(trtc_define_1.TRTCDeviceType.TRTCDeviceTypeSpeaker);
2819
+ }
2772
2820
  }
2773
2821
  /**
2774
2822
  * 设置要使用的扬声器
@@ -2776,7 +2824,7 @@ class TRTCCloud extends events_1.EventEmitter {
2776
2824
  * @param {String} speakerId - 从 getSpeakerDevicesList 中得到的设备 ID
2777
2825
  */
2778
2826
  setCurrentSpeakerDevice(speakerId) {
2779
- this.rtcCloud.setCurrentDevice(trtc_define_1.TRTCDeviceType.TRTCDeviceTypeSpeaker, speakerId);
2827
+ this.getDeviceManager().setCurrentDevice(trtc_define_1.TRTCDeviceType.TRTCDeviceTypeSpeaker, speakerId);
2780
2828
  }
2781
2829
  /**
2782
2830
  * 获取系统当前扬声器设备音量
@@ -2784,7 +2832,13 @@ class TRTCCloud extends events_1.EventEmitter {
2784
2832
  * @return {Number} 扬声器音量,范围0 - 100
2785
2833
  */
2786
2834
  getCurrentSpeakerVolume() {
2787
- return this.rtcCloud.getCurrentDeviceVolume(trtc_define_1.TRTCDeviceType.TRTCDeviceTypeSpeaker);
2835
+ if (TRTCCloud.isIPCMode) {
2836
+ this.getDeviceManager().getCurrentDeviceVolume(trtc_define_1.TRTCDeviceType.TRTCDeviceTypeSpeaker);
2837
+ return this.stateStore.get('currentSpeakerVolume');
2838
+ }
2839
+ else {
2840
+ return this.getDeviceManager().getCurrentDeviceVolume(trtc_define_1.TRTCDeviceType.TRTCDeviceTypeSpeaker);
2841
+ }
2788
2842
  }
2789
2843
  /**
2790
2844
  * 设置系统当前扬声器设备音量
@@ -2794,7 +2848,7 @@ class TRTCCloud extends events_1.EventEmitter {
2794
2848
  * @param {Number} volume - 设置的扬声器音量,范围0 - 100
2795
2849
  */
2796
2850
  setCurrentSpeakerVolume(volume) {
2797
- this.rtcCloud.setCurrentDeviceVolume(trtc_define_1.TRTCDeviceType.TRTCDeviceTypeSpeaker, volume);
2851
+ this.getDeviceManager().setCurrentDeviceVolume(trtc_define_1.TRTCDeviceType.TRTCDeviceTypeSpeaker, volume);
2798
2852
  }
2799
2853
  /**
2800
2854
  * 设置系统当前扬声器设备的静音状态
@@ -2802,7 +2856,7 @@ class TRTCCloud extends events_1.EventEmitter {
2802
2856
  * @param {Boolean} mute 设置为 true 时,扬声器设备静音;设置为 false时,扬声器设备取消静音
2803
2857
  */
2804
2858
  setCurrentSpeakerDeviceMute(mute) {
2805
- this.rtcCloud.setCurrentDeviceMute(trtc_define_1.TRTCDeviceType.TRTCDeviceTypeSpeaker, mute);
2859
+ this.getDeviceManager().setCurrentDeviceMute(trtc_define_1.TRTCDeviceType.TRTCDeviceTypeSpeaker, mute);
2806
2860
  }
2807
2861
  /**
2808
2862
  * 获取系统当前扬声器设备是否静音
@@ -2810,7 +2864,13 @@ class TRTCCloud extends events_1.EventEmitter {
2810
2864
  * @return {Boolean} 静音状态
2811
2865
  */
2812
2866
  getCurrentSpeakerDeviceMute() {
2813
- return this.rtcCloud.getCurrentDeviceMute(trtc_define_1.TRTCDeviceType.TRTCDeviceTypeSpeaker);
2867
+ if (TRTCCloud.isIPCMode) {
2868
+ this.getDeviceManager().getCurrentDeviceMute(trtc_define_1.TRTCDeviceType.TRTCDeviceTypeSpeaker);
2869
+ return this.stateStore.get('isCurrentSpeakerMute');
2870
+ }
2871
+ else {
2872
+ return this.rtcCloud.getCurrentDeviceMute(trtc_define_1.TRTCDeviceType.TRTCDeviceTypeSpeaker);
2873
+ }
2814
2874
  }
2815
2875
  /**
2816
2876
  * 设置 SDK 使用的音频设备自动跟随系统默认设备
@@ -2823,7 +2883,7 @@ class TRTCCloud extends events_1.EventEmitter {
2823
2883
  * - false: 不跟随。只有当 SDK 使用的音频设备被移除后或插入新的音频设备为系统默认设备时,SDK 才切换至系统默认的音频设备。
2824
2884
  */
2825
2885
  enableFollowingDefaultAudioDevice(deviceType, enable) {
2826
- this.rtcCloud.enableFollowingDefaultAudioDevice(deviceType, enable);
2886
+ this.getDeviceManager().enableFollowingDefaultAudioDevice(deviceType, enable);
2827
2887
  }
2828
2888
  /////////////////////////////////////////////////////////////////////////////////
2829
2889
  //
@@ -3686,7 +3746,7 @@ class TRTCCloud extends events_1.EventEmitter {
3686
3746
  *
3687
3747
  */
3688
3748
  setMusicObserver(observer) {
3689
- this.rtcCloud.setMusicObserver(observer.onStart, observer.onPlayProgress, observer.onComplete);
3749
+ this.getAudioEffectManager().setMusicObserver(observer);
3690
3750
  }
3691
3751
  /**
3692
3752
  * 开始播放背景音乐
@@ -3720,17 +3780,17 @@ class TRTCCloud extends events_1.EventEmitter {
3720
3780
  */
3721
3781
  startPlayMusic(musicParam, callbackMap) {
3722
3782
  if ((callbackMap === null || callbackMap === void 0 ? void 0 : callbackMap.onStart) || (callbackMap === null || callbackMap === void 0 ? void 0 : callbackMap.onPlayProgress) || (callbackMap === null || callbackMap === void 0 ? void 0 : callbackMap.onComplete)) {
3723
- this.rtcCloud.setMusicObserver((callbackMap === null || callbackMap === void 0 ? void 0 : callbackMap.onStart) || null, (callbackMap === null || callbackMap === void 0 ? void 0 : callbackMap.onPlayProgress) || null, (callbackMap === null || callbackMap === void 0 ? void 0 : callbackMap.onComplete) || null);
3783
+ this.getAudioEffectManager().setMusicObserver(callbackMap);
3724
3784
  }
3725
- this.rtcCloud.startPlayMusic(musicParam);
3785
+ this.getAudioEffectManager().startPlayMusic(musicParam);
3726
3786
  }
3727
3787
  /**
3728
3788
  * 停止播放背景音乐
3729
3789
  *
3730
- * @param {Number} id 音乐 ID
3790
+ * @param {Number} id - 音乐 ID
3731
3791
  */
3732
3792
  stopPlayMusic(id) {
3733
- this.rtcCloud.stopPlayMusic(id);
3793
+ this.getAudioEffectManager().stopPlayMusic(id);
3734
3794
  }
3735
3795
  /**
3736
3796
  * 暂停播放背景音乐
@@ -3738,7 +3798,7 @@ class TRTCCloud extends events_1.EventEmitter {
3738
3798
  * @param {Number} id 音乐 ID
3739
3799
  */
3740
3800
  pausePlayMusic(id) {
3741
- this.rtcCloud.pausePlayMusic(id);
3801
+ this.getAudioEffectManager().pausePlayMusic(id);
3742
3802
  }
3743
3803
  /**
3744
3804
  * 恢复播放背景音乐
@@ -3746,7 +3806,16 @@ class TRTCCloud extends events_1.EventEmitter {
3746
3806
  * @param {Number} id 音乐 ID
3747
3807
  */
3748
3808
  resumePlayMusic(id) {
3749
- this.rtcCloud.resumePlayMusic(id);
3809
+ this.getAudioEffectManager().resumePlayMusic(id);
3810
+ }
3811
+ /**
3812
+ * 获取背景音乐的播放进度(单位:毫秒)
3813
+ *
3814
+ * @param {Number} id - 音乐 ID。
3815
+ * @return {Promise<number>|Number} 成功返回当前播放时间,单位:毫秒,失败返回 -1。
3816
+ */
3817
+ getMusicCurrentPosInMS(id) {
3818
+ return this.getAudioEffectManager().getMusicCurrentPosInMS(id);
3750
3819
  }
3751
3820
  /**
3752
3821
  * 获取背景音乐文件总时长,单位毫秒
@@ -3756,7 +3825,13 @@ class TRTCCloud extends events_1.EventEmitter {
3756
3825
  */
3757
3826
  getMusicDurationInMS(path) {
3758
3827
  path = path.replace('file:///', '');
3759
- return this.rtcCloud.getMusicDurationInMS(path);
3828
+ if (TRTCCloud.isIPCMode) {
3829
+ this.getAudioEffectManager().getMusicDurationInMS(path);
3830
+ return this.stateStore.get(`musicDuration-{path}`);
3831
+ }
3832
+ else {
3833
+ return this.getAudioEffectManager().getMusicDurationInMS(path);
3834
+ }
3760
3835
  }
3761
3836
  /**
3762
3837
  * 设置背景音乐播放进度
@@ -3765,7 +3840,7 @@ class TRTCCloud extends events_1.EventEmitter {
3765
3840
  * @param {Number} pts - 单位: 毫秒
3766
3841
  */
3767
3842
  seekMusicToPosInTime(id, pts) {
3768
- return this.rtcCloud.seekMusicToPosInTime(id, pts);
3843
+ this.getAudioEffectManager().seekMusicToPosInTime(id, pts);
3769
3844
  }
3770
3845
  /**
3771
3846
  * 设置所有背景音乐的本地音量和远端音量的大小
@@ -3779,7 +3854,7 @@ class TRTCCloud extends events_1.EventEmitter {
3779
3854
  * @param {Number} volume - 音量大小,100为正常音量,取值范围为0 - 200。
3780
3855
  */
3781
3856
  setAllMusicVolume(volume) {
3782
- return this.rtcCloud.setAllMusicVolume(volume);
3857
+ this.getAudioEffectManager().setAllMusicVolume(volume);
3783
3858
  }
3784
3859
  /**
3785
3860
  * 设置背景音乐本地播放音量的大小
@@ -3790,7 +3865,7 @@ class TRTCCloud extends events_1.EventEmitter {
3790
3865
  * @param {Number} volume - 音量大小,100为正常音量,取值范围为0 - 100;默认值:100
3791
3866
  */
3792
3867
  setMusicPlayoutVolume(id, volume) {
3793
- this.rtcCloud.setMusicPlayoutVolume(id, volume);
3868
+ this.getAudioEffectManager().setMusicPlayoutVolume(id, volume);
3794
3869
  }
3795
3870
  /**
3796
3871
  * 设置背景音乐远端播放音量的大小
@@ -3801,7 +3876,7 @@ class TRTCCloud extends events_1.EventEmitter {
3801
3876
  * @param {Number} volume - 音量大小,100为正常音量,取值范围为0 - 100;默认值:100
3802
3877
  */
3803
3878
  setMusicPublishVolume(id, volume) {
3804
- this.rtcCloud.setMusicPublishVolume(id, volume);
3879
+ this.getAudioEffectManager().setMusicPublishVolume(id, volume);
3805
3880
  }
3806
3881
  /**
3807
3882
  * 开启耳返
@@ -3812,7 +3887,7 @@ class TRTCCloud extends events_1.EventEmitter {
3812
3887
  * @param {Boolean} enable - 是否开启耳返。
3813
3888
  */
3814
3889
  enableVoiceEarMonitor(enable) {
3815
- this.rtcCloud.enableVoiceEarMonitor(enable);
3890
+ this.getAudioEffectManager().enableVoiceEarMonitor(enable);
3816
3891
  }
3817
3892
  /**
3818
3893
  * 设置耳返音量
@@ -3823,7 +3898,7 @@ class TRTCCloud extends events_1.EventEmitter {
3823
3898
  * @param {Number} volumn - 音量大小,取值范围为0 - 100,默认值:100。
3824
3899
  */
3825
3900
  setVoiceEarMonitorVolume(volumn) {
3826
- this.rtcCloud.setVoiceEarMonitorVolume(volumn);
3901
+ this.getAudioEffectManager().setVoiceEarMonitorVolume(volumn);
3827
3902
  }
3828
3903
  /**
3829
3904
  * 设置语音音量
@@ -3834,7 +3909,7 @@ class TRTCCloud extends events_1.EventEmitter {
3834
3909
  * @param {Number} volume - 音量大小,取值范围为0 - 100,默认值:100。
3835
3910
  */
3836
3911
  setVoiceCaptureVolume(volume) {
3837
- this.rtcCloud.setVoiceCaptureVolume(volume);
3912
+ this.getAudioEffectManager().setVoiceCaptureVolume(volume);
3838
3913
  }
3839
3914
  /**
3840
3915
  * 设置语音音调
@@ -3846,7 +3921,7 @@ class TRTCCloud extends events_1.EventEmitter {
3846
3921
  if (pitch < -1.0 || pitch > 1.0) {
3847
3922
  throw new Error('pitch is out of range [-1.0, 1.0]');
3848
3923
  }
3849
- this.rtcCloud.setVoicePitch(pitch);
3924
+ this.getAudioEffectManager().setVoicePitch(pitch);
3850
3925
  }
3851
3926
  /**
3852
3927
  * 设置人声的混响效果
@@ -3858,7 +3933,7 @@ class TRTCCloud extends events_1.EventEmitter {
3858
3933
  * @param {TRTCVoiceReverbType} type - 人声的混响效果类型。
3859
3934
  */
3860
3935
  setVoiceReverbType(type) {
3861
- this.rtcCloud.setVoiceReverbType(type);
3936
+ this.getAudioEffectManager().setVoiceReverbType(type);
3862
3937
  }
3863
3938
  /**
3864
3939
  * 设置人声的变声效果
@@ -3869,7 +3944,7 @@ class TRTCCloud extends events_1.EventEmitter {
3869
3944
  * @param {TRTCVoiceChangerType} type - 人声的变声效果类型 。
3870
3945
  */
3871
3946
  setVoiceChangerType(type) {
3872
- this.rtcCloud.setVoiceChangerType(type);
3947
+ this.getAudioEffectManager().setVoiceChangerType(type);
3873
3948
  }
3874
3949
  /////////////////////////////////////////////////////////////////////////////////
3875
3950
  //
@@ -4091,13 +4166,13 @@ class TRTCCloud extends events_1.EventEmitter {
4091
4166
  if (playback === undefined || playback === null) {
4092
4167
  playback = false;
4093
4168
  }
4094
- this.rtcCloud.startMicDeviceTest(interval, playback);
4169
+ this.getDeviceManager().startMicDeviceTest(interval, playback);
4095
4170
  }
4096
4171
  /**
4097
4172
  * 停止麦克风测试
4098
4173
  */
4099
4174
  stopMicDeviceTest() {
4100
- this.rtcCloud.stopMicDeviceTest();
4175
+ this.getDeviceManager().stopMicDeviceTest();
4101
4176
  }
4102
4177
  /**
4103
4178
  * 开始进行扬声器测试
@@ -4110,13 +4185,13 @@ class TRTCCloud extends events_1.EventEmitter {
4110
4185
  */
4111
4186
  startSpeakerDeviceTest(testAudioFilePath) {
4112
4187
  testAudioFilePath = testAudioFilePath.replace('file:///', '');
4113
- this.rtcCloud.startSpeakerDeviceTest(testAudioFilePath);
4188
+ this.getDeviceManager().startSpeakerDeviceTest(testAudioFilePath);
4114
4189
  }
4115
4190
  /**
4116
4191
  * 停止扬声器测试
4117
4192
  */
4118
4193
  stopSpeakerDeviceTest() {
4119
- this.rtcCloud.stopSpeakerDeviceTest();
4194
+ this.getDeviceManager().stopSpeakerDeviceTest();
4120
4195
  }
4121
4196
  /////////////////////////////////////////////////////////////////////////////////
4122
4197
  //
@@ -4298,51 +4373,7 @@ class TRTCCloud extends events_1.EventEmitter {
4298
4373
  */
4299
4374
  setPluginParams(type, options) {
4300
4375
  this.logger.log(`setPluginParams params:`, type, options);
4301
- switch (type) {
4302
- case trtc_define_1.TRTCPluginType.TRTCPluginTypeVideoProcess:
4303
- this._setVideoProcessPluginParams(options);
4304
- break;
4305
- case trtc_define_1.TRTCPluginType.TRTCPluginTypeMediaEncryptDecrypt:
4306
- this._setMediaEncryptDecryptPluginParams(options);
4307
- break;
4308
- case trtc_define_1.TRTCPluginType.TRTCPluginTypeAudioProcess:
4309
- this._setAudioProcessPluginParams(options);
4310
- break;
4311
- default:
4312
- this.logger.log(`setPluginConfigParams invalid type:${type}`);
4313
- break;
4314
- }
4315
- }
4316
- _setVideoProcessPluginParams(options) {
4317
- if (options.pixelFormat !== undefined) {
4318
- switch (options.pixelFormat) {
4319
- case trtc_define_1.TRTCVideoPixelFormat.TRTCVideoPixelFormat_I420:
4320
- case trtc_define_1.TRTCVideoPixelFormat.TRTCVideoPixelFormat_RGBA32:
4321
- case trtc_define_1.TRTCVideoPixelFormat.TRTCVideoPixelFormat_BGRA32:
4322
- this.videoProcessBufferType = trtc_define_1.TRTCVideoBufferType.TRTCVideoBufferType_Buffer;
4323
- break;
4324
- case trtc_define_1.TRTCVideoPixelFormat.TRTCVideoPixelFormat_Texture_2D:
4325
- this.videoProcessBufferType = trtc_define_1.TRTCVideoBufferType.TRTCVideoBufferType_Texture;
4326
- break;
4327
- default:
4328
- console.error(`setPluginParams() unspported pixelFormat: ${options.pixelFormat}`);
4329
- return;
4330
- }
4331
- this.videoProcessPixelFormat = options.pixelFormat;
4332
- }
4333
- if (options.enable !== undefined) {
4334
- this.rtcCloud.enableLocalVideoCustomProcess(!!options.enable, this.videoProcessPixelFormat, this.videoProcessBufferType);
4335
- }
4336
- }
4337
- _setMediaEncryptDecryptPluginParams(options) {
4338
- if (options.enable !== undefined) {
4339
- this.rtcCloud.enableEncodedDataCustomProcess(!!options.enable);
4340
- }
4341
- }
4342
- _setAudioProcessPluginParams(options) {
4343
- if (options.enable !== undefined) {
4344
- this.rtcCloud.enableAudioFrameCustomProcess(!!options.enable);
4345
- }
4376
+ this.getPluginManager().setPluginParams(type, options);
4346
4377
  }
4347
4378
  /**
4348
4379
  * 添加插件
@@ -4357,10 +4388,7 @@ class TRTCCloud extends events_1.EventEmitter {
4357
4388
  *
4358
4389
  */
4359
4390
  addPlugin(options) {
4360
- const pluginType = options.type || trtc_define_1.TRTCPluginType.TRTCPluginTypeVideoProcess;
4361
- const realDeviceId = options.deviceId || "";
4362
- this.rtcCloud.registerPlugin(options.id, options.path, pluginType, realDeviceId);
4363
- return this._createPlugin(options.id, realDeviceId);
4391
+ return this.getPluginManager().addPlugin(options);
4364
4392
  }
4365
4393
  /**
4366
4394
  * 删除插件
@@ -4370,26 +4398,11 @@ class TRTCCloud extends events_1.EventEmitter {
4370
4398
  * @param [deviceId] {String} - 摄像头设备 ID,开启多个摄像头美颜时必填。
4371
4399
  */
4372
4400
  removePlugin(id, deviceId) {
4373
- this.rtcCloud.unregisterPlugin(id, deviceId || "");
4374
- }
4375
- _createPlugin(pluginId, deviceId) {
4376
- return {
4377
- id: pluginId,
4378
- deviceId: deviceId || "",
4379
- enable: () => {
4380
- return this.rtcCloud.enablePlugin(pluginId, true, deviceId || "");
4381
- },
4382
- disable: () => {
4383
- return this.rtcCloud.enablePlugin(pluginId, false, deviceId || "");
4384
- },
4385
- setParameter: (param) => {
4386
- return this.rtcCloud.setPluginParameter(pluginId, param, deviceId || "");
4387
- }
4388
- };
4401
+ this.getPluginManager().removePlugin(id, deviceId || "");
4389
4402
  }
4390
4403
  /**
4391
4404
  * 注册插件事件监听,全局只需要调用一次
4392
- * @param {Function} pluginCb - 插件事件回调函数
4405
+ * @param {Function} pluginCallback - 插件事件回调函数
4393
4406
  * - pluginId - 插件ID
4394
4407
  * - errorCode - 错误码。0、-1、-2、-3、-4、-5 是 SDK 内部定义错误码,其它错误码是插件自定义错误码。
4395
4408
  * - 0 表示 addPlugin 成功
@@ -4402,8 +4415,8 @@ class TRTCCloud extends events_1.EventEmitter {
4402
4415
  *
4403
4416
  * 注意:错误码:-1000 到 1000 是 SDK 预留错误码,用户自定义插件中,请使用这个范围以外的错误码。
4404
4417
  */
4405
- setPluginCallback(pluginCb) {
4406
- this.rtcCloud.setPluginCallback(pluginCb);
4418
+ setPluginCallback(pluginCallback) {
4419
+ this.getPluginManager().setCallback(pluginCallback);
4407
4420
  }
4408
4421
  /**
4409
4422
  * 初始化插件管理器
@@ -4419,10 +4432,12 @@ class TRTCCloud extends events_1.EventEmitter {
4419
4432
  *
4420
4433
  */
4421
4434
  initPluginManager(options) {
4422
- this.setPluginParams(trtc_define_1.TRTCPluginType.TRTCPluginTypeVideoProcess, {
4423
- enable: true,
4424
- pixelFormat: (options === null || options === void 0 ? void 0 : options.pixelFormat) || trtc_define_1.TRTCVideoPixelFormat.TRTCVideoPixelFormat_I420
4425
- });
4435
+ if (!TRTCCloud.isIPCMode) {
4436
+ this.setPluginParams(trtc_define_1.TRTCPluginType.TRTCPluginTypeVideoProcess, {
4437
+ enable: true,
4438
+ pixelFormat: (options === null || options === void 0 ? void 0 : options.pixelFormat) || trtc_define_1.TRTCVideoPixelFormat.TRTCVideoPixelFormat_I420
4439
+ });
4440
+ }
4426
4441
  }
4427
4442
  /**
4428
4443
  * 销毁插件管理
@@ -4431,22 +4446,21 @@ class TRTCCloud extends events_1.EventEmitter {
4431
4446
  *
4432
4447
  */
4433
4448
  destroyPluginManager() {
4434
- this.setPluginParams(trtc_define_1.TRTCPluginType.TRTCPluginTypeVideoProcess, {
4435
- enable: false,
4436
- });
4449
+ if (!TRTCCloud.isIPCMode) {
4450
+ this.setPluginParams(trtc_define_1.TRTCPluginType.TRTCPluginTypeVideoProcess, {
4451
+ enable: false,
4452
+ });
4453
+ }
4437
4454
  }
4438
4455
  /**
4439
4456
  * 获取插件列表
4440
- * @returns TRTCPluginInfo[]
4457
+ * @returns TRTCPluginInfo[]|null
4441
4458
  *
4442
4459
  * @ignore
4443
4460
  * @deprecated
4444
4461
  */
4445
4462
  getPluginList() {
4446
- return this.rtcCloud.getPluginIds().map((item) => {
4447
- const ids = item.split('__');
4448
- return this._createPlugin(ids[0], ids[1]);
4449
- });
4463
+ return this.getPluginManager().getPluginList();
4450
4464
  }
4451
4465
  //----------------------------------//
4452
4466
  // plugin API -- end
@@ -4454,6 +4468,22 @@ class TRTCCloud extends events_1.EventEmitter {
4454
4468
  //----------------------------------//
4455
4469
  // Vod API -- start
4456
4470
  //----------------------------------//
4471
+ // createVodPlayer(mediaFilePath: string, repeat: boolean) {
4472
+ // const nativeVodPlayer = this.rtcCloud.createVodPlayer(mediaFilePath, repeat);
4473
+ // if (nativeVodPlayer) {
4474
+ // const vodPlayer = new VodPlayer(nativeVodPlayer, mediaFilePath, repeat);
4475
+ // vodPlayer.setVodPlayerRenderCallback();
4476
+ // vodPlayer.setVodEventCallback();
4477
+ // this.vodPlayers[vodPlayer.key] = vodPlayer;
4478
+ // return vodPlayer;
4479
+ // }
4480
+ // return null;
4481
+ // }
4482
+ // destroyVodPlayer(vodPlayer: VodPlayer) {
4483
+ // vodPlayer.destroyRender();
4484
+ // this.rtcCloud.destroyVodPlayer(vodPlayer.key);
4485
+ // delete this.vodPlayers[vodPlayer.key];
4486
+ // }
4457
4487
  //----------------------------------//
4458
4488
  // Vod API -- end
4459
4489
  //----------------------------------//
@@ -4464,6 +4494,9 @@ class TRTCCloud extends events_1.EventEmitter {
4464
4494
  this.logger.debug('setEnableRenderFrame:' + enable);
4465
4495
  this.enableRenderFrame = enable;
4466
4496
  }
4497
+ log(info) {
4498
+ this.rtcCloud.log(info);
4499
+ }
4467
4500
  _getRendererMap(uid, streamType) {
4468
4501
  const key = this._getKey(uid, streamType);
4469
4502
  return this.videoRendererMap.get(key);
@@ -4859,6 +4892,101 @@ class TRTCCloud extends events_1.EventEmitter {
4859
4892
  }
4860
4893
  videoBufferInfo.buffer && this.rtcCloud.setRemoteVideoBuffer(userId, videoBufferInfo.buffer, videoBufferInfo.streamType, videoBufferInfo.width, videoBufferInfo.height, videoBufferInfo.pixelFormat, videoBufferInfo.id);
4861
4894
  }
4895
+ // //-------------------------------------------------//
4896
+ // // Local media transcoding API begin
4897
+ // //-------------------------------------------------//
4898
+ // /**
4899
+ // * 创建本地多媒体合图实例
4900
+ // *
4901
+ // * 注意:单例模式,多次调用返回的是同一个对象
4902
+ // *
4903
+ // * @param {Object} config - 配置参数
4904
+ // * @param {TRTCVideoPixelFormat} config.pixelFormat - 视频数据的像素格式
4905
+ // * @returns {TRTCLocalMediaTranscoder}
4906
+ // */
4907
+ // createLocalMediaTranscoder(config?: {
4908
+ // pixelFormat: TRTCVideoPixelFormat
4909
+ // }): TRTCLocalMediaTranscoder | null {
4910
+ // if (this.localMediaTranscoder === null) {
4911
+ // let pixelFormat = TRTCVideoPixelFormat.TRTCVideoPixelFormat_I420;
4912
+ // if (config && config.pixelFormat) {
4913
+ // pixelFormat = config.pixelFormat;
4914
+ // }
4915
+ // const nativeLocalMediaTranscoding = this.rtcCloud.createLocalMediaTranscoding();
4916
+ // if (nativeLocalMediaTranscoding) {
4917
+ // this.localMediaTranscoder = new TRTCLocalMediaTranscoder(nativeLocalMediaTranscoding, pixelFormat);
4918
+ // } else {
4919
+ // console.warn('TRTCLocalMediaTranscoder create error. Currently only support "Windows" operation system.')
4920
+ // }
4921
+ // }
4922
+ // return this.localMediaTranscoder;
4923
+ // }
4924
+ // /**
4925
+ // * 销毁本地多媒体合图实例
4926
+ // */
4927
+ // destroyLocalMediaTranscoder(): void {
4928
+ // if (this.localMediaTranscoder) {
4929
+ // try {
4930
+ // this.localMediaTranscoder.destroy();
4931
+ // this.localMediaTranscoder = null;
4932
+ // this.rtcCloud.destroyLocalMediaTranscoding();
4933
+ // } catch (e: any) {
4934
+ // // 重复销毁会有报错提示
4935
+ // console.warn(`trtc:destroyLocalMediaTranscoder warning:`, e.message);
4936
+ // }
4937
+ // }
4938
+ // }
4939
+ // //-------------------------------------------------//
4940
+ // // Local media transocoding API end
4941
+ // //-------------------------------------------------//
4942
+ /**
4943
+ * 获取设备管理器
4944
+ *
4945
+ * @returns {TRTCDeviceManager}
4946
+ */
4947
+ getDeviceManager() {
4948
+ return DeviceManager_1.default.getInstance({
4949
+ isIPCMode: TRTCCloud.isIPCMode,
4950
+ nodeTRTCCloud: this.rtcCloud,
4951
+ });
4952
+ }
4953
+ /**
4954
+ * 获取音效管理器
4955
+ *
4956
+ * @returns {TRTCAudioEffectManager}
4957
+ */
4958
+ getAudioEffectManager() {
4959
+ return AudioEffectManager_1.default.getInstance({
4960
+ isIPCMode: TRTCCloud.isIPCMode,
4961
+ nodeTRTCCloud: this.rtcCloud,
4962
+ });
4963
+ }
4964
+ /**
4965
+ * 获取本地混流管理器
4966
+ *
4967
+ * @returns {TRTCMediaMixingManager | null}
4968
+ */
4969
+ getMediaMixingManager() {
4970
+ if (TRTCCloud.isIPCMode) {
4971
+ return MediaMixingManager_1.default.getInstance({
4972
+ deviceManager: this.getDeviceManager()
4973
+ });
4974
+ }
4975
+ else {
4976
+ return null;
4977
+ }
4978
+ }
4979
+ /**
4980
+ * 获取插件管理器
4981
+ *
4982
+ * @returns {TRTCPluginManager}
4983
+ */
4984
+ getPluginManager() {
4985
+ return PluginManager_1.default.getInstance({
4986
+ isIPCMode: TRTCCloud.isIPCMode,
4987
+ nodeTRTCCloud: this.rtcCloud,
4988
+ });
4989
+ }
4862
4990
  }
4863
4991
  class VideoRenderCallback {
4864
4992
  constructor() {