@volcengine/veplayer-plugin 2.7.1-rc.1 → 2.7.1-rc.3

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.
@@ -41,10 +41,10 @@ function _regeneratorRuntime$1() {
41
41
  return obj[key] = value;
42
42
  };
43
43
  }
44
- function wrap(innerFn, outerFn, self, tryLocsList) {
44
+ function wrap(innerFn, outerFn, self2, tryLocsList) {
45
45
  var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []);
46
46
  return defineProperty(generator, "_invoke", {
47
- value: makeInvokeMethod(innerFn, self, context)
47
+ value: makeInvokeMethod(innerFn, self2, context)
48
48
  }), generator;
49
49
  }
50
50
  function tryCatch(fn, obj, arg) {
@@ -111,7 +111,7 @@ function _regeneratorRuntime$1() {
111
111
  }
112
112
  });
113
113
  }
114
- function makeInvokeMethod(innerFn, self, context) {
114
+ function makeInvokeMethod(innerFn, self2, context) {
115
115
  var state = "suspendedStart";
116
116
  return function(method, arg) {
117
117
  if ("executing" === state)
@@ -140,7 +140,7 @@ function _regeneratorRuntime$1() {
140
140
  } else
141
141
  "return" === context.method && context.abrupt("return", context.arg);
142
142
  state = "executing";
143
- var record = tryCatch(innerFn, self, context);
143
+ var record = tryCatch(innerFn, self2, context);
144
144
  if ("normal" === record.type) {
145
145
  if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel)
146
146
  continue;
@@ -222,9 +222,9 @@ function _regeneratorRuntime$1() {
222
222
  };
223
223
  }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function() {
224
224
  return this;
225
- }), exports.AsyncIterator = AsyncIterator, exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
225
+ }), exports.AsyncIterator = AsyncIterator, exports.async = function(innerFn, outerFn, self2, tryLocsList, PromiseImpl) {
226
226
  void 0 === PromiseImpl && (PromiseImpl = Promise);
227
- var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
227
+ var iter = new AsyncIterator(wrap(innerFn, outerFn, self2, tryLocsList), PromiseImpl);
228
228
  return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function(result) {
229
229
  return result.done ? result.value : iter.next();
230
230
  });
@@ -351,9 +351,9 @@ function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
351
351
  }
