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.
package/dist/hls.light.js CHANGED
@@ -1028,7 +1028,7 @@
1028
1028
  // Some browsers don't allow to use bind on console object anyway
1029
1029
  // fallback to default if needed
1030
1030
  try {
1031
- newLogger.log("Debug logs enabled for \"" + context + "\" in hls.js version " + "1.6.0-beta.1.0.canary.10809");
1031
+ newLogger.log("Debug logs enabled for \"" + context + "\" in hls.js version " + "1.6.0-beta.1.0.canary.10811");
1032
1032
  } catch (e) {
1033
1033
  /* log fn threw an exception. All logger methods are no-ops. */
1034
1034
  return createLogger();
@@ -1749,6 +1749,10 @@
1749
1749
  return tiers;
1750
1750
  }, {});
1751
1751
  }
1752
+ function useAlternateAudio(audioTrackUrl, hls) {
1753
+ var _hls$levels$hls$loadL;
1754
+ return !!audioTrackUrl && audioTrackUrl !== ((_hls$levels$hls$loadL = hls.levels[hls.loadLevel]) == null ? void 0 : _hls$levels$hls$loadL.uri);
1755
+ }
1752
1756
 
1753
1757
  var AbrController = /*#__PURE__*/function (_Logger) {
1754
1758
  function AbrController(_hls) {
@@ -13003,19 +13007,23 @@
13003
13007
  this.videoTrackConfig = undefined;
13004
13008
  };
13005
13009
  _proto.getVideoStartPts = function getVideoStartPts(videoSamples) {
13010
+ // Get the minimum PTS value relative to the first sample's PTS, normalized for 33-bit wrapping
13006
13011
  var rolloverDetected = false;
13012
+ var firstPts = videoSamples[0].pts;
13007
13013
  var startPTS = videoSamples.reduce(function (minPTS, sample) {
13008
- var delta = sample.pts - minPTS;
13014
+ var pts = sample.pts;
13015
+ var delta = pts - minPTS;
13009
13016
  if (delta < -4294967296) {
13010
13017
  // 2^32, see PTSNormalize for reasoning, but we're hitting a rollover here, and we don't want that to impact the timeOffset calculation
13011
13018
  rolloverDetected = true;
13012
- return normalizePts(minPTS, sample.pts);
13013
- } else if (delta > 0) {
13019
+ pts = normalizePts(pts, firstPts);
13020
+ delta = pts - minPTS;
13021
+ }
13022
+ if (delta > 0) {
13014
13023
  return minPTS;
13015
- } else {
13016
- return sample.pts;
13017
13024
  }
13018
- }, videoSamples[0].pts);
13025
+ return pts;
13026
+ }, firstPts);
13019
13027
  if (rolloverDetected) {
13020
13028
  this.logger.debug('PTS rollover detected');
13021
13029
  }
@@ -19758,7 +19766,7 @@
19758
19766
  return !remuxResult.audio && !remuxResult.video && !remuxResult.text && !remuxResult.id3 && !remuxResult.initSegment;
19759
19767
  }
19760
19768
 
19761
- var version = "1.6.0-beta.1.0.canary.10809";
19769
+ var version = "1.6.0-beta.1.0.canary.10811";
19762
19770
 
19763
19771
  // ensure the worker ends up in the bundle
19764
19772
  // If the worker should not be included this gets aliased to empty.js
@@ -20752,9 +20760,10 @@
20752
20760
  transmuxer.push(payload, initSegmentData, audioCodec, videoCodec, frag, part, details.totalduration, accurateTimeOffset, chunkMeta, initPTS);
20753
20761
  };
20754
20762
  _proto.onAudioTrackSwitching = function onAudioTrackSwitching(event, data) {
20763
+ var hls = this.hls;
20755
20764
  // if any URL found on new audio track, it is an alternate audio track
20756
20765
  var fromAltAudio = this.altAudio === 2;
20757
- var altAudio = !!data.url;
20766
+ var altAudio = useAlternateAudio(data.url, hls);
20758
20767
  // if we switch on main audio, ensure that main fragment scheduling is synced with media.buffered
20759
20768
  // don't do anything if we switch to alt audio: audio stream controller is handling it.
20760
20769
  // we will just have to change buffer scheduling on audioTrackSwitched
@@ -20777,7 +20786,6 @@
20777
20786
  // Reset audio transmuxer so when switching back to main audio we're not still appending where we left off
20778
20787
  this.resetTransmuxer();
20779
20788
  }
20780
- var hls = this.hls;
20781
20789
  // If switching from alt to main audio, flush all audio and trigger track switched
20782
20790
  if (fromAltAudio) {
20783
20791
  hls.trigger(Events.BUFFER_FLUSHING, {
@@ -20793,8 +20801,7 @@
20793
20801
  }
20794
20802
  };
20795
20803
  _proto.onAudioTrackSwitched = function onAudioTrackSwitched(event, data) {
20796
- var trackId = data.id;
20797
- var altAudio = !!this.hls.audioTracks[trackId].url;
20804
+ var altAudio = useAlternateAudio(data.url, this.hls);
20798
20805
  if (altAudio) {
20799
20806
  var videoBuffer = this.videoBuffer;
20800
20807
  // if we switched on alternate audio, ensure that main fragment scheduling is synced with video sourcebuffer buffered