hls.js 1.5.12-0.canary.10397 → 1.5.12-0.canary.10399
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.js +21 -11
- package/dist/hls.js.d.ts +2 -1
- package/dist/hls.js.map +1 -1
- package/dist/hls.light.js +21 -11
- 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 +21 -11
- 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 +21 -11
- package/dist/hls.mjs.map +1 -1
- package/dist/hls.worker.js +1 -1
- package/package.json +1 -1
- package/src/controller/base-stream-controller.ts +15 -8
- package/src/controller/latency-controller.ts +8 -0
- package/src/hls.ts +4 -0
package/dist/hls.light.mjs
CHANGED
@@ -420,7 +420,7 @@ function enableLogs(debugConfig, context, id) {
|
|
420
420
|
// Some browsers don't allow to use bind on console object anyway
|
421
421
|
// fallback to default if needed
|
422
422
|
try {
|
423
|
-
newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.5.12-0.canary.
|
423
|
+
newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.5.12-0.canary.10399"}`);
|
424
424
|
} catch (e) {
|
425
425
|
/* log fn threw an exception. All logger methods are no-ops. */
|
426
426
|
return createLogger();
|
@@ -4570,6 +4570,7 @@ class LatencyController {
|
|
4570
4570
|
this.currentTime = 0;
|
4571
4571
|
this.stallCount = 0;
|
4572
4572
|
this._latency = null;
|
4573
|
+
this._targetLatencyUpdated = false;
|
4573
4574
|
this.onTimeupdate = () => {
|
4574
4575
|
const {
|
4575
4576
|
media,
|
@@ -4647,12 +4648,17 @@ class LatencyController {
|
|
4647
4648
|
} = this.config;
|
4648
4649
|
const userConfig = this.hls.userConfig;
|
4649
4650
|
let targetLatency = lowLatencyMode ? partHoldBack || holdBack : holdBack;
|
4650
|
-
if (userConfig.liveSyncDuration || userConfig.liveSyncDurationCount || targetLatency === 0) {
|
4651
|
+
if (this._targetLatencyUpdated || userConfig.liveSyncDuration || userConfig.liveSyncDurationCount || targetLatency === 0) {
|
4651
4652
|
targetLatency = liveSyncDuration !== undefined ? liveSyncDuration : liveSyncDurationCount * targetduration;
|
4652
4653
|
}
|
4653
4654
|
const maxLiveSyncOnStallIncrease = targetduration;
|
4654
4655
|
return targetLatency + Math.min(this.stallCount * this.config.liveSyncOnStallIncrease, maxLiveSyncOnStallIncrease);
|
4655
4656
|
}
|
4657
|
+
set targetLatency(latency) {
|
4658
|
+
this.stallCount = 0;
|
4659
|
+
this.config.liveSyncDuration = latency;
|
4660
|
+
this._targetLatencyUpdated = true;
|
4661
|
+
}
|
4656
4662
|
get liveSyncPosition() {
|
4657
4663
|
const liveEdge = this.estimateLiveEdge();
|
4658
4664
|
const targetLatency = this.targetLatency;
|
@@ -12755,7 +12761,7 @@ class BaseStreamController extends TaskLoop {
|
|
12755
12761
|
// If backtracking, always remove from the tracker without reducing max buffer length
|
12756
12762
|
const backtrackFragment = this.backtrackFragment;
|
12757
12763
|
const backtracked = backtrackFragment ? frag.sn - backtrackFragment.sn : 0;
|
12758
|
-
if (backtracked === 1 || this.reduceMaxBufferLength(minForwardBufferLength)) {
|
12764
|
+
if (backtracked === 1 || this.reduceMaxBufferLength(minForwardBufferLength, frag.duration)) {
|
12759
12765
|
fragmentTracker.removeFragment(frag);
|
12760
12766
|
}
|
12761
12767
|
} else if (((_this$mediaBuffer = this.mediaBuffer) == null ? void 0 : _this$mediaBuffer.buffered.length) === 0) {
|
@@ -13256,10 +13262,10 @@ class BaseStreamController extends TaskLoop {
|
|
13256
13262
|
}
|
13257
13263
|
return Math.min(maxBufLen, config.maxMaxBufferLength);
|
13258
13264
|
}
|
13259
|
-
reduceMaxBufferLength(threshold) {
|
13265
|
+
reduceMaxBufferLength(threshold, fragDuration) {
|
13260
13266
|
const config = this.config;
|
13261
|
-
const minLength = threshold
|
13262
|
-
const reducedLength = config.maxMaxBufferLength / 2;
|
13267
|
+
const minLength = Math.max(Math.min(threshold, config.maxBufferLength), fragDuration);
|
13268
|
+
const reducedLength = Math.max(threshold - fragDuration * 3, config.maxMaxBufferLength / 2);
|
13263
13269
|
if (reducedLength >= minLength) {
|
13264
13270
|
// reduce max buffer length as it might be too high. we do this to avoid loop flushing ...
|
13265
13271
|
config.maxMaxBufferLength = reducedLength;
|
@@ -13649,13 +13655,14 @@ class BaseStreamController extends TaskLoop {
|
|
13649
13655
|
reduceLengthAndFlushBuffer(data) {
|
13650
13656
|
// if in appending state
|
13651
13657
|
if (this.state === State.PARSING || this.state === State.PARSED) {
|
13658
|
+
const frag = data.frag;
|
13652
13659
|
const playlistType = data.parent;
|
13653
13660
|
const bufferedInfo = this.getFwdBufferInfo(this.mediaBuffer, playlistType);
|
13654
13661
|
// 0.5 : tolerance needed as some browsers stalls playback before reaching buffered end
|
13655
13662
|
// reduce max buf len if current position is buffered
|
13656
13663
|
const buffered = bufferedInfo && bufferedInfo.len > 0.5;
|
13657
13664
|
if (buffered) {
|
13658
|
-
this.reduceMaxBufferLength(bufferedInfo.len);
|
13665
|
+
this.reduceMaxBufferLength(bufferedInfo.len, (frag == null ? void 0 : frag.duration) || 10);
|
13659
13666
|
}
|
13660
13667
|
const flushBuffer = !buffered;
|
13661
13668
|
if (flushBuffer) {
|
@@ -13664,9 +13671,9 @@ class BaseStreamController extends TaskLoop {
|
|
13664
13671
|
// in that case flush the whole audio buffer to recover
|
13665
13672
|
this.warn(`Buffer full error while media.currentTime is not buffered, flush ${playlistType} buffer`);
|
13666
13673
|
}
|
13667
|
-
if (
|
13668
|
-
this.fragmentTracker.removeFragment(
|
13669
|
-
this.nextLoadPosition =
|
13674
|
+
if (frag) {
|
13675
|
+
this.fragmentTracker.removeFragment(frag);
|
13676
|
+
this.nextLoadPosition = frag.start;
|
13670
13677
|
}
|
13671
13678
|
this.resetLoadingState();
|
13672
13679
|
return flushBuffer;
|
@@ -20658,7 +20665,7 @@ class Hls {
|
|
20658
20665
|
* Get the video-dev/hls.js package version.
|
20659
20666
|
*/
|
20660
20667
|
static get version() {
|
20661
|
-
return "1.5.12-0.canary.
|
20668
|
+
return "1.5.12-0.canary.10399";
|
20662
20669
|
}
|
20663
20670
|
|
20664
20671
|
/**
|
@@ -21453,6 +21460,9 @@ class Hls {
|
|
21453
21460
|
get targetLatency() {
|
21454
21461
|
return this.latencyController.targetLatency;
|
21455
21462
|
}
|
21463
|
+
set targetLatency(latency) {
|
21464
|
+
this.latencyController.targetLatency = latency;
|
21465
|
+
}
|
21456
21466
|
|
21457
21467
|
/**
|
21458
21468
|
* the rate at which the edge of the current live playlist is advancing or 1 if there is none
|