hls.js 1.6.0-beta.1.0.canary.10786 → 1.6.0-beta.1.0.canary.10788

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.mjs CHANGED
@@ -400,7 +400,7 @@ function enableLogs(debugConfig, context, id) {
400
400
  // Some browsers don't allow to use bind on console object anyway
401
401
  // fallback to default if needed
402
402
  try {
403
- newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.6.0-beta.1.0.canary.10786"}`);
403
+ newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.6.0-beta.1.0.canary.10788"}`);
404
404
  } catch (e) {
405
405
  /* log fn threw an exception. All logger methods are no-ops. */
406
406
  return createLogger();
@@ -7748,12 +7748,14 @@ function adjustSliding(oldDetails, newDetails, matchingStableVariantOrRendition
7748
7748
  let sliding = 0;
7749
7749
  if (advancedOrStable && delta < oldFragments.length) {
7750
7750
  sliding = oldFragments[delta].start;
7751
+ } else if (advancedOrStable && newDetails.startSN === oldDetails.endSN + 1) {
7752
+ sliding = oldDetails.fragmentEnd;
7751
7753
  } else if (advancedOrStable && matchingStableVariantOrRendition) {
7752
- // align new start with old end (updated playlist start sequence is past end sequence of last update)
7753
- sliding = oldDetails.edge;
7754
- } else if (!newDetails.skippedSegments && newDetails.fragments[0].start === 0) {
7754
+ // align with expected position (updated playlist start sequence is past end sequence of last update)
7755
+ sliding = oldDetails.fragmentStart + delta * newDetails.levelTargetDuration;
7756
+ } else if (!newDetails.skippedSegments && newDetails.fragmentStart === 0) {
7755
7757
  // align new start with old (playlist switch has a sequence with no overlap and should not be used for alignment)
7756
- sliding = oldDetails.fragments[0].start;
7758
+ sliding = oldDetails.fragmentStart;
7757
7759
  } else {
7758
7760
  // new details already has a sliding offset or has skipped segments
7759
7761
  return;
@@ -9806,7 +9808,7 @@ var eventemitter3 = {exports: {}};
9806
9808
  var eventemitter3Exports = eventemitter3.exports;
9807
9809
  var EventEmitter = /*@__PURE__*/getDefaultExportFromCjs(eventemitter3Exports);
9808
9810
 
9809
- const version = "1.6.0-beta.1.0.canary.10786";
9811
+ const version = "1.6.0-beta.1.0.canary.10788";
9810
9812
 
9811
9813
  // ensure the worker ends up in the bundle
9812
9814
  // If the worker should not be included this gets aliased to empty.js
@@ -16065,8 +16067,9 @@ const TICK_INTERVAL$2 = 100; // how often to tick in ms
16065
16067
  class AudioStreamController extends BaseStreamController {
16066
16068
  constructor(hls, fragmentTracker, keyLoader) {
16067
16069
  super(hls, fragmentTracker, keyLoader, 'audio-stream-controller', PlaylistLevelType.AUDIO);
16068
- this.videoAnchor = null;
16070
+ this.mainAnchor = null;
16069
16071
  this.mainFragLoading = null;
16072
+ this.audioOnly = false;
16070
16073
  this.bufferedTrack = null;
16071
16074
  this.switchingTrack = null;
16072
16075
  this.trackId = -1;
@@ -16080,9 +16083,10 @@ class AudioStreamController extends BaseStreamController {
16080
16083
  onHandlerDestroying() {
16081
16084
  this.unregisterListeners();
16082
16085
  super.onHandlerDestroying();
16083
- this.mainDetails = null;
16084
- this.bufferedTrack = null;
16085
- this.switchingTrack = null;
16086
+ this.resetItem();
16087
+ }
16088
+ resetItem() {
16089
+ this.mainDetails = this.mainAnchor = this.mainFragLoading = this.bufferedTrack = this.switchingTrack = this.waitingData = this.cachedTrackLoadedData = null;
16086
16090
  }
16087
16091
  registerListeners() {
16088
16092
  super.registerListeners();
@@ -16139,7 +16143,7 @@ class AudioStreamController extends BaseStreamController {
16139
16143
  timescale
16140
16144
  };
16141
16145
  this.log(`InitPTS for cc: ${cc} found from main: ${initPTS}/${timescale}`);
16142
- this.videoAnchor = frag;
16146
+ this.mainAnchor = frag;
16143
16147
  // If we are waiting, tick immediately to unblock audio fragment transmuxing
16144
16148
  if (this.state === State.WAITING_INIT_PTS) {
16145
16149
  const waitingData = this.waitingData;
@@ -16230,7 +16234,7 @@ class AudioStreamController extends BaseStreamController {
16230
16234
  cache,
16231
16235
  complete
16232
16236
  } = waitingData;
16233
- const videoAnchor = this.videoAnchor;
16237
+ const mainAnchor = this.mainAnchor;
16234
16238
  if (this.initPTS[frag.cc] !== undefined) {
16235
16239
  this.waitingData = null;
16236
16240
  this.state = State.FRAG_LOADING;
@@ -16245,10 +16249,10 @@ class AudioStreamController extends BaseStreamController {
16245
16249
  if (complete) {
16246
16250
  super._handleFragmentLoadComplete(data);
16247
16251
  }
16248
- } else if (videoAnchor && videoAnchor.cc !== waitingData.frag.cc) {
16252
+ } else if (mainAnchor && mainAnchor.cc !== waitingData.frag.cc) {
16249
16253
  // Drop waiting fragment if videoTrackCC has changed since waitingFragment was set and initPTS was not found
16250
- this.log(`Waiting fragment cc (${frag.cc}) cancelled because video is at cc ${videoAnchor.cc}`);
16251
- this.nextLoadPosition = this.findSyncFrag(videoAnchor).start;
16254
+ this.log(`Waiting fragment cc (${frag.cc}) cancelled because video is at cc ${mainAnchor.cc}`);
16255
+ this.nextLoadPosition = this.findSyncFrag(mainAnchor).start;
16252
16256
  this.clearWaitingFragment();
16253
16257
  }
16254
16258
  } else {
@@ -16370,7 +16374,7 @@ class AudioStreamController extends BaseStreamController {
16370
16374
 
16371
16375
  // Request audio segments up to one fragment ahead of main stream-controller
16372
16376
  const mainFragLoading = (_this$mainFragLoading = this.mainFragLoading) == null ? void 0 : _this$mainFragLoading.frag;
16373
- if (this.startFragRequested && mainFragLoading && isMediaFragment(mainFragLoading) && isMediaFragment(frag) && !frag.endList && (!trackDetails.live || !this.loadingParts && targetBufferTime < this.hls.liveSyncPosition)) {
16377
+ if (!this.audioOnly && this.startFragRequested && mainFragLoading && isMediaFragment(mainFragLoading) && isMediaFragment(frag) && !frag.endList && (!trackDetails.live || !this.loadingParts && targetBufferTime < this.hls.liveSyncPosition)) {
16374
16378
  let mainFrag = mainFragLoading;
16375
16379
  if (frag.start > mainFrag.end) {
16376
16380
  // Get buffered frag at target position from tracker (loaded out of sequence)
@@ -16435,8 +16439,8 @@ class AudioStreamController extends BaseStreamController {
16435
16439
  }
16436
16440
  onManifestLoading() {
16437
16441
  super.onManifestLoading();
16438
- this.bufferFlushed = this.flushing = false;
16439
- this.mainDetails = this.waitingData = this.videoAnchor = this.bufferedTrack = this.cachedTrackLoadedData = this.switchingTrack = null;
16442
+ this.bufferFlushed = this.flushing = this.audioOnly = false;
16443
+ this.resetItem();
16440
16444
  this.trackId = -1;
16441
16445
  }
16442
16446
  onLevelLoaded(event, data) {
@@ -16456,7 +16460,8 @@ class AudioStreamController extends BaseStreamController {
16456
16460
  details: newDetails,
16457
16461
  id: trackId
16458
16462
  } = data;
16459
- if (this.mainDetails == null || this.mainDetails.expired || newDetails.endCC > this.mainDetails.endCC) {
16463
+ const mainDetails = this.mainDetails;
16464
+ if (!mainDetails || mainDetails.expired || newDetails.endCC > mainDetails.endCC) {
16460
16465
  this.cachedTrackLoadedData = data;
16461
16466
  if (this.state !== State.STOPPED) {
16462
16467
  this.state = State.WAITING_TRACK;
@@ -16472,8 +16477,7 @@ class AudioStreamController extends BaseStreamController {
16472
16477
  let sliding = 0;
16473
16478
  if (newDetails.live || (_track$details = track.details) != null && _track$details.live) {
16474
16479
  this.checkLiveUpdate(newDetails);
16475
- const mainDetails = this.mainDetails;
16476
- if (newDetails.deltaUpdateFailed || !mainDetails) {
16480
+ if (newDetails.deltaUpdateFailed) {
16477
16481
  return;
16478
16482
  }
16479
16483
  if (track.details) {
@@ -16494,8 +16498,8 @@ class AudioStreamController extends BaseStreamController {
16494
16498
  this.levelLastLoaded = track;
16495
16499
 
16496
16500
  // compute start position if we are aligned with the main playlist
16497
- if (!this.startFragRequested && (this.mainDetails || !newDetails.live)) {
16498
- this.setStartPosition(this.mainDetails || newDetails, sliding);
16501
+ if (!this.startFragRequested) {
16502
+ this.setStartPosition(mainDetails, sliding);
16499
16503
  }
16500
16504
  this.hls.trigger(Events.AUDIO_TRACK_UPDATED, {
16501
16505
  details: newDetails,
@@ -16592,7 +16596,7 @@ class AudioStreamController extends BaseStreamController {
16592
16596
  }
16593
16597
  }
16594
16598
  onFragLoading(event, data) {
16595
- if (data.frag.type === PlaylistLevelType.MAIN && isMediaFragment(data.frag)) {
16599
+ if (!this.audioOnly && data.frag.type === PlaylistLevelType.MAIN && isMediaFragment(data.frag)) {
16596
16600
  this.mainFragLoading = data;
16597
16601
  if (this.state === State.IDLE) {
16598
16602
  this.tick();
@@ -16605,6 +16609,10 @@ class AudioStreamController extends BaseStreamController {
16605
16609
  part
16606
16610
  } = data;
16607
16611
  if (frag.type !== PlaylistLevelType.AUDIO) {
16612
+ if (!this.audioOnly && frag.type === PlaylistLevelType.MAIN && !frag.elementaryStreams.video && !frag.elementaryStreams.audiovideo) {
16613
+ this.audioOnly = true;
16614
+ this.mainFragLoading = null;
16615
+ }
16608
16616
  return;
16609
16617
  }
16610
16618
  if (this.fragContextChanged(frag)) {