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