@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.
@@ -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,49 @@
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
+ if (_this._checkStatsErrorTimer) {
5803
+ clearTimeout(_this._checkStatsErrorTimer);
5804
+ }
5805
+ _this._checkStatsErrorTimer = setTimeout(/* @__PURE__ */ _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee() {
5806
+ var stats, _stats$video, framesDecoded, bytesReceived;
5807
+ return _regeneratorRuntime$1().wrap(function _callee$(_context) {
5808
+ while (1)
5809
+ switch (_context.prev = _context.next) {
5810
+ case 0:
5811
+ _context.next = 2;
5812
+ return _this.getStatsSnapshoot();
5813
+ case 2:
5814
+ stats = _context.sent;
5815
+ if (stats.video) {
5816
+ _stats$video = stats.video, framesDecoded = _stats$video.framesDecoded, bytesReceived = _stats$video.bytesReceived;
5817
+ if (!bytesReceived) {
5818
+ _this._emitError(StreamingError.create(ERR.MEDIA, ERR.SUB_TYPES.MEDIA_ERR_DECODE, {
5819
+ message: "rts receive empty"
5820
+ }));
5821
+ } else if (!framesDecoded) {
5822
+ _this._emitError(StreamingError.create(ERR.MEDIA, ERR.SUB_TYPES.MEDIA_ERR_DECODE, {
5823
+ message: "rts decode error"
5824
+ }));
5825
+ }
5826
+ }
5827
+ case 4:
5828
+ case "end":
5829
+ return _context.stop();
5830
+ }
5831
+ }, _callee);
5832
+ })), _this._opts.checkStatsErrorDelay);
5833
+ case 2:
5834
+ case "end":
5835
+ return _context2.stop();
5836
+ }
5837
+ }, _callee2);
5838
+ })));
5160
5839
  _defineProperty$2(_assertThisInitialized$1(_this), "_onTrack", function(e) {
5161
5840
  logger.log("addTrack: ", e.track, e.streams);
5162
5841
  _this["_".concat(e.track.kind)] = e.track;
@@ -5188,6 +5867,30 @@
5188
5867
  });
5189
5868
  });
5190
5869
  });
