trtc-electron-sdk 12.2.701 → 12.2.702

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.
@@ -1,43 +1,42 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.TRTCDeviceManager = void 0;
4
7
  const events_1 = require("events");
5
- const NodeTRTCEngine = require('../../../build/Release/trtc_electron_sdk.node');
6
8
  const trtc_define_1 = require("../../trtc_define");
7
- const logger = console;
9
+ const logger_1 = __importDefault(require("../../logger"));
10
+ const NodeTRTCEngine = require('../../../build/Release/trtc_electron_sdk.node');
8
11
  /**
9
12
  * 设备管理器
10
13
  */
11
14
  class TRTCDeviceManager {
12
15
  constructor(options) {
13
16
  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;
17
+ this.promiseStore = new Map();
18
+ this.eventEmitter = new events_1.EventEmitter();
19
+ this.eventHandler = this.eventHandler.bind(this);
20
+ this.isIPCMode = options.isIPCMode;
21
+ if (this.isIPCMode) {
22
+ this.nodeDeviceManager = new NodeTRTCEngine.NodeRemoteDeviceManager();
23
+ this.nodeDeviceManager.setRemoteDeviceManagerCallback(this.eventHandler);
27
24
  }
28
25
  else {
29
- return TRTCDeviceManager.deviceNanager;
26
+ this.nodeDeviceManager = options.nodeTRTCCloud;
30
27
  }
31
28
  }
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;
29
+ destroy() {
30
+ var _a, _b;
31
+ this.nodeDeviceManager = null;
32
+ (_a = this.promiseStore) === null || _a === void 0 ? void 0 : _a.forEach((value) => {
33
+ value.forEach(({ reject }) => {
34
+ reject();
35
+ });
36
+ });
37
+ (_b = this.promiseStore) === null || _b === void 0 ? void 0 : _b.clear();
38
+ this.promiseStore = undefined;
39
+ this.eventEmitter = undefined;
41
40
  }
42
41
  /**
43
42
  * 获取设备列表
@@ -46,7 +45,7 @@ class TRTCDeviceManager {
46
45
  * @returns {Array<TRTCDeviceInfo>}
47
46
  */
48
47
  getDevicesList(type) {
49
- logger.debug(`${this.logPrefix}getDevicesList`, type);
48
+ logger_1.default.debug(`${this.logPrefix}getDevicesList`, type);
50
49
  const deviceInfos = this.nodeDeviceManager.getDevicesList(type);
51
50
  if (type === trtc_define_1.TRTCDeviceType.TRTCDeviceTypeCamera) {
52
51
  deviceInfos === null || deviceInfos === void 0 ? void 0 : deviceInfos.forEach((item) => {
@@ -61,7 +60,7 @@ class TRTCDeviceManager {
61
60
  }
62
61
  }
63
62
  catch (e) {
64
- logger.warn(`${this.logPrefix}camera device properties parse error.`, JSON.stringify(item));
63
+ logger_1.default.warn(`${this.logPrefix}camera device properties parse error.`, JSON.stringify(item));
65
64
  item.deviceProperties = {};
66
65
  }
67
66
  });
@@ -69,8 +68,8 @@ class TRTCDeviceManager {
69
68
  return deviceInfos;
70
69
  }
71
70
  setCurrentDevice(type, deviceId) {
72
- logger.debug(`${this.logPrefix}setCurrentDevice`, type, deviceId);
73
- if (TRTCDeviceManager.isIPCMode) {
71
+ logger_1.default.debug(`${this.logPrefix}setCurrentDevice`, type, deviceId);
72
+ if (this.isIPCMode) {
74
73
  return new Promise((resolve, reject) => {
75
74
  const key = `setCurrentDevice-${type}`;
76
75
  this.addPromise(key, resolve, reject);
@@ -82,8 +81,8 @@ class TRTCDeviceManager {
82
81
  }
83
82
  }
84
83
  getCurrentDevice(type) {
85
- logger.debug(`${this.logPrefix}getCurrentDevice`, type);
86
- if (TRTCDeviceManager.isIPCMode) {
84
+ logger_1.default.debug(`${this.logPrefix}getCurrentDevice`, type);
85
+ if (this.isIPCMode) {
87
86
  return new Promise((resolve, reject) => {
88
87
  const key = `getCurrentDevice-${type}`;
89
88
  this.addPromise(key, resolve, reject);
@@ -95,8 +94,8 @@ class TRTCDeviceManager {
95
94
  }
96
95
  }
97
96
  setCurrentDeviceVolume(type, volume) {
98
- logger.debug(`${this.logPrefix}setCurrentDeviceVolume`, type, volume);
99
- if (TRTCDeviceManager.isIPCMode) {
97
+ logger_1.default.debug(`${this.logPrefix}setCurrentDeviceVolume`, type, volume);
98
+ if (this.isIPCMode) {
100
99
  return new Promise((resolve, reject) => {
101
100
  const key = `setCurrentDeviceVolume-${type}`;
102
101
  this.addPromise(key, resolve, reject);
@@ -108,8 +107,8 @@ class TRTCDeviceManager {
108
107
  }
109
108
  }
110
109
  getCurrentDeviceVolume(type) {
111
- logger.debug(`${this.logPrefix}getCurrentDeviceVolume`, type);
112
- if (TRTCDeviceManager.isIPCMode) {
110
+ logger_1.default.debug(`${this.logPrefix}getCurrentDeviceVolume`, type);
111
+ if (this.isIPCMode) {
113
112
  return new Promise((resolve, reject) => {
114
113
  const key = `getCurrentDeviceVolume-${type}`;
115
114
  this.addPromise(key, resolve, reject);
@@ -121,8 +120,8 @@ class TRTCDeviceManager {
121
120
  }
122
121
  }
123
122
  setCurrentDeviceMute(type, mute) {
124
- logger.debug(`${this.logPrefix}setCurrentDeviceMute`, type, mute);
125
- if (TRTCDeviceManager.isIPCMode) {
123
+ logger_1.default.debug(`${this.logPrefix}setCurrentDeviceMute`, type, mute);
124
+ if (this.isIPCMode) {
126
125
  return new Promise((resolve, reject) => {
127
126
  const key = `setCurrentDeviceMute-${type}`;
128
127
  this.addPromise(key, resolve, reject);
@@ -134,8 +133,8 @@ class TRTCDeviceManager {
134
133
  }
135
134
  }
136
135
  getCurrentDeviceMute(type) {
137
- logger.debug(`${this.logPrefix}getCurrentDeviceMute`);
138
- if (TRTCDeviceManager.isIPCMode) {
136
+ logger_1.default.debug(`${this.logPrefix}getCurrentDeviceMute`);
137
+ if (this.isIPCMode) {
139
138
  return new Promise((resolve, reject) => {
140
139
  const key = `getCurrentDeviceMute-${type}`;
141
140
  this.addPromise(key, resolve, reject);
@@ -147,8 +146,8 @@ class TRTCDeviceManager {
147
146
  }
148
147
  }
149
148
  enableFollowingDefaultAudioDevice(type, enable) {
150
- logger.debug(`${this.logPrefix}enableFollowingDefaultAudioDevice`, type, enable);
151
- if (TRTCDeviceManager.isIPCMode) {
149
+ logger_1.default.debug(`${this.logPrefix}enableFollowingDefaultAudioDevice`, type, enable);
150
+ if (this.isIPCMode) {
152
151
  return new Promise((resolve, reject) => {
153
152
  const key = `enableFollowingDefaultAudioDevice-${type}`;
154
153
  this.addPromise(key, resolve, reject);
@@ -160,8 +159,8 @@ class TRTCDeviceManager {
160
159
  }
161
160
  }
162
161
  startMicDeviceTest(interval, playback = false) {
163
- logger.debug(`${this.logPrefix}startMicDeviceTest`, interval, playback);
164
- if (TRTCDeviceManager.isIPCMode) {
162
+ logger_1.default.debug(`${this.logPrefix}startMicDeviceTest`, interval, playback);
163
+ if (this.isIPCMode) {
165
164
  return new Promise((resolve, reject) => {
166
165
  const key = `startMicDeviceTest`;
167
166
  this.addPromise(key, resolve, reject);
@@ -173,8 +172,8 @@ class TRTCDeviceManager {
173
172
  }
174
173
  }
175
174
  stopMicDeviceTest() {
176
- logger.debug(`${this.logPrefix}stopMicDeviceTest`);
177
- if (TRTCDeviceManager.isIPCMode) {
175
+ logger_1.default.debug(`${this.logPrefix}stopMicDeviceTest`);
176
+ if (this.isIPCMode) {
178
177
  return new Promise((resolve, reject) => {
179
178
  const key = `stopMicDeviceTest`;
180
179
  this.addPromise(key, resolve, reject);
@@ -186,8 +185,8 @@ class TRTCDeviceManager {
186
185
  }
187
186
  }
188
187
  startSpeakerDeviceTest(filePath) {
189
- logger.debug(`${this.logPrefix}startSpeakerDeviceTest`, filePath);
190
- if (TRTCDeviceManager.isIPCMode) {
188
+ logger_1.default.debug(`${this.logPrefix}startSpeakerDeviceTest`, filePath);
189
+ if (this.isIPCMode) {
191
190
  return new Promise((resolve, reject) => {
192
191
  const key = `startSpeakerDeviceTest`;
193
192
  this.addPromise(key, resolve, reject);
@@ -199,8 +198,8 @@ class TRTCDeviceManager {
199
198
  }
200
199
  }
201
200
  stopSpeakerDeviceTest() {
202
- logger.debug(`${this.logPrefix}stopSpeakerDeviceTest`);
203
- if (TRTCDeviceManager.isIPCMode) {
201
+ logger_1.default.debug(`${this.logPrefix}stopSpeakerDeviceTest`);
202
+ if (this.isIPCMode) {
204
203
  return new Promise((resolve, reject) => {
205
204
  const key = `stopSpeakerDeviceTest`;
206
205
  this.addPromise(key, resolve, reject);
@@ -212,8 +211,8 @@ class TRTCDeviceManager {
212
211
  }
213
212
  }
214
213
  setApplicationPlayVolume(volume) {
215
- logger.debug(`${this.logPrefix}setApplicationPlayVolume`, volume);
216
- if (TRTCDeviceManager.isIPCMode) {
214
+ logger_1.default.debug(`${this.logPrefix}setApplicationPlayVolume`, volume);
215
+ if (this.isIPCMode) {
217
216
  return new Promise((resolve, reject) => {
218
217
  const key = `setApplicationPlayVolume`;
219
218
  this.addPromise(key, resolve, reject);
@@ -225,8 +224,8 @@ class TRTCDeviceManager {
225
224
  }
226
225
  }
227
226
  getApplicationPlayVolume() {
228
- logger.debug(`${this.logPrefix}getApplicationPlayVolume`);
229
- if (TRTCDeviceManager.isIPCMode) {
227
+ logger_1.default.debug(`${this.logPrefix}getApplicationPlayVolume`);
228
+ if (this.isIPCMode) {
230
229
  return new Promise((resolve, reject) => {
231
230
  const key = `getApplicationPlayVolume`;
232
231
  this.addPromise(key, resolve, reject);
@@ -238,8 +237,8 @@ class TRTCDeviceManager {
238
237
  }
239
238
  }
240
239
  setApplicationMuteState(mute) {
241
- logger.debug(`${this.logPrefix}setApplicationMuteState`, mute);
242
- if (TRTCDeviceManager.isIPCMode) {
240
+ logger_1.default.debug(`${this.logPrefix}setApplicationMuteState`, mute);
241
+ if (this.isIPCMode) {
243
242
  return new Promise((resolve, reject) => {
244
243
  const key = `setApplicationMuteState`;
245
244
  this.addPromise(key, resolve, reject);
@@ -251,8 +250,8 @@ class TRTCDeviceManager {
251
250
  }
252
251
  }
253
252
  getApplicationMuteState() {
254
- logger.debug(`${this.logPrefix}getApplicationMuteState`);
255
- if (TRTCDeviceManager.isIPCMode) {
253
+ logger_1.default.debug(`${this.logPrefix}getApplicationMuteState`);
254
+ if (this.isIPCMode) {
256
255
  return new Promise((resolve, reject) => {
257
256
  const key = `setApplicationMuteState`;
258
257
  this.addPromise(key, resolve, reject);
@@ -264,8 +263,8 @@ class TRTCDeviceManager {
264
263
  }
265
264
  }
266
265
  setCameraCaptureParam(params) {
267
- logger.debug(`${this.logPrefix}setCameraCaptureParam:`, params);
268
- if (TRTCDeviceManager.isIPCMode) {
266
+ logger_1.default.debug(`${this.logPrefix}setCameraCaptureParam:`, params);
267
+ if (this.isIPCMode) {
269
268
  return this.nodeDeviceManager.setCameraCapturerParam(params);
270
269
  }
271
270
  else {
@@ -314,7 +313,7 @@ class TRTCDeviceManager {
314
313
  }
315
314
  }
316
315
  eventHandler(args) {
317
- logger.debug('TRTCDeviceManager event:', args);
316
+ logger_1.default.debug('TRTCDeviceManager event:', args);
318
317
  const key = args[0];
319
318
  const data = args[1];
320
319
  switch (key) {
@@ -377,13 +376,13 @@ class TRTCDeviceManager {
377
376
  this.onGetApplicationMuteStateFinished(data.muted);
378
377
  break;
379
378
  default:
380
- logger.warn("TRTCDeviceManager unsupported event type:", key);
379
+ logger_1.default.warn("TRTCDeviceManager unsupported event type:", key);
381
380
  break;
382
381
  }
383
382
  }
384
383
  onDeviceChange(deviceId, type, state) {
385
384
  var _a;
386
- logger.debug(`${this.logPrefix}onDeviceChange`, deviceId, type, state);
385
+ logger_1.default.debug(`${this.logPrefix}onDeviceChange`, deviceId, type, state);
387
386
  (_a = this.eventEmitter) === null || _a === void 0 ? void 0 : _a.emit('onDeviceChange', deviceId, type, state);
388
387
  }
389
388
  onSetCurrentDeviceFinished(type, result) {
@@ -456,7 +455,7 @@ class TRTCDeviceManager {
456
455
  }
457
456
  // ****** 这一部分接口暴露不合理,暂时通过 TRTCMediaMixingManager 暴露给用户 **************/
458
457
  startCameraDeviceTest(windowID, rect) {
459
- logger.debug(`${this.logPrefix}startCameraDeviceTest`, windowID, rect);
458
+ logger_1.default.debug(`${this.logPrefix}startCameraDeviceTest`, windowID, rect);
460
459
  let newWindowID = 0;
461
460
  if (windowID instanceof Uint8Array) {
462
461
  for (let i = windowID.length - 1; i >= 0; i--) {
@@ -473,7 +472,7 @@ class TRTCDeviceManager {
473
472
  });
474
473
  }
475
474
  stopCameraDeviceTest() {
476
- logger.debug(`${this.logPrefix}stopCameraDeviceTest`);
475
+ logger_1.default.debug(`${this.logPrefix}stopCameraDeviceTest`);
477
476
  return new Promise((resolve, reject) => {
478
477
  const key = `stopCameraDeviceTest`;
479
478
  this.addPromise(key, resolve, reject);
@@ -481,23 +480,23 @@ class TRTCDeviceManager {
481
480
  });
482
481
  }
483
482
  setCameraTestRenderMirror(mirror) {
484
- logger.debug(`${this.logPrefix}setCameraTestRenderMirror`, mirror);
483
+ logger_1.default.debug(`${this.logPrefix}setCameraTestRenderMirror`, mirror);
485
484
  this.nodeDeviceManager.setCameraTestRenderMirror(mirror);
486
485
  }
487
486
  setCameraTestDeviceId(cameraId) {
488
- logger.debug(`${this.logPrefix}setCameraTestDeviceId`, cameraId);
487
+ logger_1.default.debug(`${this.logPrefix}setCameraTestDeviceId`, cameraId);
489
488
  this.nodeDeviceManager.setCameraTestDeviceId(cameraId);
490
489
  }
491
490
  setCameraTestResolution(width, height) {
492
- logger.debug(`${this.logPrefix}setCameraTestResolution`, width, height);
491
+ logger_1.default.debug(`${this.logPrefix}setCameraTestResolution`, width, height);
493
492
  this.nodeDeviceManager.setCameraTestResolution(width, height);
494
493
  }
495
494
  setCameraTestVideoPluginPath(path) {
496
- logger.debug(`${this.logPrefix}setCameraTestVideoPluginPath`, path);
495
+ logger_1.default.debug(`${this.logPrefix}setCameraTestVideoPluginPath`, path);
497
496
  this.nodeDeviceManager.setCameraTestVideoPluginPath(path);
498
497
  }
499
498
  setCameraTestVideoPluginParameter(params) {
500
- logger.debug(`${this.logPrefix}setCameraTestVideoPluginParameter`, params);
499
+ logger_1.default.debug(`${this.logPrefix}setCameraTestVideoPluginParameter`, params);
501
500
  this.nodeDeviceManager.setCameraTestVideoPluginParameter(params);
502
501
  }
503
502
  }
@@ -30,21 +30,13 @@ export declare type TRTCMediaMixingEncParam = {
30
30
  */
31
31
  export declare class TRTCMediaMixingManager {
32
32
  private logPrefix;
33
- private static mediaMixingManager;
34
33
  private nodeMediaMixingPlugin;
35
34
  private deviceManager;
36
35
  private eventEmitter;
37
36
  constructor(options: {
38
37
  deviceManager: TRTCDeviceManager;
39
38
  });
40
- /**
41
- * 获取混流管理器
42
- *
43
- * @returns {TRTCMediaMixingManager}
44
- */
45
- static getInstance(options: {
46
- deviceManager: TRTCDeviceManager;
47
- }): TRTCMediaMixingManager;
39
+ destroy(): void;
48
40
  private eventHandler;
49
41
  /**
50
42
  * 设置混流视频预览参数
@@ -102,7 +94,7 @@ export declare class TRTCMediaMixingManager {
102
94
  *
103
95
  * 如果用户应用有特殊配置,默认路径可能找不到服务进程程序,需要自行传入路径。
104
96
  *
105
- * @param path {string} - 设置服务进程程序路径
97
+ * @param path {string} - 服务进程程序路径
106
98
  *
107
99
  * @returns {Promise<void>}
108
100
  */
@@ -8,9 +8,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
11
14
  Object.defineProperty(exports, "__esModule", { value: true });
12
15
  exports.TRTCMediaMixingManager = exports.TRTCMediaSourceType = exports.TRTCMediaMixingEvent = void 0;
13
16
  const events_1 = require("events");
17
+ const logger_1 = __importDefault(require("../../logger"));
14
18
  const NodeTRTCEngine = require('../../../build/Release/trtc_electron_sdk.node');
15
19
  var TRTCMediaMixingEvent;
16
20
  (function (TRTCMediaMixingEvent) {
@@ -24,39 +28,26 @@ var TRTCMediaSourceType;
24
28
  TRTCMediaSourceType[TRTCMediaSourceType["kImage"] = 2] = "kImage";
25
29
  TRTCMediaSourceType[TRTCMediaSourceType["kRemoteVideo"] = 3] = "kRemoteVideo";
26
30
  })(TRTCMediaSourceType = exports.TRTCMediaSourceType || (exports.TRTCMediaSourceType = {}));
27
- const logger = console;
28
31
  /**
29
32
  * 本地混流管理器
30
33
  */
31
34
  class TRTCMediaMixingManager {
32
35
  constructor(options) {
33
36
  this.logPrefix = '[TRTCMediaMixingManager]';
34
- if (!TRTCMediaMixingManager.mediaMixingManager) {
35
- this.eventEmitter = new events_1.EventEmitter();
36
- this.eventHandler = this.eventHandler.bind(this);
37
- this.nodeMediaMixingPlugin = new NodeTRTCEngine.NodeRemoteMultiSourcePlugin();
38
- this.nodeMediaMixingPlugin.setRemoteMultiSourcePluginCallback(this.eventHandler);
39
- this.deviceManager = options.deviceManager;
40
- TRTCMediaMixingManager.mediaMixingManager = this;
41
- this.setMediaServerPath('');
42
- }
43
- else {
44
- return TRTCMediaMixingManager.mediaMixingManager;
45
- }
46
- }
47
- /**
48
- * 获取混流管理器
49
- *
50
- * @returns {TRTCMediaMixingManager}
51
- */
52
- static getInstance(options) {
53
- if (!TRTCMediaMixingManager.mediaMixingManager) {
54
- TRTCMediaMixingManager.mediaMixingManager = new TRTCMediaMixingManager(options);
55
- }
56
- return TRTCMediaMixingManager.mediaMixingManager;
37
+ this.eventEmitter = new events_1.EventEmitter();
38
+ this.eventHandler = this.eventHandler.bind(this);
39
+ this.nodeMediaMixingPlugin = new NodeTRTCEngine.NodeRemoteMultiSourcePlugin();
40
+ this.nodeMediaMixingPlugin.setRemoteMultiSourcePluginCallback(this.eventHandler);
41
+ this.deviceManager = options.deviceManager;
42
+ this.setMediaServerPath('');
43
+ }
44
+ destroy() {
45
+ this.deviceManager = null;
46
+ this.nodeMediaMixingPlugin = null;
47
+ this.eventEmitter = null;
57
48
  }
58
49
  eventHandler(args) {
59
- logger.log(`${this.logPrefix} event:`, args);
50
+ logger_1.default.log(`${this.logPrefix} event:`, args);
60
51
  // const key = args[0] as string;
61
52
  // const data = args[1] as { [key: string]: never };
62
53
  // To do: 待完善
@@ -154,7 +145,7 @@ class TRTCMediaMixingManager {
154
145
  *
155
146
  * 如果用户应用有特殊配置,默认路径可能找不到服务进程程序,需要自行传入路径。
156
147
  *
157
- * @param path {string} - 设置服务进程程序路径
148
+ * @param path {string} - 服务进程程序路径
158
149
  *
159
150
  * @returns {Promise<void>}
160
151
  */
@@ -173,7 +164,7 @@ class TRTCMediaMixingManager {
173
164
  serverPath = `${resourcesPath}\\liteav_media_server.exe`;
174
165
  }
175
166
  }
176
- logger.log(`${this.logPrefix} server path:${serverPath}`);
167
+ logger_1.default.log(`${this.logPrefix} server path:${serverPath}`);
177
168
  return yield this.nodeMediaMixingPlugin.setMediaServerPath(serverPath);
178
169
  });
179
170
  }
@@ -199,25 +190,32 @@ class TRTCMediaMixingManager {
199
190
  }
200
191
  // ****** 这一部分接口暴露不合理,暂时不对暴露在 API 文档上 **************/
201
192
  startCameraDeviceTest(windowID, rect) {
202
- return this.deviceManager.startCameraDeviceTest(windowID, rect);
193
+ var _a;
194
+ return ((_a = this.deviceManager) === null || _a === void 0 ? void 0 : _a.startCameraDeviceTest(windowID, rect)) || Promise.reject();
203
195
  }
204
196
  stopCameraDeviceTest() {
205
- return this.deviceManager.stopCameraDeviceTest();
197
+ var _a;
198
+ return ((_a = this.deviceManager) === null || _a === void 0 ? void 0 : _a.stopCameraDeviceTest()) || Promise.reject();
206
199
  }
207
200
  setCameraTestRenderMirror(mirror) {
208
- this.deviceManager.setCameraTestRenderMirror(mirror);
201
+ var _a;
202
+ (_a = this.deviceManager) === null || _a === void 0 ? void 0 : _a.setCameraTestRenderMirror(mirror);
209
203
  }
210
204
  setCameraTestDeviceId(cameraId) {
211
- this.deviceManager.setCameraTestDeviceId(cameraId);
205
+ var _a;
206
+ (_a = this.deviceManager) === null || _a === void 0 ? void 0 : _a.setCameraTestDeviceId(cameraId);
212
207
  }
213
208
  setCameraTestResolution(width, height) {
214
- this.deviceManager.setCameraTestResolution(width, height);
209
+ var _a;
210
+ (_a = this.deviceManager) === null || _a === void 0 ? void 0 : _a.setCameraTestResolution(width, height);
215
211
  }
216
212
  setCameraTestVideoPluginPath(path) {
217
- this.deviceManager.setCameraTestVideoPluginPath(path);
213
+ var _a;
214
+ (_a = this.deviceManager) === null || _a === void 0 ? void 0 : _a.setCameraTestVideoPluginPath(path);
218
215
  }
219
216
  setCameraTestVideoPluginParameter(params) {
220
- this.deviceManager.setCameraTestVideoPluginParameter(params);
217
+ var _a;
218
+ (_a = this.deviceManager) === null || _a === void 0 ? void 0 : _a.setCameraTestVideoPluginParameter(params);
221
219
  }
222
220
  }
223
221
  exports.TRTCMediaMixingManager = TRTCMediaMixingManager;
@@ -23,8 +23,7 @@ export declare class TRTCPlugin {
23
23
  */
24
24
  export declare class TRTCPluginManager {
25
25
  private logPrefix;
26
- private static pluginManager;
27
- private static isIPCMode;
26
+ private isIPCMode;
28
27
  private nodePluginManager;
29
28
  private videoProcessBufferType;
30
29
  private videoProcessPixelFormat;
@@ -32,15 +31,7 @@ export declare class TRTCPluginManager {
32
31
  isIPCMode: boolean;
33
32
  nodeTRTCCloud: typeof NodeTRTCEngine.TRTCCloud | typeof NodeTRTCEngine.RemoteTRTCCloud;
34
33
  });
35
- /**
36
- * 获取插件管理器
37
- *
38
- * @returns {TRTCPluginManager}
39
- */
40
- static getInstance(options: {
41
- isIPCMode: boolean;
42
- nodeTRTCCloud: typeof NodeTRTCEngine.TRTCCloud | typeof NodeTRTCEngine.RemoteTRTCCloud;
43
- }): TRTCPluginManager;
34
+ destroy(): void;
44
35
  setPluginParams(type: TRTCPluginType, options: TRTCVideoProcessPluginOptions | TRTCMediaEncryptDecryptPluginOptions | TRTCAudioProcessPluginOptions): void;
45
36
  private _setVideoProcessPluginParams;
46
37
  private _setMediaEncryptDecryptPluginParams;
@@ -1,9 +1,12 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.TRTCPluginManager = exports.TRTCPlugin = void 0;
4
7
  const trtc_define_1 = require("../../trtc_define");
8
+ const logger_1 = __importDefault(require("../../logger"));
5
9
  const NodeTRTCEngine = require('../../../build/Release/trtc_electron_sdk.node');
6
- const logger = console;
7
10
  /**
8
11
  * TRTC 插件
9
12
  */
@@ -21,7 +24,7 @@ class TRTCPlugin {
21
24
  return this.pluginId;
22
25
  }
23
26
  enable(flag = true) {
24
- logger.log(`${this.logPrefix}enable:${flag} ${this.pluginId}`);
27
+ logger_1.default.log(`${this.logPrefix}enable:${flag} ${this.pluginId}`);
25
28
  this.nativeVideoEffectPlugin.enable(flag);
26
29
  }
27
30
  /**
@@ -31,7 +34,7 @@ class TRTCPlugin {
31
34
  this.enable(false);
32
35
  }
33
36
  setParameter(param) {
34
- logger.log(`${this.logPrefix}setParameter:${this.pluginId}`);
37
+ logger_1.default.log(`${this.logPrefix}setParameter:${this.pluginId}`);
35
38
  this.nativeVideoEffectPlugin.setParameter(param);
36
39
  }
37
40
  }
@@ -44,42 +47,28 @@ class TRTCPluginManager {
44
47
  this.logPrefix = '[TRTCPluginManager]';
45
48
  this.videoProcessBufferType = trtc_define_1.TRTCVideoBufferType.TRTCVideoBufferType_Buffer;
46
49
  this.videoProcessPixelFormat = trtc_define_1.TRTCVideoPixelFormat.TRTCVideoPixelFormat_I420;
47
- if (!TRTCPluginManager.pluginManager) {
48
- TRTCPluginManager.isIPCMode = options.isIPCMode;
49
- if (TRTCPluginManager.isIPCMode) {
50
- this.nodePluginManager = new NodeTRTCEngine.NodeRemoteVideoPluginManager();
51
- }
52
- else {
53
- this.videoProcessBufferType = trtc_define_1.TRTCVideoBufferType.TRTCVideoBufferType_Buffer;
54
- this.videoProcessPixelFormat = trtc_define_1.TRTCVideoPixelFormat.TRTCVideoPixelFormat_I420;
55
- this.nodePluginManager = options.nodeTRTCCloud;
56
- }
57
- TRTCPluginManager.pluginManager = this;
50
+ this.isIPCMode = options.isIPCMode;
51
+ if (this.isIPCMode) {
52
+ this.nodePluginManager = new NodeTRTCEngine.NodeRemoteVideoPluginManager();
58
53
  }
59
54
  else {
60
- return TRTCPluginManager.pluginManager;
55
+ this.videoProcessBufferType = trtc_define_1.TRTCVideoBufferType.TRTCVideoBufferType_Buffer;
56
+ this.videoProcessPixelFormat = trtc_define_1.TRTCVideoPixelFormat.TRTCVideoPixelFormat_I420;
57
+ this.nodePluginManager = options.nodeTRTCCloud;
61
58
  }
62
59
  }
63
60
  ;
64
- /**
65
- * 获取插件管理器
66
- *
67
- * @returns {TRTCPluginManager}
68
- */
69
- static getInstance(options) {
70
- if (!TRTCPluginManager.pluginManager) {
71
- TRTCPluginManager.pluginManager = new TRTCPluginManager(options);
72
- }
73
- return TRTCPluginManager.pluginManager;
61
+ destroy() {
62
+ this.nodePluginManager = null;
74
63
  }
75
64
  setPluginParams(type, options) {
76
- logger.log(`${this.logPrefix}setPluginParams params:`, type, options);
77
- if (TRTCPluginManager.isIPCMode) {
65
+ logger_1.default.log(`${this.logPrefix}setPluginParams params:`, type, options);
66
+ if (this.isIPCMode) {
78
67
  if (type === trtc_define_1.TRTCPluginType.TRTCPluginTypeVideoProcess) {
79
68
  this.nodePluginManager.setVideoPluginFormat(trtc_define_1.TRTCVideoBufferType.TRTCVideoBufferType_Buffer, options.pixelFormat);
80
69
  }
81
70
  else {
82
- logger.log(`${this.logPrefix}setPluginParams not supported params:`, type, options);
71
+ logger_1.default.log(`${this.logPrefix}setPluginParams not supported params:`, type, options);
83
72
  }
84
73
  }
85
74
  else {
@@ -94,7 +83,7 @@ class TRTCPluginManager {
94
83
  this._setAudioProcessPluginParams(options);
95
84
  break;
96
85
  default:
97
- logger.log(`setPluginParams invalid type:${type}`);
86
+ logger_1.default.log(`setPluginParams invalid type:${type}`);
98
87
  break;
99
88
  }
100
89
  }
@@ -111,7 +100,7 @@ class TRTCPluginManager {
111
100
  this.videoProcessBufferType = trtc_define_1.TRTCVideoBufferType.TRTCVideoBufferType_Texture;
112
101
  break;
113
102
  default:
114
- logger.error(`${this.logPrefix}setPluginParams() unspported pixelFormat: ${options.pixelFormat}`);
103
+ logger_1.default.error(`${this.logPrefix}setPluginParams() unspported pixelFormat: ${options.pixelFormat}`);
115
104
  return;
116
105
  }
117
106
  this.videoProcessPixelFormat = options.pixelFormat;
@@ -131,8 +120,8 @@ class TRTCPluginManager {
131
120
  }
132
121
  }
133
122
  addPlugin(options) {
134
- logger.log(`${this.logPrefix}addPlugin options:`, options);
135
- if (TRTCPluginManager.isIPCMode) {
123
+ logger_1.default.log(`${this.logPrefix}addPlugin options:`, options);
124
+ if (this.isIPCMode) {
136
125
  const nativeVideoEffectPlugin = this.nodePluginManager.addVideoPlugin(options.deviceId, options.id, options.path);
137
126
  return new TRTCPlugin(options.id, options.deviceId || '', nativeVideoEffectPlugin);
138
127
  }
@@ -159,8 +148,8 @@ class TRTCPluginManager {
159
148
  };
160
149
  }
161
150
  removePlugin(pluginId, deviceId) {
162
- logger.log(`${this.logPrefix}removePlugin pluginId:${pluginId} deviceId:${deviceId}`);
163
- if (TRTCPluginManager.isIPCMode) {
151
+ logger_1.default.log(`${this.logPrefix}removePlugin pluginId:${pluginId} deviceId:${deviceId}`);
152
+ if (this.isIPCMode) {
164
153
  this.nodePluginManager.removeVideoPlugin(deviceId, pluginId);
165
154
  }
166
155
  else {
@@ -168,7 +157,7 @@ class TRTCPluginManager {
168
157
  }
169
158
  }
170
159
  setCallback(callback) {
171
- if (TRTCPluginManager.isIPCMode) {
160
+ if (this.isIPCMode) {
172
161
  this.nodePluginManager.setCallback(callback);
173
162
  }
174
163
  else {
@@ -179,9 +168,9 @@ class TRTCPluginManager {
179
168
  * @deprecated
180
169
  */
181
170
  getPluginList() {
182
- logger.log(`${this.logPrefix}getPluginList`);
183
- if (TRTCPluginManager.isIPCMode) {
184
- logger.warn(`${this.logPrefix}getPluginList not supported`);
171
+ logger_1.default.log(`${this.logPrefix}getPluginList`);
172
+ if (this.isIPCMode) {
173
+ logger_1.default.warn(`${this.logPrefix}getPluginList not supported`);
185
174
  return null;
186
175
  }
187
176
  else {