@byteplus/veplayer-plugin 2.7.1-rc.0 → 2.8.0-rc.0
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.
- package/esm/index.development.js +21749 -9206
- package/esm/index.production.css +1 -1
- package/esm/index.production.js +6 -6
- package/esm/veplayer.plugin.rtm.development.js +2072 -300
- package/esm/veplayer.plugin.rtm.production.js +1 -1
- package/esm/veplayer.strategy.base.development.js +11083 -0
- package/esm/veplayer.strategy.base.production.js +2 -0
- package/esm/veplayer.strategy.rtm.adaptive.buffer.development.js +970 -0
- package/esm/veplayer.strategy.rtm.adaptive.buffer.production.js +2 -0
- package/package.json +1 -1
- package/umd/veplayer.plugin.rtm.development.js +2046 -274
- package/umd/veplayer.plugin.rtm.production.js +1 -1
- package/umd/veplayer.strategy.base.development.js +11085 -0
- package/umd/veplayer.strategy.base.production.js +1 -0
- package/umd/veplayer.strategy.rtm.adaptive.buffer.development.js +974 -0
- package/umd/veplayer.strategy.rtm.adaptive.buffer.production.js +1 -0
|
@@ -2,6 +2,32 @@
|
|
|
2
2
|
typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define(["exports"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.__VEPLAYER_PLUGIN_RTM__ = {}));
|
|
3
3
|
})(this, function(exports2) {
|
|
4
4
|
"use strict";
|
|
5
|
+
function _iterableToArrayLimit(arr, i) {
|
|
6
|
+
var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
|
|
7
|
+
if (null != _i) {
|
|
8
|
+
var _s, _e, _x, _r, _arr = [], _n = true, _d = false;
|
|
9
|
+
try {
|
|
10
|
+
if (_x = (_i = _i.call(arr)).next, 0 === i) {
|
|
11
|
+
if (Object(_i) !== _i)
|
|
12
|
+
return;
|
|
13
|
+
_n = false;
|
|
14
|
+
} else
|
|
15
|
+
for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = true)
|
|
16
|
+
;
|
|
17
|
+
} catch (err) {
|
|
18
|
+
_d = true, _e = err;
|
|
19
|
+
} finally {
|
|
20
|
+
try {
|
|
21
|
+
if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r))
|
|
22
|
+
return;
|
|
23
|
+
} finally {
|
|
24
|
+
if (_d)
|
|
25
|
+
throw _e;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return _arr;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
5
31
|
function ownKeys$2(object, enumerableOnly) {
|
|
6
32
|
var keys = Object.keys(object);
|
|
7
33
|
if (Object.getOwnPropertySymbols) {
|
|
@@ -368,33 +394,33 @@
|
|
|
368
394
|
});
|
|
369
395
|
};
|
|
370
396
|
}
|
|
371
|
-
function _classCallCheck$
|
|
397
|
+
function _classCallCheck$3(instance, Constructor) {
|
|
372
398
|
if (!(instance instanceof Constructor)) {
|
|
373
399
|
throw new TypeError("Cannot call a class as a function");
|
|
374
400
|
}
|
|
375
401
|
}
|
|
376
|
-
function _defineProperties$
|
|
402
|
+
function _defineProperties$3(target, props) {
|
|
377
403
|
for (var i = 0; i < props.length; i++) {
|
|
378
404
|
var descriptor = props[i];
|
|
379
405
|
descriptor.enumerable = descriptor.enumerable || false;
|
|
380
406
|
descriptor.configurable = true;
|
|
381
407
|
if ("value" in descriptor)
|
|
382
408
|
descriptor.writable = true;
|
|
383
|
-
Object.defineProperty(target, _toPropertyKey$
|
|
409
|
+
Object.defineProperty(target, _toPropertyKey$3(descriptor.key), descriptor);
|
|
384
410
|
}
|
|
385
411
|
}
|
|
386
|
-
function _createClass$
|
|
412
|
+
function _createClass$3(Constructor, protoProps, staticProps) {
|
|
387
413
|
if (protoProps)
|
|
388
|
-
_defineProperties$
|
|
414
|
+
_defineProperties$3(Constructor.prototype, protoProps);
|
|
389
415
|
if (staticProps)
|
|
390
|
-
_defineProperties$
|
|
416
|
+
_defineProperties$3(Constructor, staticProps);
|
|
391
417
|
Object.defineProperty(Constructor, "prototype", {
|
|
392
418
|
writable: false
|
|
393
419
|
});
|
|
394
420
|
return Constructor;
|
|
395
421
|
}
|
|
396
422
|
function _defineProperty$2(obj, key, value) {
|
|
397
|
-
key = _toPropertyKey$
|
|
423
|
+
key = _toPropertyKey$3(key);
|
|
398
424
|
if (key in obj) {
|
|
399
425
|
Object.defineProperty(obj, key, {
|
|
400
426
|
value,
|
|
@@ -479,7 +505,51 @@
|
|
|
479
505
|
return _possibleConstructorReturn$1(this, result);
|
|
480
506
|
};
|
|
481
507
|
}
|
|
482
|
-
function
|
|
508
|
+
function _slicedToArray(arr, i) {
|
|
509
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray$2(arr, i) || _nonIterableRest();
|
|
510
|
+
}
|
|
511
|
+
function _toConsumableArray$1(arr) {
|
|
512
|
+
return _arrayWithoutHoles$1(arr) || _iterableToArray$1(arr) || _unsupportedIterableToArray$2(arr) || _nonIterableSpread$1();
|
|
513
|
+
}
|
|
514
|
+
function _arrayWithoutHoles$1(arr) {
|
|
515
|
+
if (Array.isArray(arr))
|
|
516
|
+
return _arrayLikeToArray$2(arr);
|
|
517
|
+
}
|
|
518
|
+
function _arrayWithHoles(arr) {
|
|
519
|
+
if (Array.isArray(arr))
|
|
520
|
+
return arr;
|
|
521
|
+
}
|
|
522
|
+
function _iterableToArray$1(iter) {
|
|
523
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null)
|
|
524
|
+
return Array.from(iter);
|
|
525
|
+
}
|
|
526
|
+
function _unsupportedIterableToArray$2(o, minLen) {
|
|
527
|
+
if (!o)
|
|
528
|
+
return;
|
|
529
|
+
if (typeof o === "string")
|
|
530
|
+
return _arrayLikeToArray$2(o, minLen);
|
|
531
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
532
|
+
if (n === "Object" && o.constructor)
|
|
533
|
+
n = o.constructor.name;
|
|
534
|
+
if (n === "Map" || n === "Set")
|
|
535
|
+
return Array.from(o);
|
|
536
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
|
|
537
|
+
return _arrayLikeToArray$2(o, minLen);
|
|
538
|
+
}
|
|
539
|
+
function _arrayLikeToArray$2(arr, len) {
|
|
540
|
+
if (len == null || len > arr.length)
|
|
541
|
+
len = arr.length;
|
|
542
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++)
|
|
543
|
+
arr2[i] = arr[i];
|
|
544
|
+
return arr2;
|
|
545
|
+
}
|
|
546
|
+
function _nonIterableSpread$1() {
|
|
547
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
548
|
+
}
|
|
549
|
+
function _nonIterableRest() {
|
|
550
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
551
|
+
}
|
|
552
|
+
function _toPrimitive$3(input, hint) {
|
|
483
553
|
if (typeof input !== "object" || input === null)
|
|
484
554
|
return input;
|
|
485
555
|
var prim = input[Symbol.toPrimitive];
|
|
@@ -491,8 +561,8 @@
|
|
|
491
561
|
}
|
|
492
562
|
return (hint === "string" ? String : Number)(input);
|
|
493
563
|
}
|
|
494
|
-
function _toPropertyKey$
|
|
495
|
-
var key = _toPrimitive$
|
|
564
|
+
function _toPropertyKey$3(arg) {
|
|
565
|
+
var key = _toPrimitive$3(arg, "string");
|
|
496
566
|
return typeof key === "symbol" ? key : String(key);
|
|
497
567
|
}
|
|
498
568
|
function ownKeys$1(object, enumerableOnly) {
|
|
@@ -524,33 +594,33 @@
|
|
|
524
594
|
return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
|
|
525
595
|
}, _typeof$1(obj);
|
|
526
596
|
}
|
|
527
|
-
function _classCallCheck$
|
|
597
|
+
function _classCallCheck$2(instance, Constructor) {
|
|
528
598
|
if (!(instance instanceof Constructor)) {
|
|
529
599
|
throw new TypeError("Cannot call a class as a function");
|
|
530
600
|
}
|
|
531
601
|
}
|
|
532
|
-
function _defineProperties$
|
|
602
|
+
function _defineProperties$2(target, props) {
|
|
533
603
|
for (var i = 0; i < props.length; i++) {
|
|
534
604
|
var descriptor = props[i];
|
|
535
605
|
descriptor.enumerable = descriptor.enumerable || false;
|
|
536
606
|
descriptor.configurable = true;
|
|
537
607
|
if ("value" in descriptor)
|
|
538
608
|
descriptor.writable = true;
|
|
539
|
-
Object.defineProperty(target, _toPropertyKey$
|
|
609
|
+
Object.defineProperty(target, _toPropertyKey$2(descriptor.key), descriptor);
|
|
540
610
|
}
|
|
541
611
|
}
|
|
542
|
-
function _createClass$
|
|
612
|
+
function _createClass$2(Constructor, protoProps, staticProps) {
|
|
543
613
|
if (protoProps)
|
|
544
|
-
_defineProperties$
|
|
614
|
+
_defineProperties$2(Constructor.prototype, protoProps);
|
|
545
615
|
if (staticProps)
|
|
546
|
-
_defineProperties$
|
|
616
|
+
_defineProperties$2(Constructor, staticProps);
|
|
547
617
|
Object.defineProperty(Constructor, "prototype", {
|
|
548
618
|
writable: false
|
|
549
619
|
});
|
|
550
620
|
return Constructor;
|
|
551
621
|
}
|
|
552
622
|
function _defineProperty$1(obj, key, value) {
|
|
553
|
-
key = _toPropertyKey$
|
|
623
|
+
key = _toPropertyKey$2(key);
|
|
554
624
|
if (key in obj) {
|
|
555
625
|
Object.defineProperty(obj, key, {
|
|
556
626
|
value,
|
|
@@ -597,7 +667,7 @@
|
|
|
597
667
|
function _nonIterableSpread() {
|
|
598
668
|
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
669
|
}
|
|
600
|
-
function _toPrimitive$
|
|
670
|
+
function _toPrimitive$2(input, hint) {
|
|
601
671
|
if (typeof input !== "object" || input === null)
|
|
602
672
|
return input;
|
|
603
673
|
var prim = input[Symbol.toPrimitive];
|
|
@@ -609,8 +679,8 @@
|
|
|
609
679
|
}
|
|
610
680
|
return (hint === "string" ? String : Number)(input);
|
|
611
681
|
}
|
|
612
|
-
function _toPropertyKey$
|
|
613
|
-
var key = _toPrimitive$
|
|
682
|
+
function _toPropertyKey$2(arg) {
|
|
683
|
+
var key = _toPrimitive$2(arg, "string");
|
|
614
684
|
return typeof key === "symbol" ? key : String(key);
|
|
615
685
|
}
|
|
616
686
|
function getDefaultExportFromCjs(x) {
|
|
@@ -834,10 +904,10 @@
|
|
|
834
904
|
};
|
|
835
905
|
var XgplayerTimeRange = /* @__PURE__ */ function() {
|
|
836
906
|
function XgplayerTimeRange2(bufferedList) {
|
|
837
|
-
_classCallCheck$
|
|
907
|
+
_classCallCheck$2(this, XgplayerTimeRange2);
|
|
838
908
|
this.bufferedList = bufferedList;
|
|
839
909
|
}
|
|
840
|
-
_createClass$
|
|
910
|
+
_createClass$2(XgplayerTimeRange2, [{
|
|
841
911
|
key: "start",
|
|
842
912
|
value: function start(index) {
|
|
843
913
|
return this.bufferedList[index].start;
|
|
@@ -1543,7 +1613,7 @@
|
|
|
1543
1613
|
5: 5105,
|
|
1544
1614
|
6: 5106
|
|
1545
1615
|
};
|
|
1546
|
-
var Errors = /* @__PURE__ */ _createClass$
|
|
1616
|
+
var Errors = /* @__PURE__ */ _createClass$2(
|
|
1547
1617
|
function Errors2(player) {
|
|
1548
1618
|
var errorInfo = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
|
|
1549
1619
|
errorType: "",
|
|
@@ -1553,7 +1623,7 @@
|
|
|
1553
1623
|
ext: {},
|
|
1554
1624
|
mediaError: null
|
|
1555
1625
|
};
|
|
1556
|
-
_classCallCheck$
|
|
1626
|
+
_classCallCheck$2(this, Errors2);
|
|
1557
1627
|
var ERROR_TYPES = player && player.i18n ? player.i18n.ERROR_TYPES : null;
|
|
1558
1628
|
if (player.media) {
|
|
1559
1629
|
var mediaError = errorInfo.mediaError ? errorInfo.mediaError : player.media.error || {};
|
|
@@ -1770,7 +1840,7 @@
|
|
|
1770
1840
|
}
|
|
1771
1841
|
var BasePlugin = /* @__PURE__ */ function() {
|
|
1772
1842
|
function BasePlugin2(args) {
|
|
1773
|
-
_classCallCheck$
|
|
1843
|
+
_classCallCheck$2(this, BasePlugin2);
|
|
1774
1844
|
if (util.checkIsFunction(this.beforeCreate)) {
|
|
1775
1845
|
this.beforeCreate(args);
|
|
1776
1846
|
}
|
|
@@ -1784,7 +1854,7 @@
|
|
|
1784
1854
|
this.pluginName = "";
|
|
1785
1855
|
this.__init(args);
|
|
1786
1856
|
}
|
|
1787
|
-
_createClass$
|
|
1857
|
+
_createClass$2(BasePlugin2, [{
|
|
1788
1858
|
key: "beforeCreate",
|
|
1789
1859
|
value: function beforeCreate(args) {
|
|
1790
1860
|
}
|
|
@@ -2403,33 +2473,33 @@
|
|
|
2403
2473
|
});
|
|
2404
2474
|
};
|
|
2405
2475
|
}
|
|
2406
|
-
function _classCallCheck(instance, Constructor) {
|
|
2476
|
+
function _classCallCheck$1(instance, Constructor) {
|
|
2407
2477
|
if (!(instance instanceof Constructor)) {
|
|
2408
2478
|
throw new TypeError("Cannot call a class as a function");
|
|
2409
2479
|
}
|
|
2410
2480
|
}
|
|
2411
|
-
function _defineProperties(target, props) {
|
|
2481
|
+
function _defineProperties$1(target, props) {
|
|
2412
2482
|
for (var i = 0; i < props.length; i++) {
|
|
2413
2483
|
var descriptor = props[i];
|
|
2414
2484
|
descriptor.enumerable = descriptor.enumerable || false;
|
|
2415
2485
|
descriptor.configurable = true;
|
|
2416
2486
|
if ("value" in descriptor)
|
|
2417
2487
|
descriptor.writable = true;
|
|
2418
|
-
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
2488
|
+
Object.defineProperty(target, _toPropertyKey$1(descriptor.key), descriptor);
|
|
2419
2489
|
}
|
|
2420
2490
|
}
|
|
2421
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
|
2491
|
+
function _createClass$1(Constructor, protoProps, staticProps) {
|
|
2422
2492
|
if (protoProps)
|
|
2423
|
-
_defineProperties(Constructor.prototype, protoProps);
|
|
2493
|
+
_defineProperties$1(Constructor.prototype, protoProps);
|
|
2424
2494
|
if (staticProps)
|
|
2425
|
-
_defineProperties(Constructor, staticProps);
|
|
2495
|
+
_defineProperties$1(Constructor, staticProps);
|
|
2426
2496
|
Object.defineProperty(Constructor, "prototype", {
|
|
2427
2497
|
writable: false
|
|
2428
2498
|
});
|
|
2429
2499
|
return Constructor;
|
|
2430
2500
|
}
|
|
2431
2501
|
function _defineProperty(obj, key, value) {
|
|
2432
|
-
key = _toPropertyKey(key);
|
|
2502
|
+
key = _toPropertyKey$1(key);
|
|
2433
2503
|
if (key in obj) {
|
|
2434
2504
|
Object.defineProperty(obj, key, {
|
|
2435
2505
|
value,
|
|
@@ -2692,7 +2762,7 @@
|
|
|
2692
2762
|
}
|
|
2693
2763
|
};
|
|
2694
2764
|
}
|
|
2695
|
-
function _toPrimitive(input, hint) {
|
|
2765
|
+
function _toPrimitive$1(input, hint) {
|
|
2696
2766
|
if (typeof input !== "object" || input === null)
|
|
2697
2767
|
return input;
|
|
2698
2768
|
var prim = input[Symbol.toPrimitive];
|
|
@@ -2704,8 +2774,8 @@
|
|
|
2704
2774
|
}
|
|
2705
2775
|
return (hint === "string" ? String : Number)(input);
|
|
2706
2776
|
}
|
|
2707
|
-
function _toPropertyKey(arg) {
|
|
2708
|
-
var key = _toPrimitive(arg, "string");
|
|
2777
|
+
function _toPropertyKey$1(arg) {
|
|
2778
|
+
var key = _toPrimitive$1(arg, "string");
|
|
2709
2779
|
return typeof key === "symbol" ? key : String(key);
|
|
2710
2780
|
}
|
|
2711
2781
|
function createPublicPromise() {
|
|
@@ -2804,7 +2874,7 @@
|
|
|
2804
2874
|
var _super = _createSuper(StreamingError2);
|
|
2805
2875
|
function StreamingError2(type, subType, origin, payload, msg) {
|
|
2806
2876
|
var _this;
|
|
2807
|
-
_classCallCheck(this, StreamingError2);
|
|
2877
|
+
_classCallCheck$1(this, StreamingError2);
|
|
2808
2878
|
_this = _super.call(this, msg || (origin === null || origin === void 0 ? void 0 : origin.message));
|
|
2809
2879
|
_this.errorType = type === ERR.NETWORK_TIMEOUT ? ERR.NETWORK : type;
|
|
2810
2880
|
_this.originError = origin;
|
|
@@ -2817,7 +2887,7 @@
|
|
|
2817
2887
|
}
|
|
2818
2888
|
return _this;
|
|
2819
2889
|
}
|
|
2820
|
-
_createClass(StreamingError2, null, [{
|
|
2890
|
+
_createClass$1(StreamingError2, null, [{
|
|
2821
2891
|
key: "create",
|
|
2822
2892
|
value: function create(type, subType, origin, payload, msg) {
|
|
2823
2893
|
if (type instanceof StreamingError2) {
|
|
@@ -2853,7 +2923,7 @@
|
|
|
2853
2923
|
var SIMPLE_TYPE = ["Boolean", "Number", "String", "Undefined", "Null", "Date", "Object"];
|
|
2854
2924
|
var Logger = /* @__PURE__ */ function() {
|
|
2855
2925
|
function Logger2(name, config) {
|
|
2856
|
-
_classCallCheck(this, Logger2);
|
|
2926
|
+
_classCallCheck$1(this, Logger2);
|
|
2857
2927
|
this.name = name || "";
|
|
2858
2928
|
this._prefix = "[".concat(this.name, "]");
|
|
2859
2929
|
this.logCacheLevel = (config === null || config === void 0 ? void 0 : config.logCacheLevel) || 3;
|
|
@@ -2861,7 +2931,7 @@
|
|
|
2861
2931
|
this.logSize = 0;
|
|
2862
2932
|
this.logTextArray = [];
|
|
2863
2933
|
}
|
|
2864
|
-
_createClass(Logger2, [{
|
|
2934
|
+
_createClass$1(Logger2, [{
|
|
2865
2935
|
key: "debug",
|
|
2866
2936
|
value: function debug() {
|
|
2867
2937
|
var _console;
|
|
@@ -3039,7 +3109,7 @@
|
|
|
3039
3109
|
var _super = _createSuper(NetError2);
|
|
3040
3110
|
function NetError2(url, request, response, msg) {
|
|
3041
3111
|
var _this;
|
|
3042
|
-
_classCallCheck(this, NetError2);
|
|
3112
|
+
_classCallCheck$1(this, NetError2);
|
|
3043
3113
|
_this = _super.call(this, msg);
|
|
3044
3114
|
_defineProperty(_assertThisInitialized(_this), "retryCount", 0);
|
|
3045
3115
|
_defineProperty(_assertThisInitialized(_this), "isTimeout", false);
|
|
@@ -3052,7 +3122,7 @@
|
|
|
3052
3122
|
_this.response = response;
|
|
3053
3123
|
return _this;
|
|
3054
3124
|
}
|
|
3055
|
-
return _createClass(NetError2);
|
|
3125
|
+
return _createClass$1(NetError2);
|
|
3056
3126
|
}(/* @__PURE__ */ _wrapNativeSuper(Error));
|
|
3057
3127
|
var toString = Object.prototype.toString;
|
|
3058
3128
|
function isObject(a) {
|
|
@@ -3177,7 +3247,7 @@
|
|
|
3177
3247
|
var _super = _createSuper(FetchLoader2);
|
|
3178
3248
|
function FetchLoader2() {
|
|
3179
3249
|
var _this;
|
|
3180
|
-
_classCallCheck(this, FetchLoader2);
|
|
3250
|
+
_classCallCheck$1(this, FetchLoader2);
|
|
3181
3251
|
_this = _super.call(this);
|
|
3182
3252
|
_defineProperty(_assertThisInitialized(_this), "_abortController", null);
|
|
3183
3253
|
_defineProperty(_assertThisInitialized(_this), "_timeoutTimer", null);
|
|
@@ -3195,7 +3265,7 @@
|
|
|
3195
3265
|
_defineProperty(_assertThisInitialized(_this), "_priOptions", null);
|
|
3196
3266
|
return _this;
|
|
3197
3267
|
}
|
|
3198
|
-
_createClass(FetchLoader2, [{
|
|
3268
|
+
_createClass$1(FetchLoader2, [{
|
|
3199
3269
|
key: "load",
|
|
3200
3270
|
value: function load(_ref) {
|
|
3201
3271
|
var _this$_abortControlle, _this2 = this;
|
|
@@ -3629,7 +3699,7 @@
|
|
|
3629
3699
|
var _super = _createSuper(XhrLoader2);
|
|
3630
3700
|
function XhrLoader2() {
|
|
3631
3701
|
var _this;
|
|
3632
|
-
_classCallCheck(this, XhrLoader2);
|
|
3702
|
+
_classCallCheck$1(this, XhrLoader2);
|
|
3633
3703
|
_this = _super.call(this);
|
|
3634
3704
|
_defineProperty(_assertThisInitialized(_this), "_xhr", null);
|
|
3635
3705
|
_defineProperty(_assertThisInitialized(_this), "_aborted", false);
|
|
@@ -3659,7 +3729,7 @@
|
|
|
3659
3729
|
_defineProperty(_assertThisInitialized(_this), "_priOptions", null);
|
|
3660
3730
|
return _this;
|
|
3661
3731
|
}
|
|
3662
|
-
_createClass(XhrLoader2, [{
|
|
3732
|
+
_createClass$1(XhrLoader2, [{
|
|
3663
3733
|
key: "load",
|
|
3664
3734
|
value: function load(req) {
|
|
3665
3735
|
var _this2 = this;
|
|
@@ -3944,7 +4014,7 @@
|
|
|
3944
4014
|
var _excluded = ["retry", "retryDelay", "onRetryError", "transformError"];
|
|
3945
4015
|
var Task = /* @__PURE__ */ function() {
|
|
3946
4016
|
function Task2(type, config) {
|
|
3947
|
-
_classCallCheck(this, Task2);
|
|
4017
|
+
_classCallCheck$1(this, Task2);
|
|
3948
4018
|
this.promise = createPublicPromise();
|
|
3949
4019
|
this.alive = !!config.onProgress;
|
|
3950
4020
|
!config.logger && (config.logger = new Logger("Loader"));
|
|
@@ -3957,7 +4027,7 @@
|
|
|
3957
4027
|
this._retryCheckFunc = config.retryCheckFunc;
|
|
3958
4028
|
this._logger = config.logger;
|
|
3959
4029
|
}
|
|
3960
|
-
_createClass(Task2, [{
|
|
4030
|
+
_createClass$1(Task2, [{
|
|
3961
4031
|
key: "exec",
|
|
3962
4032
|
value: function exec() {
|
|
3963
4033
|
var _this = this;
|
|
@@ -4076,7 +4146,7 @@
|
|
|
4076
4146
|
var _super = _createSuper(NetLoader2);
|
|
4077
4147
|
function NetLoader2(cfg) {
|
|
4078
4148
|
var _this;
|
|
4079
|
-
_classCallCheck(this, NetLoader2);
|
|
4149
|
+
_classCallCheck$1(this, NetLoader2);
|
|
4080
4150
|
_this = _super.call(this, cfg);
|
|
4081
4151
|
_defineProperty(_assertThisInitialized(_this), "type", LoaderType.FETCH);
|
|
4082
4152
|
_defineProperty(_assertThisInitialized(_this), "_queue", []);
|
|
@@ -4091,7 +4161,7 @@
|
|
|
4091
4161
|
_this.log = cfg.logger;
|
|
4092
4162
|
return _this;
|
|
4093
4163
|
}
|
|
4094
|
-
_createClass(NetLoader2, [{
|
|
4164
|
+
_createClass$1(NetLoader2, [{
|
|
4095
4165
|
key: "isFetch",
|
|
4096
4166
|
value: function isFetch() {
|
|
4097
4167
|
return this.type === LoaderType.FETCH;
|
|
@@ -4195,7 +4265,8 @@
|
|
|
4195
4265
|
return NetLoader2;
|
|
4196
4266
|
}(EventEmitter);
|
|
4197
4267
|
var EXTEND_EVENTS = {
|
|
4198
|
-
RTC_STATE_CHANGE: "core.rtcstatechange"
|
|
4268
|
+
RTC_STATE_CHANGE: "core.rtcstatechange",
|
|
4269
|
+
RTC_NETWORK: "core.rtcnetwork"
|
|
4199
4270
|
};
|
|
4200
4271
|
var lib = {};
|
|
4201
4272
|
var parser$1 = {};
|
|
@@ -4885,7 +4956,60 @@
|
|
|
4885
4956
|
networkEvaluateInterval: 1e3,
|
|
4886
4957
|
delayHint: 0,
|
|
4887
4958
|
seamlesslyReload: false,
|
|
4888
|
-
|
|
4959
|
+
enableSei: false,
|
|
4960
|
+
enableOriginSdpLogger: false,
|
|
4961
|
+
checkStatsErrorDelay: 5e3,
|
|
4962
|
+
enableNetworkQuality: false,
|
|
4963
|
+
networkQuality: {
|
|
4964
|
+
networkQos: {
|
|
4965
|
+
1: {
|
|
4966
|
+
"maxRtt": 250,
|
|
4967
|
+
"maxLoss": 0.15
|
|
4968
|
+
},
|
|
4969
|
+
2: {
|
|
4970
|
+
"maxRtt": 500,
|
|
4971
|
+
"maxLoss": 0.3,
|
|
4972
|
+
"minRetransmittedRate": 0.2
|
|
4973
|
+
},
|
|
4974
|
+
3: {
|
|
4975
|
+
"maxRtt": 750,
|
|
4976
|
+
"maxLoss": 0.45,
|
|
4977
|
+
"minRetransmittedRate": 0.35
|
|
4978
|
+
},
|
|
4979
|
+
4: {
|
|
4980
|
+
"maxRtt": 1e3,
|
|
4981
|
+
"maxLoss": 0.6,
|
|
4982
|
+
"minRetransmittedRate": 0.5
|
|
4983
|
+
}
|
|
4984
|
+
},
|
|
4985
|
+
networkQoe: {
|
|
4986
|
+
audioDelay: 2e3,
|
|
4987
|
+
audioStallRadio: 0.3,
|
|
4988
|
+
videoDelay: 2e3,
|
|
4989
|
+
videoStallRadio: 0.6
|
|
4990
|
+
}
|
|
4991
|
+
},
|
|
4992
|
+
enableAdaptiveJitterBuffer: false,
|
|
4993
|
+
adaptiveJitterBuffer: {
|
|
4994
|
+
networkWindow: 3
|
|
4995
|
+
},
|
|
4996
|
+
networkStrategy: {
|
|
4997
|
+
1: {
|
|
4998
|
+
"jitterBuffer": null
|
|
4999
|
+
},
|
|
5000
|
+
2: {
|
|
5001
|
+
"jitterBuffer": 1.5
|
|
5002
|
+
},
|
|
5003
|
+
3: {
|
|
5004
|
+
"jitterBuffer": 2
|
|
5005
|
+
},
|
|
5006
|
+
4: {
|
|
5007
|
+
"jitterBuffer": 3
|
|
5008
|
+
},
|
|
5009
|
+
5: {
|
|
5010
|
+
"jitterBuffer": 3
|
|
5011
|
+
}
|
|
5012
|
+
}
|
|
4889
5013
|
}, opts);
|
|
4890
5014
|
}
|
|
4891
5015
|
function _getStats(stats) {
|
|
@@ -4900,10 +5024,11 @@
|
|
|
4900
5024
|
}
|
|
4901
5025
|
});
|
|
4902
5026
|
return inboundRtps.map(function(inbound) {
|
|
5027
|
+
var _inbound$mediaType;
|
|
4903
5028
|
var codec = stats.get(inbound.codecId);
|
|
4904
5029
|
var track = stats.get(inbound.trackId);
|
|
4905
5030
|
return {
|
|
4906
|
-
type: inbound.mediaType,
|
|
5031
|
+
type: (_inbound$mediaType = inbound.mediaType) !== null && _inbound$mediaType !== void 0 ? _inbound$mediaType : inbound.kind,
|
|
4907
5032
|
inboundRtp: inbound,
|
|
4908
5033
|
remoteOutBoundRtp: remoteOutboundRtps.find(function(x) {
|
|
4909
5034
|
return x.mediaType === inbound.mediaType;
|
|
@@ -4923,7 +5048,7 @@
|
|
|
4923
5048
|
});
|
|
4924
5049
|
}
|
|
4925
5050
|
function getStatsSnapshoot(stats) {
|
|
4926
|
-
var _v$
|
|
5051
|
+
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
5052
|
var v = stats === null || stats === void 0 ? void 0 : stats.filter(function(x) {
|
|
4928
5053
|
return x.type === "video";
|
|
4929
5054
|
})[0];
|
|
@@ -4932,6 +5057,7 @@
|
|
|
4932
5057
|
})[0];
|
|
4933
5058
|
var videoRemote;
|
|
4934
5059
|
var audioRemote;
|
|
5060
|
+
var averageJitterBufferDelay;
|
|
4935
5061
|
if (v && v.remoteOutBoundRtp) {
|
|
4936
5062
|
videoRemote = {
|
|
4937
5063
|
bytesSent: v.remoteOutBoundRtp.bytesSent,
|
|
@@ -4944,26 +5070,31 @@
|
|
|
4944
5070
|
packetsSent: a.remoteOutBoundRtp.packetsSent
|
|
4945
5071
|
};
|
|
4946
5072
|
}
|
|
5073
|
+
if ((v === null || v === void 0 ? void 0 : (_v$inboundRtp = v.inboundRtp) === null || _v$inboundRtp === void 0 ? void 0 : _v$inboundRtp.jitterBufferDelay) !== void 0) {
|
|
5074
|
+
var _v$inboundRtp2, _v$inboundRtp3;
|
|
5075
|
+
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;
|
|
5076
|
+
}
|
|
4947
5077
|
return {
|
|
4948
5078
|
video: !v ? void 0 : {
|
|
4949
5079
|
codec: (_v$codec = v.codec) === null || _v$codec === void 0 ? void 0 : _v$codec.mimeType,
|
|
4950
5080
|
payloadType: (_v$codec2 = v.codec) === null || _v$codec2 === void 0 ? void 0 : _v$codec2.payloadType,
|
|
4951
5081
|
sdpFmtpLine: (_v$codec3 = v.codec) === null || _v$codec3 === void 0 ? void 0 : _v$codec3.sdpFmtpLine,
|
|
4952
|
-
bytesReceived: ((_v$
|
|
4953
|
-
firCount: (_v$
|
|
4954
|
-
pliCount: (_v$
|
|
4955
|
-
frameHeight: (_v$
|
|
4956
|
-
frameWidth: (_v$
|
|
4957
|
-
framesDecoded: (_v$
|
|
4958
|
-
framesDropped: (_v$
|
|
4959
|
-
framesPerSecond: (_v$
|
|
4960
|
-
framesReceived: (_v$
|
|
4961
|
-
jitter: (_v$
|
|
4962
|
-
jitterBufferDelay: (_v$
|
|
4963
|
-
keyFramesDecoded: (_v$
|
|
4964
|
-
nackCount: (_v$
|
|
4965
|
-
packetsLost: ((_v$
|
|
4966
|
-
packetsReceived: ((_v$
|
|
5082
|
+
bytesReceived: ((_v$inboundRtp4 = v.inboundRtp) === null || _v$inboundRtp4 === void 0 ? void 0 : _v$inboundRtp4.bytesReceived) || 0,
|
|
5083
|
+
firCount: (_v$inboundRtp5 = v.inboundRtp) === null || _v$inboundRtp5 === void 0 ? void 0 : _v$inboundRtp5.firCount,
|
|
5084
|
+
pliCount: (_v$inboundRtp6 = v.inboundRtp) === null || _v$inboundRtp6 === void 0 ? void 0 : _v$inboundRtp6.pliCount,
|
|
5085
|
+
frameHeight: (_v$inboundRtp7 = v.inboundRtp) === null || _v$inboundRtp7 === void 0 ? void 0 : _v$inboundRtp7.frameHeight,
|
|
5086
|
+
frameWidth: (_v$inboundRtp8 = v.inboundRtp) === null || _v$inboundRtp8 === void 0 ? void 0 : _v$inboundRtp8.frameWidth,
|
|
5087
|
+
framesDecoded: (_v$inboundRtp9 = v.inboundRtp) === null || _v$inboundRtp9 === void 0 ? void 0 : _v$inboundRtp9.framesDecoded,
|
|
5088
|
+
framesDropped: (_v$inboundRtp10 = v.inboundRtp) === null || _v$inboundRtp10 === void 0 ? void 0 : _v$inboundRtp10.framesDropped,
|
|
5089
|
+
framesPerSecond: (_v$inboundRtp11 = v.inboundRtp) === null || _v$inboundRtp11 === void 0 ? void 0 : _v$inboundRtp11.framesPerSecond,
|
|
5090
|
+
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,
|
|
5091
|
+
jitter: (_v$inboundRtp13 = v.inboundRtp) === null || _v$inboundRtp13 === void 0 ? void 0 : _v$inboundRtp13.jitter,
|
|
5092
|
+
jitterBufferDelay: (_v$inboundRtp14 = v.inboundRtp) === null || _v$inboundRtp14 === void 0 ? void 0 : _v$inboundRtp14.jitterBufferDelay,
|
|
5093
|
+
keyFramesDecoded: (_v$inboundRtp15 = v.inboundRtp) === null || _v$inboundRtp15 === void 0 ? void 0 : _v$inboundRtp15.keyFramesDecoded,
|
|
5094
|
+
nackCount: (_v$inboundRtp16 = v.inboundRtp) === null || _v$inboundRtp16 === void 0 ? void 0 : _v$inboundRtp16.nackCount,
|
|
5095
|
+
packetsLost: ((_v$inboundRtp17 = v.inboundRtp) === null || _v$inboundRtp17 === void 0 ? void 0 : _v$inboundRtp17.packetsLost) || 0,
|
|
5096
|
+
packetsReceived: ((_v$inboundRtp18 = v.inboundRtp) === null || _v$inboundRtp18 === void 0 ? void 0 : _v$inboundRtp18.packetsReceived) || 0,
|
|
5097
|
+
averageJitterBufferDelay
|
|
4967
5098
|
},
|
|
4968
5099
|
audio: !a ? void 0 : {
|
|
4969
5100
|
codec: (_a$codec = a.codec) === null || _a$codec === void 0 ? void 0 : _a$codec.mimeType,
|
|
@@ -4986,7 +5117,7 @@
|
|
|
4986
5117
|
var NetworkEvaluate = /* @__PURE__ */ function() {
|
|
4987
5118
|
function NetworkEvaluate2(pc, interval) {
|
|
4988
5119
|
var _this = this;
|
|
4989
|
-
_classCallCheck$
|
|
5120
|
+
_classCallCheck$3(this, NetworkEvaluate2);
|
|
4990
5121
|
_defineProperty$2(this, "_pc", null);
|
|
4991
5122
|
_defineProperty$2(this, "_lastVideoStats", null);
|
|
4992
5123
|
_defineProperty$2(this, "_lastRemoteVideoStats", null);
|
|
@@ -5049,7 +5180,7 @@
|
|
|
5049
5180
|
this._timerInterval = interval;
|
|
5050
5181
|
this.start(interval);
|
|
5051
5182
|
}
|
|
5052
|
-
_createClass$
|
|
5183
|
+
_createClass$3(NetworkEvaluate2, [{
|
|
5053
5184
|
key: "start",
|
|
5054
5185
|
value: function start(interval) {
|
|
5055
5186
|
clearInterval(this._timer);
|
|
@@ -5135,105 +5266,1600 @@
|
|
|
5135
5266
|
}]);
|
|
5136
5267
|
return NetworkEvaluate2;
|
|
5137
5268
|
}();
|
|
5138
|
-
|
|
5139
|
-
|
|
5140
|
-
|
|
5141
|
-
|
|
5142
|
-
|
|
5143
|
-
|
|
5144
|
-
|
|
5145
|
-
|
|
5146
|
-
|
|
5147
|
-
|
|
5148
|
-
|
|
5149
|
-
|
|
5150
|
-
|
|
5151
|
-
|
|
5152
|
-
_defineProperty$2(_assertThisInitialized$1(_this), "_media", null);
|
|
5153
|
-
_defineProperty$2(_assertThisInitialized$1(_this), "_opts", null);
|
|
5154
|
-
_defineProperty$2(_assertThisInitialized$1(_this), "_loader", null);
|
|
5155
|
-
_defineProperty$2(_assertThisInitialized$1(_this), "_networkEvaluate", null);
|
|
5156
|
-
_defineProperty$2(_assertThisInitialized$1(_this), "_retry", 0);
|
|
5157
|
-
_defineProperty$2(_assertThisInitialized$1(_this), "_waitingTimer", 0);
|
|
5158
|
-
_defineProperty$2(_assertThisInitialized$1(_this), "_rctConnectStartTs", 0);
|
|
5159
|
-
_defineProperty$2(_assertThisInitialized$1(_this), "_isReplacing", false);
|
|
5160
|
-
_defineProperty$2(_assertThisInitialized$1(_this), "_onTrack", function(e) {
|
|
5161
|
-
logger.log("addTrack: ", e.track, e.streams);
|
|
5162
|
-
_this["_".concat(e.track.kind)] = e.track;
|
|
5269
|
+
function isSupported() {
|
|
5270
|
+
if (!window.RTCPeerConnection || !window.RTCPeerConnection.prototype.addTransceiver) {
|
|
5271
|
+
return false;
|
|
5272
|
+
}
|
|
5273
|
+
return true;
|
|
5274
|
+
}
|
|
5275
|
+
function getCapacity() {
|
|
5276
|
+
if (!isSupported())
|
|
5277
|
+
return Promise.reject("RTCPeerConnection no support");
|
|
5278
|
+
var pc;
|
|
5279
|
+
try {
|
|
5280
|
+
pc = new RTCPeerConnection();
|
|
5281
|
+
pc.addTransceiver("video", {
|
|
5282
|
+
direction: "recvonly"
|
|
5163
5283
|
});
|
|
5164
|
-
|
|
5165
|
-
|
|
5166
|
-
if (!(((_this$_pc = _this._pc) === null || _this$_pc === void 0 ? void 0 : _this$_pc.connectionState) === "connected" || ((_this$_pc2 = _this._pc) === null || _this$_pc2 === void 0 ? void 0 : _this$_pc2.iceConnectionState) === "connected"))
|
|
5167
|
-
return;
|
|
5168
|
-
clearTimeout(_this._waitingTimer);
|
|
5169
|
-
_this._waitingTimer = setTimeout(function() {
|
|
5170
|
-
var _this$_media;
|
|
5171
|
-
if ((_this$_media = _this._media) !== null && _this$_media !== void 0 && _this$_media.paused)
|
|
5172
|
-
return;
|
|
5173
|
-
_this.emit("waiting");
|
|
5174
|
-
}, _this._opts.stallInterval);
|
|
5284
|
+
pc.addTransceiver("audio", {
|
|
5285
|
+
direction: "recvonly"
|
|
5175
5286
|
});
|
|
5176
|
-
|
|
5177
|
-
|
|
5178
|
-
|
|
5179
|
-
|
|
5180
|
-
|
|
5181
|
-
|
|
5182
|
-
|
|
5183
|
-
|
|
5184
|
-
|
|
5185
|
-
|
|
5186
|
-
|
|
5187
|
-
|
|
5188
|
-
|
|
5189
|
-
|
|
5287
|
+
} catch (e) {
|
|
5288
|
+
return Promise.reject(e === null || e === void 0 ? void 0 : e.message);
|
|
5289
|
+
}
|
|
5290
|
+
return pc.createOffer().then(function(offer) {
|
|
5291
|
+
var _sdpJson$media, _sdpJson$media2, _vMedia$rtp, _aMedia$rtp;
|
|
5292
|
+
logger.log(offer.sdp);
|
|
5293
|
+
var sdpJson = lib.parse(offer.sdp);
|
|
5294
|
+
var vMedia = (_sdpJson$media = sdpJson.media) === null || _sdpJson$media === void 0 ? void 0 : _sdpJson$media.filter(function(x) {
|
|
5295
|
+
return x.type === "video";
|
|
5296
|
+
})[0];
|
|
5297
|
+
var aMedia = (_sdpJson$media2 = sdpJson.media) === null || _sdpJson$media2 === void 0 ? void 0 : _sdpJson$media2.filter(function(x) {
|
|
5298
|
+
return x.type === "audio";
|
|
5299
|
+
})[0];
|
|
5300
|
+
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) {
|
|
5301
|
+
return x.codec === "VP8" || x.codec === "VP9" || x.codec === "H264";
|
|
5190
5302
|
});
|
|
5191
|
-
|
|
5192
|
-
|
|
5193
|
-
error: StreamingError.network(error),
|
|
5194
|
-
retryTime
|
|
5195
|
-
});
|
|
5303
|
+
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) {
|
|
5304
|
+
return x.codec === "opus";
|
|
5196
5305
|
});
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
|
|
5204
|
-
|
|
5205
|
-
|
|
5206
|
-
|
|
5207
|
-
|
|
5208
|
-
|
|
5209
|
-
|
|
5210
|
-
|
|
5211
|
-
|
|
5212
|
-
|
|
5213
|
-
|
|
5214
|
-
|
|
5215
|
-
|
|
5216
|
-
|
|
5217
|
-
|
|
5218
|
-
|
|
5306
|
+
var vFmtp = vMedia === null || vMedia === void 0 ? void 0 : vMedia.fmtp;
|
|
5307
|
+
var aFmtp = aMedia === null || aMedia === void 0 ? void 0 : aMedia.fmtp;
|
|
5308
|
+
vFmtp && vCodecs.map(function(codec) {
|
|
5309
|
+
var _vFmtp$filter$;
|
|
5310
|
+
codec.config = (_vFmtp$filter$ = vFmtp.filter(function(x) {
|
|
5311
|
+
return x.payload === codec.payload;
|
|
5312
|
+
})[0]) === null || _vFmtp$filter$ === void 0 ? void 0 : _vFmtp$filter$.config;
|
|
5313
|
+
});
|
|
5314
|
+
aFmtp && aCodecs.map(function(codec) {
|
|
5315
|
+
var _aFmtp$filter$;
|
|
5316
|
+
codec.config = (_aFmtp$filter$ = aFmtp.filter(function(x) {
|
|
5317
|
+
return x.payload === codec.payload;
|
|
5318
|
+
})[0]) === null || _aFmtp$filter$ === void 0 ? void 0 : _aFmtp$filter$.config;
|
|
5319
|
+
});
|
|
5320
|
+
pc.close();
|
|
5321
|
+
return {
|
|
5322
|
+
video: vCodecs,
|
|
5323
|
+
audio: aCodecs
|
|
5324
|
+
};
|
|
5325
|
+
});
|
|
5326
|
+
}
|
|
5327
|
+
var isEncodedTransformSupported = function isEncodedTransformSupported2() {
|
|
5328
|
+
return typeof TransformStream !== "undefined" && typeof RTCRtpSender !== "undefined" && typeof RTCRtpReceiver !== "undefined" && typeof RTCRtpScriptTransform !== "undefined" && "transform" in RTCRtpSender.prototype && "transform" in RTCRtpReceiver.prototype && isWorkerSupported() && isMessageChannelSupported();
|
|
5329
|
+
};
|
|
5330
|
+
var isWorkerSupported = function isWorkerSupported2() {
|
|
5331
|
+
return typeof window !== "undefined" && window.Worker;
|
|
5332
|
+
};
|
|
5333
|
+
var isMessageChannelSupported = function isMessageChannelSupported2() {
|
|
5334
|
+
return typeof MessageChannel !== "undefined";
|
|
5335
|
+
};
|
|
5336
|
+
var isLegacyEncodedTransformSupported = function isLegacyEncodedTransformSupported2() {
|
|
5337
|
+
return typeof TransformStream !== "undefined" && typeof RTCRtpSender !== "undefined" && typeof RTCRtpReceiver !== "undefined" && typeof RTCRtpSender.prototype.createEncodedStreams !== "undefined" && typeof RTCRtpReceiver.prototype.createEncodedStreams !== "undefined";
|
|
5338
|
+
};
|
|
5339
|
+
var Nalunit = {
|
|
5340
|
+
getNALUnits: function getNALUnits(buffer) {
|
|
5341
|
+
var isH265 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
5342
|
+
if (buffer.length - buffer.position < 4) {
|
|
5343
|
+
return [];
|
|
5219
5344
|
}
|
|
5220
|
-
|
|
5221
|
-
|
|
5222
|
-
|
|
5223
|
-
|
|
5345
|
+
var position = buffer.position;
|
|
5346
|
+
if (buffer.getInt32(position) === 1 || buffer.getInt16(position) === 0 && buffer.getInt8(position + 2) === 1) {
|
|
5347
|
+
return Nalunit.getAnnexbNals(buffer, isH265);
|
|
5348
|
+
} else {
|
|
5349
|
+
return Nalunit.getAvccNals(buffer, isH265);
|
|
5224
5350
|
}
|
|
5225
|
-
},
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
|
|
5351
|
+
},
|
|
5352
|
+
getAnnexbNals: function getAnnexbNals(buffer, isH265) {
|
|
5353
|
+
var nals = [];
|
|
5354
|
+
var position = Nalunit.getHeaderPositionAnnexB(buffer);
|
|
5355
|
+
var start = position.pos;
|
|
5356
|
+
var end = start;
|
|
5357
|
+
while (start < buffer.length - 4) {
|
|
5358
|
+
var header = new Uint8Array(buffer.buffer.slice(start, start + position.headerLength));
|
|
5359
|
+
if (position.pos === buffer.position) {
|
|
5360
|
+
buffer.skip(position.headerLength);
|
|
5361
|
+
}
|
|
5362
|
+
position = Nalunit.getHeaderPositionAnnexB(buffer);
|
|
5363
|
+
end = position.pos;
|
|
5364
|
+
var body = new Uint8Array(buffer.buffer.slice(start + header.byteLength, end));
|
|
5365
|
+
var unit = {
|
|
5366
|
+
header,
|
|
5367
|
+
body,
|
|
5368
|
+
type: -1
|
|
5369
|
+
};
|
|
5370
|
+
isH265 ? Nalunit.analyseH265Nal(unit) : Nalunit.analyseNal(unit);
|
|
5371
|
+
if ((unit.type <= 9 || isH265 && unit.type <= 40) && unit.type !== 0) {
|
|
5372
|
+
nals.push(unit);
|
|
5373
|
+
}
|
|
5374
|
+
buffer.skip(end - buffer.position);
|
|
5375
|
+
start = end;
|
|
5229
5376
|
}
|
|
5230
|
-
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
|
|
5377
|
+
return nals;
|
|
5378
|
+
},
|
|
5379
|
+
getAvccNals: function getAvccNals(buffer, isH265) {
|
|
5380
|
+
var nals = [];
|
|
5381
|
+
while (buffer.position < buffer.length - 4) {
|
|
5382
|
+
var length = buffer.getInt32(buffer.position);
|
|
5383
|
+
if (buffer.length - buffer.position >= length) {
|
|
5384
|
+
var header = new Uint8Array(buffer.buffer.slice(buffer.position, buffer.position + 4));
|
|
5385
|
+
buffer.skip(4);
|
|
5386
|
+
var body = new Uint8Array(buffer.buffer.slice(buffer.position, buffer.position + length));
|
|
5387
|
+
buffer.skip(length);
|
|
5388
|
+
var unit = {
|
|
5389
|
+
header,
|
|
5390
|
+
body,
|
|
5391
|
+
type: -1
|
|
5392
|
+
};
|
|
5393
|
+
isH265 ? Nalunit.analyseH265Nal(unit) : Nalunit.analyseNal(unit);
|
|
5394
|
+
if (unit.type <= 9 && unit.type !== 0) {
|
|
5395
|
+
nals.push(unit);
|
|
5396
|
+
}
|
|
5397
|
+
} else {
|
|
5398
|
+
break;
|
|
5399
|
+
}
|
|
5234
5400
|
}
|
|
5235
|
-
|
|
5236
|
-
|
|
5401
|
+
return nals;
|
|
5402
|
+
},
|
|
5403
|
+
analyseNal: function analyseNal(unit) {
|
|
5404
|
+
var type = unit.body[0] & 31;
|
|
5405
|
+
unit.type = type;
|
|
5406
|
+
switch (type) {
|
|
5407
|
+
case 1:
|
|
5408
|
+
unit.ndr = true;
|
|
5409
|
+
break;
|
|
5410
|
+
case 5:
|
|
5411
|
+
unit.idr = true;
|
|
5412
|
+
break;
|
|
5413
|
+
case 6:
|
|
5414
|
+
unit.sei = true;
|
|
5415
|
+
break;
|
|
5416
|
+
case 7:
|
|
5417
|
+
unit.sps = true;
|
|
5418
|
+
break;
|
|
5419
|
+
case 8:
|
|
5420
|
+
unit.pps = true;
|
|
5421
|
+
break;
|
|
5422
|
+
}
|
|
5423
|
+
},
|
|
5424
|
+
analyseH265Nal: function analyseH265Nal(unit) {
|
|
5425
|
+
var type = (unit.body[0] & 126) >> 1;
|
|
5426
|
+
unit.type = type;
|
|
5427
|
+
switch (type) {
|
|
5428
|
+
case 39:
|
|
5429
|
+
case 40:
|
|
5430
|
+
unit.sei = true;
|
|
5431
|
+
break;
|
|
5432
|
+
}
|
|
5433
|
+
},
|
|
5434
|
+
getHeaderPositionAnnexB: function getHeaderPositionAnnexB(buffer) {
|
|
5435
|
+
var pos = buffer.position;
|
|
5436
|
+
var headerLength = 0;
|
|
5437
|
+
var bufferLen = buffer.length;
|
|
5438
|
+
while (headerLength !== 3 && headerLength !== 4 && pos < bufferLen - 4) {
|
|
5439
|
+
if (buffer.getInt16(pos) === 0) {
|
|
5440
|
+
if (buffer.getInt16(pos + 2) === 1) {
|
|
5441
|
+
headerLength = 4;
|
|
5442
|
+
} else if (buffer.getInt8(pos + 2) === 1) {
|
|
5443
|
+
headerLength = 3;
|
|
5444
|
+
} else {
|
|
5445
|
+
pos++;
|
|
5446
|
+
}
|
|
5447
|
+
} else {
|
|
5448
|
+
pos++;
|
|
5449
|
+
}
|
|
5450
|
+
}
|
|
5451
|
+
if (pos === bufferLen - 4) {
|
|
5452
|
+
if (buffer.getInt16(pos) === 0) {
|
|
5453
|
+
if (buffer.getInt16(pos + 2) === 1) {
|
|
5454
|
+
headerLength = 4;
|
|
5455
|
+
} else {
|
|
5456
|
+
pos = bufferLen;
|
|
5457
|
+
}
|
|
5458
|
+
} else {
|
|
5459
|
+
pos++;
|
|
5460
|
+
if (buffer.getInt16(pos) === 0 && buffer.getInt8(pos) === 1) {
|
|
5461
|
+
headerLength = 3;
|
|
5462
|
+
} else {
|
|
5463
|
+
pos = bufferLen;
|
|
5464
|
+
}
|
|
5465
|
+
}
|
|
5466
|
+
}
|
|
5467
|
+
return {
|
|
5468
|
+
pos,
|
|
5469
|
+
headerLength
|
|
5470
|
+
};
|
|
5471
|
+
},
|
|
5472
|
+
isH265VideoFrame: function isH265VideoFrame(chunk) {
|
|
5473
|
+
var _chunk$getMetadata, _chunk$getMetadata$ca;
|
|
5474
|
+
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");
|
|
5475
|
+
}
|
|
5476
|
+
};
|
|
5477
|
+
var RTCDataView = /* @__PURE__ */ function() {
|
|
5478
|
+
function RTCDataView2(buffer) {
|
|
5479
|
+
_classCallCheck$3(this, RTCDataView2);
|
|
5480
|
+
_defineProperty$2(this, "_position", 0);
|
|
5481
|
+
this._dataview = new DataView(buffer);
|
|
5482
|
+
}
|
|
5483
|
+
_createClass$3(RTCDataView2, [{
|
|
5484
|
+
key: "length",
|
|
5485
|
+
get: function get() {
|
|
5486
|
+
return this.buffer.byteLength;
|
|
5487
|
+
}
|
|
5488
|
+
}, {
|
|
5489
|
+
key: "buffer",
|
|
5490
|
+
get: function get() {
|
|
5491
|
+
return this._dataview.buffer;
|
|
5492
|
+
}
|
|
5493
|
+
}, {
|
|
5494
|
+
key: "position",
|
|
5495
|
+
get: function get() {
|
|
5496
|
+
return this._position;
|
|
5497
|
+
},
|
|
5498
|
+
set: function set(value) {
|
|
5499
|
+
this._position = value;
|
|
5500
|
+
}
|
|
5501
|
+
}, {
|
|
5502
|
+
key: "back",
|
|
5503
|
+
value: function back(count) {
|
|
5504
|
+
this.position -= count;
|
|
5505
|
+
}
|
|
5506
|
+
}, {
|
|
5507
|
+
key: "getUint8",
|
|
5508
|
+
value: function getUint8(offset) {
|
|
5509
|
+
return this._dataview.getUint8(offset);
|
|
5510
|
+
}
|
|
5511
|
+
}, {
|
|
5512
|
+
key: "getInt8",
|
|
5513
|
+
value: function getInt8(offset) {
|
|
5514
|
+
return this._dataview.getInt8(offset);
|
|
5515
|
+
}
|
|
5516
|
+
}, {
|
|
5517
|
+
key: "getInt16",
|
|
5518
|
+
value: function getInt16(offset) {
|
|
5519
|
+
return this._dataview.getInt16(offset);
|
|
5520
|
+
}
|
|
5521
|
+
}, {
|
|
5522
|
+
key: "getUint16",
|
|
5523
|
+
value: function getUint16(offset) {
|
|
5524
|
+
return this._dataview.getUint16(offset);
|
|
5525
|
+
}
|
|
5526
|
+
}, {
|
|
5527
|
+
key: "getUint32",
|
|
5528
|
+
value: function getUint32(offset) {
|
|
5529
|
+
return this._dataview.getUint32(offset);
|
|
5530
|
+
}
|
|
5531
|
+
}, {
|
|
5532
|
+
key: "getInt32",
|
|
5533
|
+
value: function getInt32(offset) {
|
|
5534
|
+
return this._dataview.getInt32(offset);
|
|
5535
|
+
}
|
|
5536
|
+
}, {
|
|
5537
|
+
key: "skip",
|
|
5538
|
+
value: function skip(count) {
|
|
5539
|
+
var loop = Math.floor(count / 4);
|
|
5540
|
+
var last = count % 4;
|
|
5541
|
+
for (var i = 0; i < loop; i++) {
|
|
5542
|
+
RTCDataView2.readByte(this, 4);
|
|
5543
|
+
}
|
|
5544
|
+
if (last > 0) {
|
|
5545
|
+
RTCDataView2.readByte(this, last);
|
|
5546
|
+
}
|
|
5547
|
+
}
|
|
5548
|
+
}, {
|
|
5549
|
+
key: "readUint8",
|
|
5550
|
+
value: function readUint8() {
|
|
5551
|
+
return RTCDataView2.readByte(this, 1);
|
|
5552
|
+
}
|
|
5553
|
+
}, {
|
|
5554
|
+
key: "readUint16",
|
|
5555
|
+
value: function readUint16() {
|
|
5556
|
+
return RTCDataView2.readByte(this, 2);
|
|
5557
|
+
}
|
|
5558
|
+
}, {
|
|
5559
|
+
key: "readUint24",
|
|
5560
|
+
value: function readUint24() {
|
|
5561
|
+
return RTCDataView2.readByte(this, 3);
|
|
5562
|
+
}
|
|
5563
|
+
}, {
|
|
5564
|
+
key: "readUint32",
|
|
5565
|
+
value: function readUint32() {
|
|
5566
|
+
return RTCDataView2.readByte(this, 4);
|
|
5567
|
+
}
|
|
5568
|
+
}, {
|
|
5569
|
+
key: "readUint64",
|
|
5570
|
+
value: function readUint64() {
|
|
5571
|
+
return RTCDataView2.readByte(this, 8);
|
|
5572
|
+
}
|
|
5573
|
+
}, {
|
|
5574
|
+
key: "readInt8",
|
|
5575
|
+
value: function readInt8() {
|
|
5576
|
+
return RTCDataView2.readByte(this, 1, true);
|
|
5577
|
+
}
|
|
5578
|
+
}, {
|
|
5579
|
+
key: "readInt16",
|
|
5580
|
+
value: function readInt16() {
|
|
5581
|
+
return RTCDataView2.readByte(this, 2, true);
|
|
5582
|
+
}
|
|
5583
|
+
}, {
|
|
5584
|
+
key: "readInt32",
|
|
5585
|
+
value: function readInt32() {
|
|
5586
|
+
return RTCDataView2.readByte(this, 4, true);
|
|
5587
|
+
}
|
|
5588
|
+
}, {
|
|
5589
|
+
key: "writeUint32",
|
|
5590
|
+
value: function writeUint32(value) {
|
|
5591
|
+
return new Uint8Array([value >>> 24 & 255, value >>> 16 & 255, value >>> 8 & 255, value & 255]);
|
|
5592
|
+
}
|
|
5593
|
+
}], [{
|
|
5594
|
+
key: "readByte",
|
|
5595
|
+
value: function readByte(buffer, size, sign) {
|
|
5596
|
+
var res;
|
|
5597
|
+
switch (size) {
|
|
5598
|
+
case 1:
|
|
5599
|
+
if (sign) {
|
|
5600
|
+
res = buffer.getInt8(buffer.position);
|
|
5601
|
+
} else {
|
|
5602
|
+
res = buffer.getUint8(buffer.position);
|
|
5603
|
+
}
|
|
5604
|
+
break;
|
|
5605
|
+
case 2:
|
|
5606
|
+
if (sign) {
|
|
5607
|
+
res = buffer.getInt16(buffer.position);
|
|
5608
|
+
} else {
|
|
5609
|
+
res = buffer.getUint16(buffer.position);
|
|
5610
|
+
}
|
|
5611
|
+
break;
|
|
5612
|
+
case 3:
|
|
5613
|
+
if (sign) {
|
|
5614
|
+
throw new Error("not supported for readByte 3");
|
|
5615
|
+
} else {
|
|
5616
|
+
res = buffer.getUint8(buffer.position) << 16;
|
|
5617
|
+
res |= buffer.getUint8(buffer.position + 1) << 8;
|
|
5618
|
+
res |= buffer.getUint8(buffer.position + 2);
|
|
5619
|
+
}
|
|
5620
|
+
break;
|
|
5621
|
+
case 4:
|
|
5622
|
+
if (sign) {
|
|
5623
|
+
res = buffer.getInt32(buffer.position);
|
|
5624
|
+
} else {
|
|
5625
|
+
res = buffer.getUint32(buffer.position);
|
|
5626
|
+
}
|
|
5627
|
+
break;
|
|
5628
|
+
case 8:
|
|
5629
|
+
if (sign) {
|
|
5630
|
+
throw new Error("not supported for readBody 8");
|
|
5631
|
+
} else {
|
|
5632
|
+
res = buffer.getUint32(buffer.position) << 32;
|
|
5633
|
+
res |= buffer.getUint32(buffer.position + 4);
|
|
5634
|
+
}
|
|
5635
|
+
break;
|
|
5636
|
+
default:
|
|
5637
|
+
res = "";
|
|
5638
|
+
}
|
|
5639
|
+
buffer.position += size;
|
|
5640
|
+
return res;
|
|
5641
|
+
}
|
|
5642
|
+
}]);
|
|
5643
|
+
return RTCDataView2;
|
|
5644
|
+
}();
|
|
5645
|
+
function _classCallCheck(instance, Constructor) {
|
|
5646
|
+
if (!(instance instanceof Constructor)) {
|
|
5647
|
+
throw new TypeError("Cannot call a class as a function");
|
|
5648
|
+
}
|
|
5649
|
+
}
|
|
5650
|
+
function _defineProperties(target, props) {
|
|
5651
|
+
for (var i = 0; i < props.length; i++) {
|
|
5652
|
+
var descriptor = props[i];
|
|
5653
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
5654
|
+
descriptor.configurable = true;
|
|
5655
|
+
if ("value" in descriptor)
|
|
5656
|
+
descriptor.writable = true;
|
|
5657
|
+
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
5658
|
+
}
|
|
5659
|
+
}
|
|
5660
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
5661
|
+
if (protoProps)
|
|
5662
|
+
_defineProperties(Constructor.prototype, protoProps);
|
|
5663
|
+
if (staticProps)
|
|
5664
|
+
_defineProperties(Constructor, staticProps);
|
|
5665
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
5666
|
+
writable: false
|
|
5667
|
+
});
|
|
5668
|
+
return Constructor;
|
|
5669
|
+
}
|
|
5670
|
+
function _toPrimitive(input, hint) {
|
|
5671
|
+
if (typeof input !== "object" || input === null)
|
|
5672
|
+
return input;
|
|
5673
|
+
var prim = input[Symbol.toPrimitive];
|
|
5674
|
+
if (prim !== void 0) {
|
|
5675
|
+
var res = prim.call(input, hint || "default");
|
|
5676
|
+
if (typeof res !== "object")
|
|
5677
|
+
return res;
|
|
5678
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
5679
|
+
}
|
|
5680
|
+
return (hint === "string" ? String : Number)(input);
|
|
5681
|
+
}
|
|
5682
|
+
function _toPropertyKey(arg) {
|
|
5683
|
+
var key = _toPrimitive(arg, "string");
|
|
5684
|
+
return typeof key === "symbol" ? key : String(key);
|
|
5685
|
+
}
|
|
5686
|
+
function readBig32(data) {
|
|
5687
|
+
var i = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
|
|
5688
|
+
return (data[i] << 24 >>> 0) + (data[i + 1] << 16) + (data[i + 2] << 8) + (data[i + 3] || 0);
|
|
5689
|
+
}
|
|
5690
|
+
var NALu = /* @__PURE__ */ function() {
|
|
5691
|
+
function NALu2() {
|
|
5692
|
+
_classCallCheck(this, NALu2);
|
|
5693
|
+
}
|
|
5694
|
+
_createClass(NALu2, null, [{
|
|
5695
|
+
key: "parseAnnexB",
|
|
5696
|
+
value: function parseAnnexB(data) {
|
|
5697
|
+
var j = data.byteLength - 1;
|
|
5698
|
+
var dropZerosLength = 0;
|
|
5699
|
+
do {
|
|
5700
|
+
if (data[j] === 0) {
|
|
5701
|
+
dropZerosLength++;
|
|
5702
|
+
} else {
|
|
5703
|
+
break;
|
|
5704
|
+
}
|
|
5705
|
+
j--;
|
|
5706
|
+
} while (j > 0);
|
|
5707
|
+
if (dropZerosLength >= 3) {
|
|
5708
|
+
data = data.subarray(0, j + 1);
|
|
5709
|
+
}
|
|
5710
|
+
var len = data.length;
|
|
5711
|
+
var start = 2;
|
|
5712
|
+
var end = 0;
|
|
5713
|
+
while (data[start] !== null && data[start] !== void 0 && data[start] !== 1) {
|
|
5714
|
+
start++;
|
|
5715
|
+
}
|
|
5716
|
+
start++;
|
|
5717
|
+
end = start + 2;
|
|
5718
|
+
if (end >= len)
|
|
5719
|
+
return [];
|
|
5720
|
+
var units = [];
|
|
5721
|
+
while (end < len) {
|
|
5722
|
+
switch (data[end]) {
|
|
5723
|
+
case 0:
|
|
5724
|
+
if (data[end - 1] !== 0) {
|
|
5725
|
+
end += 2;
|
|
5726
|
+
break;
|
|
5727
|
+
} else if (data[end - 2] !== 0) {
|
|
5728
|
+
end++;
|
|
5729
|
+
break;
|
|
5730
|
+
} else if (end < len - 1 && data[end + 1] !== 1) {
|
|
5731
|
+
end++;
|
|
5732
|
+
break;
|
|
5733
|
+
}
|
|
5734
|
+
if (start !== end - 2)
|
|
5735
|
+
units.push(data.subarray(start, end - 2));
|
|
5736
|
+
do {
|
|
5737
|
+
end++;
|
|
5738
|
+
} while (data[end] !== 1 && end < len);
|
|
5739
|
+
start = end + 1;
|
|
5740
|
+
end = start + 2;
|
|
5741
|
+
break;
|
|
5742
|
+
case 1:
|
|
5743
|
+
if (data[end - 1] !== 0 || data[end - 2] !== 0) {
|
|
5744
|
+
end += 3;
|
|
5745
|
+
break;
|
|
5746
|
+
}
|
|
5747
|
+
if (start !== end - 2)
|
|
5748
|
+
units.push(data.subarray(start, end - 2));
|
|
5749
|
+
start = end + 1;
|
|
5750
|
+
end = start + 2;
|
|
5751
|
+
break;
|
|
5752
|
+
default:
|
|
5753
|
+
end += 3;
|
|
5754
|
+
break;
|
|
5755
|
+
}
|
|
5756
|
+
}
|
|
5757
|
+
if (start < len)
|
|
5758
|
+
units.push(data.subarray(start));
|
|
5759
|
+
return units;
|
|
5760
|
+
}
|
|
5761
|
+
}, {
|
|
5762
|
+
key: "parseAvcC",
|
|
5763
|
+
value: function parseAvcC(data) {
|
|
5764
|
+
var size = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 4;
|
|
5765
|
+
if (data.length < 4)
|
|
5766
|
+
return;
|
|
5767
|
+
var dataLen = data.length;
|
|
5768
|
+
var units = [];
|
|
5769
|
+
var offset = 0;
|
|
5770
|
+
var length;
|
|
5771
|
+
while (offset + size < dataLen) {
|
|
5772
|
+
length = readBig32(data, offset);
|
|
5773
|
+
if (size === 3)
|
|
5774
|
+
length >>>= 8;
|
|
5775
|
+
offset += size;
|
|
5776
|
+
if (!length)
|
|
5777
|
+
continue;
|
|
5778
|
+
if (offset + length > dataLen) {
|
|
5779
|
+
break;
|
|
5780
|
+
}
|
|
5781
|
+
units.push(data.subarray(offset, offset + length));
|
|
5782
|
+
offset += length;
|
|
5783
|
+
}
|
|
5784
|
+
return units;
|
|
5785
|
+
}
|
|
5786
|
+
}, {
|
|
5787
|
+
key: "parseSEI",
|
|
5788
|
+
value: function parseSEI(unit, isHevc) {
|
|
5789
|
+
var len = unit.length;
|
|
5790
|
+
var i = isHevc ? 2 : 1;
|
|
5791
|
+
var type = 0;
|
|
5792
|
+
var size = 0;
|
|
5793
|
+
var uuid = "";
|
|
5794
|
+
while (unit[i] === 255) {
|
|
5795
|
+
type += 255;
|
|
5796
|
+
i++;
|
|
5797
|
+
}
|
|
5798
|
+
type += unit[i++];
|
|
5799
|
+
while (unit[i] === 255) {
|
|
5800
|
+
size += 255;
|
|
5801
|
+
i++;
|
|
5802
|
+
}
|
|
5803
|
+
size += unit[i++];
|
|
5804
|
+
if (type === 5 && len > i + 16) {
|
|
5805
|
+
for (var j = 0; j < 16; j++) {
|
|
5806
|
+
uuid += unit[i].toString(16);
|
|
5807
|
+
i++;
|
|
5808
|
+
}
|
|
5809
|
+
}
|
|
5810
|
+
return {
|
|
5811
|
+
payload: unit.subarray(i, i + size),
|
|
5812
|
+
type,
|
|
5813
|
+
size,
|
|
5814
|
+
uuid
|
|
5815
|
+
};
|
|
5816
|
+
}
|
|
5817
|
+
}, {
|
|
5818
|
+
key: "removeEPB",
|
|
5819
|
+
value: function removeEPB(uint) {
|
|
5820
|
+
var length = uint.byteLength;
|
|
5821
|
+
var emulationPreventionBytesPositions = [];
|
|
5822
|
+
var i = 1;
|
|
5823
|
+
while (i < length - 2) {
|
|
5824
|
+
if (uint[i] === 0 && uint[i + 1] === 0 && uint[i + 2] === 3) {
|
|
5825
|
+
emulationPreventionBytesPositions.push(i + 2);
|
|
5826
|
+
i += 2;
|
|
5827
|
+
} else {
|
|
5828
|
+
i++;
|
|
5829
|
+
}
|
|
5830
|
+
}
|
|
5831
|
+
if (!emulationPreventionBytesPositions.length)
|
|
5832
|
+
return uint;
|
|
5833
|
+
var newLength = length - emulationPreventionBytesPositions.length;
|
|
5834
|
+
var newData = new Uint8Array(newLength);
|
|
5835
|
+
var sourceIndex = 0;
|
|
5836
|
+
for (i = 0; i < newLength; sourceIndex++, i++) {
|
|
5837
|
+
if (sourceIndex === emulationPreventionBytesPositions[0]) {
|
|
5838
|
+
sourceIndex++;
|
|
5839
|
+
emulationPreventionBytesPositions.shift();
|
|
5840
|
+
}
|
|
5841
|
+
newData[i] = uint[sourceIndex];
|
|
5842
|
+
}
|
|
5843
|
+
return newData;
|
|
5844
|
+
}
|
|
5845
|
+
}]);
|
|
5846
|
+
return NALu2;
|
|
5847
|
+
}();
|
|
5848
|
+
function receiveSEITransform(postMessage) {
|
|
5849
|
+
var transform = new TransformStream({
|
|
5850
|
+
transform: function transform2(encodedFrame, controller) {
|
|
5851
|
+
var isH265 = Nalunit.isH265VideoFrame(encodedFrame);
|
|
5852
|
+
var NALs = Nalunit.getNALUnits(new RTCDataView(encodedFrame.data), isH265);
|
|
5853
|
+
NALs.forEach(function(nalUnit) {
|
|
5854
|
+
if (nalUnit.sei) {
|
|
5855
|
+
var decodedSei = NALu.parseSEI(NALu.removeEPB(nalUnit.body), false);
|
|
5856
|
+
if (decodedSei) {
|
|
5857
|
+
postMessage({
|
|
5858
|
+
data: decodedSei,
|
|
5859
|
+
sei: {
|
|
5860
|
+
code: decodedSei.type,
|
|
5861
|
+
content: decodedSei.payload
|
|
5862
|
+
}
|
|
5863
|
+
});
|
|
5864
|
+
}
|
|
5865
|
+
}
|
|
5866
|
+
});
|
|
5867
|
+
controller.enqueue(encodedFrame);
|
|
5868
|
+
}
|
|
5869
|
+
});
|
|
5870
|
+
return transform;
|
|
5871
|
+
}
|
|
5872
|
+
if (typeof self !== "undefined" && self.constructor.name === "DedicatedWorkerGlobalScope") {
|
|
5873
|
+
self.addEventListener("rtctransform", function(event) {
|
|
5874
|
+
var transformer = event.transformer;
|
|
5875
|
+
var port = transformer.options.port;
|
|
5876
|
+
var transform = receiveSEITransform(function(msg) {
|
|
5877
|
+
port.postMessage(msg);
|
|
5878
|
+
});
|
|
5879
|
+
transformer.readable.pipeThrough(transform).pipeTo(event.transformer.writable);
|
|
5880
|
+
});
|
|
5881
|
+
}
|
|
5882
|
+
var encodedJs = "IWZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO3ZhciBlPXtnZXROQUxVbml0czpmdW5jdGlvbih0KXt2YXIgbj1hcmd1bWVudHMubGVuZ3RoPjEmJnZvaWQgMCE9PWFyZ3VtZW50c1sxXSYmYXJndW1lbnRzWzFdO2lmK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lKGUpfSxuZXcgVHJhbnNmb3JtU3RyZWFtKHt0cmFuc2Zvcm06ZnVuY3Rpb24odCxyKXt2YXIgYT1lLmlzSDI2NVZpZGVvRnJhbWUodCk7ZS5nZXROQUxVbml0cyhuZXcgaSh0LmRhdGEpLGEpLmZvckVhY2goKGZ1bmN0aW9uKGUpe2lmKGUuc2VpKXt2YXIgdD11LnBhcnNlU0VJKHUucmVtb3ZlRVBCKGUuYm9keSksITEpO3QmJm4oe2RhdGE6dCxzZWk6e2NvZGU6dC50eXBlLGNvbnRlbnQ6dC5wYXlsb2FkfX0pfX0pKSxyLmVucXVldWUodCl9fSkpO3IucmVhZGFibGUucGlwZVRocm91Z2gobykucGlwZVRvKHQudHJhbnNmb3JtZXIud3JpdGFibGUpfSkpfSgpOwo=";
|
|
5883
|
+
var blob = typeof window !== "undefined" && window.Blob && new Blob([atob(encodedJs)], {
|
|
5884
|
+
type: "text/javascript;charset=utf-8"
|
|
5885
|
+
});
|
|
5886
|
+
function WorkerWrapper() {
|
|
5887
|
+
var objURL = blob && (window.URL || window.webkitURL).createObjectURL(blob);
|
|
5888
|
+
try {
|
|
5889
|
+
return objURL ? new Worker(objURL, {}) : new Worker("data:application/javascript;base64," + encodedJs, {
|
|
5890
|
+
type: "module"
|
|
5891
|
+
});
|
|
5892
|
+
} finally {
|
|
5893
|
+
objURL && (window.URL || window.webkitURL).revokeObjectURL(objURL);
|
|
5894
|
+
}
|
|
5895
|
+
}
|
|
5896
|
+
var AudioStallObserver = /* @__PURE__ */ function() {
|
|
5897
|
+
function AudioStallObserver2() {
|
|
5898
|
+
_classCallCheck$3(this, AudioStallObserver2);
|
|
5899
|
+
_defineProperty$2(this, "_audioStallTimer", null);
|
|
5900
|
+
_defineProperty$2(this, "_preSample", null);
|
|
5901
|
+
_defineProperty$2(this, "_isStallInPreReportEnd", false);
|
|
5902
|
+
_defineProperty$2(this, "_stallList", []);
|
|
5903
|
+
_defineProperty$2(this, "_audioTransceiver", null);
|
|
5904
|
+
}
|
|
5905
|
+
_createClass$3(AudioStallObserver2, [{
|
|
5906
|
+
key: "start",
|
|
5907
|
+
value: function start(transceiver) {
|
|
5908
|
+
this.stop();
|
|
5909
|
+
this._audioTransceiver = transceiver;
|
|
5910
|
+
if (AudioStallObserver2.interval >= 100) {
|
|
5911
|
+
this._startStallCountInterval();
|
|
5912
|
+
}
|
|
5913
|
+
}
|
|
5914
|
+
}, {
|
|
5915
|
+
key: "stop",
|
|
5916
|
+
value: function stop() {
|
|
5917
|
+
this._stallList = [];
|
|
5918
|
+
if (this._audioStallTimer) {
|
|
5919
|
+
clearTimeout(this._audioStallTimer);
|
|
5920
|
+
this._audioStallTimer = null;
|
|
5921
|
+
}
|
|
5922
|
+
}
|
|
5923
|
+
}, {
|
|
5924
|
+
key: "destroy",
|
|
5925
|
+
value: function destroy() {
|
|
5926
|
+
this.stop();
|
|
5927
|
+
this._audioTransceiver = null;
|
|
5928
|
+
}
|
|
5929
|
+
}, {
|
|
5930
|
+
key: "getAudioStallInfo",
|
|
5931
|
+
value: function() {
|
|
5932
|
+
var _getAudioStallInfo = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee() {
|
|
5933
|
+
var extra, reportInfo;
|
|
5934
|
+
return _regeneratorRuntime$1().wrap(function _callee$(_context) {
|
|
5935
|
+
while (1)
|
|
5936
|
+
switch (_context.prev = _context.next) {
|
|
5937
|
+
case 0:
|
|
5938
|
+
extra = {
|
|
5939
|
+
stats_count: this._stallList.filter(function(v) {
|
|
5940
|
+
return v.get_stats_cost;
|
|
5941
|
+
}).length,
|
|
5942
|
+
stall_list: _toConsumableArray$1(this._stallList)
|
|
5943
|
+
};
|
|
5944
|
+
_context.prev = 1;
|
|
5945
|
+
_context.next = 4;
|
|
5946
|
+
return this._audioStallCount();
|
|
5947
|
+
case 4:
|
|
5948
|
+
_context.next = 8;
|
|
5949
|
+
break;
|
|
5950
|
+
case 6:
|
|
5951
|
+
_context.prev = 6;
|
|
5952
|
+
_context.t0 = _context["catch"](1);
|
|
5953
|
+
case 8:
|
|
5954
|
+
reportInfo = computeStallInfo(this._stallList, 2, this._isStallInPreReportEnd);
|
|
5955
|
+
this._isStallInPreReportEnd = reportInfo.isStallInEnd;
|
|
5956
|
+
this.stop();
|
|
5957
|
+
this._startStallCountInterval();
|
|
5958
|
+
return _context.abrupt("return", {
|
|
5959
|
+
stallCount: reportInfo.stall_count,
|
|
5960
|
+
stallDuration: reportInfo.stall_duration,
|
|
5961
|
+
list: reportInfo.list,
|
|
5962
|
+
extra
|
|
5963
|
+
});
|
|
5964
|
+
case 13:
|
|
5965
|
+
case "end":
|
|
5966
|
+
return _context.stop();
|
|
5967
|
+
}
|
|
5968
|
+
}, _callee, this, [[1, 6]]);
|
|
5969
|
+
}));
|
|
5970
|
+
function getAudioStallInfo() {
|
|
5971
|
+
return _getAudioStallInfo.apply(this, arguments);
|
|
5972
|
+
}
|
|
5973
|
+
return getAudioStallInfo;
|
|
5974
|
+
}()
|
|
5975
|
+
}, {
|
|
5976
|
+
key: "_startStallCountInterval",
|
|
5977
|
+
value: function _startStallCountInterval() {
|
|
5978
|
+
var _this = this;
|
|
5979
|
+
var loop = /* @__PURE__ */ function() {
|
|
5980
|
+
var _ref = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee2() {
|
|
5981
|
+
return _regeneratorRuntime$1().wrap(function _callee2$(_context2) {
|
|
5982
|
+
while (1)
|
|
5983
|
+
switch (_context2.prev = _context2.next) {
|
|
5984
|
+
case 0:
|
|
5985
|
+
clearTimeout(_this._audioStallTimer);
|
|
5986
|
+
_this._audioStallTimer = null;
|
|
5987
|
+
_context2.next = 4;
|
|
5988
|
+
return _this._audioStallCount();
|
|
5989
|
+
case 4:
|
|
5990
|
+
if (!_this._audioStallTimer) {
|
|
5991
|
+
_this._audioStallTimer = setTimeout(loop, AudioStallObserver2.interval);
|
|
5992
|
+
}
|
|
5993
|
+
case 5:
|
|
5994
|
+
case "end":
|
|
5995
|
+
return _context2.stop();
|
|
5996
|
+
}
|
|
5997
|
+
}, _callee2);
|
|
5998
|
+
}));
|
|
5999
|
+
return function loop2() {
|
|
6000
|
+
return _ref.apply(this, arguments);
|
|
6001
|
+
};
|
|
6002
|
+
}();
|
|
6003
|
+
this._audioStallTimer = setTimeout(loop, AudioStallObserver2.interval);
|
|
6004
|
+
}
|
|
6005
|
+
}, {
|
|
6006
|
+
key: "_audioStallCount",
|
|
6007
|
+
value: function() {
|
|
6008
|
+
var _audioStallCount2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee3() {
|
|
6009
|
+
var get_stats_start, inboundRTP, reason, len, _this$_audioTransceiv, reports, _inboundRTP, _inboundRTP2, get_stats_end, end, diff, _inboundRTP3, concealedSamples, totalSamplesReceived, interval_concealed_samples, interval_samples_received, is_stall;
|
|
6010
|
+
return _regeneratorRuntime$1().wrap(function _callee3$(_context3) {
|
|
6011
|
+
while (1)
|
|
6012
|
+
switch (_context3.prev = _context3.next) {
|
|
6013
|
+
case 0:
|
|
6014
|
+
if (!(this._preSample && Date.now() - this._preSample.ts < AudioStallObserver2.interval * 0.5)) {
|
|
6015
|
+
_context3.next = 2;
|
|
6016
|
+
break;
|
|
6017
|
+
}
|
|
6018
|
+
return _context3.abrupt("return");
|
|
6019
|
+
case 2:
|
|
6020
|
+
get_stats_start = Date.now();
|
|
6021
|
+
len = 0;
|
|
6022
|
+
_context3.prev = 4;
|
|
6023
|
+
_context3.next = 7;
|
|
6024
|
+
return (_this$_audioTransceiv = this._audioTransceiver) === null || _this$_audioTransceiv === void 0 ? void 0 : _this$_audioTransceiv.receiver.getStats();
|
|
6025
|
+
case 7:
|
|
6026
|
+
reports = _context3.sent;
|
|
6027
|
+
reports === null || reports === void 0 ? void 0 : reports.forEach(function(stats) {
|
|
6028
|
+
if (stats.type === "inbound-rtp") {
|
|
6029
|
+
inboundRTP = stats;
|
|
6030
|
+
}
|
|
6031
|
+
len++;
|
|
6032
|
+
});
|
|
6033
|
+
_context3.next = 14;
|
|
6034
|
+
break;
|
|
6035
|
+
case 11:
|
|
6036
|
+
_context3.prev = 11;
|
|
6037
|
+
_context3.t0 = _context3["catch"](4);
|
|
6038
|
+
reason = _context3.t0.message || JSON.stringify(_context3.t0);
|
|
6039
|
+
case 14:
|
|
6040
|
+
if (this._preSample) {
|
|
6041
|
+
_context3.next = 17;
|
|
6042
|
+
break;
|
|
6043
|
+
}
|
|
6044
|
+
this._preSample = {
|
|
6045
|
+
ts: Date.now(),
|
|
6046
|
+
concealedSamples: ((_inboundRTP = inboundRTP) === null || _inboundRTP === void 0 ? void 0 : _inboundRTP.concealedSamples) || 0,
|
|
6047
|
+
totalSamplesReceived: ((_inboundRTP2 = inboundRTP) === null || _inboundRTP2 === void 0 ? void 0 : _inboundRTP2.totalSamplesReceived) || 0
|
|
6048
|
+
};
|
|
6049
|
+
return _context3.abrupt("return");
|
|
6050
|
+
case 17:
|
|
6051
|
+
get_stats_end = Date.now();
|
|
6052
|
+
end = Date.now();
|
|
6053
|
+
diff = end - this._preSample.ts;
|
|
6054
|
+
if (!inboundRTP) {
|
|
6055
|
+
this._stallList.push({
|
|
6056
|
+
diff,
|
|
6057
|
+
start: this._preSample.ts,
|
|
6058
|
+
end,
|
|
6059
|
+
get_stats_cost: get_stats_end - get_stats_start,
|
|
6060
|
+
get_stats_start,
|
|
6061
|
+
get_stats_end,
|
|
6062
|
+
reason: !len ? "no report" : reason || "no inbound-rtp"
|
|
6063
|
+
});
|
|
6064
|
+
} else {
|
|
6065
|
+
_inboundRTP3 = inboundRTP, concealedSamples = _inboundRTP3.concealedSamples, totalSamplesReceived = _inboundRTP3.totalSamplesReceived;
|
|
6066
|
+
interval_concealed_samples = concealedSamples - this._preSample.concealedSamples;
|
|
6067
|
+
interval_samples_received = totalSamplesReceived - this._preSample.totalSamplesReceived;
|
|
6068
|
+
is_stall = interval_concealed_samples >= 0 && interval_samples_received >= 0 && interval_concealed_samples >= AudioStallObserver2.ratio * interval_samples_received;
|
|
6069
|
+
this._stallList.push({
|
|
6070
|
+
concealed: interval_concealed_samples,
|
|
6071
|
+
received: interval_samples_received,
|
|
6072
|
+
diff,
|
|
6073
|
+
start: this._preSample.ts,
|
|
6074
|
+
end,
|
|
6075
|
+
get_stats_cost: get_stats_end - get_stats_start,
|
|
6076
|
+
get_stats_start,
|
|
6077
|
+
get_stats_end,
|
|
6078
|
+
is_stall
|
|
6079
|
+
});
|
|
6080
|
+
this._preSample.concealedSamples = concealedSamples;
|
|
6081
|
+
this._preSample.totalSamplesReceived = totalSamplesReceived;
|
|
6082
|
+
this._preSample.ts = end;
|
|
6083
|
+
}
|
|
6084
|
+
case 21:
|
|
6085
|
+
case "end":
|
|
6086
|
+
return _context3.stop();
|
|
6087
|
+
}
|
|
6088
|
+
}, _callee3, this, [[4, 11]]);
|
|
6089
|
+
}));
|
|
6090
|
+
function _audioStallCount() {
|
|
6091
|
+
return _audioStallCount2.apply(this, arguments);
|
|
6092
|
+
}
|
|
6093
|
+
return _audioStallCount;
|
|
6094
|
+
}()
|
|
6095
|
+
}]);
|
|
6096
|
+
return AudioStallObserver2;
|
|
6097
|
+
}();
|
|
6098
|
+
_defineProperty$2(AudioStallObserver, "interval", 100);
|
|
6099
|
+
_defineProperty$2(AudioStallObserver, "ratio", 0.6);
|
|
6100
|
+
var computeStallInfo = function computeStallInfo2(list, times, isStallInPreEnd) {
|
|
6101
|
+
var _list$;
|
|
6102
|
+
var res = {
|
|
6103
|
+
stall_count: 0,
|
|
6104
|
+
stall_duration: 0,
|
|
6105
|
+
isStallInEnd: false,
|
|
6106
|
+
list: []
|
|
6107
|
+
};
|
|
6108
|
+
var count = 0;
|
|
6109
|
+
var duration = 0;
|
|
6110
|
+
var _loop = function _loop2(_idx) {
|
|
6111
|
+
var info = list[_idx];
|
|
6112
|
+
if (info.is_stall) {
|
|
6113
|
+
count++;
|
|
6114
|
+
duration += info.diff || 0;
|
|
6115
|
+
}
|
|
6116
|
+
var lastItem = _idx === list.length - 1;
|
|
6117
|
+
if (!info.is_stall || lastItem) {
|
|
6118
|
+
var needCount = count >= times;
|
|
6119
|
+
var rightIdx = _idx + times - count - 1;
|
|
6120
|
+
if (!needCount && count > 2) {
|
|
6121
|
+
var tempDuration = 0;
|
|
6122
|
+
list.slice(_idx + 1, rightIdx + 1).forEach(function(v) {
|
|
6123
|
+
if (v.is_stall) {
|
|
6124
|
+
tempDuration += v.diff || 0;
|
|
6125
|
+
}
|
|
6126
|
+
});
|
|
6127
|
+
needCount = duration + tempDuration > AudioStallObserver.interval * times * AudioStallObserver.ratio;
|
|
6128
|
+
if (needCount) {
|
|
6129
|
+
_idx = rightIdx;
|
|
6130
|
+
duration += tempDuration;
|
|
6131
|
+
}
|
|
6132
|
+
}
|
|
6133
|
+
if (needCount) {
|
|
6134
|
+
res.stall_count++;
|
|
6135
|
+
res.stall_duration += duration;
|
|
6136
|
+
res.list.push(duration);
|
|
6137
|
+
}
|
|
6138
|
+
if (lastItem) {
|
|
6139
|
+
res.isStallInEnd = needCount;
|
|
6140
|
+
}
|
|
6141
|
+
count = duration = 0;
|
|
6142
|
+
}
|
|
6143
|
+
idx = _idx;
|
|
6144
|
+
};
|
|
6145
|
+
for (var idx = 0; idx < list.length; idx++) {
|
|
6146
|
+
_loop(idx);
|
|
6147
|
+
}
|
|
6148
|
+
if (((_list$ = list[0]) === null || _list$ === void 0 ? void 0 : _list$.is_stall) === true && isStallInPreEnd && res.stall_count > 0) {
|
|
6149
|
+
res.stall_count--;
|
|
6150
|
+
}
|
|
6151
|
+
return res;
|
|
6152
|
+
};
|
|
6153
|
+
function isSafari() {
|
|
6154
|
+
var ua = navigator.userAgent;
|
|
6155
|
+
return ua.match("Safari") !== null && ua.match("Chrome") === null;
|
|
6156
|
+
}
|
|
6157
|
+
function isFirefox() {
|
|
6158
|
+
var ua = navigator.userAgent;
|
|
6159
|
+
return ua.match("Firefox") !== null;
|
|
6160
|
+
}
|
|
6161
|
+
var checkVideoFrameCallback = function checkVideoFrameCallback2() {
|
|
6162
|
+
return typeof window !== "undefined" && typeof HTMLVideoElement.prototype.requestVideoFrameCallback === "function";
|
|
6163
|
+
};
|
|
6164
|
+
var VideoStallObserver = /* @__PURE__ */ function() {
|
|
6165
|
+
function VideoStallObserver2() {
|
|
6166
|
+
_classCallCheck$3(this, VideoStallObserver2);
|
|
6167
|
+
this._removeHandler = void 0;
|
|
6168
|
+
this._remotePlayPauseHandler = void 0;
|
|
6169
|
+
this._prePts = void 0;
|
|
6170
|
+
this._stallList = void 0;
|
|
6171
|
+
this._videoInWaiting100ms = false;
|
|
6172
|
+
this._videoInWaiting500ms = false;
|
|
6173
|
+
this._isPaused = void 0;
|
|
6174
|
+
this._pauseStart = 0;
|
|
6175
|
+
this._pauseDuration = 0;
|
|
6176
|
+
this._requestVideoFrameCallbackTimer = void 0;
|
|
6177
|
+
this._player = void 0;
|
|
6178
|
+
this._stallTimeThreshold = {
|
|
6179
|
+
stall500ms: isSafari() || isFirefox() ? 550 : 500,
|
|
6180
|
+
stall100ms: 100
|
|
6181
|
+
};
|
|
6182
|
+
this._support100msStall = checkVideoFrameCallback();
|
|
6183
|
+
}
|
|
6184
|
+
_createClass$3(VideoStallObserver2, [{
|
|
6185
|
+
key: "start",
|
|
6186
|
+
value: function start(player) {
|
|
6187
|
+
var _this = this;
|
|
6188
|
+
this._player = player;
|
|
6189
|
+
if (this._support100msStall) {
|
|
6190
|
+
if (player) {
|
|
6191
|
+
this._requestVideoFrameCallbackTimer = player.requestVideoFrameCallback(this._onVideoRefresh.bind(this));
|
|
6192
|
+
this._removeHandler = function() {
|
|
6193
|
+
if (_this._requestVideoFrameCallbackTimer) {
|
|
6194
|
+
player.cancelVideoFrameCallback(_this._requestVideoFrameCallbackTimer);
|
|
6195
|
+
}
|
|
6196
|
+
};
|
|
6197
|
+
}
|
|
6198
|
+
} else {
|
|
6199
|
+
var handle = function handle2() {
|
|
6200
|
+
return _this._onVideoTimeupdate(player);
|
|
6201
|
+
};
|
|
6202
|
+
player.addEventListener("timeupdate", handle);
|
|
6203
|
+
this._removeHandler = function() {
|
|
6204
|
+
return player.removeEventListener("timeupdate", handle);
|
|
6205
|
+
};
|
|
6206
|
+
}
|
|
6207
|
+
var handlePause = function handlePause2() {
|
|
6208
|
+
return _this._onVideoPause();
|
|
6209
|
+
};
|
|
6210
|
+
player.addEventListener("pause", handlePause);
|
|
6211
|
+
var handlePlay = function handlePlay2() {
|
|
6212
|
+
return _this._onVideoPlay();
|
|
6213
|
+
};
|
|
6214
|
+
player.addEventListener("play", handlePlay);
|
|
6215
|
+
this._remotePlayPauseHandler = function() {
|
|
6216
|
+
player.removeEventListener("pause", handlePause);
|
|
6217
|
+
player.removeEventListener("play", handlePlay);
|
|
6218
|
+
};
|
|
6219
|
+
}
|
|
6220
|
+
}, {
|
|
6221
|
+
key: "stop",
|
|
6222
|
+
value: function stop() {
|
|
6223
|
+
delete this._player;
|
|
6224
|
+
if (this._removeHandler) {
|
|
6225
|
+
this._removeHandler();
|
|
6226
|
+
}
|
|
6227
|
+
delete this._removeHandler;
|
|
6228
|
+
if (this._remotePlayPauseHandler) {
|
|
6229
|
+
this._remotePlayPauseHandler();
|
|
6230
|
+
}
|
|
6231
|
+
delete this._remotePlayPauseHandler;
|
|
6232
|
+
delete this._stallList;
|
|
6233
|
+
delete this._prePts;
|
|
6234
|
+
this._videoInWaiting100ms = false;
|
|
6235
|
+
this._videoInWaiting500ms = false;
|
|
6236
|
+
}
|
|
6237
|
+
}, {
|
|
6238
|
+
key: "destroy",
|
|
6239
|
+
value: function destroy() {
|
|
6240
|
+
this.stop();
|
|
6241
|
+
}
|
|
6242
|
+
}, {
|
|
6243
|
+
key: "getStallInfo",
|
|
6244
|
+
value: function getStallInfo(_ref) {
|
|
6245
|
+
var _this2 = this;
|
|
6246
|
+
var interval = _ref.interval, frameRateReceived = _ref.frameRateReceived, frameRateDecoded = _ref.frameRateDecoded, bitrate = _ref.bitrate;
|
|
6247
|
+
var stallInfo = {
|
|
6248
|
+
pts: 0,
|
|
6249
|
+
stall: {
|
|
6250
|
+
stallCount500ms: 0,
|
|
6251
|
+
stallDuration500ms: 0,
|
|
6252
|
+
stallRate500ms: 0,
|
|
6253
|
+
stallCount100ms: 0,
|
|
6254
|
+
stallDuration100ms: 0,
|
|
6255
|
+
stallRate100ms: 0
|
|
6256
|
+
},
|
|
6257
|
+
pauseDuration: this._getPauseDuration()
|
|
6258
|
+
};
|
|
6259
|
+
if (this._stallList) {
|
|
6260
|
+
var poorNetworkInSafari = (isSafari() || isFirefox()) && (bitrate === 0 || (frameRateDecoded || Infinity) <= 1 || (frameRateReceived || Infinity) <= 1);
|
|
6261
|
+
if (poorNetworkInSafari || this._stallList.length === 0) {
|
|
6262
|
+
stallInfo.stall.stallDuration500ms = interval;
|
|
6263
|
+
stallInfo.stall.stallCount500ms = this._videoInWaiting500ms ? 0 : 1;
|
|
6264
|
+
stallInfo.stall.stallRate500ms = 1;
|
|
6265
|
+
this._videoInWaiting500ms = true;
|
|
6266
|
+
if (this._support100msStall) {
|
|
6267
|
+
stallInfo.stall.stallDuration100ms = interval;
|
|
6268
|
+
stallInfo.stall.stallCount100ms = this._videoInWaiting100ms ? 0 : 1;
|
|
6269
|
+
stallInfo.stall.stallRate100ms = 1;
|
|
6270
|
+
this._videoInWaiting100ms = true;
|
|
6271
|
+
}
|
|
6272
|
+
} else {
|
|
6273
|
+
this._stallList.forEach(function(frameRecord, idx) {
|
|
6274
|
+
var timeUpdateInterval = frameRecord.timeUpdateInterval, playTime = frameRecord.playTime;
|
|
6275
|
+
var stallDuration = timeUpdateInterval;
|
|
6276
|
+
if (idx === 0 && (_this2._videoInWaiting100ms || _this2._videoInWaiting500ms)) {
|
|
6277
|
+
stallDuration = Math.round(timeUpdateInterval % interval);
|
|
6278
|
+
}
|
|
6279
|
+
if (timeUpdateInterval > _this2._stallTimeThreshold.stall500ms) {
|
|
6280
|
+
stallInfo.stall.stallDuration500ms += stallDuration;
|
|
6281
|
+
if (!_this2._videoInWaiting500ms) {
|
|
6282
|
+
stallInfo.stall.stallCount500ms++;
|
|
6283
|
+
}
|
|
6284
|
+
_this2._videoInWaiting500ms = true;
|
|
6285
|
+
} else {
|
|
6286
|
+
_this2._videoInWaiting500ms = false;
|
|
6287
|
+
}
|
|
6288
|
+
if (_this2._support100msStall) {
|
|
6289
|
+
if (timeUpdateInterval > _this2._stallTimeThreshold.stall100ms) {
|
|
6290
|
+
stallInfo.stall.stallDuration100ms += stallDuration;
|
|
6291
|
+
if (!_this2._videoInWaiting100ms) {
|
|
6292
|
+
stallInfo.stall.stallCount100ms++;
|
|
6293
|
+
}
|
|
6294
|
+
_this2._videoInWaiting100ms = true;
|
|
6295
|
+
} else {
|
|
6296
|
+
_this2._videoInWaiting100ms = false;
|
|
6297
|
+
}
|
|
6298
|
+
}
|
|
6299
|
+
stallInfo.pts = playTime;
|
|
6300
|
+
});
|
|
6301
|
+
}
|
|
6302
|
+
var _stallInfo$stall = stallInfo.stall, stallDuration500ms = _stallInfo$stall.stallDuration500ms, stallDuration100ms = _stallInfo$stall.stallDuration100ms;
|
|
6303
|
+
stallInfo.stall.stallRate500ms = Math.min(Number((stallDuration500ms / interval).toFixed(4)), 1);
|
|
6304
|
+
if (this._support100msStall) {
|
|
6305
|
+
stallInfo.stall.stallRate100ms = Math.min(Number((stallDuration100ms / interval).toFixed(4)), 1);
|
|
6306
|
+
} else {
|
|
6307
|
+
delete stallInfo.stall.stallRate100ms;
|
|
6308
|
+
delete stallInfo.stall.stallCount100ms;
|
|
6309
|
+
delete stallInfo.stall.stallDuration100ms;
|
|
6310
|
+
}
|
|
6311
|
+
this._stallList = [];
|
|
6312
|
+
}
|
|
6313
|
+
return stallInfo;
|
|
6314
|
+
}
|
|
6315
|
+
}, {
|
|
6316
|
+
key: "_getPauseDuration",
|
|
6317
|
+
value: function _getPauseDuration() {
|
|
6318
|
+
var pause_duration = this._pauseDuration;
|
|
6319
|
+
this._pauseDuration = 0;
|
|
6320
|
+
if (this._isPaused) {
|
|
6321
|
+
var now = Date.now();
|
|
6322
|
+
var diff = now - (this._pauseStart || 0);
|
|
6323
|
+
if (diff > 500) {
|
|
6324
|
+
this._pauseStart = now;
|
|
6325
|
+
pause_duration += diff;
|
|
6326
|
+
}
|
|
6327
|
+
}
|
|
6328
|
+
return pause_duration;
|
|
6329
|
+
}
|
|
6330
|
+
}, {
|
|
6331
|
+
key: "_onVideoPause",
|
|
6332
|
+
value: function _onVideoPause() {
|
|
6333
|
+
this._isPaused = true;
|
|
6334
|
+
this._pauseStart = Date.now();
|
|
6335
|
+
}
|
|
6336
|
+
}, {
|
|
6337
|
+
key: "_onVideoPlay",
|
|
6338
|
+
value: function _onVideoPlay() {
|
|
6339
|
+
this._isPaused = false;
|
|
6340
|
+
var diff = Date.now() - this._pauseStart;
|
|
6341
|
+
if (diff > 500) {
|
|
6342
|
+
this._pauseDuration += diff;
|
|
6343
|
+
}
|
|
6344
|
+
}
|
|
6345
|
+
}, {
|
|
6346
|
+
key: "_onVideoTimeupdate",
|
|
6347
|
+
value: function _onVideoTimeupdate(video) {
|
|
6348
|
+
if (!video || video.currentTime === 0) {
|
|
6349
|
+
return;
|
|
6350
|
+
}
|
|
6351
|
+
if (this._prePts === void 0) {
|
|
6352
|
+
this._prePts = video.currentTime;
|
|
6353
|
+
return;
|
|
6354
|
+
}
|
|
6355
|
+
if (!this._stallList) {
|
|
6356
|
+
this._stallList = [];
|
|
6357
|
+
}
|
|
6358
|
+
if (video.currentTime > this._prePts) {
|
|
6359
|
+
var delta = video.currentTime - this._prePts;
|
|
6360
|
+
this._stallList.push({
|
|
6361
|
+
playTime: video.currentTime,
|
|
6362
|
+
timeUpdateInterval: Math.round(delta * 1e3)
|
|
6363
|
+
});
|
|
6364
|
+
}
|
|
6365
|
+
this._prePts = video.currentTime;
|
|
6366
|
+
}
|
|
6367
|
+
}, {
|
|
6368
|
+
key: "_onVideoRefresh",
|
|
6369
|
+
value: function _onVideoRefresh(_, data) {
|
|
6370
|
+
if (!this._stallList) {
|
|
6371
|
+
this._stallList = [];
|
|
6372
|
+
}
|
|
6373
|
+
if (this._prePts) {
|
|
6374
|
+
var delta = data.presentationTime - this._prePts;
|
|
6375
|
+
this._stallList.push({
|
|
6376
|
+
playTime: data.presentationTime,
|
|
6377
|
+
timeUpdateInterval: Math.round(delta)
|
|
6378
|
+
});
|
|
6379
|
+
}
|
|
6380
|
+
this._prePts = data.presentationTime;
|
|
6381
|
+
if (this._player) {
|
|
6382
|
+
this._player.requestVideoFrameCallback(this._onVideoRefresh.bind(this));
|
|
6383
|
+
}
|
|
6384
|
+
}
|
|
6385
|
+
}]);
|
|
6386
|
+
return VideoStallObserver2;
|
|
6387
|
+
}();
|
|
6388
|
+
function getRecvAudioStats(_x) {
|
|
6389
|
+
return _getRecvAudioStats.apply(this, arguments);
|
|
6390
|
+
}
|
|
6391
|
+
function _getRecvAudioStats() {
|
|
6392
|
+
_getRecvAudioStats = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee(getStats2) {
|
|
6393
|
+
var currentStats, result;
|
|
6394
|
+
return _regeneratorRuntime$1().wrap(function _callee$(_context) {
|
|
6395
|
+
while (1)
|
|
6396
|
+
switch (_context.prev = _context.next) {
|
|
6397
|
+
case 0:
|
|
6398
|
+
currentStats = {};
|
|
6399
|
+
_context.next = 3;
|
|
6400
|
+
return getStats2;
|
|
6401
|
+
case 3:
|
|
6402
|
+
result = _context.sent;
|
|
6403
|
+
currentStats.timestamp = Date.now();
|
|
6404
|
+
result === null || result === void 0 ? void 0 : result.forEach(function(stat) {
|
|
6405
|
+
if (stat.type === "inbound-rtp") {
|
|
6406
|
+
currentStats.packetsLost = stat.packetsLost;
|
|
6407
|
+
currentStats.packetsReceived = stat.packetsReceived;
|
|
6408
|
+
currentStats.bytesReceived = stat.bytesReceived;
|
|
6409
|
+
if (stat.jitterBufferDelay !== void 0) {
|
|
6410
|
+
currentStats.jitterBufferDelay = stat.jitterBufferDelay;
|
|
6411
|
+
currentStats.jitterBufferEmittedCount = stat.jitterBufferEmittedCount;
|
|
6412
|
+
}
|
|
6413
|
+
if (stat.totalSamplesReceived !== void 0) {
|
|
6414
|
+
currentStats.totalSamplesReceived = stat.totalSamplesReceived;
|
|
6415
|
+
currentStats.concealedSamples = stat.concealedSamples;
|
|
6416
|
+
currentStats.silentConcealedSamples = stat.silentConcealedSamples;
|
|
6417
|
+
currentStats.concealmentEvents = stat.concealmentEvents;
|
|
6418
|
+
}
|
|
6419
|
+
if (stat.fecPacketsReceived !== void 0) {
|
|
6420
|
+
currentStats.fecPacketsReceived = stat.fecPacketsReceived;
|
|
6421
|
+
}
|
|
6422
|
+
} else if (stat.type === "codec") {
|
|
6423
|
+
currentStats.recordSampleRate = stat.clockRate;
|
|
6424
|
+
if (stat.channels) {
|
|
6425
|
+
currentStats.numChannels = stat.channels;
|
|
6426
|
+
}
|
|
6427
|
+
currentStats.codecType = stat.mimeType;
|
|
6428
|
+
} else if (stat.type === "candidate-pair") {
|
|
6429
|
+
currentStats.rtt = stat.currentRoundTripTime * 1e3;
|
|
6430
|
+
currentStats.total_rtt = stat.totalRoundTripTime * 1e3;
|
|
6431
|
+
} else if (stat.type === "track" && stat.audioLevel !== void 0)
|
|
6432
|
+
;
|
|
6433
|
+
else if (stat.type === "ssrc")
|
|
6434
|
+
;
|
|
6435
|
+
});
|
|
6436
|
+
return _context.abrupt("return", currentStats);
|
|
6437
|
+
case 7:
|
|
6438
|
+
case "end":
|
|
6439
|
+
return _context.stop();
|
|
6440
|
+
}
|
|
6441
|
+
}, _callee);
|
|
6442
|
+
}));
|
|
6443
|
+
return _getRecvAudioStats.apply(this, arguments);
|
|
6444
|
+
}
|
|
6445
|
+
function diffRecvAudioStats(oldStats, newStats) {
|
|
6446
|
+
var statsInterval = diffNumber(oldStats, newStats, "timestamp");
|
|
6447
|
+
var packetsLostDiff = diffNumber(oldStats, newStats, "packetsLost");
|
|
6448
|
+
var jitterBufferDelay = Math.round(diffNumber(oldStats, newStats, "jitterBufferDelay") / diffNumber(oldStats, newStats, "jitterBufferEmittedCount") * 1e3);
|
|
6449
|
+
return {
|
|
6450
|
+
audioLossRate: +(packetsLostDiff / (diffNumber(oldStats, newStats, "packetsReceived") + packetsLostDiff)).toFixed(2),
|
|
6451
|
+
receivedKBitrate: +(diffNumber(oldStats, newStats, "bytesReceived") * 8 / statsInterval).toFixed(2),
|
|
6452
|
+
statsInterval,
|
|
6453
|
+
rtt: newStats.rtt || 0,
|
|
6454
|
+
jitterBufferDelay,
|
|
6455
|
+
numChannels: newStats.numChannels || 1,
|
|
6456
|
+
receivedSampleRate: diffNumber(oldStats, newStats, "totalSamplesReceived") / statsInterval,
|
|
6457
|
+
concealedSamples: Math.round(diffNumber(oldStats, newStats, "concealedSamples")),
|
|
6458
|
+
concealmentEvent: Math.round(diffNumber(oldStats, newStats, "concealmentEvents")),
|
|
6459
|
+
e2eDelay: Math.round(newStats.rtt + jitterBufferDelay)
|
|
6460
|
+
};
|
|
6461
|
+
}
|
|
6462
|
+
function getRecvVideoStats(_x2) {
|
|
6463
|
+
return _getRecvVideoStats.apply(this, arguments);
|
|
6464
|
+
}
|
|
6465
|
+
function _getRecvVideoStats() {
|
|
6466
|
+
_getRecvVideoStats = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee2(getStats2) {
|
|
6467
|
+
var currentStats, result;
|
|
6468
|
+
return _regeneratorRuntime$1().wrap(function _callee2$(_context2) {
|
|
6469
|
+
while (1)
|
|
6470
|
+
switch (_context2.prev = _context2.next) {
|
|
6471
|
+
case 0:
|
|
6472
|
+
currentStats = {};
|
|
6473
|
+
_context2.next = 3;
|
|
6474
|
+
return getStats2;
|
|
6475
|
+
case 3:
|
|
6476
|
+
result = _context2.sent;
|
|
6477
|
+
currentStats.timestamp = Date.now();
|
|
6478
|
+
result === null || result === void 0 ? void 0 : result.forEach(function(stat) {
|
|
6479
|
+
if (stat.type === "inbound-rtp") {
|
|
6480
|
+
currentStats.packetsLost = stat.packetsLost;
|
|
6481
|
+
currentStats.packetsReceived = stat.packetsReceived;
|
|
6482
|
+
currentStats.bytesReceived = stat.bytesReceived;
|
|
6483
|
+
currentStats.framesDecoded = stat.framesDecoded;
|
|
6484
|
+
currentStats.totalDecodeTime = stat.totalDecodeTime;
|
|
6485
|
+
currentStats.framesReceived = stat.framesReceived;
|
|
6486
|
+
currentStats.keyFramesDecoded = stat.keyFramesDecoded;
|
|
6487
|
+
currentStats.framesDropped = stat.framesDropped;
|
|
6488
|
+
currentStats.firCount = stat.firCount;
|
|
6489
|
+
currentStats.nackCount = stat.nackCount;
|
|
6490
|
+
currentStats.pliCount = stat.pliCount;
|
|
6491
|
+
if (stat.jitterBufferDelay !== void 0) {
|
|
6492
|
+
currentStats.jitterBufferEmittedCount = stat.jitterBufferEmittedCount;
|
|
6493
|
+
currentStats.jitterBufferDelay = stat.jitterBufferDelay;
|
|
6494
|
+
}
|
|
6495
|
+
if (stat.frameWidth !== void 0) {
|
|
6496
|
+
currentStats.width = stat.frameWidth;
|
|
6497
|
+
currentStats.height = stat.frameHeight;
|
|
6498
|
+
}
|
|
6499
|
+
} else if (stat.type === "track" && stat.frameWidth !== void 0) {
|
|
6500
|
+
currentStats.width = stat.frameWidth;
|
|
6501
|
+
currentStats.height = stat.frameHeight;
|
|
6502
|
+
if (stat.framesReceived !== void 0) {
|
|
6503
|
+
currentStats.framesReceived = stat.framesReceived;
|
|
6504
|
+
}
|
|
6505
|
+
} else if (stat.type === "codec") {
|
|
6506
|
+
currentStats.codecType = stat.mimeType;
|
|
6507
|
+
} else if (stat.type === "candidate-pair") {
|
|
6508
|
+
currentStats.rtt = stat.currentRoundTripTime * 1e3;
|
|
6509
|
+
currentStats.totalRtt = stat.totalRoundTripTime * 1e3;
|
|
6510
|
+
}
|
|
6511
|
+
});
|
|
6512
|
+
return _context2.abrupt("return", currentStats);
|
|
6513
|
+
case 7:
|
|
6514
|
+
case "end":
|
|
6515
|
+
return _context2.stop();
|
|
6516
|
+
}
|
|
6517
|
+
}, _callee2);
|
|
6518
|
+
}));
|
|
6519
|
+
return _getRecvVideoStats.apply(this, arguments);
|
|
6520
|
+
}
|
|
6521
|
+
function diffRecvVideoStats(oldStats, newStats) {
|
|
6522
|
+
var statsInterval = diffNumber(oldStats, newStats, "timestamp");
|
|
6523
|
+
var packetsLostDiff = diffNumber(oldStats, newStats, "packetsLost");
|
|
6524
|
+
var nackCount = diffNumber(oldStats, newStats, "nackCount");
|
|
6525
|
+
var packetsReceived = diffNumber(oldStats, newStats, "packetsReceived");
|
|
6526
|
+
var jitterBufferDelay = Math.round(diffNumber(oldStats, newStats, "jitterBufferDelay") / diffNumber(oldStats, newStats, "jitterBufferEmittedCount") * 1e3);
|
|
6527
|
+
return {
|
|
6528
|
+
statsInterval,
|
|
6529
|
+
width: newStats.width || 0,
|
|
6530
|
+
height: newStats.height || 0,
|
|
6531
|
+
videoLossRate: +(packetsLostDiff / (diffNumber(oldStats, newStats, "packetsReceived") + packetsLostDiff)),
|
|
6532
|
+
receivedKBitrate: +(diffNumber(oldStats, newStats, "bytesReceived") * 8 / statsInterval).toFixed(2),
|
|
6533
|
+
decoderOutputFrameRate: Math.round(diffNumber(oldStats, newStats, "framesDecoded") * 1e3 / statsInterval),
|
|
6534
|
+
receivedFrameRate: Math.round(diffNumber(oldStats, newStats, "framesReceived") * 1e3 / statsInterval),
|
|
6535
|
+
rtt: newStats.rtt || 0,
|
|
6536
|
+
totalRtt: Math.round(newStats.totalRtt || 0),
|
|
6537
|
+
jitterBufferDelay,
|
|
6538
|
+
codecType: newStats.codecType,
|
|
6539
|
+
packetsReceived,
|
|
6540
|
+
avgDecodeDelay: Math.round(diffNumber(oldStats, newStats, "totalDecodeTime") * 1e3 / diffNumber(oldStats, newStats, "framesDecoded")),
|
|
6541
|
+
keyFramesDecoded: diffNumber(oldStats, newStats, "keyFramesDecoded"),
|
|
6542
|
+
framesDropped: diffNumber(oldStats, newStats, "framesDropped"),
|
|
6543
|
+
firCount: diffNumber(oldStats, newStats, "firCount"),
|
|
6544
|
+
nackCount,
|
|
6545
|
+
pliCount: diffNumber(oldStats, newStats, "pliCount"),
|
|
6546
|
+
e2eDelay: Math.round(newStats.rtt + jitterBufferDelay),
|
|
6547
|
+
retransmittedRate: +(nackCount / (packetsReceived + packetsLostDiff)).toFixed(2)
|
|
6548
|
+
};
|
|
6549
|
+
}
|
|
6550
|
+
function diffNumber(oldValue, newValue, key) {
|
|
6551
|
+
var oldV = Number.isNaN(oldValue[key]) ? 0 : +oldValue[key];
|
|
6552
|
+
var newV = Number.isNaN(newValue[key]) ? 0 : +newValue[key];
|
|
6553
|
+
return Math.max(0, newV - oldV);
|
|
6554
|
+
}
|
|
6555
|
+
var QoELevel = {
|
|
6556
|
+
INVALID: 0,
|
|
6557
|
+
GOOD: 1,
|
|
6558
|
+
MEDIUM: 2,
|
|
6559
|
+
POOR: 3
|
|
6560
|
+
};
|
|
6561
|
+
var QosLevel = {
|
|
6562
|
+
UNKOWN: 0,
|
|
6563
|
+
EXCELLENT: 1,
|
|
6564
|
+
GOOD: 2,
|
|
6565
|
+
POOR: 3,
|
|
6566
|
+
BAD: 4,
|
|
6567
|
+
VBAD: 5
|
|
6568
|
+
};
|
|
6569
|
+
var Quality = {
|
|
6570
|
+
UNKNOWN: 0,
|
|
6571
|
+
EXCELLENT: 1,
|
|
6572
|
+
GOOD: 2,
|
|
6573
|
+
POOR: 3,
|
|
6574
|
+
BAD: 4,
|
|
6575
|
+
VBAD: 5,
|
|
6576
|
+
DOWN: 6
|
|
6577
|
+
};
|
|
6578
|
+
var NetworkQuality = /* @__PURE__ */ function() {
|
|
6579
|
+
function NetworkQuality2(peer, networkQualityParams) {
|
|
6580
|
+
_classCallCheck$3(this, NetworkQuality2);
|
|
6581
|
+
_defineProperty$2(this, "_preDownlinkStats", []);
|
|
6582
|
+
this._peer = peer;
|
|
6583
|
+
this._networkQualityParams = networkQualityParams;
|
|
6584
|
+
}
|
|
6585
|
+
_createClass$3(NetworkQuality2, [{
|
|
6586
|
+
key: "getDownlinkQuality",
|
|
6587
|
+
value: function getDownlinkQuality(audioStats, videoStats) {
|
|
6588
|
+
if (audioStats.receivedKBitrate === 0 && videoStats.receivedKBitrate === 0) {
|
|
6589
|
+
return;
|
|
6590
|
+
}
|
|
6591
|
+
if (this._peer.connectionState !== "connected" && this._peer.connectionState !== "connecting" || !navigator.onLine) {
|
|
6592
|
+
return [Quality.DOWN, {}];
|
|
6593
|
+
}
|
|
6594
|
+
var audioQos = this._getQosLevel(audioStats.rtt, audioStats.audioLossRate, videoStats.retransmittedRate);
|
|
6595
|
+
var audioQoe = this._getDownlinkQoE("audio", audioStats.stallDuration / audioStats.statsInterval, audioStats.e2eDelay);
|
|
6596
|
+
var audioLevel = this._getNetworkQuality(audioQos, audioQoe);
|
|
6597
|
+
var videoQos = this._getQosLevel(videoStats.rtt, videoStats.videoLossRate, videoStats.retransmittedRate);
|
|
6598
|
+
var videoQoe = this._getDownlinkQoE("video", videoStats.stallDuration / videoStats.statsInterval, videoStats.e2eDelay);
|
|
6599
|
+
var videoLevel = this._getNetworkQuality(videoQos, videoQoe);
|
|
6600
|
+
var quality = audioLevel && videoLevel ? Math.ceil((audioLevel + videoLevel) / 2) : audioLevel || videoLevel;
|
|
6601
|
+
var qualityQos = audioQos && videoQos ? Math.ceil((audioQos + videoQos) / 2) : audioQos || videoQos;
|
|
6602
|
+
if (quality) {
|
|
6603
|
+
this._preDownlinkStats = [].concat(_toConsumableArray$1(this._preDownlinkStats), [quality]).slice(-2);
|
|
6604
|
+
return [Math.floor(this._preDownlinkStats.reduce(function(res, cur) {
|
|
6605
|
+
return cur + res;
|
|
6606
|
+
}, 0) / this._preDownlinkStats.length), {
|
|
6607
|
+
qualityQos,
|
|
6608
|
+
audioLevel,
|
|
6609
|
+
videoLevel,
|
|
6610
|
+
audioQos,
|
|
6611
|
+
audioQoe,
|
|
6612
|
+
videoQos,
|
|
6613
|
+
videoQoe
|
|
6614
|
+
}];
|
|
6615
|
+
}
|
|
6616
|
+
}
|
|
6617
|
+
}, {
|
|
6618
|
+
key: "destroy",
|
|
6619
|
+
value: function destroy() {
|
|
6620
|
+
this._preDownlinkStats = [];
|
|
6621
|
+
}
|
|
6622
|
+
}, {
|
|
6623
|
+
key: "_getQosLevel",
|
|
6624
|
+
value: function _getQosLevel(rtt, loss, retransmittedRate) {
|
|
6625
|
+
var quality;
|
|
6626
|
+
var qosQualityParams = this._networkQualityParams.networkQos;
|
|
6627
|
+
if ((!rtt || rtt <= qosQualityParams[QosLevel.EXCELLENT].maxRtt) && loss <= qosQualityParams[QosLevel.EXCELLENT].maxLoss) {
|
|
6628
|
+
quality = QosLevel.EXCELLENT;
|
|
6629
|
+
} else if ((!rtt || rtt <= qosQualityParams[QosLevel.GOOD].maxRtt) && loss <= qosQualityParams[QosLevel.GOOD].maxLoss) {
|
|
6630
|
+
quality = QosLevel.GOOD;
|
|
6631
|
+
} else if ((!rtt || rtt <= qosQualityParams[QosLevel.POOR].maxRtt) && loss <= qosQualityParams[QosLevel.POOR].maxLoss) {
|
|
6632
|
+
quality = QosLevel.POOR;
|
|
6633
|
+
} else if ((!rtt || rtt <= qosQualityParams[QosLevel.BAD].maxRtt) && loss <= qosQualityParams[QosLevel.BAD].maxLoss) {
|
|
6634
|
+
quality = QosLevel.BAD;
|
|
6635
|
+
} else {
|
|
6636
|
+
quality = QosLevel.VBAD;
|
|
6637
|
+
}
|
|
6638
|
+
if (retransmittedRate > qosQualityParams[QosLevel.BAD].minRetransmittedRate) {
|
|
6639
|
+
quality = Math.max(quality, QosLevel.BAD);
|
|
6640
|
+
} else if (retransmittedRate > qosQualityParams[QosLevel.POOR].minRetransmittedRate) {
|
|
6641
|
+
quality = Math.max(quality, QosLevel.POOR);
|
|
6642
|
+
} else if (retransmittedRate > qosQualityParams[QosLevel.GOOD].minRetransmittedRate) {
|
|
6643
|
+
quality = Math.max(quality, QosLevel.GOOD);
|
|
6644
|
+
}
|
|
6645
|
+
return quality;
|
|
6646
|
+
}
|
|
6647
|
+
}, {
|
|
6648
|
+
key: "_getDownlinkQoE",
|
|
6649
|
+
value: function _getDownlinkQoE(streamType, stallRadio, delay) {
|
|
6650
|
+
var qoeQualityParams = this._networkQualityParams.networkQoe;
|
|
6651
|
+
var conf = {
|
|
6652
|
+
audio: {
|
|
6653
|
+
delay: qoeQualityParams.audioDelay,
|
|
6654
|
+
stallRadio: qoeQualityParams.audioStallRadio
|
|
6655
|
+
},
|
|
6656
|
+
video: {
|
|
6657
|
+
delay: qoeQualityParams.videoDelay,
|
|
6658
|
+
stallRadio: qoeQualityParams.videoStallRadio
|
|
6659
|
+
}
|
|
6660
|
+
}[streamType];
|
|
6661
|
+
if (stallRadio > conf.stallRadio || delay > conf.delay || stallRadio > conf.stallRadio / 2 && delay > conf.delay / 2) {
|
|
6662
|
+
return QoELevel.POOR;
|
|
6663
|
+
} else if (stallRadio > conf.stallRadio / 2 || delay > conf.delay / 2) {
|
|
6664
|
+
return QoELevel.MEDIUM;
|
|
6665
|
+
} else {
|
|
6666
|
+
return QoELevel.MEDIUM;
|
|
6667
|
+
}
|
|
6668
|
+
}
|
|
6669
|
+
}, {
|
|
6670
|
+
key: "_getNetworkQuality",
|
|
6671
|
+
value: function _getNetworkQuality(QoS, QoE) {
|
|
6672
|
+
if (QoE === QoELevel.GOOD) {
|
|
6673
|
+
return Math.max(QoS - 2, 1);
|
|
6674
|
+
} else if (QoE === QoELevel.MEDIUM) {
|
|
6675
|
+
return QoS;
|
|
6676
|
+
} else {
|
|
6677
|
+
return Math.min(QoS + 1, 5);
|
|
6678
|
+
}
|
|
6679
|
+
}
|
|
6680
|
+
}]);
|
|
6681
|
+
return NetworkQuality2;
|
|
6682
|
+
}();
|
|
6683
|
+
var logger = new Logger("rts");
|
|
6684
|
+
var Rts = /* @__PURE__ */ function(_EventEmitter) {
|
|
6685
|
+
_inherits$1(Rts2, _EventEmitter);
|
|
6686
|
+
var _super = _createSuper$1(Rts2);
|
|
6687
|
+
function Rts2(opts) {
|
|
6688
|
+
var _this;
|
|
6689
|
+
_classCallCheck$3(this, Rts2);
|
|
6690
|
+
_this = _super.call(this);
|
|
6691
|
+
_defineProperty$2(_assertThisInitialized$1(_this), "_url", "");
|
|
6692
|
+
_defineProperty$2(_assertThisInitialized$1(_this), "_pc", null);
|
|
6693
|
+
_defineProperty$2(_assertThisInitialized$1(_this), "_audioTransceicer", null);
|
|
6694
|
+
_defineProperty$2(_assertThisInitialized$1(_this), "_videoTransceicer", null);
|
|
6695
|
+
_defineProperty$2(_assertThisInitialized$1(_this), "_mediaStream", null);
|
|
6696
|
+
_defineProperty$2(_assertThisInitialized$1(_this), "_lastMediaStream", null);
|
|
6697
|
+
_defineProperty$2(_assertThisInitialized$1(_this), "_media", null);
|
|
6698
|
+
_defineProperty$2(_assertThisInitialized$1(_this), "_opts", null);
|
|
6699
|
+
_defineProperty$2(_assertThisInitialized$1(_this), "_loader", null);
|
|
6700
|
+
_defineProperty$2(_assertThisInitialized$1(_this), "_networkEvaluate", null);
|
|
6701
|
+
_defineProperty$2(_assertThisInitialized$1(_this), "_retry", 0);
|
|
6702
|
+
_defineProperty$2(_assertThisInitialized$1(_this), "_waitingTimer", 0);
|
|
6703
|
+
_defineProperty$2(_assertThisInitialized$1(_this), "_rctConnectStartTs", 0);
|
|
6704
|
+
_defineProperty$2(_assertThisInitialized$1(_this), "_isReplacing", false);
|
|
6705
|
+
_defineProperty$2(_assertThisInitialized$1(_this), "_checkStatsErrorTimer", null);
|
|
6706
|
+
_defineProperty$2(_assertThisInitialized$1(_this), "_audioStallObserver", null);
|
|
6707
|
+
_defineProperty$2(_assertThisInitialized$1(_this), "_videoStallObserver", null);
|
|
6708
|
+
_defineProperty$2(_assertThisInitialized$1(_this), "_networkQuality", null);
|
|
6709
|
+
_defineProperty$2(_assertThisInitialized$1(_this), "_preAudioStats", null);
|
|
6710
|
+
_defineProperty$2(_assertThisInitialized$1(_this), "_preVideoStats", null);
|
|
6711
|
+
_defineProperty$2(_assertThisInitialized$1(_this), "_rtcReportTimer", 0);
|
|
6712
|
+
_defineProperty$2(_assertThisInitialized$1(_this), "_networkQualityResult", []);
|
|
6713
|
+
_defineProperty$2(_assertThisInitialized$1(_this), "_checkStatsError", /* @__PURE__ */ _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee2() {
|
|
6714
|
+
return _regeneratorRuntime$1().wrap(function _callee2$(_context2) {
|
|
6715
|
+
while (1)
|
|
6716
|
+
switch (_context2.prev = _context2.next) {
|
|
6717
|
+
case 0:
|
|
6718
|
+
_this._checkStatsErrorTimer = setTimeout(/* @__PURE__ */ _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee() {
|
|
6719
|
+
var stats, _stats$video, framesDecoded, bytesReceived;
|
|
6720
|
+
return _regeneratorRuntime$1().wrap(function _callee$(_context) {
|
|
6721
|
+
while (1)
|
|
6722
|
+
switch (_context.prev = _context.next) {
|
|
6723
|
+
case 0:
|
|
6724
|
+
_context.next = 2;
|
|
6725
|
+
return _this.getStatsSnapshoot();
|
|
6726
|
+
case 2:
|
|
6727
|
+
stats = _context.sent;
|
|
6728
|
+
if (stats.video) {
|
|
6729
|
+
_stats$video = stats.video, framesDecoded = _stats$video.framesDecoded, bytesReceived = _stats$video.bytesReceived;
|
|
6730
|
+
if (!bytesReceived) {
|
|
6731
|
+
_this._emitError(StreamingError.create(ERR.MEDIA, ERR.SUB_TYPES.MEDIA_ERR_DECODE, {
|
|
6732
|
+
message: "rts receive empty"
|
|
6733
|
+
}));
|
|
6734
|
+
} else if (!framesDecoded) {
|
|
6735
|
+
_this._emitError(StreamingError.create(ERR.MEDIA, ERR.SUB_TYPES.MEDIA_ERR_DECODE, {
|
|
6736
|
+
message: "rts decode error"
|
|
6737
|
+
}));
|
|
6738
|
+
}
|
|
6739
|
+
}
|
|
6740
|
+
case 4:
|
|
6741
|
+
case "end":
|
|
6742
|
+
return _context.stop();
|
|
6743
|
+
}
|
|
6744
|
+
}, _callee);
|
|
6745
|
+
})), _this._opts.checkStatsErrorDelay);
|
|
6746
|
+
case 1:
|
|
6747
|
+
case "end":
|
|
6748
|
+
return _context2.stop();
|
|
6749
|
+
}
|
|
6750
|
+
}, _callee2);
|
|
6751
|
+
})));
|
|
6752
|
+
_defineProperty$2(_assertThisInitialized$1(_this), "_onTrack", function(e) {
|
|
6753
|
+
logger.log("addTrack: ", e.track, e.streams);
|
|
6754
|
+
_this["_".concat(e.track.kind)] = e.track;
|
|
6755
|
+
});
|
|
6756
|
+
_defineProperty$2(_assertThisInitialized$1(_this), "_mockWaitingByTimeupdate", function() {
|
|
6757
|
+
var _this$_pc, _this$_pc2;
|
|
6758
|
+
if (!(((_this$_pc = _this._pc) === null || _this$_pc === void 0 ? void 0 : _this$_pc.connectionState) === "connected" || ((_this$_pc2 = _this._pc) === null || _this$_pc2 === void 0 ? void 0 : _this$_pc2.iceConnectionState) === "connected"))
|
|
6759
|
+
return;
|
|
6760
|
+
clearTimeout(_this._waitingTimer);
|
|
6761
|
+
_this._waitingTimer = setTimeout(function() {
|
|
6762
|
+
var _this$_media;
|
|
6763
|
+
if ((_this$_media = _this._media) !== null && _this$_media !== void 0 && _this$_media.paused)
|
|
6764
|
+
return;
|
|
6765
|
+
_this.emit("waiting");
|
|
6766
|
+
}, _this._opts.stallInterval);
|
|
6767
|
+
});
|
|
6768
|
+
_defineProperty$2(_assertThisInitialized$1(_this), "_onLoadedData", function() {
|
|
6769
|
+
logger.log("loadeddata emit");
|
|
6770
|
+
_this._startRtcReport();
|
|
6771
|
+
_this.getStatsSnapshoot().then(function(snap) {
|
|
6772
|
+
_this.emit(EVENT.METADATA_PARSED, {
|
|
6773
|
+
type: "video",
|
|
6774
|
+
elapsed: Date.now() - _this._rctConnectStartTs,
|
|
6775
|
+
meta: snap.video
|
|
6776
|
+
});
|
|
6777
|
+
_this.emit(EVENT.METADATA_PARSED, {
|
|
6778
|
+
type: "audio",
|
|
6779
|
+
elapsed: Date.now() - _this._rctConnectStartTs,
|
|
6780
|
+
meta: snap.audio
|
|
6781
|
+
});
|
|
6782
|
+
});
|
|
6783
|
+
});
|
|
6784
|
+
_defineProperty$2(_assertThisInitialized$1(_this), "_setDelay", function(delayHint) {
|
|
6785
|
+
var currentDelay = _this._getDelay();
|
|
6786
|
+
delayHint = typeof delayHint === "number" && delayHint > 0 ? delayHint : null;
|
|
6787
|
+
if (currentDelay === delayHint)
|
|
6788
|
+
return;
|
|
6789
|
+
try {
|
|
6790
|
+
var videoReceiver = _this._videoTransceicer.receiver;
|
|
6791
|
+
var audioReceiver = _this._audioTransceicer.receiver;
|
|
6792
|
+
var key = [
|
|
6793
|
+
"playoutDelayHint",
|
|
6794
|
+
"jitterBufferDelayHint",
|
|
6795
|
+
"jitterBufferTarget"
|
|
6796
|
+
].find(function(key2) {
|
|
6797
|
+
return key2 in videoReceiver && key2 in audioReceiver;
|
|
6798
|
+
});
|
|
6799
|
+
if (key) {
|
|
6800
|
+
audioReceiver[key] = delayHint;
|
|
6801
|
+
logger.log("set audioReceiver.".concat(key, " = ").concat(delayHint));
|
|
6802
|
+
}
|
|
6803
|
+
} catch (error) {
|
|
6804
|
+
logger.error("set delay error", error);
|
|
6805
|
+
}
|
|
6806
|
+
});
|
|
6807
|
+
_defineProperty$2(_assertThisInitialized$1(_this), "_getDelay", function() {
|
|
6808
|
+
try {
|
|
6809
|
+
var key = ["playoutDelayHint", "jitterBufferDelayHint", "jitterBufferTarget"].find(function(key2) {
|
|
6810
|
+
return key2 in _this._videoTransceicer.receiver && key2 in _this._audioTransceicer.receiver;
|
|
6811
|
+
});
|
|
6812
|
+
return _this._audioTransceicer.receiver[key];
|
|
6813
|
+
} catch (error) {
|
|
6814
|
+
logger.error("get delay error");
|
|
6815
|
+
}
|
|
6816
|
+
});
|
|
6817
|
+
_defineProperty$2(_assertThisInitialized$1(_this), "_onLoaderRetry", function(error, retryTime) {
|
|
6818
|
+
_this.emit(EVENT.LOAD_RETRY, {
|
|
6819
|
+
error: StreamingError.network(error),
|
|
6820
|
+
retryTime
|
|
6821
|
+
});
|
|
6822
|
+
});
|
|
6823
|
+
_this._opts = getOption(opts);
|
|
6824
|
+
_this._media = _this._opts.media;
|
|
6825
|
+
_this._loader = new NetLoader(_objectSpread2$2(_objectSpread2$2({}, opts.fetchOptions), {}, {
|
|
6826
|
+
responseType: "json",
|
|
6827
|
+
method: "POST",
|
|
6828
|
+
retry: _this._opts.retryCount,
|
|
6829
|
+
retryDelay: _this._opts.retryDelay,
|
|
6830
|
+
timeout: _this._opts.loadTimeout,
|
|
6831
|
+
onRetryError: _this._onLoaderRetry,
|
|
6832
|
+
logger
|
|
6833
|
+
}));
|
|
6834
|
+
_this._retry = _this._opts.retryCount;
|
|
6835
|
+
_this._bindMediaEvent();
|
|
6836
|
+
if (_this._opts.mediaStream && _this._opts.seamlesslyReload) {
|
|
6837
|
+
_this._lastMediaStream = _this._opts.mediaStream;
|
|
6838
|
+
}
|
|
6839
|
+
return _this;
|
|
6840
|
+
}
|
|
6841
|
+
_createClass$3(Rts2, [{
|
|
6842
|
+
key: "pc",
|
|
6843
|
+
get: function get() {
|
|
6844
|
+
return this._pc;
|
|
6845
|
+
}
|
|
6846
|
+
}, {
|
|
6847
|
+
key: "audioTrack",
|
|
6848
|
+
get: function get() {
|
|
6849
|
+
return this._audio;
|
|
6850
|
+
}
|
|
6851
|
+
}, {
|
|
6852
|
+
key: "videoTack",
|
|
6853
|
+
get: function get() {
|
|
6854
|
+
return this._video;
|
|
6855
|
+
}
|
|
6856
|
+
}, {
|
|
6857
|
+
key: "loader",
|
|
6858
|
+
get: function get() {
|
|
6859
|
+
return this._loader;
|
|
6860
|
+
}
|
|
6861
|
+
}, {
|
|
6862
|
+
key: "networkStats",
|
|
5237
6863
|
get: function get() {
|
|
5238
6864
|
var _this$_networkEvaluat;
|
|
5239
6865
|
return (_this$_networkEvaluat = this._networkEvaluate) === null || _this$_networkEvaluat === void 0 ? void 0 : _this$_networkEvaluat.getStats();
|
|
@@ -5253,12 +6879,12 @@
|
|
|
5253
6879
|
}, {
|
|
5254
6880
|
key: "load",
|
|
5255
6881
|
value: function() {
|
|
5256
|
-
var _load = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function
|
|
6882
|
+
var _load = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee3(url) {
|
|
5257
6883
|
var _this2 = this;
|
|
5258
|
-
var lastPc;
|
|
5259
|
-
return _regeneratorRuntime$1().wrap(function
|
|
6884
|
+
var lastPc, encodedTransformSupported;
|
|
6885
|
+
return _regeneratorRuntime$1().wrap(function _callee3$(_context3) {
|
|
5260
6886
|
while (1)
|
|
5261
|
-
switch (
|
|
6887
|
+
switch (_context3.prev = _context3.next) {
|
|
5262
6888
|
case 0:
|
|
5263
6889
|
this._disconnect();
|
|
5264
6890
|
this._url = url;
|
|
@@ -5267,25 +6893,28 @@
|
|
|
5267
6893
|
if (lastPc) {
|
|
5268
6894
|
lastPc.close();
|
|
5269
6895
|
}
|
|
5270
|
-
|
|
5271
|
-
|
|
6896
|
+
encodedTransformSupported = isLegacyEncodedTransformSupported();
|
|
6897
|
+
_context3.prev = 6;
|
|
6898
|
+
this._pc = new RTCPeerConnection({
|
|
6899
|
+
encodedInsertableStreams: encodedTransformSupported && this._opts.enableSei ? true : void 0
|
|
6900
|
+
});
|
|
5272
6901
|
this._bindRTCEvents();
|
|
5273
|
-
|
|
6902
|
+
_context3.next = 11;
|
|
5274
6903
|
return this._connect(url);
|
|
5275
|
-
case
|
|
5276
|
-
|
|
6904
|
+
case 11:
|
|
6905
|
+
_context3.next = 16;
|
|
5277
6906
|
break;
|
|
5278
|
-
case
|
|
5279
|
-
|
|
5280
|
-
|
|
6907
|
+
case 13:
|
|
6908
|
+
_context3.prev = 13;
|
|
6909
|
+
_context3.t0 = _context3["catch"](6);
|
|
5281
6910
|
setTimeout(function() {
|
|
5282
|
-
return _this2._emitError(StreamingError.create(ERR.OTHER, null,
|
|
6911
|
+
return _this2._emitError(StreamingError.create(ERR.OTHER, null, _context3.t0));
|
|
5283
6912
|
});
|
|
5284
|
-
case
|
|
6913
|
+
case 16:
|
|
5285
6914
|
case "end":
|
|
5286
|
-
return
|
|
6915
|
+
return _context3.stop();
|
|
5287
6916
|
}
|
|
5288
|
-
},
|
|
6917
|
+
}, _callee3, this, [[6, 13]]);
|
|
5289
6918
|
}));
|
|
5290
6919
|
function load(_x) {
|
|
5291
6920
|
return _load.apply(this, arguments);
|
|
@@ -5311,6 +6940,7 @@
|
|
|
5311
6940
|
});
|
|
5312
6941
|
if (pc.connectionState === "disconnected" || pc.connectionState === "failed") {
|
|
5313
6942
|
_this3.emit("waiting");
|
|
6943
|
+
_this3._stopRtcReport();
|
|
5314
6944
|
}
|
|
5315
6945
|
if (pc.connectionState === "failed") {
|
|
5316
6946
|
if (_this3._retry === 0) {
|
|
@@ -5327,6 +6957,7 @@
|
|
|
5327
6957
|
responseUrl: _this3._url,
|
|
5328
6958
|
elapsed: Date.now() - _this3._rctConnectStartTs
|
|
5329
6959
|
});
|
|
6960
|
+
_this3._checkStatsError();
|
|
5330
6961
|
}
|
|
5331
6962
|
});
|
|
5332
6963
|
}
|
|
@@ -5364,6 +6995,54 @@
|
|
|
5364
6995
|
}
|
|
5365
6996
|
}
|
|
5366
6997
|
}
|
|
6998
|
+
}, {
|
|
6999
|
+
key: "initVideoEncodedTransform",
|
|
7000
|
+
value: function initVideoEncodedTransform() {
|
|
7001
|
+
var _this5 = this;
|
|
7002
|
+
if (!this._videoTransceicer || !this._videoTransceicer.receiver) {
|
|
7003
|
+
console.log("no receiver found when trying to bind encodedTransform");
|
|
7004
|
+
return;
|
|
7005
|
+
}
|
|
7006
|
+
var receiver = this._videoTransceicer.receiver;
|
|
7007
|
+
if (isLegacyEncodedTransformSupported()) {
|
|
7008
|
+
var _receiver$createEncod = receiver.createEncodedStreams(), readable = _receiver$createEncod.readable, writable = _receiver$createEncod.writable;
|
|
7009
|
+
readable.pipeThrough(receiveSEITransform(function(sei) {
|
|
7010
|
+
_this5.emit(EVENT.SEI, sei);
|
|
7011
|
+
})).pipeTo(writable);
|
|
7012
|
+
} else if (isEncodedTransformSupported()) {
|
|
7013
|
+
var worker = new WorkerWrapper();
|
|
7014
|
+
var channel = new MessageChannel();
|
|
7015
|
+
this._videoTransceicer.receiver.transform = new RTCRtpScriptTransform(worker, {
|
|
7016
|
+
port: channel.port2
|
|
7017
|
+
}, [channel.port2]);
|
|
7018
|
+
channel.port1.onmessage = function(e) {
|
|
7019
|
+
_this5.emit(EVENT.SEI, e.data);
|
|
7020
|
+
};
|
|
7021
|
+
}
|
|
7022
|
+
}
|
|
7023
|
+
}, {
|
|
7024
|
+
key: "initAudioEncodedTransform",
|
|
7025
|
+
value: function initAudioEncodedTransform() {
|
|
7026
|
+
if (!this._audioTransceicer || !this._audioTransceicer.receiver) {
|
|
7027
|
+
logger.warn("no receiver found when trying to bind encodedTransform");
|
|
7028
|
+
return;
|
|
7029
|
+
}
|
|
7030
|
+
if (!isLegacyEncodedTransformSupported()) {
|
|
7031
|
+
logger.warn("legacy EncodedTransform is not supported");
|
|
7032
|
+
return;
|
|
7033
|
+
}
|
|
7034
|
+
var receiver = this._audioTransceicer.receiver;
|
|
7035
|
+
var _receiver$createEncod2 = receiver.createEncodedStreams(), readable = _receiver$createEncod2.readable, writable = _receiver$createEncod2.writable;
|
|
7036
|
+
readable.pipeThrough(new TransformStream({
|
|
7037
|
+
transform: function transform(chunk, controller) {
|
|
7038
|
+
if (chunk.data.byteLength <= 1e3) {
|
|
7039
|
+
controller.enqueue(chunk);
|
|
7040
|
+
} else {
|
|
7041
|
+
logger.log("too large audio frame", chunk.data.byteLength);
|
|
7042
|
+
}
|
|
7043
|
+
}
|
|
7044
|
+
})).pipeTo(writable);
|
|
7045
|
+
}
|
|
5367
7046
|
}, {
|
|
5368
7047
|
key: "_bindMediaEvent",
|
|
5369
7048
|
value: function _bindMediaEvent() {
|
|
@@ -5373,15 +7052,15 @@
|
|
|
5373
7052
|
}, {
|
|
5374
7053
|
key: "_connect",
|
|
5375
7054
|
value: function() {
|
|
5376
|
-
var _connect2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function
|
|
5377
|
-
var pc, offer,
|
|
5378
|
-
return _regeneratorRuntime$1().wrap(function
|
|
7055
|
+
var _connect2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee4() {
|
|
7056
|
+
var pc, offer, parsed, finnalUrl, _this$_opts, _answer$remoteSdp, _this$_opts2, _answer$remoteSdp2, _parsed$media, parseSession, sessionId, reqStart, res, answer, err, _parsed;
|
|
7057
|
+
return _regeneratorRuntime$1().wrap(function _callee4$(_context4) {
|
|
5379
7058
|
while (1)
|
|
5380
|
-
switch (
|
|
7059
|
+
switch (_context4.prev = _context4.next) {
|
|
5381
7060
|
case 0:
|
|
5382
7061
|
pc = this._pc;
|
|
5383
7062
|
if (!pc.addTransceiver) {
|
|
5384
|
-
|
|
7063
|
+
_context4.next = 11;
|
|
5385
7064
|
break;
|
|
5386
7065
|
}
|
|
5387
7066
|
this._audioTransceicer = pc.addTransceiver("audio", {
|
|
@@ -5390,28 +7069,26 @@
|
|
|
5390
7069
|
this._videoTransceicer = pc.addTransceiver("video", {
|
|
5391
7070
|
direction: "recvonly"
|
|
5392
7071
|
});
|
|
5393
|
-
|
|
5394
|
-
if (
|
|
5395
|
-
this.
|
|
5396
|
-
this.
|
|
5397
|
-
this._videoTransceicer.receiver.playoutDelayHint = delayHint;
|
|
5398
|
-
this._videoTransceicer.receiver.jitterBufferDelayHint = delayHint;
|
|
7072
|
+
!this._opts.enableAdaptiveJitterBuffer && this._setDelay(this._opts.delayHint);
|
|
7073
|
+
if (this._opts.enableSei) {
|
|
7074
|
+
this.initVideoEncodedTransform();
|
|
7075
|
+
this.initAudioEncodedTransform();
|
|
5399
7076
|
}
|
|
5400
|
-
|
|
7077
|
+
_context4.next = 8;
|
|
5401
7078
|
return pc.createOffer();
|
|
5402
7079
|
case 8:
|
|
5403
|
-
offer =
|
|
5404
|
-
|
|
7080
|
+
offer = _context4.sent;
|
|
7081
|
+
_context4.next = 14;
|
|
5405
7082
|
break;
|
|
5406
7083
|
case 11:
|
|
5407
|
-
|
|
7084
|
+
_context4.next = 13;
|
|
5408
7085
|
return pc.createOffer({
|
|
5409
7086
|
iceRestart: true,
|
|
5410
7087
|
offerToReceiveAudio: true,
|
|
5411
7088
|
offerToReceiveVideo: true
|
|
5412
7089
|
});
|
|
5413
7090
|
case 13:
|
|
5414
|
-
offer =
|
|
7091
|
+
offer = _context4.sent;
|
|
5415
7092
|
case 14:
|
|
5416
7093
|
logger.log("local offer");
|
|
5417
7094
|
logger.log(offer.sdp);
|
|
@@ -5437,11 +7114,11 @@
|
|
|
5437
7114
|
});
|
|
5438
7115
|
offer.sdp = lib.write(parsed);
|
|
5439
7116
|
logger.log("local offer modified:\n", offer.sdp);
|
|
5440
|
-
|
|
7117
|
+
_context4.next = 22;
|
|
5441
7118
|
return pc.setLocalDescription(offer);
|
|
5442
7119
|
case 22:
|
|
5443
7120
|
finnalUrl = this._url;
|
|
5444
|
-
|
|
7121
|
+
_context4.prev = 23;
|
|
5445
7122
|
if (this._opts.preProcessUrl) {
|
|
5446
7123
|
finnalUrl = this._opts.preProcessUrl(finnalUrl).url;
|
|
5447
7124
|
}
|
|
@@ -5454,7 +7131,7 @@
|
|
|
5454
7131
|
sessionId
|
|
5455
7132
|
});
|
|
5456
7133
|
reqStart = Date.now();
|
|
5457
|
-
|
|
7134
|
+
_context4.next = 32;
|
|
5458
7135
|
return this._loader.load(finnalUrl, {
|
|
5459
7136
|
body: JSON.stringify({
|
|
5460
7137
|
sessionId,
|
|
@@ -5463,22 +7140,22 @@
|
|
|
5463
7140
|
})
|
|
5464
7141
|
});
|
|
5465
7142
|
case 32:
|
|
5466
|
-
res =
|
|
7143
|
+
res = _context4.sent;
|
|
5467
7144
|
this.emit(EVENT.LOAD_RESPONSE_HEADERS, {
|
|
5468
7145
|
headers: res.response.headers
|
|
5469
7146
|
});
|
|
5470
7147
|
answer = res === null || res === void 0 ? void 0 : res.data;
|
|
5471
7148
|
if (!((answer === null || answer === void 0 ? void 0 : answer.code) === 404 || (answer === null || answer === void 0 ? void 0 : answer.code) === 403)) {
|
|
5472
|
-
|
|
7149
|
+
_context4.next = 40;
|
|
5473
7150
|
break;
|
|
5474
7151
|
}
|
|
5475
7152
|
err = StreamingError.create(answer.code === 404 ? ERR.NETWORK_NOTFOUND : ERR.NETWORK_FORBIDDEN, null, answer);
|
|
5476
7153
|
err.errorType = ERR.NETWORK;
|
|
5477
7154
|
this._emitError(err);
|
|
5478
|
-
return
|
|
7155
|
+
return _context4.abrupt("return");
|
|
5479
7156
|
case 40:
|
|
5480
7157
|
if (!((answer === null || answer === void 0 ? void 0 : answer.code) !== 200)) {
|
|
5481
|
-
|
|
7158
|
+
_context4.next = 42;
|
|
5482
7159
|
break;
|
|
5483
7160
|
}
|
|
5484
7161
|
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));
|
|
@@ -5499,38 +7176,178 @@
|
|
|
5499
7176
|
})
|
|
5500
7177
|
});
|
|
5501
7178
|
_parsed.media.forEach(function(x) {
|
|
7179
|
+
var _x$ssrcs, _x$ssrcs$find;
|
|
5502
7180
|
x.fingerprint.hash = x.fingerprint.hash.toUpperCase();
|
|
7181
|
+
var msid = (_x$ssrcs = x.ssrcs) === null || _x$ssrcs === void 0 ? void 0 : (_x$ssrcs$find = _x$ssrcs.find(function(s) {
|
|
7182
|
+
return s.attribute === "msid";
|
|
7183
|
+
})) === null || _x$ssrcs$find === void 0 ? void 0 : _x$ssrcs$find.value;
|
|
7184
|
+
if (msid && !x.msid) {
|
|
7185
|
+
x.msid = msid;
|
|
7186
|
+
}
|
|
5503
7187
|
});
|
|
5504
7188
|
answer.remoteSdp.sdp = lib.write(_parsed);
|
|
5505
7189
|
logger.log("answer modified:\n", answer.remoteSdp.sdp);
|
|
5506
7190
|
this._rctConnectStartTs = Date.now();
|
|
5507
|
-
|
|
7191
|
+
_context4.next = 52;
|
|
5508
7192
|
return this._pc.setRemoteDescription(answer.remoteSdp);
|
|
5509
7193
|
case 52:
|
|
5510
7194
|
this._networkEvaluate = new NetworkEvaluate(pc, this._opts.networkEvaluateInterval);
|
|
5511
|
-
|
|
7195
|
+
_context4.next = 58;
|
|
5512
7196
|
break;
|
|
5513
7197
|
case 55:
|
|
5514
|
-
|
|
5515
|
-
|
|
5516
|
-
this._emitError(StreamingError.network(
|
|
7198
|
+
_context4.prev = 55;
|
|
7199
|
+
_context4.t0 = _context4["catch"](23);
|
|
7200
|
+
this._emitError(StreamingError.network(_context4.t0));
|
|
5517
7201
|
case 58:
|
|
5518
7202
|
case "end":
|
|
5519
|
-
return
|
|
7203
|
+
return _context4.stop();
|
|
5520
7204
|
}
|
|
5521
|
-
},
|
|
7205
|
+
}, _callee4, this, [[23, 55]]);
|
|
5522
7206
|
}));
|
|
5523
7207
|
function _connect() {
|
|
5524
7208
|
return _connect2.apply(this, arguments);
|
|
5525
7209
|
}
|
|
5526
7210
|
return _connect;
|
|
5527
7211
|
}()
|
|
7212
|
+
}, {
|
|
7213
|
+
key: "_startRtcReport",
|
|
7214
|
+
value: function _startRtcReport() {
|
|
7215
|
+
var _this6 = this;
|
|
7216
|
+
this._rtcReportTimer = setInterval(/* @__PURE__ */ _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee5() {
|
|
7217
|
+
var _yield$Promise$all, _yield$Promise$all2, curAudioStats, curVideoStats, _this6$_audioStallObs, _this6$_videoStallObs, _this6$_networkQualit, _this6$_networkQualit2, audioStats, videoStats, audioStallInfo, videoStallInfo, _ref4, _ref5, quality, qualityInfo, targetDelay;
|
|
7218
|
+
return _regeneratorRuntime$1().wrap(function _callee5$(_context5) {
|
|
7219
|
+
while (1)
|
|
7220
|
+
switch (_context5.prev = _context5.next) {
|
|
7221
|
+
case 0:
|
|
7222
|
+
if (!_this6._audioStallObserver && _this6._audioTransceicer) {
|
|
7223
|
+
_this6._audioStallObserver = new AudioStallObserver();
|
|
7224
|
+
_this6._audioStallObserver.start(_this6._audioTransceicer);
|
|
7225
|
+
}
|
|
7226
|
+
if (!_this6._videoStallObserver && _this6._video) {
|
|
7227
|
+
_this6._videoStallObserver = new VideoStallObserver();
|
|
7228
|
+
_this6._videoStallObserver.start(_this6._media);
|
|
7229
|
+
}
|
|
7230
|
+
if (!_this6._networkQuality && _this6._opts.enableNetworkQuality) {
|
|
7231
|
+
_this6._networkQuality = new NetworkQuality(_this6._pc, _this6._opts.networkQuality);
|
|
7232
|
+
}
|
|
7233
|
+
_context5.next = 5;
|
|
7234
|
+
return Promise.all([getRecvAudioStats(_this6._audioTransceicer.receiver.getStats()), getRecvVideoStats(_this6._videoTransceicer.receiver.getStats())]);
|
|
7235
|
+
case 5:
|
|
7236
|
+
_yield$Promise$all = _context5.sent;
|
|
7237
|
+
_yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
|
|
7238
|
+
curAudioStats = _yield$Promise$all2[0];
|
|
7239
|
+
curVideoStats = _yield$Promise$all2[1];
|
|
7240
|
+
if (!(_this6._preAudioStats && _this6._preVideoStats)) {
|
|
7241
|
+
_context5.next = 21;
|
|
7242
|
+
break;
|
|
7243
|
+
}
|
|
7244
|
+
audioStats = diffRecvAudioStats(_this6._preAudioStats, curAudioStats);
|
|
7245
|
+
videoStats = diffRecvVideoStats(_this6._preVideoStats, curVideoStats);
|
|
7246
|
+
_context5.next = 14;
|
|
7247
|
+
return (_this6$_audioStallObs = _this6._audioStallObserver) === null || _this6$_audioStallObs === void 0 ? void 0 : _this6$_audioStallObs.getAudioStallInfo();
|
|
7248
|
+
case 14:
|
|
7249
|
+
audioStallInfo = _context5.sent;
|
|
7250
|
+
_context5.next = 17;
|
|
7251
|
+
return (_this6$_videoStallObs = _this6._videoStallObserver) === null || _this6$_videoStallObs === void 0 ? void 0 : _this6$_videoStallObs.getStallInfo({
|
|
7252
|
+
interval: videoStats.statsInterval,
|
|
7253
|
+
frameRateReceived: videoStats.frameRateReceived,
|
|
7254
|
+
frameRateDecoded: videoStats.frameRateDecoded,
|
|
7255
|
+
bitrate: videoStats.receivedKBitrate
|
|
7256
|
+
});
|
|
7257
|
+
case 17:
|
|
7258
|
+
videoStallInfo = _context5.sent;
|
|
7259
|
+
_ref4 = (_this6$_networkQualit = (_this6$_networkQualit2 = _this6._networkQuality) === null || _this6$_networkQualit2 === void 0 ? void 0 : _this6$_networkQualit2.getDownlinkQuality(_objectSpread2$2(_objectSpread2$2({}, audioStats), {}, {
|
|
7260
|
+
stallDuration: audioStallInfo.stallDuration
|
|
7261
|
+
}), _objectSpread2$2(_objectSpread2$2({}, videoStats), {}, {
|
|
7262
|
+
stallDuration: videoStallInfo.stall.stallDuration100ms
|
|
7263
|
+
}))) !== null && _this6$_networkQualit !== void 0 ? _this6$_networkQualit : [], _ref5 = _slicedToArray(_ref4, 2), quality = _ref5[0], qualityInfo = _ref5[1];
|
|
7264
|
+
if (_this6._opts.enableAdaptiveJitterBuffer) {
|
|
7265
|
+
targetDelay = _this6._handleJitterBuffer(qualityInfo === null || qualityInfo === void 0 ? void 0 : qualityInfo.qualityQos, _this6._opts.adaptiveJitterBuffer, _this6._opts.networkStrategy);
|
|
7266
|
+
}
|
|
7267
|
+
_this6.emit(EXTEND_EVENTS.RTC_NETWORK, {
|
|
7268
|
+
interval: videoStats.statsInterval,
|
|
7269
|
+
visibility_state: document.visibilityState,
|
|
7270
|
+
network_quality: quality,
|
|
7271
|
+
audio_stall_duration: audioStallInfo.stallDuration,
|
|
7272
|
+
audio_stall_count: audioStallInfo.stallCount,
|
|
7273
|
+
audio_stall_time_per_100sec: audioStallInfo.stallDuration / audioStats.statsInterval * 100,
|
|
7274
|
+
audio_stall_count_per_100sec: audioStallInfo.stallCount / audioStats.statsInterval * 100 * 1e3,
|
|
7275
|
+
video_stall_duration: videoStallInfo.stall.stallDuration500ms,
|
|
7276
|
+
video_stall_count: videoStallInfo.stall.stallCount500ms,
|
|
7277
|
+
video_stall_duration_100ms: videoStallInfo.stall.stallDuration100ms,
|
|
7278
|
+
video_stall_count_100ms: videoStallInfo.stall.stallCount100ms,
|
|
7279
|
+
video_stall_time_per_100sec: videoStallInfo.stall.stallDuration500ms / videoStats.statsInterval * 100,
|
|
7280
|
+
video_stall_count_per_100sec: videoStallInfo.stall.stallCount500ms / videoStats.statsInterval * 100 * 1e3,
|
|
7281
|
+
rtt: videoStats.rtt,
|
|
7282
|
+
video_jb_delay: videoStats.jitterBufferDelay,
|
|
7283
|
+
audio_jb_delay: audioStats.jitterBufferDelay,
|
|
7284
|
+
audio_lost_rate: audioStats.audioLossRate,
|
|
7285
|
+
video_lost_rate: videoStats.videoLossRate,
|
|
7286
|
+
video_retransmitted_rate: videoStats.retransmittedRate,
|
|
7287
|
+
quality_audio_level: qualityInfo === null || qualityInfo === void 0 ? void 0 : qualityInfo.audioLevel,
|
|
7288
|
+
quality_video_level: qualityInfo === null || qualityInfo === void 0 ? void 0 : qualityInfo.videoLevel,
|
|
7289
|
+
quality_audio_qos: qualityInfo === null || qualityInfo === void 0 ? void 0 : qualityInfo.audioQos,
|
|
7290
|
+
quality_video_qos: qualityInfo === null || qualityInfo === void 0 ? void 0 : qualityInfo.videoQos,
|
|
7291
|
+
quality_qos: qualityInfo === null || qualityInfo === void 0 ? void 0 : qualityInfo.qualityQos,
|
|
7292
|
+
quality_audio_qoe: qualityInfo === null || qualityInfo === void 0 ? void 0 : qualityInfo.audioQoe,
|
|
7293
|
+
quality_video_qoe: qualityInfo === null || qualityInfo === void 0 ? void 0 : qualityInfo.videoQoe,
|
|
7294
|
+
current_delay: _this6._getDelay(),
|
|
7295
|
+
target_delay: targetDelay
|
|
7296
|
+
});
|
|
7297
|
+
case 21:
|
|
7298
|
+
_this6._preAudioStats = curAudioStats;
|
|
7299
|
+
_this6._preVideoStats = curVideoStats;
|
|
7300
|
+
case 23:
|
|
7301
|
+
case "end":
|
|
7302
|
+
return _context5.stop();
|
|
7303
|
+
}
|
|
7304
|
+
}, _callee5);
|
|
7305
|
+
})), 2e3);
|
|
7306
|
+
}
|
|
7307
|
+
}, {
|
|
7308
|
+
key: "_handleJitterBuffer",
|
|
7309
|
+
value: function _handleJitterBuffer(quality, adaptiveJitterBuffer, networkStrategy) {
|
|
7310
|
+
this._networkQualityResult.push(quality);
|
|
7311
|
+
if (this._networkQualityResult.length > adaptiveJitterBuffer.networkWindow) {
|
|
7312
|
+
this._networkQualityResult.shift();
|
|
7313
|
+
}
|
|
7314
|
+
var validNetworkQualityResult = this._networkQualityResult.filter(Boolean);
|
|
7315
|
+
if (validNetworkQualityResult.length === adaptiveJitterBuffer.networkWindow) {
|
|
7316
|
+
var _networkStrategy$aver;
|
|
7317
|
+
var sorted = _toConsumableArray$1(validNetworkQualityResult).sort(function(a, b) {
|
|
7318
|
+
return a - b;
|
|
7319
|
+
});
|
|
7320
|
+
var mid = Math.floor(sorted.length / 2);
|
|
7321
|
+
var averageQuality = sorted.length % 2 !== 0 ? sorted[mid] : (sorted[mid - 1] + sorted[mid]) / 2;
|
|
7322
|
+
if (averageQuality && ((_networkStrategy$aver = networkStrategy[averageQuality]) === null || _networkStrategy$aver === void 0 ? void 0 : _networkStrategy$aver.jitterBuffer) !== void 0) {
|
|
7323
|
+
var _networkStrategy$aver2, _networkStrategy$aver3;
|
|
7324
|
+
this._setDelay((_networkStrategy$aver2 = networkStrategy[averageQuality]) === null || _networkStrategy$aver2 === void 0 ? void 0 : _networkStrategy$aver2.jitterBuffer);
|
|
7325
|
+
return (_networkStrategy$aver3 = networkStrategy[averageQuality]) === null || _networkStrategy$aver3 === void 0 ? void 0 : _networkStrategy$aver3.jitterBuffer;
|
|
7326
|
+
}
|
|
7327
|
+
}
|
|
7328
|
+
}
|
|
7329
|
+
}, {
|
|
7330
|
+
key: "_stopRtcReport",
|
|
7331
|
+
value: function _stopRtcReport() {
|
|
7332
|
+
var _this$_audioStallObse, _this$_videoStallObse, _this$_networkQuality;
|
|
7333
|
+
(_this$_audioStallObse = this._audioStallObserver) === null || _this$_audioStallObse === void 0 ? void 0 : _this$_audioStallObse.destroy();
|
|
7334
|
+
(_this$_videoStallObse = this._videoStallObserver) === null || _this$_videoStallObse === void 0 ? void 0 : _this$_videoStallObse.destroy();
|
|
7335
|
+
(_this$_networkQuality = this._networkQuality) === null || _this$_networkQuality === void 0 ? void 0 : _this$_networkQuality.destroy();
|
|
7336
|
+
this._audioStallObserver = null;
|
|
7337
|
+
this._videoStallObserver = null;
|
|
7338
|
+
this._networkQuality = null;
|
|
7339
|
+
if (this._rtcReportTimer) {
|
|
7340
|
+
clearInterval(this._rtcReportTimer);
|
|
7341
|
+
this._rtcReportTimer = 0;
|
|
7342
|
+
}
|
|
7343
|
+
}
|
|
5528
7344
|
}, {
|
|
5529
7345
|
key: "_disconnect",
|
|
5530
7346
|
value: function _disconnect() {
|
|
5531
7347
|
var _this$_loader, _this$_networkEvaluat2;
|
|
5532
7348
|
(_this$_loader = this._loader) === null || _this$_loader === void 0 ? void 0 : _this$_loader.cancel();
|
|
5533
7349
|
(_this$_networkEvaluat2 = this._networkEvaluate) === null || _this$_networkEvaluat2 === void 0 ? void 0 : _this$_networkEvaluat2.destroy();
|
|
7350
|
+
this._stopRtcReport();
|
|
5534
7351
|
this._audioTransceicer = null;
|
|
5535
7352
|
this._videoTransceicer = null;
|
|
5536
7353
|
this._mediaStream = null;
|
|
@@ -5540,6 +7357,10 @@
|
|
|
5540
7357
|
key: "_emitError",
|
|
5541
7358
|
value: function _emitError(error) {
|
|
5542
7359
|
this.emit(EVENT.ERROR, error);
|
|
7360
|
+
clearTimeout(this._checkStatsErrorTimer);
|
|
7361
|
+
if (this._pc) {
|
|
7362
|
+
this._pc.close();
|
|
7363
|
+
}
|
|
5543
7364
|
}
|
|
5544
7365
|
}, {
|
|
5545
7366
|
key: "destroy",
|
|
@@ -5556,6 +7377,7 @@
|
|
|
5556
7377
|
this._loader = null;
|
|
5557
7378
|
this._media = null;
|
|
5558
7379
|
this._pc = null;
|
|
7380
|
+
this._opts = null;
|
|
5559
7381
|
}
|
|
5560
7382
|
}], [{
|
|
5561
7383
|
key: "enableLogger",
|
|
@@ -5578,70 +7400,12 @@
|
|
|
5578
7400
|
}
|
|
5579
7401
|
} catch (error) {
|
|
5580
7402
|
}
|
|
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
7403
|
var RtsPlugin = /* @__PURE__ */ function(_BasePlugin) {
|
|
5640
7404
|
_inherits$1(RtsPlugin2, _BasePlugin);
|
|
5641
7405
|
var _super = _createSuper$1(RtsPlugin2);
|
|
5642
7406
|
function RtsPlugin2() {
|
|
5643
7407
|
var _this;
|
|
5644
|
-
_classCallCheck$
|
|
7408
|
+
_classCallCheck$3(this, RtsPlugin2);
|
|
5645
7409
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
5646
7410
|
args[_key] = arguments[_key];
|
|
5647
7411
|
}
|
|
@@ -5706,7 +7470,7 @@
|
|
|
5706
7470
|
});
|
|
5707
7471
|
return _this;
|
|
5708
7472
|
}
|
|
5709
|
-
_createClass$
|
|
7473
|
+
_createClass$3(RtsPlugin2, [{
|
|
5710
7474
|
key: "pc",
|
|
5711
7475
|
get: function get() {
|
|
5712
7476
|
var _this$_rts4;
|
|
@@ -5738,7 +7502,7 @@
|
|
|
5738
7502
|
}, {
|
|
5739
7503
|
key: "version",
|
|
5740
7504
|
get: function get() {
|
|
5741
|
-
return "0.2.1-alpha.
|
|
7505
|
+
return "0.2.1-alpha.29";
|
|
5742
7506
|
}
|
|
5743
7507
|
}, {
|
|
5744
7508
|
key: "beforePlayerInit",
|
|
@@ -5803,6 +7567,12 @@
|
|
|
5803
7567
|
var _this$_rts10;
|
|
5804
7568
|
return (_this$_rts10 = this._rts) === null || _this$_rts10 === void 0 ? void 0 : _this$_rts10.networkStats;
|
|
5805
7569
|
}
|
|
7570
|
+
}, {
|
|
7571
|
+
key: "setDelay",
|
|
7572
|
+
value: function setDelay(delayHint) {
|
|
7573
|
+
var _this$_rts11;
|
|
7574
|
+
(_this$_rts11 = this._rts) === null || _this$_rts11 === void 0 ? void 0 : _this$_rts11._setDelay(delayHint);
|
|
7575
|
+
}
|
|
5806
7576
|
}, {
|
|
5807
7577
|
key: "_clearDisconnectTimer",
|
|
5808
7578
|
value: function _clearDisconnectTimer() {
|
|
@@ -5812,15 +7582,15 @@
|
|
|
5812
7582
|
}, {
|
|
5813
7583
|
key: "_closeAfterPause",
|
|
5814
7584
|
value: function _closeAfterPause() {
|
|
5815
|
-
var _this$
|
|
5816
|
-
if (!((_this$
|
|
7585
|
+
var _this$_rts12, _this$config, _this$_rts14;
|
|
7586
|
+
if (!((_this$_rts12 = this._rts) !== null && _this$_rts12 !== void 0 && _this$_rts12._pc)) {
|
|
5817
7587
|
return;
|
|
5818
7588
|
}
|
|
5819
7589
|
if ((_this$config = this.config) !== null && _this$config !== void 0 && _this$config.seamlesslyReload) {
|
|
5820
|
-
var _this$
|
|
5821
|
-
this._mediaStream = (_this$
|
|
7590
|
+
var _this$_rts13;
|
|
7591
|
+
this._mediaStream = (_this$_rts13 = this._rts) === null || _this$_rts13 === void 0 ? void 0 : _this$_rts13._mediaStream;
|
|
5822
7592
|
}
|
|
5823
|
-
(_this$
|
|
7593
|
+
(_this$_rts14 = this._rts) === null || _this$_rts14 === void 0 ? void 0 : _this$_rts14.destroy(true);
|
|
5824
7594
|
this._rts = null;
|
|
5825
7595
|
}
|
|
5826
7596
|
}, {
|
|
@@ -5833,7 +7603,9 @@
|
|
|
5833
7603
|
this._transCoreEvent(EVENT.LOAD_RESPONSE_HEADERS);
|
|
5834
7604
|
this._transCoreEvent(EVENT.LOAD_RETRY);
|
|
5835
7605
|
this._transCoreEvent(EVENT.METADATA_PARSED);
|
|
7606
|
+
this._transCoreEvent(EVENT.SEI);
|
|
5836
7607
|
this._transCoreEvent(EXTEND_EVENTS.RTC_STATE_CHANGE);
|
|
7608
|
+
this._transCoreEvent(EXTEND_EVENTS.RTC_NETWORK);
|
|
5837
7609
|
}
|
|
5838
7610
|
}, {
|
|
5839
7611
|
key: "_transErrorEvent",
|