agora-rte-sdk 2.8.21 → 2.8.40

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 (58) hide show
  1. package/dist/index.js +2 -2
  2. package/lib/configs/index.d.ts +8 -6
  3. package/lib/configs/index.js +8 -6
  4. package/lib/core/engine/index.js +1 -7
  5. package/lib/core/logger/index.d.ts +1 -0
  6. package/lib/core/logger/index.js +22 -2
  7. package/lib/core/logger/log.worker.js +4 -2
  8. package/lib/core/media/control.d.ts +11 -8
  9. package/lib/core/media/control.js +42 -32
  10. package/lib/core/media/player.d.ts +9 -0
  11. package/lib/core/media/player.js +36 -0
  12. package/lib/core/media/track.d.ts +8 -1
  13. package/lib/core/media/track.js +18 -0
  14. package/lib/core/media/type.d.ts +113 -0
  15. package/lib/core/media/type.js +31 -0
  16. package/lib/core/processor/channel-msg/data.d.ts +1 -0
  17. package/lib/core/processor/channel-msg/data.js +5 -0
  18. package/lib/core/processor/channel-msg/handler.d.ts +1 -3
  19. package/lib/core/processor/channel-msg/handler.js +20 -21
  20. package/lib/core/processor/channel-msg/message-parser.d.ts +6 -0
  21. package/lib/core/processor/channel-msg/message-parser.js +57 -0
  22. package/lib/core/processor/channel-msg/struct.d.ts +5 -0
  23. package/lib/core/processor/channel-msg/synchronizer.d.ts +7 -14
  24. package/lib/core/processor/channel-msg/synchronizer.js +33 -48
  25. package/lib/core/processor/peer-msg/handler.d.ts +16 -0
  26. package/lib/core/processor/peer-msg/handler.js +57 -0
  27. package/lib/core/processor/peer-msg/struct.d.ts +4 -0
  28. package/lib/core/processor/type.d.ts +200 -0
  29. package/lib/core/rc/index.js +6 -2
  30. package/lib/core/rtc/adapter/base.d.ts +6 -7
  31. package/lib/core/rtc/adapter/electron/device.d.ts +0 -1
  32. package/lib/core/rtc/adapter/electron/device.js +0 -5
  33. package/lib/core/rtc/adapter/electron/index.d.ts +6 -7
  34. package/lib/core/rtc/adapter/electron/index.js +22 -24
  35. package/lib/core/rtc/adapter/web/client.d.ts +11 -9
  36. package/lib/core/rtc/adapter/web/client.js +40 -38
  37. package/lib/core/rtc/adapter/web/device.d.ts +0 -1
  38. package/lib/core/rtc/adapter/web/device.js +0 -5
  39. package/lib/core/rtc/adapter/web/dispatcher.d.ts +61 -0
  40. package/lib/core/rtc/adapter/web/dispatcher.js +166 -0
  41. package/lib/core/rtc/adapter/web/index.d.ts +11 -7
  42. package/lib/core/rtc/adapter/web/index.js +25 -16
  43. package/lib/core/rtc/adapter/web/thread.d.ts +18 -11
  44. package/lib/core/rtc/adapter/web/thread.js +241 -133
  45. package/lib/core/rtc/channel.d.ts +2 -3
  46. package/lib/core/rtc/index.d.ts +5 -4
  47. package/lib/core/rtc/index.js +12 -12
  48. package/lib/core/rtc/type.d.ts +0 -4
  49. package/lib/core/services/api.d.ts +15 -0
  50. package/lib/core/services/api.js +36 -1
  51. package/lib/core/utils/events.d.ts +0 -1
  52. package/lib/index.d.ts +3 -1
  53. package/lib/index.js +24 -17
  54. package/lib/scene/index.d.ts +1 -5
  55. package/lib/scene/index.js +88 -66
  56. package/lib/scene/state-sync.d.ts +21 -0
  57. package/lib/scene/state-sync.js +169 -0
  58. package/package.json +1 -1
@@ -14,9 +14,6 @@ require("core-js/modules/es.object.get-prototype-of.js");
14
14
  require("core-js/modules/es.object.set-prototype-of.js");
15
15
  require("core-js/modules/es.array.reverse.js");
16
16
  require("core-js/modules/es.array.slice.js");
17
- require("core-js/modules/es.object.keys.js");
18
- require("core-js/modules/es.object.get-own-property-descriptors.js");
19
- require("core-js/modules/es.object.define-properties.js");
20
17
  require("core-js/modules/es.weak-map.js");