5870
+ _defineProperty$2(_assertThisInitialized$1(_this), "_setDelay", function(delayHint) {
5871
+ if (delayHint) {
5872
+ try {
5873
+ var videoReceiver = _this._videoTransceicer.receiver;
5874
+ var audioReceiver = _this._audioTransceicer.receiver;
5875
+ if ("playoutDelayHint" in videoReceiver && "playoutDelayHint" in audioReceiver) {
5876
+ _this._audioTransceicer.receiver.playoutDelayHint = delayHint;
5877
+ _this._videoTransceicer.receiver.playoutDelayHint = delayHint;
5878
+ return;
5879
+ }
5880
+ if ("jitterBufferDelayHint" in videoReceiver && "jitterBufferDelayHint" in audioReceiver) {
5881
+ _this._audioTransceicer.receiver.jitterBufferDelayHint = delayHint;
5882
+ _this._videoTransceicer.receiver.jitterBufferDelayHint = delayHint;
5883
+ return;
5884
+ }
5885
+ if ("jitterBufferTarget" in videoReceiver && "jitterBufferTarget" in audioReceiver) {
5886
+ _this._audioTransceicer.receiver.jitterBufferTarget = delayHint * 1e3;
5887
+ _this._videoTransceicer.receiver.jitterBufferTarget = delayHint * 1e3;
5888
+ }
5889
+ } catch (error) {
5890
+ logger.error("set delay error");
5891
+ }
5892
+ }
5893
+ });
5191
5894
  _defineProperty$2(_assertThisInitialized$1(_this), "_onLoaderRetry", function(error, retryTime) {
5192
5895
  _this.emit(EVENT.LOAD_RETRY, {
5193
5896
  error: StreamingError.network(error),
@@ -5212,7 +5915,7 @@
5212
5915
  }
5213
5916
  return _this;
5214
5917
  }
5215
- _createClass$2(Rts2, [{
5918
+ _createClass$3(Rts2, [{
5216
5919
  key: "pc",
5217
5920
  get: function get() {
5218
5921
  return this._pc;
@@ -5253,12 +5956,12 @@
5253
5956
  }, {
5254
5957
  key: "load",
5255
5958
  value: function() {
5256
- var _load = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee(url) {
5959
+ var _load = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee3(url) {
5257
5960
  var _this2 = this;
5258
- var lastPc;
5259
- return _regeneratorRuntime$1().wrap(function _callee$(_context) {
5961
+ var lastPc, encodedTransformSupported;
5962
+ return _regeneratorRuntime$1().wrap(function _callee3$(_context3) {
5260
5963
  while (1)
5261
- switch (_context.prev = _context.next) {
5964
+ switch (_context3.prev = _context3.next) {
5262
5965
  case 0:
5263
5966
  this._disconnect();
5264
5967
  this._url = url;
@@ -5267,25 +5970,28 @@
5267
5970
  if (lastPc) {
5268
5971
  lastPc.close();
5269
5972
  }
5270
- _context.prev = 5;
5271
- this._pc = new RTCPeerConnection();
5973
+ encodedTransformSupported = isLegacyEncodedTransformSupported();
5974
+ _context3.prev = 6;
5975
+ this._pc = new RTCPeerConnection({
5976
+ encodedInsertableStreams: encodedTransformSupported && this._opts.enableSei ? true : void 0
5977
+ });
5272
5978
  this._bindRTCEvents();
5273
- _context.next = 10;
5979
+ _context3.next = 11;
5274
5980
  return this._connect(url);
5275
- case 10:
5276
- _context.next = 15;
5981
+ case 11:
5982
+ _context3.next = 16;
5277
5983
  break;
5278
- case 12:
5279
- _context.prev = 12;
5280
- _context.t0 = _context["catch"](5);
5984
+ case 13:
5985
+ _context3.prev = 13;
5986
+ _context3.t0 = _context3["catch"](6);
5281
5987
  setTimeout(function() {
5282
- return _this2._emitError(StreamingError.create(ERR.OTHER, null, _context.t0));
5988
+ return _this2._emitError(StreamingError.create(ERR.OTHER, null, _context3.t0));
5283
5989
  });
5284
- case 15:
5990
+ case 16:
5285
5991
  case "end":
5286
- return _context.stop();
5992
+ return _context3.stop();
5287
5993
  }
5288
- }, _callee, this, [[5, 12]]);
5994
+ }, _callee3, this, [[6, 13]]);
5289
5995
  }));
5290
5996
  function load(_x) {
5291
5997
  return _load.apply(this, arguments);
@@ -5327,6 +6033,7 @@
5327
6033
  responseUrl: _this3._url,
5328
6034
  elapsed: Date.now() - _this3._rctConnectStartTs
5329
6035
  });
6036
+ _this3._checkStatsError();
5330
6037
  }
5331
6038
  });
5332
6039
  }
@@ -5364,6 +6071,54 @@
5364
6071
  }
5365
6072
  }
5366
6073
  }
6074
+ }, {
6075
+ key: "initVideoEncodedTransform",
6076
+ value: function initVideoEncodedTransform() {
6077
+ var _this5 = this;
6078
+ if (!this._videoTransceicer || !this._videoTransceicer.receiver) {
6079
+ console.log("no receiver found when trying to bind encodedTransform");
6080
+ return;
6081
+ }
6082
+ var receiver = this._videoTransceicer.receiver;
6083
+ if (isLegacyEncodedTransformSupported()) {
6084
+ var _receiver$createEncod = receiver.createEncodedStreams(), readable = _receiver$createEncod.readable, writable = _receiver$createEncod.writable;
6085
+ readable.pipeThrough(receiveSEITransform(function(sei) {
6086
+ _this5.emit(EVENT.SEI, sei);
6087
+ })).pipeTo(writable);
6088
+ } else if (isEncodedTransformSupported()) {
6089
+ var worker = new WorkerWrapper();
6090
+ var channel = new MessageChannel();
6091
+ this._videoTransceicer.receiver.transform = new RTCRtpScriptTransform(worker, {
6092
+ port: channel.port2
6093
+ }, [channel.port2]);
6094
+ channel.port1.onmessage = function(e) {
6095
+ _this5.emit(EVENT.SEI, e.data);
6096
+ };
6097
+ }
6098
+ }
6099
+ }, {
6100
+ key: "initAudioEncodedTransform",
6101
+ value: function initAudioEncodedTransform() {
6102
+ if (!this._audioTransceicer || !this._audioTransceicer.receiver) {
6103
+ logger.warn("no receiver found when trying to bind encodedTransform");
6104
+ return;
6105
+ }
6106
+ if (!isLegacyEncodedTransformSupported()) {
6107
+ logger.warn("legacy EncodedTransform is not supported");
6108
+ return;
6109
+ }
6110
+ var receiver = this._audioTransceicer.receiver;
6111
+ var _receiver$createEncod2 = receiver.createEncodedStreams(), readable = _receiver$createEncod2.readable, writable = _receiver$createEncod2.writable;
6112
+ readable.pipeThrough(new TransformStream({
6113
+ transform: function transform(chunk, controller) {
6114
+ if (chunk.data.byteLength <= 1e3) {
6115
+ controller.enqueue(chunk);
6116
+ } else {
6117
+ logger.log("too large audio frame", chunk.data.byteLength);
6118
+ }
6119
+ }
6120
+ })).pipeTo(writable);
6121
+ }
5367
6122
  }, {
5368
6123
  key: "_bindMediaEvent",
5369
6124
  value: function _bindMediaEvent() {
@@ -5373,15 +6128,15 @@
5373
6128
  }, {
5374
6129
  key: "_connect",
5375
6130
  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) {
6131
+ var _connect2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee4() {
6132
+ var pc, offer, parsed, finnalUrl, _this$_opts, _answer$remoteSdp, _this$_opts2, _answer$remoteSdp2, _parsed$media, parseSession, sessionId, reqStart, res, answer, err, _parsed;
6133
+ return _regeneratorRuntime$1().wrap(function _callee4$(_context4) {
5379
6134
  while (1)
5380
- switch (_context2.prev = _context2.next) {
6135
+ switch (_context4.prev = _context4.next) {
5381
6136
  case 0:
5382
6137
  pc = this._pc;
5383
6138
  if (!pc.addTransceiver) {
5384
- _context2.next = 11;
6139
+ _context4.next = 11;
5385
6140
  break;
5386
6141
  }
5387
6142
  this._audioTransceicer = pc.addTransceiver("audio", {
@@ -5390,28 +6145,26 @@
5390
6145
  this._videoTransceicer = pc.addTransceiver("video", {
5391
6146
  direction: "recvonly"
5392
6147
  });
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;
6148
+ this._setDelay(this._opts.delayHint);
6149
+ if (this._opts.enableSei) {
6150
+ this.initVideoEncodedTransform();
6151
+ this.initAudioEncodedTransform();
5399
6152
  }
5400
- _context2.next = 8;
6153
+ _context4.next = 8;
5401
6154
  return pc.createOffer();
5402
6155
  case 8:
5403
- offer = _context2.sent;
5404
- _context2.next = 14;
6156
+ offer = _context4.sent;
6157
+ _context4.next = 14;
5405
6158
  break;
5406
6159
  case 11:
5407
- _context2.next = 13;
6160
+ _context4.next = 13;
5408
6161
  return pc.createOffer({
5409
6162
  iceRestart: true,
5410
6163
  offerToReceiveAudio: true,
5411
6164
  offerToReceiveVideo: true
5412
6165
  });
5413
6166
  case 13:
5414
- offer = _context2.sent;
6167
+ offer = _context4.sent;
5415
6168
  case 14:
5416
6169
  logger.log("local offer");
5417
6170
  logger.log(offer.sdp);
@@ -5437,11 +6190,11 @@
5437
6190
  });
5438
6191
  offer.sdp = lib.write(parsed);
5439
6192
  logger.log("local offer modified:\n", offer.sdp);
5440
- _context2.next = 22;
6193
+ _context4.next = 22;
5441
6194
  return pc.setLocalDescription(offer);
5442
6195
  case 22:
5443
6196
  finnalUrl = this._url;
5444
- _context2.prev = 23;
6197
+ _context4.prev = 23;
5445
6198
  if (this._opts.preProcessUrl) {
5446
6199
  finnalUrl = this._opts.preProcessUrl(finnalUrl).url;
5447
6200
  }
@@ -5454,7 +6207,7 @@
5454
6207
  sessionId
5455
6208
  });
5456
6209
  reqStart = Date.now();
5457
- _context2.next = 32;
6210
+ _context4.next = 32;
5458
6211
  return this._loader.load(finnalUrl, {
5459
6212
  body: JSON.stringify({
5460
6213
  sessionId,
@@ -5463,22 +6216,22 @@
5463
6216
  })
5464
6217
  });
5465
6218
  case 32:
5466
- res = _context2.sent;
6219
+ res = _context4.sent;
5467
6220
  this.emit(EVENT.LOAD_RESPONSE_HEADERS, {
5468
6221
  headers: res.response.headers
5469
6222
  });
5470
6223
  answer = res === null || res === void 0 ? void 0 : res.data;
5471
6224
  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;
6225
+ _context4.next = 40;
5473
6226
  break;
5474
6227
  }
5475
6228
  err = StreamingError.create(answer.code === 404 ? ERR.NETWORK_NOTFOUND : ERR.NETWORK_FORBIDDEN, null, answer);
5476
6229
  err.errorType = ERR.NETWORK;
5477
6230
  this._emitError(err);
5478
- return _context2.abrupt("return");
6231
+ return _context4.abrupt("return");
5479
6232
  case 40:
5480
6233
  if (!((answer === null || answer === void 0 ? void 0 : answer.code) !== 200)) {
5481
- _context2.next = 42;
6234
+ _context4.next = 42;
5482
6235
  break;
5483
6236
  }
5484
6237
  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 +6257,21 @@
5504
6257
  answer.remoteSdp.sdp = lib.write(_parsed);
5505
6258
  logger.log("answer modified:\n", answer.remoteSdp.sdp);
5506
6259
  this._rctConnectStartTs = Date.now();
5507
- _context2.next = 52;
6260
+ _context4.next = 52;
5508
6261
  return this._pc.setRemoteDescription(answer.remoteSdp);
5509
6262
  case 52:
5510
6263
  this._networkEvaluate = new NetworkEvaluate(pc, this._opts.networkEvaluateInterval);
5511
- _context2.next = 58;
6264
+ _context4.next = 58;
5512
6265
  break;
5513
6266
  case 55:
5514
- _context2.prev = 55;
5515
- _context2.t0 = _context2["catch"](23);
5516
- this._emitError(StreamingError.network(_context2.t0));
6267
+ _context4.prev = 55;
6268
+ _context4.t0 = _context4["catch"](23);
6269
+ this._emitError(StreamingError.network(_context4.t0));
5517
6270
  case 58:
5518
6271
  case "end":
5519
- return _context2.stop();
6272
+ return _context4.stop();
5520
6273
  }
5521
- }, _callee2, this, [[23, 55]]);
6274
+ }, _callee4, this, [[23, 55]]);
5522
6275
  }));
