hls.js 1.6.0-beta.1.0.canary.10809 → 1.6.0-beta.1.0.canary.10811

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.
@@ -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.10809"}`);
403
+ newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.6.0-beta.1.0.canary.10811"}`);
404
404
  } catch (e) {
405
405
  /* log fn threw an exception. All logger methods are no-ops. */
406
406
  return createLogger();
@@ -1059,6 +1059,10 @@ function getCodecTiers(levels, audioTracksByGroup, minAutoLevel, maxAutoLevel) {
1059
1059
  return tiers;
1060
1060
  }, {});
1061
1061
  }
1062
+ function useAlternateAudio(audioTrackUrl, hls) {
1063
+ var _hls$levels$hls$loadL;
1064
+ return !!audioTrackUrl && audioTrackUrl !== ((_hls$levels$hls$loadL = hls.levels[hls.loadLevel]) == null ? void 0 : _hls$levels$hls$loadL.uri);
1065
+ }
1062
1066
 
1063
1067
  class AbrController extends Logger {
1064
1068
  constructor(_hls) {
@@ -15293,19 +15297,23 @@ class MP4Remuxer {
15293
15297
  this.videoTrackConfig = undefined;
15294
15298
  }
15295
15299
  getVideoStartPts(videoSamples) {
15300
+ // Get the minimum PTS value relative to the first sample's PTS, normalized for 33-bit wrapping
15296
15301
  let rolloverDetected = false;
15302
+ const firstPts = videoSamples[0].pts;
15297
15303
  const startPTS = videoSamples.reduce((minPTS, sample) => {
15298
- const delta = sample.pts - minPTS;
15304
+ let pts = sample.pts;
15305
+ let delta = pts - minPTS;
15299
15306
  if (delta < -4294967296) {
15300
15307
  // 2^32, see PTSNormalize for reasoning, but we're hitting a rollover here, and we don't want that to impact the timeOffset calculation
15301
15308
  rolloverDetected = true;
15302
- return normalizePts(minPTS, sample.pts);
15303
- } else if (delta > 0) {
15309
+ pts = normalizePts(pts, firstPts);
15310
+ delta = pts - minPTS;
15311
+ }
15312
+ if (delta > 0) {
15304
15313
  return minPTS;
15305
- } else {
15306
- return sample.pts;
15307
15314
  }
15308
- }, videoSamples[0].pts);
15315
+ return pts;
15316
+ }, firstPts);
15309
15317
  if (rolloverDetected) {
15310
15318
  this.logger.debug('PTS rollover detected');
15311
15319
  }
@@ -19138,7 +19146,7 @@ class GapController extends Logger {
19138
19146
  }
19139
19147
  }
19140
19148
 
19141
- const version = "1.6.0-beta.1.0.canary.10809";
19149
+ const version = "1.6.0-beta.1.0.canary.10811";
19142
19150
 
19143
19151
  // ensure the worker ends up in the bundle
19144
19152
  // If the worker should not be included this gets aliased to empty.js
@@ -20162,9 +20170,10 @@ class StreamController extends BaseStreamController {
20162
20170
  transmuxer.push(payload, initSegmentData, audioCodec, videoCodec, frag, part, details.totalduration, accurateTimeOffset, chunkMeta, initPTS);
20163
20171
  }
20164
20172
  onAudioTrackSwitching(event, data) {
20173
+ const hls = this.hls;
20165
20174
  // if any URL found on new audio track, it is an alternate audio track
20166
20175
  const fromAltAudio = this.altAudio === 2;
20167
- const altAudio = !!data.url;
20176
+ const altAudio = useAlternateAudio(data.url, hls);
20168
20177
  // if we switch on main audio, ensure that main fragment scheduling is synced with media.buffered
20169
20178
  // don't do anything if we switch to alt audio: audio stream controller is handling it.
20170
20179
  // we will just have to change buffer scheduling on audioTrackSwitched
@@ -20187,7 +20196,6 @@ class StreamController extends BaseStreamController {
20187
20196
  // Reset audio transmuxer so when switching back to main audio we're not still appending where we left off
20188
20197
  this.resetTransmuxer();
20189
20198
  }
20190
- const hls = this.hls;
20191
20199
  // If switching from alt to main audio, flush all audio and trigger track switched
20192
20200
  if (fromAltAudio) {
20193
20201
  hls.trigger(Events.BUFFER_FLUSHING, {
@@ -20203,8 +20211,7 @@ class StreamController extends BaseStreamController {
20203
20211
  }
20204
20212
  }
20205
20213
  onAudioTrackSwitched(event, data) {
20206
- const trackId = data.id;
20207
- const altAudio = !!this.hls.audioTracks[trackId].url;
20214
+ const altAudio = useAlternateAudio(data.url, this.hls);
20208
20215
  if (altAudio) {
20209
20216
  const videoBuffer = this.videoBuffer;
20210
20217
  // if we switched on alternate audio, ensure that main fragment scheduling is synced with video sourcebuffer buffered