agora-rte-sdk 3.10.0-alpha → 3.10.0-beta

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.
Files changed (30) hide show
  1. package/lib/plugin/monitor/index.js +4 -2
  2. package/lib/plugin/restful-client/index.js +19 -6
  3. package/lib/plugin/rtc/electron/canvas-tag-pool.js +2 -2
  4. package/lib/plugin/rtc/electron/client.js +11 -5
  5. package/lib/plugin/rtc/electron/publisher.js +9 -1
  6. package/lib/plugin/rtc/electron/source-manager.js +6 -0
  7. package/lib/plugin/rtc/electron/utils.js +6 -6
  8. package/lib/plugin/rtc/web/assembler.d.ts +3 -0
  9. package/lib/plugin/rtc/web/assembler.js +83 -32
  10. package/lib/plugin/rtc/web/device.js +17 -1
  11. package/lib/plugin/rtc/web/effect-enabler.js +10 -2
  12. package/lib/plugin/rtc/web/publish.js +14 -7
  13. package/lib/plugin/rtc/web/publisher.js +11 -10
  14. package/lib/plugin/rtc/web/track-control/microphone.d.ts +4 -2
  15. package/lib/plugin/rtc/web/track-control/microphone.js +16 -2
  16. package/lib/plugin/rtc/web/type.d.ts +2 -1
  17. package/lib-es/plugin/monitor/index.js +4 -2
  18. package/lib-es/plugin/restful-client/index.js +19 -6
  19. package/lib-es/plugin/rtc/electron/canvas-tag-pool.js +2 -2
  20. package/lib-es/plugin/rtc/electron/client.js +11 -5
  21. package/lib-es/plugin/rtc/electron/publisher.js +9 -1
  22. package/lib-es/plugin/rtc/electron/source-manager.js +6 -0
  23. package/lib-es/plugin/rtc/electron/utils.js +6 -6
  24. package/lib-es/plugin/rtc/web/assembler.js +83 -32
  25. package/lib-es/plugin/rtc/web/device.js +17 -1
  26. package/lib-es/plugin/rtc/web/effect-enabler.js +10 -2
  27. package/lib-es/plugin/rtc/web/publish.js +14 -7
  28. package/lib-es/plugin/rtc/web/publisher.js +11 -10
  29. package/lib-es/plugin/rtc/web/track-control/microphone.js +17 -3
  30. package/package.json +3 -3
