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 CHANGED
@@ -522,7 +522,7 @@
522
522
  // Some browsers don't allow to use bind on console object anyway
523
523
  // fallback to default if needed
524
524
  try {
525
- newLogger.log("Debug logs enabled for \"" + context + "\" in hls.js version " + "1.5.12-0.canary.10397");
525
+ newLogger.log("Debug logs enabled for \"" + context + "\" in hls.js version " + "1.5.12-0.canary.10399");
526
526
  } catch (e) {
527
527
  /* log fn threw an exception. All logger methods are no-ops. */
528
528
  return createLogger();
@@ -5339,6 +5339,7 @@
5339
5339
  this.currentTime = 0;
5340
5340
  this.stallCount = 0;
5341
5341
  this._latency = null;
5342
+ this._targetLatencyUpdated = false;
5342
5343
  this.onTimeupdate = function () {
5343
5344
  var media = _this.media,
5344
5345
  levelDetails = _this.levelDetails;
@@ -5483,11 +5484,16 @@
5483
5484
  lowLatencyMode = _this$config2.lowLatencyMode;
5484
5485
  var userConfig = this.hls.userConfig;
5485
5486
  var targetLatency = lowLatencyMode ? partHoldBack || holdBack : holdBack;
5486
- if (userConfig.liveSyncDuration || userConfig.liveSyncDurationCount || targetLatency === 0) {
5487
+ if (this._targetLatencyUpdated || userConfig.liveSyncDuration || userConfig.liveSyncDurationCount || targetLatency === 0) {
5487
5488
  targetLatency = liveSyncDuration !== undefined ? liveSyncDuration : liveSyncDurationCount * targetduration;
5488
5489
  }
5489
5490
  var maxLiveSyncOnStallIncrease = targetduration;
5490
5491
  return targetLatency + Math.min(this.stallCount * this.config.liveSyncOnStallIncrease, maxLiveSyncOnStallIncrease);
5492
+ },
5493
+ set: function set(latency) {
5494
+ this.stallCount = 0;
5495
+ this.config.liveSyncDuration = latency;
5496
+ this._targetLatencyUpdated = true;
5491
5497
  }
5492
5498
  }, {
5493
5499
  key: "liveSyncPosition",
@@ -10258,7 +10264,7 @@
10258
10264
  // If backtracking, always remove from the tracker without reducing max buffer length
10259
10265
  var backtrackFragment = this.backtrackFragment;
10260
10266
  var backtracked = backtrackFragment ? frag.sn - backtrackFragment.sn : 0;
10261
- if (backtracked === 1 || this.reduceMaxBufferLength(minForwardBufferLength)) {
10267
+ if (backtracked === 1 || this.reduceMaxBufferLength(minForwardBufferLength, frag.duration)) {
10262
10268
  fragmentTracker.removeFragment(frag);
10263
10269
  }
10264
10270
  } else if (((_this$mediaBuffer = this.mediaBuffer) == null ? void 0 : _this$mediaBuffer.buffered.length) === 0) {
@@ -10756,10 +10762,10 @@
10756
10762
  }
10757
10763
  return Math.min(maxBufLen, config.maxMaxBufferLength);
10758
10764
  };
10759
- _proto.reduceMaxBufferLength = function reduceMaxBufferLength(threshold) {
10765
+ _proto.reduceMaxBufferLength = function reduceMaxBufferLength(threshold, fragDuration) {
10760
10766
  var config = this.config;
10761
- var minLength = threshold || config.maxBufferLength;
10762
- var reducedLength = config.maxMaxBufferLength / 2;
10767
+ var minLength = Math.max(Math.min(threshold, config.maxBufferLength), fragDuration);
10768
+ var reducedLength = Math.max(threshold - fragDuration * 3, config.maxMaxBufferLength / 2);
10763
10769
  if (reducedLength >= minLength) {
10764
10770
  // reduce max buffer length as it might be too high. we do this to avoid loop flushing ...
10765
10771
  config.maxMaxBufferLength = reducedLength;
@@ -11134,13 +11140,14 @@
11134
11140
  _proto.reduceLengthAndFlushBuffer = function reduceLengthAndFlushBuffer(data) {
11135
11141
  // if in appending state
11136
11142
  if (this.state === State.PARSING || this.state === State.PARSED) {
11143
+ var frag = data.frag;
11137
11144
  var playlistType = data.parent;
11138
11145
  var bufferedInfo = this.getFwdBufferInfo(this.mediaBuffer, playlistType);
11139
11146
  // 0.5 : tolerance needed as some browsers stalls playback before reaching buffered end
11140
11147
  // reduce max buf len if current position is buffered
11141
11148
  var buffered = bufferedInfo && bufferedInfo.len > 0.5;
11142
11149
  if (buffered) {
11143
- this.reduceMaxBufferLength(bufferedInfo.len);
11150
+ this.reduceMaxBufferLength(bufferedInfo.len, (frag == null ? void 0 : frag.duration) || 10);
11144
11151
  }
11145
11152
  var flushBuffer = !buffered;
11146
11153
  if (flushBuffer) {
@@ -11149,9 +11156,9 @@
11149
11156
  // in that case flush the whole audio buffer to recover
11150
11157
  this.warn("Buffer full error while media.currentTime is not buffered, flush " + playlistType + " buffer");
11151
11158
  }
11152
- if (data.frag) {
11153
- this.fragmentTracker.removeFragment(data.frag);
11154
- this.nextLoadPosition = data.frag.start;
11159
+ if (frag) {
11160
+ this.fragmentTracker.removeFragment(frag);
11161
+ this.nextLoadPosition = frag.start;
11155
11162
  }
11156
11163
  this.resetLoadingState();
11157
11164
  return flushBuffer;
@@ -30740,6 +30747,9 @@
30740
30747
  key: "targetLatency",
30741
30748
  get: function get() {
30742
30749
  return this.latencyController.targetLatency;
30750
+ },
30751
+ set: function set(latency) {
30752
+ this.latencyController.targetLatency = latency;
30743
30753
  }
30744
30754
 
30745
30755
  /**
@@ -30778,7 +30788,7 @@
30778
30788
  * Get the video-dev/hls.js package version.
30779
30789
  */
30780
30790
  function get() {
30781
- return "1.5.12-0.canary.10397";
30791
+ return "1.5.12-0.canary.10399";
30782
30792
  }
30783
30793
  }, {
30784
30794
  key: "Events",
package/dist/hls.js.d.ts CHANGED
@@ -302,7 +302,7 @@ export declare class BaseStreamController extends TaskLoop implements NetworkCom
302
302
  protected getFwdBufferInfo(bufferable: Bufferable | null, type: PlaylistLevelType): BufferInfo | null;
303
303
  protected getFwdBufferInfoAtPos(bufferable: Bufferable | null, pos: number, type: PlaylistLevelType): BufferInfo | null;
304
304
  protected getMaxBufferLength(levelBitrate?: number): number;
305
- protected reduceMaxBufferLength(threshold: number): boolean;
305
+ protected reduceMaxBufferLength(threshold: number, fragDuration: number): boolean;
306
306
  protected getAppendedFrag(position: number, playlistType?: PlaylistLevelType): Fragment | null;
307
307
  protected getNextFragment(pos: number, levelDetails: LevelDetails): Fragment | null;
308
308
  protected isLoopLoading(frag: Fragment, targetBufferTime: number): boolean;
@@ -1673,6 +1673,7 @@ declare class Hls implements HlsEventEmitter {
1673
1673
  * target distance from the edge as calculated by the latency controller
1674
1674
  */
1675
1675
  get targetLatency(): number | null;
1676
+ set targetLatency(latency: number);
1676
1677
  /**
1677
1678
  * the rate at which the edge of the current live playlist is advancing or 1 if there is none
1678
1679
  */