@volcengine/veplayer-plugin 2.7.1-rc.0 → 2.7.1-rc.2

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.
@@ -368,33 +368,33 @@
368
368
  });
369
369
  };
370
370
  }
371
- function _classCallCheck$2(instance, Constructor) {
371
+ function _classCallCheck$3(instance, Constructor) {
372
372
  if (!(instance instanceof Constructor)) {
373
373
  throw new TypeError("Cannot call a class as a function");
374
374
  }
375
375
  }
376
- function _defineProperties$2(target, props) {
376
+ function _defineProperties$3(target, props) {
377
377
  for (var i = 0; i < props.length; i++) {
378
378
  var descriptor = props[i];
379
379
  descriptor.enumerable = descriptor.enumerable || false;
380
380
  descriptor.configurable = true;
381
381
  if ("value" in descriptor)
382
382
  descriptor.writable = true;
383
- Object.defineProperty(target, _toPropertyKey$2(descriptor.key), descriptor);
383
+ Object.defineProperty(target, _toPropertyKey$3(descriptor.key), descriptor);
384
384
  }
385
385
  }
386
- function _createClass$2(Constructor, protoProps, staticProps) {
386
+ function _createClass$3(Constructor, protoProps, staticProps) {
387
387
  if (protoProps)
388
- _defineProperties$2(Constructor.prototype, protoProps);
388
+ _defineProperties$3(Constructor.prototype, protoProps);
389
389
  if (staticProps)
390
- _defineProperties$2(Constructor, staticProps);
390
+ _defineProperties$3(Constructor, staticProps);
391
391
  Object.defineProperty(Constructor, "prototype", {
392
392
  writable: false
393
393
  });
394
394
  return Constructor;
395
395
  }
396
396
  function _defineProperty$2(obj, key, value) {
397
- key = _toPropertyKey$2(key);
397
+ key = _toPropertyKey$3(key);
398
398
  if (key in obj) {
399
399
  Object.defineProperty(obj, key, {
400
400
  value,
@@ -479,7 +479,7 @@
479
479
  return _possibleConstructorReturn$1(this, result);
480
480
  };
481
481
  }
482
- function _toPrimitive$2(input, hint) {
482
+ function _toPrimitive$3(input, hint) {
483
483
  if (typeof input !== "object" || input === null)
484
484
  return input;
485
485
  var prim = input[Symbol.toPrimitive];
@@ -491,8 +491,8 @@
491
491
  }
492
492
  return (hint === "string" ? String : Number)(input);
493
493
  }
494
- function _toPropertyKey$2(arg) {
495
- var key = _toPrimitive$2(arg, "string");
494
+ function _toPropertyKey$3(arg) {
495
+ var key = _toPrimitive$3(arg, "string");
496
496
  return typeof key === "symbol" ? key : String(key);
497
497
  }
498
498
  function ownKeys$1(object, enumerableOnly) {
@@ -524,33 +524,33 @@
524
524
  return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
525
525
  }, _typeof$1(obj);
526
526
  }
527
- function _classCallCheck$1(instance, Constructor) {
527
+ function _classCallCheck$2(instance, Constructor) {
528
528
  if (!(instance instanceof Constructor)) {
529
529
  throw new TypeError("Cannot call a class as a function");
530
530
  }
531
531
  }
532
- function _defineProperties$1(target, props) {
532
+ function _defineProperties$2(target, props) {
533
533
  for (var i = 0; i < props.length; i++) {
534
534
  var descriptor = props[i];
535
535
  descriptor.enumerable = descriptor.enumerable || false;
536
536
  descriptor.configurable = true;
537
537
  if ("value" in descriptor)
538
538
  descriptor.writable = true;
539
- Object.defineProperty(target, _toPropertyKey$1(descriptor.key), descriptor);
539
+ Object.defineProperty(target, _toPropertyKey$2(descriptor.key), descriptor);
540
540
  }
541
541
  }
542
- function _createClass$1(Constructor, protoProps, staticProps) {
542
+ function _createClass$2(Constructor, protoProps, staticProps) {
543
543
  if (protoProps)
544
- _defineProperties$1(Constructor.prototype, protoProps);
544
+ _defineProperties$2(Constructor.prototype, protoProps);
545
545
  if (staticProps)
546
- _defineProperties$1(Constructor, staticProps);
546
+ _defineProperties$2(Constructor, staticProps);
547
547
  Object.defineProperty(Constructor, "prototype", {
548
548
  writable: false
549
549
  });
550
550
  return Constructor;
551
551
  }
552
552
  function _defineProperty$1(obj, key, value) {
553
- key = _toPropertyKey$1(key);
553
+ key = _toPropertyKey$2(key);
554
554
  if (key in obj) {
555
555
  Object.defineProperty(obj, key, {
556
556
  value,
@@ -597,7 +597,7 @@
597
597
  function _nonIterableSpread() {
598
598
  throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
599
599
  }
600
- function _toPrimitive$1(input, hint) {
600
+ function _toPrimitive$2(input, hint) {
601
601
  if (typeof input !== "object" || input === null)
602
602
  return input;
603
603
  var prim = input[Symbol.toPrimitive];
@@ -609,8 +609,8 @@
609
609
  }
610
610
  return (hint === "string" ? String : Number)(input);
611
611
  }
612
- function _toPropertyKey$1(arg) {
613
- var key = _toPrimitive$1(arg, "string");
612
+ function _toPropertyKey$2(arg) {
613
+ var key = _toPrimitive$2(arg, "string");
614
614
  return typeof key === "symbol" ? key : String(key);
615
615
  }
616
616
  function getDefaultExportFromCjs(x) {
@@ -834,10 +834,10 @@
834
834
  };
835
835
  var XgplayerTimeRange = /* @__PURE__ */ function() {
836
836
  function XgplayerTimeRange2(bufferedList) {
837
- _classCallCheck$1(this, XgplayerTimeRange2);
837
+ _classCallCheck$2(this, XgplayerTimeRange2);
838
838
  this.bufferedList = bufferedList;
839
839
  }
840
- _createClass$1(XgplayerTimeRange2, [{
840
+ _createClass$2(XgplayerTimeRange2, [{
841
841
  key: "start",
842
842
  value: function start(index) {
843
843
  return this.bufferedList[index].start;
@@ -1543,7 +1543,7 @@
1543
1543
  5: 5105,
1544
1544
  6: 5106
1545
1545
  };
1546
- var Errors = /* @__PURE__ */ _createClass$1(
1546
+ var Errors = /* @__PURE__ */ _createClass$2(
1547
1547
  function Errors2(player) {
1548
1548
  var errorInfo = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
1549
1549
  errorType: "",
@@ -1553,7 +1553,7 @@
1553
1553
  ext: {},
1554
1554
  mediaError: null
1555
1555
  };
1556
- _classCallCheck$1(this, Errors2);
1556
+ _classCallCheck$2(this, Errors2);
1557
1557
  var ERROR_TYPES = player && player.i18n ? player.i18n.ERROR_TYPES : null;
1558
1558
  if (player.media) {
1559
1559
  var mediaError = errorInfo.mediaError ? errorInfo.mediaError : player.media.error || {};
@@ -1770,7 +1770,7 @@
1770
1770
  }
1771
1771
  var BasePlugin = /* @__PURE__ */ function() {
1772
1772
  function BasePlugin2(args) {
1773
- _classCallCheck$1(this, BasePlugin2);
1773
+ _classCallCheck$2(this, BasePlugin2);
1774
1774
  if (util.checkIsFunction(this.beforeCreate)) {
1775
1775
  this.beforeCreate(args);
1776
1776
  }
@@ -1784,7 +1784,7 @@
1784
1784
  this.pluginName = "";
1785
1785
  this.__init(args);
1786
1786
  }
1787
- _createClass$1(BasePlugin2, [{
1787
+ _createClass$2(BasePlugin2, [{
1788
1788
  key: "beforeCreate",
1789
1789
  value: function beforeCreate(args) {
1790
1790
  }
@@ -2403,33 +2403,33 @@
2403
2403
  });
2404
2404
  };
2405
2405
  }
2406
- function _classCallCheck(instance, Constructor) {
2406
+ function _classCallCheck$1(instance, Constructor) {
2407
2407
  if (!(instance instanceof Constructor)) {
2408
2408
  throw new TypeError("Cannot call a class as a function");
2409
2409
  }
2410
2410
  }
2411
- function _defineProperties(target, props) {
2411
+ function _defineProperties$1(target, props) {
2412
2412
  for (var i = 0; i < props.length; i++) {
2413
2413
  var descriptor = props[i];
2414
2414
  descriptor.enumerable = descriptor.enumerable || false;
2415
2415
  descriptor.configurable = true;
2416
2416
  if ("value" in descriptor)
2417
2417
  descriptor.writable = true;
2418
- Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
2418
+ Object.defineProperty(target, _toPropertyKey$1(descriptor.key), descriptor);
2419
2419
  }
2420
2420
  }
2421
- function _createClass(Constructor, protoProps, staticProps) {
2421
+ function _createClass$1(Constructor, protoProps, staticProps) {
2422
2422
  if (protoProps)
2423
- _defineProperties(Constructor.prototype, protoProps);
2423
+ _defineProperties$1(Constructor.prototype, protoProps);
2424
2424
  if (staticProps)
2425
- _defineProperties(Constructor, staticProps);
2425
+ _defineProperties$1(Constructor, staticProps);
2426
2426
  Object.defineProperty(Constructor, "prototype", {
2427
2427
  writable: false
2428
2428
  });
2429
2429
  return Constructor;
2430
2430
  }
2431
2431
  function _defineProperty(obj, key, value) {
2432
- key = _toPropertyKey(key);
2432
+ key = _toPropertyKey$1(key);
2433
2433
  if (key in obj) {
2434
2434
  Object.defineProperty(obj, key, {
2435
2435
  value,
@@ -2692,7 +2692,7 @@
2692
2692
  }
2693
2693
  };
2694
2694
  }
2695
- function _toPrimitive(input, hint) {
2695
+ function _toPrimitive$1(input, hint) {
2696
2696
  if (typeof input !== "object" || input === null)
2697
2697
  return input;
2698
2698
  var prim = input[Symbol.toPrimitive];
@@ -2704,8 +2704,8 @@
2704
2704
  }
2705
2705
  return (hint === "string" ? String : Number)(input);
2706
2706
  }
2707
- function _toPropertyKey(arg) {
2708
- var key = _toPrimitive(arg, "string");
2707
+ function _toPropertyKey$1(arg) {
2708
+ var key = _toPrimitive$1(arg, "string");
2709
2709
  return typeof key === "symbol" ? key : String(key);
2710
2710
  }
2711
2711
  function createPublicPromise() {
@@ -2804,7 +2804,7 @@
2804
2804
  var _super = _createSuper(StreamingError2);
2805
2805
  function StreamingError2(type, subType, origin, payload, msg) {
2806
2806
  var _this;
2807
- _classCallCheck(this, StreamingError2);
2807
+ _classCallCheck$1(this, StreamingError2);
2808
2808
  _this = _super.call(this, msg || (origin === null || origin === void 0 ? void 0 : origin.message));
2809
2809
  _this.errorType = type === ERR.NETWORK_TIMEOUT ? ERR.NETWORK : type;
2810
2810
  _this.originError = origin;
@@ -2817,7 +2817,7 @@
2817
2817
  }
2818
2818
  return _this;
2819
2819
  }
2820
- _createClass(StreamingError2, null, [{
2820
+ _createClass$1(StreamingError2, null, [{
2821
2821
  key: "create",
2822
2822
  value: function create(type, subType, origin, payload, msg) {
2823
2823
  if (type instanceof StreamingError2) {
@@ -2853,7 +2853,7 @@
2853
2853
  var SIMPLE_TYPE = ["Boolean", "Number", "String", "Undefined", "Null", "Date", "Object"];
2854
2854
  var Logger = /* @__PURE__ */ function() {
2855
2855
  function Logger2(name, config) {
2856
- _classCallCheck(this, Logger2);
2856
+ _classCallCheck$1(this, Logger2);
2857
2857
  this.name = name || "";
2858
2858
  this._prefix = "[".concat(this.name, "]");
2859
2859
  this.logCacheLevel = (config === null || config === void 0 ? void 0 : config.logCacheLevel) || 3;
@@ -2861,7 +2861,7 @@
2861
2861
  this.logSize = 0;
2862
2862
  this.logTextArray = [];
2863
2863
  }
2864
- _createClass(Logger2, [{
2864
+ _createClass$1(Logger2, [{
2865
2865
  key: "debug",
2866
2866
  value: function debug() {
2867
2867
  var _console;
@@ -3039,7 +3039,7 @@
3039
3039
  var _super = _createSuper(NetError2);
3040
3040
  function NetError2(url, request, response, msg) {
3041
3041
  var _this;
3042
- _classCallCheck(this, NetError2);
3042
+ _classCallCheck$1(this, NetError2);
3043
3043
  _this = _super.call(this, msg);
3044
3044
  _defineProperty(_assertThisInitialized(_this), "retryCount", 0);
3045
3045
  _defineProperty(_assertThisInitialized(_this), "isTimeout", false);
@@ -3052,7 +3052,7 @@
3052
3052
  _this.response = response;
3053
3053
  return _this;
3054
3054
  }
3055
- return _createClass(NetError2);
3055
+ return _createClass$1(NetError2);
3056
3056
  }(/* @__PURE__ */ _wrapNativeSuper(Error));
3057
3057
  var toString = Object.prototype.toString;
3058
3058
  function isObject(a) {
@@ -3177,7 +3177,7 @@
3177
3177
  var _super = _createSuper(FetchLoader2);
3178
3178
  function FetchLoader2() {
3179
3179
  var _this;
3180
- _classCallCheck(this, FetchLoader2);
3180
+ _classCallCheck$1(this, FetchLoader2);
3181
3181
  _this = _super.call(this);
3182
3182
  _defineProperty(_assertThisInitialized(_this), "_abortController", null);
3183
3183
  _defineProperty(_assertThisInitialized(_this), "_timeoutTimer", null);
@@ -3195,7 +3195,7 @@
3195
3195
  _defineProperty(_assertThisInitialized(_this), "_priOptions", null);
3196
3196
  return _this;
3197
3197
  }
3198
- _createClass(FetchLoader2, [{
3198
+ _createClass$1(FetchLoader2, [{
3199
3199
  key: "load",
3200
3200
  value: function load(_ref) {
3201
3201
  var _this$_abortControlle, _this2 = this;
@@ -3629,7 +3629,7 @@
3629
3629
  var _super = _createSuper(XhrLoader2);
3630
3630
  function XhrLoader2() {
3631
3631
  var _this;
3632
- _classCallCheck(this, XhrLoader2);
3632
+ _classCallCheck$1(this, XhrLoader2);
3633
3633
  _this = _super.call(this);
3634
3634
  _defineProperty(_assertThisInitialized(_this), "_xhr", null);
3635
3635
  _defineProperty(_assertThisInitialized(_this), "_aborted", false);
@@ -3659,7 +3659,7 @@
3659
3659
  _defineProperty(_assertThisInitialized(_this), "_priOptions", null);
3660
3660
  return _this;
3661
3661
  }
3662
- _createClass(XhrLoader2, [{
3662
+ _createClass$1(XhrLoader2, [{
3663
3663
  key: "load",
3664
3664
  value: function load(req) {
3665
3665
  var _this2 = this;
@@ -3944,7 +3944,7 @@
3944
3944
  var _excluded = ["retry", "retryDelay", "onRetryError", "transformError"];
3945
3945
  var Task = /* @__PURE__ */ function() {
3946
3946
  function Task2(type, config) {
3947
- _classCallCheck(this, Task2);
3947
+ _classCallCheck$1(this, Task2);
3948
3948
  this.promise = createPublicPromise();
3949
3949
  this.alive = !!config.onProgress;
3950
3950
  !config.logger && (config.logger = new Logger("Loader"));
@@ -3957,7 +3957,7 @@
3957
3957
  this._retryCheckFunc = config.retryCheckFunc;
3958
3958
  this._logger = config.logger;
3959
3959
  }
3960
- _createClass(Task2, [{
3960
+ _createClass$1(Task2, [{
3961
3961
  key: "exec",
3962
3962
  value: function exec() {
3963
3963
  var _this = this;
@@ -4076,7 +4076,7 @@
4076
4076
  var _super = _createSuper(NetLoader2);
4077
4077
  function NetLoader2(cfg) {
4078
4078
  var _this;
4079
- _classCallCheck(this, NetLoader2);
4079
+ _classCallCheck$1(this, NetLoader2);
4080
4080
  _this = _super.call(this, cfg);
4081
4081
  _defineProperty(_assertThisInitialized(_this), "type", LoaderType.FETCH);
4082
4082
  _defineProperty(_assertThisInitialized(_this), "_queue", []);
@@ -4091,7 +4091,7 @@
4091
4091
  _this.log = cfg.logger;
4092
4092
  return _this;
4093
4093
  }
4094
- _createClass(NetLoader2, [{
4094
+ _createClass$1(NetLoader2, [{
4095
4095
  key: "isFetch",
4096
4096
  value: function isFetch() {
4097
4097
  return this.type === LoaderType.FETCH;
@@ -4885,7 +4885,9 @@
4885
4885
  networkEvaluateInterval: 1e3,
4886
4886
  delayHint: 0,
4887
4887
  seamlesslyReload: false,
4888
- enableOriginSdpLogger: false
4888
+ enableSei: false,
4889
+ enableOriginSdpLogger: false,
4890
+ checkStatsErrorDelay: 5e3
4889
4891
  }, opts);
4890
4892
  }
4891
4893
  function _getStats(stats) {
@@ -4900,10 +4902,11 @@
4900
4902
  }
4901
4903
  });
4902
4904
  return inboundRtps.map(function(inbound) {
4905
+ var _inbound$mediaType;
4903
4906
  var codec = stats.get(inbound.codecId);
4904
4907
  var track = stats.get(inbound.trackId);
4905
4908
  return {
4906
- type: inbound.mediaType,
4909
+ type: (_inbound$mediaType = inbound.mediaType) !== null && _inbound$mediaType !== void 0 ? _inbound$mediaType : inbound.kind,
4907
4910
  inboundRtp: inbound,
4908
4911
  remoteOutBoundRtp: remoteOutboundRtps.find(function(x) {
4909
4912
  return x.mediaType === inbound.mediaType;
@@ -4923,7 +4926,7 @@
4923
4926
  });
4924
4927
  }
4925
4928
  function getStatsSnapshoot(stats) {
4926
- 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;
4929
+ 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;
4927
4930
  var v = stats === null || stats === void 0 ? void 0 : stats.filter(function(x) {
4928
4931
  return x.type === "video";
4929
4932
  })[0];
@@ -4932,6 +4935,7 @@
4932
4935
  })[0];
4933
4936
  var videoRemote;
4934
4937
  var audioRemote;
4938
+ var averageJitterBufferDelay;
4935
4939
  if (v && v.remoteOutBoundRtp) {
4936
4940
  videoRemote = {
4937
4941
  bytesSent: v.remoteOutBoundRtp.bytesSent,
@@ -4944,26 +4948,31 @@
4944
4948
  packetsSent: a.remoteOutBoundRtp.packetsSent
4945
4949
  };
4946
4950
  }
4951
+ if ((v === null || v === void 0 ? void 0 : (_v$inboundRtp = v.inboundRtp) === null || _v$inboundRtp === void 0 ? void 0 : _v$inboundRtp.jitterBufferDelay) !== void 0) {
4952
+ var _v$inboundRtp2, _v$inboundRtp3;
4953
+ 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;
4954
+ }
4947
4955
  return {
4948
4956
  video: !v ? void 0 : {
4949
4957
  codec: (_v$codec = v.codec) === null || _v$codec === void 0 ? void 0 : _v$codec.mimeType,
4950
4958
  payloadType: (_v$codec2 = v.codec) === null || _v$codec2 === void 0 ? void 0 : _v$codec2.payloadType,
4951
4959
  sdpFmtpLine: (_v$codec3 = v.codec) === null || _v$codec3 === void 0 ? void 0 : _v$codec3.sdpFmtpLine,
4952
- bytesReceived: ((_v$inboundRtp = v.inboundRtp) === null || _v$inboundRtp === void 0 ? void 0 : _v$inboundRtp.bytesReceived) || 0,
4953
- firCount: (_v$inboundRtp2 = v.inboundRtp) === null || _v$inboundRtp2 === void 0 ? void 0 : _v$inboundRtp2.firCount,
4954
- pliCount: (_v$inboundRtp3 = v.inboundRtp) === null || _v$inboundRtp3 === void 0 ? void 0 : _v$inboundRtp3.pliCount,
4955
- frameHeight: (_v$inboundRtp4 = v.inboundRtp) === null || _v$inboundRtp4 === void 0 ? void 0 : _v$inboundRtp4.frameHeight,
4956
- frameWidth: (_v$inboundRtp5 = v.inboundRtp) === null || _v$inboundRtp5 === void 0 ? void 0 : _v$inboundRtp5.frameWidth,
4957
- framesDecoded: (_v$inboundRtp6 = v.inboundRtp) === null || _v$inboundRtp6 === void 0 ? void 0 : _v$inboundRtp6.framesDecoded,
4958
- framesDropped: (_v$inboundRtp7 = v.inboundRtp) === null || _v$inboundRtp7 === void 0 ? void 0 : _v$inboundRtp7.framesDropped,
4959
- framesPerSecond: (_v$inboundRtp8 = v.inboundRtp) === null || _v$inboundRtp8 === void 0 ? void 0 : _v$inboundRtp8.framesPerSecond,
4960
- framesReceived: (_v$inboundRtp9 = v.inboundRtp) === null || _v$inboundRtp9 === void 0 ? void 0 : _v$inboundRtp9.framesReceived,
4961
- jitter: (_v$inboundRtp10 = v.inboundRtp) === null || _v$inboundRtp10 === void 0 ? void 0 : _v$inboundRtp10.jitter,
4962
- jitterBufferDelay: (_v$inboundRtp11 = v.inboundRtp) === null || _v$inboundRtp11 === void 0 ? void 0 : _v$inboundRtp11.jitterBufferDelay,
4963
- keyFramesDecoded: (_v$inboundRtp12 = v.inboundRtp) === null || _v$inboundRtp12 === void 0 ? void 0 : _v$inboundRtp12.keyFramesDecoded,
4964
- nackCount: (_v$inboundRtp13 = v.inboundRtp) === null || _v$inboundRtp13 === void 0 ? void 0 : _v$inboundRtp13.nackCount,
4965
- packetsLost: ((_v$inboundRtp14 = v.inboundRtp) === null || _v$inboundRtp14 === void 0 ? void 0 : _v$inboundRtp14.packetsLost) || 0,
4966
- packetsReceived: ((_v$inboundRtp15 = v.inboundRtp) === null || _v$inboundRtp15 === void 0 ? void 0 : _v$inboundRtp15.packetsReceived) || 0
4960
+ bytesReceived: ((_v$inboundRtp4 = v.inboundRtp) === null || _v$inboundRtp4 === void 0 ? void 0 : _v$inboundRtp4.bytesReceived) || 0,
4961
+ firCount: (_v$inboundRtp5 = v.inboundRtp) === null || _v$inboundRtp5 === void 0 ? void 0 : _v$inboundRtp5.firCount,
4962
+ pliCount: (_v$inboundRtp6 = v.inboundRtp) === null || _v$inboundRtp6 === void 0 ? void 0 : _v$inboundRtp6.pliCount,
4963
+ frameHeight: (_v$inboundRtp7 = v.inboundRtp) === null || _v$inboundRtp7 === void 0 ? void 0 : _v$inboundRtp7.frameHeight,
4964
+ frameWidth: (_v$inboundRtp8 = v.inboundRtp) === null || _v$inboundRtp8 === void 0 ? void 0 : _v$inboundRtp8.frameWidth,
4965
+ framesDecoded: (_v$inboundRtp9 = v.inboundRtp) === null || _v$inboundRtp9 === void 0 ? void 0 : _v$inboundRtp9.framesDecoded,
4966
+ framesDropped: (_v$inboundRtp10 = v.inboundRtp) === null || _v$inboundRtp10 === void 0 ? void 0 : _v$inboundRtp10.framesDropped,
4967
+ framesPerSecond: (_v$inboundRtp11 = v.inboundRtp) === null || _v$inboundRtp11 === void 0 ? void 0 : _v$inboundRtp11.framesPerSecond,
4968
+ 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,
4969
+ jitter: (_v$inboundRtp13 = v.inboundRtp) === null || _v$inboundRtp13 === void 0 ? void 0 : _v$inboundRtp13.jitter,
4970
+ jitterBufferDelay: (_v$inboundRtp14 = v.inboundRtp) === null || _v$inboundRtp14 === void 0 ? void 0 : _v$inboundRtp14.jitterBufferDelay,
4971
+ keyFramesDecoded: (_v$inboundRtp15 = v.inboundRtp) === null || _v$inboundRtp15 === void 0 ? void 0 : _v$inboundRtp15.keyFramesDecoded,
4972
+ nackCount: (_v$inboundRtp16 = v.inboundRtp) === null || _v$inboundRtp16 === void 0 ? void 0 : _v$inboundRtp16.nackCount,
4973
+ packetsLost: ((_v$inboundRtp17 = v.inboundRtp) === null || _v$inboundRtp17 === void 0 ? void 0 : _v$inboundRtp17.packetsLost) || 0,
4974
+ packetsReceived: ((_v$inboundRtp18 = v.inboundRtp) === null || _v$inboundRtp18 === void 0 ? void 0 : _v$inboundRtp18.packetsReceived) || 0,
4975
+ averageJitterBufferDelay
4967
4976
  },
4968
4977
  audio: !a ? void 0 : {
4969
4978
  codec: (_a$codec = a.codec) === null || _a$codec === void 0 ? void 0 : _a$codec.mimeType,
@@ -4986,7 +4995,7 @@
4986
4995
  var NetworkEvaluate = /* @__PURE__ */ function() {
4987
4996
  function NetworkEvaluate2(pc, interval) {
4988
4997
  var _this = this;
4989
- _classCallCheck$2(this, NetworkEvaluate2);
4998
+ _classCallCheck$3(this, NetworkEvaluate2);
4990
4999
  _defineProperty$2(this, "_pc", null);
4991
5000
  _defineProperty$2(this, "_lastVideoStats", null);
4992
5001
  _defineProperty$2(this, "_lastRemoteVideoStats", null);
@@ -5049,7 +5058,7 @@
5049
5058
  this._timerInterval = interval;
5050
5059
  this.start(interval);
5051
5060
  }
5052
- _createClass$2(NetworkEvaluate2, [{
5061
+ _createClass$3(NetworkEvaluate2, [{
5053
5062
  key: "start",
5054
5063
  value: function start(interval) {
5055
5064
  clearInterval(this._timer);
@@ -5135,13 +5144,640 @@
5135
5144
  }]);
5136
5145
  return NetworkEvaluate2;
5137
5146
  }();
5147
+ function isSupported() {
5148
+ if (!window.RTCPeerConnection || !window.RTCPeerConnection.prototype.addTransceiver) {
5149
+ return false;
5150
+ }
5151
+ return true;
5152
+ }
5153
+ function getCapacity() {
5154
+ if (!isSupported())
5155
+ return Promise.reject("RTCPeerConnection no support");
5156
+ var pc;
5157
+ try {
5158
+ pc = new RTCPeerConnection();
5159
+ pc.addTransceiver("video", {
5160
+ direction: "recvonly"
5161
+ });
5162
+ pc.addTransceiver("audio", {
5163
+ direction: "recvonly"
5164
+ });
5165
+ } catch (e) {
5166
+ return Promise.reject(e === null || e === void 0 ? void 0 : e.message);
5167
+ }
5168
+ return pc.createOffer().then(function(offer) {
5169
+ var _sdpJson$media, _sdpJson$media2, _vMedia$rtp, _aMedia$rtp;
5170
+ logger.log(offer.sdp);
5171
+ var sdpJson = lib.parse(offer.sdp);
5172
+ var vMedia = (_sdpJson$media = sdpJson.media) === null || _sdpJson$media === void 0 ? void 0 : _sdpJson$media.filter(function(x) {
5173
+ return x.type === "video";
5174
+ })[0];
5175
+ var aMedia = (_sdpJson$media2 = sdpJson.media) === null || _sdpJson$media2 === void 0 ? void 0 : _sdpJson$media2.filter(function(x) {
5176
+ return x.type === "audio";
5177
+ })[0];
5178
+ 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) {
5179
+ return x.codec === "VP8" || x.codec === "VP9" || x.codec === "H264";
5180
+ });
5181
+ 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) {
5182
+ return x.codec === "opus";
5183
+ });
5184
+ var vFmtp = vMedia === null || vMedia === void 0 ? void 0 : vMedia.fmtp;
5185
+ var aFmtp = aMedia === null || aMedia === void 0 ? void 0 : aMedia.fmtp;
5186
+ vFmtp && vCodecs.map(function(codec) {
5187
+ var _vFmtp$filter$;
5188
+ codec.config = (_vFmtp$filter$ = vFmtp.filter(function(x) {
5189
+ return x.payload === codec.payload;
5190
+ })[0]) === null || _vFmtp$filter$ === void 0 ? void 0 : _vFmtp$filter$.config;
5191
+ });
5192
+ aFmtp && aCodecs.map(function(codec) {
5193
+ var _aFmtp$filter$;
5194
+ codec.config = (_aFmtp$filter$ = aFmtp.filter(function(x) {
5195
+ return x.payload === codec.payload;
5196
+ })[0]) === null || _aFmtp$filter$ === void 0 ? void 0 : _aFmtp$filter$.config;
5197
+ });
5198
+ pc.close();
5199
+ return {
5200
+ video: vCodecs,
5201
+ audio: aCodecs
5202
+ };
5203
+ });
5204
+ }
5205
+ var isEncodedTransformSupported = function isEncodedTransformSupported2() {
5206
+ return typeof TransformStream !== "undefined" && typeof RTCRtpSender !== "undefined" && typeof RTCRtpReceiver !== "undefined" && typeof RTCRtpScriptTransform !== "undefined" && "transform" in RTCRtpSender.prototype && "transform" in RTCRtpReceiver.prototype && isWorkerSupported() && isMessageChannelSupported();
5207
+ };
5208
+ var isWorkerSupported = function isWorkerSupported2() {
5209
+ return typeof window !== "undefined" && window.Worker;
5210
+ };
5211
+ var isMessageChannelSupported = function isMessageChannelSupported2() {
5212
+ return typeof MessageChannel !== "undefined";
5213
+ };
5214
+ var isLegacyEncodedTransformSupported = function isLegacyEncodedTransformSupported2() {
5215
+ return typeof TransformStream !== "undefined" && typeof RTCRtpSender !== "undefined" && typeof RTCRtpReceiver !== "undefined" && typeof RTCRtpSender.prototype.createEncodedStreams !== "undefined" && typeof RTCRtpReceiver.prototype.createEncodedStreams !== "undefined";
5216
+ };
5217
+ var Nalunit = {
5218
+ getNALUnits: function getNALUnits(buffer) {
5219
+ var isH265 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
5220
+ if (buffer.length - buffer.position < 4) {
5221
+ return [];
5222
+ }
5223
+ var position = buffer.position;
5224
+ if (buffer.getInt32(position) === 1 || buffer.getInt16(position) === 0 && buffer.getInt8(position + 2) === 1) {
5225
+ return Nalunit.getAnnexbNals(buffer, isH265);
5226
+ } else {
5227
+ return Nalunit.getAvccNals(buffer, isH265);
5228
+ }
5229
+ },
5230
+ getAnnexbNals: function getAnnexbNals(buffer, isH265) {
5231
+ var nals = [];
5232
+ var position = Nalunit.getHeaderPositionAnnexB(buffer);
5233
+ var start = position.pos;
5234
+ var end = start;
5235
+ while (start < buffer.length - 4) {
5236
+ var header = new Uint8Array(buffer.buffer.slice(start, start + position.headerLength));
5237
+ if (position.pos === buffer.position) {
5238
+ buffer.skip(position.headerLength);
5239
+ }
5240
+ position = Nalunit.getHeaderPositionAnnexB(buffer);
5241
+ end = position.pos;
5242
+ var body = new Uint8Array(buffer.buffer.slice(start + header.byteLength, end));
5243
+ var unit = {
5244
+ header,
5245
+ body,
5246
+ type: -1
5247
+ };
5248
+ isH265 ? Nalunit.analyseH265Nal(unit) : Nalunit.analyseNal(unit);
5249
+ if ((unit.type <= 9 || isH265 && unit.type <= 40) && unit.type !== 0) {
5250
+ nals.push(unit);
5251
+ }
5252
+ buffer.skip(end - buffer.position);
5253
+ start = end;
5254
+ }
5255
+ return nals;
5256
+ },
5257
+ getAvccNals: function getAvccNals(buffer, isH265) {
5258
+ var nals = [];
5259
+ while (buffer.position < buffer.length - 4) {
5260
+ var length = buffer.getInt32(buffer.position);
5261
+ if (buffer.length - buffer.position >= length) {
5262
+ var header = new Uint8Array(buffer.buffer.slice(buffer.position, buffer.position + 4));
5263
+ buffer.skip(4);
5264
+ var body = new Uint8Array(buffer.buffer.slice(buffer.position, buffer.position + length));
5265
+ buffer.skip(length);
5266
+ var unit = {
5267
+ header,
5268
+ body,
5269
+ type: -1
5270
+ };
5271
+ isH265 ? Nalunit.analyseH265Nal(unit) : Nalunit.analyseNal(unit);
5272
+ if (unit.type <= 9 && unit.type !== 0) {
5273
+ nals.push(unit);
5274
+ }
5275
+ } else {
5276
+ break;
5277
+ }
5278
+ }
5279
+ return nals;
5280
+ },
5281
+ analyseNal: function analyseNal(unit) {
5282
+ var type = unit.body[0] & 31;
5283
+ unit.type = type;
5284
+ switch (type) {
5285
+ case 1:
5286
+ unit.ndr = true;
5287
+ break;
5288
+ case 5:
5289
+ unit.idr = true;
5290
+ break;
5291
+ case 6:
5292
+ unit.sei = true;
5293
+ break;
5294
+ case 7:
5295
+ unit.sps = true;
5296
+ break;
5297
+ case 8:
5298
+ unit.pps = true;
5299
+ break;
5300
+ }
5301
+ },
5302
+ analyseH265Nal: function analyseH265Nal(unit) {
5303
+ var type = (unit.body[0] & 126) >> 1;
5304
+ unit.type = type;
5305
+ switch (type) {
5306
+ case 39:
5307
+ case 40:
5308
+ unit.sei = true;
5309
+ break;
5310
+ }
5311
+ },
5312
+ getHeaderPositionAnnexB: function getHeaderPositionAnnexB(buffer) {
5313
+ var pos = buffer.position;
5314
+ var headerLength = 0;
5315
+ var bufferLen = buffer.length;
5316
+ while (headerLength !== 3 && headerLength !== 4 && pos < bufferLen - 4) {
5317
+ if (buffer.getInt16(pos) === 0) {
5318
+ if (buffer.getInt16(pos + 2) === 1) {
5319
+ headerLength = 4;
5320
+ } else if (buffer.getInt8(pos + 2) === 1) {
5321
+ headerLength = 3;
5322
+ } else {
5323
+ pos++;
5324
+ }
5325
+ } else {
5326
+ pos++;
5327
+ }
5328
+ }
5329
+ if (pos === bufferLen - 4) {
5330
+ if (buffer.getInt16(pos) === 0) {
5331
+ if (buffer.getInt16(pos + 2) === 1) {
5332
+ headerLength = 4;
5333
+ } else {
5334
+ pos = bufferLen;
5335
+ }
5336
+ } else {
5337
+ pos++;
5338
+ if (buffer.getInt16(pos) === 0 && buffer.getInt8(pos) === 1) {
5339
+ headerLength = 3;
5340
+ } else {
5341
+ pos = bufferLen;
5342
+ }
5343
+ }
5344
+ }
5345
+ return {
5346
+ pos,
5347
+ headerLength
5348
+ };
5349
+ },
5350
+ isH265VideoFrame: function isH265VideoFrame(chunk) {
5351
+ var _chunk$getMetadata, _chunk$getMetadata$ca;
5352
+ 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");
5353
+ }
5354
+ };
5355
+ var RTCDataView = /* @__PURE__ */ function() {
5356
+ function RTCDataView2(buffer) {
5357
+ _classCallCheck$3(this, RTCDataView2);
5358
+ _defineProperty$2(this, "_position", 0);
5359
+ this._dataview = new DataView(buffer);
5360
+ }
5361
+ _createClass$3(RTCDataView2, [{
5362
+ key: "length",
5363
+ get: function get() {
5364
+ return this.buffer.byteLength;
5365
+ }
5366
+ }, {
5367
+ key: "buffer",
5368
+ get: function get() {
5369
+ return this._dataview.buffer;
5370
+ }
5371
+ }, {
5372
+ key: "position",
5373
+ get: function get() {
5374
+ return this._position;
5375
+ },
5376
+ set: function set(value) {
5377
+ this._position = value;
5378
+ }
5379
+ }, {
5380
+ key: "back",
5381
+ value: function back(count) {
5382
+ this.position -= count;
5383
+ }
5384
+ }, {
5385
+ key: "getUint8",
5386
+ value: function getUint8(offset) {
5387
+ return this._dataview.getUint8(offset);
5388
+ }
5389
+ }, {
5390
+ key: "getInt8",
5391
+ value: function getInt8(offset) {
5392
+ return this._dataview.getInt8(offset);
5393
+ }
5394
+ }, {
5395
+ key: "getInt16",
5396
+ value: function getInt16(offset) {
5397
+ return this._dataview.getInt16(offset);
5398
+ }
5399
+ }, {
5400
+ key: "getUint16",
5401
+ value: function getUint16(offset) {
5402
+ return this._dataview.getUint16(offset);
5403
+ }
5404
+ }, {
5405
+ key: "getUint32",
5406
+ value: function getUint32(offset) {
5407
+ return this._dataview.getUint32(offset);
5408
+ }
5409
+ }, {
5410
+ key: "getInt32",
5411
+ value: function getInt32(offset) {
5412
+ return this._dataview.getInt32(offset);
5413
+ }
5414
+ }, {
5415
+ key: "skip",
5416
+ value: function skip(count) {
5417
+ var loop = Math.floor(count / 4);
5418
+ var last = count % 4;
5419
+ for (var i = 0; i < loop; i++) {
5420
+ RTCDataView2.readByte(this, 4);
5421
+ }
5422
+ if (last > 0) {
5423
+ RTCDataView2.readByte(this, last);
5424
+ }
5425
+ }
5426
+ }, {
5427
+ key: "readUint8",
5428
+ value: function readUint8() {
5429
+ return RTCDataView2.readByte(this, 1);
5430
+ }
5431
+ }, {
5432
+ key: "readUint16",
5433
+ value: function readUint16() {
5434
+ return RTCDataView2.readByte(this, 2);
5435
+ }
5436
+ }, {
5437
+ key: "readUint24",
5438
+ value: function readUint24() {
5439
+ return RTCDataView2.readByte(this, 3);
5440
+ }
5441
+ }, {
5442
+ key: "readUint32",
5443
+ value: function readUint32() {
5444
+ return RTCDataView2.readByte(this, 4);
5445
+ }
5446
+ }, {
5447
+ key: "readUint64",
5448
+ value: function readUint64() {
5449
+ return RTCDataView2.readByte(this, 8);
5450
+ }
5451
+ }, {
5452
+ key: "readInt8",
5453
+ value: function readInt8() {
5454
+ return RTCDataView2.readByte(this, 1, true);
5455
+ }
5456
+ }, {
5457
+ key: "readInt16",
5458
+ value: function readInt16() {
5459
+ return RTCDataView2.readByte(this, 2, true);
5460
+ }
5461
+ }, {
5462
+ key: "readInt32",
5463
+ value: function readInt32() {
5464
+ return RTCDataView2.readByte(this, 4, true);
5465
+ }
5466
+ }, {
5467
+ key: "writeUint32",
5468
+ value: function writeUint32(value) {
5469
+ return new Uint8Array([value >>> 24 & 255, value >>> 16 & 255, value >>> 8 & 255, value & 255]);
5470
+ }
5471
+ }], [{
5472
+ key: "readByte",
5473
+ value: function readByte(buffer, size, sign) {
5474
+ var res;
5475
+ switch (size) {
5476
+ case 1:
5477
+ if (sign) {
5478
+ res = buffer.getInt8(buffer.position);
5479
+ } else {
5480
+ res = buffer.getUint8(buffer.position);
5481
+ }
5482
+ break;
5483
+ case 2:
5484
+ if (sign) {
5485
+ res = buffer.getInt16(buffer.position);
5486
+ } else {
5487
+ res = buffer.getUint16(buffer.position);
5488
+ }
5489
+ break;
5490
+ case 3:
5491
+ if (sign) {
5492
+ throw new Error("not supported for readByte 3");
5493
+ } else {
5494
+ res = buffer.getUint8(buffer.position) << 16;
5495
+ res |= buffer.getUint8(buffer.position + 1) << 8;
5496
+ res |= buffer.getUint8(buffer.position + 2);
5497
+ }
5498
+ break;
5499
+ case 4:
5500
+ if (sign) {
5501
+ res = buffer.getInt32(buffer.position);
5502
+ } else {
5503
+ res = buffer.getUint32(buffer.position);
5504
+ }
5505
+ break;
5506
+ case 8:
5507
+ if (sign) {
5508
+ throw new Error("not supported for readBody 8");
5509
+ } else {
5510
+ res = buffer.getUint32(buffer.position) << 32;
5511
+ res |= buffer.getUint32(buffer.position + 4);
5512
+ }
5513
+ break;
5514
+ default:
5515
+ res = "";
5516
+ }
5517
+ buffer.position += size;
5518
+ return res;
5519
+ }
5520
+ }]);
5521
+ return RTCDataView2;
5522
+ }();
5523
+ function _classCallCheck(instance, Constructor) {
5524
+ if (!(instance instanceof Constructor)) {
5525
+ throw new TypeError("Cannot call a class as a function");
5526
+ }
5527
+ }
5528
+ function _defineProperties(target, props) {
5529
+ for (var i = 0; i < props.length; i++) {
5530
+ var descriptor = props[i];
5531
+ descriptor.enumerable = descriptor.enumerable || false;
5532
+ descriptor.configurable = true;
5533
+ if ("value" in descriptor)
5534
+ descriptor.writable = true;
5535
+ Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
5536
+ }
5537
+ }
5538
+ function _createClass(Constructor, protoProps, staticProps) {
5539
+ if (protoProps)
5540
+ _defineProperties(Constructor.prototype, protoProps);
5541
+ if (staticProps)
5542
+ _defineProperties(Constructor, staticProps);
5543
+ Object.defineProperty(Constructor, "prototype", {
5544
+ writable: false
5545
+ });
5546
+ return Constructor;
5547
+ }
5548
+ function _toPrimitive(input, hint) {
5549
+ if (typeof input !== "object" || input === null)
5550
+ return input;
5551
+ var prim = input[Symbol.toPrimitive];
5552
+ if (prim !== void 0) {
5553
+ var res = prim.call(input, hint || "default");
5554
+ if (typeof res !== "object")
5555
+ return res;
5556
+ throw new TypeError("@@toPrimitive must return a primitive value.");
5557
+ }
5558
+ return (hint === "string" ? String : Number)(input);
5559
+ }
5560
+ function _toPropertyKey(arg) {
5561
+ var key = _toPrimitive(arg, "string");
5562
+ return typeof key === "symbol" ? key : String(key);
5563
+ }
5564
+ function readBig32(data) {
5565
+ var i = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
5566
+ return (data[i] << 24 >>> 0) + (data[i + 1] << 16) + (data[i + 2] << 8) + (data[i + 3] || 0);
5567
+ }
5568
+ var NALu = /* @__PURE__ */ function() {
5569
+ function NALu2() {
5570
+ _classCallCheck(this, NALu2);
5571
+ }
5572
+ _createClass(NALu2, null, [{
5573
+ key: "parseAnnexB",
5574
+ value: function parseAnnexB(data) {
5575
+ var j = data.byteLength - 1;
5576
+ var dropZerosLength = 0;
5577
+ do {
5578
+ if (data[j] === 0) {
5579
+ dropZerosLength++;
5580
+ } else {
5581
+ break;
5582
+ }
5583
+ j--;
5584
+ } while (j > 0);
5585
+ if (dropZerosLength >= 3) {
5586
+ data = data.subarray(0, j + 1);
5587
+ }
5588
+ var len = data.length;
5589
+ var start = 2;
5590
+ var end = 0;
5591
+ while (data[start] !== null && data[start] !== void 0 && data[start] !== 1) {
5592
+ start++;
5593
+ }
5594
+ start++;
5595
+ end = start + 2;
5596
+ if (end >= len)
5597
+ return [];
5598
+ var units = [];
5599
+ while (end < len) {
5600
+ switch (data[end]) {
5601
+ case 0:
5602
+ if (data[end - 1] !== 0) {
5603
+ end += 2;
5604
+ break;
5605
+ } else if (data[end - 2] !== 0) {
5606
+ end++;
5607
+ break;
5608
+ } else if (end < len - 1 && data[end + 1] !== 1) {
5609
+ end++;
5610
+ break;
5611
+ }
5612
+ if (start !== end - 2)
5613
+ units.push(data.subarray(start, end - 2));
5614
+ do {
5615
+ end++;
5616
+ } while (data[end] !== 1 && end < len);
5617
+ start = end + 1;
5618
+ end = start + 2;
5619
+ break;
5620
+ case 1:
5621
+ if (data[end - 1] !== 0 || data[end - 2] !== 0) {
5622
+ end += 3;
5623
+ break;
5624
+ }
5625
+ if (start !== end - 2)
5626
+ units.push(data.subarray(start, end - 2));
5627
+ start = end + 1;
5628
+ end = start + 2;
5629
+ break;
5630
+ default:
5631
+ end += 3;
5632
+ break;
5633
+ }
5634
+ }
5635
+ if (start < len)
5636
+ units.push(data.subarray(start));
5637
+ return units;
5638
+ }
5639
+ }, {
5640
+ key: "parseAvcC",
5641
+ value: function parseAvcC(data) {
5642
+ var size = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 4;
5643
+ if (data.length < 4)
5644
+ return;
5645
+ var dataLen = data.length;
5646
+ var units = [];
5647
+ var offset = 0;
5648
+ var length;
5649
+ while (offset + size < dataLen) {
5650
+ length = readBig32(data, offset);
5651
+ if (size === 3)
5652
+ length >>>= 8;
5653
+ offset += size;
5654
+ if (!length)
5655
+ continue;
5656
+ if (offset + length > dataLen) {
5657
+ break;
5658
+ }
5659
+ units.push(data.subarray(offset, offset + length));
5660
+ offset += length;
5661
+ }
5662
+ return units;
5663
+ }
5664
+ }, {
5665
+ key: "parseSEI",
5666
+ value: function parseSEI(unit, isHevc) {
5667
+ var len = unit.length;
5668
+ var i = isHevc ? 2 : 1;
5669
+ var type = 0;
5670
+ var size = 0;
5671
+ var uuid = "";
5672
+ while (unit[i] === 255) {
5673
+ type += 255;
5674
+ i++;
5675
+ }
5676
+ type += unit[i++];
5677
+ while (unit[i] === 255) {
5678
+ size += 255;
5679
+ i++;
5680
+ }
5681
+ size += unit[i++];
5682
+ if (type === 5 && len > i + 16) {
5683
+ for (var j = 0; j < 16; j++) {
5684
+ uuid += unit[i].toString(16);
5685
+ i++;
5686
+ }
5687
+ }
5688
+ return {
5689
+ payload: unit.subarray(i, i + size),
5690
+ type,
5691
+ size,
5692
+ uuid
5693
+ };
5694
+ }
5695
+ }, {
5696
+ key: "removeEPB",
5697
+ value: function removeEPB(uint) {
5698
+ var length = uint.byteLength;
5699
+ var emulationPreventionBytesPositions = [];
5700
+ var i = 1;
5701
+ while (i < length - 2) {
5702
+ if (uint[i] === 0 && uint[i + 1] === 0 && uint[i + 2] === 3) {
5703
+ emulationPreventionBytesPositions.push(i + 2);
5704
+ i += 2;
5705
+ } else {
5706
+ i++;
5707
+ }
5708
+ }
5709
+ if (!emulationPreventionBytesPositions.length)
5710
+ return uint;
5711
+ var newLength = length - emulationPreventionBytesPositions.length;
5712
+ var newData = new Uint8Array(newLength);
5713
+ var sourceIndex = 0;
5714
+ for (i = 0; i < newLength; sourceIndex++, i++) {
5715
+ if (sourceIndex === emulationPreventionBytesPositions[0]) {
5716
+ sourceIndex++;
5717
+ emulationPreventionBytesPositions.shift();
5718
+ }
5719
+ newData[i] = uint[sourceIndex];
5720
+ }
5721
+ return newData;
5722
+ }
5723
+ }]);
5724
+ return NALu2;
5725
+ }();
5726
+ function receiveSEITransform(postMessage) {
5727
+ var transform = new TransformStream({
5728
+ transform: function transform2(encodedFrame, controller) {
5729
+ var isH265 = Nalunit.isH265VideoFrame(encodedFrame);
5730
+ var NALs = Nalunit.getNALUnits(new RTCDataView(encodedFrame.data), isH265);
5731
+ NALs.forEach(function(nalUnit) {
5732
+ if (nalUnit.sei) {
5733
+ var decodedSei = NALu.parseSEI(NALu.removeEPB(nalUnit.body), false);
5734
+ if (decodedSei) {
5735
+ postMessage({
5736
+ data: decodedSei,
5737
+ sei: {
5738
+ code: decodedSei.type,
5739
+ content: decodedSei.payload
5740
+ }
5741
+ });
5742
+ }
5743
+ }
5744
+ });
5745
+ controller.enqueue(encodedFrame);
5746
+ }
5747
+ });
5748
+ return transform;
5749
+ }
5750
+ if (typeof self !== "undefined" && self.constructor.name === "DedicatedWorkerGlobalScope") {
5751
+ self.addEventListener("rtctransform", function(event) {
5752
+ var transformer = event.transformer;
5753
+ var port = transformer.options.port;
5754
+ var transform = receiveSEITransform(function(msg) {
5755
+ port.postMessage(msg);
5756
+ });
5757
+ transformer.readable.pipeThrough(transform).pipeTo(event.transformer.writable);
5758
+ });
5759
+ }
5760
+ var encodedJs = "IWZ1bmN0a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YuYWRkRXZlbnRMaXN0ZW5lcigicnRjdHJhbnNmb3JtIiwoZnVuY3Rpb24odCl7dmFyIG4scj10LnRyYW5zZm9ybWVyLGE9ci5vcHRpb25zLnBvcnQsbz0obj1mdW5jdGlvbihlKXthLnBvc3RNZXNzYWdlKGUpfSxuZXcgVHJhbnNmb3JtU3RyZWFtKHt0cmFuc2Zvcm06ZnVuY3Rpb24odCxyKXt2YXIgYT1lLmlzSDI2NVZpZGVvRnJhbWUodCk7ZS5nZXROQUxVbml0cyhuZXcgaSh0LmRhdGEpLGEpLmZvckVhY2goKGZ1bmN0aW9uKGUpe2lmKGUuc2VpKXt2YXIgdD11LnBhcnNlU0VJKHUucmVtb3ZlRVBCKGUuYm9keSksITEpO3QmJm4oe2RhdGE6dCxzZWk6e2NvZGU6dC50eXBlLGNvbnRlbnQ6dC5wYXlsb2FkfX0pfX0pKSxyLmVucXVldWUodCl9fSkpO3IucmVhZGFibGUucGlwZVRocm91Z2gobykucGlwZVRvKHQudHJhbnNmb3JtZXIud3JpdGFibGUpfSkpfSgpOwo=";
5761
+ var blob = typeof window !== "undefined" && window.Blob && new Blob([atob(encodedJs)], {
5762
+ type: "text/javascript;charset=utf-8"
5763
+ });
5764
+ function WorkerWrapper() {
5765
+ var objURL = blob && (window.URL || window.webkitURL).createObjectURL(blob);
5766
+ try {
5767
+ return objURL ? new Worker(objURL, {}) : new Worker("data:application/javascript;base64," + encodedJs, {
5768
+ type: "module"
5769
+ });
5770
+ } finally {
5771
+ objURL && (window.URL || window.webkitURL).revokeObjectURL(objURL);
5772
+ }
5773
+ }
5138
5774
  var logger = new Logger("rts");
5139
5775
  var Rts = /* @__PURE__ */ function(_EventEmitter) {
5140
5776
  _inherits$1(Rts2, _EventEmitter);
5141
5777
  var _super = _createSuper$1(Rts2);
5142
5778
  function Rts2(opts) {
5143
5779
  var _this;
5144
- _classCallCheck$2(this, Rts2);
5780
+ _classCallCheck$3(this, Rts2);
5145
5781
  _this = _super.call(this);
5146
5782
  _defineProperty$2(_assertThisInitialized$1(_this), "_url", "");
5147
5783
  _defineProperty$2(_assertThisInitialized$1(_this), "_pc", null);
@@ -5157,6 +5793,46 @@
5157
5793
  _defineProperty$2(_assertThisInitialized$1(_this), "_waitingTimer", 0);
5158
5794
  _defineProperty$2(_assertThisInitialized$1(_this), "_rctConnectStartTs", 0);
5159
5795
  _defineProperty$2(_assertThisInitialized$1(_this), "_isReplacing", false);
5796
+ _defineProperty$2(_assertThisInitialized$1(_this), "_checkStatsErrorTimer", null);
5797
+ _defineProperty$2(_assertThisInitialized$1(_this), "_checkStatsError", /* @__PURE__ */ _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee2() {
5798
+ return _regeneratorRuntime$1().wrap(function _callee2$(_context2) {
5799
+ while (1)
5800
+ switch (_context2.prev = _context2.next) {
5801
+ case 0:
5802
+ _this._checkStatsErrorTimer = setTimeout(/* @__PURE__ */ _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee() {
5803
+ var stats, _stats$video, framesDecoded, bytesReceived;
5804
+ return _regeneratorRuntime$1().wrap(function _callee$(_context) {
5805
+ while (1)
5806
+ switch (_context.prev = _context.next) {
5807
+ case 0:
5808
+ _context.next = 2;
5809
+ return _this.getStatsSnapshoot();
5810
+ case 2:
5811
+ stats = _context.sent;
5812
+ if (stats.video) {
5813
+ _stats$video = stats.video, framesDecoded = _stats$video.framesDecoded, bytesReceived = _stats$video.bytesReceived;
5814
+ if (!bytesReceived) {
5815
+ _this._emitError(StreamingError.create(ERR.MEDIA, ERR.SUB_TYPES.MEDIA_ERR_DECODE, {
5816
+ message: "rts receive empty"
5817
+ }));
5818
+ } else if (!framesDecoded) {
5819
+ _this._emitError(StreamingError.create(ERR.MEDIA, ERR.SUB_TYPES.MEDIA_ERR_DECODE, {
5820
+ message: "rts decode error"
5821
+ }));
5822
+ }
5823
+ }
5824
+ case 4:
5825
+ case "end":
5826
+ return _context.stop();
5827
+ }
5828
+ }, _callee);
5829
+ })), _this._opts.checkStatsErrorDelay);
5830
+ case 1:
5831
+ case "end":
5832
+ return _context2.stop();
5833
+ }
5834
+ }, _callee2);
5835
+ })));
5160
5836
  _defineProperty$2(_assertThisInitialized$1(_this), "_onTrack", function(e) {
5161
5837
  logger.log("addTrack: ", e.track, e.streams);
5162
5838
  _this["_".concat(e.track.kind)] = e.track;
@@ -5188,6 +5864,30 @@
5188
5864
  });
5189
5865
  });
5190
5866
  });
5867
+ _defineProperty$2(_assertThisInitialized$1(_this), "_setDelay", function(delayHint) {
5868
+ if (delayHint) {
5869
+ try {
5870
+ var videoReceiver = _this._videoTransceicer.receiver;
5871
+ var audioReceiver = _this._audioTransceicer.receiver;
5872
+ if ("playoutDelayHint" in videoReceiver && "playoutDelayHint" in audioReceiver) {
5873
+ _this._audioTransceicer.receiver.playoutDelayHint = delayHint;
5874
+ _this._videoTransceicer.receiver.playoutDelayHint = delayHint;
5875
+ return;
5876
+ }
5877
+ if ("jitterBufferDelayHint" in videoReceiver && "jitterBufferDelayHint" in audioReceiver) {
5878
+ _this._audioTransceicer.receiver.jitterBufferDelayHint = delayHint;
5879
+ _this._videoTransceicer.receiver.jitterBufferDelayHint = delayHint;
5880
+ return;
5881
+ }
5882
+ if ("jitterBufferTarget" in videoReceiver && "jitterBufferTarget" in audioReceiver) {
5883
+ _this._audioTransceicer.receiver.jitterBufferTarget = delayHint * 1e3;
5884
+ _this._videoTransceicer.receiver.jitterBufferTarget = delayHint * 1e3;
5885
+ }
5886
+ } catch (error) {
5887
+ logger.error("set delay error");
5888
+ }
5889
+ }
5890
+ });
5191
5891
  _defineProperty$2(_assertThisInitialized$1(_this), "_onLoaderRetry", function(error, retryTime) {
5192
5892
  _this.emit(EVENT.LOAD_RETRY, {
5193
5893
  error: StreamingError.network(error),
@@ -5212,7 +5912,7 @@
5212
5912
  }
5213
5913
  return _this;
5214
5914
  }
5215
- _createClass$2(Rts2, [{
5915
+ _createClass$3(Rts2, [{
5216
5916
  key: "pc",
5217
5917
  get: function get() {
5218
5918
  return this._pc;
@@ -5253,12 +5953,12 @@
5253
5953
  }, {
5254
5954
  key: "load",
5255
5955
  value: function() {
5256
- var _load = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee(url) {
5956
+ var _load = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee3(url) {
5257
5957
  var _this2 = this;
5258
- var lastPc;
5259
- return _regeneratorRuntime$1().wrap(function _callee$(_context) {
5958
+ var lastPc, encodedTransformSupported;
5959
+ return _regeneratorRuntime$1().wrap(function _callee3$(_context3) {
5260
5960
  while (1)
5261
- switch (_context.prev = _context.next) {
5961
+ switch (_context3.prev = _context3.next) {
5262
5962
  case 0:
5263
5963
  this._disconnect();
5264
5964
  this._url = url;
@@ -5267,25 +5967,28 @@
5267
5967
  if (lastPc) {
5268
5968
  lastPc.close();
5269
5969
  }
5270
- _context.prev = 5;
5271
- this._pc = new RTCPeerConnection();
5970
+ encodedTransformSupported = isLegacyEncodedTransformSupported();
5971
+ _context3.prev = 6;
5972
+ this._pc = new RTCPeerConnection({
5973
+ encodedInsertableStreams: encodedTransformSupported && this._opts.enableSei ? true : void 0
5974
+ });
5272
5975
  this._bindRTCEvents();
5273
- _context.next = 10;
5976
+ _context3.next = 11;
5274
5977
  return this._connect(url);
5275
- case 10:
5276
- _context.next = 15;
5978
+ case 11:
5979
+ _context3.next = 16;
5277
5980
  break;
5278
- case 12:
5279
- _context.prev = 12;
5280
- _context.t0 = _context["catch"](5);
5981
+ case 13:
5982
+ _context3.prev = 13;
5983
+ _context3.t0 = _context3["catch"](6);
5281
5984
  setTimeout(function() {
5282
- return _this2._emitError(StreamingError.create(ERR.OTHER, null, _context.t0));
5985
+ return _this2._emitError(StreamingError.create(ERR.OTHER, null, _context3.t0));
5283
5986
  });
5284
- case 15:
5987
+ case 16:
5285
5988
  case "end":
5286
- return _context.stop();
5989
+ return _context3.stop();
5287
5990
  }
5288
- }, _callee, this, [[5, 12]]);
5991
+ }, _callee3, this, [[6, 13]]);
5289
5992
  }));
5290
5993
  function load(_x) {
5291
5994
  return _load.apply(this, arguments);
@@ -5327,6 +6030,7 @@
5327
6030
  responseUrl: _this3._url,
5328
6031
  elapsed: Date.now() - _this3._rctConnectStartTs
5329
6032
  });
6033
+ _this3._checkStatsError();
5330
6034
  }
5331
6035
  });
5332
6036
  }
@@ -5364,6 +6068,54 @@
5364
6068
  }
5365
6069
  }
5366
6070
  }
6071
+ }, {
6072
+ key: "initVideoEncodedTransform",
6073
+ value: function initVideoEncodedTransform() {
6074
+ var _this5 = this;
6075
+ if (!this._videoTransceicer || !this._videoTransceicer.receiver) {
6076
+ console.log("no receiver found when trying to bind encodedTransform");
6077
+ return;
6078
+ }
6079
+ var receiver = this._videoTransceicer.receiver;
6080
+ if (isLegacyEncodedTransformSupported()) {
6081
+ var _receiver$createEncod = receiver.createEncodedStreams(), readable = _receiver$createEncod.readable, writable = _receiver$createEncod.writable;
6082
+ readable.pipeThrough(receiveSEITransform(function(sei) {
6083
+ _this5.emit(EVENT.SEI, sei);
6084
+ })).pipeTo(writable);
6085
+ } else if (isEncodedTransformSupported()) {
6086
+ var worker = new WorkerWrapper();
6087
+ var channel = new MessageChannel();
6088
+ this._videoTransceicer.receiver.transform = new RTCRtpScriptTransform(worker, {
6089
+ port: channel.port2
6090
+ }, [channel.port2]);
6091
+ channel.port1.onmessage = function(e) {
6092
+ _this5.emit(EVENT.SEI, e.data);
6093
+ };
6094
+ }
6095
+ }
6096
+ }, {
6097
+ key: "initAudioEncodedTransform",
6098
+ value: function initAudioEncodedTransform() {
6099
+ if (!this._audioTransceicer || !this._audioTransceicer.receiver) {
6100
+ logger.warn("no receiver found when trying to bind encodedTransform");
6101
+ return;
6102
+ }
6103
+ if (!isLegacyEncodedTransformSupported()) {
6104
+ logger.warn("legacy EncodedTransform is not supported");
6105
+ return;
6106
+ }
6107
+ var receiver = this._audioTransceicer.receiver;
6108
+ var _receiver$createEncod2 = receiver.createEncodedStreams(), readable = _receiver$createEncod2.readable, writable = _receiver$createEncod2.writable;
6109
+ readable.pipeThrough(new TransformStream({
6110
+ transform: function transform(chunk, controller) {
6111
+ if (chunk.data.byteLength <= 1e3) {
6112
+ controller.enqueue(chunk);
6113
+ } else {
6114
+ logger.log("too large audio frame", chunk.data.byteLength);
6115
+ }
6116
+ }
6117
+ })).pipeTo(writable);
6118
+ }
5367
6119
  }, {
5368
6120
  key: "_bindMediaEvent",
5369
6121
  value: function _bindMediaEvent() {
@@ -5373,15 +6125,15 @@
5373
6125
  }, {
5374
6126
  key: "_connect",
5375
6127
  value: function() {
5376
- var _connect2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee2() {
5377
- var pc, offer, delayHint, parsed, finnalUrl, _this$_opts, _answer$remoteSdp, _this$_opts2, _answer$remoteSdp2, _parsed$media, parseSession, sessionId, reqStart, res, answer, err, _parsed;
5378
- return _regeneratorRuntime$1().wrap(function _callee2$(_context2) {
6128
+ var _connect2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee4() {
6129
+ var pc, offer, parsed, finnalUrl, _this$_opts, _answer$remoteSdp, _this$_opts2, _answer$remoteSdp2, _parsed$media, parseSession, sessionId, reqStart, res, answer, err, _parsed;
6130
+ return _regeneratorRuntime$1().wrap(function _callee4$(_context4) {
5379
6131
  while (1)
5380
- switch (_context2.prev = _context2.next) {
6132
+ switch (_context4.prev = _context4.next) {
5381
6133
  case 0:
5382
6134
  pc = this._pc;
5383
6135
  if (!pc.addTransceiver) {
5384
- _context2.next = 11;
6136
+ _context4.next = 11;
5385
6137
  break;
5386
6138
  }
5387
6139
  this._audioTransceicer = pc.addTransceiver("audio", {
@@ -5390,28 +6142,26 @@
5390
6142
  this._videoTransceicer = pc.addTransceiver("video", {
5391
6143
  direction: "recvonly"
5392
6144
  });
5393
- delayHint = this._opts.delayHint;
5394
- if (delayHint) {
5395
- this._audioTransceicer.receiver.playoutDelayHint = delayHint;
5396
- this._audioTransceicer.receiver.jitterBufferDelayHint = delayHint;
5397
- this._videoTransceicer.receiver.playoutDelayHint = delayHint;
5398
- this._videoTransceicer.receiver.jitterBufferDelayHint = delayHint;
6145
+ this._setDelay(this._opts.delayHint);
6146
+ if (this._opts.enableSei) {
6147
+ this.initVideoEncodedTransform();
6148
+ this.initAudioEncodedTransform();
5399
6149
  }
5400
- _context2.next = 8;
6150
+ _context4.next = 8;
5401
6151
  return pc.createOffer();
5402
6152
  case 8:
5403
- offer = _context2.sent;
5404
- _context2.next = 14;
6153
+ offer = _context4.sent;
6154
+ _context4.next = 14;
5405
6155
  break;
5406
6156
  case 11:
5407
- _context2.next = 13;
6157
+ _context4.next = 13;
5408
6158
  return pc.createOffer({
5409
6159
  iceRestart: true,
5410
6160
  offerToReceiveAudio: true,
5411
6161
  offerToReceiveVideo: true
5412
6162
  });
5413
6163
  case 13:
5414
- offer = _context2.sent;
6164
+ offer = _context4.sent;
5415
6165
  case 14:
5416
6166
  logger.log("local offer");
5417
6167
  logger.log(offer.sdp);
@@ -5437,11 +6187,11 @@
5437
6187
  });
5438
6188
  offer.sdp = lib.write(parsed);
5439
6189
  logger.log("local offer modified:\n", offer.sdp);
5440
- _context2.next = 22;
6190
+ _context4.next = 22;
5441
6191
  return pc.setLocalDescription(offer);
5442
6192
  case 22:
5443
6193
  finnalUrl = this._url;
5444
- _context2.prev = 23;
6194
+ _context4.prev = 23;
5445
6195
  if (this._opts.preProcessUrl) {
5446
6196
  finnalUrl = this._opts.preProcessUrl(finnalUrl).url;
5447
6197
  }
@@ -5454,7 +6204,7 @@
5454
6204
  sessionId
5455
6205
  });
5456
6206
  reqStart = Date.now();
5457
- _context2.next = 32;
6207
+ _context4.next = 32;
5458
6208
  return this._loader.load(finnalUrl, {
5459
6209
  body: JSON.stringify({
5460
6210
  sessionId,
@@ -5463,22 +6213,22 @@
5463
6213
  })
5464
6214
  });
5465
6215
  case 32:
5466
- res = _context2.sent;
6216
+ res = _context4.sent;
5467
6217
  this.emit(EVENT.LOAD_RESPONSE_HEADERS, {
5468
6218
  headers: res.response.headers
5469
6219
  });
5470
6220
  answer = res === null || res === void 0 ? void 0 : res.data;
5471
6221
  if (!((answer === null || answer === void 0 ? void 0 : answer.code) === 404 || (answer === null || answer === void 0 ? void 0 : answer.code) === 403)) {
5472
- _context2.next = 40;
6222
+ _context4.next = 40;
5473
6223
  break;
5474
6224
  }
5475
6225
  err = StreamingError.create(answer.code === 404 ? ERR.NETWORK_NOTFOUND : ERR.NETWORK_FORBIDDEN, null, answer);
5476
6226
  err.errorType = ERR.NETWORK;
5477
6227
  this._emitError(err);
5478
- return _context2.abrupt("return");
6228
+ return _context4.abrupt("return");
5479
6229
  case 40:
5480
6230
  if (!((answer === null || answer === void 0 ? void 0 : answer.code) !== 200)) {
5481
- _context2.next = 42;
6231
+ _context4.next = 42;
5482
6232
  break;
5483
6233
  }
5484
6234
  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));
@@ -5504,21 +6254,21 @@
5504
6254
  answer.remoteSdp.sdp = lib.write(_parsed);
5505
6255
  logger.log("answer modified:\n", answer.remoteSdp.sdp);
5506
6256
  this._rctConnectStartTs = Date.now();
5507
- _context2.next = 52;
6257
+ _context4.next = 52;
5508
6258
  return this._pc.setRemoteDescription(answer.remoteSdp);
5509
6259
  case 52:
5510
6260
  this._networkEvaluate = new NetworkEvaluate(pc, this._opts.networkEvaluateInterval);
5511
- _context2.next = 58;
6261
+ _context4.next = 58;
5512
6262
  break;
5513
6263
  case 55:
5514
- _context2.prev = 55;
5515
- _context2.t0 = _context2["catch"](23);
5516
- this._emitError(StreamingError.network(_context2.t0));
6264
+ _context4.prev = 55;
6265
+ _context4.t0 = _context4["catch"](23);
6266
+ this._emitError(StreamingError.network(_context4.t0));
5517
6267
  case 58:
5518
6268
  case "end":
5519
- return _context2.stop();
6269
+ return _context4.stop();
5520
6270
  }
5521
- }, _callee2, this, [[23, 55]]);
6271
+ }, _callee4, this, [[23, 55]]);
5522
6272
  }));
5523
6273
  function _connect() {
5524
6274
  return _connect2.apply(this, arguments);
@@ -5540,6 +6290,10 @@
5540
6290
  key: "_emitError",
5541
6291
  value: function _emitError(error) {
5542
6292
  this.emit(EVENT.ERROR, error);
6293
+ clearTimeout(this._checkStatsErrorTimer);
6294
+ if (this._pc) {
6295
+ this._pc.close();
6296
+ }
5543
6297
  }
5544
6298
  }, {
5545
6299
  key: "destroy",
@@ -5556,6 +6310,7 @@
5556
6310
  this._loader = null;
5557
6311
  this._media = null;
5558
6312
  this._pc = null;
6313
+ this._opts = null;
5559
6314
  }
5560
6315
  }], [{
5561
6316
  key: "enableLogger",
@@ -5578,70 +6333,12 @@
5578
6333
  }
5579
6334
  } catch (error) {
5580
6335
  }
5581
- function isSupported() {
5582
- if (!window.RTCPeerConnection || !window.RTCPeerConnection.prototype.addTransceiver) {
5583
- return false;
5584
- }
5585
- return true;
5586
- }
5587
- function getCapacity() {
5588
- if (!isSupported())
5589
- return Promise.reject("RTCPeerConnection no support");
5590
- var pc;
5591
- try {
5592
- pc = new RTCPeerConnection();
5593
- pc.addTransceiver("video", {
5594
- direction: "recvonly"
5595
- });
5596
- pc.addTransceiver("audio", {
5597
- direction: "recvonly"
5598
- });
5599
- } catch (e) {
5600
- return Promise.reject(e === null || e === void 0 ? void 0 : e.message);
5601
- }
5602
- return pc.createOffer().then(function(offer) {
5603
- var _sdpJson$media, _sdpJson$media2, _vMedia$rtp, _aMedia$rtp;
5604
- logger.log(offer.sdp);
5605
- var sdpJson = lib.parse(offer.sdp);
5606
- var vMedia = (_sdpJson$media = sdpJson.media) === null || _sdpJson$media === void 0 ? void 0 : _sdpJson$media.filter(function(x) {
5607
- return x.type === "video";
5608
- })[0];
5609
- var aMedia = (_sdpJson$media2 = sdpJson.media) === null || _sdpJson$media2 === void 0 ? void 0 : _sdpJson$media2.filter(function(x) {
5610
- return x.type === "audio";
5611
- })[0];
5612
- 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) {
5613
- return x.codec === "VP8" || x.codec === "VP9" || x.codec === "H264";
5614
- });
5615
- 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) {
5616
- return x.codec === "opus";
5617
- });
5618
- var vFmtp = vMedia === null || vMedia === void 0 ? void 0 : vMedia.fmtp;
5619
- var aFmtp = aMedia === null || aMedia === void 0 ? void 0 : aMedia.fmtp;
5620
- vFmtp && vCodecs.map(function(codec) {
5621
- var _vFmtp$filter$;
5622
- codec.config = (_vFmtp$filter$ = vFmtp.filter(function(x) {
5623
- return x.payload === codec.payload;
5624
- })[0]) === null || _vFmtp$filter$ === void 0 ? void 0 : _vFmtp$filter$.config;
5625
- });
5626
- aFmtp && aCodecs.map(function(codec) {
5627
- var _aFmtp$filter$;
5628
- codec.config = (_aFmtp$filter$ = aFmtp.filter(function(x) {
5629
- return x.payload === codec.payload;
5630
- })[0]) === null || _aFmtp$filter$ === void 0 ? void 0 : _aFmtp$filter$.config;
5631
- });
5632
- pc.close();
5633
- return {
5634
- video: vCodecs,
5635
- audio: aCodecs
5636
- };
5637
- });
5638
- }
5639
6336
  var RtsPlugin = /* @__PURE__ */ function(_BasePlugin) {
5640
6337
  _inherits$1(RtsPlugin2, _BasePlugin);
5641
6338
  var _super = _createSuper$1(RtsPlugin2);
5642
6339
  function RtsPlugin2() {
5643
6340
  var _this;
5644
- _classCallCheck$2(this, RtsPlugin2);
6341
+ _classCallCheck$3(this, RtsPlugin2);
5645
6342
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
5646
6343
  args[_key] = arguments[_key];
5647
6344
  }
@@ -5706,7 +6403,7 @@
5706
6403
  });
5707
6404
  return _this;
5708
6405
  }
5709
- _createClass$2(RtsPlugin2, [{
6406
+ _createClass$3(RtsPlugin2, [{
5710
6407
  key: "pc",
5711
6408
  get: function get() {
5712
6409
  var _this$_rts4;
@@ -5738,7 +6435,7 @@
5738
6435
  }, {
5739
6436
  key: "version",
5740
6437
  get: function get() {
5741
- return "0.2.1-alpha.14";
6438
+ return "0.2.1-alpha.24";
5742
6439
  }
5743
6440
  }, {
5744
6441
  key: "beforePlayerInit",
@@ -5833,6 +6530,7 @@
5833
6530
  this._transCoreEvent(EVENT.LOAD_RESPONSE_HEADERS);
5834
6531
  this._transCoreEvent(EVENT.LOAD_RETRY);
5835
6532
  this._transCoreEvent(EVENT.METADATA_PARSED);
6533
+ this._transCoreEvent(EVENT.SEI);
5836
6534
  this._transCoreEvent(EXTEND_EVENTS.RTC_STATE_CHANGE);
5837
6535
  }
5838
6536
  }, {