hls.js 1.6.0-beta.1.0.canary.10787 → 1.6.0-beta.1.0.canary.10789
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 +141 -148
- package/dist/hls.js.d.ts +10 -6
- package/dist/hls.js.map +1 -1
- package/dist/hls.light.js +100 -87
- 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 +97 -84
- 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 +138 -145
- package/dist/hls.mjs.map +1 -1
- package/dist/hls.worker.js +1 -1
- package/package.json +1 -1
- 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 +9 -7
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.10789");
|
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,
|
@@ -8181,12 +8185,14 @@
|
|
8181
8185
|
var sliding = 0;
|
8182
8186
|
if (advancedOrStable && delta < oldFragments.length) {
|
8183
8187
|
sliding = oldFragments[delta].start;
|
8188
|
+
} else if (advancedOrStable && newDetails.startSN === oldDetails.endSN + 1) {
|
8189
|
+
sliding = oldDetails.fragmentEnd;
|
8184
8190
|
} else if (advancedOrStable && matchingStableVariantOrRendition) {
|
8185
|
-
// align
|
8186
|
-
sliding = oldDetails.
|
8187
|
-
} else if (!newDetails.skippedSegments && newDetails.
|
8191
|
+
// align with expected position (updated playlist start sequence is past end sequence of last update)
|
8192
|
+
sliding = oldDetails.fragmentStart + delta * newDetails.levelTargetDuration;
|
8193
|
+
} else if (!newDetails.skippedSegments && newDetails.fragmentStart === 0) {
|
8188
8194
|
// align new start with old (playlist switch has a sequence with no overlap and should not be used for alignment)
|
8189
|
-
sliding = oldDetails.
|
8195
|
+
sliding = oldDetails.fragmentStart;
|
8190
8196
|
} else {
|
8191
8197
|
// new details already has a sliding offset or has skipped segments
|
8192
8198
|
return;
|
@@ -16324,7 +16330,6 @@
|
|
16324
16330
|
_this = _Logger.call(this, logPrefix, hls.logger) || this;
|
16325
16331
|
_this.hls = void 0;
|
16326
16332
|
_this.timer = -1;
|
16327
|
-
_this.requestScheduled = -1;
|
16328
16333
|
_this.canLoad = false;
|
16329
16334
|
_this.hls = hls;
|
16330
16335
|
return _this;
|
@@ -16344,7 +16349,6 @@
|
|
16344
16349
|
};
|
16345
16350
|
_proto.startLoad = function startLoad() {
|
16346
16351
|
this.canLoad = true;
|
16347
|
-
this.requestScheduled = -1;
|
16348
16352
|
this.loadPlaylist();
|
16349
16353
|
};
|
16350
16354
|
_proto.stopLoad = function stopLoad() {
|
@@ -16389,19 +16393,27 @@
|
|
16389
16393
|
}
|
16390
16394
|
};
|
16391
16395
|
_proto.loadPlaylist = function loadPlaylist(hlsUrlParameters) {
|
16392
|
-
if (this.requestScheduled === -1) {
|
16393
|
-
this.requestScheduled = self.performance.now();
|
16394
|
-
}
|
16395
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();
|
16396
16402
|
};
|
16397
16403
|
_proto.shouldLoadPlaylist = function shouldLoadPlaylist(playlist) {
|
16398
16404
|
return this.canLoad && !!playlist && !!playlist.url && (!playlist.details || playlist.details.live);
|
16399
16405
|
};
|
16400
|
-
_proto.
|
16401
|
-
|
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;
|
16402
16415
|
};
|
16403
16416
|
_proto.playlistLoaded = function playlistLoaded(index, data, previousDetails) {
|
16404
|
-
var _this2 = this;
|
16405
16417
|
var details = data.details,
|
16406
16418
|
stats = data.stats;
|
16407
16419
|
|
@@ -16422,10 +16434,9 @@
|
|
16422
16434
|
|
16423
16435
|
// if current playlist is a live playlist, arm a timer to reload it
|
16424
16436
|
if (details.live || previousDetails != null && previousDetails.live) {
|
16437
|
+
var levelOrTrack = 'levelInfo' in data ? data.levelInfo : data.track;
|
16425
16438
|
details.reloaded(previousDetails);
|
16426
|
-
|
16427
|
-
this.log("live playlist " + index + " " + (details.advanced ? 'REFRESHED ' + details.lastPartSn + '-' + details.lastPartIndex : details.updated ? 'UPDATED' : 'MISSED'));
|
16428
|
-
}
|
16439
|
+
this.log("live playlist " + index + " " + (details.advanced ? 'REFRESHED ' + details.lastPartSn + '-' + details.lastPartIndex : details.updated ? 'UPDATED' : 'MISSED'));
|
16429
16440
|
// Merge live playlists to adjust fragment starts and fill in delta playlist skipped segments
|
16430
16441
|
if (previousDetails && details.fragments.length > 0) {
|
16431
16442
|
mergeDetails(previousDetails, details);
|
@@ -16481,52 +16492,67 @@
|
|
16481
16492
|
}
|
16482
16493
|
deliveryDirectives = this.getDeliveryDirectives(details, data.deliveryDirectives, msn, part);
|
16483
16494
|
if (lowLatencyMode || !lastPart) {
|
16484
|
-
this.
|
16495
|
+
this.loadingPlaylist(levelOrTrack, deliveryDirectives);
|
16485
16496
|
return;
|
16486
16497
|
}
|
16487
16498
|
} else if (details.canBlockReload || details.canSkipUntil) {
|
16488
16499
|
deliveryDirectives = this.getDeliveryDirectives(details, data.deliveryDirectives, msn, part);
|
16489
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
|
+
}
|
16490
16507
|
var bufferInfo = this.hls.mainForwardBufferInfo;
|
16491
16508
|
var position = bufferInfo ? bufferInfo.end - bufferInfo.len : 0;
|
16492
16509
|
var distanceToLiveEdgeMs = (details.edge - position) * 1000;
|
16493
16510
|
var reloadInterval = computeReloadInterval(details, distanceToLiveEdgeMs);
|
16494
|
-
if (details.
|
16495
|
-
|
16496
|
-
}
|
16497
|
-
|
16498
|
-
|
16499
|
-
|
16500
|
-
this.requestScheduled = now;
|
16501
|
-
} else if (this.requestScheduled - now <= 0) {
|
16502
|
-
this.requestScheduled += reloadInterval;
|
16503
|
-
}
|
16504
|
-
var estimatedTimeUntilUpdate = this.requestScheduled - now;
|
16505
|
-
estimatedTimeUntilUpdate = Math.max(0, estimatedTimeUntilUpdate);
|
16506
|
-
this.log("reload live playlist " + index + " in " + Math.round(estimatedTimeUntilUpdate) + " ms");
|
16507
|
-
// this.log(
|
16508
|
-
// `live reload ${details.updated ? 'REFRESHED' : 'MISSED'}
|
16509
|
-
// reload in ${estimatedTimeUntilUpdate / 1000}
|
16510
|
-
// round trip ${(stats.loading.end - stats.loading.start) / 1000}
|
16511
|
-
// diff ${
|
16512
|
-
// (reloadInterval -
|
16513
|
-
// (estimatedTimeUntilUpdate +
|
16514
|
-
// stats.loading.end -
|
16515
|
-
// stats.loading.start)) /
|
16516
|
-
// 1000
|
16517
|
-
// }
|
16518
|
-
// reload interval ${reloadInterval / 1000}
|
16519
|
-
// target duration ${details.targetduration}
|
16520
|
-
// distance to edge ${distanceToLiveEdgeMs / 1000}`
|
16521
|
-
// );
|
16522
|
-
|
16523
|
-
this.timer = self.setTimeout(function () {
|
16524
|
-
return _this2.loadPlaylist(deliveryDirectives);
|
16525
|
-
}, estimatedTimeUntilUpdate);
|
16511
|
+
if (details.requestScheduled + reloadInterval < now) {
|
16512
|
+
details.requestScheduled = now;
|
16513
|
+
} else {
|
16514
|
+
details.requestScheduled += reloadInterval;
|
16515
|
+
}
|
16516
|
+
this.scheduleLoading(levelOrTrack, deliveryDirectives);
|
16526
16517
|
} else {
|
16527
16518
|
this.clearTimer();
|
16528
16519
|
}
|
16529
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
|
+
};
|
16530
16556
|
_proto.getDeliveryDirectives = function getDeliveryDirectives(details, previousDeliveryDirectives, msn, part) {
|
16531
16557
|
var skip = getSkipValue(details);
|
16532
16558
|
if (previousDeliveryDirectives != null && previousDeliveryDirectives.skip && details.deltaUpdateFailed) {
|
@@ -16549,7 +16575,6 @@
|
|
16549
16575
|
var retry = !!errorAction && !!retryConfig && (action === NetworkErrorAction.RetryRequest || !errorAction.resolved && action === NetworkErrorAction.SendAlternateToPenaltyBox);
|
16550
16576
|
if (retry) {
|
16551
16577
|
var _errorEvent$context;
|
16552
|
-
this.requestScheduled = -1;
|
16553
16578
|
if (retryCount >= retryConfig.maxNumRetry) {
|
16554
16579
|
return false;
|
16555
16580
|
}
|
@@ -16872,10 +16897,7 @@
|
|
16872
16897
|
return;
|
16873
16898
|
}
|
16874
16899
|
if (data.context.type === PlaylistContextType.LEVEL && data.context.level === this.level) {
|
16875
|
-
|
16876
|
-
if (!retry) {
|
16877
|
-
this.requestScheduled = -1;
|
16878
|
-
}
|
16900
|
+
this.checkRetry(data);
|
16879
16901
|
}
|
16880
16902
|
}
|
16881
16903
|
|
@@ -16930,36 +16952,28 @@
|
|
16930
16952
|
};
|
16931
16953
|
_proto.loadPlaylist = function loadPlaylist(hlsUrlParameters) {
|
16932
16954
|
_BasePlaylistControll.prototype.loadPlaylist.call(this);
|
16933
|
-
|
16934
|
-
|
16935
|
-
if (currentLevel && this.shouldLoadPlaylist(currentLevel)) {
|
16936
|
-
var url = currentLevel.uri;
|
16937
|
-
if (hlsUrlParameters) {
|
16938
|
-
try {
|
16939
|
-
url = hlsUrlParameters.addDirectives(url);
|
16940
|
-
} catch (error) {
|
16941
|
-
this.warn("Could not construct new URL with HLS Delivery Directives: " + error);
|
16942
|
-
}
|
16943
|
-
}
|
16944
|
-
var pathwayId = currentLevel.attrs['PATHWAY-ID'];
|
16945
|
-
var details = currentLevel.details;
|
16946
|
-
var age = details == null ? void 0 : details.age;
|
16947
|
-
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);
|
16948
|
-
|
16949
|
-
// console.log('Current audio track group ID:', this.hls.audioTracks[this.hls.audioTrack].groupId);
|
16950
|
-
// console.log('New video quality level audio group id:', levelObject.attrs.AUDIO, level);
|
16951
|
-
this.clearTimer();
|
16952
|
-
this.hls.trigger(Events.LEVEL_LOADING, {
|
16953
|
-
url: url,
|
16954
|
-
level: currentLevelIndex,
|
16955
|
-
levelInfo: currentLevel,
|
16956
|
-
pathwayId: currentLevel.attrs['PATHWAY-ID'],
|
16957
|
-
id: 0,
|
16958
|
-
// Deprecated Level urlId
|
16959
|
-
deliveryDirectives: hlsUrlParameters || null
|
16960
|
-
});
|
16955
|
+
if (this.shouldLoadPlaylist(this.currentLevel)) {
|
16956
|
+
this.scheduleLoading(this.currentLevel, hlsUrlParameters);
|
16961
16957
|
}
|
16962
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
|
+
};
|
16963
16977
|
_proto.removeLevel = function removeLevel(levelIndex) {
|
16964
16978
|
var _this4 = this,
|
16965
16979
|
_this$currentLevel;
|
@@ -17054,9 +17068,7 @@
|
|
17054
17068
|
this.currentLevelIndex = newLevel;
|
17055
17069
|
this.currentLevel = level;
|
17056
17070
|
if (lastLevelIndex === newLevel && lastLevel && lastPathwayId === pathwayId) {
|
17057
|
-
|
17058
|
-
return;
|
17059
|
-
}
|
17071
|
+
return;
|
17060
17072
|
}
|
17061
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 : ''));
|
17062
17074
|
var levelSwitchingData = {
|
@@ -18934,10 +18946,11 @@
|
|
18934
18946
|
this.nextLoadPosition = startPosition;
|
18935
18947
|
};
|
18936
18948
|
_proto.getLoadPosition = function getLoadPosition() {
|
18949
|
+
var _this$hls;
|
18937
18950
|
var media = this.media;
|
18938
18951
|
// if we have not yet loaded any fragment, start loading from start position
|
18939
18952
|
var pos = 0;
|
18940
|
-
if (this.hls.hasEnoughToStart && media) {
|
18953
|
+
if ((_this$hls = this.hls) != null && _this$hls.hasEnoughToStart && media) {
|
18941
18954
|
pos = media.currentTime;
|
18942
18955
|
} else if (this.nextLoadPosition >= 0) {
|
18943
18956
|
pos = this.nextLoadPosition;
|
@@ -19731,7 +19744,7 @@
|
|
19731
19744
|
return !remuxResult.audio && !remuxResult.video && !remuxResult.text && !remuxResult.id3 && !remuxResult.initSegment;
|
19732
19745
|
}
|
19733
19746
|
|
19734
|
-
var version = "1.6.0-beta.1.0.canary.
|
19747
|
+
var version = "1.6.0-beta.1.0.canary.10789";
|
19735
19748
|
|
19736
19749
|
// ensure the worker ends up in the bundle
|
19737
19750
|
// If the worker should not be included this gets aliased to empty.js
|