hls.js 1.6.0-beta.1.0.canary.10788 → 1.6.0-beta.1.0.canary.10791
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.d.mts +10 -6
- package/dist/hls.d.ts +10 -6
- package/dist/hls.js +135 -144
- package/dist/hls.js.d.ts +10 -6
- package/dist/hls.js.map +1 -1
- package/dist/hls.light.js +94 -83
- 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 +91 -80
- package/dist/hls.light.mjs.map +1 -1
- package/dist/hls.min.js +1 -1
- package/dist/hls.min.js.map +1 -1
- package/dist/hls.mjs +132 -141
- package/dist/hls.mjs.map +1 -1
- package/dist/hls.worker.js +1 -1
- package/package.json +2 -2
- package/src/controller/audio-track-controller.ts +32 -46
- package/src/controller/base-playlist-controller.ts +97 -77
- package/src/controller/base-stream-controller.ts +1 -1
- package/src/controller/level-controller.ts +31 -46
- package/src/controller/subtitle-track-controller.ts +28 -39
- package/src/loader/level-details.ts +1 -0
- package/src/utils/level-helper.ts +3 -0
package/dist/hls.light.js
CHANGED
@@ -1028,7 +1028,7 @@
|
|
1028
1028
|
// Some browsers don't allow to use bind on console object anyway
|
1029
1029
|
// fallback to default if needed
|
1030
1030
|
try {
|
1031
|
-
newLogger.log("Debug logs enabled for \"" + context + "\" in hls.js version " + "1.6.0-beta.1.0.canary.
|
1031
|
+
newLogger.log("Debug logs enabled for \"" + context + "\" in hls.js version " + "1.6.0-beta.1.0.canary.10791");
|
1032
1032
|
} catch (e) {
|
1033
1033
|
/* log fn threw an exception. All logger methods are no-ops. */
|
1034
1034
|
return createLogger();
|
@@ -5778,6 +5778,7 @@
|
|
5778
5778
|
this.dateRanges = void 0;
|
5779
5779
|
this.dateRangeTagCount = 0;
|
5780
5780
|
this.live = true;
|
5781
|
+
this.requestScheduled = -1;
|
5781
5782
|
this.ageHeader = 0;
|
5782
5783
|
this.advancedDateTime = void 0;
|
5783
5784
|
this.updated = true;
|
@@ -8110,6 +8111,9 @@
|
|
8110
8111
|
newDetails.driftEnd = oldDetails.driftEnd;
|
8111
8112
|
newDetails.advancedDateTime = oldDetails.advancedDateTime;
|
8112
8113
|
}
|
8114
|
+
if (newDetails.requestScheduled === -1) {
|
8115
|
+
newDetails.requestScheduled = oldDetails.requestScheduled;
|
8116
|
+
}
|
8113
8117
|
}
|
8114
8118
|
function mergeDateRanges(oldDateRanges, newDetails) {
|
8115
8119
|
var deltaDateRanges = newDetails.dateRanges,
|
@@ -16326,7 +16330,6 @@
|
|
16326
16330
|
_this = _Logger.call(this, logPrefix, hls.logger) || this;
|
16327
16331
|
_this.hls = void 0;
|
16328
16332
|
_this.timer = -1;
|
16329
|
-
_this.requestScheduled = -1;
|
16330
16333
|
_this.canLoad = false;
|
16331
16334
|
_this.hls = hls;
|
16332
16335
|
return _this;
|
@@ -16346,7 +16349,6 @@
|
|
16346
16349
|
};
|
16347
16350
|
_proto.startLoad = function startLoad() {
|
16348
16351
|
this.canLoad = true;
|
16349
|
-
this.requestScheduled = -1;
|
16350
16352
|
this.loadPlaylist();
|
16351
16353
|
};
|
16352
16354
|
_proto.stopLoad = function stopLoad() {
|
@@ -16391,19 +16393,27 @@
|
|
16391
16393
|
}
|
16392
16394
|
};
|
16393
16395
|
_proto.loadPlaylist = function loadPlaylist(hlsUrlParameters) {
|
16394
|
-
if (this.requestScheduled === -1) {
|
16395
|
-
this.requestScheduled = self.performance.now();
|
16396
|
-
}
|
16397
16396
|
// Loading is handled by the subclasses
|
16397
|
+
this.clearTimer();
|
16398
|
+
};
|
16399
|
+
_proto.loadingPlaylist = function loadingPlaylist(playlist, hlsUrlParameters) {
|
16400
|
+
// Loading is handled by the subclasses
|
16401
|
+
this.clearTimer();
|
16398
16402
|
};
|
16399
16403
|
_proto.shouldLoadPlaylist = function shouldLoadPlaylist(playlist) {
|
16400
16404
|
return this.canLoad && !!playlist && !!playlist.url && (!playlist.details || playlist.details.live);
|
16401
16405
|
};
|
16402
|
-
_proto.
|
16403
|
-
|
16406
|
+
_proto.getUrlWithDirectives = function getUrlWithDirectives(uri, hlsUrlParameters) {
|
16407
|
+
if (hlsUrlParameters) {
|
16408
|
+
try {
|
16409
|
+
return hlsUrlParameters.addDirectives(uri);
|
16410
|
+
} catch (error) {
|
16411
|
+
this.warn("Could not construct new URL with HLS Delivery Directives: " + error);
|
16412
|
+
}
|
16413
|
+
}
|
16414
|
+
return uri;
|
16404
16415
|
};
|
16405
16416
|
_proto.playlistLoaded = function playlistLoaded(index, data, previousDetails) {
|
16406
|
-
var _this2 = this;
|
16407
16417
|
var details = data.details,
|
16408
16418
|
stats = data.stats;
|
16409
16419
|
|
@@ -16424,10 +16434,9 @@
|
|
16424
16434
|
|
16425
16435
|
// if current playlist is a live playlist, arm a timer to reload it
|
16426
16436
|
if (details.live || previousDetails != null && previousDetails.live) {
|
16437
|
+
var levelOrTrack = 'levelInfo' in data ? data.levelInfo : data.track;
|
16427
16438
|
details.reloaded(previousDetails);
|
16428
|
-
|
16429
|
-
this.log("live playlist " + index + " " + (details.advanced ? 'REFRESHED ' + details.lastPartSn + '-' + details.lastPartIndex : details.updated ? 'UPDATED' : 'MISSED'));
|
16430
|
-
}
|
16439
|
+
this.log("live playlist " + index + " " + (details.advanced ? 'REFRESHED ' + details.lastPartSn + '-' + details.lastPartIndex : details.updated ? 'UPDATED' : 'MISSED'));
|
16431
16440
|
// Merge live playlists to adjust fragment starts and fill in delta playlist skipped segments
|
16432
16441
|
if (previousDetails && details.fragments.length > 0) {
|
16433
16442
|
mergeDetails(previousDetails, details);
|
@@ -16483,52 +16492,67 @@
|
|
16483
16492
|
}
|
16484
16493
|
deliveryDirectives = this.getDeliveryDirectives(details, data.deliveryDirectives, msn, part);
|
16485
16494
|
if (lowLatencyMode || !lastPart) {
|
16486
|
-
this.
|
16495
|
+
this.loadingPlaylist(levelOrTrack, deliveryDirectives);
|
16487
16496
|
return;
|
16488
16497
|
}
|
16489
16498
|
} else if (details.canBlockReload || details.canSkipUntil) {
|
16490
16499
|
deliveryDirectives = this.getDeliveryDirectives(details, data.deliveryDirectives, msn, part);
|
16491
16500
|
}
|
16501
|
+
if (details.requestScheduled === -1) {
|
16502
|
+
details.requestScheduled = stats.loading.start;
|
16503
|
+
}
|
16504
|
+
if (deliveryDirectives && msn !== undefined && details.canBlockReload) {
|
16505
|
+
details.requestScheduled -= details.partTarget * 1000 || 1000;
|
16506
|
+
}
|
16492
16507
|
var bufferInfo = this.hls.mainForwardBufferInfo;
|
16493
16508
|
var position = bufferInfo ? bufferInfo.end - bufferInfo.len : 0;
|
16494
16509
|
var distanceToLiveEdgeMs = (details.edge - position) * 1000;
|
16495
16510
|
var reloadInterval = computeReloadInterval(details, distanceToLiveEdgeMs);
|
16496
|
-
if (details.
|
16497
|
-
|
16498
|
-
}
|
16499
|
-
|
16500
|
-
|
16501
|
-
|
16502
|
-
this.requestScheduled = now;
|
16503
|
-
} else if (this.requestScheduled - now <= 0) {
|
16504
|
-
this.requestScheduled += reloadInterval;
|
16505
|
-
}
|
16506
|
-
var estimatedTimeUntilUpdate = this.requestScheduled - now;
|
16507
|
-
estimatedTimeUntilUpdate = Math.max(0, estimatedTimeUntilUpdate);
|
16508
|
-
this.log("reload live playlist " + index + " in " + Math.round(estimatedTimeUntilUpdate) + " ms");
|
16509
|
-
// this.log(
|
16510
|
-
// `live reload ${details.updated ? 'REFRESHED' : 'MISSED'}
|
16511
|
-
// reload in ${estimatedTimeUntilUpdate / 1000}
|
16512
|
-
// round trip ${(stats.loading.end - stats.loading.start) / 1000}
|
16513
|
-
// diff ${
|
16514
|
-
// (reloadInterval -
|
16515
|
-
// (estimatedTimeUntilUpdate +
|
16516
|
-
// stats.loading.end -
|
16517
|
-
// stats.loading.start)) /
|
16518
|
-
// 1000
|
16519
|
-
// }
|
16520
|
-
// reload interval ${reloadInterval / 1000}
|
16521
|
-
// target duration ${details.targetduration}
|
16522
|
-
// distance to edge ${distanceToLiveEdgeMs / 1000}`
|
16523
|
-
// );
|
16524
|
-
|
16525
|
-
this.timer = self.setTimeout(function () {
|
16526
|
-
return _this2.loadPlaylist(deliveryDirectives);
|
16527
|
-
}, estimatedTimeUntilUpdate);
|
16511
|
+
if (details.requestScheduled + reloadInterval < now) {
|
16512
|
+
details.requestScheduled = now;
|
16513
|
+
} else {
|
16514
|
+
details.requestScheduled += reloadInterval;
|
16515
|
+
}
|
16516
|
+
this.scheduleLoading(levelOrTrack, deliveryDirectives);
|
16528
16517
|
} else {
|
16529
16518
|
this.clearTimer();
|
16530
16519
|
}
|
16531
16520
|
};
|
16521
|
+
_proto.scheduleLoading = function scheduleLoading(levelOrTrack, deliveryDirectives) {
|
16522
|
+
var _this2 = this;
|
16523
|
+
var details = levelOrTrack.details;
|
16524
|
+
if (!details) {
|
16525
|
+
this.loadingPlaylist(levelOrTrack, deliveryDirectives);
|
16526
|
+
return;
|
16527
|
+
}
|
16528
|
+
var now = self.performance.now();
|
16529
|
+
var requestScheduled = details.requestScheduled;
|
16530
|
+
if (now >= requestScheduled) {
|
16531
|
+
this.loadingPlaylist(levelOrTrack, deliveryDirectives);
|
16532
|
+
return;
|
16533
|
+
}
|
16534
|
+
var estimatedTimeUntilUpdate = requestScheduled - now;
|
16535
|
+
this.log("reload live playlist " + (levelOrTrack.name || levelOrTrack.bitrate + 'bps') + " in " + Math.round(estimatedTimeUntilUpdate) + " ms");
|
16536
|
+
// this.log(
|
16537
|
+
// `live reload ${details.updated ? 'REFRESHED' : 'MISSED'}
|
16538
|
+
// reload in ${estimatedTimeUntilUpdate / 1000}
|
16539
|
+
// round trip ${(stats.loading.end - stats.loading.start) / 1000}
|
16540
|
+
// diff ${
|
16541
|
+
// (reloadInterval -
|
16542
|
+
// (estimatedTimeUntilUpdate +
|
16543
|
+
// stats.loading.end -
|
16544
|
+
// stats.loading.start)) /
|
16545
|
+
// 1000
|
16546
|
+
// }
|
16547
|
+
// reload interval ${reloadInterval / 1000}
|
16548
|
+
// target duration ${details.targetduration}
|
16549
|
+
// distance to edge ${distanceToLiveEdgeMs / 1000}`
|
16550
|
+
// );
|
16551
|
+
|
16552
|
+
this.timer = self.setTimeout(function () {
|
16553
|
+
return _this2.loadingPlaylist(levelOrTrack, deliveryDirectives);
|
16554
|
+
}, estimatedTimeUntilUpdate);
|
16555
|
+
};
|
16532
16556
|
_proto.getDeliveryDirectives = function getDeliveryDirectives(details, previousDeliveryDirectives, msn, part) {
|
16533
16557
|
var skip = getSkipValue(details);
|
16534
16558
|
if (previousDeliveryDirectives != null && previousDeliveryDirectives.skip && details.deltaUpdateFailed) {
|
@@ -16551,7 +16575,6 @@
|
|
16551
16575
|
var retry = !!errorAction && !!retryConfig && (action === NetworkErrorAction.RetryRequest || !errorAction.resolved && action === NetworkErrorAction.SendAlternateToPenaltyBox);
|
16552
16576
|
if (retry) {
|
16553
16577
|
var _errorEvent$context;
|
16554
|
-
this.requestScheduled = -1;
|
16555
16578
|
if (retryCount >= retryConfig.maxNumRetry) {
|
16556
16579
|
return false;
|
16557
16580
|
}
|
@@ -16874,10 +16897,7 @@
|
|
16874
16897
|
return;
|
16875
16898
|
}
|
16876
16899
|
if (data.context.type === PlaylistContextType.LEVEL && data.context.level === this.level) {
|
16877
|
-
|
16878
|
-
if (!retry) {
|
16879
|
-
this.requestScheduled = -1;
|
16880
|
-
}
|
16900
|
+
this.checkRetry(data);
|
16881
16901
|
}
|
16882
16902
|
}
|
16883
16903
|
|
@@ -16932,36 +16952,28 @@
|
|
16932
16952
|
};
|
16933
16953
|
_proto.loadPlaylist = function loadPlaylist(hlsUrlParameters) {
|
16934
16954
|
_BasePlaylistControll.prototype.loadPlaylist.call(this);
|
16935
|
-
|
16936
|
-
|
16937
|
-
if (currentLevel && this.shouldLoadPlaylist(currentLevel)) {
|
16938
|
-
var url = currentLevel.uri;
|
16939
|
-
if (hlsUrlParameters) {
|
16940
|
-
try {
|
16941
|
-
url = hlsUrlParameters.addDirectives(url);
|
16942
|
-
} catch (error) {
|
16943
|
-
this.warn("Could not construct new URL with HLS Delivery Directives: " + error);
|
16944
|
-
}
|
16945
|
-
}
|
16946
|
-
var pathwayId = currentLevel.attrs['PATHWAY-ID'];
|
16947
|
-
var details = currentLevel.details;
|
16948
|
-
var age = details == null ? void 0 : details.age;
|
16949
|
-
this.log("Loading level index " + currentLevelIndex + ((hlsUrlParameters == null ? void 0 : hlsUrlParameters.msn) !== undefined ? ' at sn ' + hlsUrlParameters.msn + ' part ' + hlsUrlParameters.part : '') + (pathwayId ? ' Pathway ' + pathwayId : '') + (age && details.live ? ' age ' + age.toFixed(1) + (details.type ? ' ' + details.type || '' : '') : '') + " " + url);
|
16950
|
-
|
16951
|
-
// console.log('Current audio track group ID:', this.hls.audioTracks[this.hls.audioTrack].groupId);
|
16952
|
-
// console.log('New video quality level audio group id:', levelObject.attrs.AUDIO, level);
|
16953
|
-
this.clearTimer();
|
16954
|
-
this.hls.trigger(Events.LEVEL_LOADING, {
|
16955
|
-
url: url,
|
16956
|
-
level: currentLevelIndex,
|
16957
|
-
levelInfo: currentLevel,
|
16958
|
-
pathwayId: currentLevel.attrs['PATHWAY-ID'],
|
16959
|
-
id: 0,
|
16960
|
-
// Deprecated Level urlId
|
16961
|
-
deliveryDirectives: hlsUrlParameters || null
|
16962
|
-
});
|
16955
|
+
if (this.shouldLoadPlaylist(this.currentLevel)) {
|
16956
|
+
this.scheduleLoading(this.currentLevel, hlsUrlParameters);
|
16963
16957
|
}
|
16964
16958
|
};
|
16959
|
+
_proto.loadingPlaylist = function loadingPlaylist(currentLevel, hlsUrlParameters) {
|
16960
|
+
_BasePlaylistControll.prototype.loadingPlaylist.call(this, currentLevel, hlsUrlParameters);
|
16961
|
+
var url = this.getUrlWithDirectives(currentLevel.uri, hlsUrlParameters);
|
16962
|
+
var currentLevelIndex = this.currentLevelIndex;
|
16963
|
+
var pathwayId = currentLevel.attrs['PATHWAY-ID'];
|
16964
|
+
var details = currentLevel.details;
|
16965
|
+
var age = details == null ? void 0 : details.age;
|
16966
|
+
this.log("Loading level index " + currentLevelIndex + ((hlsUrlParameters == null ? void 0 : hlsUrlParameters.msn) !== undefined ? ' at sn ' + hlsUrlParameters.msn + ' part ' + hlsUrlParameters.part : '') + (pathwayId ? ' Pathway ' + pathwayId : '') + (age && details.live ? ' age ' + age.toFixed(1) + (details.type ? ' ' + details.type || '' : '') : '') + " " + url);
|
16967
|
+
this.hls.trigger(Events.LEVEL_LOADING, {
|
16968
|
+
url: url,
|
16969
|
+
level: currentLevelIndex,
|
16970
|
+
levelInfo: currentLevel,
|
16971
|
+
pathwayId: currentLevel.attrs['PATHWAY-ID'],
|
16972
|
+
id: 0,
|
16973
|
+
// Deprecated Level urlId
|
16974
|
+
deliveryDirectives: hlsUrlParameters || null
|
16975
|
+
});
|
16976
|
+
};
|
16965
16977
|
_proto.removeLevel = function removeLevel(levelIndex) {
|
16966
16978
|
var _this4 = this,
|
16967
16979
|
_this$currentLevel;
|
@@ -17056,9 +17068,7 @@
|
|
17056
17068
|
this.currentLevelIndex = newLevel;
|
17057
17069
|
this.currentLevel = level;
|
17058
17070
|
if (lastLevelIndex === newLevel && lastLevel && lastPathwayId === pathwayId) {
|
17059
|
-
|
17060
|
-
return;
|
17061
|
-
}
|
17071
|
+
return;
|
17062
17072
|
}
|
17063
17073
|
this.log("Switching to level " + newLevel + " (" + (level.height ? level.height + 'p ' : '') + (level.videoRange ? level.videoRange + ' ' : '') + (level.codecSet ? level.codecSet + ' ' : '') + "@" + level.bitrate + ")" + (pathwayId ? ' with Pathway ' + pathwayId : '') + " from level " + lastLevelIndex + (lastPathwayId ? ' with Pathway ' + lastPathwayId : ''));
|
17064
17074
|
var levelSwitchingData = {
|
@@ -18936,10 +18946,11 @@
|
|
18936
18946
|
this.nextLoadPosition = startPosition;
|
18937
18947
|
};
|
18938
18948
|
_proto.getLoadPosition = function getLoadPosition() {
|
18949
|
+
var _this$hls;
|
18939
18950
|
var media = this.media;
|
18940
18951
|
// if we have not yet loaded any fragment, start loading from start position
|
18941
18952
|
var pos = 0;
|
18942
|
-
if (this.hls.hasEnoughToStart && media) {
|
18953
|
+
if ((_this$hls = this.hls) != null && _this$hls.hasEnoughToStart && media) {
|
18943
18954
|
pos = media.currentTime;
|
18944
18955
|
} else if (this.nextLoadPosition >= 0) {
|
18945
18956
|
pos = this.nextLoadPosition;
|
@@ -19733,7 +19744,7 @@
|
|
19733
19744
|
return !remuxResult.audio && !remuxResult.video && !remuxResult.text && !remuxResult.id3 && !remuxResult.initSegment;
|
19734
19745
|
}
|
19735
19746
|
|
19736
|
-
var version = "1.6.0-beta.1.0.canary.
|
19747
|
+
var version = "1.6.0-beta.1.0.canary.10791";
|
19737
19748
|
|
19738
19749
|
// ensure the worker ends up in the bundle
|
19739
19750
|
// If the worker should not be included this gets aliased to empty.js
|