trtc-electron-sdk 12.0.606 → 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/README.md +2 -2
- package/liteav/VideoRenderControl/VideoRenderFPSMonitor.d.ts +37 -0
- package/liteav/VideoRenderControl/VideoRenderFPSMonitor.js +127 -0
- 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 +74 -7
- package/liteav/trtc.js +198 -24
- package/liteav/trtc_define.d.ts +64 -6
- package/liteav/trtc_define.js +79 -46
- package/package.json +1 -1
- package/scripts/copy-sdk.js +4 -0
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ Tencent Real-Time Communication (TRTC) is a set of low-latency, high-quality rea
|
|
|
23
23
|
## ⏬ Install
|
|
24
24
|
By default, it will install the SDK compatible with your device Operation System platform and node.js CPU architecture. If you want to install SDK for specific Operating System or CPU architecture. You can configure the `platform` and `arch` you want in `package.json` or `.npmrc` file as following code. If you configure both, the configuration in `package.json` will work and override that in `.npmrc`.
|
|
25
25
|
|
|
26
|
-
```
|
|
26
|
+
```js
|
|
27
27
|
// package.json
|
|
28
28
|
{
|
|
29
29
|
...
|
|
@@ -65,7 +65,7 @@ const version = rtcCloud.getSDKVersion();
|
|
|
65
65
|
## 📦 Build
|
|
66
66
|
Taking webpack and electron-builder as example.
|
|
67
67
|
|
|
68
|
-
```
|
|
68
|
+
```js
|
|
69
69
|
// webpack config
|
|
70
70
|
module.exports = {
|
|
71
71
|
...
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @class RenderFPSMonitor
|
|
3
|
+
*/
|
|
4
|
+
declare class VideoRenderFPSMonitor {
|
|
5
|
+
private logPrefix;
|
|
6
|
+
private emitter;
|
|
7
|
+
private nextAnimationFrame;
|
|
8
|
+
private lastTimestamp;
|
|
9
|
+
private refreshCount;
|
|
10
|
+
private pageRefreshFPS;
|
|
11
|
+
private lastPageRefreshFPS;
|
|
12
|
+
private videoRenderFPS;
|
|
13
|
+
private lastVideoRenderFPS;
|
|
14
|
+
private statisticDuration;
|
|
15
|
+
constructor();
|
|
16
|
+
private initPageRefreshFPSStatistic;
|
|
17
|
+
private statisticPageRefreshFPS;
|
|
18
|
+
/**
|
|
19
|
+
* 规则:
|
|
20
|
+
* 页面刷新帧率低于 10 时,设置渲染帧率为 5
|
|
21
|
+
* 页面刷新帧率低于 20 时,设置渲染帧率为 15
|
|
22
|
+
* 页面刷新帧率低于 30 时,设置渲染帧率为 25
|
|
23
|
+
* 页面刷新帧率高于 30 时,设置渲染帧率为 -1,负数表示关闭渲染帧率限制
|
|
24
|
+
* 页面刷新帧率从低于 10 到 30+ 时,持续 2 秒后,设置渲染帧率为 15
|
|
25
|
+
* 页面刷新帧率从低于 20 到 30+ 时,持续 2 秒后,设置渲染帧率为 25
|
|
26
|
+
* 页面刷新帧率从低于 30 到 30+ 时,持续 2 秒后,设置渲染帧率为 -1,负数表示关闭渲染帧率限制
|
|
27
|
+
*/
|
|
28
|
+
private statisticVideoRenderFPS;
|
|
29
|
+
private onVisibilityChange;
|
|
30
|
+
private notifyFPS;
|
|
31
|
+
destroy(): void;
|
|
32
|
+
on(event: string, listener: (...args: any[]) => void): void;
|
|
33
|
+
off(event: string, listener: (...args: any[]) => void): void;
|
|
34
|
+
emit(event: string, ...args: any[]): void;
|
|
35
|
+
}
|
|
36
|
+
export declare const videoRenderFPSMonitor: VideoRenderFPSMonitor;
|
|
37
|
+
export default VideoRenderFPSMonitor;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.videoRenderFPSMonitor = void 0;
|
|
7
|
+
const events_1 = require("events");
|
|
8
|
+
const logger_1 = __importDefault(require("../logger"));
|
|
9
|
+
/**
|
|
10
|
+
* @class RenderFPSMonitor
|
|
11
|
+
*/
|
|
12
|
+
class VideoRenderFPSMonitor {
|
|
13
|
+
constructor() {
|
|
14
|
+
this.logPrefix = '[RenderFPSMonitor]';
|
|
15
|
+
this.emitter = new events_1.EventEmitter();
|
|
16
|
+
this.nextAnimationFrame = 0;
|
|
17
|
+
this.lastTimestamp = 0;
|
|
18
|
+
this.refreshCount = 0;
|
|
19
|
+
this.pageRefreshFPS = 0;
|
|
20
|
+
this.lastPageRefreshFPS = 60;
|
|
21
|
+
this.videoRenderFPS = 0;
|
|
22
|
+
this.lastVideoRenderFPS = -1;
|
|
23
|
+
this.statisticDuration = 2000;
|
|
24
|
+
this.statisticPageRefreshFPS = this.statisticPageRefreshFPS.bind(this);
|
|
25
|
+
this.onVisibilityChange = this.onVisibilityChange.bind(this);
|
|
26
|
+
this.initPageRefreshFPSStatistic();
|
|
27
|
+
document.addEventListener('visibilitychange', this.onVisibilityChange);
|
|
28
|
+
}
|
|
29
|
+
initPageRefreshFPSStatistic() {
|
|
30
|
+
if (window.requestAnimationFrame) {
|
|
31
|
+
this.nextAnimationFrame = window.requestAnimationFrame(this.statisticPageRefreshFPS);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
statisticPageRefreshFPS(timestamp) {
|
|
35
|
+
if (this.lastTimestamp === 0) {
|
|
36
|
+
this.lastTimestamp = timestamp;
|
|
37
|
+
}
|
|
38
|
+
this.refreshCount++;
|
|
39
|
+
const duration = timestamp - this.lastTimestamp;
|
|
40
|
+
if (duration >= this.statisticDuration) {
|
|
41
|
+
this.lastPageRefreshFPS = this.pageRefreshFPS;
|
|
42
|
+
this.pageRefreshFPS = Math.round(this.refreshCount * 1000 / duration);
|
|
43
|
+
setTimeout(() => {
|
|
44
|
+
this.statisticVideoRenderFPS();
|
|
45
|
+
}, 0);
|
|
46
|
+
this.lastTimestamp = timestamp;
|
|
47
|
+
this.refreshCount = 0;
|
|
48
|
+
}
|
|
49
|
+
this.nextAnimationFrame = window.requestAnimationFrame(this.statisticPageRefreshFPS);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* 规则:
|
|
53
|
+
* 页面刷新帧率低于 10 时,设置渲染帧率为 5
|
|
54
|
+
* 页面刷新帧率低于 20 时,设置渲染帧率为 15
|
|
55
|
+
* 页面刷新帧率低于 30 时,设置渲染帧率为 25
|
|
56
|
+
* 页面刷新帧率高于 30 时,设置渲染帧率为 -1,负数表示关闭渲染帧率限制
|
|
57
|
+
* 页面刷新帧率从低于 10 到 30+ 时,持续 2 秒后,设置渲染帧率为 15
|
|
58
|
+
* 页面刷新帧率从低于 20 到 30+ 时,持续 2 秒后,设置渲染帧率为 25
|
|
59
|
+
* 页面刷新帧率从低于 30 到 30+ 时,持续 2 秒后,设置渲染帧率为 -1,负数表示关闭渲染帧率限制
|
|
60
|
+
*/
|
|
61
|
+
statisticVideoRenderFPS() {
|
|
62
|
+
if (this.pageRefreshFPS <= 10) {
|
|
63
|
+
this.videoRenderFPS = this.pageRefreshFPS < 5 ? this.pageRefreshFPS : 5;
|
|
64
|
+
}
|
|
65
|
+
else if (this.pageRefreshFPS <= 20) {
|
|
66
|
+
this.videoRenderFPS = this.pageRefreshFPS < 15 ? this.pageRefreshFPS : 15;
|
|
67
|
+
}
|
|
68
|
+
else if (this.pageRefreshFPS <= 30) {
|
|
69
|
+
this.videoRenderFPS = this.pageRefreshFPS < 25 ? this.pageRefreshFPS : 25;
|
|
70
|
+
}
|
|
71
|
+
else if (this.pageRefreshFPS > 30 && this.lastPageRefreshFPS <= 10) {
|
|
72
|
+
this.videoRenderFPS = 15;
|
|
73
|
+
}
|
|
74
|
+
else if (this.pageRefreshFPS > 30 && this.lastPageRefreshFPS <= 20) {
|
|
75
|
+
this.videoRenderFPS = 25;
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
this.videoRenderFPS = -1;
|
|
79
|
+
}
|
|
80
|
+
if (this.lastVideoRenderFPS !== this.videoRenderFPS) {
|
|
81
|
+
this.lastVideoRenderFPS = this.videoRenderFPS;
|
|
82
|
+
this.notifyFPS();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
onVisibilityChange() {
|
|
86
|
+
if (document.hidden) {
|
|
87
|
+
logger_1.default.info(`${this.logPrefix} document hidden`);
|
|
88
|
+
this.videoRenderFPS = 1;
|
|
89
|
+
this.pageRefreshFPS = 1;
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
logger_1.default.info(`${this.logPrefix} document show`);
|
|
93
|
+
this.videoRenderFPS = 5; // 慢启动
|
|
94
|
+
this.pageRefreshFPS = 5;
|
|
95
|
+
}
|
|
96
|
+
this.lastVideoRenderFPS = this.videoRenderFPS;
|
|
97
|
+
this.lastTimestamp = 0;
|
|
98
|
+
this.refreshCount = 0;
|
|
99
|
+
this.notifyFPS();
|
|
100
|
+
}
|
|
101
|
+
notifyFPS() {
|
|
102
|
+
logger_1.default.debug(`${this.logPrefix} pageRefreshFPS:${this.pageRefreshFPS} videoRenderFPS: ${this.videoRenderFPS}`);
|
|
103
|
+
this.emit('videoRenderFPS', {
|
|
104
|
+
pageFPS: this.pageRefreshFPS,
|
|
105
|
+
videoFPS: this.videoRenderFPS,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
destroy() {
|
|
109
|
+
if (this.nextAnimationFrame) {
|
|
110
|
+
window.cancelAnimationFrame(this.nextAnimationFrame);
|
|
111
|
+
this.nextAnimationFrame = 0;
|
|
112
|
+
}
|
|
113
|
+
this.emitter.removeAllListeners();
|
|
114
|
+
document.removeEventListener('visibilitychange', this.onVisibilityChange);
|
|
115
|
+
}
|
|
116
|
+
on(event, listener) {
|
|
117
|
+
this.emitter.on(event, listener);
|
|
118
|
+
}
|
|
119
|
+
off(event, listener) {
|
|
120
|
+
this.emitter.off(event, listener);
|
|
121
|
+
}
|
|
122
|
+
emit(event, ...args) {
|
|
123
|
+
this.emitter.emit(event, ...args);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
exports.videoRenderFPSMonitor = new VideoRenderFPSMonitor();
|
|
127
|
+
exports.default = VideoRenderFPSMonitor;
|
|
@@ -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;
|