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.
@@ -0,0 +1,91 @@
1
+ declare const NodeTRTCEngine: any;
2
+ import { TRTCCameraCaptureParams, TRTCDeviceInfo, TRTCDeviceType, Rect } from '../../trtc_define';
3
+ /**
4
+ * 设备管理器
5
+ */
6
+ export declare class TRTCDeviceManager {
7
+ private logPrefix;
8
+ private static deviceNanager;
9
+ private static isIPCMode;
10
+ private nodeDeviceManager;
11
+ private promiseStore;
12
+ private eventEmitter;
13
+ constructor(options: {
14
+ isIPCMode: boolean;
15
+ nodeTRTCCloud: typeof NodeTRTCEngine.TRTCCloud | typeof NodeTRTCEngine.RemoteTRTCCloud;
16
+ });
17
+ /**
18
+ * 获取设备管理器
19
+ * @returns {TRTCDeviceManager}
20
+ */
21
+ static getInstance(options: {
22
+ isIPCMode: boolean;
23
+ nodeTRTCCloud: typeof NodeTRTCEngine.TRTCCloud | typeof NodeTRTCEngine.RemoteTRTCCloud;
24
+ }): TRTCDeviceManager;
25
+ /**
26
+ * 获取设备列表
27
+ *
28
+ * @param type {TRTCDeviceType} - 设备类型
29
+ * @returns {Array<TRTCDeviceInfo>}
30
+ */
31
+ getDevicesList(type: TRTCDeviceType): Array<TRTCDeviceInfo>;
32
+ setCurrentDevice(type: TRTCDeviceType, deviceId: string): Promise<void> | void;
33
+ getCurrentDevice(type: TRTCDeviceType): Promise<TRTCDeviceInfo> | TRTCDeviceInfo;
34
+ setCurrentDeviceVolume(type: TRTCDeviceType, volume: number): Promise<void> | void;
35
+ getCurrentDeviceVolume(type: TRTCDeviceType): Promise<number> | number;
36
+ setCurrentDeviceMute(type: TRTCDeviceType, mute: boolean): Promise<void> | void;
37
+ getCurrentDeviceMute(type: TRTCDeviceType): Promise<boolean> | boolean;
38
+ enableFollowingDefaultAudioDevice(type: TRTCDeviceType, enable: boolean): Promise<void> | void;
39
+ startMicDeviceTest(interval: number, playback?: boolean): Promise<void> | void;
40
+ stopMicDeviceTest(): Promise<void> | void;
41
+ startSpeakerDeviceTest(filePath: string): Promise<void> | void;
42
+ stopSpeakerDeviceTest(): Promise<void> | void;
43
+ setApplicationPlayVolume(volume: number): Promise<void> | void;
44
+ getApplicationPlayVolume(): Promise<number> | number;
45
+ setApplicationMuteState(mute: boolean): Promise<void> | void;
46
+ getApplicationMuteState(): Promise<boolean> | boolean;
47
+ setCameraCaptureParam(params: TRTCCameraCaptureParams): Promise<void> | void;
48
+ /**
49
+ * 监听事件
50
+ *
51
+ * @param event {String} - 事件名称
52
+ * @param func {Function} - 事件回调函数
53
+ */
54
+ on(event: string, func: (...args: any[]) => void): void;
55
+ /**
56
+ * 取消事件监听
57
+ *
58
+ * @param event {String} - 事件名
59
+ * @param func {Function} - 事件回调函数
60
+ */
61
+ off(event: string, func: (...args: any[]) => void): void;
62
+ private addPromise;
63
+ private removePromise;
64
+ private eventHandler;
65
+ private onDeviceChange;
66
+ private onSetCurrentDeviceFinished;
67
+ private onGetCurrentDeviceFinished;
68
+ private onSetCurrentDeviceVolumeFinished;
69
+ private onGetCurrentDeviceVolumeFinished;
70
+ private onSetCurrentDeviceMuteFinished;
71
+ private onGetCurrentDeviceMuteFinished;
72
+ private onEnableFollowingDefaultAudioDeviceFinished;
73
+ private onStartCameraDeviceTestFinished;
74
+ private onStopCameraDeviceTestFinished;
75
+ private onStartMicDeviceTestFinished;
76
+ private onStopMicDeviceTestFinished;
77
+ private onStartSpeakerDeviceTestFinished;
78
+ private onStopSpeakerDeviceTestFinished;
79
+ private onSetApplicationPlayVolumeFinished;
80
+ private onGetApplicationPlayVolumeFinished;
81
+ private onSetApplicationMuteStateFinished;
82
+ private onGetApplicationMuteStateFinished;
83
+ startCameraDeviceTest(windowID: number | Uint8Array, rect?: Rect): Promise<number>;
84
+ stopCameraDeviceTest(): Promise<number>;
85
+ setCameraTestRenderMirror(mirror: boolean): void;
86
+ setCameraTestDeviceId(cameraId: string): void;
87
+ setCameraTestResolution(width: number, height: number): void;
88
+ setCameraTestVideoPluginPath(path: string): void;
89
+ setCameraTestVideoPluginParameter(params: string): void;
90
+ }
91
+ export default TRTCDeviceManager;
@@ -0,0 +1,505 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TRTCDeviceManager = void 0;
4
+ const events_1 = require("events");
5
+ const NodeTRTCEngine = require('../../../build/Release/trtc_electron_sdk.node');
6
+ const trtc_define_1 = require("../../trtc_define");
7
+ const logger = console;
8
+ /**
9
+ * 设备管理器
10
+ */
11
+ class TRTCDeviceManager {
12
+ constructor(options) {
13
+ this.logPrefix = '[TRTCDeviceManager]';
14
+ if (!TRTCDeviceManager.deviceNanager) {
15
+ this.promiseStore = new Map();
16
+ this.eventEmitter = new events_1.EventEmitter();
17
+ this.eventHandler = this.eventHandler.bind(this);
18
+ TRTCDeviceManager.isIPCMode = options.isIPCMode;
19
+ if (TRTCDeviceManager.isIPCMode) {
20
+ this.nodeDeviceManager = new NodeTRTCEngine.NodeRemoteDeviceManager();
21
+ this.nodeDeviceManager.setRemoteDeviceManagerCallback(this.eventHandler);
22
+ }
23
+ else {
24
+ this.nodeDeviceManager = options.nodeTRTCCloud;
25
+ }
26
+ TRTCDeviceManager.deviceNanager = this;
27
+ }
28
+ else {
29
+ return TRTCDeviceManager.deviceNanager;
30
+ }
31
+ }
32
+ /**
33
+ * 获取设备管理器
34
+ * @returns {TRTCDeviceManager}
35
+ */
36
+ static getInstance(options) {
37
+ if (!TRTCDeviceManager.deviceNanager) {
38
+ TRTCDeviceManager.deviceNanager = new TRTCDeviceManager(options);
39
+ }
40
+ return TRTCDeviceManager.deviceNanager;
41
+ }
42
+ /**
43
+ * 获取设备列表
44
+ *
45
+ * @param type {TRTCDeviceType} - 设备类型
46
+ * @returns {Array<TRTCDeviceInfo>}
47
+ */
48
+ getDevicesList(type) {
49
+ logger.debug(`${this.logPrefix}getDevicesList`, type);
50
+ const deviceInfos = this.nodeDeviceManager.getDevicesList(type);
51
+ if (type === trtc_define_1.TRTCDeviceType.TRTCDeviceTypeCamera) {
52
+ deviceInfos === null || deviceInfos === void 0 ? void 0 : deviceInfos.forEach((item) => {
53
+ try {
54
+ if (item.deviceProperties) {
55
+ const properties = JSON.parse(item.deviceProperties);
56
+ item.deviceProperties = properties;
57
+ }
58
+ else {
59
+ // 虚拟摄像头可能没有 deviceProperties 字段
60
+ item.deviceProperties = {};
61
+ }
62
+ }
63
+ catch (e) {
64
+ logger.warn(`${this.logPrefix}camera device properties parse error.`, JSON.stringify(item));
65
+ item.deviceProperties = {};
66
+ }
67
+ });
68
+ }
69
+ return deviceInfos;
70
+ }
71
+ setCurrentDevice(type, deviceId) {
72
+ logger.debug(`${this.logPrefix}setCurrentDevice`, type, deviceId);
73
+ if (TRTCDeviceManager.isIPCMode) {
74
+ return new Promise((resolve, reject) => {
75
+ const key = `setCurrentDevice-${type}`;
76
+ this.addPromise(key, resolve, reject);
77
+ this.nodeDeviceManager.setCurrentDevice(type, deviceId);
78
+ });
79
+ }
80
+ else {
81
+ this.nodeDeviceManager.setCurrentDevice(type, deviceId);
82
+ }
83
+ }
84
+ getCurrentDevice(type) {
85
+ logger.debug(`${this.logPrefix}getCurrentDevice`, type);
86
+ if (TRTCDeviceManager.isIPCMode) {
87
+ return new Promise((resolve, reject) => {
88
+ const key = `getCurrentDevice-${type}`;
89
+ this.addPromise(key, resolve, reject);
90
+ this.nodeDeviceManager.getCurrentDevice(type);
91
+ });
92
+ }
93
+ else {
94
+ return this.nodeDeviceManager.getCurrentDevice(type);
95
+ }
96
+ }
97
+ setCurrentDeviceVolume(type, volume) {
98
+ logger.debug(`${this.logPrefix}setCurrentDeviceVolume`, type, volume);
99
+ if (TRTCDeviceManager.isIPCMode) {
100
+ return new Promise((resolve, reject) => {
101
+ const key = `setCurrentDeviceVolume-${type}`;
102
+ this.addPromise(key, resolve, reject);
103
+ this.nodeDeviceManager.setCurrentDeviceVolume(type, volume);
104
+ });
105
+ }
106
+ else {
107
+ this.nodeDeviceManager.setCurrentDeviceVolume(type, volume);
108
+ }
109
+ }
110
+ getCurrentDeviceVolume(type) {
111
+ logger.debug(`${this.logPrefix}getCurrentDeviceVolume`, type);
112
+ if (TRTCDeviceManager.isIPCMode) {
113
+ return new Promise((resolve, reject) => {
114
+ const key = `getCurrentDeviceVolume-${type}`;
115
+ this.addPromise(key, resolve, reject);
116
+ this.nodeDeviceManager.getCurrentDeviceVolume(type);
117
+ });
118
+ }
119
+ else {
120
+ return this.nodeDeviceManager.getCurrentDeviceVolume(type);
121
+ }
122
+ }
123
+ setCurrentDeviceMute(type, mute) {
124
+ logger.debug(`${this.logPrefix}setCurrentDeviceMute`, type, mute);
125
+ if (TRTCDeviceManager.isIPCMode) {
126
+ return new Promise((resolve, reject) => {
127
+ const key = `setCurrentDeviceMute-${type}`;
128
+ this.addPromise(key, resolve, reject);
129
+ this.nodeDeviceManager.setCurrentDeviceMute(type, mute);
130
+ });
131
+ }
132
+ else {
133
+ this.nodeDeviceManager.setCurrentDeviceMute(type, mute);
134
+ }
135
+ }
136
+ getCurrentDeviceMute(type) {
137
+ logger.debug(`${this.logPrefix}getCurrentDeviceMute`);
138
+ if (TRTCDeviceManager.isIPCMode) {
139
+ return new Promise((resolve, reject) => {
140
+ const key = `getCurrentDeviceMute-${type}`;
141
+ this.addPromise(key, resolve, reject);
142
+ this.nodeDeviceManager.getCurrentDeviceMute(type);
143
+ });
144
+ }
145
+ else {
146
+ return this.nodeDeviceManager.getCurrentDeviceMute(type);
147
+ }
148
+ }
149
+ enableFollowingDefaultAudioDevice(type, enable) {
150
+ logger.debug(`${this.logPrefix}enableFollowingDefaultAudioDevice`, type, enable);
151
+ if (TRTCDeviceManager.isIPCMode) {
152
+ return new Promise((resolve, reject) => {
153
+ const key = `enableFollowingDefaultAudioDevice-${type}`;
154
+ this.addPromise(key, resolve, reject);
155
+ this.nodeDeviceManager.enableFollowingDefaultAudioDevice(type, enable);
156
+ });
157
+ }
158
+ else {
159
+ this.nodeDeviceManager.enableFollowingDefaultAudioDevice(type, enable);
160
+ }
161
+ }
162
+ startMicDeviceTest(interval, playback = false) {
163
+ logger.debug(`${this.logPrefix}startMicDeviceTest`, interval, playback);
164
+ if (TRTCDeviceManager.isIPCMode) {
165
+ return new Promise((resolve, reject) => {
166
+ const key = `startMicDeviceTest`;
167
+ this.addPromise(key, resolve, reject);
168
+ this.nodeDeviceManager.startMicDeviceTest(interval, playback);
169
+ });
170
+ }
171
+ else {
172
+ this.nodeDeviceManager.startMicDeviceTest(interval, playback);
173
+ }
174
+ }
175
+ stopMicDeviceTest() {
176
+ logger.debug(`${this.logPrefix}stopMicDeviceTest`);
177
+ if (TRTCDeviceManager.isIPCMode) {
178
+ return new Promise((resolve, reject) => {
179
+ const key = `stopMicDeviceTest`;
180
+ this.addPromise(key, resolve, reject);
181
+ this.nodeDeviceManager.stopMicDeviceTest();
182
+ });
183
+ }
184
+ else {
185
+ this.nodeDeviceManager.stopMicDeviceTest();
186
+ }
187
+ }
188
+ startSpeakerDeviceTest(filePath) {
189
+ logger.debug(`${this.logPrefix}startSpeakerDeviceTest`, filePath);
190
+ if (TRTCDeviceManager.isIPCMode) {
191
+ return new Promise((resolve, reject) => {
192
+ const key = `startSpeakerDeviceTest`;
193
+ this.addPromise(key, resolve, reject);
194
+ this.nodeDeviceManager.startSpeakerDeviceTest(filePath);
195
+ });
196
+ }
197
+ else {
198
+ this.nodeDeviceManager.startSpeakerDeviceTest(filePath);
199
+ }
200
+ }
201
+ stopSpeakerDeviceTest() {
202
+ logger.debug(`${this.logPrefix}stopSpeakerDeviceTest`);
203
+ if (TRTCDeviceManager.isIPCMode) {
204
+ return new Promise((resolve, reject) => {
205
+ const key = `stopSpeakerDeviceTest`;
206
+ this.addPromise(key, resolve, reject);
207
+ this.nodeDeviceManager.stopSpeakerDeviceTest();
208
+ });
209
+ }
210
+ else {
211
+ this.nodeDeviceManager.stopSpeakerDeviceTest();
212
+ }
213
+ }
214
+ setApplicationPlayVolume(volume) {
215
+ logger.debug(`${this.logPrefix}setApplicationPlayVolume`, volume);
216
+ if (TRTCDeviceManager.isIPCMode) {
217
+ return new Promise((resolve, reject) => {
218
+ const key = `setApplicationPlayVolume`;
219
+ this.addPromise(key, resolve, reject);
220
+ this.nodeDeviceManager.setApplicationPlayVolume(volume);
221
+ });
222
+ }
223
+ else {
224
+ this.nodeDeviceManager.setApplicationPlayVolume(volume);
225
+ }
226
+ }
227
+ getApplicationPlayVolume() {
228
+ logger.debug(`${this.logPrefix}getApplicationPlayVolume`);
229
+ if (TRTCDeviceManager.isIPCMode) {
230
+ return new Promise((resolve, reject) => {
231
+ const key = `getApplicationPlayVolume`;
232
+ this.addPromise(key, resolve, reject);
233
+ this.nodeDeviceManager.getApplicationPlayVolume();
234
+ });
235
+ }
236
+ else {
237
+ return this.nodeDeviceManager.getApplicationPlayVolume();
238
+ }
239
+ }
240
+ setApplicationMuteState(mute) {
241
+ logger.debug(`${this.logPrefix}setApplicationMuteState`, mute);
242
+ if (TRTCDeviceManager.isIPCMode) {
243
+ return new Promise((resolve, reject) => {
244
+ const key = `setApplicationMuteState`;
245
+ this.addPromise(key, resolve, reject);
246
+ this.nodeDeviceManager.setApplicationMuteState(mute);
247
+ });
248
+ }
249
+ else {
250
+ this.nodeDeviceManager.setApplicationMuteState(mute);
251
+ }
252
+ }
253
+ getApplicationMuteState() {
254
+ logger.debug(`${this.logPrefix}getApplicationMuteState`);
255
+ if (TRTCDeviceManager.isIPCMode) {
256
+ return new Promise((resolve, reject) => {
257
+ const key = `setApplicationMuteState`;
258
+ this.addPromise(key, resolve, reject);
259
+ this.nodeDeviceManager.getApplicationMuteState();
260
+ });
261
+ }
262
+ else {
263
+ return this.nodeDeviceManager.getApplicationMuteState();
264
+ }
265
+ }
266
+ setCameraCaptureParam(params) {
267
+ logger.debug(`${this.logPrefix}setCameraCaptureParam:`, params);
268
+ if (TRTCDeviceManager.isIPCMode) {
269
+ return this.nodeDeviceManager.setCameraCapturerParam(params);
270
+ }
271
+ else {
272
+ this.nodeDeviceManager.setCameraCaptureParam(params);
273
+ }
274
+ }
275
+ /**
276
+ * 监听事件
277
+ *
278
+ * @param event {String} - 事件名称
279
+ * @param func {Function} - 事件回调函数
280
+ */
281
+ on(event, func) {
282
+ var _a;
283
+ (_a = this.eventEmitter) === null || _a === void 0 ? void 0 : _a.on(event, func);
284
+ }
285
+ /**
286
+ * 取消事件监听
287
+ *
288
+ * @param event {String} - 事件名
289
+ * @param func {Function} - 事件回调函数
290
+ */
291
+ off(event, func) {
292
+ var _a;
293
+ (_a = this.eventEmitter) === null || _a === void 0 ? void 0 : _a.off(event, func);
294
+ }
295
+ addPromise(key, resolve, reject) {
296
+ var _a, _b, _c;
297
+ if (!((_a = this.promiseStore) === null || _a === void 0 ? void 0 : _a.has(key))) {
298
+ (_b = this.promiseStore) === null || _b === void 0 ? void 0 : _b.set(key, []);
299
+ }
300
+ const storedPromises = (_c = this.promiseStore) === null || _c === void 0 ? void 0 : _c.get(key);
301
+ storedPromises === null || storedPromises === void 0 ? void 0 : storedPromises.push({
302
+ resolve,
303
+ reject
304
+ });
305
+ }
306
+ removePromise(key, value) {
307
+ var _a, _b;
308
+ const storedPromises = (_a = this.promiseStore) === null || _a === void 0 ? void 0 : _a.get(key);
309
+ if (storedPromises) {
310
+ storedPromises.forEach(({ resolve, reject }) => {
311
+ resolve(value);
312
+ });
313
+ (_b = this.promiseStore) === null || _b === void 0 ? void 0 : _b.delete(key);
314
+ }
315
+ }
316
+ eventHandler(args) {
317
+ logger.debug('TRTCDeviceManager event:', args);
318
+ const key = args[0];
319
+ const data = args[1];
320
+ switch (key) {
321
+ case "onDeviceChanged":
322
+ this.onDeviceChange(data.deviceId, data.type, data.state);
323
+ break;
324
+ case "onSetCurrentDeviceFinished":
325
+ this.onSetCurrentDeviceFinished(data.type, data.result);
326
+ break;
327
+ case "onGetCurrentDeviceFinished":
328
+ this.onGetCurrentDeviceFinished(data.type, {
329
+ deviceId: data.deviceId,
330
+ deviceName: data.deviceName,
331
+ deviceProperties: {}
332
+ });
333
+ break;
334
+ case "onSetCurrentDeviceVolumeFinished":
335
+ this.onSetCurrentDeviceVolumeFinished(data.type, data.result);
336
+ break;
337
+ case "onGetCurrentDeviceVolumeFinished":
338
+ this.onGetCurrentDeviceVolumeFinished(data.type, data.volume);
339
+ break;
340
+ case "onSetCurrentDeviceMuteFinished":
341
+ this.onSetCurrentDeviceMuteFinished(data.type, data.result);
342
+ break;
343
+ case "onGetCurrentDeviceMuteFinished":
344
+ this.onGetCurrentDeviceMuteFinished(data.type, data.muted);
345
+ break;
346
+ case "onEnableFollowingDefaultAudioDeviceFinished":
347
+ this.onEnableFollowingDefaultAudioDeviceFinished(data.type, data.result);
348
+ break;
349
+ case "onStartCameraDeviceTestFinished":
350
+ this.onStartCameraDeviceTestFinished(data.result);
351
+ break;
352
+ case "onStopCameraDeviceTestFinished":
353
+ this.onStopCameraDeviceTestFinished(data.result);
354
+ break;
355
+ case "onStartMicDeviceTestFinished":
356
+ this.onStartMicDeviceTestFinished(data.result);
357
+ break;
358
+ case "onStopMicDeviceTestFinished":
359
+ this.onStopMicDeviceTestFinished(data.result);
360
+ break;
361
+ case "onStartSpeakerDeviceTestFinished":
362
+ this.onStartSpeakerDeviceTestFinished(data.result);
363
+ break;
364
+ case "onStopSpeakerDeviceTestFinished":
365
+ this.onStopSpeakerDeviceTestFinished(data.result);
366
+ break;
367
+ case "onSetApplicationPlayVolumeFinished":
368
+ this.onSetApplicationPlayVolumeFinished(data.result);
369
+ break;
370
+ case "onGetApplicationPlayVolumeFinished":
371
+ this.onGetApplicationPlayVolumeFinished(data.volume);
372
+ break;
373
+ case "onSetApplicationMuteStateFinished":
374
+ this.onSetApplicationMuteStateFinished(data.result);
375
+ break;
376
+ case "onGetApplicationMuteStateFinished":
377
+ this.onGetApplicationMuteStateFinished(data.muted);
378
+ break;
379
+ default:
380
+ logger.warn("TRTCDeviceManager unsupported event type:", key);
381
+ break;
382
+ }
383
+ }
384
+ onDeviceChange(deviceId, type, state) {
385
+ var _a;
386
+ logger.debug(`${this.logPrefix}onDeviceChange`, deviceId, type, state);
387
+ (_a = this.eventEmitter) === null || _a === void 0 ? void 0 : _a.emit('onDeviceChange', deviceId, type, state);
388
+ }
389
+ onSetCurrentDeviceFinished(type, result) {
390
+ const key = `setCurrentDevice-${type}`;
391
+ this.removePromise(key, result);
392
+ }
393
+ onGetCurrentDeviceFinished(type, deviceInfo) {
394
+ const key = `getCurrentDevice-${type}`;
395
+ this.removePromise(key, deviceInfo);
396
+ }
397
+ onSetCurrentDeviceVolumeFinished(type, result) {
398
+ const key = `setCurrentDeviceVolume-${type}`;
399
+ this.removePromise(key, result);
400
+ }
401
+ onGetCurrentDeviceVolumeFinished(type, volume) {
402
+ const key = `getCurrentDeviceVolume-${type}`;
403
+ this.removePromise(key, volume);
404
+ }
405
+ onSetCurrentDeviceMuteFinished(type, result) {
406
+ const key = `setCurrentDeviceMute-${type}`;
407
+ this.removePromise(key, result);
408
+ }
409
+ onGetCurrentDeviceMuteFinished(type, muted) {
410
+ const key = `getCurrentDeviceMute-${type}`;
411
+ this.removePromise(key, muted);
412
+ }
413
+ onEnableFollowingDefaultAudioDeviceFinished(type, result) {
414
+ const key = `enableFollowingDefaultAudioDevice-${type}`;
415
+ this.removePromise(key, result);
416
+ }
417
+ onStartCameraDeviceTestFinished(result) {
418
+ const key = `startCameraDeviceTest`;
419
+ this.removePromise(key, result);
420
+ }
421
+ onStopCameraDeviceTestFinished(result) {
422
+ const key = `stopCameraDeviceTest`;
423
+ this.removePromise(key, result);
424
+ }
425
+ onStartMicDeviceTestFinished(result) {
426
+ const key = `startMicDeviceTest`;
427
+ this.removePromise(key, result);
428
+ }
429
+ onStopMicDeviceTestFinished(result) {
430
+ const key = `stopMicDeviceTest`;
431
+ this.removePromise(key, result);
432
+ }
433
+ onStartSpeakerDeviceTestFinished(result) {
434
+ const key = `startSpeakerDeviceTest`;
435
+ this.removePromise(key, result);
436
+ }
437
+ onStopSpeakerDeviceTestFinished(result) {
438
+ const key = `stopSpeakerDeviceTest`;
439
+ this.removePromise(key, result);
440
+ }
441
+ onSetApplicationPlayVolumeFinished(result) {
442
+ const key = `setApplicationPlayVolume`;
443
+ this.removePromise(key, result);
444
+ }
445
+ onGetApplicationPlayVolumeFinished(volume) {
446
+ const key = `getApplicationPlayVolume`;
447
+ this.removePromise(key, volume);
448
+ }
449
+ onSetApplicationMuteStateFinished(result) {
450
+ const key = `setApplicationMuteState`;
451
+ this.removePromise(key, result);
452
+ }
453
+ onGetApplicationMuteStateFinished(muted) {
454
+ const key = `getApplicationMuteState`;
455
+ this.removePromise(key, muted);
456
+ }
457
+ // ****** 这一部分接口暴露不合理,暂时通过 TRTCMediaMixingManager 暴露给用户 **************/
458
+ startCameraDeviceTest(windowID, rect) {
459
+ logger.debug(`${this.logPrefix}startCameraDeviceTest`, windowID, rect);
460
+ let newWindowID = 0;
461
+ if (windowID instanceof Uint8Array) {
462
+ for (let i = windowID.length - 1; i >= 0; i--) {
463
+ newWindowID = (newWindowID * 256) + windowID[i];
464
+ }
465
+ }
466
+ else {
467
+ newWindowID = windowID;
468
+ }
469
+ return new Promise((resolve, reject) => {
470
+ const key = `startCameraDeviceTest`;
471
+ this.addPromise(key, resolve, reject);
472
+ this.nodeDeviceManager.startCameraDeviceTest(newWindowID, rect);
473
+ });
474
+ }
475
+ stopCameraDeviceTest() {
476
+ logger.debug(`${this.logPrefix}stopCameraDeviceTest`);
477
+ return new Promise((resolve, reject) => {
478
+ const key = `stopCameraDeviceTest`;
479
+ this.addPromise(key, resolve, reject);
480
+ this.nodeDeviceManager.stopCameraDeviceTest();
481
+ });
482
+ }
483
+ setCameraTestRenderMirror(mirror) {
484
+ logger.debug(`${this.logPrefix}setCameraTestRenderMirror`, mirror);
485
+ this.nodeDeviceManager.setCameraTestRenderMirror(mirror);
486
+ }
487
+ setCameraTestDeviceId(cameraId) {
488
+ logger.debug(`${this.logPrefix}setCameraTestDeviceId`, cameraId);
489
+ this.nodeDeviceManager.setCameraTestDeviceId(cameraId);
490
+ }
491
+ setCameraTestResolution(width, height) {
492
+ logger.debug(`${this.logPrefix}setCameraTestResolution`, width, height);
493
+ this.nodeDeviceManager.setCameraTestResolution(width, height);
494
+ }
495
+ setCameraTestVideoPluginPath(path) {
496
+ logger.debug(`${this.logPrefix}setCameraTestVideoPluginPath`, path);
497
+ this.nodeDeviceManager.setCameraTestVideoPluginPath(path);
498
+ }
499
+ setCameraTestVideoPluginParameter(params) {
500
+ logger.debug(`${this.logPrefix}setCameraTestVideoPluginParameter`, params);
501
+ this.nodeDeviceManager.setCameraTestVideoPluginParameter(params);
502
+ }
503
+ }
504
+ exports.TRTCDeviceManager = TRTCDeviceManager;
505
+ exports.default = TRTCDeviceManager;