5523
6276
  function _connect() {
5524
6277
  return _connect2.apply(this, arguments);
@@ -5531,6 +6284,7 @@
5531
6284
  var _this$_loader, _this$_networkEvaluat2;
5532
6285
  (_this$_loader = this._loader) === null || _this$_loader === void 0 ? void 0 : _this$_loader.cancel();
5533
6286
  (_this$_networkEvaluat2 = this._networkEvaluate) === null || _this$_networkEvaluat2 === void 0 ? void 0 : _this$_networkEvaluat2.destroy();
6287
+ clearTimeout(this._checkStatsErrorTimer);
5534
6288
  this._audioTransceicer = null;
5535
6289
  this._videoTransceicer = null;
5536
6290
  this._mediaStream = null;
@@ -5540,6 +6294,10 @@
5540
6294
  key: "_emitError",
5541
6295
  value: function _emitError(error) {
5542
6296
  this.emit(EVENT.ERROR, error);
6297
+ clearTimeout(this._checkStatsErrorTimer);
6298
+ if (this._pc) {
6299
+ this._pc.close();
6300
+ }
5543
6301
  }
5544
6302
  }, {
5545
6303
  key: "destroy",
@@ -5556,6 +6314,7 @@
5556
6314
  this._loader = null;
5557
6315
  this._media = null;
5558
6316
  this._pc = null;
6317
+ this._opts = null;
5559
6318
  }