352
352
  function _asyncToGenerator$1(fn) {
353
353
  return function() {
354
- var self = this, args = arguments;
354
+ var self2 = this, args = arguments;
355
355
  return new Promise(function(resolve, reject) {
356
- var gen = fn.apply(self, args);
356
+ var gen = fn.apply(self2, args);
357
357
  function _next(value) {
358
358
  asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
359
359
  }
@@ -364,33 +364,33 @@ function _asyncToGenerator$1(fn) {
364
364
  });
365
365
  };
366
366
  }
367
- function _classCallCheck$2(instance, Constructor) {
367
+ function _classCallCheck$3(instance, Constructor) {
368
368
  if (!(instance instanceof Constructor)) {
369
369
  throw new TypeError("Cannot call a class as a function");
370
370
  }
371
371
  }
372
- function _defineProperties$2(target, props) {
372
+ function _defineProperties$3(target, props) {
373
373
  for (var i = 0; i < props.length; i++) {
374
374
  var descriptor = props[i];
375
375
  descriptor.enumerable = descriptor.enumerable || false;
376
376
  descriptor.configurable = true;
377
377
  if ("value" in descriptor)
378
378
  descriptor.writable = true;
379
- Object.defineProperty(target, _toPropertyKey$2(descriptor.key), descriptor);
379
+ Object.defineProperty(target, _toPropertyKey$3(descriptor.key), descriptor);
380
380
  }
381
381
  }
382
- function _createClass$2(Constructor, protoProps, staticProps) {
382
+ function _createClass$3(Constructor, protoProps, staticProps) {
383
383
  if (protoProps)
384
- _defineProperties$2(Constructor.prototype, protoProps);
384
+ _defineProperties$3(Constructor.prototype, protoProps);
385
385
  if (staticProps)
386
- _defineProperties$2(Constructor, staticProps);
386
+ _defineProperties$3(Constructor, staticProps);
387
387
  Object.defineProperty(Constructor, "prototype", {
388
388
  writable: false
389
389
  });
390
390
  return Constructor;
391
391
  }
392
392
  function _defineProperty$2(obj, key, value) {
393
- key = _toPropertyKey$2(key);
393
+ key = _toPropertyKey$3(key);
394
394
  if (key in obj) {
395
395
  Object.defineProperty(obj, key, {
396
396
  value,
@@ -448,19 +448,19 @@ function _isNativeReflectConstruct$1() {
448
448
  return false;
449
449
  }
450
450
  }
451
- function _assertThisInitialized$1(self) {
452
- if (self === void 0) {
451
+ function _assertThisInitialized$1(self2) {
452
+ if (self2 === void 0) {
453
453
  throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
454
454
  }
455
- return self;
455
+ return self2;
456
456
  }
457
- function _possibleConstructorReturn$1(self, call) {
457
+ function _possibleConstructorReturn$1(self2, call) {
458
458
  if (call && (typeof call === "object" || typeof call === "function")) {
459
459
  return call;
460
460
  } else if (call !== void 0) {
461
461
  throw new TypeError("Derived constructors may only return object or undefined");
462
462
  }
463
- return _assertThisInitialized$1(self);
463
+ return _assertThisInitialized$1(self2);
464
464
  }
465
465
  function _createSuper$1(Derived) {
466
466
  var hasNativeReflectConstruct = _isNativeReflectConstruct$1();
@@ -475,7 +475,7 @@ function _createSuper$1(Derived) {
475
475
  return _possibleConstructorReturn$1(this, result);
476
476
  };
477
477
  }
478
- function _toPrimitive$2(input, hint) {
478
+ function _toPrimitive$3(input, hint) {
479
479
  if (typeof input !== "object" || input === null)
480
480
  return input;
481
481
  var prim = input[Symbol.toPrimitive];
@@ -487,8 +487,8 @@ function _toPrimitive$2(input, hint) {
487
487
  }
488
488
  return (hint === "string" ? String : Number)(input);
489
489
  }
490
- function _toPropertyKey$2(arg) {
491
- var key = _toPrimitive$2(arg, "string");
490
+ function _toPropertyKey$3(arg) {
491
+ var key = _toPrimitive$3(arg, "string");
492
492
  return typeof key === "symbol" ? key : String(key);
493
493
  }
494
494
  function ownKeys$1(object, enumerableOnly) {
@@ -520,33 +520,33 @@ function _typeof$1(obj) {
520
520
  return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
521
521
  }, _typeof$1(obj);
522
522
  }
523
- function _classCallCheck$1(instance, Constructor) {
523
+ function _classCallCheck$2(instance, Constructor) {
524
524
  if (!(instance instanceof Constructor)) {
525
525
  throw new TypeError("Cannot call a class as a function");
526
526
  }
527
527
  }
528
- function _defineProperties$1(target, props) {
528
+ function _defineProperties$2(target, props) {
529
529
  for (var i = 0; i < props.length; i++) {
530
530
  var descriptor = props[i];
531
531
  descriptor.enumerable = descriptor.enumerable || false;
532
532
  descriptor.configurable = true;
533
533
  if ("value" in descriptor)
534
534
  descriptor.writable = true;
535
- Object.defineProperty(target, _toPropertyKey$1(descriptor.key), descriptor);
535
+ Object.defineProperty(target, _toPropertyKey$2(descriptor.key), descriptor);
536
536
  }
537
537
  }
538
- function _createClass$1(Constructor, protoProps, staticProps) {
538
+ function _createClass$2(Constructor, protoProps, staticProps) {
539
539
  if (protoProps)
540
- _defineProperties$1(Constructor.prototype, protoProps);
540
+ _defineProperties$2(Constructor.prototype, protoProps);
541
541
  if (staticProps)
542
- _defineProperties$1(Constructor, staticProps);
542
+ _defineProperties$2(Constructor, staticProps);
543
543
  Object.defineProperty(Constructor, "prototype", {
544
544
  writable: false
545
545
  });
546
546
  return Constructor;
547
547
  }
548
548
  function _defineProperty$1(obj, key, value) {
549
- key = _toPropertyKey$1(key);
549
+ key = _toPropertyKey$2(key);
550
550
  if (key in obj) {
551
551
  Object.defineProperty(obj, key, {
552
552
  value,
@@ -593,7 +593,7 @@ function _arrayLikeToArray$1(arr, len) {
593
593
  function _nonIterableSpread() {
594
594
  throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
595
595
  }
596
- function _toPrimitive$1(input, hint) {
596
+ function _toPrimitive$2(input, hint) {
597
597
  if (typeof input !== "object" || input === null)
598
598
  return input;
599
599
  var prim = input[Symbol.toPrimitive];
@@ -605,8 +605,8 @@ function _toPrimitive$1(input, hint) {
605
605
  }
606
606
  return (hint === "string" ? String : Number)(input);
607
607
  }
608
- function _toPropertyKey$1(arg) {
609
- var key = _toPrimitive$1(arg, "string");
608
+ function _toPropertyKey$2(arg) {
609
+ var key = _toPrimitive$2(arg, "string");
610
610
  return typeof key === "symbol" ? key : String(key);
611
611
  }
612
612
  function getDefaultExportFromCjs(x) {
@@ -830,10 +830,10 @@ var XG_DEBUG = {
830
830
  };
831
831
  var XgplayerTimeRange = /* @__PURE__ */ function() {
832
832
  function XgplayerTimeRange2(bufferedList) {
833
- _classCallCheck$1(this, XgplayerTimeRange2);
833
+ _classCallCheck$2(this, XgplayerTimeRange2);
834
834
  this.bufferedList = bufferedList;
835
835
  }
836
- _createClass$1(XgplayerTimeRange2, [{
836
+ _createClass$2(XgplayerTimeRange2, [{
837
837
  key: "start",
838
838
  value: function start(index) {
839
839
  return this.bufferedList[index].start;
@@ -1539,7 +1539,7 @@ var ERROR_MAP = {
1539
1539
  5: 5105,
1540
1540
  6: 5106
1541
1541
  };
1542
- var Errors = /* @__PURE__ */ _createClass$1(
1542
+ var Errors = /* @__PURE__ */ _createClass$2(
1543
1543
  function Errors2(player) {
1544
1544
  var errorInfo = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
1545
1545
  errorType: "",
@@ -1549,7 +1549,7 @@ var Errors = /* @__PURE__ */ _createClass$1(
1549
1549
  ext: {},
1550
1550
  mediaError: null
1551
1551
  };
1552
- _classCallCheck$1(this, Errors2);
1552
+ _classCallCheck$2(this, Errors2);
1553
1553
  var ERROR_TYPES = player && player.i18n ? player.i18n.ERROR_TYPES : null;
1554
1554
  if (player.media) {
1555
1555
  var mediaError = errorInfo.mediaError ? errorInfo.mediaError : player.media.error || {};
@@ -1766,7 +1766,7 @@ function showErrorMsg(pluginName, msg) {
1766
1766
  }
1767
1767
  var BasePlugin = /* @__PURE__ */ function() {
1768
1768
  function BasePlugin2(args) {
1769
- _classCallCheck$1(this, BasePlugin2);
1769
+ _classCallCheck$2(this, BasePlugin2);
1770
1770
  if (util.checkIsFunction(this.beforeCreate)) {
1771
1771
  this.beforeCreate(args);
1772
1772
  }
@@ -1780,7 +1780,7 @@ var BasePlugin = /* @__PURE__ */ function() {
1780
1780
  this.pluginName = "";
1781
1781
  this.__init(args);
1782
1782
  }
1783
- _createClass$1(BasePlugin2, [{
1783
+ _createClass$2(BasePlugin2, [{
1784
1784
  key: "beforeCreate",
1785
1785
  value: function beforeCreate(args) {
1786
1786
  }
@@ -2068,10 +2068,10 @@ function _regeneratorRuntime() {
2068
2068
  return obj[key] = value;
2069
2069
  };
2070
2070
  }
2071
- function wrap(innerFn, outerFn, self, tryLocsList) {
2071
+ function wrap(innerFn, outerFn, self2, tryLocsList) {
2072
2072
  var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []);
2073
2073
  return defineProperty(generator, "_invoke", {
2074
- value: makeInvokeMethod(innerFn, self, context)
2074
+ value: makeInvokeMethod(innerFn, self2, context)
2075
2075
  }), generator;
2076
2076
  }
2077
2077
  function tryCatch(fn, obj, arg) {
@@ -2138,7 +2138,7 @@ function _regeneratorRuntime() {
2138
2138
  }
2139
2139
  });
2140
2140
  }
2141
- function makeInvokeMethod(innerFn, self, context) {
2141
+ function makeInvokeMethod(innerFn, self2, context) {
2142
2142
  var state = "suspendedStart";
2143
2143
  return function(method, arg) {
2144
2144
  if ("executing" === state)
@@ -2167,7 +2167,7 @@ function _regeneratorRuntime() {
2167
2167
  } else
2168
2168
  "return" === context.method && context.abrupt("return", context.arg);
2169
2169
  state = "executing";
2170
- var record = tryCatch(innerFn, self, context);
2170
+ var record = tryCatch(innerFn, self2, context);
2171
2171
  if ("normal" === record.type) {
2172
2172
  if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel)
2173
2173
  continue;
@@ -2249,9 +2249,9 @@ function _regeneratorRuntime() {
2249
2249
  };
2250
2250
  }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function() {
2251
2251
  return this;
2252
- }), exports.AsyncIterator = AsyncIterator, exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
2252
+ }), exports.AsyncIterator = AsyncIterator, exports.async = function(innerFn, outerFn, self2, tryLocsList, PromiseImpl) {
2253
2253
  void 0 === PromiseImpl && (PromiseImpl = Promise);
2254
- var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
2254
+ var iter = new AsyncIterator(wrap(innerFn, outerFn, self2, tryLocsList), PromiseImpl);
2255
2255
  return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function(result) {
2256
2256
  return result.done ? result.value : iter.next();
2257
2257
  });
@@ -2386,9 +2386,9 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
2386
2386
  }
2387
2387
  function _asyncToGenerator(fn) {
2388
2388
  return function() {
2389
- var self = this, args = arguments;
2389
+ var self2 = this, args = arguments;
2390
2390
  return new Promise(function(resolve, reject) {
2391
- var gen = fn.apply(self, args);
2391
+ var gen = fn.apply(self2, args);
2392
2392
  function _next(value) {
2393
2393
  asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
2394
2394
  }
@@ -2399,33 +2399,33 @@ function _asyncToGenerator(fn) {
2399
2399
  });
2400
2400
  };
2401
2401
  }
2402
- function _classCallCheck(instance, Constructor) {
2402
+ function _classCallCheck$1(instance, Constructor) {
2403
2403
  if (!(instance instanceof Constructor)) {
2404
2404
  throw new TypeError("Cannot call a class as a function");
2405
2405
  }
2406
2406
  }
2407
- function _defineProperties(target, props) {
2407
+ function _defineProperties$1(target, props) {
2408
2408
  for (var i = 0; i < props.length; i++) {
2409
2409
  var descriptor = props[i];
2410
2410
  descriptor.enumerable = descriptor.enumerable || false;
2411
2411
  descriptor.configurable = true;
2412
2412
  if ("value" in descriptor)
2413
2413
  descriptor.writable = true;
2414
- Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
2414
+ Object.defineProperty(target, _toPropertyKey$1(descriptor.key), descriptor);
2415
2415
  }
2416
2416
  }
2417
- function _createClass(Constructor, protoProps, staticProps) {
2417
+ function _createClass$1(Constructor, protoProps, staticProps) {
2418
2418
  if (protoProps)
2419
- _defineProperties(Constructor.prototype, protoProps);
2419
+ _defineProperties$1(Constructor.prototype, protoProps);
2420
2420
  if (staticProps)
2421
- _defineProperties(Constructor, staticProps);
2421
+ _defineProperties$1(Constructor, staticProps);
2422
2422
  Object.defineProperty(Constructor, "prototype", {
2423
2423
  writable: false
2424
2424
  });
2425
2425
  return Constructor;
2426
2426
  }
2427
2427
  function _defineProperty(obj, key, value) {
2428
- key = _toPropertyKey(key);
2428
+ key = _toPropertyKey$1(key);
2429
2429
  if (key in obj) {
2430
2430
  Object.defineProperty(obj, key, {
2431
2431
  value,
@@ -2562,19 +2562,19 @@ function _objectWithoutProperties(source, excluded) {
2562
2562
  }
2563
2563
  return target;
2564
2564
  }
2565
- function _assertThisInitialized(self) {
2566
- if (self === void 0) {
2565
+ function _assertThisInitialized(self2) {
2566
+ if (self2 === void 0) {
2567
2567
  throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
2568
2568
  }
2569
- return self;
2569
+ return self2;
2570
2570
  }
2571
- function _possibleConstructorReturn(self, call) {
2571
+ function _possibleConstructorReturn(self2, call) {
2572
2572
  if (call && (typeof call === "object" || typeof call === "function")) {
2573
2573
  return call;
2574
2574
  } else if (call !== void 0) {
2575
2575
  throw new TypeError("Derived constructors may only return object or undefined");
2576
2576
  }
2577
- return _assertThisInitialized(self);
2577
+ return _assertThisInitialized(self2);
2578
2578
  }
2579
2579
  function _createSuper(Derived) {
2580
2580
  var hasNativeReflectConstruct = _isNativeReflectConstruct();
@@ -2688,7 +2688,7 @@ function _createForOfIteratorHelper(o, allowArrayLike) {
2688
2688
  }
2689
2689
  };
2690
2690
  }
2691
- function _toPrimitive(input, hint) {
2691
+ function _toPrimitive$1(input, hint) {
2692
2692
  if (typeof input !== "object" || input === null)
2693
2693
  return input;
2694
2694
  var prim = input[Symbol.toPrimitive];
@@ -2700,8 +2700,8 @@ function _toPrimitive(input, hint) {
2700
2700
  }
2701
2701
  return (hint === "string" ? String : Number)(input);
2702
2702
  }
2703
- function _toPropertyKey(arg) {
2704
- var key = _toPrimitive(arg, "string");
2703
+ function _toPropertyKey$1(arg) {
2704
+ var key = _toPrimitive$1(arg, "string");
2705
2705
  return typeof key === "symbol" ? key : String(key);
2706
2706
  }
2707
2707
  function createPublicPromise() {
@@ -2800,7 +2800,7 @@ var StreamingError = /* @__PURE__ */ function(_Error) {
2800
2800
  var _super = _createSuper(StreamingError2);
2801
2801
  function StreamingError2(type, subType, origin, payload, msg) {
2802
2802
  var _this;
2803
- _classCallCheck(this, StreamingError2);
2803
+ _classCallCheck$1(this, StreamingError2);
2804
2804
  _this = _super.call(this, msg || (origin === null || origin === void 0 ? void 0 : origin.message));
2805
2805
  _this.errorType = type === ERR.NETWORK_TIMEOUT ? ERR.NETWORK : type;
2806
2806
  _this.originError = origin;
@@ -2813,7 +2813,7 @@ var StreamingError = /* @__PURE__ */ function(_Error) {
2813
2813
  }
2814
2814
  return _this;
2815
2815
  }
2816
- _createClass(StreamingError2, null, [{
2816
+ _createClass$1(StreamingError2, null, [{
2817
2817
  key: "create",
2818
2818
  value: function create(type, subType, origin, payload, msg) {
2819
2819
  if (type instanceof StreamingError2) {
@@ -2849,7 +2849,7 @@ var LOG_MAX_SIZE = 200 * 1024;
2849
2849
  var SIMPLE_TYPE = ["Boolean", "Number", "String", "Undefined", "Null", "Date", "Object"];
2850
2850
  var Logger = /* @__PURE__ */ function() {
2851
2851
  function Logger2(name, config) {
2852
- _classCallCheck(this, Logger2);
2852
+ _classCallCheck$1(this, Logger2);
2853
2853
  this.name = name || "";
2854
2854
  this._prefix = "[".concat(this.name, "]");
2855
2855
  this.logCacheLevel = (config === null || config === void 0 ? void 0 : config.logCacheLevel) || 3;
@@ -2857,7 +2857,7 @@ var Logger = /* @__PURE__ */ function() {
2857
2857
  this.logSize = 0;
2858
2858
  this.logTextArray = [];
2859
2859
  }
2860
- _createClass(Logger2, [{
2860
+ _createClass$1(Logger2, [{
2861
2861
  key: "debug",
2862
2862
  value: function debug() {
2863
2863
  var _console;
@@ -3035,7 +3035,7 @@ var NetError = /* @__PURE__ */ function(_Error) {
3035
3035
  var _super = _createSuper(NetError2);
3036
3036
  function NetError2(url, request, response, msg) {
3037
3037
  var _this;
3038
- _classCallCheck(this, NetError2);
3038
+ _classCallCheck$1(this, NetError2);
3039
3039
  _this = _super.call(this, msg);
3040
3040
  _defineProperty(_assertThisInitialized(_this), "retryCount", 0);
3041
3041
  _defineProperty(_assertThisInitialized(_this), "isTimeout", false);
@@ -3048,7 +3048,7 @@ var NetError = /* @__PURE__ */ function(_Error) {
3048
3048
  _this.response = response;
3049
3049
  return _this;
3050
3050
  }
3051
- return _createClass(NetError2);
3051
+ return _createClass$1(NetError2);
3052
3052
  }(/* @__PURE__ */ _wrapNativeSuper(Error));
3053
3053
  var toString = Object.prototype.toString;
3054
3054
  function isObject(a) {
@@ -3173,7 +3173,7 @@ var FetchLoader = /* @__PURE__ */ function(_EventEmitter) {
3173
3173
  var _super = _createSuper(FetchLoader2);
3174
3174
  function FetchLoader2() {
3175
3175
  var _this;
3176
- _classCallCheck(this, FetchLoader2);
3176
+ _classCallCheck$1(this, FetchLoader2);
3177
3177
  _this = _super.call(this);
3178
3178
  _defineProperty(_assertThisInitialized(_this), "_abortController", null);
3179
3179
  _defineProperty(_assertThisInitialized(_this), "_timeoutTimer", null);
@@ -3191,7 +3191,7 @@ var FetchLoader = /* @__PURE__ */ function(_EventEmitter) {
3191
3191
  _defineProperty(_assertThisInitialized(_this), "_priOptions", null);
3192
3192
  return _this;
3193
3193
  }
3194
- _createClass(FetchLoader2, [{
3194
+ _createClass$1(FetchLoader2, [{
3195
3195
  key: "load",
3196
3196
  value: function load(_ref) {
3197
3197
  var _this$_abortControlle, _this2 = this;
@@ -3625,7 +3625,7 @@ var XhrLoader = /* @__PURE__ */ function(_EventEmitter) {
3625
3625
  var _super = _createSuper(XhrLoader2);
3626
3626
  function XhrLoader2() {
3627
3627
  var _this;
3628
- _classCallCheck(this, XhrLoader2);
3628
+ _classCallCheck$1(this, XhrLoader2);
3629
3629
  _this = _super.call(this);
3630
3630
  _defineProperty(_assertThisInitialized(_this), "_xhr", null);
3631
3631
  _defineProperty(_assertThisInitialized(_this), "_aborted", false);
@@ -3655,7 +3655,7 @@ var XhrLoader = /* @__PURE__ */ function(_EventEmitter) {
3655
3655
  _defineProperty(_assertThisInitialized(_this), "_priOptions", null);
3656
3656
  return _this;
3657
3657
  }
3658
- _createClass(XhrLoader2, [{
3658
+ _createClass$1(XhrLoader2, [{
3659
3659
  key: "load",
3660
3660
  value: function load(req) {
3661
3661
  var _this2 = this;
@@ -3940,7 +3940,7 @@ var XhrLoader = /* @__PURE__ */ function(_EventEmitter) {
3940
3940
  var _excluded = ["retry", "retryDelay", "onRetryError", "transformError"];
3941
3941
  var Task = /* @__PURE__ */ function() {
3942
3942
  function Task2(type, config) {
3943
- _classCallCheck(this, Task2);
3943
+ _classCallCheck$1(this, Task2);
3944
3944
  this.promise = createPublicPromise();
3945
3945
  this.alive = !!config.onProgress;
3946
3946
  !config.logger && (config.logger = new Logger("Loader"));
@@ -3953,7 +3953,7 @@ var Task = /* @__PURE__ */ function() {
3953
3953
  this._retryCheckFunc = config.retryCheckFunc;
3954
3954
  this._logger = config.logger;
3955
3955
  }
3956
- _createClass(Task2, [{
3956
+ _createClass$1(Task2, [{
3957
3957
  key: "exec",
3958
3958
  value: function exec() {
3959
3959
  var _this = this;
@@ -4072,7 +4072,7 @@ var NetLoader = /* @__PURE__ */ function(_EventEmitter) {
4072
4072
  var _super = _createSuper(NetLoader2);
4073
4073
  function NetLoader2(cfg) {
4074
4074
  var _this;
4075
- _classCallCheck(this, NetLoader2);
4075
+ _classCallCheck$1(this, NetLoader2);
4076
4076
  _this = _super.call(this, cfg);
4077
4077
  _defineProperty(_assertThisInitialized(_this), "type", LoaderType.FETCH);
4078
4078
  _defineProperty(_assertThisInitialized(_this), "_queue", []);
@@ -4087,7 +4087,7 @@ var NetLoader = /* @__PURE__ */ function(_EventEmitter) {
4087
4087
  _this.log = cfg.logger;
4088
4088
  return _this;
4089
4089
  }
4090
- _createClass(NetLoader2, [{
4090
+ _createClass$1(NetLoader2, [{
4091
4091
  key: "isFetch",
4092
4092
  value: function isFetch() {
4093
4093
  return this.type === LoaderType.FETCH;
@@ -4881,7 +4881,9 @@ function getOption(opts) {
4881
4881
  networkEvaluateInterval: 1e3,
4882
4882
  delayHint: 0,
4883
4883
  seamlesslyReload: false,
4884
- enableOriginSdpLogger: false
4884
+ enableSei: false,
4885
+ enableOriginSdpLogger: false,
4886
+ checkStatsErrorDelay: 5e3
4885
4887
  }, opts);
4886
4888
  }
4887
4889
  function _getStats(stats) {
@@ -4896,10 +4898,11 @@ function _getStats(stats) {
4896
4898
  }
4897
4899
  });
4898
4900
  return inboundRtps.map(function(inbound) {
4901
+ var _inbound$mediaType;
4899
4902
  var codec = stats.get(inbound.codecId);
4900
4903
  var track = stats.get(inbound.trackId);
4901
4904
  return {
4902
- type: inbound.mediaType,
4905
+ type: (_inbound$mediaType = inbound.mediaType) !== null && _inbound$mediaType !== void 0 ? _inbound$mediaType : inbound.kind,
4903
4906
  inboundRtp: inbound,
4904
4907
  remoteOutBoundRtp: remoteOutboundRtps.find(function(x) {
4905
4908
  return x.mediaType === inbound.mediaType;
@@ -4919,7 +4922,7 @@ function getStats(pc) {
4919
4922
  });
4920
4923
  }
4921
4924
  function getStatsSnapshoot(stats) {
4922
- var _v$codec, _v$codec2, _v$codec3, _v$inboundRtp, _v$inboundRtp2, _v$inboundRtp3, _v$inboundRtp4, _v$inboundRtp5, _v$inboundRtp6, _v$inboundRtp7, _v$inboundRtp8, _v$inboundRtp9, _v$inboundRtp10, _v$inboundRtp11, _v$inboundRtp12, _v$inboundRtp13, _v$inboundRtp14, _v$inboundRtp15, _a$codec, _a$codec2, _a$codec3, _a$inboundRtp, _a$inboundRtp2, _a$inboundRtp3, _a$inboundRtp4, _a$inboundRtp5, _a$inboundRtp6, _a$inboundRtp7, _a$inboundRtp8;
4925
+ var _v$inboundRtp, _v$codec, _v$codec2, _v$codec3, _v$inboundRtp4, _v$inboundRtp5, _v$inboundRtp6, _v$inboundRtp7, _v$inboundRtp8, _v$inboundRtp9, _v$inboundRtp10, _v$inboundRtp11, _v$inboundRtp$framesR, _v$inboundRtp12, _v$track, _v$inboundRtp13, _v$inboundRtp14, _v$inboundRtp15, _v$inboundRtp16, _v$inboundRtp17, _v$inboundRtp18, _a$codec, _a$codec2, _a$codec3, _a$inboundRtp, _a$inboundRtp2, _a$inboundRtp3, _a$inboundRtp4, _a$inboundRtp5, _a$inboundRtp6, _a$inboundRtp7, _a$inboundRtp8;
4923
4926
  var v = stats === null || stats === void 0 ? void 0 : stats.filter(function(x) {
4924
4927
  return x.type === "video";
4925
4928
  })[0];
@@ -4928,6 +4931,7 @@ function getStatsSnapshoot(stats) {
4928
4931
  })[0];
4929
4932
  var videoRemote;
4930
4933
  var audioRemote;
4934
+ var averageJitterBufferDelay;
4931
4935
  if (v && v.remoteOutBoundRtp) {
4932
4936
  videoRemote = {
4933
4937
  bytesSent: v.remoteOutBoundRtp.bytesSent,
@@ -4940,26 +4944,31 @@ function getStatsSnapshoot(stats) {
4940
4944
  packetsSent: a.remoteOutBoundRtp.packetsSent
4941
4945
  };
4942
4946
  }
4947
+ if ((v === null || v === void 0 ? void 0 : (_v$inboundRtp = v.inboundRtp) === null || _v$inboundRtp === void 0 ? void 0 : _v$inboundRtp.jitterBufferDelay) !== void 0) {
4948
+ var _v$inboundRtp2, _v$inboundRtp3;
4949
+ averageJitterBufferDelay = ((_v$inboundRtp2 = v.inboundRtp) === null || _v$inboundRtp2 === void 0 ? void 0 : _v$inboundRtp2.jitterBufferDelay) / ((_v$inboundRtp3 = v.inboundRtp) === null || _v$inboundRtp3 === void 0 ? void 0 : _v$inboundRtp3.jitterBufferEmittedCount) * 1e3;
4950
+ }
4943
4951
  return {
4944
4952
  video: !v ? void 0 : {
4945
4953
  codec: (_v$codec = v.codec) === null || _v$codec === void 0 ? void 0 : _v$codec.mimeType,
4946
4954
  payloadType: (_v$codec2 = v.codec) === null || _v$codec2 === void 0 ? void 0 : _v$codec2.payloadType,
4947
4955
  sdpFmtpLine: (_v$codec3 = v.codec) === null || _v$codec3 === void 0 ? void 0 : _v$codec3.sdpFmtpLine,
4948
- bytesReceived: ((_v$inboundRtp = v.inboundRtp) === null || _v$inboundRtp === void 0 ? void 0 : _v$inboundRtp.bytesReceived) || 0,
4949
- firCount: (_v$inboundRtp2 = v.inboundRtp) === null || _v$inboundRtp2 === void 0 ? void 0 : _v$inboundRtp2.firCount,
4950
- pliCount: (_v$inboundRtp3 = v.inboundRtp) === null || _v$inboundRtp3 === void 0 ? void 0 : _v$inboundRtp3.pliCount,
4951
- frameHeight: (_v$inboundRtp4 = v.inboundRtp) === null || _v$inboundRtp4 === void 0 ? void 0 : _v$inboundRtp4.frameHeight,
4952
- frameWidth: (_v$inboundRtp5 = v.inboundRtp) === null || _v$inboundRtp5 === void 0 ? void 0 : _v$inboundRtp5.frameWidth,
4953
- framesDecoded: (_v$inboundRtp6 = v.inboundRtp) === null || _v$inboundRtp6 === void 0 ? void 0 : _v$inboundRtp6.framesDecoded,
4954
- framesDropped: (_v$inboundRtp7 = v.inboundRtp) === null || _v$inboundRtp7 === void 0 ? void 0 : _v$inboundRtp7.framesDropped,
4955
- framesPerSecond: (_v$inboundRtp8 = v.inboundRtp) === null || _v$inboundRtp8 === void 0 ? void 0 : _v$inboundRtp8.framesPerSecond,
4956
- framesReceived: (_v$inboundRtp9 = v.inboundRtp) === null || _v$inboundRtp9 === void 0 ? void 0 : _v$inboundRtp9.framesReceived,
4957
- jitter: (_v$inboundRtp10 = v.inboundRtp) === null || _v$inboundRtp10 === void 0 ? void 0 : _v$inboundRtp10.jitter,
4958
- jitterBufferDelay: (_v$inboundRtp11 = v.inboundRtp) === null || _v$inboundRtp11 === void 0 ? void 0 : _v$inboundRtp11.jitterBufferDelay,
4959
- keyFramesDecoded: (_v$inboundRtp12 = v.inboundRtp) === null || _v$inboundRtp12 === void 0 ? void 0 : _v$inboundRtp12.keyFramesDecoded,
4960
- nackCount: (_v$inboundRtp13 = v.inboundRtp) === null || _v$inboundRtp13 === void 0 ? void 0 : _v$inboundRtp13.nackCount,
4961
- packetsLost: ((_v$inboundRtp14 = v.inboundRtp) === null || _v$inboundRtp14 === void 0 ? void 0 : _v$inboundRtp14.packetsLost) || 0,
4962
- packetsReceived: ((_v$inboundRtp15 = v.inboundRtp) === null || _v$inboundRtp15 === void 0 ? void 0 : _v$inboundRtp15.packetsReceived) || 0
4956
+ bytesReceived: ((_v$inboundRtp4 = v.inboundRtp) === null || _v$inboundRtp4 === void 0 ? void 0 : _v$inboundRtp4.bytesReceived) || 0,
4957
+ firCount: (_v$inboundRtp5 = v.inboundRtp) === null || _v$inboundRtp5 === void 0 ? void 0 : _v$inboundRtp5.firCount,
4958
+ pliCount: (_v$inboundRtp6 = v.inboundRtp) === null || _v$inboundRtp6 === void 0 ? void 0 : _v$inboundRtp6.pliCount,
4959
+ frameHeight: (_v$inboundRtp7 = v.inboundRtp) === null || _v$inboundRtp7 === void 0 ? void 0 : _v$inboundRtp7.frameHeight,
4960
+ frameWidth: (_v$inboundRtp8 = v.inboundRtp) === null || _v$inboundRtp8 === void 0 ? void 0 : _v$inboundRtp8.frameWidth,
4961
+ framesDecoded: (_v$inboundRtp9 = v.inboundRtp) === null || _v$inboundRtp9 === void 0 ? void 0 : _v$inboundRtp9.framesDecoded,
4962
+ framesDropped: (_v$inboundRtp10 = v.inboundRtp) === null || _v$inboundRtp10 === void 0 ? void 0 : _v$inboundRtp10.framesDropped,
4963
+ framesPerSecond: (_v$inboundRtp11 = v.inboundRtp) === null || _v$inboundRtp11 === void 0 ? void 0 : _v$inboundRtp11.framesPerSecond,
4964
+ framesReceived: (_v$inboundRtp$framesR = (_v$inboundRtp12 = v.inboundRtp) === null || _v$inboundRtp12 === void 0 ? void 0 : _v$inboundRtp12.framesReceived) !== null && _v$inboundRtp$framesR !== void 0 ? _v$inboundRtp$framesR : (_v$track = v.track) === null || _v$track === void 0 ? void 0 : _v$track.framesReceived,
4965
+ jitter: (_v$inboundRtp13 = v.inboundRtp) === null || _v$inboundRtp13 === void 0 ? void 0 : _v$inboundRtp13.jitter,
4966
+ jitterBufferDelay: (_v$inboundRtp14 = v.inboundRtp) === null || _v$inboundRtp14 === void 0 ? void 0 : _v$inboundRtp14.jitterBufferDelay,
4967
+ keyFramesDecoded: (_v$inboundRtp15 = v.inboundRtp) === null || _v$inboundRtp15 === void 0 ? void 0 : _v$inboundRtp15.keyFramesDecoded,
4968
+ nackCount: (_v$inboundRtp16 = v.inboundRtp) === null || _v$inboundRtp16 === void 0 ? void 0 : _v$inboundRtp16.nackCount,
4969
+ packetsLost: ((_v$inboundRtp17 = v.inboundRtp) === null || _v$inboundRtp17 === void 0 ? void 0 : _v$inboundRtp17.packetsLost) || 0,
4970
+ packetsReceived: ((_v$inboundRtp18 = v.inboundRtp) === null || _v$inboundRtp18 === void 0 ? void 0 : _v$inboundRtp18.packetsReceived) || 0,
4971
+ averageJitterBufferDelay
4963
4972
  },
4964
4973
  audio: !a ? void 0 : {
4965
4974
  codec: (_a$codec = a.codec) === null || _a$codec === void 0 ? void 0 : _a$codec.mimeType,
@@ -4982,7 +4991,7 @@ var QUEUE_SIZE = 5;
4982
4991
  var NetworkEvaluate = /* @__PURE__ */ function() {
4983
4992
  function NetworkEvaluate2(pc, interval) {
4984
4993
  var _this = this;
4985
- _classCallCheck$2(this, NetworkEvaluate2);
4994
+ _classCallCheck$3(this, NetworkEvaluate2);
4986
4995
  _defineProperty$2(this, "_pc", null);
4987
4996
  _defineProperty$2(this, "_lastVideoStats", null);
4988
4997
  _defineProperty$2(this, "_lastRemoteVideoStats", null);
@@ -5045,7 +5054,7 @@ var NetworkEvaluate = /* @__PURE__ */ function() {
5045
5054
  this._timerInterval = interval;
5046
5055
  this.start(interval);
5047
5056
  }
5048
- _createClass$2(NetworkEvaluate2, [{
5057
+ _createClass$3(NetworkEvaluate2, [{
5049
5058
  key: "start",
5050
5059
  value: function start(interval) {
5051
5060
  clearInterval(this._timer);
@@ -5131,13 +5140,640 @@ var NetworkEvaluate = /* @__PURE__ */ function() {
5131
5140
  }]);
5132
5141
  return NetworkEvaluate2;
5133
5142
  }();
5143
+ function isSupported() {
5144
+ if (!window.RTCPeerConnection || !window.RTCPeerConnection.prototype.addTransceiver) {
5145
+ return false;
5146
+ }
5147
+ return true;
5148
+ }
5149
+ function getCapacity() {
5150
+ if (!isSupported())
5151
+ return Promise.reject("RTCPeerConnection no support");
5152
+ var pc;
5153
+ try {
5154
+ pc = new RTCPeerConnection();
5155
+ pc.addTransceiver("video", {
5156
+ direction: "recvonly"
5157
+ });
5158
+ pc.addTransceiver("audio", {
5159
+ direction: "recvonly"
5160
+ });
5161
+ } catch (e) {
5162
+ return Promise.reject(e === null || e === void 0 ? void 0 : e.message);
5163
+ }
5164
+ return pc.createOffer().then(function(offer) {
5165
+ var _sdpJson$media, _sdpJson$media2, _vMedia$rtp, _aMedia$rtp;
5166
+ logger.log(offer.sdp);
5167
+ var sdpJson = lib.parse(offer.sdp);
5168
+ var vMedia = (_sdpJson$media = sdpJson.media) === null || _sdpJson$media === void 0 ? void 0 : _sdpJson$media.filter(function(x) {
5169
+ return x.type === "video";
5170
+ })[0];
5171
+ var aMedia = (_sdpJson$media2 = sdpJson.media) === null || _sdpJson$media2 === void 0 ? void 0 : _sdpJson$media2.filter(function(x) {
5172
+ return x.type === "audio";
5173
+ })[0];
5174
+ var vCodecs = vMedia === null || vMedia === void 0 ? void 0 : (_vMedia$rtp = vMedia.rtp) === null || _vMedia$rtp === void 0 ? void 0 : _vMedia$rtp.filter(function(x) {
5175
+ return x.codec === "VP8" || x.codec === "VP9" || x.codec === "H264";
5176
+ });
5177
+ var aCodecs = aMedia === null || aMedia === void 0 ? void 0 : (_aMedia$rtp = aMedia.rtp) === null || _aMedia$rtp === void 0 ? void 0 : _aMedia$rtp.filter(function(x) {
5178
+ return x.codec === "opus";
5179
+ });
5180
+ var vFmtp = vMedia === null || vMedia === void 0 ? void 0 : vMedia.fmtp;
5181
+ var aFmtp = aMedia === null || aMedia === void 0 ? void 0 : aMedia.fmtp;
5182
+ vFmtp && vCodecs.map(function(codec) {
5183
+ var _vFmtp$filter$;
5184
+ codec.config = (_vFmtp$filter$ = vFmtp.filter(function(x) {
5185
+ return x.payload === codec.payload;
5186
+ })[0]) === null || _vFmtp$filter$ === void 0 ? void 0 : _vFmtp$filter$.config;
5187
+ });
5188
+ aFmtp && aCodecs.map(function(codec) {
5189
+ var _aFmtp$filter$;
5190
+ codec.config = (_aFmtp$filter$ = aFmtp.filter(function(x) {
5191
+ return x.payload === codec.payload;
5192
+ })[0]) === null || _aFmtp$filter$ === void 0 ? void 0 : _aFmtp$filter$.config;
5193
+ });
5194
+ pc.close();
5195
+ return {
5196
+ video: vCodecs,
5197
+ audio: aCodecs
5198
+ };
5199
+ });
5200
+ }
5201
+ var isEncodedTransformSupported = function isEncodedTransformSupported2() {
5202
+ return typeof TransformStream !== "undefined" && typeof RTCRtpSender !== "undefined" && typeof RTCRtpReceiver !== "undefined" && typeof RTCRtpScriptTransform !== "undefined" && "transform" in RTCRtpSender.prototype && "transform" in RTCRtpReceiver.prototype && isWorkerSupported() && isMessageChannelSupported();
5203
+ };
5204
+ var isWorkerSupported = function isWorkerSupported2() {
5205
+ return typeof window !== "undefined" && window.Worker;
5206
+ };
5207
+ var isMessageChannelSupported = function isMessageChannelSupported2() {
5208
+ return typeof MessageChannel !== "undefined";
5209
+ };
5210
+ var isLegacyEncodedTransformSupported = function isLegacyEncodedTransformSupported2() {
5211
+ return typeof TransformStream !== "undefined" && typeof RTCRtpSender !== "undefined" && typeof RTCRtpReceiver !== "undefined" && typeof RTCRtpSender.prototype.createEncodedStreams !== "undefined" && typeof RTCRtpReceiver.prototype.createEncodedStreams !== "undefined";
5212
+ };
5213
+ var Nalunit = {
5214
+ getNALUnits: function getNALUnits(buffer) {
5215
+ var isH265 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
5216
+ if (buffer.length - buffer.position < 4) {
5217
+ return [];
5218
+ }
5219
+ var position = buffer.position;
5220
+ if (buffer.getInt32(position) === 1 || buffer.getInt16(position) === 0 && buffer.getInt8(position + 2) === 1) {
5221
+ return Nalunit.getAnnexbNals(buffer, isH265);
5222
+ } else {
5223
+ return Nalunit.getAvccNals(buffer, isH265);
5224
+ }
5225
+ },
5226
+ getAnnexbNals: function getAnnexbNals(buffer, isH265) {
5227
+ var nals = [];
5228
+ var position = Nalunit.getHeaderPositionAnnexB(buffer);
5229
+ var start = position.pos;
5230
+ var end = start;
5231
+ while (start < buffer.length - 4) {
5232
+ var header = new Uint8Array(buffer.buffer.slice(start, start + position.headerLength));
5233
+ if (position.pos === buffer.position) {
5234
+ buffer.skip(position.headerLength);
5235
+ }
5236
+ position = Nalunit.getHeaderPositionAnnexB(buffer);
5237
+ end = position.pos;
5238
+ var body = new Uint8Array(buffer.buffer.slice(start + header.byteLength, end));
5239
+ var unit = {
5240
+ header,
5241
+ body,
5242
+ type: -1
5243
+ };
5244
+ isH265 ? Nalunit.analyseH265Nal(unit) : Nalunit.analyseNal(unit);
5245
+ if ((unit.type <= 9 || isH265 && unit.type <= 40) && unit.type !== 0) {
5246
+ nals.push(unit);
5247
+ }
5248
+ buffer.skip(end - buffer.position);
5249
+ start = end;
5250
+ }
5251
+ return nals;
5252
+ },
5253
+ getAvccNals: function getAvccNals(buffer, isH265) {
5254
+ var nals = [];
5255
+ while (buffer.position < buffer.length - 4) {
5256
+ var length = buffer.getInt32(buffer.position);
5257
+ if (buffer.length - buffer.position >= length) {
5258
+ var header = new Uint8Array(buffer.buffer.slice(buffer.position, buffer.position + 4));
5259
+ buffer.skip(4);
5260
+ var body = new Uint8Array(buffer.buffer.slice(buffer.position, buffer.position + length));
5261
+ buffer.skip(length);
5262
+ var unit = {
5263
+ header,
5264
+ body,
5265
+ type: -1
5266
+ };
5267
+ isH265 ? Nalunit.analyseH265Nal(unit) : Nalunit.analyseNal(unit);
5268
+ if (unit.type <= 9 && unit.type !== 0) {
5269
+ nals.push(unit);
5270
+ }
5271
+ } else {
5272
+ break;
5273
+ }
5274
+ }
5275
+ return nals;
5276
+ },
5277
+ analyseNal: function analyseNal(unit) {
5278
+ var type = unit.body[0] & 31;
5279
+ unit.type = type;
5280
+ switch (type) {
5281
+ case 1:
5282
+ unit.ndr = true;
5283
+ break;
5284
+ case 5:
5285
+ unit.idr = true;
5286
+ break;
5287
+ case 6:
5288
+ unit.sei = true;
5289
+ break;
5290
+ case 7:
5291
+ unit.sps = true;
5292
+ break;
5293
+ case 8:
5294
+ unit.pps = true;
5295
+ break;
5296
+ }
5297
+ },
5298
+ analyseH265Nal: function analyseH265Nal(unit) {
5299
+ var type = (unit.body[0] & 126) >> 1;
5300
+ unit.type = type;
5301
+ switch (type) {
5302
+ case 39:
5303
+ case 40:
5304
+ unit.sei = true;
5305
+ break;
5306
+ }
5307
+ },
5308
+ getHeaderPositionAnnexB: function getHeaderPositionAnnexB(buffer) {
5309
+ var pos = buffer.position;
5310
+ var headerLength = 0;
5311
+ var bufferLen = buffer.length;
5312
+ while (headerLength !== 3 && headerLength !== 4 && pos < bufferLen - 4) {
5313
+ if (buffer.getInt16(pos) === 0) {
5314
+ if (buffer.getInt16(pos + 2) === 1) {
5315
+ headerLength = 4;
5316
+ } else if (buffer.getInt8(pos + 2) === 1) {
5317
+ headerLength = 3;
5318
+ } else {
5319
+ pos++;
5320
+ }
5321
+ } else {
5322
+ pos++;
5323
+ }
5324
+ }
5325
+ if (pos === bufferLen - 4) {
5326
+ if (buffer.getInt16(pos) === 0) {
5327
+ if (buffer.getInt16(pos + 2) === 1) {
5328
+ headerLength = 4;
5329
+ } else {
5330
+ pos = bufferLen;
5331
+ }
5332
+ } else {
5333
+ pos++;
5334
+ if (buffer.getInt16(pos) === 0 && buffer.getInt8(pos) === 1) {
5335
+ headerLength = 3;
5336
+ } else {
5337
+ pos = bufferLen;
5338
+ }
5339
+ }
5340
+ }
5341
+ return {
5342
+ pos,
5343
+ headerLength
5344
+ };
5345
+ },
5346
+ isH265VideoFrame: function isH265VideoFrame(chunk) {
5347
+ var _chunk$getMetadata, _chunk$getMetadata$ca;
5348
+ return (((_chunk$getMetadata = chunk.getMetadata) === null || _chunk$getMetadata === void 0 ? void 0 : (_chunk$getMetadata$ca = _chunk$getMetadata.call(chunk)) === null || _chunk$getMetadata$ca === void 0 ? void 0 : _chunk$getMetadata$ca.mimeType) || "").toLowerCase().includes("h265");
5349
+ }
5350
+ };
5351
+ var RTCDataView = /* @__PURE__ */ function() {
5352
+ function RTCDataView2(buffer) {
5353
+ _classCallCheck$3(this, RTCDataView2);
5354
+ _defineProperty$2(this, "_position", 0);
5355
+ this._dataview = new DataView(buffer);
5356
+ }
5357
+ _createClass$3(RTCDataView2, [{
5358
+ key: "length",
5359
+ get: function get() {
5360
+ return this.buffer.byteLength;
5361
+ }
5362
+ }, {
5363
+ key: "buffer",
5364
+ get: function get() {
5365
+ return this._dataview.buffer;
5366
+ }
5367
+ }, {
5368
+ key: "position",
5369
+ get: function get() {
5370
+ return this._position;
5371
+ },
5372
+ set: function set(value) {
5373
+ this._position = value;
5374
+ }
5375
+ }, {
5376
+ key: "back",
5377
+ value: function back(count) {
5378
+ this.position -= count;
5379
+ }
5380
+ }, {
5381
+ key: "getUint8",
5382
+ value: function getUint8(offset) {
5383
+ return this._dataview.getUint8(offset);
5384
+ }
5385
+ }, {
5386
+ key: "getInt8",
5387
+ value: function getInt8(offset) {
5388
+ return this._dataview.getInt8(offset);
5389
+ }
5390
+ }, {
5391
+ key: "getInt16",
5392
+ value: function getInt16(offset) {
5393
+ return this._dataview.getInt16(offset);
5394
+ }
5395
+ }, {
5396
+ key: "getUint16",
5397
+ value: function getUint16(offset) {
5398
+ return this._dataview.getUint16(offset);
5399
+ }
5400
+ }, {
5401
+ key: "getUint32",
5402
+ value: function getUint32(offset) {
5403
+ return this._dataview.getUint32(offset);
5404
+ }
5405
+ }, {
5406
+ key: "getInt32",
5407
+ value: function getInt32(offset) {
5408
+ return this._dataview.getInt32(offset);
5409
+ }
5410
+ }, {
5411
+ key: "skip",
5412
+ value: function skip(count) {
5413
+ var loop = Math.floor(count / 4);
5414
+ var last = count % 4;
5415
+ for (var i = 0; i < loop; i++) {
5416
+ RTCDataView2.readByte(this, 4);
5417
+ }
5418
+ if (last > 0) {
5419
+ RTCDataView2.readByte(this, last);
5420
+ }
5421
+ }
5422
+ }, {
5423
+ key: "readUint8",
5424
+ value: function readUint8() {
5425
+ return RTCDataView2.readByte(this, 1);
5426
+ }
5427
+ }, {
5428
+ key: "readUint16",
5429
+ value: function readUint16() {
5430
+ return RTCDataView2.readByte(this, 2);
5431
+ }
5432
+ }, {
5433
+ key: "readUint24",
5434
+ value: function readUint24() {
5435
+ return RTCDataView2.readByte(this, 3);
5436
+ }
5437
+ }, {
5438
+ key: "readUint32",
5439
+ value: function readUint32() {
5440
+ return RTCDataView2.readByte(this, 4);
5441
+ }
5442
+ }, {
5443
+ key: "readUint64",
5444
+ value: function readUint64() {
5445
+ return RTCDataView2.readByte(this, 8);
5446
+ }
5447
+ }, {
5448
+ key: "readInt8",
5449
+ value: function readInt8() {
5450
+ return RTCDataView2.readByte(this, 1, true);
5451
+ }
5452
+ }, {
5453
+ key: "readInt16",
5454
+ value: function readInt16() {
5455
+ return RTCDataView2.readByte(this, 2, true);
5456
+ }
5457
+ }, {
5458
+ key: "readInt32",
5459
+ value: function readInt32() {
5460
+ return RTCDataView2.readByte(this, 4, true);
5461
+ }
5462
+ }, {
5463
+ key: "writeUint32",
5464
+ value: function writeUint32(value) {
5465
+ return new Uint8Array([value >>> 24 & 255, value >>> 16 & 255, value >>> 8 & 255, value & 255]);
5466
+ }
5467
+ }], [{
5468
+ key: "readByte",
5469
+ value: function readByte(buffer, size, sign) {
5470
+ var res;
5471
+ switch (size) {
5472
+ case 1:
5473
+ if (sign) {
5474
+ res = buffer.getInt8(buffer.position);
5475
+ } else {
5476
+ res = buffer.getUint8(buffer.position);
5477
+ }
5478
+ break;
5479
+ case 2:
5480
+ if (sign) {
5481
+ res = buffer.getInt16(buffer.position);
5482
+ } else {
5483
+ res = buffer.getUint16(buffer.position);
5484
+ }
5485
+ break;
5486
+ case 3:
5487
+ if (sign) {
5488
+ throw new Error("not supported for readByte 3");
5489
+ } else {
5490
+ res = buffer.getUint8(buffer.position) << 16;
5491
+ res |= buffer.getUint8(buffer.position + 1) << 8;
5492
+ res |= buffer.getUint8(buffer.position + 2);
5493
+ }
5494
+ break;
5495
+ case 4:
5496
+ if (sign) {
5497
+ res = buffer.getInt32(buffer.position);
5498
+ } else {
5499
+ res = buffer.getUint32(buffer.position);
5500
+ }
5501
+ break;
5502
+ case 8:
5503
+ if (sign) {
5504
+ throw new Error("not supported for readBody 8");
5505
+ } else {
5506
+ res = buffer.getUint32(buffer.position) << 32;
5507
+ res |= buffer.getUint32(buffer.position + 4);
5508
+ }
5509
+ break;
5510
+ default:
5511
+ res = "";
5512
+ }
5513
+ buffer.position += size;
5514
+ return res;
5515
+ }
5516
+ }]);
5517
+ return RTCDataView2;
5518
+ }();
5519
+ function _classCallCheck(instance, Constructor) {
5520
+ if (!(instance instanceof Constructor)) {
5521
+ throw new TypeError("Cannot call a class as a function");
5522
+ }
5523
+ }
5524
+ function _defineProperties(target, props) {
5525
+ for (var i = 0; i < props.length; i++) {
5526
+ var descriptor = props[i];
5527
+ descriptor.enumerable = descriptor.enumerable || false;
5528
+ descriptor.configurable = true;
5529
+ if ("value" in descriptor)
5530
+ descriptor.writable = true;
5531
+ Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
5532
+ }
5533
+ }
5534
+ function _createClass(Constructor, protoProps, staticProps) {
5535
+ if (protoProps)
5536
+ _defineProperties(Constructor.prototype, protoProps);
5537
+ if (staticProps)
5538
+ _defineProperties(Constructor, staticProps);
5539
+ Object.defineProperty(Constructor, "prototype", {
5540
+ writable: false
5541
+ });
5542
+ return Constructor;
5543
+ }
5544
+ function _toPrimitive(input, hint) {
5545
+ if (typeof input !== "object" || input === null)
5546
+ return input;
5547
+ var prim = input[Symbol.toPrimitive];
5548
+ if (prim !== void 0) {
5549
+ var res = prim.call(input, hint || "default");
5550
+ if (typeof res !== "object")
5551
+ return res;
5552
+ throw new TypeError("@@toPrimitive must return a primitive value.");
5553
+ }
5554
+ return (hint === "string" ? String : Number)(input);
5555
+ }
5556
+ function _toPropertyKey(arg) {
5557
+ var key = _toPrimitive(arg, "string");
5558
+ return typeof key === "symbol" ? key : String(key);
5559
+ }
5560
+ function readBig32(data) {
5561
+ var i = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
5562
+ return (data[i] << 24 >>> 0) + (data[i + 1] << 16) + (data[i + 2] << 8) + (data[i + 3] || 0);
5563
+ }
5564
+ var NALu = /* @__PURE__ */ function() {
5565
+ function NALu2() {
5566
+ _classCallCheck(this, NALu2);
5567
+ }
5568
+ _createClass(NALu2, null, [{
5569
+ key: "parseAnnexB",
5570
+ value: function parseAnnexB(data) {
5571
+ var j = data.byteLength - 1;
5572
+ var dropZerosLength = 0;
5573
+ do {
5574
+ if (data[j] === 0) {
5575
+ dropZerosLength++;
5576
+ } else {
5577
+ break;
5578
+ }
5579
+ j--;
5580
+ } while (j > 0);
5581
+ if (dropZerosLength >= 3) {
5582
+ data = data.subarray(0, j + 1);
5583
+ }
5584
+ var len = data.length;
5585
+ var start = 2;
5586
+ var end = 0;
5587
+ while (data[start] !== null && data[start] !== void 0 && data[start] !== 1) {
5588
+ start++;
5589
+ }
5590
+ start++;
5591
+ end = start + 2;
5592
+ if (end >= len)
5593
+ return [];
5594
+ var units = [];
5595
+ while (end < len) {
5596
+ switch (data[end]) {
5597
+ case 0:
5598
+ if (data[end - 1] !== 0) {
5599
+ end += 2;
5600
+ break;
5601
+ } else if (data[end - 2] !== 0) {
5602
+ end++;
5603
+ break;
5604
+ } else if (end < len - 1 && data[end + 1] !== 1) {
5605
+ end++;
5606
+ break;
5607
+ }
5608
+ if (start !== end - 2)
5609
+ units.push(data.subarray(start, end - 2));
5610
+ do {
5611
+ end++;
5612
+ } while (data[end] !== 1 && end < len);
5613
+ start = end + 1;
5614
+ end = start + 2;
5615
+ break;
5616
+ case 1:
5617
+ if (data[end - 1] !== 0 || data[end - 2] !== 0) {
5618
+ end += 3;
5619
+ break;
5620
+ }
5621
+ if (start !== end - 2)
5622
+ units.push(data.subarray(start, end - 2));
5623
+ start = end + 1;
5624
+ end = start + 2;
5625
+ break;
5626
+ default:
5627
+ end += 3;
5628
+ break;
5629
+ }
5630
+ }
5631
+ if (start < len)
5632
+ units.push(data.subarray(start));
5633
+ return units;
5634
+ }
5635
+ }, {
5636
+ key: "parseAvcC",
5637
+ value: function parseAvcC(data) {
5638
+ var size = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 4;
5639
+ if (data.length < 4)
5640
+ return;
5641
+ var dataLen = data.length;
5642
+ var units = [];
5643
+ var offset = 0;
5644
+ var length;
5645
+ while (offset + size < dataLen) {
5646
+ length = readBig32(data, offset);
5647
+ if (size === 3)
5648
+ length >>>= 8;
5649
+ offset += size;
5650
+ if (!length)
5651
+ continue;
5652
+ if (offset + length > dataLen) {
5653
+ break;
5654
+ }
5655
+ units.push(data.subarray(offset, offset + length));
5656
+ offset += length;
5657
+ }
5658
+ return units;
5659
+ }
5660
+ }, {
5661
+ key: "parseSEI",
5662
+ value: function parseSEI(unit, isHevc) {
5663
+ var len = unit.length;
5664
+ var i = isHevc ? 2 : 1;
5665
+ var type = 0;
5666
+ var size = 0;
5667
+ var uuid = "";
5668
+ while (unit[i] === 255) {
5669
+ type += 255;
5670
+ i++;
5671
+ }
5672
+ type += unit[i++];
5673
+ while (unit[i] === 255) {
5674
+ size += 255;
5675
+ i++;
5676
+ }
5677
+ size += unit[i++];
5678
+ if (type === 5 && len > i + 16) {
5679
+ for (var j = 0; j < 16; j++) {
5680
+ uuid += unit[i].toString(16);
5681
+ i++;
5682
+ }
5683
+ }
5684
+ return {
5685
+ payload: unit.subarray(i, i + size),
5686
+ type,
5687
+ size,
5688
+ uuid
5689
+ };
5690
+ }
5691
+ }, {
5692
+ key: "removeEPB",
5693
+ value: function removeEPB(uint) {
5694
+ var length = uint.byteLength;
5695
+ var emulationPreventionBytesPositions = [];
5696
+ var i = 1;
5697
+ while (i < length - 2) {
5698
+ if (uint[i] === 0 && uint[i + 1] === 0 && uint[i + 2] === 3) {
5699
+ emulationPreventionBytesPositions.push(i + 2);
5700
+ i += 2;
5701
+ } else {
5702
+ i++;
5703
+ }
5704
+ }
5705
+ if (!emulationPreventionBytesPositions.length)
5706
+ return uint;
5707
+ var newLength = length - emulationPreventionBytesPositions.length;
5708
+ var newData = new Uint8Array(newLength);
5709
+ var sourceIndex = 0;
5710
+ for (i = 0; i < newLength; sourceIndex++, i++) {
5711
+ if (sourceIndex === emulationPreventionBytesPositions[0]) {
5712
+ sourceIndex++;
5713
+ emulationPreventionBytesPositions.shift();
5714
+ }
5715
+ newData[i] = uint[sourceIndex];
5716
+ }
5717
+ return newData;
5718
+ }
5719
+ }]);
5720
+ return NALu2;
5721
+ }();
5722
+ function receiveSEITransform(postMessage) {
5723
+ var transform = new TransformStream({
5724
+ transform: function transform2(encodedFrame, controller) {
5725
+ var isH265 = Nalunit.isH265VideoFrame(encodedFrame);
5726
+ var NALs = Nalunit.getNALUnits(new RTCDataView(encodedFrame.data), isH265);
5727
+ NALs.forEach(function(nalUnit) {
5728
+ if (nalUnit.sei) {
5729
+ var decodedSei = NALu.parseSEI(NALu.removeEPB(nalUnit.body), false);
5730
+ if (decodedSei) {
5731
+ postMessage({
5732
+ data: decodedSei,
5733
+ sei: {
5734
+ code: decodedSei.type,
5735
+ content: decodedSei.payload
5736
+ }
5737
+ });
5738
+ }
5739
+ }
5740
+ });
5741
+ controller.enqueue(encodedFrame);
5742
+ }
5743
+ });
5744
+ return transform;
5745
+ }
5746
+ if (typeof self !== "undefined" && self.constructor.name === "DedicatedWorkerGlobalScope") {
5747
+ self.addEventListener("rtctransform", function(event) {
5748
+ var transformer = event.transformer;
5749
+ var port = transformer.options.port;
5750
+ var transform = receiveSEITransform(function(msg) {
5751
+ port.postMessage(msg);
5752
+ });
5753
+ transformer.readable.pipeThrough(transform).pipeTo(event.transformer.writable);
5754
+ });
5755
+ }
5756
+ var encodedJs = "IWZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO3ZhciBlPXtnZXROQUxVbml0czpmdW5jdGlvbih0KXt2YXIgbj1hcmd1bWVudHMubGVuZ3RoPjEmJnZvaWQgMCE9PWFyZ3VtZW50c1sxXSYmYXJndW1lbnRzWzFdO2lmKHQubGVuZ3RoLXQucG9zaXRpb248NClyZXR1cm5bXTt2YXIgcj10LnBvc2l0aW9uO3JldHVybiAxPT09dC5nZXRJbnQzMihyKXx8MD09PXQuZ2V0SW50MTYocikmJjE9PT10LmdldEludDgocisyKT9lLmdldEFubmV4Yk5hbHModCxuKTplLmdldEF2Y2NOYWxzKHQsbil9LGdldEFubmV4Yk5hbHM6ZnVuY3Rpb24odCxuKXtmb3IodmFyIHI9W10saT1lLmdldEhlYWRlclBvc2l0aW9uQW5uZXhCKHQpLGE9aS5wb3Msbz1hO2E8dC5sZW5ndGgtNDspe3ZhciB1PW5ldyBVaW50OEFycmF5KHQuYnVmZmVyLnNsaWNlKGEsYStpLmhlYWRlckxlbmd0aCkpO2kucG9zPT09dC5wb3NpdGlvbiYmdC5za2lwKGkuaGVhZGVyTGVuZ3RoKSxvPShpPWUuZ2V0SGVhZGVyUG9zaXRpb25Bbm5leEIodCkpLnBvczt2YXIgcz17aGVhZGVyOnUsYm9keTpuZXcgVWludDhBcnJheSh0LmJ1ZmZlci5zbGljZShhK3UuYn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ludDhBcnJheShpKSxvPTA7Zm9yKHI9MDtyPGk7bysrLHIrKylvPT09blswXSYmKG8rKyxuLnNoaWZ0KCkpLGFbcl09ZVtvXTtyZXR1cm4gYX19XSwobj1udWxsKSYmYSh0LnByb3RvdHlwZSxuKSxyJiZhKHQsciksT2JqZWN0LmRlZmluZVByb3BlcnR5KHQsInByb3RvdHlwZSIse3dyaXRhYmxlOiExfSksZX0oKTsidW5kZWZpbmVkIiE9dHlwZW9mIHNlbGYmJiJEZWRpY2F0ZWRXb3JrZXJHbG9iYWxTY29wZSI9PT1zZWxmLmNvbnN0cnVjdG9yLm5hbWUmJnNlbGYuYWRkRXZlbnRMaXN0ZW5lcigicnRjdHJhbnNmb3JtIiwoZnVuY3Rpb24odCl7dmFyIG4scj10LnRyYW5zZm9ybWVyLGE9ci5vcHRpb25zLnBvcnQsbz0obj1mdW5jdGlvbihlKXthLnBvc3RNZXNzYWdlKGUpfSxuZXcgVHJhbnNmb3JtU3RyZWFtKHt0cmFuc2Zvcm06ZnVuY3Rpb24odCxyKXt2YXIgYT1lLmlzSDI2NVZpZGVvRnJhbWUodCk7ZS5nZXROQUxVbml0cyhuZXcgaSh0LmRhdGEpLGEpLmZvckVhY2goKGZ1bmN0aW9uKGUpe2lmKGUuc2VpKXt2YXIgdD11LnBhcnNlU0VJKHUucmVtb3ZlRVBCKGUuYm9keSksITEpO3QmJm4oe2RhdGE6dCxzZWk6e2NvZGU6dC50eXBlLGNvbnRlbnQ6dC5wYXlsb2FkfX0pfX0pKSxyLmVucXVldWUodCl9fSkpO3IucmVhZGFibGUucGlwZVRocm91Z2gobykucGlwZVRvKHQudHJhbnNmb3JtZXIud3JpdGFibGUpfSkpfSgpOwo=";
5757
+ var blob = typeof window !== "undefined" && window.Blob && new Blob([atob(encodedJs)], {
5758
+ type: "text/javascript;charset=utf-8"
5759
+ });
5760
+ function WorkerWrapper() {
5761
+ var objURL = blob && (window.URL || window.webkitURL).createObjectURL(blob);
5762
+ try {
5763
+ return objURL ? new Worker(objURL, {}) : new Worker("data:application/javascript;base64," + encodedJs, {
5764
+ type: "module"
5765
+ });
5766
+ } finally {
5767
+ objURL && (window.URL || window.webkitURL).revokeObjectURL(objURL);
5768
+ }
5769
+ }
5134
5770
  var logger = new Logger("rts");
5135
5771
  var Rts = /* @__PURE__ */ function(_EventEmitter) {
5136
5772
  _inherits$1(Rts2, _EventEmitter);
5137
5773
  var _super = _createSuper$1(Rts2);
5138
5774
  function Rts2(opts) {
5139
5775
  var _this;
5140
- _classCallCheck$2(this, Rts2);
5776
+ _classCallCheck$3(this, Rts2);
5141
5777
  _this = _super.call(this);
5142
5778
  _defineProperty$2(_assertThisInitialized$1(_this), "_url", "");
5143
5779
  _defineProperty$2(_assertThisInitialized$1(_this), "_pc", null);
@@ -5153,6 +5789,49 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
5153
5789
  _defineProperty$2(_assertThisInitialized$1(_this), "_waitingTimer", 0);
5154
5790
  _defineProperty$2(_assertThisInitialized$1(_this), "_rctConnectStartTs", 0);
5155
5791
  _defineProperty$2(_assertThisInitialized$1(_this), "_isReplacing", false);
5792
+ _defineProperty$2(_assertThisInitialized$1(_this), "_checkStatsErrorTimer", null);
5793
+ _defineProperty$2(_assertThisInitialized$1(_this), "_checkStatsError", /* @__PURE__ */ _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee2() {
5794
+ return _regeneratorRuntime$1().wrap(function _callee2$(_context2) {
5795
+ while (1)
5796
+ switch (_context2.prev = _context2.next) {
5797
+ case 0:
5798
+ if (_this._checkStatsErrorTimer) {
5799
+ clearTimeout(_this._checkStatsErrorTimer);
5800
+ }
5801
+ _this._checkStatsErrorTimer = setTimeout(/* @__PURE__ */ _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee() {
5802
+ var stats, _stats$video, framesDecoded, bytesReceived;
5803
+ return _regeneratorRuntime$1().wrap(function _callee$(_context) {
5804
+ while (1)
5805
+ switch (_context.prev = _context.next) {
5806
+ case 0:
5807
+ _context.next = 2;
5808
+ return _this.getStatsSnapshoot();
5809
+ case 2:
5810
+ stats = _context.sent;
5811
+ if (stats.video) {
5812
+ _stats$video = stats.video, framesDecoded = _stats$video.framesDecoded, bytesReceived = _stats$video.bytesReceived;
5813
+ if (!bytesReceived) {
5814
+ _this._emitError(StreamingError.create(ERR.MEDIA, ERR.SUB_TYPES.MEDIA_ERR_DECODE, {
5815
+ message: "rts receive empty"
5816
+ }));
5817
+ } else if (!framesDecoded) {
5818
+ _this._emitError(StreamingError.create(ERR.MEDIA, ERR.SUB_TYPES.MEDIA_ERR_DECODE, {
5819
+ message: "rts decode error"
5820
+ }));
5821
+ }
5822
+ }
5823
+ case 4:
5824
+ case "end":
5825
+ return _context.stop();
5826
+ }
5827
+ }, _callee);
5828
+ })), _this._opts.checkStatsErrorDelay);
5829
+ case 2:
5830
+ case "end":
5831
+ return _context2.stop();
5832
+ }
5833
+ }, _callee2);
5834
+ })));
5156
5835
  _defineProperty$2(_assertThisInitialized$1(_this), "_onTrack", function(e) {
5157
5836
  logger.log("addTrack: ", e.track, e.streams);
5158
5837
  _this["_".concat(e.track.kind)] = e.track;
@@ -5184,6 +5863,30 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
5184
5863
  });
5185
5864
  });
5186
5865
  });
5866
+ _defineProperty$2(_assertThisInitialized$1(_this), "_setDelay", function(delayHint) {
5867
+ if (delayHint) {
5868
+ try {
5869
+ var videoReceiver = _this._videoTransceicer.receiver;
5870
+ var audioReceiver = _this._audioTransceicer.receiver;
5871
+ if ("playoutDelayHint" in videoReceiver && "playoutDelayHint" in audioReceiver) {
5872
+ _this._audioTransceicer.receiver.playoutDelayHint = delayHint;
5873
+ _this._videoTransceicer.receiver.playoutDelayHint = delayHint;
5874
+ return;
5875
+ }
5876
+ if ("jitterBufferDelayHint" in videoReceiver && "jitterBufferDelayHint" in audioReceiver) {
5877
+ _this._audioTransceicer.receiver.jitterBufferDelayHint = delayHint;
5878
+ _this._videoTransceicer.receiver.jitterBufferDelayHint = delayHint;
5879
+ return;
5880
+ }
5881
+ if ("jitterBufferTarget" in videoReceiver && "jitterBufferTarget" in audioReceiver) {
5882
+ _this._audioTransceicer.receiver.jitterBufferTarget = delayHint * 1e3;
5883
+ _this._videoTransceicer.receiver.jitterBufferTarget = delayHint * 1e3;
5884
+ }
5885
+ } catch (error) {
5886
+ logger.error("set delay error");
5887
+ }
5888
+ }
5889
+ });
5187
5890
  _defineProperty$2(_assertThisInitialized$1(_this), "_onLoaderRetry", function(error, retryTime) {
5188
5891
  _this.emit(EVENT.LOAD_RETRY, {
5189
5892
  error: StreamingError.network(error),
@@ -5208,7 +5911,7 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
5208
5911
  }
5209
5912
  return _this;
5210
5913
  }
5211
- _createClass$2(Rts2, [{
5914
+ _createClass$3(Rts2, [{
5212
5915
  key: "pc",
5213
5916
  get: function get() {
5214
5917
  return this._pc;
@@ -5249,12 +5952,12 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
5249
5952
  }, {
5250
5953
  key: "load",
5251
5954
  value: function() {
5252
- var _load = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee(url) {
5955
+ var _load = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee3(url) {
5253
5956
  var _this2 = this;
5254
- var lastPc;
5255
- return _regeneratorRuntime$1().wrap(function _callee$(_context) {
5957
+ var lastPc, encodedTransformSupported;
5958
+ return _regeneratorRuntime$1().wrap(function _callee3$(_context3) {
5256
5959
  while (1)
5257
- switch (_context.prev = _context.next) {
5960
+ switch (_context3.prev = _context3.next) {
5258
5961
  case 0:
5259
5962
  this._disconnect();
5260
5963
  this._url = url;
@@ -5263,25 +5966,28 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
5263
5966
  if (lastPc) {
5264
5967
  lastPc.close();
5265
5968
  }
5266
- _context.prev = 5;
5267
- this._pc = new RTCPeerConnection();
5969
+ encodedTransformSupported = isLegacyEncodedTransformSupported();
5970
+ _context3.prev = 6;
5971
+ this._pc = new RTCPeerConnection({
5972
+ encodedInsertableStreams: encodedTransformSupported && this._opts.enableSei ? true : void 0
5973
+ });
5268
5974
  this._bindRTCEvents();
5269
- _context.next = 10;
5975
+ _context3.next = 11;
5270
5976
  return this._connect(url);
5271
- case 10:
5272
- _context.next = 15;
5977
+ case 11:
5978
+ _context3.next = 16;
5273
5979
  break;
5274
- case 12:
5275
- _context.prev = 12;
5276
- _context.t0 = _context["catch"](5);
5980
+ case 13:
5981
+ _context3.prev = 13;
5982
+ _context3.t0 = _context3["catch"](6);
5277
5983
  setTimeout(function() {
5278
- return _this2._emitError(StreamingError.create(ERR.OTHER, null, _context.t0));
5984
+ return _this2._emitError(StreamingError.create(ERR.OTHER, null, _context3.t0));
5279
5985
  });
5280
- case 15:
5986
+ case 16:
5281
5987
  case "end":
5282
- return _context.stop();
5988
+ return _context3.stop();
5283
5989
  }
5284
- }, _callee, this, [[5, 12]]);
5990
+ }, _callee3, this, [[6, 13]]);
5285
5991
  }));
5286
5992
  function load(_x) {
5287
5993
  return _load.apply(this, arguments);
@@ -5323,6 +6029,7 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
5323
6029
  responseUrl: _this3._url,
5324
6030
  elapsed: Date.now() - _this3._rctConnectStartTs
5325
6031
  });
6032
+ _this3._checkStatsError();
5326
6033
  }
5327
6034
  });
5328
6035
  }
@@ -5360,6 +6067,54 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
5360
6067
  }
5361
6068
  }
5362
6069
  }
6070
+ }, {
6071
+ key: "initVideoEncodedTransform",
6072
+ value: function initVideoEncodedTransform() {
6073
+ var _this5 = this;
6074
+ if (!this._videoTransceicer || !this._videoTransceicer.receiver) {
6075
+ console.log("no receiver found when trying to bind encodedTransform");
6076
+ return;
6077
+ }
6078
+ var receiver = this._videoTransceicer.receiver;
6079
+ if (isLegacyEncodedTransformSupported()) {
6080
+ var _receiver$createEncod = receiver.createEncodedStreams(), readable = _receiver$createEncod.readable, writable = _receiver$createEncod.writable;
6081
+ readable.pipeThrough(receiveSEITransform(function(sei) {
6082
+ _this5.emit(EVENT.SEI, sei);
6083
+ })).pipeTo(writable);
6084
+ } else if (isEncodedTransformSupported()) {
6085
+ var worker = new WorkerWrapper();
6086
+ var channel = new MessageChannel();
6087
+ this._videoTransceicer.receiver.transform = new RTCRtpScriptTransform(worker, {
6088
+ port: channel.port2
6089
+ }, [channel.port2]);
6090
+ channel.port1.onmessage = function(e) {
6091
+ _this5.emit(EVENT.SEI, e.data);
6092
+ };
6093
+ }
6094
+ }
6095
+ }, {
6096
+ key: "initAudioEncodedTransform",
6097
+ value: function initAudioEncodedTransform() {
6098
+ if (!this._audioTransceicer || !this._audioTransceicer.receiver) {
6099
+ logger.warn("no receiver found when trying to bind encodedTransform");
6100
+ return;
6101
+ }
6102
+ if (!isLegacyEncodedTransformSupported()) {
6103
+ logger.warn("legacy EncodedTransform is not supported");
6104
+ return;
6105
+ }
6106
+ var receiver = this._audioTransceicer.receiver;
6107
+ var _receiver$createEncod2 = receiver.createEncodedStreams(), readable = _receiver$createEncod2.readable, writable = _receiver$createEncod2.writable;
6108
+ readable.pipeThrough(new TransformStream({
6109
+ transform: function transform(chunk, controller) {
6110
+ if (chunk.data.byteLength <= 1e3) {
6111
+ controller.enqueue(chunk);
6112
+ } else {
6113
+ logger.log("too large audio frame", chunk.data.byteLength);
6114
+ }
6115
+ }
6116
+ })).pipeTo(writable);
6117
+ }
5363
6118
  }, {
5364
6119
  key: "_bindMediaEvent",
5365
6120
  value: function _bindMediaEvent() {
@@ -5369,15 +6124,15 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
5369
6124
  }, {
5370
6125
  key: "_connect",
5371
6126
  value: function() {
5372
- var _connect2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee2() {
5373
- var pc, offer, delayHint, parsed, finnalUrl, _this$_opts, _answer$remoteSdp, _this$_opts2, _answer$remoteSdp2, _parsed$media, parseSession, sessionId, reqStart, res, answer, err, _parsed;
5374
- return _regeneratorRuntime$1().wrap(function _callee2$(_context2) {
6127
+ var _connect2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee4() {
6128
+ var pc, offer, parsed, finnalUrl, _this$_opts, _answer$remoteSdp, _this$_opts2, _answer$remoteSdp2, _parsed$media, parseSession, sessionId, reqStart, res, answer, err, _parsed;
6129
+ return _regeneratorRuntime$1().wrap(function _callee4$(_context4) {
5375
6130
  while (1)
5376
- switch (_context2.prev = _context2.next) {
6131
+ switch (_context4.prev = _context4.next) {
5377
6132
  case 0:
5378
6133
  pc = this._pc;
5379
6134
  if (!pc.addTransceiver) {
5380
- _context2.next = 11;
6135
+ _context4.next = 11;
5381
6136
  break;
5382
6137
  }
5383
6138
  this._audioTransceicer = pc.addTransceiver("audio", {
@@ -5386,28 +6141,26 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
5386
6141
  this._videoTransceicer = pc.addTransceiver("video", {
5387
6142
  direction: "recvonly"
5388
6143
  });
5389
- delayHint = this._opts.delayHint;
5390
- if (delayHint) {
5391
- this._audioTransceicer.receiver.playoutDelayHint = delayHint;
5392
- this._audioTransceicer.receiver.jitterBufferDelayHint = delayHint;
5393
- this._videoTransceicer.receiver.playoutDelayHint = delayHint;
5394
- this._videoTransceicer.receiver.jitterBufferDelayHint = delayHint;
6144
+ this._setDelay(this._opts.delayHint);
6145
+ if (this._opts.enableSei) {
6146
+ this.initVideoEncodedTransform();
6147
+ this.initAudioEncodedTransform();
5395
6148
  }
5396
- _context2.next = 8;
6149
+ _context4.next = 8;
5397
6150
  return pc.createOffer();
5398
6151
  case 8:
5399
- offer = _context2.sent;
5400
- _context2.next = 14;
6152
+ offer = _context4.sent;
6153
+ _context4.next = 14;
5401
6154
  break;
5402
6155
  case 11:
5403
- _context2.next = 13;
6156
+ _context4.next = 13;
5404
6157
  return pc.createOffer({
5405
6158
  iceRestart: true,
5406
6159
  offerToReceiveAudio: true,
5407
6160
  offerToReceiveVideo: true
5408
6161
  });
5409
6162
  case 13:
5410
- offer = _context2.sent;
6163
+ offer = _context4.sent;
5411
6164
  case 14:
5412
6165
  logger.log("local offer");
5413
6166
  logger.log(offer.sdp);
@@ -5433,11 +6186,11 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
5433
6186
  });
5434
6187
  offer.sdp = lib.write(parsed);
5435
6188
  logger.log("local offer modified:\n", offer.sdp);
5436
- _context2.next = 22;
6189
+ _context4.next = 22;
5437
6190
  return pc.setLocalDescription(offer);
5438
6191
  case 22:
5439
6192
  finnalUrl = this._url;
5440
- _context2.prev = 23;
6193
+ _context4.prev = 23;
5441
6194
  if (this._opts.preProcessUrl) {
5442
6195
  finnalUrl = this._opts.preProcessUrl(finnalUrl).url;
5443
6196
  }
@@ -5450,7 +6203,7 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
5450
6203
  sessionId
5451
6204
  });
5452
6205
  reqStart = Date.now();
5453
- _context2.next = 32;
6206
+ _context4.next = 32;
5454
6207
  return this._loader.load(finnalUrl, {
5455
6208
  body: JSON.stringify({
5456
6209
  sessionId,
@@ -5459,22 +6212,22 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
5459
6212
  })
5460
6213
  });
5461
6214
  case 32:
5462
- res = _context2.sent;
6215
+ res = _context4.sent;
5463
6216
  this.emit(EVENT.LOAD_RESPONSE_HEADERS, {
5464
6217
  headers: res.response.headers
5465
6218
  });
5466
6219
  answer = res === null || res === void 0 ? void 0 : res.data;
5467
6220
  if (!((answer === null || answer === void 0 ? void 0 : answer.code) === 404 || (answer === null || answer === void 0 ? void 0 : answer.code) === 403)) {
5468
- _context2.next = 40;
6221
+ _context4.next = 40;
5469
6222
  break;
5470
6223
  }
5471
6224
  err = StreamingError.create(answer.code === 404 ? ERR.NETWORK_NOTFOUND : ERR.NETWORK_FORBIDDEN, null, answer);
5472
6225
  err.errorType = ERR.NETWORK;
5473
6226
  this._emitError(err);
5474
- return _context2.abrupt("return");
6227
+ return _context4.abrupt("return");
5475
6228
  case 40:
5476
6229
  if (!((answer === null || answer === void 0 ? void 0 : answer.code) !== 200)) {
5477
- _context2.next = 42;
6230
+ _context4.next = 42;
5478
6231
  break;
5479
6232
  }
5480
6233
  throw new Error("code: ".concat(answer === null || answer === void 0 ? void 0 : answer.code, ", message:").concat(answer === null || answer === void 0 ? void 0 : answer.message));
@@ -5500,21 +6253,21 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
5500
6253
  answer.remoteSdp.sdp = lib.write(_parsed);
5501
6254
  logger.log("answer modified:\n", answer.remoteSdp.sdp);
5502
6255
  this._rctConnectStartTs = Date.now();
5503
- _context2.next = 52;
6256
+ _context4.next = 52;
5504
6257
  return this._pc.setRemoteDescription(answer.remoteSdp);
5505
6258
  case 52:
5506
6259
  this._networkEvaluate = new NetworkEvaluate(pc, this._opts.networkEvaluateInterval);
5507
- _context2.next = 58;
6260
+ _context4.next = 58;
5508
6261
  break;
5509
6262
  case 55:
5510
- _context2.prev = 55;
5511
- _context2.t0 = _context2["catch"](23);
5512
- this._emitError(StreamingError.network(_context2.t0));
6263
+ _context4.prev = 55;
6264
+ _context4.t0 = _context4["catch"](23);
6265
+ this._emitError(StreamingError.network(_context4.t0));
5513
6266
  case 58:
5514
6267
  case "end":
5515
- return _context2.stop();
6268
+ return _context4.stop();
5516
6269
  }
5517
- }, _callee2, this, [[23, 55]]);
6270
+ }, _callee4, this, [[23, 55]]);
5518
6271
  }));
5519
6272
  function _connect() {
5520
6273
  return _connect2.apply(this, arguments);
@@ -5527,6 +6280,7 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
5527
6280
  var _this$_loader, _this$_networkEvaluat2;
5528
6281
  (_this$_loader = this._loader) === null || _this$_loader === void 0 ? void 0 : _this$_loader.cancel();
5529
6282
  (_this$_networkEvaluat2 = this._networkEvaluate) === null || _this$_networkEvaluat2 === void 0 ? void 0 : _this$_networkEvaluat2.destroy();
6283
+ clearTimeout(this._checkStatsErrorTimer);
5530
6284
  this._audioTransceicer = null;
5531
6285
  this._videoTransceicer = null;
5532
6286
  this._mediaStream = null;
@@ -5536,6 +6290,10 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
5536
6290
  key: "_emitError",
5537
6291
  value: function _emitError(error) {
5538
6292
  this.emit(EVENT.ERROR, error);
6293
+ clearTimeout(this._checkStatsErrorTimer);
6294
+ if (this._pc) {
6295
+ this._pc.close();
6296
+ }
5539
6297
  }
5540
6298
  }, {
5541
6299
  key: "destroy",
@@ -5552,6 +6310,7 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
5552
6310
  this._loader = null;
5553
6311
  this._media = null;
5554
6312
  this._pc = null;
6313
+ this._opts = null;
5555
6314
  }
5556
6315
  }], [{
5557
6316
  key: "enableLogger",
@@ -5574,70 +6333,12 @@ try {
5574
6333
  }
5575
6334
  } catch (error) {
5576
6335
  }
5577
- function isSupported() {
5578
- if (!window.RTCPeerConnection || !window.RTCPeerConnection.prototype.addTransceiver) {
5579
- return false;
5580
- }
5581
- return true;
5582
- }
5583
- function getCapacity() {
5584
- if (!isSupported())
5585
- return Promise.reject("RTCPeerConnection no support");
5586
- var pc;
5587
- try {
5588
- pc = new RTCPeerConnection();
5589
- pc.addTransceiver("video", {
5590
- direction: "recvonly"
5591
- });
5592
- pc.addTransceiver("audio", {
5593
- direction: "recvonly"
5594
- });
5595
- } catch (e) {
5596
- return Promise.reject(e === null || e === void 0 ? void 0 : e.message);
5597
- }
5598
- return pc.createOffer().then(function(offer) {
5599
- var _sdpJson$media, _sdpJson$media2, _vMedia$rtp, _aMedia$rtp;
5600
- logger.log(offer.sdp);
5601
- var sdpJson = lib.parse(offer.sdp);
5602
- var vMedia = (_sdpJson$media = sdpJson.media) === null || _sdpJson$media === void 0 ? void 0 : _sdpJson$media.filter(function(x) {
5603
- return x.type === "video";
5604
- })[0];
5605
- var aMedia = (_sdpJson$media2 = sdpJson.media) === null || _sdpJson$media2 === void 0 ? void 0 : _sdpJson$media2.filter(function(x) {
5606
- return x.type === "audio";
5607
- })[0];
5608
- var vCodecs = vMedia === null || vMedia === void 0 ? void 0 : (_vMedia$rtp = vMedia.rtp) === null || _vMedia$rtp === void 0 ? void 0 : _vMedia$rtp.filter(function(x) {
5609
- return x.codec === "VP8" || x.codec === "VP9" || x.codec === "H264";
5610
- });
5611
- var aCodecs = aMedia === null || aMedia === void 0 ? void 0 : (_aMedia$rtp = aMedia.rtp) === null || _aMedia$rtp === void 0 ? void 0 : _aMedia$rtp.filter(function(x) {
5612
- return x.codec === "opus";
5613
- });
5614
- var vFmtp = vMedia === null || vMedia === void 0 ? void 0 : vMedia.fmtp;
5615
- var aFmtp = aMedia === null || aMedia === void 0 ? void 0 : aMedia.fmtp;
5616
- vFmtp && vCodecs.map(function(codec) {
5617
- var _vFmtp$filter$;
5618
- codec.config = (_vFmtp$filter$ = vFmtp.filter(function(x) {
5619
- return x.payload === codec.payload;
5620
- })[0]) === null || _vFmtp$filter$ === void 0 ? void 0 : _vFmtp$filter$.config;
5621
- });
5622
- aFmtp && aCodecs.map(function(codec) {
5623
- var _aFmtp$filter$;
5624
- codec.config = (_aFmtp$filter$ = aFmtp.filter(function(x) {
5625
- return x.payload === codec.payload;
5626
- })[0]) === null || _aFmtp$filter$ === void 0 ? void 0 : _aFmtp$filter$.config;
5627
- });
5628
- pc.close();
5629
- return {
5630
- video: vCodecs,
5631
- audio: aCodecs
5632
- };
5633
- });
5634
- }
5635
6336
  var RtsPlugin = /* @__PURE__ */ function(_BasePlugin) {
5636
6337
  _inherits$1(RtsPlugin2, _BasePlugin);
5637
6338
  var _super = _createSuper$1(RtsPlugin2);
5638
6339
  function RtsPlugin2() {
5639
6340
  var _this;
5640
- _classCallCheck$2(this, RtsPlugin2);
6341
+ _classCallCheck$3(this, RtsPlugin2);
5641
6342
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
5642
6343
  args[_key] = arguments[_key];
5643
6344
  }
@@ -5702,7 +6403,7 @@ var RtsPlugin = /* @__PURE__ */ function(_BasePlugin) {
5702
6403
  });
5703
6404
  return _this;
5704
6405
  }
5705
- _createClass$2(RtsPlugin2, [{
6406
+ _createClass$3(RtsPlugin2, [{
5706
6407
  key: "pc",
5707
6408
  get: function get() {
5708
6409
  var _this$_rts4;
@@ -5734,7 +6435,7 @@ var RtsPlugin = /* @__PURE__ */ function(_BasePlugin) {
5734
6435
  }, {
5735
6436
  key: "version",
5736
6437
  get: function get() {
5737
- return "0.2.1-alpha.14";
6438
+ return "0.2.1-alpha.32";
5738
6439
  }
5739
6440
  }, {
5740
6441
  key: "beforePlayerInit",
@@ -5829,6 +6530,7 @@ var RtsPlugin = /* @__PURE__ */ function(_BasePlugin) {
5829
6530
  this._transCoreEvent(EVENT.LOAD_RESPONSE_HEADERS);
5830
6531
  this._transCoreEvent(EVENT.LOAD_RETRY);
5831
6532
  this._transCoreEvent(EVENT.METADATA_PARSED);
6533
+ this._transCoreEvent(EVENT.SEI);
5832
6534
  this._transCoreEvent(EXTEND_EVENTS.RTC_STATE_CHANGE);
5833
6535
  }
5834
6536
  }, {