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.js CHANGED
@@ -1057,7 +1057,7 @@
1057
1057
  // Some browsers don't allow to use bind on console object anyway
1058
1058
  // fallback to default if needed
1059
1059
  try {
1060
- newLogger.log("Debug logs enabled for \"" + context + "\" in hls.js version " + "1.6.0-beta.1.0.canary.10809");
1060
+ newLogger.log("Debug logs enabled for \"" + context + "\" in hls.js version " + "1.6.0-beta.1.0.canary.10811");
1061
1061
  } catch (e) {
1062
1062
  /* log fn threw an exception. All logger methods are no-ops. */
1063
1063
  return createLogger();
@@ -2047,6 +2047,10 @@
2047
2047
  }
2048
2048
  return -1;
2049
2049
  }
2050
+ function useAlternateAudio(audioTrackUrl, hls) {
2051
+ var _hls$levels$hls$loadL;
2052
+ return !!audioTrackUrl && audioTrackUrl !== ((_hls$levels$hls$loadL = hls.levels[hls.loadLevel]) == null ? void 0 : _hls$levels$hls$loadL.uri);
2053
+ }
2050
2054
 
2051
2055
  var AbrController = /*#__PURE__*/function (_Logger) {
2052
2056
  function AbrController(_hls) {
@@ -14743,19 +14747,23 @@
14743
14747
  this.videoTrackConfig = undefined;
14744
14748
  };
14745
14749
  _proto.getVideoStartPts = function getVideoStartPts(videoSamples) {
14750
+ // Get the minimum PTS value relative to the first sample's PTS, normalized for 33-bit wrapping
14746
14751
  var rolloverDetected = false;
14752
+ var firstPts = videoSamples[0].pts;
14747
14753
  var startPTS = videoSamples.reduce(function (minPTS, sample) {
14748
- var delta = sample.pts - minPTS;
14754
+ var pts = sample.pts;
14755
+ var delta = pts - minPTS;
14749
14756
  if (delta < -4294967296) {
14750
14757
  // 2^32, see PTSNormalize for reasoning, but we're hitting a rollover here, and we don't want that to impact the timeOffset calculation
14751
14758
  rolloverDetected = true;
14752
- return normalizePts(minPTS, sample.pts);
14753
- } else if (delta > 0) {
14759
+ pts = normalizePts(pts, firstPts);
14760
+ delta = pts - minPTS;
14761
+ }
14762
+ if (delta > 0) {
14754
14763
  return minPTS;
14755
- } else {
14756
- return sample.pts;
14757
14764
  }
14758
- }, videoSamples[0].pts);
14765
+ return pts;
14766
+ }, firstPts);
14759
14767
  if (rolloverDetected) {
14760
14768
  this.logger.debug('PTS rollover detected');
14761
14769
  }
@@ -16288,7 +16296,7 @@
16288
16296
  return !remuxResult.audio && !remuxResult.video && !remuxResult.text && !remuxResult.id3 && !remuxResult.initSegment;
16289
16297
  }
16290
16298
 
16291
- var version = "1.6.0-beta.1.0.canary.10809";
16299
+ var version = "1.6.0-beta.1.0.canary.10811";
16292
16300
 
16293
16301
  // ensure the worker ends up in the bundle
16294
16302
  // If the worker should not be included this gets aliased to empty.js
@@ -17992,17 +18000,15 @@
17992
18000
  return -1;
17993
18001
  };
17994
18002
  _proto.loadPlaylist = function loadPlaylist(hlsUrlParameters) {
17995
- var _this$hls$levels$this;
17996
18003
  _BasePlaylistControll.prototype.loadPlaylist.call(this);
17997
18004
  var audioTrack = this.currentTrack;
17998
18005
  if (!this.shouldLoadPlaylist(audioTrack)) {
17999
18006
  return;
18000
18007
  }
18001
- if (audioTrack.url === ((_this$hls$levels$this = this.hls.levels[this.hls.loadLevel]) == null ? void 0 : _this$hls$levels$this.uri)) {
18002
- // Do not load audio rendition with URI matching main variant URI
18003
- return;
18008
+ // Do not load audio rendition with URI matching main variant URI
18009
+ if (useAlternateAudio(audioTrack.url, this.hls)) {
18010
+ this.scheduleLoading(audioTrack, hlsUrlParameters);
18004
18011
  }
18005
- this.scheduleLoading(audioTrack, hlsUrlParameters);
18006
18012
  };
18007
18013
  _proto.loadingPlaylist = function loadingPlaylist(audioTrack, hlsUrlParameters) {
18008
18014
  _BasePlaylistControll.prototype.loadingPlaylist.call(this, audioTrack, hlsUrlParameters);
@@ -24517,6 +24523,10 @@
24517
24523
  this.hls.on(Events.BUFFER_CODECS, this.onBufferCodecs, this);
24518
24524
  };
24519
24525
  _proto.onLevelUpdated = function onLevelUpdated(event, data) {
24526
+ if (data.level === -1) {
24527
+ // level was removed
24528
+ return;
24529
+ }
24520
24530
  var main = this.hls.levels[data.level];
24521
24531
  var currentSelection = _objectSpread2(_objectSpread2({}, this.mediaSelection || this.altSelection), {}, {
24522
24532
  main: main
@@ -32613,9 +32623,10 @@
32613
32623
  transmuxer.push(payload, initSegmentData, audioCodec, videoCodec, frag, part, details.totalduration, accurateTimeOffset, chunkMeta, initPTS);
32614
32624
  };
32615
32625
  _proto.onAudioTrackSwitching = function onAudioTrackSwitching(event, data) {
32626
+ var hls = this.hls;
32616
32627
  // if any URL found on new audio track, it is an alternate audio track
32617
32628
  var fromAltAudio = this.altAudio === 2;
32618
- var altAudio = !!data.url;
32629
+ var altAudio = useAlternateAudio(data.url, hls);
32619
32630
  // if we switch on main audio, ensure that main fragment scheduling is synced with media.buffered
32620
32631
  // don't do anything if we switch to alt audio: audio stream controller is handling it.
32621
32632
  // we will just have to change buffer scheduling on audioTrackSwitched
@@ -32638,7 +32649,6 @@
32638
32649
  // Reset audio transmuxer so when switching back to main audio we're not still appending where we left off
32639
32650
  this.resetTransmuxer();
32640
32651
  }
32641
- var hls = this.hls;
32642
32652
  // If switching from alt to main audio, flush all audio and trigger track switched
32643
32653
  if (fromAltAudio) {
32644
32654
  hls.trigger(Events.BUFFER_FLUSHING, {
@@ -32654,8 +32664,7 @@
32654
32664
  }
32655
32665
  };
32656
32666
  _proto.onAudioTrackSwitched = function onAudioTrackSwitched(event, data) {
32657
- var trackId = data.id;
32658
- var altAudio = !!this.hls.audioTracks[trackId].url;
32667
+ var altAudio = useAlternateAudio(data.url, this.hls);
32659
32668
  if (altAudio) {
32660
32669
  var videoBuffer = this.videoBuffer;
32661
32670
  // if we switched on alternate audio, ensure that main fragment scheduling is synced with video sourcebuffer buffered