5560
6319
  }], [{
5561
6320
  key: "enableLogger",
@@ -5578,70 +6337,12 @@
5578
6337
  }
5579
6338
  } catch (error) {
5580
6339
  }
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
6340
  var RtsPlugin = /* @__PURE__ */ function(_BasePlugin) {
5640
6341
  _inherits$1(RtsPlugin2, _BasePlugin);
5641
6342
  var _super = _createSuper$1(RtsPlugin2);
5642
6343
  function RtsPlugin2() {
5643
6344
  var _this;
5644
- _classCallCheck$2(this, RtsPlugin2);
6345
+ _classCallCheck$3(this, RtsPlugin2);
5645
6346
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
5646
6347
  args[_key] = arguments[_key];
5647
6348
  }
@@ -5706,7 +6407,7 @@
5706
6407
  });
5707
6408
  return _this;
5708
6409
  }
5709
- _createClass$2(RtsPlugin2, [{
6410
+ _createClass$3(RtsPlugin2, [{
5710
6411
  key: "pc",
5711
6412
  get: function get() {
5712
6413
  var _this$_rts4;
@@ -5738,7 +6439,7 @@
5738
6439
  }, {
5739
6440
  key: "version",
5740
6441
  get: function get() {
5741
- return "0.2.1-alpha.14";
6442
+ return "0.2.1-alpha.32";
5742
6443
  }
5743
6444
  }, {
5744
6445
  key: "beforePlayerInit",
@@ -5833,6 +6534,7 @@
5833
6534
  this._transCoreEvent(EVENT.LOAD_RESPONSE_HEADERS);
5834
6535
  this._transCoreEvent(EVENT.LOAD_RETRY);
5835
6536
  this._transCoreEvent(EVENT.METADATA_PARSED);
6537
+ this._transCoreEvent(EVENT.SEI);
5836
6538
  this._transCoreEvent(EXTEND_EVENTS.RTC_STATE_CHANGE);
5837
6539
  }
5838
6540
  }, {