hls.js 1.5.8-0.canary.10115 → 1.5.8-0.canary.10119
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/dist/hls-demo.js +2 -3
- package/dist/hls-demo.js.map +1 -1
- package/dist/hls.js +301 -327
- package/dist/hls.js.map +1 -1
- package/dist/hls.light.js +201 -222
- package/dist/hls.light.js.map +1 -1
- package/dist/hls.light.min.js +1 -1
- package/dist/hls.light.min.js.map +1 -1
- package/dist/hls.light.mjs +3 -3
- package/dist/hls.min.js +1 -1
- package/dist/hls.min.js.map +1 -1
- package/dist/hls.mjs +3 -3
- package/dist/hls.worker.js +1 -1
- package/dist/hls.worker.js.map +1 -1
- package/package.json +8 -8
package/dist/hls.js
CHANGED
@@ -53,7 +53,7 @@
|
|
53
53
|
}
|
54
54
|
function _toPropertyKey(t) {
|
55
55
|
var i = _toPrimitive(t, "string");
|
56
|
-
return "symbol" == typeof i ? i :
|
56
|
+
return "symbol" == typeof i ? i : i + "";
|
57
57
|
}
|
58
58
|
function _defineProperties(target, props) {
|
59
59
|
for (var i = 0; i < props.length; i++) {
|
@@ -151,12 +151,6 @@
|
|
151
151
|
};
|
152
152
|
return _wrapNativeSuper(Class);
|
153
153
|
}
|
154
|
-
function _assertThisInitialized(self) {
|
155
|
-
if (self === void 0) {
|
156
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
157
|
-
}
|
158
|
-
return self;
|
159
|
-
}
|
160
154
|
function _unsupportedIterableToArray(o, minLen) {
|
161
155
|
if (!o) return;
|
162
156
|
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
@@ -574,7 +568,7 @@
|
|
574
568
|
}
|
575
569
|
return attrs;
|
576
570
|
};
|
577
|
-
_createClass(AttrList, [{
|
571
|
+
return _createClass(AttrList, [{
|
578
572
|
key: "clientAttrs",
|
579
573
|
get: function get() {
|
580
574
|
return Object.keys(this).filter(function (attr) {
|
@@ -582,7 +576,6 @@
|
|
582
576
|
});
|
583
577
|
}
|
584
578
|
}]);
|
585
|
-
return AttrList;
|
586
579
|
}();
|
587
580
|
|
588
581
|
var Logger = function Logger(label, logger) {
|
@@ -644,7 +637,7 @@
|
|
644
637
|
// Some browsers don't allow to use bind on console object anyway
|
645
638
|
// fallback to default if needed
|
646
639
|
try {
|
647
|
-
newLogger.log("Debug logs enabled for \"" + context + "\" in hls.js version " + "1.5.8-0.canary.
|
640
|
+
newLogger.log("Debug logs enabled for \"" + context + "\" in hls.js version " + "1.5.8-0.canary.10119");
|
648
641
|
} catch (e) {
|
649
642
|
/* log fn threw an exception. All logger methods are no-ops. */
|
650
643
|
return createLogger();
|
@@ -696,7 +689,7 @@
|
|
696
689
|
}
|
697
690
|
}
|
698
691
|
}
|
699
|
-
_createClass(DateRange, [{
|
692
|
+
return _createClass(DateRange, [{
|
700
693
|
key: "id",
|
701
694
|
get: function get() {
|
702
695
|
return this.attr.ID;
|
@@ -755,7 +748,6 @@
|
|
755
748
|
return !!this.id && !this._badValueForSameId && isFiniteNumber(this.startDate.getTime()) && (this.duration === null || this.duration >= 0) && (!this.endOnNext || !!this.class);
|
756
749
|
}
|
757
750
|
}]);
|
758
|
-
return DateRange;
|
759
751
|
}();
|
760
752
|
|
761
753
|
var LoadStats = function LoadStats() {
|
@@ -812,7 +804,7 @@
|
|
812
804
|
}
|
813
805
|
this._byteRange = [start, parseInt(params[0]) + start];
|
814
806
|
};
|
815
|
-
_createClass(BaseSegment, [{
|
807
|
+
return _createClass(BaseSegment, [{
|
816
808
|
key: "byteRange",
|
817
809
|
get: function get() {
|
818
810
|
if (!this._byteRange) {
|
@@ -844,17 +836,15 @@
|
|
844
836
|
this._url = value;
|
845
837
|
}
|
846
838
|
}]);
|
847
|
-
return BaseSegment;
|
848
839
|
}();
|
849
840
|
|
850
841
|
/**
|
851
842
|
* Object representing parsed data from an HLS Segment. Found in {@link hls.js#LevelDetails.fragments}.
|
852
843
|
*/
|
853
|
-
var Fragment = /*#__PURE__*/function (
|
854
|
-
_inheritsLoose(Fragment, _BaseSegment);
|
844
|
+
var Fragment = /*#__PURE__*/function (_BaseSegment2) {
|
855
845
|
function Fragment(type, baseurl) {
|
856
846
|
var _this;
|
857
|
-
_this =
|
847
|
+
_this = _BaseSegment2.call(this, baseurl) || this;
|
858
848
|
_this._decryptdata = null;
|
859
849
|
_this.rawProgramDateTime = null;
|
860
850
|
_this.programDateTime = null;
|
@@ -912,6 +902,7 @@
|
|
912
902
|
_this.type = type;
|
913
903
|
return _this;
|
914
904
|
}
|
905
|
+
_inheritsLoose(Fragment, _BaseSegment2);
|
915
906
|
var _proto2 = Fragment.prototype;
|
916
907
|
_proto2.setKeyFormat = function setKeyFormat(keyFormat) {
|
917
908
|
if (this.levelkeys) {
|
@@ -953,7 +944,7 @@
|
|
953
944
|
elementaryStreams[ElementaryStreamTypes.VIDEO] = null;
|
954
945
|
elementaryStreams[ElementaryStreamTypes.AUDIOVIDEO] = null;
|
955
946
|
};
|
956
|
-
_createClass(Fragment, [{
|
947
|
+
return _createClass(Fragment, [{
|
957
948
|
key: "decryptdata",
|
958
949
|
get: function get() {
|
959
950
|
var levelkeys = this.levelkeys;
|
@@ -1009,17 +1000,15 @@
|
|
1009
1000
|
return false;
|
1010
1001
|
}
|
1011
1002
|
}]);
|
1012
|
-
return Fragment;
|
1013
1003
|
}(BaseSegment);
|
1014
1004
|
|
1015
1005
|
/**
|
1016
1006
|
* Object representing parsed data from an HLS Partial Segment. Found in {@link hls.js#LevelDetails.partList}.
|
1017
1007
|
*/
|
1018
|
-
var Part = /*#__PURE__*/function (
|
1019
|
-
_inheritsLoose(Part, _BaseSegment2);
|
1008
|
+
var Part = /*#__PURE__*/function (_BaseSegment3) {
|
1020
1009
|
function Part(partAttrs, frag, baseurl, index, previous) {
|
1021
1010
|
var _this2;
|
1022
|
-
_this2 =
|
1011
|
+
_this2 = _BaseSegment3.call(this, baseurl) || this;
|
1023
1012
|
_this2.fragOffset = 0;
|
1024
1013
|
_this2.duration = 0;
|
1025
1014
|
_this2.gap = false;
|
@@ -1043,7 +1032,8 @@
|
|
1043
1032
|
}
|
1044
1033
|
return _this2;
|
1045
1034
|
}
|
1046
|
-
|
1035
|
+
_inheritsLoose(Part, _BaseSegment3);
|
1036
|
+
return _createClass(Part, [{
|
1047
1037
|
key: "start",
|
1048
1038
|
get: function get() {
|
1049
1039
|
return this.fragment.start + this.fragOffset;
|
@@ -1060,7 +1050,6 @@
|
|
1060
1050
|
return !!(elementaryStreams.audio || elementaryStreams.video || elementaryStreams.audiovideo);
|
1061
1051
|
}
|
1062
1052
|
}]);
|
1063
|
-
return Part;
|
1064
1053
|
}(BaseSegment);
|
1065
1054
|
|
1066
1055
|
var DEFAULT_TARGET_DURATION = 10;
|
@@ -1139,7 +1128,7 @@
|
|
1139
1128
|
}
|
1140
1129
|
this.availabilityDelay = previous.availabilityDelay;
|
1141
1130
|
};
|
1142
|
-
_createClass(LevelDetails, [{
|
1131
|
+
return _createClass(LevelDetails, [{
|
1143
1132
|
key: "hasProgramDateTime",
|
1144
1133
|
get: function get() {
|
1145
1134
|
if (this.fragments.length) {
|
@@ -1212,7 +1201,6 @@
|
|
1212
1201
|
return this.endSN;
|
1213
1202
|
}
|
1214
1203
|
}]);
|
1215
|
-
return LevelDetails;
|
1216
1204
|
}();
|
1217
1205
|
|
1218
1206
|
function base64Decode(base64encodedStr) {
|
@@ -2932,9 +2920,6 @@
|
|
2932
2920
|
|
2933
2921
|
var keyUriToKeyIdMap = {};
|
2934
2922
|
var LevelKey = /*#__PURE__*/function () {
|
2935
|
-
LevelKey.clearKeyUriToKeyIdMap = function clearKeyUriToKeyIdMap() {
|
2936
|
-
keyUriToKeyIdMap = {};
|
2937
|
-
};
|
2938
2923
|
function LevelKey(method, uri, format, formatversions, iv) {
|
2939
2924
|
if (formatversions === void 0) {
|
2940
2925
|
formatversions = [1];
|
@@ -2960,6 +2945,9 @@
|
|
2960
2945
|
this.encrypted = method ? method !== 'NONE' : false;
|
2961
2946
|
this.isCommonEncryption = this.encrypted && !isFullSegmentEncryption(method);
|
2962
2947
|
}
|
2948
|
+
LevelKey.clearKeyUriToKeyIdMap = function clearKeyUriToKeyIdMap() {
|
2949
|
+
keyUriToKeyIdMap = {};
|
2950
|
+
};
|
2963
2951
|
var _proto = LevelKey.prototype;
|
2964
2952
|
_proto.isSupported = function isSupported() {
|
2965
2953
|
// If it's Segment encryption or No encryption, just select that key system
|
@@ -5122,7 +5110,7 @@
|
|
5122
5110
|
}
|
5123
5111
|
return liveEdge - this.currentTime;
|
5124
5112
|
};
|
5125
|
-
_createClass(LatencyController, [{
|
5113
|
+
return _createClass(LatencyController, [{
|
5126
5114
|
key: "latency",
|
5127
5115
|
get: function get() {
|
5128
5116
|
return this._latency || 0;
|
@@ -5206,7 +5194,6 @@
|
|
5206
5194
|
return (bufferedRanges ? media.buffered.end(bufferedRanges - 1) : levelDetails.edge) - this.currentTime;
|
5207
5195
|
}
|
5208
5196
|
}]);
|
5209
|
-
return LatencyController;
|
5210
5197
|
}();
|
5211
5198
|
|
5212
5199
|
var HdcpLevels = ['NONE', 'TYPE-0', 'TYPE-1', null];
|
@@ -5340,7 +5327,7 @@
|
|
5340
5327
|
// Deprecated methods (retained for backwards compatibility)
|
5341
5328
|
;
|
5342
5329
|
_proto2.addFallback = function addFallback() {};
|
5343
|
-
_createClass(Level, [{
|
5330
|
+
return _createClass(Level, [{
|
5344
5331
|
key: "maxBitrate",
|
5345
5332
|
get: function get() {
|
5346
5333
|
return Math.max(this.realBitrate, this.bitrate);
|
@@ -5419,7 +5406,6 @@
|
|
5419
5406
|
return (_this$subtitleGroups = this.subtitleGroups) == null ? void 0 : _this$subtitleGroups[0];
|
5420
5407
|
}
|
5421
5408
|
}]);
|
5422
|
-
return Level;
|
5423
5409
|
}();
|
5424
5410
|
function hasGroup(groups, groupId) {
|
5425
5411
|
if (!groupId || !groups) {
|
@@ -6014,7 +6000,6 @@
|
|
6014
6000
|
SwitchToSDR: 4
|
6015
6001
|
}; // Reserved for future use
|
6016
6002
|
var ErrorController = /*#__PURE__*/function (_Logger) {
|
6017
|
-
_inheritsLoose(ErrorController, _Logger);
|
6018
6003
|
function ErrorController(hls) {
|
6019
6004
|
var _this;
|
6020
6005
|
_this = _Logger.call(this, 'error-controller', hls.logger) || this;
|
@@ -6025,6 +6010,7 @@
|
|
6025
6010
|
_this.registerListeners();
|
6026
6011
|
return _this;
|
6027
6012
|
}
|
6013
|
+
_inheritsLoose(ErrorController, _Logger);
|
6028
6014
|
var _proto = ErrorController.prototype;
|
6029
6015
|
_proto.registerListeners = function registerListeners() {
|
6030
6016
|
var hls = this.hls;
|
@@ -6382,7 +6368,6 @@
|
|
6382
6368
|
}(Logger);
|
6383
6369
|
|
6384
6370
|
var BasePlaylistController = /*#__PURE__*/function (_Logger) {
|
6385
|
-
_inheritsLoose(BasePlaylistController, _Logger);
|
6386
6371
|
function BasePlaylistController(hls, logPrefix) {
|
6387
6372
|
var _this;
|
6388
6373
|
_this = _Logger.call(this, logPrefix, hls.logger) || this;
|
@@ -6393,6 +6378,7 @@
|
|
6393
6378
|
_this.hls = hls;
|
6394
6379
|
return _this;
|
6395
6380
|
}
|
6381
|
+
_inheritsLoose(BasePlaylistController, _Logger);
|
6396
6382
|
var _proto = BasePlaylistController.prototype;
|
6397
6383
|
_proto.destroy = function destroy() {
|
6398
6384
|
this.clearTimer();
|
@@ -7227,7 +7213,6 @@
|
|
7227
7213
|
}
|
7228
7214
|
|
7229
7215
|
var AbrController = /*#__PURE__*/function (_Logger) {
|
7230
|
-
_inheritsLoose(AbrController, _Logger);
|
7231
7216
|
function AbrController(_hls) {
|
7232
7217
|
var _this;
|
7233
7218
|
_this = _Logger.call(this, 'abr', _hls.logger) || this;
|
@@ -7249,10 +7234,10 @@
|
|
7249
7234
|
quickly enough to prevent underbuffering
|
7250
7235
|
*/
|
7251
7236
|
_this._abandonRulesCheck = function () {
|
7252
|
-
var
|
7253
|
-
frag =
|
7254
|
-
part =
|
7255
|
-
hls =
|
7237
|
+
var _this2 = _this,
|
7238
|
+
frag = _this2.fragCurrent,
|
7239
|
+
part = _this2.partCurrent,
|
7240
|
+
hls = _this2.hls;
|
7256
7241
|
var autoLevelEnabled = hls.autoLevelEnabled,
|
7257
7242
|
media = hls.media;
|
7258
7243
|
if (!frag || !media) {
|
@@ -7353,6 +7338,7 @@
|
|
7353
7338
|
_this.registerListeners();
|
7354
7339
|
return _this;
|
7355
7340
|
}
|
7341
|
+
_inheritsLoose(AbrController, _Logger);
|
7356
7342
|
var _proto = AbrController.prototype;
|
7357
7343
|
_proto.resetEstimator = function resetEstimator(abrEwmaDefaultEstimate) {
|
7358
7344
|
if (abrEwmaDefaultEstimate) {
|
@@ -7640,7 +7626,7 @@
|
|
7640
7626
|
};
|
7641
7627
|
_proto.findBestLevel = function findBestLevel(currentBw, minAutoLevel, maxAutoLevel, bufferStarvationDelay, maxStarvationDelay, bwFactor, bwUpFactor) {
|
7642
7628
|
var _level$details,
|
7643
|
-
|
7629
|
+
_this3 = this;
|
7644
7630
|
var maxFetchDuration = bufferStarvationDelay + maxStarvationDelay;
|
7645
7631
|
var lastLoadedFragLevel = this.lastLoadedFragLevel;
|
7646
7632
|
var selectionBaseLevel = lastLoadedFragLevel === -1 ? this.hls.firstLevel : lastLoadedFragLevel;
|
@@ -7698,19 +7684,19 @@
|
|
7698
7684
|
if (typeof (mediaCapabilities == null ? void 0 : mediaCapabilities.decodingInfo) === 'function' && requiresMediaCapabilitiesDecodingInfo(levelInfo, audioTracksByGroup, currentVideoRange, currentFrameRate, currentBw, audioPreference)) {
|
7699
7685
|
levelInfo.supportedPromise = getMediaDecodingInfoPromise(levelInfo, audioTracksByGroup, mediaCapabilities);
|
7700
7686
|
levelInfo.supportedPromise.then(function (decodingInfo) {
|
7701
|
-
if (!
|
7687
|
+
if (!_this3.hls) {
|
7702
7688
|
return;
|
7703
7689
|
}
|
7704
7690
|
levelInfo.supportedResult = decodingInfo;
|
7705
|
-
var levels =
|
7691
|
+
var levels = _this3.hls.levels;
|
7706
7692
|
var index = levels.indexOf(levelInfo);
|
7707
7693
|
if (decodingInfo.error) {
|
7708
|
-
|
7694
|
+
_this3.warn("MediaCapabilities decodingInfo error: \"" + decodingInfo.error + "\" for level " + index + " " + JSON.stringify(decodingInfo));
|
7709
7695
|
} else if (!decodingInfo.supported) {
|
7710
|
-
|
7696
|
+
_this3.warn("Unsupported MediaCapabilities decodingInfo result for level " + index + " " + JSON.stringify(decodingInfo));
|
7711
7697
|
if (index > -1 && levels.length > 1) {
|
7712
|
-
|
7713
|
-
|
7698
|
+
_this3.log("Removing unsupported level " + index);
|
7699
|
+
_this3.hls.removeLevel(index);
|
7714
7700
|
}
|
7715
7701
|
}
|
7716
7702
|
});
|
@@ -7742,7 +7728,7 @@
|
|
7742
7728
|
|
7743
7729
|
// Use average bitrate when starvation delay (buffer length) is gt or eq two segment durations and rebuffering is not expected (maxStarvationDelay > 0)
|
7744
7730
|
var bitrate = currentFragDuration && bufferStarvationDelay >= currentFragDuration * 2 && maxStarvationDelay === 0 ? levels[i].averageBitrate : levels[i].maxBitrate;
|
7745
|
-
var fetchDuration =
|
7731
|
+
var fetchDuration = _this3.getTimeToLoadFrag(ttfbEstimateSec, adjustedbw, bitrate * avgDuration, levelDetails === undefined);
|
7746
7732
|
var canSwitchWithinTolerance =
|
7747
7733
|
// if adjusted bw is greater than level bitrate AND
|
7748
7734
|
adjustedbw >= bitrate && (
|
@@ -7751,17 +7737,17 @@
|
|
7751
7737
|
// fragment fetchDuration unknown OR live stream OR fragment fetchDuration less than max allowed fetch duration, then this level matches
|
7752
7738
|
// we don't account for max Fetch Duration for live streams, this is to avoid switching down when near the edge of live sliding window ...
|
7753
7739
|
// special case to support startLevel = -1 (bitrateTest) on live streams : in that case we should not exit loop so that findBestLevel will return -1
|
7754
|
-
fetchDuration <= ttfbEstimateSec || !isFiniteNumber(fetchDuration) || live && !
|
7740
|
+
fetchDuration <= ttfbEstimateSec || !isFiniteNumber(fetchDuration) || live && !_this3.bitrateTestDelay || fetchDuration < maxFetchDuration);
|
7755
7741
|
if (canSwitchWithinTolerance) {
|
7756
|
-
var forcedAutoLevel =
|
7742
|
+
var forcedAutoLevel = _this3.forcedAutoLevel;
|
7757
7743
|
if (i !== loadLevel && (forcedAutoLevel === -1 || forcedAutoLevel !== loadLevel)) {
|
7758
7744
|
if (levelsSkipped.length) {
|
7759
|
-
|
7745
|
+
_this3.trace("Skipped level(s) " + levelsSkipped.join(',') + " of " + maxAutoLevel + " max with CODECS and VIDEO-RANGE:\"" + levels[levelsSkipped[0]].codecs + "\" " + levels[levelsSkipped[0]].videoRange + "; not compatible with \"" + level.codecs + "\" " + currentVideoRange);
|
7760
7746
|
}
|
7761
|
-
|
7747
|
+
_this3.info("switch candidate:" + selectionBaseLevel + "->" + i + " adjustedbw(" + Math.round(adjustedbw) + ")-bitrate=" + Math.round(adjustedbw - bitrate) + " ttfb:" + ttfbEstimateSec.toFixed(1) + " avgDuration:" + avgDuration.toFixed(1) + " maxFetchDuration:" + maxFetchDuration.toFixed(1) + " fetchDuration:" + fetchDuration.toFixed(1) + " firstSelection:" + firstSelection + " codecSet:" + currentCodecSet + " videoRange:" + currentVideoRange + " hls.loadLevel:" + loadLevel);
|
7762
7748
|
}
|
7763
7749
|
if (firstSelection) {
|
7764
|
-
|
7750
|
+
_this3.firstSelection = i;
|
7765
7751
|
}
|
7766
7752
|
// as we are looping from highest to lowest, this will return the best achievable quality level
|
7767
7753
|
return {
|
@@ -7778,7 +7764,7 @@
|
|
7778
7764
|
// not enough time budget even with quality level 0 ... rebuffering might happen
|
7779
7765
|
return -1;
|
7780
7766
|
};
|
7781
|
-
_createClass(AbrController, [{
|
7767
|
+
return _createClass(AbrController, [{
|
7782
7768
|
key: "firstAutoLevel",
|
7783
7769
|
get: function get() {
|
7784
7770
|
var _this$hls2 = this.hls,
|
@@ -7844,7 +7830,6 @@
|
|
7844
7830
|
}
|
7845
7831
|
}
|
7846
7832
|
}]);
|
7847
|
-
return AbrController;
|
7848
7833
|
}(Logger);
|
7849
7834
|
|
7850
7835
|
/**
|
@@ -7877,7 +7862,6 @@
|
|
7877
7862
|
* task processing on the next main loop iteration (also known as "next tick" in the Node/JS runtime lingo).
|
7878
7863
|
*/
|
7879
7864
|
var TaskLoop = /*#__PURE__*/function (_Logger) {
|
7880
|
-
_inheritsLoose(TaskLoop, _Logger);
|
7881
7865
|
function TaskLoop(label, logger) {
|
7882
7866
|
var _this;
|
7883
7867
|
_this = _Logger.call(this, label, logger) || this;
|
@@ -7885,9 +7869,10 @@
|
|
7885
7869
|
_this._tickTimer = null;
|
7886
7870
|
_this._tickInterval = null;
|
7887
7871
|
_this._tickCallCount = 0;
|
7888
|
-
_this._boundTick = _this.tick.bind(
|
7872
|
+
_this._boundTick = _this.tick.bind(_this);
|
7889
7873
|
return _this;
|
7890
7874
|
}
|
7875
|
+
_inheritsLoose(TaskLoop, _Logger);
|
7891
7876
|
var _proto = TaskLoop.prototype;
|
7892
7877
|
_proto.destroy = function destroy() {
|
7893
7878
|
this.onHandlerDestroying();
|
@@ -9014,7 +8999,6 @@
|
|
9014
8999
|
return method === 'AES-128' || method === 'AES-256';
|
9015
9000
|
}
|
9016
9001
|
var LoadError = /*#__PURE__*/function (_Error) {
|
9017
|
-
_inheritsLoose(LoadError, _Error);
|
9018
9002
|
function LoadError(data) {
|
9019
9003
|
var _this3;
|
9020
9004
|
_this3 = _Error.call(this, data.error.message) || this;
|
@@ -9022,6 +9006,7 @@
|
|
9022
9006
|
_this3.data = data;
|
9023
9007
|
return _this3;
|
9024
9008
|
}
|
9009
|
+
_inheritsLoose(LoadError, _Error);
|
9025
9010
|
return LoadError;
|
9026
9011
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
9027
9012
|
|
@@ -9529,7 +9514,6 @@
|
|
9529
9514
|
WAITING_LEVEL: 'WAITING_LEVEL'
|
9530
9515
|
};
|
9531
9516
|
var BaseStreamController = /*#__PURE__*/function (_TaskLoop) {
|
9532
|
-
_inheritsLoose(BaseStreamController, _TaskLoop);
|
9533
9517
|
function BaseStreamController(hls, fragmentTracker, keyLoader, logPrefix, playlistType) {
|
9534
9518
|
var _this;
|
9535
9519
|
_this = _TaskLoop.call(this, logPrefix, hls.logger) || this;
|
@@ -9560,12 +9544,12 @@
|
|
9560
9544
|
_this.buffering = true;
|
9561
9545
|
_this.loadingParts = false;
|
9562
9546
|
_this.onMediaSeeking = function () {
|
9563
|
-
var
|
9564
|
-
config =
|
9565
|
-
fragCurrent =
|
9566
|
-
media =
|
9567
|
-
mediaBuffer =
|
9568
|
-
state =
|
9547
|
+
var _this2 = _this,
|
9548
|
+
config = _this2.config,
|
9549
|
+
fragCurrent = _this2.fragCurrent,
|
9550
|
+
media = _this2.media,
|
9551
|
+
mediaBuffer = _this2.mediaBuffer,
|
9552
|
+
state = _this2.state;
|
9569
9553
|
var currentTime = media ? media.currentTime : 0;
|
9570
9554
|
var bufferInfo = BufferHelper.bufferInfo(mediaBuffer ? mediaBuffer : media, currentTime, config.maxBufferHole);
|
9571
9555
|
_this.log("media seeking to " + (isFiniteNumber(currentTime) ? currentTime.toFixed(3) : currentTime) + ", state: " + state);
|
@@ -9630,6 +9614,7 @@
|
|
9630
9614
|
_this.decrypter = new Decrypter(hls.config);
|
9631
9615
|
return _this;
|
9632
9616
|
}
|
9617
|
+
_inheritsLoose(BaseStreamController, _TaskLoop);
|
9633
9618
|
var _proto = BaseStreamController.prototype;
|
9634
9619
|
_proto.registerListeners = function registerListeners() {
|
9635
9620
|
var hls = this.hls;
|
@@ -9763,42 +9748,42 @@
|
|
9763
9748
|
this._loadFragForPlayback(frag, level, targetBufferTime);
|
9764
9749
|
};
|
9765
9750
|
_proto._loadFragForPlayback = function _loadFragForPlayback(frag, level, targetBufferTime) {
|
9766
|
-
var
|
9751
|
+
var _this3 = this;
|
9767
9752
|
var progressCallback = function progressCallback(data) {
|
9768
|
-
if (
|
9769
|
-
|
9770
|
-
|
9753
|
+
if (_this3.fragContextChanged(frag)) {
|
9754
|
+
_this3.warn("Fragment " + frag.sn + (data.part ? ' p: ' + data.part.index : '') + " of level " + frag.level + " was dropped during download.");
|
9755
|
+
_this3.fragmentTracker.removeFragment(frag);
|
9771
9756
|
return;
|
9772
9757
|
}
|
9773
9758
|
frag.stats.chunkCount++;
|
9774
|
-
|
9759
|
+
_this3._handleFragmentLoadProgress(data);
|
9775
9760
|
};
|
9776
9761
|
this._doFragLoad(frag, level, targetBufferTime, progressCallback).then(function (data) {
|
9777
9762
|
if (!data) {
|
9778
9763
|
// if we're here we probably needed to backtrack or are waiting for more parts
|
9779
9764
|
return;
|
9780
9765
|
}
|
9781
|
-
var state =
|
9782
|
-
if (
|
9783
|
-
if (state === State.FRAG_LOADING || !
|
9784
|
-
|
9785
|
-
|
9766
|
+
var state = _this3.state;
|
9767
|
+
if (_this3.fragContextChanged(frag)) {
|
9768
|
+
if (state === State.FRAG_LOADING || !_this3.fragCurrent && state === State.PARSING) {
|
9769
|
+
_this3.fragmentTracker.removeFragment(frag);
|
9770
|
+
_this3.state = State.IDLE;
|
9786
9771
|
}
|
9787
9772
|
return;
|
9788
9773
|
}
|
9789
9774
|
if ('payload' in data) {
|
9790
|
-
|
9791
|
-
|
9775
|
+
_this3.log("Loaded fragment " + frag.sn + " of level " + frag.level);
|
9776
|
+
_this3.hls.trigger(Events.FRAG_LOADED, data);
|
9792
9777
|
}
|
9793
9778
|
|
9794
9779
|
// Pass through the whole payload; controllers not implementing progressive loading receive data from this callback
|
9795
|
-
|
9780
|
+
_this3._handleFragmentLoadComplete(data);
|
9796
9781
|
}).catch(function (reason) {
|
9797
|
-
if (
|
9782
|
+
if (_this3.state === State.STOPPED || _this3.state === State.ERROR) {
|
9798
9783
|
return;
|
9799
9784
|
}
|
9800
|
-
|
9801
|
-
|
9785
|
+
_this3.warn(reason);
|
9786
|
+
_this3.resetFragmentLoading(frag);
|
9802
9787
|
});
|
9803
9788
|
};
|
9804
9789
|
_proto.clearTrackerIfNeeded = function clearTrackerIfNeeded(frag) {
|
@@ -9861,14 +9846,14 @@
|
|
9861
9846
|
this.hls.trigger(Events.BUFFER_FLUSHING, flushScope);
|
9862
9847
|
};
|
9863
9848
|
_proto._loadInitSegment = function _loadInitSegment(frag, level) {
|
9864
|
-
var
|
9849
|
+
var _this4 = this;
|
9865
9850
|
this._doFragLoad(frag, level).then(function (data) {
|
9866
|
-
if (!data ||
|
9851
|
+
if (!data || _this4.fragContextChanged(frag) || !_this4.levels) {
|
9867
9852
|
throw new Error('init load aborted');
|
9868
9853
|
}
|
9869
9854
|
return data;
|
9870
9855
|
}).then(function (data) {
|
9871
|
-
var hls =
|
9856
|
+
var hls = _this4.hls;
|
9872
9857
|
var payload = data.payload;
|
9873
9858
|
var decryptData = frag.decryptdata;
|
9874
9859
|
|
@@ -9876,7 +9861,7 @@
|
|
9876
9861
|
if (payload && payload.byteLength > 0 && decryptData != null && decryptData.key && decryptData.iv && isFullSegmentEncryption(decryptData.method)) {
|
9877
9862
|
var startTime = self.performance.now();
|
9878
9863
|
// decrypt init segment data
|
9879
|
-
return
|
9864
|
+
return _this4.decrypter.decrypt(new Uint8Array(payload), decryptData.key.buffer, decryptData.iv.buffer, getAesModeFromFullSegmentMethod(decryptData.method)).catch(function (err) {
|
9880
9865
|
hls.trigger(Events.ERROR, {
|
9881
9866
|
type: ErrorTypes.MEDIA_ERROR,
|
9882
9867
|
details: ErrorDetails.FRAG_DECRYPT_ERROR,
|
@@ -9897,16 +9882,16 @@
|
|
9897
9882
|
}
|
9898
9883
|
});
|
9899
9884
|
data.payload = decryptedData;
|
9900
|
-
return
|
9885
|
+
return _this4.completeInitSegmentLoad(data);
|
9901
9886
|
});
|
9902
9887
|
}
|
9903
|
-
return
|
9888
|
+
return _this4.completeInitSegmentLoad(data);
|
9904
9889
|
}).catch(function (reason) {
|
9905
|
-
if (
|
9890
|
+
if (_this4.state === State.STOPPED || _this4.state === State.ERROR) {
|
9906
9891
|
return;
|
9907
9892
|
}
|
9908
|
-
|
9909
|
-
|
9893
|
+
_this4.warn(reason);
|
9894
|
+
_this4.resetFragmentLoading(frag);
|
9910
9895
|
});
|
9911
9896
|
};
|
9912
9897
|
_proto.completeInitSegmentLoad = function completeInitSegmentLoad(data) {
|
@@ -9981,7 +9966,7 @@
|
|
9981
9966
|
_proto._handleFragmentLoadProgress = function _handleFragmentLoadProgress(frag) {};
|
9982
9967
|
_proto._doFragLoad = function _doFragLoad(frag, level, targetBufferTime, progressCallback) {
|
9983
9968
|
var _frag$decryptdata,
|
9984
|
-
|
9969
|
+
_this5 = this;
|
9985
9970
|
if (targetBufferTime === void 0) {
|
9986
9971
|
targetBufferTime = null;
|
9987
9972
|
}
|
@@ -9995,10 +9980,10 @@
|
|
9995
9980
|
this.state = State.KEY_LOADING;
|
9996
9981
|
this.fragCurrent = frag;
|
9997
9982
|
keyLoadingPromise = this.keyLoader.load(frag).then(function (keyLoadedData) {
|
9998
|
-
if (!
|
9999
|
-
|
10000
|
-
if (
|
10001
|
-
|
9983
|
+
if (!_this5.fragContextChanged(keyLoadedData.frag)) {
|
9984
|
+
_this5.hls.trigger(Events.KEY_LOADED, keyLoadedData);
|
9985
|
+
if (_this5.state === State.KEY_LOADING) {
|
9986
|
+
_this5.state = State.IDLE;
|
10002
9987
|
}
|
10003
9988
|
return keyLoadedData;
|
10004
9989
|
}
|
@@ -10036,16 +10021,16 @@
|
|
10036
10021
|
var _result;
|
10037
10022
|
if (keyLoadingPromise) {
|
10038
10023
|
_result = keyLoadingPromise.then(function (keyLoadedData) {
|
10039
|
-
if (!keyLoadedData ||
|
10024
|
+
if (!keyLoadedData || _this5.fragContextChanged(keyLoadedData.frag)) {
|
10040
10025
|
return null;
|
10041
10026
|
}
|
10042
|
-
return
|
10027
|
+
return _this5.doFragPartsLoad(frag, part, level, progressCallback);
|
10043
10028
|
}).catch(function (error) {
|
10044
|
-
return
|
10029
|
+
return _this5.handleFragLoadError(error);
|
10045
10030
|
});
|
10046
10031
|
} else {
|
10047
10032
|
_result = this.doFragPartsLoad(frag, part, level, progressCallback).catch(function (error) {
|
10048
|
-
return
|
10033
|
+
return _this5.handleFragLoadError(error);
|
10049
10034
|
});
|
10050
10035
|
}
|
10051
10036
|
this.hls.trigger(Events.FRAG_LOADING, {
|
@@ -10082,12 +10067,12 @@
|
|
10082
10067
|
var result;
|
10083
10068
|
if (dataOnProgress && keyLoadingPromise) {
|
10084
10069
|
result = keyLoadingPromise.then(function (keyLoadedData) {
|
10085
|
-
if (!keyLoadedData ||
|
10070
|
+
if (!keyLoadedData || _this5.fragContextChanged(keyLoadedData == null ? void 0 : keyLoadedData.frag)) {
|
10086
10071
|
return null;
|
10087
10072
|
}
|
10088
|
-
return
|
10073
|
+
return _this5.fragmentLoader.load(frag, progressCallback);
|
10089
10074
|
}).catch(function (error) {
|
10090
|
-
return
|
10075
|
+
return _this5.handleFragLoadError(error);
|
10091
10076
|
});
|
10092
10077
|
} else {
|
10093
10078
|
// load unencrypted fragment data with progress event,
|
@@ -10099,7 +10084,7 @@
|
|
10099
10084
|
}
|
10100
10085
|
return fragLoadedData;
|
10101
10086
|
}).catch(function (error) {
|
10102
|
-
return
|
10087
|
+
return _this5.handleFragLoadError(error);
|
10103
10088
|
});
|
10104
10089
|
}
|
10105
10090
|
this.hls.trigger(Events.FRAG_LOADING, {
|
@@ -10112,16 +10097,16 @@
|
|
10112
10097
|
return result;
|
10113
10098
|
};
|
10114
10099
|
_proto.doFragPartsLoad = function doFragPartsLoad(frag, fromPart, level, progressCallback) {
|
10115
|
-
var
|
10100
|
+
var _this6 = this;
|
10116
10101
|
return new Promise(function (resolve, reject) {
|
10117
10102
|
var _level$details;
|
10118
10103
|
var partsLoaded = [];
|
10119
10104
|
var initialPartList = (_level$details = level.details) == null ? void 0 : _level$details.partList;
|
10120
10105
|
var loadPart = function loadPart(part) {
|
10121
|
-
|
10106
|
+
_this6.fragmentLoader.loadPart(frag, part, progressCallback).then(function (partLoadedData) {
|
10122
10107
|
partsLoaded[part.index] = partLoadedData;
|
10123
10108
|
var loadedPart = partLoadedData.part;
|
10124
|
-
|
10109
|
+
_this6.hls.trigger(Events.FRAG_LOADED, partLoadedData);
|
10125
10110
|
var nextPart = getPartWith(level, frag.sn, part.index + 1) || findPart(initialPartList, frag.sn, part.index + 1);
|
10126
10111
|
if (nextPart) {
|
10127
10112
|
loadPart(nextPart);
|
@@ -10765,7 +10750,7 @@
|
|
10765
10750
|
this.fragmentTracker.removeFragmentsInRange(start, Infinity, this.playlistType, false, true);
|
10766
10751
|
};
|
10767
10752
|
_proto.updateLevelTiming = function updateLevelTiming(frag, part, level, partial) {
|
10768
|
-
var
|
10753
|
+
var _this7 = this,
|
10769
10754
|
_this$transmuxer;
|
10770
10755
|
var details = level.details;
|
10771
10756
|
if (!details) {
|
@@ -10780,11 +10765,11 @@
|
|
10780
10765
|
// Destroy the transmuxer after it's next time offset failed to advance because duration was <= 0.
|
10781
10766
|
// The new transmuxer will be configured with a time offset matching the next fragment start,
|
10782
10767
|
// preventing the timeline from shifting.
|
10783
|
-
|
10768
|
+
_this7.warn("Could not parse fragment " + frag.sn + " " + type + " duration reliably (" + parsedDuration + ")");
|
10784
10769
|
return result || false;
|
10785
10770
|
}
|
10786
10771
|
var drift = partial ? 0 : updateFragPTSDTS(details, frag, info.startPTS, info.endPTS, info.startDTS, info.endDTS);
|
10787
|
-
|
10772
|
+
_this7.hls.trigger(Events.LEVEL_PTS_UPDATED, {
|
10788
10773
|
details: details,
|
10789
10774
|
level: level,
|
10790
10775
|
drift: drift,
|
@@ -10841,7 +10826,7 @@
|
|
10841
10826
|
this.resetLoadingState();
|
10842
10827
|
}
|
10843
10828
|
};
|
10844
|
-
_createClass(BaseStreamController, [{
|
10829
|
+
return _createClass(BaseStreamController, [{
|
10845
10830
|
key: "state",
|
10846
10831
|
get: function get() {
|
10847
10832
|
return this._state;
|
@@ -10854,7 +10839,6 @@
|
|
10854
10839
|
}
|
10855
10840
|
}
|
10856
10841
|
}]);
|
10857
|
-
return BaseStreamController;
|
10858
10842
|
}(TaskLoop);
|
10859
10843
|
|
10860
10844
|
var ChunkCache = /*#__PURE__*/function () {
|
@@ -11452,7 +11436,6 @@
|
|
11452
11436
|
}
|
11453
11437
|
|
11454
11438
|
var AACDemuxer = /*#__PURE__*/function (_BaseAudioDemuxer) {
|
11455
|
-
_inheritsLoose(AACDemuxer, _BaseAudioDemuxer);
|
11456
11439
|
function AACDemuxer(observer, config) {
|
11457
11440
|
var _this;
|
11458
11441
|
_this = _BaseAudioDemuxer.call(this) || this;
|
@@ -11462,6 +11445,7 @@
|
|
11462
11445
|
_this.config = config;
|
11463
11446
|
return _this;
|
11464
11447
|
}
|
11448
|
+
_inheritsLoose(AACDemuxer, _BaseAudioDemuxer);
|
11465
11449
|
var _proto = AACDemuxer.prototype;
|
11466
11450
|
_proto.resetInitSegment = function resetInitSegment(initSegment, audioCodec, videoCodec, trackDuration) {
|
11467
11451
|
_BaseAudioDemuxer.prototype.resetInitSegment.call(this, initSegment, audioCodec, videoCodec, trackDuration);
|
@@ -11671,7 +11655,6 @@
|
|
11671
11655
|
};
|
11672
11656
|
|
11673
11657
|
var AC3Demuxer = /*#__PURE__*/function (_BaseAudioDemuxer) {
|
11674
|
-
_inheritsLoose(AC3Demuxer, _BaseAudioDemuxer);
|
11675
11658
|
function AC3Demuxer(observer) {
|
11676
11659
|
var _this;
|
11677
11660
|
_this = _BaseAudioDemuxer.call(this) || this;
|
@@ -11679,6 +11662,7 @@
|
|
11679
11662
|
_this.observer = observer;
|
11680
11663
|
return _this;
|
11681
11664
|
}
|
11665
|
+
_inheritsLoose(AC3Demuxer, _BaseAudioDemuxer);
|
11682
11666
|
var _proto = AC3Demuxer.prototype;
|
11683
11667
|
_proto.resetInitSegment = function resetInitSegment(initSegment, audioCodec, videoCodec, trackDuration) {
|
11684
11668
|
_BaseAudioDemuxer.prototype.resetInitSegment.call(this, initSegment, audioCodec, videoCodec, trackDuration);
|
@@ -12103,10 +12087,10 @@
|
|
12103
12087
|
}();
|
12104
12088
|
|
12105
12089
|
var AvcVideoParser = /*#__PURE__*/function (_BaseVideoParser) {
|
12106
|
-
_inheritsLoose(AvcVideoParser, _BaseVideoParser);
|
12107
12090
|
function AvcVideoParser() {
|
12108
12091
|
return _BaseVideoParser.apply(this, arguments) || this;
|
12109
12092
|
}
|
12093
|
+
_inheritsLoose(AvcVideoParser, _BaseVideoParser);
|
12110
12094
|
var _proto = AvcVideoParser.prototype;
|
12111
12095
|
_proto.parsePES = function parsePES(track, textTrack, pes, last, duration) {
|
12112
12096
|
var _this = this;
|
@@ -12436,7 +12420,6 @@
|
|
12436
12420
|
}(BaseVideoParser);
|
12437
12421
|
|
12438
12422
|
var HevcVideoParser = /*#__PURE__*/function (_BaseVideoParser) {
|
12439
|
-
_inheritsLoose(HevcVideoParser, _BaseVideoParser);
|
12440
12423
|
function HevcVideoParser() {
|
12441
12424
|
var _this;
|
12442
12425
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
@@ -12446,6 +12429,7 @@
|
|
12446
12429
|
_this.initVPS = null;
|
12447
12430
|
return _this;
|
12448
12431
|
}
|
12432
|
+
_inheritsLoose(HevcVideoParser, _BaseVideoParser);
|
12449
12433
|
var _proto = HevcVideoParser.prototype;
|
12450
12434
|
_proto.parsePES = function parsePES(track, textTrack, pes, last, duration) {
|
12451
12435
|
var _this2 = this;
|
@@ -13988,10 +13972,10 @@
|
|
13988
13972
|
}
|
13989
13973
|
|
13990
13974
|
var MP3Demuxer = /*#__PURE__*/function (_BaseAudioDemuxer) {
|
13991
|
-
_inheritsLoose(MP3Demuxer, _BaseAudioDemuxer);
|
13992
13975
|
function MP3Demuxer() {
|
13993
13976
|
return _BaseAudioDemuxer.apply(this, arguments) || this;
|
13994
13977
|
}
|
13978
|
+
_inheritsLoose(MP3Demuxer, _BaseAudioDemuxer);
|
13995
13979
|
var _proto = MP3Demuxer.prototype;
|
13996
13980
|
_proto.resetInitSegment = function resetInitSegment(initSegment, audioCodec, videoCodec, trackDuration) {
|
13997
13981
|
_BaseAudioDemuxer.prototype.resetInitSegment.call(this, initSegment, audioCodec, videoCodec, trackDuration);
|
@@ -17096,7 +17080,6 @@
|
|
17096
17080
|
|
17097
17081
|
var TICK_INTERVAL$2 = 100; // how often to tick in ms
|
17098
17082
|
var AudioStreamController = /*#__PURE__*/function (_BaseStreamController) {
|
17099
|
-
_inheritsLoose(AudioStreamController, _BaseStreamController);
|
17100
17083
|
function AudioStreamController(hls, fragmentTracker, keyLoader) {
|
17101
17084
|
var _this;
|
17102
17085
|
_this = _BaseStreamController.call(this, hls, fragmentTracker, keyLoader, 'audio-stream-controller', PlaylistLevelType.AUDIO) || this;
|
@@ -17114,6 +17097,7 @@
|
|
17114
17097
|
_this.registerListeners();
|
17115
17098
|
return _this;
|
17116
17099
|
}
|
17100
|
+
_inheritsLoose(AudioStreamController, _BaseStreamController);
|
17117
17101
|
var _proto = AudioStreamController.prototype;
|
17118
17102
|
_proto.onHandlerDestroying = function onHandlerDestroying() {
|
17119
17103
|
this.unregisterListeners();
|
@@ -17829,7 +17813,6 @@
|
|
17829
17813
|
}(BaseStreamController);
|
17830
17814
|
|
17831
17815
|
var AudioTrackController = /*#__PURE__*/function (_BasePlaylistControll) {
|
17832
|
-
_inheritsLoose(AudioTrackController, _BasePlaylistControll);
|
17833
17816
|
function AudioTrackController(hls) {
|
17834
17817
|
var _this;
|
17835
17818
|
_this = _BasePlaylistControll.call(this, hls, 'audio-track-controller') || this;
|
@@ -17842,6 +17825,7 @@
|
|
17842
17825
|
_this.registerListeners();
|
17843
17826
|
return _this;
|
17844
17827
|
}
|
17828
|
+
_inheritsLoose(AudioTrackController, _BasePlaylistControll);
|
17845
17829
|
var _proto = AudioTrackController.prototype;
|
17846
17830
|
_proto.registerListeners = function registerListeners() {
|
17847
17831
|
var hls = this.hls;
|
@@ -18131,7 +18115,7 @@
|
|
18131
18115
|
});
|
18132
18116
|
}
|
18133
18117
|
};
|
18134
|
-
_createClass(AudioTrackController, [{
|
18118
|
+
return _createClass(AudioTrackController, [{
|
18135
18119
|
key: "allAudioTracks",
|
18136
18120
|
get: function get() {
|
18137
18121
|
return this.tracks;
|
@@ -18152,13 +18136,11 @@
|
|
18152
18136
|
this.setAudioTrack(newId);
|
18153
18137
|
}
|
18154
18138
|
}]);
|
18155
|
-
return AudioTrackController;
|
18156
18139
|
}(BasePlaylistController);
|
18157
18140
|
|
18158
18141
|
var TICK_INTERVAL$1 = 500; // how often to tick in ms
|
18159
18142
|
|
18160
18143
|
var SubtitleStreamController = /*#__PURE__*/function (_BaseStreamController) {
|
18161
|
-
_inheritsLoose(SubtitleStreamController, _BaseStreamController);
|
18162
18144
|
function SubtitleStreamController(hls, fragmentTracker, keyLoader) {
|
18163
18145
|
var _this;
|
18164
18146
|
_this = _BaseStreamController.call(this, hls, fragmentTracker, keyLoader, 'subtitle-stream-controller', PlaylistLevelType.SUBTITLE) || this;
|
@@ -18168,6 +18150,7 @@
|
|
18168
18150
|
_this.registerListeners();
|
18169
18151
|
return _this;
|
18170
18152
|
}
|
18153
|
+
_inheritsLoose(SubtitleStreamController, _BaseStreamController);
|
18171
18154
|
var _proto = SubtitleStreamController.prototype;
|
18172
18155
|
_proto.onHandlerDestroying = function onHandlerDestroying() {
|
18173
18156
|
this.unregisterListeners();
|
@@ -18504,13 +18487,12 @@
|
|
18504
18487
|
_BaseStreamController.prototype.loadFragment.call(this, frag, level, targetBufferTime);
|
18505
18488
|
}
|
18506
18489
|
};
|
18507
|
-
_createClass(SubtitleStreamController, [{
|
18490
|
+
return _createClass(SubtitleStreamController, [{
|
18508
18491
|
key: "mediaBufferTimeRanges",
|
18509
18492
|
get: function get() {
|
18510
18493
|
return new BufferableInstance(this.tracksBuffered[this.currentTrackId] || []);
|
18511
18494
|
}
|
18512
18495
|
}]);
|
18513
|
-
return SubtitleStreamController;
|
18514
18496
|
}(BaseStreamController);
|
18515
18497
|
var BufferableInstance = function BufferableInstance(timeranges) {
|
18516
18498
|
this.buffered = void 0;
|
@@ -18535,7 +18517,6 @@
|
|
18535
18517
|
};
|
18536
18518
|
|
18537
18519
|
var SubtitleTrackController = /*#__PURE__*/function (_BasePlaylistControll) {
|
18538
|
-
_inheritsLoose(SubtitleTrackController, _BasePlaylistControll);
|
18539
18520
|
function SubtitleTrackController(hls) {
|
18540
18521
|
var _this;
|
18541
18522
|
_this = _BasePlaylistControll.call(this, hls, 'subtitle-track-controller') || this;
|
@@ -18582,6 +18563,7 @@
|
|
18582
18563
|
_this.registerListeners();
|
18583
18564
|
return _this;
|
18584
18565
|
}
|
18566
|
+
_inheritsLoose(SubtitleTrackController, _BasePlaylistControll);
|
18585
18567
|
var _proto = SubtitleTrackController.prototype;
|
18586
18568
|
_proto.destroy = function destroy() {
|
18587
18569
|
this.unregisterListeners();
|
@@ -18956,7 +18938,7 @@
|
|
18956
18938
|
var hlsUrlParameters = this.switchParams(track.url, lastTrack == null ? void 0 : lastTrack.details);
|
18957
18939
|
this.loadPlaylist(hlsUrlParameters);
|
18958
18940
|
};
|
18959
|
-
_createClass(SubtitleTrackController, [{
|
18941
|
+
return _createClass(SubtitleTrackController, [{
|
18960
18942
|
key: "subtitleDisplay",
|
18961
18943
|
get: function get() {
|
18962
18944
|
return this._subtitleDisplay;
|
@@ -18991,7 +18973,6 @@
|
|
18991
18973
|
this.setSubtitleTrack(newId);
|
18992
18974
|
}
|
18993
18975
|
}]);
|
18994
|
-
return SubtitleTrackController;
|
18995
18976
|
}(BasePlaylistController);
|
18996
18977
|
|
18997
18978
|
var BufferOperationQueue = /*#__PURE__*/function () {
|
@@ -19062,7 +19043,6 @@
|
|
19062
19043
|
|
19063
19044
|
var VIDEO_CODEC_PROFILE_REPLACE = /(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/;
|
19064
19045
|
var BufferController = /*#__PURE__*/function (_Logger) {
|
19065
|
-
_inheritsLoose(BufferController, _Logger);
|
19066
19046
|
function BufferController(hls, fragmentTracker) {
|
19067
19047
|
var _this;
|
19068
19048
|
_this = _Logger.call(this, 'buffer-controller', hls.logger) || this;
|
@@ -19114,9 +19094,9 @@
|
|
19114
19094
|
};
|
19115
19095
|
// Keep as arrow functions so that we can directly reference these functions directly as event listeners
|
19116
19096
|
_this._onMediaSourceOpen = function () {
|
19117
|
-
var
|
19118
|
-
media =
|
19119
|
-
mediaSource =
|
19097
|
+
var _this2 = _this,
|
19098
|
+
media = _this2.media,
|
19099
|
+
mediaSource = _this2.mediaSource;
|
19120
19100
|
_this.log('Media source opened');
|
19121
19101
|
if (media) {
|
19122
19102
|
media.removeEventListener('emptied', _this._onMediaEmptied);
|
@@ -19142,9 +19122,9 @@
|
|
19142
19122
|
_this.log('Media source ended');
|
19143
19123
|
};
|
19144
19124
|
_this._onMediaEmptied = function () {
|
19145
|
-
var
|
19146
|
-
mediaSrc =
|
19147
|
-
_objectUrl =
|
19125
|
+
var _this3 = _this,
|
19126
|
+
mediaSrc = _this3.mediaSrc,
|
19127
|
+
_objectUrl = _this3._objectUrl;
|
19148
19128
|
if (mediaSrc !== _objectUrl) {
|
19149
19129
|
_this.error("Media element src was set while attaching MediaSource (" + _objectUrl + " > " + mediaSrc + ")");
|
19150
19130
|
}
|
@@ -19156,6 +19136,7 @@
|
|
19156
19136
|
_this.registerListeners();
|
19157
19137
|
return _this;
|
19158
19138
|
}
|
19139
|
+
_inheritsLoose(BufferController, _Logger);
|
19159
19140
|
var _proto = BufferController.prototype;
|
19160
19141
|
_proto.hasSourceTypes = function hasSourceTypes() {
|
19161
19142
|
return this.getSourceBufferTypes().length > 0 || Object.keys(this.pendingTracks).length > 0;
|
@@ -19330,9 +19311,9 @@
|
|
19330
19311
|
this.hls.trigger(Events.MEDIA_DETACHED, undefined);
|
19331
19312
|
};
|
19332
19313
|
_proto.onBufferReset = function onBufferReset() {
|
19333
|
-
var
|
19314
|
+
var _this4 = this;
|
19334
19315
|
this.getSourceBufferTypes().forEach(function (type) {
|
19335
|
-
|
19316
|
+
_this4.resetBuffer(type);
|
19336
19317
|
});
|
19337
19318
|
this._initSourceBuffer();
|
19338
19319
|
this.hls.resumeBuffering();
|
@@ -19355,14 +19336,14 @@
|
|
19355
19336
|
}
|
19356
19337
|
};
|
19357
19338
|
_proto.onBufferCodecs = function onBufferCodecs(event, data) {
|
19358
|
-
var
|
19339
|
+
var _this5 = this;
|
19359
19340
|
var sourceBufferCount = this.getSourceBufferTypes().length;
|
19360
19341
|
var trackNames = Object.keys(data);
|
19361
19342
|
trackNames.forEach(function (trackName) {
|
19362
19343
|
if (sourceBufferCount) {
|
19363
19344
|
var _track$buffer;
|
19364
19345
|
// check if SourceBuffer codec needs to change
|
19365
|
-
var track =
|
19346
|
+
var track = _this5.tracks[trackName];
|
19366
19347
|
if (track && typeof ((_track$buffer = track.buffer) == null ? void 0 : _track$buffer.changeType) === 'function') {
|
19367
19348
|
var _trackCodec;
|
19368
19349
|
var _data$trackName = data[trackName],
|
@@ -19377,12 +19358,12 @@
|
|
19377
19358
|
var nextCodec = (_trackCodec = trackCodec) == null ? void 0 : _trackCodec.replace(VIDEO_CODEC_PROFILE_REPLACE, '$1');
|
19378
19359
|
if (trackCodec && currentCodec !== nextCodec) {
|
19379
19360
|
if (trackName.slice(0, 5) === 'audio') {
|
19380
|
-
trackCodec = getCodecCompatibleName(trackCodec,
|
19361
|
+
trackCodec = getCodecCompatibleName(trackCodec, _this5.appendSource);
|
19381
19362
|
}
|
19382
19363
|
var mimeType = container + ";codecs=" + trackCodec;
|
19383
|
-
|
19384
|
-
|
19385
|
-
|
19364
|
+
_this5.appendChangeType(trackName, mimeType);
|
19365
|
+
_this5.log("switching codec " + currentCodecFull + " to " + trackCodec);
|
19366
|
+
_this5.tracks[trackName] = {
|
19386
19367
|
buffer: track.buffer,
|
19387
19368
|
codec: codec,
|
19388
19369
|
container: container,
|
@@ -19394,7 +19375,7 @@
|
|
19394
19375
|
}
|
19395
19376
|
} else {
|
19396
19377
|
// if source buffer(s) not created yet, appended buffer tracks in this.pendingTracks
|
19397
|
-
|
19378
|
+
_this5.pendingTracks[trackName] = data[trackName];
|
19398
19379
|
}
|
19399
19380
|
});
|
19400
19381
|
|
@@ -19412,13 +19393,13 @@
|
|
19412
19393
|
}
|
19413
19394
|
};
|
19414
19395
|
_proto.appendChangeType = function appendChangeType(type, mimeType) {
|
19415
|
-
var
|
19396
|
+
var _this6 = this;
|
19416
19397
|
var operationQueue = this.operationQueue;
|
19417
19398
|
var operation = {
|
19418
19399
|
execute: function execute() {
|
19419
|
-
var sb =
|
19400
|
+
var sb = _this6.sourceBuffer[type];
|
19420
19401
|
if (sb) {
|
19421
|
-
|
19402
|
+
_this6.log("changing " + type + " sourceBuffer type to " + mimeType);
|
19422
19403
|
sb.changeType(mimeType);
|
19423
19404
|
}
|
19424
19405
|
operationQueue.shiftAndExecuteNext(type);
|
@@ -19426,14 +19407,14 @@
|
|
19426
19407
|
onStart: function onStart() {},
|
19427
19408
|
onComplete: function onComplete() {},
|
19428
19409
|
onError: function onError(error) {
|
19429
|
-
|
19410
|
+
_this6.warn("Failed to change " + type + " SourceBuffer type", error);
|
19430
19411
|
}
|
19431
19412
|
};
|
19432
19413
|
operationQueue.append(operation, type, !!this.pendingTracks[type]);
|
19433
19414
|
};
|
19434
19415
|
_proto.blockAudio = function blockAudio(partOrFrag) {
|
19435
19416
|
var _this$fragmentTracker,
|
19436
|
-
|
19417
|
+
_this7 = this;
|
19437
19418
|
var pStart = partOrFrag.start;
|
19438
19419
|
var pTime = pStart + partOrFrag.duration * 0.05;
|
19439
19420
|
var atGap = ((_this$fragmentTracker = this.fragmentTracker.getAppendedFrag(pStart, PlaylistLevelType.MAIN)) == null ? void 0 : _this$fragmentTracker.gap) === true;
|
@@ -19442,10 +19423,10 @@
|
|
19442
19423
|
}
|
19443
19424
|
var op = {
|
19444
19425
|
execute: function execute() {
|
19445
|
-
var
|
19446
|
-
if (
|
19447
|
-
|
19448
|
-
|
19426
|
+
var _this7$fragmentTracke;
|
19427
|
+
if (_this7.lastVideoAppendEnd > pTime || _this7.sourceBuffer.video && BufferHelper.isBuffered(_this7.sourceBuffer.video, pTime) || ((_this7$fragmentTracke = _this7.fragmentTracker.getAppendedFrag(pTime, PlaylistLevelType.MAIN)) == null ? void 0 : _this7$fragmentTracke.gap) === true) {
|
19428
|
+
_this7.blockedAudioAppend = null;
|
19429
|
+
_this7.operationQueue.shiftAndExecuteNext('audio');
|
19449
19430
|
}
|
19450
19431
|
},
|
19451
19432
|
onStart: function onStart() {},
|
@@ -19466,7 +19447,7 @@
|
|
19466
19447
|
}
|
19467
19448
|
};
|
19468
19449
|
_proto.onBufferAppending = function onBufferAppending(event, eventData) {
|
19469
|
-
var
|
19450
|
+
var _this8 = this;
|
19470
19451
|
var operationQueue = this.operationQueue,
|
19471
19452
|
tracks = this.tracks;
|
19472
19453
|
var data = eventData.data,
|
@@ -19533,16 +19514,16 @@
|
|
19533
19514
|
execute: function execute() {
|
19534
19515
|
chunkStats.executeStart = self.performance.now();
|
19535
19516
|
if (checkTimestampOffset) {
|
19536
|
-
var sb =
|
19517
|
+
var sb = _this8.sourceBuffer[type];
|
19537
19518
|
if (sb) {
|
19538
19519
|
var delta = fragStart - sb.timestampOffset;
|
19539
19520
|
if (Math.abs(delta) >= 0.1) {
|
19540
|
-
|
19521
|
+
_this8.log("Updating audio SourceBuffer timestampOffset to " + fragStart + " (delta: " + delta + ") sn: " + sn + ")");
|
19541
19522
|
sb.timestampOffset = fragStart;
|
19542
19523
|
}
|
19543
19524
|
}
|
19544
19525
|
}
|
19545
|
-
|
19526
|
+
_this8.appendExecutor(data, type);
|
19546
19527
|
},
|
19547
19528
|
onStart: function onStart() {
|
19548
19529
|
// logger.debug(`[buffer-controller]: ${type} SourceBuffer updatestart`);
|
@@ -19557,19 +19538,19 @@
|
|
19557
19538
|
if (partBuffering && partBuffering.first === 0) {
|
19558
19539
|
partBuffering.first = end;
|
19559
19540
|
}
|
19560
|
-
var sourceBuffer =
|
19541
|
+
var sourceBuffer = _this8.sourceBuffer;
|
19561
19542
|
var timeRanges = {};
|
19562
19543
|
for (var _type in sourceBuffer) {
|
19563
19544
|
timeRanges[_type] = BufferHelper.getBuffered(sourceBuffer[_type]);
|
19564
19545
|
}
|
19565
|
-
|
19546
|
+
_this8.appendErrors[type] = 0;
|
19566
19547
|
if (type === 'audio' || type === 'video') {
|
19567
|
-
|
19548
|
+
_this8.appendErrors.audiovideo = 0;
|
19568
19549
|
} else {
|
19569
|
-
|
19570
|
-
|
19550
|
+
_this8.appendErrors.audio = 0;
|
19551
|
+
_this8.appendErrors.video = 0;
|
19571
19552
|
}
|
19572
|
-
|
19553
|
+
_this8.hls.trigger(Events.BUFFER_APPENDED, {
|
19573
19554
|
type: type,
|
19574
19555
|
frag: frag,
|
19575
19556
|
part: part,
|
@@ -19597,43 +19578,43 @@
|
|
19597
19578
|
// let's stop appending any segments, and report BUFFER_FULL_ERROR error
|
19598
19579
|
event.details = ErrorDetails.BUFFER_FULL_ERROR;
|
19599
19580
|
} else {
|
19600
|
-
var appendErrorCount = ++
|
19581
|
+
var appendErrorCount = ++_this8.appendErrors[type];
|
19601
19582
|
event.details = ErrorDetails.BUFFER_APPEND_ERROR;
|
19602
19583
|
/* with UHD content, we could get loop of quota exceeded error until
|
19603
19584
|
browser is able to evict some data from sourcebuffer. Retrying can help recover.
|
19604
19585
|
*/
|
19605
|
-
|
19606
|
-
if (appendErrorCount >=
|
19586
|
+
_this8.warn("Failed " + appendErrorCount + "/" + _this8.hls.config.appendErrorMaxRetry + " times to append segment in \"" + type + "\" sourceBuffer");
|
19587
|
+
if (appendErrorCount >= _this8.hls.config.appendErrorMaxRetry) {
|
19607
19588
|
event.fatal = true;
|
19608
19589
|
}
|
19609
19590
|
}
|
19610
|
-
|
19591
|
+
_this8.hls.trigger(Events.ERROR, event);
|
19611
19592
|
}
|
19612
19593
|
};
|
19613
19594
|
operationQueue.append(operation, type, !!this.pendingTracks[type]);
|
19614
19595
|
};
|
19615
19596
|
_proto.getFlushOp = function getFlushOp(type, start, end) {
|
19616
|
-
var
|
19597
|
+
var _this9 = this;
|
19617
19598
|
return {
|
19618
19599
|
execute: function execute() {
|
19619
|
-
|
19600
|
+
_this9.removeExecutor(type, start, end);
|
19620
19601
|
},
|
19621
19602
|
onStart: function onStart() {
|
19622
19603
|
// logger.debug(`[buffer-controller]: Started flushing ${data.startOffset} -> ${data.endOffset} for ${type} Source Buffer`);
|
19623
19604
|
},
|
19624
19605
|
onComplete: function onComplete() {
|
19625
19606
|
// logger.debug(`[buffer-controller]: Finished flushing ${data.startOffset} -> ${data.endOffset} for ${type} Source Buffer`);
|
19626
|
-
|
19607
|
+
_this9.hls.trigger(Events.BUFFER_FLUSHED, {
|
19627
19608
|
type: type
|
19628
19609
|
});
|
19629
19610
|
},
|
19630
19611
|
onError: function onError(error) {
|
19631
|
-
|
19612
|
+
_this9.warn("Failed to remove from " + type + " SourceBuffer", error);
|
19632
19613
|
}
|
19633
19614
|
};
|
19634
19615
|
};
|
19635
19616
|
_proto.onBufferFlushing = function onBufferFlushing(event, data) {
|
19636
|
-
var
|
19617
|
+
var _this10 = this;
|
19637
19618
|
var operationQueue = this.operationQueue;
|
19638
19619
|
var type = data.type,
|
19639
19620
|
startOffset = data.startOffset,
|
@@ -19642,12 +19623,12 @@
|
|
19642
19623
|
operationQueue.append(this.getFlushOp(type, startOffset, endOffset), type);
|
19643
19624
|
} else {
|
19644
19625
|
this.getSourceBufferTypes().forEach(function (sbType) {
|
19645
|
-
operationQueue.append(
|
19626
|
+
operationQueue.append(_this10.getFlushOp(sbType, startOffset, endOffset), sbType);
|
19646
19627
|
});
|
19647
19628
|
}
|
19648
19629
|
};
|
19649
19630
|
_proto.onFragParsed = function onFragParsed(event, data) {
|
19650
|
-
var
|
19631
|
+
var _this11 = this;
|
19651
19632
|
var frag = data.frag,
|
19652
19633
|
part = data.part;
|
19653
19634
|
var buffersAppendedTo = [];
|
@@ -19669,7 +19650,7 @@
|
|
19669
19650
|
part.stats.buffering.end = now;
|
19670
19651
|
}
|
19671
19652
|
var stats = part ? part.stats : frag.stats;
|
19672
|
-
|
19653
|
+
_this11.hls.trigger(Events.FRAG_BUFFERED, {
|
19673
19654
|
frag: frag,
|
19674
19655
|
part: part,
|
19675
19656
|
stats: stats,
|
@@ -19689,17 +19670,17 @@
|
|
19689
19670
|
// an undefined data.type will mark all buffers as EOS.
|
19690
19671
|
;
|
19691
19672
|
_proto.onBufferEos = function onBufferEos(event, data) {
|
19692
|
-
var
|
19673
|
+
var _this12 = this;
|
19693
19674
|
if (data.type === 'video') {
|
19694
19675
|
this.unblockAudio();
|
19695
19676
|
}
|
19696
19677
|
var ended = this.getSourceBufferTypes().reduce(function (acc, type) {
|
19697
|
-
var sb =
|
19678
|
+
var sb = _this12.sourceBuffer[type];
|
19698
19679
|
if (sb && (!data.type || data.type === type)) {
|
19699
19680
|
sb.ending = true;
|
19700
19681
|
if (!sb.ended) {
|
19701
19682
|
sb.ended = true;
|
19702
|
-
|
19683
|
+
_this12.log(type + " sourceBuffer now EOS");
|
19703
19684
|
}
|
19704
19685
|
}
|
19705
19686
|
return acc && !!(!sb || sb.ended);
|
@@ -19707,27 +19688,27 @@
|
|
19707
19688
|
if (ended) {
|
19708
19689
|
this.log("Queueing mediaSource.endOfStream()");
|
19709
19690
|
this.blockBuffers(function () {
|
19710
|
-
|
19711
|
-
var sb =
|
19691
|
+
_this12.getSourceBufferTypes().forEach(function (type) {
|
19692
|
+
var sb = _this12.sourceBuffer[type];
|
19712
19693
|
if (sb) {
|
19713
19694
|
sb.ending = false;
|
19714
19695
|
}
|
19715
19696
|
});
|
19716
|
-
var mediaSource =
|
19697
|
+
var mediaSource = _this12.mediaSource;
|
19717
19698
|
if (!mediaSource || mediaSource.readyState !== 'open') {
|
19718
19699
|
if (mediaSource) {
|
19719
|
-
|
19700
|
+
_this12.log("Could not call mediaSource.endOfStream(). mediaSource.readyState: " + mediaSource.readyState);
|
19720
19701
|
}
|
19721
19702
|
return;
|
19722
19703
|
}
|
19723
|
-
|
19704
|
+
_this12.log("Calling mediaSource.endOfStream()");
|
19724
19705
|
// Allow this to throw and be caught by the enqueueing function
|
19725
19706
|
mediaSource.endOfStream();
|
19726
19707
|
});
|
19727
19708
|
}
|
19728
19709
|
};
|
19729
19710
|
_proto.onLevelUpdated = function onLevelUpdated(event, _ref) {
|
19730
|
-
var
|
19711
|
+
var _this13 = this;
|
19731
19712
|
var details = _ref.details;
|
19732
19713
|
if (!details.fragments.length) {
|
19733
19714
|
return;
|
@@ -19739,7 +19720,7 @@
|
|
19739
19720
|
}
|
19740
19721
|
if (this.getSourceBufferTypes().length) {
|
19741
19722
|
this.blockBuffers(function () {
|
19742
|
-
return
|
19723
|
+
return _this13.updateMediaSource(durationAndRange);
|
19743
19724
|
});
|
19744
19725
|
} else {
|
19745
19726
|
this.updateMediaSource(durationAndRange);
|
@@ -19775,7 +19756,7 @@
|
|
19775
19756
|
}
|
19776
19757
|
};
|
19777
19758
|
_proto.flushBackBuffer = function flushBackBuffer(currentTime, targetDuration, targetBackBufferPosition) {
|
19778
|
-
var
|
19759
|
+
var _this14 = this;
|
19779
19760
|
var details = this.details,
|
19780
19761
|
sourceBuffer = this.sourceBuffer;
|
19781
19762
|
var sourceBufferTypes = this.getSourceBufferTypes();
|
@@ -19785,20 +19766,20 @@
|
|
19785
19766
|
var buffered = BufferHelper.getBuffered(sb);
|
19786
19767
|
// when target buffer start exceeds actual buffer start
|
19787
19768
|
if (buffered.length > 0 && targetBackBufferPosition > buffered.start(0)) {
|
19788
|
-
|
19769
|
+
_this14.hls.trigger(Events.BACK_BUFFER_REACHED, {
|
19789
19770
|
bufferEnd: targetBackBufferPosition
|
19790
19771
|
});
|
19791
19772
|
|
19792
19773
|
// Support for deprecated event:
|
19793
19774
|
if (details != null && details.live) {
|
19794
|
-
|
19775
|
+
_this14.hls.trigger(Events.LIVE_BACK_BUFFER_REACHED, {
|
19795
19776
|
bufferEnd: targetBackBufferPosition
|
19796
19777
|
});
|
19797
19778
|
} else if (sb.ended && buffered.end(buffered.length - 1) - currentTime < targetDuration * 2) {
|
19798
|
-
|
19779
|
+
_this14.log("Cannot flush " + type + " back buffer while SourceBuffer is in ended state");
|
19799
19780
|
return;
|
19800
19781
|
}
|
19801
|
-
|
19782
|
+
_this14.hls.trigger(Events.BUFFER_FLUSHING, {
|
19802
19783
|
startOffset: 0,
|
19803
19784
|
endOffset: targetBackBufferPosition,
|
19804
19785
|
type: type
|
@@ -19808,7 +19789,7 @@
|
|
19808
19789
|
});
|
19809
19790
|
};
|
19810
19791
|
_proto.flushFrontBuffer = function flushFrontBuffer(currentTime, targetDuration, targetFrontBufferPosition) {
|
19811
|
-
var
|
19792
|
+
var _this15 = this;
|
19812
19793
|
var sourceBuffer = this.sourceBuffer;
|
19813
19794
|
var sourceBufferTypes = this.getSourceBufferTypes();
|
19814
19795
|
sourceBufferTypes.forEach(function (type) {
|
@@ -19826,10 +19807,10 @@
|
|
19826
19807
|
if (targetFrontBufferPosition > bufferStart || currentTime >= bufferStart && currentTime <= bufferEnd) {
|
19827
19808
|
return;
|
19828
19809
|
} else if (sb.ended && currentTime - bufferEnd < 2 * targetDuration) {
|
19829
|
-
|
19810
|
+
_this15.log("Cannot flush " + type + " front buffer while SourceBuffer is in ended state");
|
19830
19811
|
return;
|
19831
19812
|
}
|
19832
|
-
|
19813
|
+
_this15.hls.trigger(Events.BUFFER_FLUSHING, {
|
19833
19814
|
startOffset: bufferStart,
|
19834
19815
|
endOffset: Infinity,
|
19835
19816
|
type: type
|
@@ -19929,7 +19910,7 @@
|
|
19929
19910
|
}
|
19930
19911
|
};
|
19931
19912
|
_proto.createSourceBuffers = function createSourceBuffers(tracks) {
|
19932
|
-
var
|
19913
|
+
var _this16 = this;
|
19933
19914
|
var sourceBuffer = this.sourceBuffer,
|
19934
19915
|
mediaSource = this.mediaSource;
|
19935
19916
|
if (!mediaSource) {
|
@@ -19945,30 +19926,30 @@
|
|
19945
19926
|
var codec = track.levelCodec || track.codec;
|
19946
19927
|
if (codec) {
|
19947
19928
|
if (trackName.slice(0, 5) === 'audio') {
|
19948
|
-
codec = getCodecCompatibleName(codec,
|
19929
|
+
codec = getCodecCompatibleName(codec, _this16.appendSource);
|
19949
19930
|
}
|
19950
19931
|
}
|
19951
19932
|
var mimeType = track.container + ";codecs=" + codec;
|
19952
|
-
|
19933
|
+
_this16.log("creating sourceBuffer(" + mimeType + ")");
|
19953
19934
|
try {
|
19954
19935
|
var sb = sourceBuffer[trackName] = mediaSource.addSourceBuffer(mimeType);
|
19955
19936
|
var sbName = trackName;
|
19956
|
-
|
19957
|
-
|
19958
|
-
|
19937
|
+
_this16.addBufferListener(sbName, 'updatestart', _this16._onSBUpdateStart);
|
19938
|
+
_this16.addBufferListener(sbName, 'updateend', _this16._onSBUpdateEnd);
|
19939
|
+
_this16.addBufferListener(sbName, 'error', _this16._onSBUpdateError);
|
19959
19940
|
// ManagedSourceBuffer bufferedchange event
|
19960
|
-
if (
|
19961
|
-
|
19941
|
+
if (_this16.appendSource) {
|
19942
|
+
_this16.addBufferListener(sbName, 'bufferedchange', function (type, event) {
|
19962
19943
|
// If media was ejected check for a change. Added ranges are redundant with changes on 'updateend' event.
|
19963
19944
|
var removedRanges = event.removedRanges;
|
19964
19945
|
if (removedRanges != null && removedRanges.length) {
|
19965
|
-
|
19946
|
+
_this16.hls.trigger(Events.BUFFER_FLUSHED, {
|
19966
19947
|
type: trackName
|
19967
19948
|
});
|
19968
19949
|
}
|
19969
19950
|
});
|
19970
19951
|
}
|
19971
|
-
|
19952
|
+
_this16.tracks[trackName] = {
|
19972
19953
|
buffer: sb,
|
19973
19954
|
codec: codec,
|
19974
19955
|
container: track.container,
|
@@ -19977,8 +19958,8 @@
|
|
19977
19958
|
id: track.id
|
19978
19959
|
};
|
19979
19960
|
} catch (err) {
|
19980
|
-
|
19981
|
-
|
19961
|
+
_this16.error("error while trying to add sourceBuffer: " + err.message);
|
19962
|
+
_this16.hls.trigger(Events.ERROR, {
|
19982
19963
|
type: ErrorTypes.MEDIA_ERROR,
|
19983
19964
|
details: ErrorDetails.BUFFER_ADD_CODEC_ERROR,
|
19984
19965
|
fatal: false,
|
@@ -20076,7 +20057,7 @@
|
|
20076
20057
|
// upon completion, since we already do it here
|
20077
20058
|
;
|
20078
20059
|
_proto.blockBuffers = function blockBuffers(onUnblocked, buffers) {
|
20079
|
-
var
|
20060
|
+
var _this17 = this;
|
20080
20061
|
if (buffers === void 0) {
|
20081
20062
|
buffers = this.getSourceBufferTypes();
|
20082
20063
|
}
|
@@ -20099,7 +20080,7 @@
|
|
20099
20080
|
// logger.debug(`[buffer-controller]: Blocking operation resolved; unblocking ${buffers} SourceBuffer`);
|
20100
20081
|
onUnblocked();
|
20101
20082
|
buffers.forEach(function (type, i) {
|
20102
|
-
var sb =
|
20083
|
+
var sb = _this17.sourceBuffer[type];
|
20103
20084
|
// Only cycle the queue if the SB is not updating. There's a bug in Chrome which sets the SB updating flag to
|
20104
20085
|
// true when changing the MediaSource duration (https://bugs.chromium.org/p/chromium/issues/detail?id=959359&can=2&q=mediasource%20duration)
|
20105
20086
|
// While this is a workaround, it's probably useful to have around
|
@@ -20133,7 +20114,7 @@
|
|
20133
20114
|
buffer.removeEventListener(l.event, l.listener);
|
20134
20115
|
});
|
20135
20116
|
};
|
20136
|
-
_createClass(BufferController, [{
|
20117
|
+
return _createClass(BufferController, [{
|
20137
20118
|
key: "mediaSrc",
|
20138
20119
|
get: function get() {
|
20139
20120
|
var _this$media;
|
@@ -20141,7 +20122,6 @@
|
|
20141
20122
|
return media == null ? void 0 : media.src;
|
20142
20123
|
}
|
20143
20124
|
}]);
|
20144
|
-
return BufferController;
|
20145
20125
|
}(Logger);
|
20146
20126
|
function removeSourceChildren(node) {
|
20147
20127
|
var sourceChildren = node.querySelectorAll('source');
|
@@ -23352,7 +23332,7 @@
|
|
23352
23332
|
}
|
23353
23333
|
return maxLevelIndex;
|
23354
23334
|
};
|
23355
|
-
_createClass(CapLevelController, [{
|
23335
|
+
return _createClass(CapLevelController, [{
|
23356
23336
|
key: "mediaWidth",
|
23357
23337
|
get: function get() {
|
23358
23338
|
return this.getDimensions().width * this.contentScaleFactor;
|
@@ -23376,7 +23356,6 @@
|
|
23376
23356
|
return pixelRatio;
|
23377
23357
|
}
|
23378
23358
|
}]);
|
23379
|
-
return CapLevelController;
|
23380
23359
|
}();
|
23381
23360
|
|
23382
23361
|
var FPSController = /*#__PURE__*/function () {
|
@@ -23487,7 +23466,6 @@
|
|
23487
23466
|
* @constructor
|
23488
23467
|
*/
|
23489
23468
|
var EMEController = /*#__PURE__*/function (_Logger) {
|
23490
|
-
_inheritsLoose(EMEController, _Logger);
|
23491
23469
|
function EMEController(hls) {
|
23492
23470
|
var _this;
|
23493
23471
|
_this = _Logger.call(this, 'eme', hls.logger) || this;
|
@@ -23541,9 +23519,9 @@
|
|
23541
23519
|
return;
|
23542
23520
|
}
|
23543
23521
|
var keyIdHex = Hex.hexDump(keyId);
|
23544
|
-
var
|
23545
|
-
keyIdToKeySessionPromise =
|
23546
|
-
mediaKeySessions =
|
23522
|
+
var _this2 = _this,
|
23523
|
+
keyIdToKeySessionPromise = _this2.keyIdToKeySessionPromise,
|
23524
|
+
mediaKeySessions = _this2.mediaKeySessions;
|
23547
23525
|
var keySessionContextPromise = keyIdToKeySessionPromise[keyIdHex];
|
23548
23526
|
var _loop = function _loop() {
|
23549
23527
|
// Match playlist key
|
@@ -23603,6 +23581,7 @@
|
|
23603
23581
|
_this.registerListeners();
|
23604
23582
|
return _this;
|
23605
23583
|
}
|
23584
|
+
_inheritsLoose(EMEController, _Logger);
|
23606
23585
|
var _proto = EMEController.prototype;
|
23607
23586
|
_proto.destroy = function destroy() {
|
23608
23587
|
this.unregisterListeners();
|
@@ -23654,7 +23633,7 @@
|
|
23654
23633
|
}
|
23655
23634
|
};
|
23656
23635
|
_proto.attemptKeySystemAccess = function attemptKeySystemAccess(keySystemsToAttempt) {
|
23657
|
-
var
|
23636
|
+
var _this3 = this;
|
23658
23637
|
var levels = this.hls.levels;
|
23659
23638
|
var uniqueCodec = function uniqueCodec(value, i, a) {
|
23660
23639
|
return !!value && a.indexOf(value) === i;
|
@@ -23671,7 +23650,7 @@
|
|
23671
23650
|
return new Promise(function (resolve, reject) {
|
23672
23651
|
var attempt = function attempt(keySystems) {
|
23673
23652
|
var keySystem = keySystems.shift();
|
23674
|
-
|
23653
|
+
_this3.getMediaKeysPromise(keySystem, audioCodecs, videoCodecs).then(function (mediaKeys) {
|
23675
23654
|
return resolve({
|
23676
23655
|
keySystem: keySystem,
|
23677
23656
|
mediaKeys: mediaKeys
|
@@ -23706,7 +23685,7 @@
|
|
23706
23685
|
return requestMediaKeySystemAccessFunc(keySystem, supportedConfigurations);
|
23707
23686
|
};
|
23708
23687
|
_proto.getMediaKeysPromise = function getMediaKeysPromise(keySystem, audioCodecs, videoCodecs) {
|
23709
|
-
var
|
23688
|
+
var _this4 = this;
|
23710
23689
|
// This can throw, but is caught in event handler callpath
|
23711
23690
|
var mediaKeySystemConfigs = getSupportedMediaKeySystemConfigurations(keySystem, audioCodecs, videoCodecs, this.config.drmSystemOptions);
|
23712
23691
|
var keySystemAccessPromises = this.keySystemAccessPromises[keySystem];
|
@@ -23718,23 +23697,23 @@
|
|
23718
23697
|
keySystemAccess: keySystemAccess
|
23719
23698
|
};
|
23720
23699
|
keySystemAccess.catch(function (error) {
|
23721
|
-
|
23700
|
+
_this4.log("Failed to obtain access to key-system \"" + keySystem + "\": " + error);
|
23722
23701
|
});
|
23723
23702
|
return keySystemAccess.then(function (mediaKeySystemAccess) {
|
23724
|
-
|
23725
|
-
var certificateRequest =
|
23726
|
-
|
23703
|
+
_this4.log("Access for key-system \"" + mediaKeySystemAccess.keySystem + "\" obtained");
|
23704
|
+
var certificateRequest = _this4.fetchServerCertificate(keySystem);
|
23705
|
+
_this4.log("Create media-keys for \"" + keySystem + "\"");
|
23727
23706
|
_keySystemAccessPromises.mediaKeys = mediaKeySystemAccess.createMediaKeys().then(function (mediaKeys) {
|
23728
|
-
|
23707
|
+
_this4.log("Media-keys created for \"" + keySystem + "\"");
|
23729
23708
|
return certificateRequest.then(function (certificate) {
|
23730
23709
|
if (certificate) {
|
23731
|
-
return
|
23710
|
+
return _this4.setMediaKeysServerCertificate(mediaKeys, keySystem, certificate);
|
23732
23711
|
}
|
23733
23712
|
return mediaKeys;
|
23734
23713
|
});
|
23735
23714
|
});
|
23736
23715
|
_keySystemAccessPromises.mediaKeys.catch(function (error) {
|
23737
|
-
|
23716
|
+
_this4.error("Failed to create media-keys for \"" + keySystem + "\"}: " + error);
|
23738
23717
|
});
|
23739
23718
|
return _keySystemAccessPromises.mediaKeys;
|
23740
23719
|
});
|
@@ -23795,13 +23774,13 @@
|
|
23795
23774
|
return this.keyFormatPromise;
|
23796
23775
|
};
|
23797
23776
|
_proto.getKeyFormatPromise = function getKeyFormatPromise(keyFormats) {
|
23798
|
-
var
|
23777
|
+
var _this5 = this;
|
23799
23778
|
return new Promise(function (resolve, reject) {
|
23800
|
-
var keySystemsInConfig = getKeySystemsForConfig(
|
23779
|
+
var keySystemsInConfig = getKeySystemsForConfig(_this5.config);
|
23801
23780
|
var keySystemsToAttempt = keyFormats.map(keySystemFormatToKeySystemDomain).filter(function (value) {
|
23802
23781
|
return !!value && keySystemsInConfig.indexOf(value) !== -1;
|
23803
23782
|
});
|
23804
|
-
return
|
23783
|
+
return _this5.getKeySystemSelectionPromise(keySystemsToAttempt).then(function (_ref3) {
|
23805
23784
|
var keySystem = _ref3.keySystem;
|
23806
23785
|
var keySystemFormat = keySystemDomainToKeySystemFormat(keySystem);
|
23807
23786
|
if (keySystemFormat) {
|
@@ -23813,7 +23792,7 @@
|
|
23813
23792
|
});
|
23814
23793
|
};
|
23815
23794
|
_proto.loadKey = function loadKey(data) {
|
23816
|
-
var
|
23795
|
+
var _this6 = this;
|
23817
23796
|
var decryptdata = data.keyInfo.decryptdata;
|
23818
23797
|
var keyId = this.getKeyIdString(decryptdata);
|
23819
23798
|
var keyDetails = "(keyId: " + keyId + " format: \"" + decryptdata.keyFormat + "\" method: " + decryptdata.method + " uri: " + decryptdata.uri + ")";
|
@@ -23823,21 +23802,21 @@
|
|
23823
23802
|
keySessionContextPromise = this.keyIdToKeySessionPromise[keyId] = this.getKeySystemForKeyPromise(decryptdata).then(function (_ref4) {
|
23824
23803
|
var keySystem = _ref4.keySystem,
|
23825
23804
|
mediaKeys = _ref4.mediaKeys;
|
23826
|
-
|
23827
|
-
|
23828
|
-
return
|
23829
|
-
|
23830
|
-
var keySessionContext =
|
23805
|
+
_this6.throwIfDestroyed();
|
23806
|
+
_this6.log("Handle encrypted media sn: " + data.frag.sn + " " + data.frag.type + ": " + data.frag.level + " using key " + keyDetails);
|
23807
|
+
return _this6.attemptSetMediaKeys(keySystem, mediaKeys).then(function () {
|
23808
|
+
_this6.throwIfDestroyed();
|
23809
|
+
var keySessionContext = _this6.createMediaKeySessionContext({
|
23831
23810
|
keySystem: keySystem,
|
23832
23811
|
mediaKeys: mediaKeys,
|
23833
23812
|
decryptdata: decryptdata
|
23834
23813
|
});
|
23835
23814
|
var scheme = 'cenc';
|
23836
|
-
return
|
23815
|
+
return _this6.generateRequestWithPreferredKeySession(keySessionContext, scheme, decryptdata.pssh, 'playlist-key');
|
23837
23816
|
});
|
23838
23817
|
});
|
23839
23818
|
keySessionContextPromise.catch(function (error) {
|
23840
|
-
return
|
23819
|
+
return _this6.handleError(error);
|
23841
23820
|
});
|
23842
23821
|
}
|
23843
23822
|
return keySessionContextPromise;
|
@@ -23889,22 +23868,22 @@
|
|
23889
23868
|
return this.attemptKeySystemAccess(keySystemsToAttempt);
|
23890
23869
|
};
|
23891
23870
|
_proto.attemptSetMediaKeys = function attemptSetMediaKeys(keySystem, mediaKeys) {
|
23892
|
-
var
|
23871
|
+
var _this7 = this;
|
23893
23872
|
var queue = this.setMediaKeysQueue.slice();
|
23894
23873
|
this.log("Setting media-keys for \"" + keySystem + "\"");
|
23895
23874
|
// Only one setMediaKeys() can run at one time, and multiple setMediaKeys() operations
|
23896
23875
|
// can be queued for execution for multiple key sessions.
|
23897
23876
|
var setMediaKeysPromise = Promise.all(queue).then(function () {
|
23898
|
-
if (!
|
23877
|
+
if (!_this7.media) {
|
23899
23878
|
throw new Error('Attempted to set mediaKeys without media element attached');
|
23900
23879
|
}
|
23901
|
-
return
|
23880
|
+
return _this7.media.setMediaKeys(mediaKeys);
|
23902
23881
|
});
|
23903
23882
|
this.setMediaKeysQueue.push(setMediaKeysPromise);
|
23904
23883
|
return setMediaKeysPromise.then(function () {
|
23905
|
-
|
23884
|
+
_this7.log("Media-keys set for \"" + keySystem + "\"");
|
23906
23885
|
queue.push(setMediaKeysPromise);
|
23907
|
-
|
23886
|
+
_this7.setMediaKeysQueue = _this7.setMediaKeysQueue.filter(function (p) {
|
23908
23887
|
return queue.indexOf(p) === -1;
|
23909
23888
|
});
|
23910
23889
|
});
|
@@ -23912,7 +23891,7 @@
|
|
23912
23891
|
_proto.generateRequestWithPreferredKeySession = function generateRequestWithPreferredKeySession(context, initDataType, initData, reason) {
|
23913
23892
|
var _this$config$drmSyste,
|
23914
23893
|
_this$config$drmSyste2,
|
23915
|
-
|
23894
|
+
_this8 = this;
|
23916
23895
|
var generateRequestFilter = (_this$config$drmSyste = this.config.drmSystems) == null ? void 0 : (_this$config$drmSyste2 = _this$config$drmSyste[context.keySystem]) == null ? void 0 : _this$config$drmSyste2.generateRequest;
|
23917
23896
|
if (generateRequestFilter) {
|
23918
23897
|
try {
|
@@ -23945,19 +23924,19 @@
|
|
23945
23924
|
}
|
23946
23925
|
var messageType = event.messageType,
|
23947
23926
|
message = event.message;
|
23948
|
-
|
23927
|
+
_this8.log("\"" + messageType + "\" message event for session \"" + keySession.sessionId + "\" message size: " + message.byteLength);
|
23949
23928
|
if (messageType === 'license-request' || messageType === 'license-renewal') {
|
23950
|
-
|
23951
|
-
|
23929
|
+
_this8.renewLicense(context, message).catch(function (error) {
|
23930
|
+
_this8.handleError(error);
|
23952
23931
|
licenseStatus.emit('error', error);
|
23953
23932
|
});
|
23954
23933
|
} else if (messageType === 'license-release') {
|
23955
23934
|
if (context.keySystem === KeySystems.FAIRPLAY) {
|
23956
|
-
|
23957
|
-
|
23935
|
+
_this8.updateKeySession(context, strToUtf8array('acknowledged'));
|
23936
|
+
_this8.removeSession(context);
|
23958
23937
|
}
|
23959
23938
|
} else {
|
23960
|
-
|
23939
|
+
_this8.warn("unhandled media key message type \"" + messageType + "\"");
|
23961
23940
|
}
|
23962
23941
|
};
|
23963
23942
|
var onkeystatuseschange = context._onkeystatuseschange = function (event) {
|
@@ -23966,12 +23945,12 @@
|
|
23966
23945
|
licenseStatus.emit('error', new Error('invalid state'));
|
23967
23946
|
return;
|
23968
23947
|
}
|
23969
|
-
|
23948
|
+
_this8.onKeyStatusChange(context);
|
23970
23949
|
var keyStatus = context.keyStatus;
|
23971
23950
|
licenseStatus.emit('keyStatus', keyStatus);
|
23972
23951
|
if (keyStatus === 'expired') {
|
23973
|
-
|
23974
|
-
|
23952
|
+
_this8.warn(context.keySystem + " expired for key " + keyId);
|
23953
|
+
_this8.renewKeySession(context);
|
23975
23954
|
}
|
23976
23955
|
};
|
23977
23956
|
context.mediaKeysSession.addEventListener('message', onmessage);
|
@@ -23996,13 +23975,13 @@
|
|
23996
23975
|
} else if (keyStatus === 'expired') {
|
23997
23976
|
reject(new Error('key expired while generating request'));
|
23998
23977
|
} else {
|
23999
|
-
|
23978
|
+
_this8.warn("unhandled key status change \"" + keyStatus + "\"");
|
24000
23979
|
}
|
24001
23980
|
});
|
24002
23981
|
});
|
24003
23982
|
return context.mediaKeysSession.generateRequest(initDataType, initData).then(function () {
|
24004
23983
|
var _context$mediaKeysSes;
|
24005
|
-
|
23984
|
+
_this8.log("Request generated for key-session \"" + ((_context$mediaKeysSes = context.mediaKeysSession) == null ? void 0 : _context$mediaKeysSes.sessionId) + "\" keyId: " + keyId);
|
24006
23985
|
}).catch(function (error) {
|
24007
23986
|
throw new EMEKeyError({
|
24008
23987
|
type: ErrorTypes.KEY_SYSTEM_ERROR,
|
@@ -24014,7 +23993,7 @@
|
|
24014
23993
|
return keyUsablePromise;
|
24015
23994
|
}).catch(function (error) {
|
24016
23995
|
licenseStatus.removeAllListeners();
|
24017
|
-
|
23996
|
+
_this8.removeSession(context);
|
24018
23997
|
throw error;
|
24019
23998
|
}).then(function () {
|
24020
23999
|
licenseStatus.removeAllListeners();
|
@@ -24022,9 +24001,9 @@
|
|
24022
24001
|
});
|
24023
24002
|
};
|
24024
24003
|
_proto.onKeyStatusChange = function onKeyStatusChange(mediaKeySessionContext) {
|
24025
|
-
var
|
24004
|
+
var _this9 = this;
|
24026
24005
|
mediaKeySessionContext.mediaKeysSession.keyStatuses.forEach(function (status, keyId) {
|
24027
|
-
|
24006
|
+
_this9.log("key status change \"" + status + "\" for keyStatuses keyId: " + Hex.hexDump('buffer' in keyId ? new Uint8Array(keyId.buffer, keyId.byteOffset, keyId.byteLength) : new Uint8Array(keyId)) + " session keyId: " + Hex.hexDump(new Uint8Array(mediaKeySessionContext.decryptdata.keyId || [])) + " uri: " + mediaKeySessionContext.decryptdata.uri);
|
24028
24007
|
mediaKeySessionContext.keyStatus = status;
|
24029
24008
|
});
|
24030
24009
|
};
|
@@ -24086,10 +24065,10 @@
|
|
24086
24065
|
});
|
24087
24066
|
};
|
24088
24067
|
_proto.setMediaKeysServerCertificate = function setMediaKeysServerCertificate(mediaKeys, keySystem, cert) {
|
24089
|
-
var
|
24068
|
+
var _this10 = this;
|
24090
24069
|
return new Promise(function (resolve, reject) {
|
24091
24070
|
mediaKeys.setServerCertificate(cert).then(function (success) {
|
24092
|
-
|
24071
|
+
_this10.log("setServerCertificate " + (success ? 'success' : 'not supported by CDM') + " (" + (cert == null ? void 0 : cert.byteLength) + ") on \"" + keySystem + "\"");
|
24093
24072
|
resolve(mediaKeys);
|
24094
24073
|
}).catch(function (error) {
|
24095
24074
|
reject(new EMEKeyError({
|
@@ -24102,9 +24081,9 @@
|
|
24102
24081
|
});
|
24103
24082
|
};
|
24104
24083
|
_proto.renewLicense = function renewLicense(context, keyMessage) {
|
24105
|
-
var
|
24084
|
+
var _this11 = this;
|
24106
24085
|
return this.requestLicense(context, new Uint8Array(keyMessage)).then(function (data) {
|
24107
|
-
return
|
24086
|
+
return _this11.updateKeySession(context, new Uint8Array(data)).catch(function (error) {
|
24108
24087
|
throw new EMEKeyError({
|
24109
24088
|
type: ErrorTypes.KEY_SYSTEM_ERROR,
|
24110
24089
|
details: ErrorDetails.KEY_SYSTEM_SESSION_UPDATE_FAILED,
|
@@ -24152,7 +24131,7 @@
|
|
24152
24131
|
return strToUtf8array(atob(challengeText));
|
24153
24132
|
};
|
24154
24133
|
_proto.setupLicenseXHR = function setupLicenseXHR(xhr, url, keysListItem, licenseChallenge) {
|
24155
|
-
var
|
24134
|
+
var _this12 = this;
|
24156
24135
|
var licenseXhrSetup = this.config.licenseXhrSetup;
|
24157
24136
|
if (!licenseXhrSetup) {
|
24158
24137
|
xhr.open('POST', url, true);
|
@@ -24165,7 +24144,7 @@
|
|
24165
24144
|
if (!keysListItem.decryptdata) {
|
24166
24145
|
throw new Error('Key removed');
|
24167
24146
|
}
|
24168
|
-
return licenseXhrSetup.call(
|
24147
|
+
return licenseXhrSetup.call(_this12.hls, xhr, url, keysListItem, licenseChallenge);
|
24169
24148
|
}).catch(function (error) {
|
24170
24149
|
if (!keysListItem.decryptdata) {
|
24171
24150
|
// Key session removed. Cancel license request.
|
@@ -24173,7 +24152,7 @@
|
|
24173
24152
|
}
|
24174
24153
|
// let's try to open before running setup
|
24175
24154
|
xhr.open('POST', url, true);
|
24176
|
-
return licenseXhrSetup.call(
|
24155
|
+
return licenseXhrSetup.call(_this12.hls, xhr, url, keysListItem, licenseChallenge);
|
24177
24156
|
}).then(function (licenseXhrSetupResult) {
|
24178
24157
|
// if licenseXhrSetup did not yet call open, let's do it now
|
24179
24158
|
if (!xhr.readyState) {
|
@@ -24187,36 +24166,36 @@
|
|
24187
24166
|
});
|
24188
24167
|
};
|
24189
24168
|
_proto.requestLicense = function requestLicense(keySessionContext, licenseChallenge) {
|
24190
|
-
var
|
24169
|
+
var _this13 = this;
|
24191
24170
|
var keyLoadPolicy = this.config.keyLoadPolicy.default;
|
24192
24171
|
return new Promise(function (resolve, reject) {
|
24193
|
-
var url =
|
24194
|
-
|
24172
|
+
var url = _this13.getLicenseServerUrl(keySessionContext.keySystem);
|
24173
|
+
_this13.log("Sending license request to URL: " + url);
|
24195
24174
|
var xhr = new XMLHttpRequest();
|
24196
24175
|
xhr.responseType = 'arraybuffer';
|
24197
24176
|
xhr.onreadystatechange = function () {
|
24198
|
-
if (!
|
24177
|
+
if (!_this13.hls || !keySessionContext.mediaKeysSession) {
|
24199
24178
|
return reject(new Error('invalid state'));
|
24200
24179
|
}
|
24201
24180
|
if (xhr.readyState === 4) {
|
24202
24181
|
if (xhr.status === 200) {
|
24203
|
-
|
24182
|
+
_this13._requestLicenseFailureCount = 0;
|
24204
24183
|
var data = xhr.response;
|
24205
|
-
|
24206
|
-
var licenseResponseCallback =
|
24184
|
+
_this13.log("License received " + (data instanceof ArrayBuffer ? data.byteLength : data));
|
24185
|
+
var licenseResponseCallback = _this13.config.licenseResponseCallback;
|
24207
24186
|
if (licenseResponseCallback) {
|
24208
24187
|
try {
|
24209
|
-
data = licenseResponseCallback.call(
|
24188
|
+
data = licenseResponseCallback.call(_this13.hls, xhr, url, keySessionContext);
|
24210
24189
|
} catch (error) {
|
24211
|
-
|
24190
|
+
_this13.error(error);
|
24212
24191
|
}
|
24213
24192
|
}
|
24214
24193
|
resolve(data);
|
24215
24194
|
} else {
|
24216
24195
|
var retryConfig = keyLoadPolicy.errorRetry;
|
24217
24196
|
var maxNumRetry = retryConfig ? retryConfig.maxNumRetry : 0;
|
24218
|
-
|
24219
|
-
if (
|
24197
|
+
_this13._requestLicenseFailureCount++;
|
24198
|
+
if (_this13._requestLicenseFailureCount > maxNumRetry || xhr.status >= 400 && xhr.status < 500) {
|
24220
24199
|
reject(new EMEKeyError({
|
24221
24200
|
type: ErrorTypes.KEY_SYSTEM_ERROR,
|
24222
24201
|
details: ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,
|
@@ -24230,9 +24209,9 @@
|
|
24230
24209
|
}
|
24231
24210
|
}, "License Request XHR failed (" + url + "). Status: " + xhr.status + " (" + xhr.statusText + ")"));
|
24232
24211
|
} else {
|
24233
|
-
var attemptsLeft = maxNumRetry -
|
24234
|
-
|
24235
|
-
|
24212
|
+
var attemptsLeft = maxNumRetry - _this13._requestLicenseFailureCount + 1;
|
24213
|
+
_this13.warn("Retrying license request, " + attemptsLeft + " attempts left");
|
24214
|
+
_this13.requestLicense(keySessionContext, licenseChallenge).then(resolve, reject);
|
24236
24215
|
}
|
24237
24216
|
}
|
24238
24217
|
}
|
@@ -24241,11 +24220,11 @@
|
|
24241
24220
|
keySessionContext.licenseXhr.abort();
|
24242
24221
|
}
|
24243
24222
|
keySessionContext.licenseXhr = xhr;
|
24244
|
-
|
24223
|
+
_this13.setupLicenseXHR(xhr, url, keySessionContext, licenseChallenge).then(function (_ref5) {
|
24245
24224
|
var xhr = _ref5.xhr,
|
24246
24225
|
licenseChallenge = _ref5.licenseChallenge;
|
24247
24226
|
if (keySessionContext.keySystem == KeySystems.PLAYREADY) {
|
24248
|
-
licenseChallenge =
|
24227
|
+
licenseChallenge = _this13.unpackPlayReadyKeyMessage(xhr, licenseChallenge);
|
24249
24228
|
}
|
24250
24229
|
xhr.send(licenseChallenge);
|
24251
24230
|
});
|
@@ -24263,7 +24242,7 @@
|
|
24263
24242
|
media.addEventListener('waitingforkey', this.onWaitingForKey);
|
24264
24243
|
};
|
24265
24244
|
_proto.onMediaDetached = function onMediaDetached() {
|
24266
|
-
var
|
24245
|
+
var _this14 = this;
|
24267
24246
|
var media = this.media;
|
24268
24247
|
var mediaKeysList = this.mediaKeySessions;
|
24269
24248
|
if (media) {
|
@@ -24280,16 +24259,16 @@
|
|
24280
24259
|
// Close all sessions and remove media keys from the video element.
|
24281
24260
|
var keySessionCount = mediaKeysList.length;
|
24282
24261
|
EMEController.CDMCleanupPromise = Promise.all(mediaKeysList.map(function (mediaKeySessionContext) {
|
24283
|
-
return
|
24262
|
+
return _this14.removeSession(mediaKeySessionContext);
|
24284
24263
|
}).concat(media == null ? void 0 : media.setMediaKeys(null).catch(function (error) {
|
24285
|
-
|
24264
|
+
_this14.log("Could not clear media keys: " + error);
|
24286
24265
|
}))).then(function () {
|
24287
24266
|
if (keySessionCount) {
|
24288
|
-
|
24267
|
+
_this14.log('finished closing key sessions and clearing media keys');
|
24289
24268
|
mediaKeysList.length = 0;
|
24290
24269
|
}
|
24291
24270
|
}).catch(function (error) {
|
24292
|
-
|
24271
|
+
_this14.log("Could not close sessions and clear media keys: " + error);
|
24293
24272
|
});
|
24294
24273
|
};
|
24295
24274
|
_proto.onManifestLoading = function onManifestLoading() {
|
@@ -24312,7 +24291,7 @@
|
|
24312
24291
|
}
|
24313
24292
|
};
|
24314
24293
|
_proto.removeSession = function removeSession(mediaKeySessionContext) {
|
24315
|
-
var
|
24294
|
+
var _this15 = this;
|
24316
24295
|
var mediaKeysSession = mediaKeySessionContext.mediaKeysSession,
|
24317
24296
|
licenseXhr = mediaKeySessionContext.licenseXhr;
|
24318
24297
|
if (mediaKeysSession) {
|
@@ -24334,11 +24313,11 @@
|
|
24334
24313
|
this.mediaKeySessions.splice(index, 1);
|
24335
24314
|
}
|
24336
24315
|
return mediaKeysSession.remove().catch(function (error) {
|
24337
|
-
|
24316
|
+
_this15.log("Could not remove session: " + error);
|
24338
24317
|
}).then(function () {
|
24339
24318
|
return mediaKeysSession.close();
|
24340
24319
|
}).catch(function (error) {
|
24341
|
-
|
24320
|
+
_this15.log("Could not close session: " + error);
|
24342
24321
|
});
|
24343
24322
|
}
|
24344
24323
|
};
|
@@ -24346,16 +24325,16 @@
|
|
24346
24325
|
}(Logger);
|
24347
24326
|
EMEController.CDMCleanupPromise = void 0;
|
24348
24327
|
var EMEKeyError = /*#__PURE__*/function (_Error) {
|
24349
|
-
_inheritsLoose(EMEKeyError, _Error);
|
24350
24328
|
function EMEKeyError(data, message) {
|
24351
|
-
var
|
24352
|
-
|
24353
|
-
|
24329
|
+
var _this16;
|
24330
|
+
_this16 = _Error.call(this, message) || this;
|
24331
|
+
_this16.data = void 0;
|
24354
24332
|
data.error || (data.error = new Error(message));
|
24355
|
-
|
24333
|
+
_this16.data = data;
|
24356
24334
|
data.err = data.error;
|
24357
|
-
return
|
24335
|
+
return _this16;
|
24358
24336
|
}
|
24337
|
+
_inheritsLoose(EMEKeyError, _Error);
|
24359
24338
|
return EMEKeyError;
|
24360
24339
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
24361
24340
|
|
@@ -25643,7 +25622,7 @@
|
|
25643
25622
|
apply(context);
|
25644
25623
|
this.loader.load(context, config, callbacks);
|
25645
25624
|
};
|
25646
|
-
_createClass(CmcdPlaylistLoader, [{
|
25625
|
+
return _createClass(CmcdPlaylistLoader, [{
|
25647
25626
|
key: "stats",
|
25648
25627
|
get: function get() {
|
25649
25628
|
return this.loader.stats;
|
@@ -25654,7 +25633,6 @@
|
|
25654
25633
|
return this.loader.context;
|
25655
25634
|
}
|
25656
25635
|
}]);
|
25657
|
-
return CmcdPlaylistLoader;
|
25658
25636
|
}();
|
25659
25637
|
}
|
25660
25638
|
|
@@ -25681,7 +25659,7 @@
|
|
25681
25659
|
apply(context);
|
25682
25660
|
this.loader.load(context, config, callbacks);
|
25683
25661
|
};
|
25684
|
-
_createClass(CmcdFragmentLoader, [{
|
25662
|
+
return _createClass(CmcdFragmentLoader, [{
|
25685
25663
|
key: "stats",
|
25686
25664
|
get: function get() {
|
25687
25665
|
return this.loader.stats;
|
@@ -25692,7 +25670,6 @@
|
|
25692
25670
|
return this.loader.context;
|
25693
25671
|
}
|
25694
25672
|
}]);
|
25695
|
-
return CmcdFragmentLoader;
|
25696
25673
|
}();
|
25697
25674
|
};
|
25698
25675
|
return CMCDController;
|
@@ -25700,7 +25677,6 @@
|
|
25700
25677
|
|
25701
25678
|
var PATHWAY_PENALTY_DURATION_MS = 300000;
|
25702
25679
|
var ContentSteeringController = /*#__PURE__*/function (_Logger) {
|
25703
|
-
_inheritsLoose(ContentSteeringController, _Logger);
|
25704
25680
|
function ContentSteeringController(hls) {
|
25705
25681
|
var _this;
|
25706
25682
|
_this = _Logger.call(this, 'content-steering', hls.logger) || this;
|
@@ -25722,6 +25698,7 @@
|
|
25722
25698
|
_this.registerListeners();
|
25723
25699
|
return _this;
|
25724
25700
|
}
|
25701
|
+
_inheritsLoose(ContentSteeringController, _Logger);
|
25725
25702
|
var _proto = ContentSteeringController.prototype;
|
25726
25703
|
_proto.registerListeners = function registerListeners() {
|
25727
25704
|
var hls = this.hls;
|
@@ -26609,7 +26586,6 @@
|
|
26609
26586
|
return new self.Request(context.url, initParams);
|
26610
26587
|
}
|
26611
26588
|
var FetchError = /*#__PURE__*/function (_Error) {
|
26612
|
-
_inheritsLoose(FetchError, _Error);
|
26613
26589
|
function FetchError(message, code, details) {
|
26614
26590
|
var _this2;
|
26615
26591
|
_this2 = _Error.call(this, message) || this;
|
@@ -26619,6 +26595,7 @@
|
|
26619
26595
|
_this2.details = details;
|
26620
26596
|
return _this2;
|
26621
26597
|
}
|
26598
|
+
_inheritsLoose(FetchError, _Error);
|
26622
26599
|
return FetchError;
|
26623
26600
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
26624
26601
|
|
@@ -27082,7 +27059,6 @@
|
|
27082
27059
|
}
|
27083
27060
|
|
27084
27061
|
var LevelController = /*#__PURE__*/function (_BasePlaylistControll) {
|
27085
|
-
_inheritsLoose(LevelController, _BasePlaylistControll);
|
27086
27062
|
function LevelController(hls, contentSteeringController) {
|
27087
27063
|
var _this;
|
27088
27064
|
_this = _BasePlaylistControll.call(this, hls, 'level-controller') || this;
|
@@ -27099,6 +27075,7 @@
|
|
27099
27075
|
_this._registerListeners();
|
27100
27076
|
return _this;
|
27101
27077
|
}
|
27078
|
+
_inheritsLoose(LevelController, _BasePlaylistControll);
|
27102
27079
|
var _proto = LevelController.prototype;
|
27103
27080
|
_proto._registerListeners = function _registerListeners() {
|
27104
27081
|
var hls = this.hls;
|
@@ -27482,7 +27459,7 @@
|
|
27482
27459
|
});
|
27483
27460
|
}
|
27484
27461
|
};
|
27485
|
-
_createClass(LevelController, [{
|
27462
|
+
return _createClass(LevelController, [{
|
27486
27463
|
key: "levels",
|
27487
27464
|
get: function get() {
|
27488
27465
|
if (this._levels.length === 0) {
|
@@ -27618,7 +27595,6 @@
|
|
27618
27595
|
}
|
27619
27596
|
}
|
27620
27597
|
}]);
|
27621
|
-
return LevelController;
|
27622
27598
|
}(BasePlaylistController);
|
27623
27599
|
function assignTrackIdsByGroup(tracks) {
|
27624
27600
|
var groups = {};
|
@@ -27915,7 +27891,6 @@
|
|
27915
27891
|
var SKIP_BUFFER_HOLE_STEP_SECONDS = 0.1;
|
27916
27892
|
var SKIP_BUFFER_RANGE_START = 0.05;
|
27917
27893
|
var GapController = /*#__PURE__*/function (_Logger) {
|
27918
|
-
_inheritsLoose(GapController, _Logger);
|
27919
27894
|
function GapController(config, media, fragmentTracker, hls) {
|
27920
27895
|
var _this;
|
27921
27896
|
_this = _Logger.call(this, 'gap-controller', hls.logger) || this;
|
@@ -27935,6 +27910,7 @@
|
|
27935
27910
|
_this.hls = hls;
|
27936
27911
|
return _this;
|
27937
27912
|
}
|
27913
|
+
_inheritsLoose(GapController, _Logger);
|
27938
27914
|
var _proto = GapController.prototype;
|
27939
27915
|
_proto.destroy = function destroy() {
|
27940
27916
|
this.media = null;
|
@@ -28239,7 +28215,6 @@
|
|
28239
28215
|
|
28240
28216
|
var TICK_INTERVAL = 100; // how often to tick in ms
|
28241
28217
|
var StreamController = /*#__PURE__*/function (_BaseStreamController) {
|
28242
|
-
_inheritsLoose(StreamController, _BaseStreamController);
|
28243
28218
|
function StreamController(hls, fragmentTracker, keyLoader) {
|
28244
28219
|
var _this;
|
28245
28220
|
_this = _BaseStreamController.call(this, hls, fragmentTracker, keyLoader, 'stream-controller', PlaylistLevelType.MAIN) || this;
|
@@ -28279,6 +28254,7 @@
|
|
28279
28254
|
_this.registerListeners();
|
28280
28255
|
return _this;
|
28281
28256
|
}
|
28257
|
+
_inheritsLoose(StreamController, _BaseStreamController);
|
28282
28258
|
var _proto = StreamController.prototype;
|
28283
28259
|
_proto.registerListeners = function registerListeners() {
|
28284
28260
|
_BaseStreamController.prototype.registerListeners.call(this);
|
@@ -29294,7 +29270,7 @@
|
|
29294
29270
|
}
|
29295
29271
|
}
|
29296
29272
|
};
|
29297
|
-
_createClass(StreamController, [{
|
29273
|
+
return _createClass(StreamController, [{
|
29298
29274
|
key: "maxBufferLength",
|
29299
29275
|
get: function get() {
|
29300
29276
|
var levels = this.levels,
|
@@ -29361,7 +29337,6 @@
|
|
29361
29337
|
return this._forceStartLoad;
|
29362
29338
|
}
|
29363
29339
|
}]);
|
29364
|
-
return StreamController;
|
29365
29340
|
}(BaseStreamController);
|
29366
29341
|
|
29367
29342
|
/**
|
@@ -29369,26 +29344,6 @@
|
|
29369
29344
|
* @public
|
29370
29345
|
*/
|
29371
29346
|
var Hls = /*#__PURE__*/function () {
|
29372
|
-
/**
|
29373
|
-
* Check if the required MediaSource Extensions are available.
|
29374
|
-
*/
|
29375
|
-
Hls.isMSESupported = function isMSESupported$1() {
|
29376
|
-
return isMSESupported();
|
29377
|
-
}
|
29378
|
-
|
29379
|
-
/**
|
29380
|
-
* Check if MediaSource Extensions are available and isTypeSupported checks pass for any baseline codecs.
|
29381
|
-
*/;
|
29382
|
-
Hls.isSupported = function isSupported$1() {
|
29383
|
-
return isSupported();
|
29384
|
-
}
|
29385
|
-
|
29386
|
-
/**
|
29387
|
-
* Get the MediaSource global used for MSE playback (ManagedMediaSource, MediaSource, or WebKitMediaSource).
|
29388
|
-
*/;
|
29389
|
-
Hls.getMediaSource = function getMediaSource$1() {
|
29390
|
-
return getMediaSource();
|
29391
|
-
};
|
29392
29347
|
/**
|
29393
29348
|
* Creates an instance of an HLS client that can attach to exactly one `HTMLMediaElement`.
|
29394
29349
|
* @param userConfig - Configuration options applied over `Hls.DefaultConfig`
|
@@ -29491,6 +29446,26 @@
|
|
29491
29446
|
this.on(Events.ERROR, onErrorOut, errorController);
|
29492
29447
|
}
|
29493
29448
|
}
|
29449
|
+
/**
|
29450
|
+
* Check if the required MediaSource Extensions are available.
|
29451
|
+
*/
|
29452
|
+
Hls.isMSESupported = function isMSESupported$1() {
|
29453
|
+
return isMSESupported();
|
29454
|
+
}
|
29455
|
+
|
29456
|
+
/**
|
29457
|
+
* Check if MediaSource Extensions are available and isTypeSupported checks pass for any baseline codecs.
|
29458
|
+
*/;
|
29459
|
+
Hls.isSupported = function isSupported$1() {
|
29460
|
+
return isSupported();
|
29461
|
+
}
|
29462
|
+
|
29463
|
+
/**
|
29464
|
+
* Get the MediaSource global used for MSE playback (ManagedMediaSource, MediaSource, or WebKitMediaSource).
|
29465
|
+
*/;
|
29466
|
+
Hls.getMediaSource = function getMediaSource$1() {
|
29467
|
+
return getMediaSource();
|
29468
|
+
};
|
29494
29469
|
var _proto = Hls.prototype;
|
29495
29470
|
_proto.createController = function createController(ControllerClass, components) {
|
29496
29471
|
if (ControllerClass) {
|
@@ -29729,7 +29704,7 @@
|
|
29729
29704
|
/**
|
29730
29705
|
* Get the complete list of audio tracks across all media groups
|
29731
29706
|
*/;
|
29732
|
-
_createClass(Hls, [{
|
29707
|
+
return _createClass(Hls, [{
|
29733
29708
|
key: "levels",
|
29734
29709
|
get: function get() {
|
29735
29710
|
var levels = this.levelController.levels;
|
@@ -30236,7 +30211,7 @@
|
|
30236
30211
|
* Get the video-dev/hls.js package version.
|
30237
30212
|
*/
|
30238
30213
|
function get() {
|
30239
|
-
return "1.5.8-0.canary.
|
30214
|
+
return "1.5.8-0.canary.10119";
|
30240
30215
|
}
|
30241
30216
|
}, {
|
30242
30217
|
key: "Events",
|
@@ -30273,7 +30248,6 @@
|
|
30273
30248
|
Hls.defaultConfig = defaultConfig;
|
30274
30249
|
}
|
30275
30250
|
}]);
|
30276
|
-
return Hls;
|
30277
30251
|
}();
|
30278
30252
|
Hls.defaultConfig = void 0;
|
30279
30253
|
|