hls.js 1.6.3-0.canary.11252 → 1.6.3-0.canary.11254

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 CHANGED
@@ -146,10 +146,10 @@ export declare class AudioStreamController extends BaseStreamController implemen
146
146
  protected registerListeners(): void;
147
147
  protected unregisterListeners(): void;
148
148
  onInitPtsFound(event: Events.INIT_PTS_FOUND, { frag, id, initPTS, timescale }: InitPTSFoundData): void;
149
- private findSyncFrag;
149
+ protected getLoadPosition(): number;
150
+ private syncWithAnchor;
150
151
  startLoad(startPosition: number, skipSeekToStartPosition?: boolean): void;
151
152
  doTick(): void;
152
- clearWaitingFragment(): void;
153
153
  protected resetLoadingState(): void;
154
154
  protected onTickEnd(): void;
155
155
  private doTickIdle;
@@ -367,7 +367,7 @@ export declare class BaseStreamController extends TaskLoop implements NetworkCom
367
367
  mapToInitFragWhenRequired(frag: Fragment | null): typeof frag;
368
368
  getNextPart(partList: Part[], frag: Fragment, targetBufferTime: number): number;
369
369
  private loadedEndOfParts;
370
- protected getInitialLiveFragment(levelDetails: LevelDetails, fragments: MediaFragment[]): MediaFragment | null;
370
+ protected getInitialLiveFragment(levelDetails: LevelDetails): MediaFragment | null;
371
371
  protected getFragmentAtPosition(bufferEnd: number, end: number, levelDetails: LevelDetails): MediaFragment | null;
372
372
  protected alignPlaylists(details: LevelDetails, previousDetails: LevelDetails | undefined, switchDetails: LevelDetails | undefined): number;
373
373
  protected waitForCdnTuneIn(details: LevelDetails): boolean | 0;
