trtc-electron-sdk 12.1.607 → 12.1.701-alpha.0
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/extensions/AudioEffectManager/index.d.ts +44 -0
- package/liteav/extensions/AudioEffectManager/index.js +161 -0
- package/liteav/extensions/DeviceManager/index.d.ts +99 -0
- package/liteav/extensions/DeviceManager/index.js +515 -0
- package/liteav/extensions/MediaMixingManager/index.d.ts +58 -0
- package/liteav/extensions/MediaMixingManager/index.js +124 -0
- package/liteav/extensions/PluginManager/index.d.ts +33 -0
- package/liteav/extensions/PluginManager/index.js +76 -0
- package/liteav/trtc.d.ts +23 -1
- package/liteav/trtc.js +126 -2
- package/liteav/trtc_define.d.ts +50 -6
- package/liteav/trtc_define.js +31 -46
- package/package.json +1 -1
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { TRTCVoiceReverbType, TRTCVoiceChangerType, TRTCAudioMusicParam } from '../../trtc_define';
|
|
2
|
+
export declare class TRTCAudioEffectManager {
|
|
3
|
+
private logPrefix;
|
|
4
|
+
private static audioEffectManager;
|
|
5
|
+
private nativeAudioEffectManager;
|
|
6
|
+
private promiseStore;
|
|
7
|
+
constructor();
|
|
8
|
+
static getInstance(): TRTCAudioEffectManager;
|
|
9
|
+
enableVoiceEarMonitor(enable: boolean): void;
|
|
10
|
+
setVoiceEarMonitorVolume(volume: number): void;
|
|
11
|
+
setVoiceReverbType(type: TRTCVoiceReverbType): void;
|
|
12
|
+
setVoiceChangerType(type: TRTCVoiceChangerType): void;
|
|
13
|
+
setVoiceCaptureVolume(volume: number): void;
|
|
14
|
+
setVoicePitch(pitch: number): void;
|
|
15
|
+
setMusicObserver(observer: {
|
|
16
|
+
onStart: (id: number, errCode: number) => void;
|
|
17
|
+
onPlayProgress: (id: number, curPtsMS: number, durationMS: number) => void;
|
|
18
|
+
onComplete: (id: number, errCode: number) => void;
|
|
19
|
+
}): void;
|
|
20
|
+
startPlayMusic(param: TRTCAudioMusicParam): void;
|
|
21
|
+
stopPlayMusic(id: number): void;
|
|
22
|
+
pausePlayMusic(id: number): void;
|
|
23
|
+
resumePlayMusic(id: number): void;
|
|
24
|
+
setAllMusicVolume(volume: number): void;
|
|
25
|
+
setMusicPublishVolume(id: number, volume: number): void;
|
|
26
|
+
setMusicPlayoutVolume(id: number, volume: number): void;
|
|
27
|
+
setMusicPitch(id: number, pitch: number): void;
|
|
28
|
+
setMusicSpeedRate(id: number, speedRate: number): void;
|
|
29
|
+
getMusicCurrentPosInMS(id: number): Promise<number>;
|
|
30
|
+
getMusicDurationInMS(path: string): Promise<number>;
|
|
31
|
+
seekMusicToPosInTime(id: number, pts: number): void;
|
|
32
|
+
setMusicScratchSpeedRate(id: number, speedRate: number): void;
|
|
33
|
+
setPreloadObserver(observer: {
|
|
34
|
+
onLoadProgress: (id: number, progress: number) => void;
|
|
35
|
+
onLoadError: (id: number, errCode: number) => void;
|
|
36
|
+
}): void;
|
|
37
|
+
preloadMusic(param: TRTCAudioMusicParam): void;
|
|
38
|
+
getMusicTrackCount(id: number): Promise<number>;
|
|
39
|
+
setMusicTrack(id: number, trackIndex: number): void;
|
|
40
|
+
private eventHandler;
|
|
41
|
+
private addPromise;
|
|
42
|
+
private removePromise;
|
|
43
|
+
}
|
|
44
|
+
export default TRTCAudioEffectManager;
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TRTCAudioEffectManager = void 0;
|
|
4
|
+
const NodeTRTCEngine = require('../../../build/Release/trtc_electron_sdk.node');
|
|
5
|
+
// To do: 待替换为 SDK JS 层 Logger
|
|
6
|
+
const logger = console;
|
|
7
|
+
class TRTCAudioEffectManager {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.logPrefix = "[TRTCAudioEffectManager]";
|
|
10
|
+
if (!TRTCAudioEffectManager.audioEffectManager) {
|
|
11
|
+
this.promiseStore = new Map();
|
|
12
|
+
this.nativeAudioEffectManager = new NodeTRTCEngine.NodeRemoteAudioEffectManager();
|
|
13
|
+
this.eventHandler = this.eventHandler.bind(this);
|
|
14
|
+
this.nativeAudioEffectManager.setRemoteAudioEffectManagerCallback(this.eventHandler);
|
|
15
|
+
TRTCAudioEffectManager.audioEffectManager = this;
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
return TRTCAudioEffectManager.audioEffectManager;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
static getInstance() {
|
|
22
|
+
if (!TRTCAudioEffectManager.audioEffectManager) {
|
|
23
|
+
TRTCAudioEffectManager.audioEffectManager = new TRTCAudioEffectManager();
|
|
24
|
+
}
|
|
25
|
+
return TRTCAudioEffectManager.audioEffectManager;
|
|
26
|
+
}
|
|
27
|
+
enableVoiceEarMonitor(enable) {
|
|
28
|
+
this.nativeAudioEffectManager.enableVoiceEarMonitor(enable);
|
|
29
|
+
}
|
|
30
|
+
setVoiceEarMonitorVolume(volume) {
|
|
31
|
+
this.nativeAudioEffectManager.setVoiceEarMonitorVolume(volume);
|
|
32
|
+
}
|
|
33
|
+
setVoiceReverbType(type) {
|
|
34
|
+
logger.debug(`${this.logPrefix}setVoiceReverbType: ${type}`);
|
|
35
|
+
this.nativeAudioEffectManager.setVoiceReverbType(type);
|
|
36
|
+
}
|
|
37
|
+
setVoiceChangerType(type) {
|
|
38
|
+
logger.debug(`${this.logPrefix}setVoiceChangerType: ${type}`);
|
|
39
|
+
this.nativeAudioEffectManager.setVoiceChangerType(type);
|
|
40
|
+
}
|
|
41
|
+
setVoiceCaptureVolume(volume) {
|
|
42
|
+
this.nativeAudioEffectManager.setVoiceCaptureVolume(volume);
|
|
43
|
+
}
|
|
44
|
+
setVoicePitch(pitch) {
|
|
45
|
+
this.nativeAudioEffectManager.setVoicePitch(pitch);
|
|
46
|
+
}
|
|
47
|
+
setMusicObserver(observer) {
|
|
48
|
+
this.nativeAudioEffectManager.setMusicObserver(observer.onStart, observer.onPlayProgress, observer.onComplete);
|
|
49
|
+
}
|
|
50
|
+
startPlayMusic(param) {
|
|
51
|
+
this.nativeAudioEffectManager.startPlayMusic(param);
|
|
52
|
+
}
|
|
53
|
+
stopPlayMusic(id) {
|
|
54
|
+
this.nativeAudioEffectManager.stopPlayMusic(id);
|
|
55
|
+
}
|
|
56
|
+
pausePlayMusic(id) {
|
|
57
|
+
this.nativeAudioEffectManager.pausePlayMusic(id);
|
|
58
|
+
}
|
|
59
|
+
resumePlayMusic(id) {
|
|
60
|
+
this.nativeAudioEffectManager.resumePlayMusic(id);
|
|
61
|
+
}
|
|
62
|
+
setAllMusicVolume(volume) {
|
|
63
|
+
this.nativeAudioEffectManager.setAllMusicVolume(volume);
|
|
64
|
+
}
|
|
65
|
+
setMusicPublishVolume(id, volume) {
|
|
66
|
+
this.nativeAudioEffectManager.setMusicPublishVolume(id, volume);
|
|
67
|
+
}
|
|
68
|
+
setMusicPlayoutVolume(id, volume) {
|
|
69
|
+
this.nativeAudioEffectManager.setMusicPlayoutVolume(id, volume);
|
|
70
|
+
}
|
|
71
|
+
setMusicPitch(id, pitch) {
|
|
72
|
+
this.nativeAudioEffectManager.setMusicPitch(id, pitch);
|
|
73
|
+
}
|
|
74
|
+
setMusicSpeedRate(id, speedRate) {
|
|
75
|
+
this.nativeAudioEffectManager.setMusicSpeedRate(id, speedRate);
|
|
76
|
+
}
|
|
77
|
+
getMusicCurrentPosInMS(id) {
|
|
78
|
+
logger.debug(`${this.logPrefix}getMusicCurrentPosInMS: ${id}`);
|
|
79
|
+
const promise = new Promise((resolve, reject) => {
|
|
80
|
+
const key = `onGetMusicCurrentPosInMS-${id}`;
|
|
81
|
+
this.addPromise(key, resolve, reject);
|
|
82
|
+
this.nativeAudioEffectManager.getMusicCurrentPosInMS(id);
|
|
83
|
+
});
|
|
84
|
+
return promise;
|
|
85
|
+
}
|
|
86
|
+
getMusicDurationInMS(path) {
|
|
87
|
+
logger.debug(`${this.logPrefix}getMusicDurationInMS: ${path}`);
|
|
88
|
+
const promise = new Promise((resolve, reject) => {
|
|
89
|
+
const key = `onGetMusicDurationInMS-${path}`;
|
|
90
|
+
this.addPromise(key, resolve, reject);
|
|
91
|
+
this.nativeAudioEffectManager.getMusicDurationInMS(path);
|
|
92
|
+
});
|
|
93
|
+
return promise;
|
|
94
|
+
}
|
|
95
|
+
seekMusicToPosInTime(id, pts) {
|
|
96
|
+
this.nativeAudioEffectManager.seekMusicToPosInTime(id, pts);
|
|
97
|
+
}
|
|
98
|
+
setMusicScratchSpeedRate(id, speedRate) {
|
|
99
|
+
this.nativeAudioEffectManager.setMusicScratchSpeedRate(id, speedRate);
|
|
100
|
+
}
|
|
101
|
+
setPreloadObserver(observer) {
|
|
102
|
+
this.nativeAudioEffectManager.setPreloadObserver(observer.onLoadProgress, observer.onLoadError);
|
|
103
|
+
}
|
|
104
|
+
preloadMusic(param) {
|
|
105
|
+
this.nativeAudioEffectManager.preloadMusic(param);
|
|
106
|
+
}
|
|
107
|
+
getMusicTrackCount(id) {
|
|
108
|
+
logger.debug(`${this.logPrefix}getMusicTrackCount: ${id}`);
|
|
109
|
+
const promise = new Promise((resolve, reject) => {
|
|
110
|
+
const key = `onGetMusicTrackCount-${id}`;
|
|
111
|
+
this.addPromise(key, resolve, reject);
|
|
112
|
+
this.nativeAudioEffectManager.getMusicTrackCount(id);
|
|
113
|
+
});
|
|
114
|
+
return promise;
|
|
115
|
+
}
|
|
116
|
+
setMusicTrack(id, trackIndex) {
|
|
117
|
+
this.nativeAudioEffectManager.setMusicTrack(id, trackIndex);
|
|
118
|
+
}
|
|
119
|
+
eventHandler(args) {
|
|
120
|
+
logger.debug(`${this.logPrefix} event:`, args);
|
|
121
|
+
const key = args[0];
|
|
122
|
+
const data = args[1];
|
|
123
|
+
logger.debug(`${this.logPrefix} event key: ${key} data:`, data);
|
|
124
|
+
switch (key) {
|
|
125
|
+
case "onGetMusicCurrentPosInMS":
|
|
126
|
+
this.removePromise(`${key}-${data.id}`, data.currentPos);
|
|
127
|
+
break;
|
|
128
|
+
case 'onGetMusicDurationInMS':
|
|
129
|
+
this.removePromise(`${key}-${data.path}`, data.durationInMS);
|
|
130
|
+
break;
|
|
131
|
+
case 'onGetMusicTrackCount':
|
|
132
|
+
this.removePromise(`${key}-${data.id}`, data.trackCount);
|
|
133
|
+
break;
|
|
134
|
+
default:
|
|
135
|
+
logger.warn(`${this.logPrefix}eventHandler un-supported event:`, key);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
addPromise(key, resolve, reject) {
|
|
139
|
+
var _a, _b, _c;
|
|
140
|
+
if (!((_a = this.promiseStore) === null || _a === void 0 ? void 0 : _a.has(key))) {
|
|
141
|
+
(_b = this.promiseStore) === null || _b === void 0 ? void 0 : _b.set(key, []);
|
|
142
|
+
}
|
|
143
|
+
const storedPromises = (_c = this.promiseStore) === null || _c === void 0 ? void 0 : _c.get(key);
|
|
144
|
+
storedPromises === null || storedPromises === void 0 ? void 0 : storedPromises.push({
|
|
145
|
+
resolve,
|
|
146
|
+
reject
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
removePromise(key, value) {
|
|
150
|
+
var _a, _b;
|
|
151
|
+
const storedPromises = (_a = this.promiseStore) === null || _a === void 0 ? void 0 : _a.get(key);
|
|
152
|
+
if (storedPromises) {
|
|
153
|
+
storedPromises.forEach(({ resolve, reject }) => {
|
|
154
|
+
resolve(value);
|
|
155
|
+
});
|
|
156
|
+
(_b = this.promiseStore) === null || _b === void 0 ? void 0 : _b.delete(key);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
exports.TRTCAudioEffectManager = TRTCAudioEffectManager;
|
|
161
|
+
exports.default = TRTCAudioEffectManager;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { TRTCCameraCaptureParams, TRTCDeviceInfo, TRTCDeviceType, TRTCRect } from '../../trtc_define';
|
|
2
|
+
/**
|
|
3
|
+
* 音视频设备事件类型
|
|
4
|
+
*/
|
|
5
|
+
export declare enum TRTCDeviceEventType {
|
|
6
|
+
/** 设备状态变更 */
|
|
7
|
+
onDeviceChanged = "onDeviceChanged"
|
|
8
|
+
}
|
|
9
|
+
export declare class TRTCDeviceManager {
|
|
10
|
+
private logPrefix;
|
|
11
|
+
private static deviceNanager;
|
|
12
|
+
private nodeDeviceManagerPlugin;
|
|
13
|
+
private promiseStore;
|
|
14
|
+
private eventEmitter;
|
|
15
|
+
constructor();
|
|
16
|
+
static getInstance(): TRTCDeviceManager;
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
* @returns
|
|
20
|
+
*
|
|
21
|
+
* @deprecated
|
|
22
|
+
*/
|
|
23
|
+
getCameraDevicesList(): Array<TRTCDeviceInfo>;
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* @returns
|
|
27
|
+
*
|
|
28
|
+
* @deprecated
|
|
29
|
+
*/
|
|
30
|
+
getMicDevicesList(): Array<TRTCDeviceInfo>;
|
|
31
|
+
/**
|
|
32
|
+
*
|
|
33
|
+
* @returns
|
|
34
|
+
*
|
|
35
|
+
* @deprecated
|
|
36
|
+
*/
|
|
37
|
+
getSpeakerDevicesList(): Array<TRTCDeviceInfo>;
|
|
38
|
+
getDevicesList(type: TRTCDeviceType): Array<TRTCDeviceInfo>;
|
|
39
|
+
setCurrentDevice(type: TRTCDeviceType, deviceId: string): Promise<number>;
|
|
40
|
+
getCurrentDevice(type: TRTCDeviceType): Promise<TRTCDeviceInfo>;
|
|
41
|
+
setCurrentDeviceVolume(type: TRTCDeviceType, volume: number): Promise<number>;
|
|
42
|
+
getCurrentDeviceVolume(type: TRTCDeviceType): Promise<number>;
|
|
43
|
+
setCurrentDeviceMute(type: TRTCDeviceType, mute: boolean): Promise<number>;
|
|
44
|
+
getCurrentDeviceMute(type: TRTCDeviceType): Promise<boolean>;
|
|
45
|
+
enableFollowingDefaultAudioDevice(type: TRTCDeviceType, enable: boolean): Promise<number>;
|
|
46
|
+
startCameraDeviceTest(windowID: number, rect: TRTCRect): Promise<number>;
|
|
47
|
+
stopCameraDeviceTest(): Promise<number>;
|
|
48
|
+
setCameraTestRenderMirror(mirror: boolean): void;
|
|
49
|
+
setCameraTestDeviceId(cameraId: string): void;
|
|
50
|
+
setCameraTestResolution(width: number, height: number): void;
|
|
51
|
+
setCameraTestVideoPluginPath(path: string): void;
|
|
52
|
+
setCameraTestVideoPluginParameter(params: string): void;
|
|
53
|
+
startMicDeviceTest(interval: number, playback?: boolean): Promise<number>;
|
|
54
|
+
stopMicDeviceTest(): Promise<number>;
|
|
55
|
+
startSpeakerDeviceTest(filePath: string): Promise<number>;
|
|
56
|
+
stopSpeakerDeviceTest(): Promise<number>;
|
|
57
|
+
setApplicationPlayVolume(volume: number): Promise<number>;
|
|
58
|
+
getApplicationPlayVolume(): Promise<number>;
|
|
59
|
+
setApplicationMuteState(mute: boolean): Promise<number>;
|
|
60
|
+
getApplicationMuteState(): Promise<boolean>;
|
|
61
|
+
setCameraCaptureParam(params: TRTCCameraCaptureParams): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* 监听事件
|
|
64
|
+
*
|
|
65
|
+
* @param event {TRTCDeviceEventType} - 事件名称
|
|
66
|
+
* @param func {(...args: any[]) => void} - 事件回调函数
|
|
67
|
+
* @param context {object} - 回调函数执行的上下文
|
|
68
|
+
*/
|
|
69
|
+
on(event: TRTCDeviceEventType, func: (...args: any[]) => void): void;
|
|
70
|
+
/**
|
|
71
|
+
* 取消事件监听
|
|
72
|
+
*
|
|
73
|
+
* @param event {TRTCDeviceEventType} - 事件名
|
|
74
|
+
* @param func {(...args: any[]) => void} - 事件回调函数
|
|
75
|
+
*/
|
|
76
|
+
off(event: TRTCDeviceEventType, func: (...args: any[]) => void): void;
|
|
77
|
+
private addPromise;
|
|
78
|
+
private removePromise;
|
|
79
|
+
private eventHandler;
|
|
80
|
+
private onDeviceChanged;
|
|
81
|
+
private onSetCurrentDeviceFinished;
|
|
82
|
+
private onGetCurrentDeviceFinished;
|
|
83
|
+
private onSetCurrentDeviceVolumeFinished;
|
|
84
|
+
private onGetCurrentDeviceVolumeFinished;
|
|
85
|
+
private onSetCurrentDeviceMuteFinished;
|
|
86
|
+
private onGetCurrentDeviceMuteFinished;
|
|
87
|
+
private onEnableFollowingDefaultAudioDeviceFinished;
|
|
88
|
+
private onStartCameraDeviceTestFinished;
|
|
89
|
+
private onStopCameraDeviceTestFinished;
|
|
90
|
+
private onStartMicDeviceTestFinished;
|
|
91
|
+
private onStopMicDeviceTestFinished;
|
|
92
|
+
private onStartSpeakerDeviceTestFinished;
|
|
93
|
+
private onStopSpeakerDeviceTestFinished;
|
|
94
|
+
private onSetApplicationPlayVolumeFinished;
|
|
95
|
+
private onGetApplicationPlayVolumeFinished;
|
|
96
|
+
private onSetApplicationMuteStateFinished;
|
|
97
|
+
private onGetApplicationMuteStateFinished;
|
|
98
|
+
}
|
|
99
|
+
export default TRTCDeviceManager;
|