21
18
  require("core-js/modules/esnext.weak-map.delete-all.js");
22
19
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
@@ -26,7 +23,6 @@ Object.defineProperty(exports, "__esModule", {
26
23
  });
27
24
  exports.AgoraRteSubscribeThread = exports.AgoraRteScreenShareThread = exports.AgoraRtePublishThreadSub = exports.AgoraRtePublishThreadMain = exports.AgoraRteMicrophoneThread = exports.AgoraRteMediaTrackThread = exports.AgoraRteCameraThread = void 0;
28
25
  var _applyDecoratedDescriptor2 = _interopRequireDefault(require("@babel/runtime/helpers/applyDecoratedDescriptor"));
29
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
30
26
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
31
27
  require("core-js/modules/es.array.concat.js");
32
28
  require("core-js/modules/es.array.reduce.js");
@@ -93,8 +89,6 @@ var _bound = require("../../../decorator/bound");
93
89
  var _dec, _class, _dec2, _class3, _dec3, _class5, _dec4, _class7, _class8, _dec5, _class10, _class11, _dec6, _class13;
94
90
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
95
91
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
96
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
97
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
98
92
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
99
93
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
100
94
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
@@ -208,7 +202,7 @@ var AgoraRteCameraThread = (_dec = _log.Log.attach({
208
202
  switch (_context2.prev = _context2.next) {
209
203
  case 0:
210
204
  if (!this.cameraEnable) {
211
- _context2.next = 36;
205
+ _context2.next = 35;
212
206
  break;
213
207
  }
214
208
  if (!this._deviceChanged) {
@@ -236,12 +230,12 @@ var AgoraRteCameraThread = (_dec = _log.Log.attach({
236
230
  _context2.prev = 11;
237
231
  _context2.t0 = _context2["catch"](3);
238
232
  _error.RteErrorCenter.shared.handleNonThrowableError(_error.AGRteErrorCode.RTC_ERR_CAM_ERR, _context2.t0);
239
- return _context2.abrupt("break", 43);
233
+ return _context2.abrupt("break", 42);
240
234
  case 15:
241
235
  this._deviceChanged = false;
242
236
  case 16:
243
237
  if (this.track) {
244
- _context2.next = 29;
238
+ _context2.next = 28;
245
239
  break;
246
240
  }
247
241
  this.logger.info("starting camera...");
@@ -281,7 +275,8 @@ var AgoraRteCameraThread = (_dec = _log.Log.attach({
281
275
  _this4.setCameraTrackState(_type.AgoraRteMediaSourceState.stopped);
282
276
  });
283
277
  _this4.setCameraTrackState(_type.AgoraRteMediaSourceState.started);
284
- case 11:
278
+ _this4.logger.info("camera started");
279
+ case 12:
285
280
  case "end":
286
281
  return _context.stop();
287
282
  }
@@ -296,25 +291,23 @@ var AgoraRteCameraThread = (_dec = _log.Log.attach({
296
291
  _context2.t2 = _context2["catch"](19);
297
292
  _error.RteErrorCenter.shared.handleNonThrowableError(_error.AGRteErrorCode.RTC_ERR_CAM_ERR, _context2.t2);
298
293
  this.setCameraTrackState(_type.AgoraRteMediaSourceState.error);
299
- return _context2.abrupt("break", 43);
294
+ return _context2.abrupt("break", 42);
300
295
  case 28:
301
- this.logger.info("camera started");
302
- case 29:
303
296
  if (this.track && this.canvas && this.canvas.view) {
304
297
  this.track.play(this.canvas.view);
305
298
  }
306
299
  this.pipeProcessors();
307
300
  if (!(this.track && (this.canvas && this.canvas.view && this.track.isPlaying || !this.canvas || !this.canvas.view))) {
308
- _context2.next = 34;
301
+ _context2.next = 33;
309
302
  break;
310
303
  }
311
304
  // ok to sleep
312
305
  this.logger.info('complete thread run');
313
- return _context2.abrupt("break", 43);
314
- case 34:
315
- _context2.next = 40;
306
+ return _context2.abrupt("break", 42);
307
+ case 33:
308
+ _context2.next = 39;
316
309
  break;
317
- case 36:
310
+ case 35:
318
311
  if (this.track) {
319
312
  this.logger.info("stopping camera...");
320
313
  this.track.stop();
@@ -326,23 +319,23 @@ var AgoraRteCameraThread = (_dec = _log.Log.attach({
326
319
  this.logger.info("camera stopped");
327
320
  }
328
321
  if (this.track) {
329
- _context2.next = 40;
322
+ _context2.next = 39;
330
323
  break;
331
324
  }
332
325
  // ok to sleep
333
326
  this.logger.info('complete thread run');
334
- return _context2.abrupt("break", 43);
335
- case 40:
336
- _context2.next = 42;
327
+ return _context2.abrupt("break", 42);
328
+ case 39:
329
+ _context2.next = 41;
337
330
  return new Promise(function (resolve) {
338
331
  return setTimeout(resolve, 500);
339
332
  });
340
- case 42:
333
+ case 41:
341
334
  if (this.running) {
342
335
  _context2.next = 0;
343
336
  break;
344
337
  }
345
- case 43:
338
+ case 42:
346
339
  case "end":
347
340
  return _context2.stop();
348
341
  }
@@ -363,22 +356,35 @@ var AgoraRteMicrophoneThread = (_dec2 = _log.Log.attach({
363
356
  }), _dec2(_class3 = /*#__PURE__*/function (_AgoraRteMediaTrackTh2) {
364
357
  (0, _inherits2["default"])(AgoraRteMicrophoneThread, _AgoraRteMediaTrackTh2);
365
358
  var _super3 = _createSuper(AgoraRteMicrophoneThread);
366
- function AgoraRteMicrophoneThread() {
359
+ function AgoraRteMicrophoneThread(rawDataDispatcher) {
367
360
  var _this5;
368
361
  (0, _classCallCheck2["default"])(this, AgoraRteMicrophoneThread);
369
- for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
370
- args[_key3] = arguments[_key3];
371
- }
372
- _this5 = _super3.call.apply(_super3, [this].concat(args));
373
- _this5.pcmTrack = void 0;
362
+ _this5 = _super3.call(this);
374
363
  _this5.micEnable = false;
364
+ _this5.trackState = _type.AgoraRteMediaSourceState.stopped;
375
365
  _this5._recordingDeviceId = void 0;
376
366
  _this5._recordingDeviceChanged = false;
377
- _this5.trackState = _type.AgoraRteMediaSourceState.stopped;
378
367
  _this5._volumePollingTask = void 0;
379
- _this5._audioRawConfig = {
380
- frameSize: 1024
381
- };
368
+ _this5._rawDataDispatcher = void 0;
369
+ _this5._pcmTrack = void 0;
370
+ _this5._rawDataDispatcher = rawDataDispatcher;
371
+ rawDataDispatcher.register('ObserverChanged', function () {
372
+ _this5.preparePcmCallback();
373
+ });
374
+ rawDataDispatcher.register('MicrophoneTrackCreated', function () {
375
+ _this5.preparePcmCallback();
376
+ });
377
+ rawDataDispatcher.register('MicrophoneTrackDestroyed', function () {
378
+ _this5.stopAudioFrameCallback();
379
+ });
380
+ rawDataDispatcher.register('Start', function () {
381
+ if (rawDataDispatcher.hasMicrophoneRawDataObservers) {
382
+ _this5.setAudioFrameCallback();
383
+ }
384
+ });
385
+ rawDataDispatcher.register('Stop', function () {
386
+ _this5.stopAudioFrameCallback();
387
+ });
382
388
  return _this5;
383
389
  }
384
390
  (0, _createClass2["default"])(AgoraRteMicrophoneThread, [{
@@ -415,47 +421,50 @@ var AgoraRteMicrophoneThread = (_dec2 = _log.Log.attach({
415
421
  this._recordingDeviceChanged = true;
416
422
  }
417
423
  }, {
418
- key: "setAudioRawDataConfig",
419
- value: function setAudioRawDataConfig(config) {
420
- this._audioRawConfig = _objectSpread(_objectSpread({}, this._audioRawConfig), config);
424
+ key: "preparePcmCallback",
425
+ value: function preparePcmCallback() {
426
+ if (this._rawDataDispatcher.hasMicrophoneRawDataObservers) {
427
+ this.setAudioFrameCallback();
428
+ } else {
429
+ this.stopAudioFrameCallback();
430
+ }
421
431
  }
422
432
  }, {
423
433
  key: "setAudioFrameCallback",
424
434
  value: function () {
425
435
  var _setAudioFrameCallback = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
426
436
  var _this7 = this;
427
- var _this$_audioRawConfig, sampleRate, frameSize;
437
+ var _this$_rawDataDispatc, sampleRate, frameSize, stereo, encoderConfig, trackClone;
428
438
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
429
439
  while (1) {
430
440
  switch (_context3.prev = _context3.next) {
431
441
  case 0:
432
- if (this._recordingDeviceId) {
442
+ if (this.track) {
433
443
  _context3.next = 3;
434
444
  break;
435
445
  }
436
- this.logger.warn("Cannot set PCM callback as there's no selected recording devices");
446
+ this.logger.warn("Cannot set PCM callback as there's no microphone track subscribed");
437
447
  return _context3.abrupt("return");
438
448
  case 3:
439
- _this$_audioRawConfig = this._audioRawConfig, sampleRate = _this$_audioRawConfig.sampleRate, frameSize = _this$_audioRawConfig.frameSize;
440
- if (this.pcmTrack) {
441
- _context3.next = 8;
442
- break;
443
- }
444
- _context3.next = 7;
445
- return _agoraRtcSdkNg["default"].createMicrophoneAudioTrack({
446
- microphoneId: this._recordingDeviceId,
447
- encoderConfig: {
449
+ _this$_rawDataDispatc = this._rawDataDispatcher.microphoneTrackRawDataConfig, sampleRate = _this$_rawDataDispatc.sampleRate, frameSize = _this$_rawDataDispatc.frameSize, stereo = _this$_rawDataDispatc.stereo;
450
+ if (!this._pcmTrack) {
451
+ encoderConfig = {
452
+ stereo: stereo,
448
453
  sampleRate: sampleRate
449
- }
450
- });
451
- case 7:
452
- this.pcmTrack = _context3.sent;
453
- case 8:
454
- this.logger.info('Attach PCM listener');
455
- this.pcmTrack.setAudioFrameCallback(function (buffer) {
456
- _this7.emit(_control.AgoraMediaControlEventType.localAudioFrame, buffer);
454
+ };
455
+ trackClone = this.track.getMediaStreamTrack().clone();
456
+ this._pcmTrack = _agoraRtcSdkNg["default"].createCustomAudioTrack({
457
+ mediaStreamTrack: trackClone,
458
+ encoderConfig: encoderConfig
459
+ });
460
+ }
461
+ this.logger.info('attach PCM listener on microphone track');
462
+ this._pcmTrack.setAudioFrameCallback(function (buffer) {
463
+ _this7._rawDataDispatcher.dispatch('AudioRawDataRecored', {
464
+ buffer: buffer
465
+ });
457
466
  }, frameSize);
458
- case 10:
467
+ case 7:
459
468
  case "end":
460
469
  return _context3.stop();
461
470
  }
@@ -470,12 +479,12 @@ var AgoraRteMicrophoneThread = (_dec2 = _log.Log.attach({
470
479
  }, {
471
480
  key: "stopAudioFrameCallback",
472
481
  value: function stopAudioFrameCallback() {
473
- if (this.pcmTrack) {
474
- this.logger.info('Detach PCM listener');
475
- this.pcmTrack.setAudioFrameCallback(null);
476
- this.pcmTrack.close();
482
+ if (this._pcmTrack) {
483
+ this.logger.info('detach PCM listener');
484
+ this._pcmTrack.setAudioFrameCallback(null);
485
+ this._pcmTrack.close();
477
486
  }
478
- this.pcmTrack = undefined;
487
+ this._pcmTrack = undefined;
479
488
  }
480
489
  }, {
481
490
  key: "onExecution",
@@ -487,7 +496,7 @@ var AgoraRteMicrophoneThread = (_dec2 = _log.Log.attach({
487
496
  switch (_context5.prev = _context5.next) {
488
497
  case 0:
489
498
  if (!this.micEnable) {
490
- _context5.next = 36;
499
+ _context5.next = 35;
491
500
  break;
492
501
  }
493
502
  if (!this._recordingDeviceChanged) {
@@ -516,12 +525,12 @@ var AgoraRteMicrophoneThread = (_dec2 = _log.Log.attach({
516
525
  _context5.t0 = _context5["catch"](3);
517
526
  _error.RteErrorCenter.shared.handleNonThrowableError(_error.AGRteErrorCode.RTC_ERR_MIC_ERR, _context5.t0);
518
527
  this.setMicTrackState(_type.AgoraRteMediaSourceState.error);
519
- return _context5.abrupt("break", 43);
528
+ return _context5.abrupt("break", 42);
520
529
  case 16:
521
530
  this._recordingDeviceChanged = false;
522
531
  case 17:
523
532
  if (this.track) {
524
- _context5.next = 30;
533
+ _context5.next = 29;
525
534
  break;
526
535
  }
527
536
  this.logger.info("starting mic...");
@@ -548,9 +557,9 @@ var AgoraRteMicrophoneThread = (_dec2 = _log.Log.attach({
548
557
  encoderConfig: encoderConfig
549
558
  });
550
559
  case 6:
551
- _this8.track = _context4.sent;
560
+ track = _context4.sent;
561
+ _this8.track = track;
552
562
  _this8.logger.info('microphone track created');
553
- track = _this8.track;
554
563
  _this8.track.on('track-ended', function () {
555
564
  _this8.logger.warn("mic track ended");
556
565
  track.stop();
@@ -561,7 +570,9 @@ var AgoraRteMicrophoneThread = (_dec2 = _log.Log.attach({
561
570
  _this8.setMicTrackState(_type.AgoraRteMediaSourceState.stopped);
562
571
  });
563
572
  _this8.setMicTrackState(_type.AgoraRteMediaSourceState.started);
564
- case 11:
573
+ _this8._rawDataDispatcher.dispatch('MicrophoneTrackCreated', track);
574
+ _this8.logger.info("mic started");
575
+ case 13:
565
576
  case "end":
566
577
  return _context4.stop();
567
578
  }
@@ -576,22 +587,20 @@ var AgoraRteMicrophoneThread = (_dec2 = _log.Log.attach({
576
587
  _context5.t2 = _context5["catch"](20);
577
588
  _error.RteErrorCenter.shared.handleNonThrowableError(_error.AGRteErrorCode.RTC_ERR_MIC_ERR, _context5.t2);
578
589
  this.setMicTrackState(_type.AgoraRteMediaSourceState.error);
579
- return _context5.abrupt("break", 43);
590
+ return _context5.abrupt("break", 42);
580
591
  case 29:
581
- this.logger.info("mic started");
582
- case 30:
583
592
  this.pipeProcessors();
584
593
  if (!this.track /* && this.track.isPlaying*/) {
585
- _context5.next = 34;
594
+ _context5.next = 33;
586
595
  break;
587
596
  }
588
597
  // ok to sleep
589
598
  this.logger.info('complete thread run');
590
- return _context5.abrupt("break", 43);
591
- case 34:
592
- _context5.next = 40;
599
+ return _context5.abrupt("break", 42);
600
+ case 33:
601
+ _context5.next = 39;
593
602
  break;
594
- case 36:
603
+ case 35:
595
604
  if (this.track) {
596
605
  this.logger.info('stopping microphone...');
597
606
  this.track.stop();
@@ -600,26 +609,27 @@ var AgoraRteMicrophoneThread = (_dec2 = _log.Log.attach({
600
609
  this.track = undefined;
601
610
  this.isPipedProcessors = false;
602
611
  this.setMicTrackState(_type.AgoraRteMediaSourceState.stopped);
612
+ this._rawDataDispatcher.dispatch('MicrophoneTrackDestroyed');
603
613
  this.logger.info('microphone stopped');
604
614
  }
605
615
  if (this.track) {
606
- _context5.next = 40;
616
+ _context5.next = 39;
607
617
  break;
608
618
  }
609
619
  // ok to sleep
610
620
  this.logger.info('complete thread run');
611
- return _context5.abrupt("break", 43);
612
- case 40:
613
- _context5.next = 42;
621
+ return _context5.abrupt("break", 42);
622
+ case 39:
623
+ _context5.next = 41;
614
624
  return new Promise(function (resolve) {
615
625
  return setTimeout(resolve, 500);
616
626
  });
617
- case 42:
627
+ case 41:
618
628
  if (this.running) {
619
629
  _context5.next = 0;
620
630
  break;
621
631
  }
622
- case 43:
632
+ case 42:
623
633
  case "end":
624
634
  return _context5.stop();
625
635
  }
@@ -643,8 +653,8 @@ var AgoraRteScreenShareThread = (_dec3 = _log.Log.attach({
643
653
  function AgoraRteScreenShareThread() {
644
654
  var _this9;
645
655
  (0, _classCallCheck2["default"])(this, AgoraRteScreenShareThread);
646
- for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
647
- args[_key4] = arguments[_key4];
656
+ for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
657
+ args[_key3] = arguments[_key3];
648
658
  }
649
659
  _this9 = _super4.call.apply(_super4, [this].concat(args));
650
660
  _this9.canvas = void 0;
@@ -1628,7 +1638,9 @@ var AgoraRteSubscribeThread = (_dec6 = _log.Log.attach({
1628
1638
  }), _dec6(_class13 = /*#__PURE__*/function (_AgoraRteThread4) {
1629
1639
  (0, _inherits2["default"])(AgoraRteSubscribeThread, _AgoraRteThread4);
1630
1640
  var _super7 = _createSuper(AgoraRteSubscribeThread);
1631
- function AgoraRteSubscribeThread(client, user, _ref2) {
1641
+ // do not modify _muteMap within thread
1642
+
1643
+ function AgoraRteSubscribeThread(client, user, _ref2, rawDataDispatcher) {
1632
1644
  var _this15;
1633
1645
  var channelName = _ref2.channelName,
1634
1646
  muteMap = _ref2.muteMap,
@@ -1645,20 +1657,43 @@ var AgoraRteSubscribeThread = (_dec6 = _log.Log.attach({
1645
1657
  _this15._volumePollingTask = void 0;
1646
1658
  _this15._prevCanvasView = void 0;
1647
1659
  _this15._prevRenderMode = void 0;
1660
+ _this15._pcmTrack = void 0;
1661
+ _this15._rawDataDispatcher = void 0;
1648
1662
  _this15._client = client;
1649
1663
  _this15._user = user;
1650
1664
  _this15._muteMap = muteMap;
1651
1665
  _this15._mediaType = mediaType;
1652
1666
  _this15._canvasMap = canvasMap;
1653
1667
  _this15._channelName = channelName;
1668
+ _this15._rawDataDispatcher = rawDataDispatcher;
1669
+ if (_this15._mediaType === 'audio') {
1670
+ rawDataDispatcher.register('ObserverChanged', function () {
1671
+ _this15.preparePcmCallback();
1672
+ });
1673
+ rawDataDispatcher.register('AudioTrackSubscribed', function (track, streamUuid) {
1674
+ if (streamUuid === _this15.streamUuid) {
1675
+ _this15.preparePcmCallback();
1676
+ }
1677
+ });
1678
+ rawDataDispatcher.register('AudioTrackUnsubscribed', function (streamUuid) {
1679
+ if (streamUuid === _this15.streamUuid) {
1680
+ _this15.stopAudioFrameCallback();
1681
+ }
1682
+ });
1683
+ rawDataDispatcher.register('Start', function () {
1684
+ if (_this15._rawDataDispatcher.hasAudioTrackRawDataObservers) {
1685
+ _this15.setAudioFrameCallback();
1686
+ }
1687
+ });
1688
+ rawDataDispatcher.register('Stop', function () {
1689
+ _this15.stopAudioFrameCallback();
1690
+ });
1691
+ }
1654
1692
  return _this15;
1655
1693
  }
1656
1694
  (0, _createClass2["default"])(AgoraRteSubscribeThread, [{
1657
1695
  key: "mute",
1658
- get:
1659
- // do not modify _muteMap within thread
1660
-
1661
- function get() {
1696
+ get: function get() {
1662
1697
  if (this._muteMap.has(this.streamUuid)) {
1663
1698
  return this._muteMap.get(this.streamUuid);
1664
1699
  }
@@ -1708,84 +1743,157 @@ var AgoraRteSubscribeThread = (_dec6 = _log.Log.attach({
1708
1743
  }
1709
1744
  }
1710
1745
  }, {
1711
- key: "onExecution",
1746
+ key: "preparePcmCallback",
1747
+ value: function preparePcmCallback() {
1748
+ if (this._rawDataDispatcher.hasAudioTrackRawDataObservers) {
1749
+ this.setAudioFrameCallback();
1750
+ } else {
1751
+ this.stopAudioFrameCallback();
1752
+ }
1753
+ }
1754
+ }, {
1755
+ key: "setAudioFrameCallback",
1712
1756
  value: function () {
1713
- var _onExecution6 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
1757
+ var _setAudioFrameCallback2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
1714
1758
  var _this16 = this;
1715
- var count;
1759
+ var _this$_rawDataDispatc2, sampleRate, frameSize, stereo, trackClone, encoderConfig;
1716
1760
  return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1717
1761
  while (1) {
1718
1762
  switch (_context22.prev = _context22.next) {
1763
+ case 0:
1764
+ if (this.track) {
1765
+ _context22.next = 3;
1766
+ break;
1767
+ }
1768
+ this.logger.warn("Cannot set PCM callback as there's no remote audio track subscribed");
1769
+ return _context22.abrupt("return");
1770
+ case 3:
1771
+ _this$_rawDataDispatc2 = this._rawDataDispatcher.audioTrackRawDataConfig, sampleRate = _this$_rawDataDispatc2.sampleRate, frameSize = _this$_rawDataDispatc2.frameSize, stereo = _this$_rawDataDispatc2.stereo;
1772
+ if (!this._pcmTrack) {
1773
+ trackClone = this.track.getMediaStreamTrack().clone();
1774
+ encoderConfig = {
1775
+ stereo: stereo,
1776
+ sampleRate: sampleRate
1777
+ };
1778
+ this._pcmTrack = _agoraRtcSdkNg["default"].createCustomAudioTrack({
1779
+ mediaStreamTrack: trackClone,
1780
+ encoderConfig: encoderConfig
1781
+ });
1782
+ }
1783
+ this.logger.info('attach PCM listener on remote audio track:', this._channelName, this.streamUuid);
1784
+ this._pcmTrack.setAudioFrameCallback(function (buffer) {
1785
+ _this16._rawDataDispatcher.dispatch('AudioRawDataBeforeMixed', {
1786
+ buffer: buffer
1787
+ }, _this16.streamUuid, _this16._channelName);
1788
+ }, frameSize);
1789
+ case 7:
1790
+ case "end":
1791
+ return _context22.stop();
1792
+ }
1793
+ }
1794
+ }, _callee22, this);
1795
+ }));
1796
+ function setAudioFrameCallback() {
1797
+ return _setAudioFrameCallback2.apply(this, arguments);
1798
+ }
1799
+ return setAudioFrameCallback;
1800
+ }()
1801
+ }, {
1802
+ key: "stopAudioFrameCallback",
1803
+ value: function stopAudioFrameCallback() {
1804
+ if (this._pcmTrack) {
1805
+ this.logger.info('detach PCM listener on remote audio track:', this._channelName, this.streamUuid);
1806
+ this._pcmTrack.setAudioFrameCallback(null);
1807
+ this._pcmTrack.close();
1808
+ }
1809
+ this._pcmTrack = undefined;
1810
+ }
1811
+ }, {
1812
+ key: "onExecution",
1813
+ value: function () {
1814
+ var _onExecution6 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
1815
+ var _this17 = this;
1816
+ var count, track;
1817
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
1818
+ while (1) {
1819
+ switch (_context23.prev = _context23.next) {
1719
1820
  case 0:
1720
1821
  // this.logger.debug(`thread notify start...`);
1721
1822
  count = 0;
1722
1823
  case 1:
1723
1824
  if (this.mute) {
1724
- _context22.next = 18;
1825
+ _context23.next = 20;
1725
1826
  break;
1726
1827
  }
1727
1828
  if (this.isTrackSubscribed()) {
1728
- _context22.next = 13;
1829
+ _context23.next = 15;
1729
1830
  break;
1730
1831
  }
1731
1832
  this.logger.info("[".concat(this._user.uid, "] subscribing ").concat(this._mediaType, "..."));
1732
- _context22.prev = 4;
1733
- _context22.next = 7;
1833
+ _context23.prev = 4;
1834
+ _context23.next = 7;
1734
1835
  return this._client.subscribe(this._user, this._mediaType);
1735
1836
  case 7:
1736
- _context22.next = 12;
1837
+ track = _context23.sent;
1838
+ if (this._mediaType === 'audio') {
1839
+ this._rawDataDispatcher.dispatch('AudioTrackSubscribed', track, this.streamUuid, this._channelName);
1840
+ }
1841
+ _context23.next = 14;
1737
1842
  break;
1738
- case 9:
1739
- _context22.prev = 9;
1740
- _context22.t0 = _context22["catch"](4);
1741
- _error.RteErrorCenter.shared.handleNonThrowableError(_error.AGRteErrorCode.RTC_ERR_TRACK_SUBSCRIBE_FAIL, _context22.t0);
1843
+ case 11:
1844
+ _context23.prev = 11;
1845
+ _context23.t0 = _context23["catch"](4);
1846
+ _error.RteErrorCenter.shared.handleNonThrowableError(_error.AGRteErrorCode.RTC_ERR_TRACK_SUBSCRIBE_FAIL, _context23.t0);
1742
1847
  // don't stop, try until success
1743
- case 12:
1848
+ case 14:
1744
1849
  this.logger.info("[".concat(this._user.uid, "] subscribed."));
1745
- case 13:
1850
+ case 15:
1746
1851
  if (this._mediaType === 'video') {
1747
1852
  this.play();
1748
1853
  } else {
1749
1854
  if (this.track) {
1750
1855
  if (!this._volumePollingTask) {
1751
1856
  this._volumePollingTask = _schedule.Scheduler.shared.addPollingTask(function () {
1752
- var volume = _this16.track.getVolumeLevel();
1857
+ var volume = _this17.track.getVolumeLevel();
1753
1858
  volume = Math.min(volume * 3, 1);
1754
- _this16.emit('audio-volume-indication', volume);
1859
+ _this17.emit('audio-volume-indication', volume);
1755
1860
  }, _schedule.Scheduler.Duration.second(0.5));
1756
1861
  }
1757
1862
  this.track.play();
1758
1863
  }
1759
1864
  }
1760
1865
  if (!this.isTrackSubscribed()) {
1761
- _context22.next = 16;
1866
+ _context23.next = 18;
1762
1867
  break;
1763
1868
  }
1764
- return _context22.abrupt("break", 38);
1765
- case 16:
1766
- _context22.next = 33;
1767
- break;
1869
+ return _context23.abrupt("break", 41);
1768
1870
  case 18:
1871
+ _context23.next = 36;
1872
+ break;
1873
+ case 20:
1769
1874
  if (!this.isTrackSubscribed()) {
1770
- _context22.next = 30;
1875
+ _context23.next = 33;
1771
1876
  break;
1772
1877
  }
1773
1878
  this.logger.info("[".concat(this._user.uid, "] unpublishing..."));
1774
- _context22.prev = 20;
1775
- _context22.next = 23;
1879
+ _context23.prev = 22;
1880
+ _context23.next = 25;
1776
1881
  return this._client.unsubscribe(this._user, this._mediaType);
1777
- case 23:
1778
- _context22.next = 29;
1779
- break;
1780
1882
  case 25:
1781
- _context22.prev = 25;
1782
- _context22.t1 = _context22["catch"](20);
1783
- _error.RteErrorCenter.shared.handleNonThrowableError(_error.AGRteErrorCode.RTC_ERR_TRACK_UNSUBSCRIBE_FAIL, _context22.t1);
1883
+ if (this._mediaType === 'audio') {
1884
+ this._rawDataDispatcher.dispatch('AudioTrackUnsubscribed', this.streamUuid, this._channelName);
1885
+ }
1886
+ _context23.next = 32;
1887
+ break;
1888
+ case 28:
1889
+ _context23.prev = 28;
1890
+ _context23.t1 = _context23["catch"](22);
1891
+ _error.RteErrorCenter.shared.handleNonThrowableError(_error.AGRteErrorCode.RTC_ERR_TRACK_UNSUBSCRIBE_FAIL, _context23.t1);
1784
1892
  //stop if unsub failed
1785
- return _context22.abrupt("break", 38);
1786
- case 29:
1893
+ return _context23.abrupt("break", 41);
1894
+ case 32:
1787
1895
  this.logger.info("[".concat(this._user.uid, "] unpublished."));
1788
- case 30:
1896
+ case 33:
1789
1897
  if (this.track) {
1790
1898
  this.logger.info("[".concat(this._user.uid, "] stopping track..."));
1791
1899
  this.track.stop();
@@ -1795,31 +1903,31 @@ var AgoraRteSubscribeThread = (_dec6 = _log.Log.attach({
1795
1903
  this.logger.info("[".concat(this._user.uid, "] track stopped"));
1796
1904
  }
1797
1905
  if (this.isTrackSubscribed()) {
1798
- _context22.next = 33;
1906
+ _context23.next = 36;
1799
1907
  break;
1800
1908
  }
1801
- return _context22.abrupt("break", 38);
1802
- case 33:
1803
- _context22.next = 35;
1909
+ return _context23.abrupt("break", 41);
1910
+ case 36:
1911
+ _context23.next = 38;
1804
1912
  return new Promise(function (resolve) {
1805
1913
  return setTimeout(resolve, 500);
1806
1914
  });
1807
- case 35:
1915
+ case 38:
1808
1916
  count++;
1809
1917
  if (count % 10 === 0) {
1810
1918
  this.logger.info("thread running...");
1811
1919
  }
1812
- case 37:
1920
+ case 40:
1813
1921
  if (this.running) {
1814
- _context22.next = 1;
1922
+ _context23.next = 1;
1815
1923
  break;
1816
1924
  }
1817
- case 38:
1925
+ case 41:
1818
1926
  case "end":
1819
- return _context22.stop();
1927
+ return _context23.stop();
1820
1928
  }
1821
1929
  }
1822
- }, _callee22, this, [[4, 9], [20, 25]]);
1930
+ }, _callee23, this, [[4, 11], [22, 28]]);
1823
1931
  }));
1824
1932
  function onExecution() {
1825
1933
  return _onExecution6.apply(this, arguments);