@@ -2006,6 +2006,7 @@ export declare type HlsConfig = {
2006
2006
  ignoreDevicePixelRatio: boolean;
2007
2007
  maxDevicePixelRatio: number;
2008
2008
  preferManagedMediaSource: boolean;
2009
+ preserveManualLevelOnError: boolean;
2009
2010
  timelineOffset?: number;
2010
2011
  ignorePlaylistParsingErrors: boolean;
2011
2012
  loader: {
package/dist/hls.d.ts CHANGED
@@ -146,10 +146,10 @@ export declare class AudioStreamController extends BaseStreamController implemen
146
146
  protected registerListeners(): void;
147
147
  protected unregisterListeners(): void;
148
148
  onInitPtsFound(event: Events.INIT_PTS_FOUND, { frag, id, initPTS, timescale }: InitPTSFoundData): void;
149
- private findSyncFrag;
149
+ protected getLoadPosition(): number;
150
+ private syncWithAnchor;
150
151
  startLoad(startPosition: number, skipSeekToStartPosition?: boolean): void;
151
152
  doTick(): void;
152
- clearWaitingFragment(): void;
153
153
  protected resetLoadingState(): void;
154
154
  protected onTickEnd(): void;
155
155
  private doTickIdle;
@@ -367,7 +367,7 @@ export declare class BaseStreamController extends TaskLoop implements NetworkCom
367
367
  mapToInitFragWhenRequired(frag: Fragment | null): typeof frag;
368
368
  getNextPart(partList: Part[], frag: Fragment, targetBufferTime: number): number;
369
369
  private loadedEndOfParts;
370
- protected getInitialLiveFragment(levelDetails: LevelDetails, fragments: MediaFragment[]): MediaFragment | null;
370
+ protected getInitialLiveFragment(levelDetails: LevelDetails): MediaFragment | null;
371
371
  protected getFragmentAtPosition(bufferEnd: number, end: number, levelDetails: LevelDetails): MediaFragment | null;
372
372
  protected alignPlaylists(details: LevelDetails, previousDetails: LevelDetails | undefined, switchDetails: LevelDetails | undefined): number;
373
373
  protected waitForCdnTuneIn(details: LevelDetails): boolean | 0;
@@ -2006,6 +2006,7 @@ export declare type HlsConfig = {
2006
2006
  ignoreDevicePixelRatio: boolean;
2007
2007
  maxDevicePixelRatio: number;
2008
2008
  preferManagedMediaSource: boolean;
2009
+ preserveManualLevelOnError: boolean;
2009
2010
  timelineOffset?: number;
2010
2011
  ignorePlaylistParsingErrors: boolean;
2011
2012
  loader: {
package/dist/hls.js CHANGED
@@ -1165,7 +1165,7 @@
1165
1165
  // Some browsers don't allow to use bind on console object anyway
1166
1166
  // fallback to default if needed
1167
1167
  try {
1168
- newLogger.log("Debug logs enabled for \"" + context + "\" in hls.js version " + "1.6.3-0.canary.11252");
1168
+ newLogger.log("Debug logs enabled for \"" + context + "\" in hls.js version " + "1.6.3-0.canary.11254");
1169
1169
  } catch (e) {
1170
1170
  /* log fn threw an exception. All logger methods are no-ops. */
1171
1171
  return createLogger();
@@ -4695,7 +4695,6 @@
4695
4695
  if (PDTValue >= (endPDT || 0)) {
4696
4696
  return null;
4697
4697
  }
4698
- maxFragLookUpTolerance = maxFragLookUpTolerance || 0;
4699
4698
  for (var seg = 0; seg < fragments.length; ++seg) {
4700
4699
  var frag = fragments[seg];
4701
4700
  if (pdtWithinToleranceTest(PDTValue, maxFragLookUpTolerance, frag)) {
@@ -4821,38 +4820,32 @@
4821
4820
  var endProgramDateTime = candidate.endProgramDateTime || 0;
4822
4821
  return endProgramDateTime - candidateLookupTolerance > pdtBufferEnd;
4823
4822
  }
4824
- function findFragWithCC(fragments, cc) {
4825
- return BinarySearch.search(fragments, function (candidate) {
4826
- if (candidate.cc < cc) {
4827
- return 1;
4828
- } else if (candidate.cc > cc) {
4829
- return -1;
4830
- } else {
4831
- return 0;
4832
- }
4833
- });
4834
- }
4835
- function findNearestWithCC(details, cc, fragment) {
4823
+ function findNearestWithCC(details, cc, pos) {
4836
4824
  if (details) {
4837
4825
  if (details.startCC <= cc && details.endCC >= cc) {
4838
- var start = fragment.start;
4839
- var end = fragment.end;
4840
4826
  var fragments = details.fragments;
4841
- if (!fragment.relurl) {
4842
- var fragmentHint = details.fragmentHint;
4843
- if (fragmentHint) {
4844
- fragments = fragments.concat(fragmentHint);
4845
- }
4827
+ var fragmentHint = details.fragmentHint;
4828
+ if (fragmentHint) {
4829
+ fragments = fragments.concat(fragmentHint);
4846
4830
  }
4847
- return BinarySearch.search(fragments, function (candidate) {
4848
- if (candidate.cc < cc || candidate.end <= start) {
4831
+ var closest;
4832
+ BinarySearch.search(fragments, function (candidate) {
4833
+ if (candidate.cc < cc) {
4849
4834
  return 1;
4850
- } else if (candidate.cc > cc || candidate.start >= end) {
4835
+ }
4836
+ if (candidate.cc > cc) {
4851
4837
  return -1;
4852
- } else {
4853
- return 0;
4854
4838
  }
4839
+ closest = candidate;
4840
+ if (candidate.end <= pos) {
4841
+ return 1;
4842
+ }
4843
+ if (candidate.start > pos) {
4844
+ return -1;
4845
+ }
4846
+ return 0;
4855
4847
  });
4848
+ return closest || null;
4856
4849
  }
4857
4850
  }
4858
4851
  return null;
@@ -5142,7 +5135,7 @@
5142
5135
  loadLevel = hls.loadLevel,
5143
5136
  minAutoLevel = hls.minAutoLevel,
5144
5137
  maxAutoLevel = hls.maxAutoLevel;
5145
- if (!hls.autoLevelEnabled) {
5138
+ if (!hls.autoLevelEnabled && !hls.config.preserveManualLevelOnError) {
5146
5139
  hls.loadLevel = -1;
5147
5140
  }
5148
5141
  var fragErrorType = (_data$frag2 = data.frag) == null ? void 0 : _data$frag2.type;
@@ -9969,7 +9962,7 @@
9969
9962
  this.log("LL-Part loading ON for initial live fragment");
9970
9963
  this.loadingParts = true;
9971
9964
  }
9972
- frag = this.getInitialLiveFragment(levelDetails, fragments);
9965
+ frag = this.getInitialLiveFragment(levelDetails);
9973
9966
  var mainStart = this.hls.startPosition;
9974
9967
  var liveSyncPosition = this.hls.liveSyncPosition;
9975
9968
  var startPosition = frag ? (mainStart !== -1 && mainStart >= start ? mainStart : liveSyncPosition) || frag.start : pos;
@@ -10099,7 +10092,8 @@
10099
10092
  "sliding" of the playlist, which is its offset from the start of playback. After sliding we can compute the real
10100
10093
  start and end times for each fragment in the playlist (after which this method will not need to be called).
10101
10094
  */;
10102
- _proto.getInitialLiveFragment = function getInitialLiveFragment(levelDetails, fragments) {
10095
+ _proto.getInitialLiveFragment = function getInitialLiveFragment(levelDetails) {
10096
+ var fragments = levelDetails.fragments;
10103
10097
  var fragPrevious = this.fragPrevious;
10104
10098
  var frag = null;
10105
10099
  if (fragPrevious) {
@@ -10122,7 +10116,7 @@
10122
10116
  // It's important to stay within the continuity range if available; otherwise the fragments in the playlist
10123
10117
  // will have the wrong start times
10124
10118
  if (!frag) {
10125
- frag = findFragWithCC(fragments, fragPrevious.cc);
10119
+ frag = findNearestWithCC(levelDetails, fragPrevious.cc, fragPrevious.end);
10126
10120
  if (frag) {
10127
10121
  this.log("Live playlist, switching playlist, load frag with same CC: " + frag.sn);
10128
10122
  }
@@ -16677,7 +16671,7 @@
16677
16671
  return !remuxResult.audio && !remuxResult.video && !remuxResult.text && !remuxResult.id3 && !remuxResult.initSegment;
16678
16672
  }
16679
16673
 
16680
- var version = "1.6.3-0.canary.11252";
16674
+ var version = "1.6.3-0.canary.11254";
16681
16675
 
16682
16676
  // ensure the worker ends up in the bundle
16683
16677
  // If the worker should not be included this gets aliased to empty.js
@@ -17133,23 +17127,46 @@
17133
17127
  if (this.state === State.WAITING_INIT_PTS) {
17134
17128
  var waitingData = this.waitingData;
17135
17129
  if (!waitingData && !this.loadingParts || waitingData && waitingData.frag.cc !== cc) {
17136
- this.nextLoadPosition = this.findSyncFrag(frag).start;
17130
+ this.syncWithAnchor(frag, waitingData == null ? void 0 : waitingData.frag);
17137
17131
  }
17138
- this.tick();
17139
17132
  } else if (!this.hls.hasEnoughToStart && inFlightFrag && inFlightFrag.cc !== cc) {
17140
- this.startFragRequested = false;
17141
- this.nextLoadPosition = this.findSyncFrag(frag).start;
17142
17133
  inFlightFrag.abortRequests();
17143
- this.resetLoadingState();
17134
+ this.syncWithAnchor(frag, inFlightFrag);
17144
17135
  } else if (this.state === State.IDLE) {
17145
17136
  this.tick();
17146
17137
  }
17147
17138
  }
17148
17139
  };
17149
- _proto.findSyncFrag = function findSyncFrag(mainFrag) {
17140
+ _proto.getLoadPosition = function getLoadPosition() {
17141
+ if (!this.startFragRequested && this.nextLoadPosition >= 0) {
17142
+ return this.nextLoadPosition;
17143
+ }
17144
+ return _BaseStreamController.prototype.getLoadPosition.call(this);
17145
+ };
17146
+ _proto.syncWithAnchor = function syncWithAnchor(mainAnchor, waitingToAppend) {
17147
+ var _this$mainFragLoading;
17148
+ // Drop waiting fragment if videoTrackCC has changed since waitingFragment was set and initPTS was not found
17149
+ var mainFragLoading = ((_this$mainFragLoading = this.mainFragLoading) == null ? void 0 : _this$mainFragLoading.frag) || null;
17150
+ if (waitingToAppend) {
17151
+ if ((mainFragLoading == null ? void 0 : mainFragLoading.cc) === waitingToAppend.cc) {
17152
+ // Wait for loading frag to complete and INIT_PTS_FOUND
17153
+ return;
17154
+ }
17155
+ }
17156
+ var targetDiscontinuity = (mainFragLoading || mainAnchor).cc;
17150
17157
  var trackDetails = this.getLevelDetails();
17151
- var cc = mainFrag.cc;
17152
- return findNearestWithCC(trackDetails, cc, mainFrag) || trackDetails && findFragWithCC(trackDetails.fragments, cc) || mainFrag;
17158
+ var pos = this.getLoadPosition();
17159
+ var syncFrag = findNearestWithCC(trackDetails, targetDiscontinuity, pos);
17160
+ // Only stop waiting for audioFrag.cc if an audio segment of the same discontinuity domain (cc) is found
17161
+ if (syncFrag) {
17162
+ this.log("Waiting fragment cc (" + (waitingToAppend == null ? void 0 : waitingToAppend.cc) + ") cancelled because video is at cc " + mainAnchor.cc);
17163
+ this.startFragRequested = false;
17164
+ this.nextLoadPosition = syncFrag.start;
17165
+ this.resetLoadingState();
17166
+ if (this.state === State.IDLE) {
17167
+ this.doTickIdle();
17168
+ }
17169
+ }
17153
17170
  };
17154
17171
  _proto.startLoad = function startLoad(startPosition, skipSeekToStartPosition) {
17155
17172
  if (!this.levels) {
@@ -17230,10 +17247,7 @@
17230
17247
  _BaseStreamController.prototype._handleFragmentLoadComplete.call(this, data);
17231
17248
  }
17232
17249
  } else if (mainAnchor && mainAnchor.cc !== waitingData.frag.cc) {
17233
- // Drop waiting fragment if videoTrackCC has changed since waitingFragment was set and initPTS was not found
17234
- this.log("Waiting fragment cc (" + frag.cc + ") cancelled because video is at cc " + mainAnchor.cc);
17235
- this.nextLoadPosition = this.findSyncFrag(mainAnchor).start;
17236
- this.clearWaitingFragment();
17250
+ this.syncWithAnchor(mainAnchor, waitingData.frag);
17237
17251
  }
17238
17252
  } else {
17239
17253
  this.state = State.IDLE;
@@ -17242,22 +17256,12 @@
17242
17256
  }
17243
17257
  this.onTickEnd();
17244
17258
  };
17245
- _proto.clearWaitingFragment = function clearWaitingFragment() {
17259
+ _proto.resetLoadingState = function resetLoadingState() {
17246
17260
  var waitingData = this.waitingData;
17247
17261
  if (waitingData) {
17248
- if (!this.hls.hasEnoughToStart) {
17249
- // Load overlapping fragment on start when discontinuity start times are not aligned
17250
- this.startFragRequested = false;
17251
- }
17252
17262
  this.fragmentTracker.removeFragment(waitingData.frag);
17253
17263
  this.waitingData = null;
17254
- if (this.state !== State.STOPPED) {
17255
- this.state = State.IDLE;
17256
- }
17257
17264
  }
17258
- };
17259
- _proto.resetLoadingState = function resetLoadingState() {
17260
- this.clearWaitingFragment();
17261
17265
  _BaseStreamController.prototype.resetLoadingState.call(this);
17262
17266
  };
17263
17267
  _proto.onTickEnd = function onTickEnd() {
@@ -17269,7 +17273,7 @@
17269
17273
  this.lastCurrentTime = media.currentTime;
17270
17274
  };
17271
17275
  _proto.doTickIdle = function doTickIdle() {
17272
- var _this$mainFragLoading;
17276
+ var _this$mainFragLoading2;
17273
17277
  var hls = this.hls,
17274
17278
  levels = this.levels,
17275
17279
  media = this.media,
@@ -17341,7 +17345,7 @@
17341
17345
  }
17342
17346
 
17343
17347
  // Request audio segments up to one fragment ahead of main stream-controller
17344
- var mainFragLoading = ((_this$mainFragLoading = this.mainFragLoading) == null ? void 0 : _this$mainFragLoading.frag) || null;
17348
+ var mainFragLoading = ((_this$mainFragLoading2 = this.mainFragLoading) == null ? void 0 : _this$mainFragLoading2.frag) || null;
17345
17349
  if (!this.audioOnly && this.startFragRequested && mainFragLoading && isMediaFragment(frag) && !frag.endList && (!trackDetails.live || !this.loadingParts && targetBufferTime < this.hls.liveSyncPosition)) {
17346
17350
  if (this.fragmentTracker.getState(mainFragLoading) === FragmentState.OK) {
17347
17351
  this.mainFragLoading = mainFragLoading = null;
@@ -25959,7 +25963,6 @@
25959
25963
  var _this$schedule$items2, _this$detachedData4;
25960
25964
  var interstitial = player.interstitial,
25961
25965
  assetItem = player.assetItem;
25962
- player.assetId;
25963
25966
  var scheduleIndex = this.schedule.findEventIndex(interstitial.identifier);
25964
25967
  var item = (_this$schedule$items2 = this.schedule.items) == null ? void 0 : _this$schedule$items2[scheduleIndex];
25965
25968
  if (!item) {
@@ -31217,6 +31220,7 @@
31217
31220
  interstitialAppendInPlace: true,
31218
31221
  interstitialLiveLookAhead: 10,
31219
31222
  useMediaCapabilities: true,
31223
+ preserveManualLevelOnError: false,
31220
31224
  certLoadPolicy: {
31221
31225
  default: defaultLoadPolicy
31222
31226
  },
package/dist/hls.js.d.ts CHANGED
@@ -146,10 +146,10 @@ export declare class AudioStreamController extends BaseStreamController implemen
146
146
  protected registerListeners(): void;
147
147
  protected unregisterListeners(): void;
148
148
  onInitPtsFound(event: Events.INIT_PTS_FOUND, { frag, id, initPTS, timescale }: InitPTSFoundData): void;
149
- private findSyncFrag;
149
+ protected getLoadPosition(): number;
150
+ private syncWithAnchor;
150
151
  startLoad(startPosition: number, skipSeekToStartPosition?: boolean): void;
151
152
  doTick(): void;
152
- clearWaitingFragment(): void;
153
153
  protected resetLoadingState(): void;
154
154
  protected onTickEnd(): void;
155
155
  private doTickIdle;
@@ -367,7 +367,7 @@ export declare class BaseStreamController extends TaskLoop implements NetworkCom
367
367
  mapToInitFragWhenRequired(frag: Fragment | null): typeof frag;
368
368
  getNextPart(partList: Part[], frag: Fragment, targetBufferTime: number): number;
369
369
  private loadedEndOfParts;
370
- protected getInitialLiveFragment(levelDetails: LevelDetails, fragments: MediaFragment[]): MediaFragment | null;
370
+ protected getInitialLiveFragment(levelDetails: LevelDetails): MediaFragment | null;
371
371
  protected getFragmentAtPosition(bufferEnd: number, end: number, levelDetails: LevelDetails): MediaFragment | null;
372
372
  protected alignPlaylists(details: LevelDetails, previousDetails: LevelDetails | undefined, switchDetails: LevelDetails | undefined): number;
373
373
  protected waitForCdnTuneIn(details: LevelDetails): boolean | 0;
@@ -2006,6 +2006,7 @@ export declare type HlsConfig = {
2006
2006
  ignoreDevicePixelRatio: boolean;
2007
2007
  maxDevicePixelRatio: number;
2008
2008
  preferManagedMediaSource: boolean;
2009
+ preserveManualLevelOnError: boolean;
2009
2010
  timelineOffset?: number;
2010
2011
  ignorePlaylistParsingErrors: boolean;
2011
2012
  loader: {