@@ -116,7 +116,7 @@ var AgoraRteMonitorImpl = exports.AgoraRteMonitorImpl = /*#__PURE__*/function ()
116
116
  while (1) switch (_context3.prev = _context3.next) {
117
117
  case 0:
118
118
  return _context3.abrupt("return", this._mutex.dispatch(/*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2() {
119
- var taskId, logManager, consoleLogs, path, logBasePath, filePattern, dirPattern, logs, _t;
119
+ var taskId, logManager, consoleLogs, path, logBasePath, filePattern, dirPattern, fileExtensionPattern, logs, _t;
120
120
  return _regenerator["default"].wrap(function (_context2) {
121
121
  while (1) switch (_context2.prev = _context2.next) {
122
122
  case 0:
@@ -149,12 +149,14 @@ var AgoraRteMonitorImpl = exports.AgoraRteMonitorImpl = /*#__PURE__*/function ()
149
149
  path = window.require('path');
150
150
  logBasePath = path.resolve(window.require('@electron/remote').app.getPath('logs'), 'logs'); // 文件名匹配:以 "agora-main"、"agora-cpp" 开头的文件
151
151
  filePattern = /^(agora-main|agora-cpp)/; // 目录名匹配:以 "agora-"、"fcr-" 或 "http-" 开头的目录
152
- dirPattern = /^(agora-|fcr-|http)/;
152
+ dirPattern = /^(agora-|fcr-|http)/; // 文件扩展名匹配:.log 结尾的文件
153
+ fileExtensionPattern = /\.log$/;
153
154
  _context2.next = 4;
154
155
  return (0, _imports.zipDir)(logBasePath, {
155
156
  recursive: true,
156
157
  filePattern: filePattern,
157
158
  dirPattern: dirPattern,
159
+ fileExtensionPattern: fileExtensionPattern,
158
160
  clean: true // 上传前清理不符合规则的旧文件/目录
159
161
  });
160
162
  case 4:
@@ -112,7 +112,7 @@ var AgoraRestfulClientImpl = exports.AgoraRestfulClientImpl = /*#__PURE__*/funct
112
112
  value: function () {
113
113
  var _sendRequest2 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2(params) {
114
114
  var _resp$status, _resp, _resp$statusText, _resp2;
115
- var method, data, path, _params$query, query, _params$headers, headers, opts, resp, traceId, url, error, httpStatus, httpStatusText, respJson, code, msg, errMsg, _t, _t2;
115
+ var method, data, path, _params$query, query, _params$headers, headers, opts, resp, traceId, url, error, httpStatus, httpStatusText, respJson, code, msg, errMsg, jsonError, isClienUnauthorized, isInternalServerError, isClientError, isServerError, _t, _t2;
116
116
  return _regenerator["default"].wrap(function (_context2) {
117
117
  while (1) switch (_context2.prev = _context2.next) {
118
118
  case 0:
@@ -186,22 +186,35 @@ var AgoraRestfulClientImpl = exports.AgoraRestfulClientImpl = /*#__PURE__*/funct
186
186
  origin: _t2
187
187
  });
188
188
  case 10:
189
- if (!((httpStatus === 401 || httpStatus === 429) && code === -1 || httpStatus >= 500)) {
189
+ jsonError = code === -1;
190
+ isClienUnauthorized = (httpStatus === 401 || httpStatus === 429) && jsonError;
191
+ isInternalServerError = httpStatus >= 500;
192
+ if (!(isClienUnauthorized || isInternalServerError)) {
193
+ _context2.next = 12;
194
+ break;
195
+ }
196
+ if (!jsonError) {
190
197
  _context2.next = 11;
191
198
  break;
192
199
  }
193
200
  throw new _client.AgoraRestfulClientError(httpStatus, resp.statusText);
194
201
  case 11:
195
- if (!(httpStatus >= 400 && httpStatus < 500 || code !== 0)) {
196
- _context2.next = 12;
202
+ throw new _client.AgoraRestfulClientError(httpStatus, msg, {
203
+ serviceCode: code
204
+ });
205
+ case 12:
206
+ isClientError = httpStatus >= 400 && httpStatus < 500;
207
+ isServerError = code !== 0;
208
+ if (!(isClientError || isServerError)) {
209
+ _context2.next = 13;
197
210
  break;
198
211
  }
199
212
  throw new _client.AgoraRestfulClientError(httpStatus, msg, {
200
213
  serviceCode: code
201
214
  });
202
- case 12:
203
- return _context2.abrupt("return", respJson);
204
215
  case 13:
216
+ return _context2.abrupt("return", respJson);
217
+ case 14:
205
218
  case "end":
206
219
  return _context2.stop();
207
220
  }
@@ -255,7 +255,7 @@ var AgoraRtcCanvasTagPoolImpl = exports.AgoraRtcCanvasTagPoolImpl = /*#__PURE__*
255
255
  view: canvasTag.canvas.view,
256
256
  sourceType: sourceIndex === -1 ? undefined : sourceType,
257
257
  setupMode: _constants.RENDER_CONSTANTS.SETUP_MODES.REMOVE,
258
- position: 1
258
+ position: 1 << 0 | 1 << 1
259
259
  };
260
260
  this._decrementRenderCount(this._rtcEngine);
261
261
  this._rtcEngine.setupLocalVideo(canvas);
@@ -303,7 +303,7 @@ var AgoraRtcCanvasTagPoolImpl = exports.AgoraRtcCanvasTagPoolImpl = /*#__PURE__*
303
303
  view: null,
304
304
  sourceType: sourceType,
305
305
  setupMode: _constants.RENDER_CONSTANTS.SETUP_MODES.REPLACE,
306
- position: 1
306
+ position: 1 << 0 | 1 << 1
307
307
  };
308
308
  this._rtcEngine.setupLocalVideo(canvas);
309
309
  this._logRenderInfo(this._rtcEngine, 'setupLocalVideo', _constants.RENDER_CONSTANTS.SETUP_MODES.REPLACE);
@@ -515,7 +515,9 @@ var AgoraRtcClientImpl = exports.AgoraRtcClientImpl = /*#__PURE__*/function (_Ag
515
515
  return Promise.resolve({
516
516
  deviceId: device.deviceId || '',
517
517
  deviceName: device.deviceName || '',
518
+ // @ts-ignore Linux 的版本上目前不存在 vendorId
518
519
  vendorId: device.vendorId || '',
520
+ // @ts-ignore Linux 的版本上目前不存在 productId
519
521
  productId: device.productId || ''
520
522
  });
521
523
  }
@@ -532,7 +534,9 @@ var AgoraRtcClientImpl = exports.AgoraRtcClientImpl = /*#__PURE__*/function (_Ag
532
534
  return {
533
535
  deviceId: deviceId || '',
534
536
  deviceName: (device === null || device === void 0 ? void 0 : device.deviceName) || '',
537
+ // @ts-ignore Linux 的版本上目前不存在 vendorId
535
538
  vendorId: (device === null || device === void 0 ? void 0 : device.vendorId) || '',
539
+ // @ts-ignore Linux 的版本上目前不存在 productId
536
540
  productId: (device === null || device === void 0 ? void 0 : device.productId) || ''
537
541
  };
538
542
  }
@@ -974,9 +978,9 @@ var AgoraRtcClientImpl = exports.AgoraRtcClientImpl = /*#__PURE__*/function (_Ag
974
978
  if (_this4._isValidDevice(device)) {
975
979
  _this4._speakerList.set(device.deviceId, {
976
980
  deviceId: device.deviceId,
977
- deviceName: device.deviceName,
978
- vendorId: device.vendorId,
979
- productId: device.productId
981
+ deviceName: device.deviceName
982
+ // vendorId: device.vendorId,
983
+ // productId: device.productId,
980
984
  });
981
985
  }
982
986
  });
@@ -1220,8 +1224,8 @@ var AgoraRtcClientImpl = exports.AgoraRtcClientImpl = /*#__PURE__*/function (_Ag
1220
1224
  case 1:
1221
1225
  newDevice = audioPlaybackDevices.find(function (device) {
1222
1226
  return _this5._isValidDevice(device) && device.deviceId === deviceId;
1223
- });
1224
- deviceInfoString = "deviceName\uFF1A".concat(newDevice === null || newDevice === void 0 ? void 0 : newDevice.deviceName, " deviceId: ").concat(newDevice === null || newDevice === void 0 ? void 0 : newDevice.deviceId, ", vendorId: ").concat(newDevice === null || newDevice === void 0 ? void 0 : newDevice.vendorId, ", productId: ").concat(newDevice === null || newDevice === void 0 ? void 0 : newDevice.productId);
1227
+ }); // @ts-ignore Linux 的版本上目前不存在 vendorId 和 productId
1228
+ deviceInfoString = "deviceName\uFF1A".concat(newDevice === null || newDevice === void 0 ? void 0 : newDevice.deviceName, " deviceId: ").concat(newDevice === null || newDevice === void 0 ? void 0 : newDevice.deviceId, ",vendorId: ").concat(newDevice === null || newDevice === void 0 ? void 0 : newDevice.vendorId, ", productId: ").concat(newDevice === null || newDevice === void 0 ? void 0 : newDevice.productId);
1225
1229
  this.logger.info("PlaybackDevices deviceInfoString: ".concat(deviceInfoString));
1226
1230
  if (!(newDevice && newDevice.deviceId && newDevice.deviceName)) {
1227
1231
  _context5.next = 2;
@@ -1230,7 +1234,9 @@ var AgoraRtcClientImpl = exports.AgoraRtcClientImpl = /*#__PURE__*/function (_Ag
1230
1234
  return _context5.abrupt("return", {
1231
1235
  deviceId: newDevice.deviceId,
1232
1236
  deviceName: newDevice.deviceName,
1237
+ // @ts-ignore Linux 的版本上目前不存在 vendorId
1233
1238
  vendorId: newDevice.vendorId,
1239
+ // @ts-ignore Linux 的版本上目前不存在 productId
1234
1240
  productId: newDevice.productId
1235
1241
  });
1236
1242
  case 2:
@@ -325,7 +325,15 @@ var AgoraRtcChannelPublisherImpl = exports.AgoraRtcChannelPublisherImpl = /*#__P
325
325
 
326
326
  // 启用双流模式
327
327
  var targetStreamConfig = this._getVideoStreamConfig(streamId, true);
328
- return this._rtcEngine.setDualStreamModeEx(1, _objectSpread({}, targetStreamConfig.lowVideoEncoderConfig), connection);
328
+ var _targetStreamConfig$l = targetStreamConfig.lowVideoEncoderConfig,
329
+ dimensions = _targetStreamConfig$l.dimensions,
330
+ bitrate = _targetStreamConfig$l.bitrate,
331
+ frameRate = _targetStreamConfig$l.frameRate;
332
+ return this._rtcEngine.setDualStreamModeEx(1, {
333
+ dimensions: dimensions,
334
+ kBitrate: bitrate,
335
+ framerate: frameRate
336
+ }, connection);
329
337
  }
330
338
  }, {
331
339
  key: "setScreenScenario",
@@ -853,7 +853,9 @@ var AgoraRtcSourceManagerImpl = exports.AgoraRtcSourceManagerImpl = /*#__PURE__*
853
853
  var deviceInfo = {
854
854
  deviceId: device.deviceId,
855
855
  deviceName: device.deviceName,
856
+ // @ts-ignore Linux 的版本上目前不存在 vendorId 和 productId
856
857
  vendorId: device.vendorId,
858
+ // @ts-ignore Linux 的版本上目前不存在 productId
857
859
  productId: device.productId
858
860
  };
859
861
  microphoneList.set(device.deviceId, deviceInfo);
@@ -931,7 +933,9 @@ var AgoraRtcSourceManagerImpl = exports.AgoraRtcSourceManagerImpl = /*#__PURE__*
931
933
  deviceInfo = {
932
934
  deviceId: device.deviceId,
933
935
  deviceName: device.deviceName,
936
+ // @ts-ignore Linux 的版本上目前不存在 vendorId 和 productId
934
937
  vendorId: device.vendorId,
938
+ // @ts-ignore Linux 的版本上目前不存在 productId
935
939
  productId: device.productId
936
940
  };
937
941
  }
@@ -1212,7 +1216,9 @@ var AgoraRtcSourceManagerImpl = exports.AgoraRtcSourceManagerImpl = /*#__PURE__*
1212
1216
  var deviceInfo = {
1213
1217
  deviceId: device.deviceId,
1214
1218
  deviceName: device.deviceName,
1219
+ // @ts-ignore Linux 的版本上目前不存在 vendorId 和 productId
1215
1220
  vendorId: device.vendorId,
1221
+ // @ts-ignore Linux 的版本上目前不存在 productId
1216
1222
  productId: device.productId
1217
1223
  };
1218
1224
  newMicList.set(device.deviceId, deviceInfo);
@@ -194,7 +194,7 @@ var performLocalVideoSetup = function performLocalVideoSetup(rtcEngine, placemen
194
194
  sourceType: sourceType,
195
195
  renderMode: renderModeType,
196
196
  mirrorMode: mirrorModeType,
197
- position: 1
197
+ position: 1 << 0 | 1 << 1
198
198
  });
199
199
  };
200
200
 
@@ -393,7 +393,7 @@ var startVideoRender = exports.startVideoRender = function startVideoRender(_ref
393
393
  sourceType: vst,
394
394
  renderMode: renderModeType,
395
395
  mirrorMode: mirrorModeType,
396
- position: 1
396
+ position: 1 << 0 | 1 << 1
397
397
  });
398
398
  }
399
399
  }
@@ -437,10 +437,10 @@ var setHighStreamEncoderConfig = function setHighStreamEncoderConfig(config, rtc
437
437
  frameRate: frameRate,
438
438
  minBitrate: 0,
439
439
  orientationMode: 0,
440
- degradationPreference: degradationPreference ? convertDegradationPreference(degradationPreference) : DEGRADATION_PREFERENCE_MAP[_type.AgoraRtcDegradationPreference.BALANCED],
441
- advanceOptions: {
442
- encodingPreference: encodingPreference
443
- }
440
+ degradationPreference: degradationPreference ? convertDegradationPreference(degradationPreference) : DEGRADATION_PREFERENCE_MAP[_type.AgoraRtcDegradationPreference.BALANCED]
441
+ // advanceOptions: {
442
+ // encodingPreference,
443
+ // },
444
444
  };
445
445
  var streamId = rtcConnection.localUid.toString();
446
446
  logger.info("[setVideoEncoderConfigurationEx]: stream type is HIGH_STREAM, call setVideoEncoderConfigurationEx: ".concat(JSON.stringify(params), ", streamId: ").concat(streamId));
@@ -4,10 +4,13 @@ export declare class AgoraRtcPreProcessorAssembler {
4
4
  protected logger: import("agora-foundation/lib/logger").Logger;
5
5
  private _processors;
6
6
  private _track?;
7
+ private _pipedProcessorsMap;
7
8
  get processors(): IBaseProcessor[];
8
9
  release(): number;
9
10
  addProcessors(processors: IBaseProcessor[]): void;
10
11
  removeProcessor(name: string): void;
12
+ removeAllProcessors(): void;
11
13
  setTrack(track?: ILocalVideoTrack | ILocalAudioTrack): void;
12
14
  private _assemble;
15
+ private _unpipeAll;
13
16
  }
@@ -6,32 +6,14 @@ require("core-js/modules/es.symbol.to-primitive.js");
6
6
  require("core-js/modules/es.error.cause.js");
7
7
  require("core-js/modules/es.error.to-string.js");
8
8
  require("core-js/modules/es.array.is-array.js");
9
- require("core-js/modules/es.array.iterator.js");
10
9
  require("core-js/modules/es.date.to-primitive.js");
11
10
  require("core-js/modules/es.function.bind.js");
12
- require("core-js/modules/es.map.js");
13
11
  require("core-js/modules/es.number.constructor.js");
14
12
  require("core-js/modules/es.object.create.js");
15
13
  require("core-js/modules/es.object.define-property.js");
16
14
  require("core-js/modules/es.object.get-own-property-descriptor.js");
17
- require("core-js/modules/es.string.iterator.js");
18
15
  require("core-js/modules/esnext.function.metadata.js");
19
- require("core-js/modules/esnext.map.delete-all.js");
20
- require("core-js/modules/esnext.map.emplace.js");
21
- require("core-js/modules/esnext.map.every.js");
22
- require("core-js/modules/esnext.map.filter.js");
23
- require("core-js/modules/esnext.map.find.js");
24
- require("core-js/modules/esnext.map.find-key.js");
25
- require("core-js/modules/esnext.map.includes.js");
26
- require("core-js/modules/esnext.map.key-of.js");
27
- require("core-js/modules/esnext.map.map-keys.js");
28
- require("core-js/modules/esnext.map.map-values.js");
29
- require("core-js/modules/esnext.map.merge.js");
30
- require("core-js/modules/esnext.map.reduce.js");
31
- require("core-js/modules/esnext.map.some.js");
32
- require("core-js/modules/esnext.map.update.js");
33
16
  require("core-js/modules/esnext.symbol.metadata.js");
34
- require("core-js/modules/web.dom-collections.iterator.js");
35
17
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
36
18
  var _typeof = require("@babel/runtime/helpers/typeof");
37
19
  Object.defineProperty(exports, "__esModule", {
@@ -39,13 +21,36 @@ Object.defineProperty(exports, "__esModule", {
39
21
  });
40
22
  exports.AgoraRtcPreProcessorAssembler = void 0;
41
23
  require("core-js/modules/es.array.filter.js");
24
+ require("core-js/modules/es.array.for-each.js");
25
+ require("core-js/modules/es.array.iterator.js");
42
26
  require("core-js/modules/es.array.push.js");
43
27
  require("core-js/modules/es.array.reduce.js");
28
+ require("core-js/modules/es.array.reverse.js");
29
+ require("core-js/modules/es.array.slice.js");
44
30
  require("core-js/modules/es.function.name.js");
31
+ require("core-js/modules/es.map.js");
45
32
  require("core-js/modules/es.object.to-string.js");
33
+ require("core-js/modules/es.string.iterator.js");
46
34
  require("core-js/modules/esnext.iterator.constructor.js");
47
35
  require("core-js/modules/esnext.iterator.filter.js");
36
+ require("core-js/modules/esnext.iterator.for-each.js");
48
37
  require("core-js/modules/esnext.iterator.reduce.js");
38
+ require("core-js/modules/esnext.map.delete-all.js");
39
+ require("core-js/modules/esnext.map.emplace.js");
40
+ require("core-js/modules/esnext.map.every.js");
41
+ require("core-js/modules/esnext.map.filter.js");
42
+ require("core-js/modules/esnext.map.find.js");
43
+ require("core-js/modules/esnext.map.find-key.js");
44
+ require("core-js/modules/esnext.map.includes.js");
45
+ require("core-js/modules/esnext.map.key-of.js");
46
+ require("core-js/modules/esnext.map.map-keys.js");
47
+ require("core-js/modules/esnext.map.map-values.js");
48
+ require("core-js/modules/esnext.map.merge.js");
49
+ require("core-js/modules/esnext.map.reduce.js");
50
+ require("core-js/modules/esnext.map.some.js");
51
+ require("core-js/modules/esnext.map.update.js");
52
+ require("core-js/modules/web.dom-collections.for-each.js");
53
+ require("core-js/modules/web.dom-collections.iterator.js");
49
54
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
50
55
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
51
56
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
@@ -68,6 +73,7 @@ var AgoraRtcPreProcessorAssembler = exports.AgoraRtcPreProcessorAssembler = /*#_
68
73
  prefix: 'AgoraRtcPreProcessorAssembler'
69
74
  })));
70
75
  (0, _defineProperty2["default"])(this, "_processors", []);
76
+ (0, _defineProperty2["default"])(this, "_pipedProcessorsMap", new Map());
71
77
  }
72
78
  return (0, _createClass2["default"])(AgoraRtcPreProcessorAssembler, [{
73
79
  key: "processors",
@@ -77,6 +83,9 @@ var AgoraRtcPreProcessorAssembler = exports.AgoraRtcPreProcessorAssembler = /*#_
77
83
  }, {
78
84
  key: "release",
79
85
  value: function release() {
86
+ this._unpipeAll();
87
+ this._processors = [];
88
+ this._track = undefined;
80
89
  return _constant.AgoraRtcErrorCode.SUCCESS;
81
90
  }
82
91
  }, {
@@ -84,6 +93,9 @@ var AgoraRtcPreProcessorAssembler = exports.AgoraRtcPreProcessorAssembler = /*#_
84
93
  value: function addProcessors(processors) {
85
94
  var _this$_processors;
86
95
  (_this$_processors = this._processors).push.apply(_this$_processors, (0, _toConsumableArray2["default"])(processors));
96
+ if (this._track) {
97
+ this._unpipeAll();
98
+ }
87
99
  this._assemble();
88
100
  }
89
101
  }, {
@@ -96,31 +108,70 @@ var AgoraRtcPreProcessorAssembler = exports.AgoraRtcPreProcessorAssembler = /*#_
96
108
  return p.name !== name;
97
109
  });
98
110
  }
111
+ }, {
112
+ key: "removeAllProcessors",
113
+ value: function removeAllProcessors() {
114
+ if (this._track) {
115
+ this._unpipeAll();
116
+ }
117
+ this._processors = [];
118
+ this._track = undefined;
119
+ }
99
120
  }, {
100
121
  key: "setTrack",
101
122
  value: function setTrack(track) {
102
- // need re-assemble
103
- // if (this._track) {
104
- // return;
105
- // }
106
-
123
+ if (this._track) {
124
+ this._unpipeAll();
125
+ }
107
126
  this._track = track;
108
127
  this._assemble();
109
128
  }
110
129
  }, {
111
130
  key: "_assemble",
112
131
  value: function _assemble() {
113
- var track = this._track;
114
- if (track) {
115
- track.unpipe();
116
- if (this._processors.length > 0) {
117
- var processorNode = this._processors.reduce(function (prev, cur) {
118
- return prev.pipe(cur);
119
- }, track);
120
- if (processorNode) {
121
- processorNode.pipe(track.processorDestination);
132
+ try {
133
+ var track = this._track;
134
+ if (track) {
135
+ // this._unpipeAll();
136
+
137
+ if (this._processors.length > 0) {
138
+ var pipedProcessors = [];
139
+ var processorNode = this._processors.reduce(function (prev, cur) {
140
+ var pipedProcessor = prev.pipe(cur);
141
+ pipedProcessors.push(cur);
142
+ return pipedProcessor;
143
+ }, track);
144
+ if (processorNode) {
145
+ processorNode.pipe(track.processorDestination);
146
+ }
147
+ this._pipedProcessorsMap.set(track, pipedProcessors);
122
148
  }
123
149
  }
150
+ } catch (e) {
151
+ this.logger.error('Assemble processors failed', e);
152
+ }
153
+ }
154
+ }, {
155
+ key: "_unpipeAll",
156
+ value: function _unpipeAll() {
157
+ var _this = this;
158
+ if (this._track) {
159
+ var pipedProcessors = this._pipedProcessorsMap.get(this._track);
160
+ if (pipedProcessors) {
161
+ pipedProcessors.slice().reverse().forEach(function (p) {
162
+ try {
163
+ p.unpipe();
164
+ } catch (e) {
165
+ _this.logger.error('Unpipe processor failed', e);
166
+ }
167
+ });
168
+ this._pipedProcessorsMap["delete"](this._track);
169
+ }
170
+ try {
171
+ this._track.unpipe();
172
+ } catch (e) {
173
+ this.logger.error('Unpipe track failed', e);
174
+ }
124
175
  }
125
176
  }
126
177
  }]);
@@ -272,6 +272,7 @@ var AgoraRtcDeviceManager = exports.AgoraRtcDeviceManager = /*#__PURE__*/functio
272
272
  }, {
273
273
  key: "enableAiDenoiser",
274
274
  value: function enableAiDenoiser(deviceId) {
275
+ this._effectManager.aiDenoiseLevel = _type.AgoraRtcAiDenoiseLevel.HIGH;
275
276
  var control = this._getMicrophoneControl(deviceId);
276
277
  control.audioDeviceContext.aiDenoiserEnabler.enable();
277
278
  return 0;
@@ -279,6 +280,7 @@ var AgoraRtcDeviceManager = exports.AgoraRtcDeviceManager = /*#__PURE__*/functio
279
280
  }, {
280
281
  key: "disableAiDenoiser",
281
282
  value: function disableAiDenoiser(deviceId) {
283
+ this._effectManager.aiDenoiseLevel = _type.AgoraRtcAiDenoiseLevel.NONE;
282
284
  var control = this._getMicrophoneControl(deviceId);
283
285
  control.audioDeviceContext.aiDenoiserEnabler.disable();
284
286
  return 0;
@@ -286,21 +288,27 @@ var AgoraRtcDeviceManager = exports.AgoraRtcDeviceManager = /*#__PURE__*/functio
286
288
  }, {
287
289
  key: "setAiDenoiseLevel",
288
290
  value: function setAiDenoiseLevel(deviceId, level) {
291
+ this._effectManager.aiDenoiseLevel = level;
289
292
  var control = this._getMicrophoneControl(deviceId);
290
293
  switch (level) {
291
294
  case _type.AgoraRtcAiDenoiseLevel.HIGH:
295
+ control.audioDeviceContext.aiDenoiserEnabler.enable();
292
296
  control.audioDeviceContext.aiDenoiserEnabler.setMode(_agoraExtensionAiDenoiser.AIDenoiserProcessorMode.NSNG);
293
297
  control.audioDeviceContext.aiDenoiserEnabler.setLevel(_agoraExtensionAiDenoiser.AIDenoiserProcessorLevel.AGGRESSIVE);
294
298
  break;
295
299
  case _type.AgoraRtcAiDenoiseLevel.MEDIUM:
300
+ control.audioDeviceContext.aiDenoiserEnabler.enable();
296
301
  control.audioDeviceContext.aiDenoiserEnabler.setMode(_agoraExtensionAiDenoiser.AIDenoiserProcessorMode.NSNG);
297
302
  control.audioDeviceContext.aiDenoiserEnabler.setLevel(_agoraExtensionAiDenoiser.AIDenoiserProcessorLevel.SOFT);
298
303
  break;
299
304
  case _type.AgoraRtcAiDenoiseLevel.LOW:
305
+ control.audioDeviceContext.aiDenoiserEnabler.enable();
300
306
  control.audioDeviceContext.aiDenoiserEnabler.setMode(_agoraExtensionAiDenoiser.AIDenoiserProcessorMode.STATIONARY_NS);
301
307
  control.audioDeviceContext.aiDenoiserEnabler.setLevel(_agoraExtensionAiDenoiser.AIDenoiserProcessorLevel.SOFT);
302
308
  break;
303
309
  case _type.AgoraRtcAiDenoiseLevel.NONE:
310
+ control.audioDeviceContext.aiDenoiserEnabler.disable();
311
+ break;
304
312
  default:
305
313
  break;
306
314
  }
@@ -646,7 +654,7 @@ var AgoraRtcDeviceManager = exports.AgoraRtcDeviceManager = /*#__PURE__*/functio
646
654
  value: function _getMicrophoneControl(deviceId) {
647
655
  var controls = this._microphoneControls;
648
656
  if (!controls.has(deviceId)) {
649
- controls.set(deviceId, new _microphone.AgoraRtcMicrophoneControl(deviceId, this, this._extensionDelegate, this._keepAudioRecording));
657
+ controls.set(deviceId, new _microphone.AgoraRtcMicrophoneControl(deviceId, this, this._extensionDelegate, this._keepAudioRecording, this._effectManager));
650
658
  }
651
659
  return controls.get(deviceId);
652
660
  }
@@ -904,5 +912,13 @@ var AgoraEffectManager = /*#__PURE__*/function () {
904
912
  set: function set(options) {
905
913
  this._virtualBackgroundOptions = options;
906
914
  }
915
+ }, {
916
+ key: "aiDenoiseLevel",
917
+ get: function get() {
918
+ return this._aiDenoiseLevel;
919
+ },
920
+ set: function set(level) {
921
+ this._aiDenoiseLevel = level;
922
+ }
907
923
  }]);
908
924
  }();
@@ -218,7 +218,11 @@ var AgoraRtcAiDenoiserEnabler = exports.AgoraRtcAiDenoiserEnabler = /*#__PURE__*
218
218
  value: function setLevel(level) {
219
219
  var preprocessorInst = this.findProcessor();
220
220
  if (preprocessorInst) {
221
- preprocessorInst.setLevel(level);
221
+ try {
222
+ preprocessorInst.setLevel(level);
223
+ } catch (e) {
224
+ this.logger.error('set ai denoiser level error', e);
225
+ }
222
226
  } else {
223
227
  this.logger.info('ai denoiser preprocessor not found');
224
228
  }
@@ -228,7 +232,11 @@ var AgoraRtcAiDenoiserEnabler = exports.AgoraRtcAiDenoiserEnabler = /*#__PURE__*
228
232
  value: function setMode(mode) {
229
233
  var preprocessorInst = this.findProcessor();
230
234
  if (preprocessorInst) {
231
- preprocessorInst.setMode(mode);
235
+ try {
236
+ preprocessorInst.setMode(mode);
237
+ } catch (e) {
238
+ this.logger.error('set ai denoiser mode error', e);
239
+ }
232
240
  } else {
233
241
  this.logger.info('ai denoiser preprocessor not found');
234
242
  }
@@ -100,7 +100,7 @@ var _misc = require("agora-foundation/lib/utilities/misc");
100
100
  var _constant = require("../../../constant");
101
101
  var _raceCondition = require("agora-foundation/lib/utilities/race-condition");
102
102
  var _AgoraRtcPublishManager;
103
- var _initProto, _publishVideoDecs, _unpublishVideoDecs, _publishAudioDecs, _unpublishAudioDecs, _setVideoEncoderConfigDecs, _setLowStreamParameterDecs, _ref;
103
+ var _initProto, _onLocalVideoTrackCreatedDecs, _onLocalVideoTrackBeforeDestroyDecs, _onLocalAudioTrackCreatedDecs, _onLocalAudioTrackBeforeDestroyDecs, _onVideoDeviceStateFlagUpdatedDecs, _onAudioDeviceStateFlagUpdatedDecs, _setDualStreamModeDecs, _publishVideoDecs, _unpublishVideoDecs, _publishAudioDecs, _unpublishAudioDecs, _setVideoEncoderConfigDecs, _setLowStreamParameterDecs, _ref;
104
104
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
105
105
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
106
106
  function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
@@ -111,7 +111,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
111
111
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
112
112
  function _setFunctionName(e, t, n) { "symbol" == _typeof(t) && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
113
113
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? _typeof(e) : "null")); return e; }
114
- _ref = (_publishVideoDecs = (0, _decorator.trace)(['streamId', 'sourceId']), _unpublishVideoDecs = (0, _decorator.trace)(['streamId']), _publishAudioDecs = (0, _decorator.trace)(['streamId', 'sourceId']), _unpublishAudioDecs = (0, _decorator.trace)(['streamId']), _setVideoEncoderConfigDecs = (0, _decorator.trace)(['streamId', 'config']), _setLowStreamParameterDecs = (0, _decorator.trace)(['config']), "logger");
114
+ _ref = (_onLocalVideoTrackCreatedDecs = (0, _decorator.trace)(['sourceId', 'localTrack']), _onLocalVideoTrackBeforeDestroyDecs = (0, _decorator.trace)(['sourceId', 'localTrack']), _onLocalAudioTrackCreatedDecs = (0, _decorator.trace)(['sourceId', 'localTrack']), _onLocalAudioTrackBeforeDestroyDecs = (0, _decorator.trace)(['sourceId', 'localTrack']), _onVideoDeviceStateFlagUpdatedDecs = (0, _decorator.trace)(['deviceId', 'flag']), _onAudioDeviceStateFlagUpdatedDecs = (0, _decorator.trace)(['deviceId', 'flag']), _setDualStreamModeDecs = (0, _decorator.trace)(['enable']), _publishVideoDecs = (0, _decorator.trace)(['streamId', 'sourceId']), _unpublishVideoDecs = (0, _decorator.trace)(['streamId']), _publishAudioDecs = (0, _decorator.trace)(['streamId', 'sourceId']), _unpublishAudioDecs = (0, _decorator.trace)(['streamId']), _setVideoEncoderConfigDecs = (0, _decorator.trace)(['streamId', 'config']), _setLowStreamParameterDecs = (0, _decorator.trace)(['config']), "logger");
115
115
  var AgoraRtcPublishManager = exports.AgoraRtcPublishManager = /*#__PURE__*/function () {
116
116
  function AgoraRtcPublishManager(_mode, _rtcClient, streamId) {
117
117
  var _videoDeviceStateMap = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : new Map();
@@ -136,10 +136,12 @@ var AgoraRtcPublishManager = exports.AgoraRtcPublishManager = /*#__PURE__*/funct
136
136
  this._localAudioTracks = _localAudioTracks;
137
137
  this._syncState = this._syncState.bind(this);
138
138
  this._streamId = streamId;
139
+ this.logger.info("initialized with streamId: ".concat(streamId));
139
140
  }
140
141
  return (0, _createClass2["default"])(AgoraRtcPublishManager, [{
141
142
  key: "onLocalVideoTrackCreated",
142
143
  value: function onLocalVideoTrackCreated(sourceId, localTrack) {
144
+ this.logger.debug("onLocalVideoTrackCreated sourceId: ".concat(sourceId, ", trackId: ").concat(localTrack.getTrackId()));
143
145
  this._localVideoTracks.set(sourceId, localTrack);
144
146
  this._applyVideoEncoderConfig();
145
147
  this._syncState();
@@ -147,6 +149,7 @@ var AgoraRtcPublishManager = exports.AgoraRtcPublishManager = /*#__PURE__*/funct
147
149
  }, {
148
150
  key: "onLocalVideoTrackBeforeDestroy",
149
151
  value: function onLocalVideoTrackBeforeDestroy(sourceId, localTrack) {
152
+ this.logger.debug("onLocalVideoTrackBeforeDestroy sourceId: ".concat(sourceId, ", trackId: ").concat(localTrack.getTrackId()));
150
153
  this._localVideoTracks["delete"](sourceId);
151
154
  this._destroyedLocalVideoTracks.set(sourceId, localTrack);
152
155
  this._syncState();
@@ -154,12 +157,14 @@ var AgoraRtcPublishManager = exports.AgoraRtcPublishManager = /*#__PURE__*/funct
154
157
  }, {
155
158
  key: "onLocalAudioTrackCreated",
156
159
  value: function onLocalAudioTrackCreated(sourceId, localTrack) {
160
+ this.logger.debug("onLocalAudioTrackCreated sourceId: ".concat(sourceId, ", trackId: ").concat(localTrack.getTrackId()));
157
161
  this._localAudioTracks.set(sourceId, localTrack);
158
162
  this._syncState();
159
163
  }
160
164
  }, {
161
165
  key: "onLocalAudioTrackBeforeDestroy",
162
166
  value: function onLocalAudioTrackBeforeDestroy(sourceId, localTrack) {
167
+ this.logger.debug("onLocalAudioTrackBeforeDestroy sourceId: ".concat(sourceId, ", trackId: ").concat(localTrack.getTrackId()));
163
168
  this._localAudioTracks["delete"](sourceId);
164
169
  this._destroyedLocalAudioTracks.set(sourceId, localTrack);
165
170
  this._syncState();
@@ -393,9 +398,10 @@ var AgoraRtcPublishManager = exports.AgoraRtcPublishManager = /*#__PURE__*/funct
393
398
  while (1) switch (_context.prev = _context.next) {
394
399
  case 0:
395
400
  track = _step2.value;
396
- isTrackPublishing = _this2._rtcClient.localTracks.find(function (localTrack) {
401
+ isTrackPublishing = !!_this2._rtcClient.localTracks.find(function (localTrack) {
397
402
  return track === localTrack;
398
403
  });
404
+ _this2.logger.debug("operate destroyed local video track: ".concat(track.getTrackId(), ", isTrackPublishing: ").concat(isTrackPublishing));
399
405
  if (!isTrackPublishing) {
400
406
  _context.next = 1;
401
407
  break;
@@ -438,9 +444,10 @@ var AgoraRtcPublishManager = exports.AgoraRtcPublishManager = /*#__PURE__*/funct
438
444
  while (1) switch (_context2.prev = _context2.next) {
439
445
  case 0:
440
446
  track = _step3.value;
441
- isTrackPublishing = _this2._rtcClient.localTracks.find(function (localTrack) {
447
+ isTrackPublishing = !!_this2._rtcClient.localTracks.find(function (localTrack) {
442
448
  return track === localTrack;
443
449
  });
450
+ _this2.logger.debug("operate destroyed local audio track: ".concat(track.getTrackId(), ", isTrackPublishing: ").concat(isTrackPublishing));
444
451
  if (!isTrackPublishing) {
445
452
  _context2.next = 1;
446
453
  break;
@@ -492,7 +499,7 @@ var AgoraRtcPublishManager = exports.AgoraRtcPublishManager = /*#__PURE__*/funct
492
499
  }
493
500
  return _context3.abrupt("return", 1);
494
501
  case 1:
495
- _this2.logger.debug("operate local video track: ".concat(sourceId, ", muted: ").concat(muted, ", started: ").concat(started));
502
+ _this2.logger.debug("operate local video track:".concat(localVideoTrack.getTrackId(), ", sourceId: ").concat(sourceId, ", muted: ").concat(muted, ", started: ").concat(started));
496
503
  if (!(!muted && started)) {
497
504
  _context3.next = 4;
498
505
  break;
@@ -567,7 +574,7 @@ var AgoraRtcPublishManager = exports.AgoraRtcPublishManager = /*#__PURE__*/funct
567
574
  }
568
575
  return _context4.abrupt("return", 1);
569
576
  case 1:
570
- _this2.logger.debug("operate local audio track: ".concat(sourceId, ", muted: ").concat(muted, ", started: ").concat(started));
577
+ _this2.logger.debug("operate local audio track: ".concat(localAudioTrack.getTrackId(), ", sourceId: ").concat(sourceId, ", muted: ").concat(muted, ", started: ").concat(started));
571
578
  if (!(!muted && started)) {
572
579
  _context4.next = 4;
573
580
  break;
@@ -773,7 +780,7 @@ var AgoraRtcPublishManager = exports.AgoraRtcPublishManager = /*#__PURE__*/funct
773
780
  }]);
774
781
  }();
775
782
  _AgoraRtcPublishManager = AgoraRtcPublishManager;
776
- var _applyDecs$e = _applyDecs(_AgoraRtcPublishManager, [[_publishVideoDecs, 2, "publishVideo"], [_unpublishVideoDecs, 2, "unpublishVideo"], [_publishAudioDecs, 2, "publishAudio"], [_unpublishAudioDecs, 2, "unpublishAudio"], [_decorator.trace, 2, "release"], [_setVideoEncoderConfigDecs, 2, "setVideoEncoderConfig"], [_setLowStreamParameterDecs, 2, "setLowStreamParameter"], [_decorator.trace, 2, "_publishTracks"], [_decorator.trace, 2, "_unpublishTracks"]], []).e;
783
+ var _applyDecs$e = _applyDecs(_AgoraRtcPublishManager, [[_onLocalVideoTrackCreatedDecs, 2, "onLocalVideoTrackCreated"], [_onLocalVideoTrackBeforeDestroyDecs, 2, "onLocalVideoTrackBeforeDestroy"], [_onLocalAudioTrackCreatedDecs, 2, "onLocalAudioTrackCreated"], [_onLocalAudioTrackBeforeDestroyDecs, 2, "onLocalAudioTrackBeforeDestroy"], [_onVideoDeviceStateFlagUpdatedDecs, 2, "onVideoDeviceStateFlagUpdated"], [_onAudioDeviceStateFlagUpdatedDecs, 2, "onAudioDeviceStateFlagUpdated"], [_setDualStreamModeDecs, 2, "setDualStreamMode"], [_publishVideoDecs, 2, "publishVideo"], [_unpublishVideoDecs, 2, "unpublishVideo"], [_publishAudioDecs, 2, "publishAudio"], [_unpublishAudioDecs, 2, "unpublishAudio"], [_decorator.trace, 2, "release"], [_setVideoEncoderConfigDecs, 2, "setVideoEncoderConfig"], [_setLowStreamParameterDecs, 2, "setLowStreamParameter"], [_decorator.trace, 2, "_publishTracks"], [_decorator.trace, 2, "_unpublishTracks"]], []).e;
777
784
  var _applyDecs$e2 = (0, _slicedToArray2["default"])(_applyDecs$e, 1);
778
785
  _initProto = _applyDecs$e2[0];
779
786
  _applyDecs$e;