hls.js 1.6.0-beta.1.0.canary.10808 → 1.6.0-beta.1.0.canary.10810

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.10808");
1060
+ newLogger.log("Debug logs enabled for \"" + context + "\" in hls.js version " + "1.6.0-beta.1.0.canary.10810");
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) {
@@ -5862,7 +5866,8 @@
5862
5866
  var _this = this;
5863
5867
  if (this.useSoftware) {
5864
5868
  return new Promise(function (resolve, reject) {
5865
- _this.softwareDecrypt(new Uint8Array(data), key, iv, aesMode);
5869
+ var dataView = ArrayBuffer.isView(data) ? data : new Uint8Array(data);
5870
+ _this.softwareDecrypt(dataView, key, iv, aesMode);
5866
5871
  var decryptResult = _this.flush();
5867
5872
  if (decryptResult) {
5868
5873
  resolve(decryptResult.buffer);
@@ -15844,7 +15849,8 @@
15844
15849
  // For Low-Latency HLS Parts, decrypt in place, since part parsing is expected on push progress
15845
15850
  var loadingParts = chunkMeta.part > -1;
15846
15851
  if (loadingParts) {
15847
- decryptedData = decrypter.flush();
15852
+ var _data = decrypter.flush();
15853
+ decryptedData = _data ? _data.buffer : _data;
15848
15854
  }
15849
15855
  if (!decryptedData) {
15850
15856
  stats.executeEnd = now();
@@ -15924,7 +15930,7 @@
15924
15930
  var decryptedData = decrypter.flush();
15925
15931
  if (decryptedData) {
15926
15932
  // Push always returns a TransmuxerResult if decryptdata is null
15927
- transmuxResults.push(this.push(decryptedData, null, chunkMeta));
15933
+ transmuxResults.push(this.push(decryptedData.buffer, null, chunkMeta));
15928
15934
  }
15929
15935
  }
15930
15936
  var demuxer = this.demuxer,
@@ -16286,7 +16292,7 @@
16286
16292
  return !remuxResult.audio && !remuxResult.video && !remuxResult.text && !remuxResult.id3 && !remuxResult.initSegment;
16287
16293
  }
16288
16294
 
16289
- var version = "1.6.0-beta.1.0.canary.10808";
16295
+ var version = "1.6.0-beta.1.0.canary.10810";
16290
16296
 
16291
16297
  // ensure the worker ends up in the bundle
16292
16298
  // If the worker should not be included this gets aliased to empty.js
@@ -16852,7 +16858,7 @@
16852
16858
  if (this.initPTS[frag.cc] !== undefined) {
16853
16859
  this.waitingData = null;
16854
16860
  this.state = State.FRAG_LOADING;
16855
- var payload = cache.flush();
16861
+ var payload = cache.flush().buffer;
16856
16862
  var data = {
16857
16863
  frag: frag,
16858
16864
  part: part,
@@ -17990,17 +17996,15 @@
17990
17996
  return -1;
17991
17997
  };
17992
17998
  _proto.loadPlaylist = function loadPlaylist(hlsUrlParameters) {
17993
- var _this$hls$levels$this;
17994
17999
  _BasePlaylistControll.prototype.loadPlaylist.call(this);
17995
18000
  var audioTrack = this.currentTrack;
17996
18001
  if (!this.shouldLoadPlaylist(audioTrack)) {
17997
18002
  return;
17998
18003
  }
17999
- if (audioTrack.url === ((_this$hls$levels$this = this.hls.levels[this.hls.loadLevel]) == null ? void 0 : _this$hls$levels$this.uri)) {
18000
- // Do not load audio rendition with URI matching main variant URI
18001
- return;
18004
+ // Do not load audio rendition with URI matching main variant URI
18005
+ if (useAlternateAudio(audioTrack.url, this.hls)) {
18006
+ this.scheduleLoading(audioTrack, hlsUrlParameters);
18002
18007
  }
18003
- this.scheduleLoading(audioTrack, hlsUrlParameters);
18004
18008
  };
18005
18009
  _proto.loadingPlaylist = function loadingPlaylist(audioTrack, hlsUrlParameters) {
18006
18010
  _BasePlaylistControll.prototype.loadingPlaylist.call(this, audioTrack, hlsUrlParameters);
@@ -21736,7 +21740,7 @@
21736
21740
  var json = bin2str(new Uint8Array(initData));
21737
21741
  try {
21738
21742
  var sinf = base64Decode(JSON.parse(json).sinf);
21739
- var tenc = parseSinf(new Uint8Array(sinf));
21743
+ var tenc = parseSinf(sinf);
21740
21744
  if (!tenc) {
21741
21745
  throw new Error("'schm' box missing or not cbcs/cenc with schi > tenc");
21742
21746
  }
@@ -22022,7 +22026,7 @@
22022
22026
  var keySessionContext = this.createMediaKeySessionContext(mediaKeySessionContext);
22023
22027
  var keyId = this.getKeyIdString(decryptdata);
22024
22028
  var scheme = 'cenc';
22025
- this.keyIdToKeySessionPromise[keyId] = this.generateRequestWithPreferredKeySession(keySessionContext, scheme, decryptdata.pssh, 'expired');
22029
+ this.keyIdToKeySessionPromise[keyId] = this.generateRequestWithPreferredKeySession(keySessionContext, scheme, decryptdata.pssh.buffer, 'expired');
22026
22030
  } else {
22027
22031
  this.warn("Could not renew expired session. Missing pssh initData.");
22028
22032
  }
@@ -22093,7 +22097,8 @@
22093
22097
  });
22094
22098
  var keySessionContextPromise = this.keyIdToKeySessionPromise[keyId] = keyContextPromise.then(function (keySessionContext) {
22095
22099
  var scheme = 'cenc';
22096
- return _this6.generateRequestWithPreferredKeySession(keySessionContext, scheme, decryptdata.pssh, 'playlist-key');
22100
+ var initData = decryptdata.pssh ? decryptdata.pssh.buffer : null;
22101
+ return _this6.generateRequestWithPreferredKeySession(keySessionContext, scheme, initData, 'playlist-key');
22097
22102
  });
22098
22103
  keySessionContextPromise.catch(function (error) {
22099
22104
  return _this6.handleError(error);
@@ -22180,7 +22185,8 @@
22180
22185
  throw new Error('Invalid response from configured generateRequest filter');
22181
22186
  }
22182
22187
  initDataType = mappedInitData.initDataType;
22183
- initData = context.decryptdata.pssh = mappedInitData.initData ? new Uint8Array(mappedInitData.initData) : null;
22188
+ initData = mappedInitData.initData ? mappedInitData.initData : null;
22189
+ context.decryptdata.pssh = initData ? new Uint8Array(initData) : null;
22184
22190
  } catch (error) {
22185
22191
  var _this$hls;
22186
22192
  this.warn(error.message);
@@ -24513,6 +24519,10 @@
24513
24519
  this.hls.on(Events.BUFFER_CODECS, this.onBufferCodecs, this);
24514
24520
  };
24515
24521
  _proto.onLevelUpdated = function onLevelUpdated(event, data) {
24522
+ if (data.level === -1) {
24523
+ // level was removed
24524
+ return;
24525
+ }
24516
24526
  var main = this.hls.levels[data.level];
24517
24527
  var currentSelection = _objectSpread2(_objectSpread2({}, this.mediaSelection || this.altSelection), {}, {
24518
24528
  main: main
@@ -29352,7 +29362,7 @@
29352
29362
  }
29353
29363
  var hls = this.hls;
29354
29364
  // Parse the WebVTT file contents.
29355
- var payloadWebVTT = (_frag$initSegment = frag.initSegment) != null && _frag$initSegment.data ? appendUint8Array(frag.initSegment.data, new Uint8Array(payload)) : payload;
29365
+ var payloadWebVTT = (_frag$initSegment = frag.initSegment) != null && _frag$initSegment.data ? appendUint8Array(frag.initSegment.data, new Uint8Array(payload)).buffer : payload;
29356
29366
  parseWebVTT(payloadWebVTT, this.initPTS[frag.cc], this.vttCCs, frag.cc, frag.start, function (cues) {
29357
29367
  _this5._appendCues(cues, frag.level);
29358
29368
  hls.trigger(Events.SUBTITLE_FRAG_PROCESSED, {
@@ -29761,7 +29771,7 @@
29761
29771
  return reader.read().then(function (data) {
29762
29772
  if (data.done) {
29763
29773
  if (chunkCache.dataLength) {
29764
- onProgress(stats, context, chunkCache.flush(), response);
29774
+ onProgress(stats, context, chunkCache.flush().buffer, response);
29765
29775
  }
29766
29776
  return Promise.resolve(new ArrayBuffer(0));
29767
29777
  }
@@ -29774,12 +29784,12 @@
29774
29784
  chunkCache.push(chunk);
29775
29785
  if (chunkCache.dataLength >= highWaterMark) {
29776
29786
  // flush in order to join the typed arrays
29777
- onProgress(stats, context, chunkCache.flush(), response);
29787
+ onProgress(stats, context, chunkCache.flush().buffer, response);
29778
29788
  }
29779
29789
  } else {
29780
29790
  // If there's nothing cached already, and the chache is large enough
29781
29791
  // just emit the progress event
29782
- onProgress(stats, context, chunk, response);
29792
+ onProgress(stats, context, chunk.buffer, response);
29783
29793
  }
29784
29794
  return _pump();
29785
29795
  }).catch(function () {
@@ -32609,9 +32619,10 @@
32609
32619
  transmuxer.push(payload, initSegmentData, audioCodec, videoCodec, frag, part, details.totalduration, accurateTimeOffset, chunkMeta, initPTS);
32610
32620
  };
32611
32621
  _proto.onAudioTrackSwitching = function onAudioTrackSwitching(event, data) {
32622
+ var hls = this.hls;
32612
32623
  // if any URL found on new audio track, it is an alternate audio track
32613
32624
  var fromAltAudio = this.altAudio === 2;
32614
- var altAudio = !!data.url;
32625
+ var altAudio = useAlternateAudio(data.url, hls);
32615
32626
  // if we switch on main audio, ensure that main fragment scheduling is synced with media.buffered
32616
32627
  // don't do anything if we switch to alt audio: audio stream controller is handling it.
32617
32628
  // we will just have to change buffer scheduling on audioTrackSwitched
@@ -32634,7 +32645,6 @@
32634
32645
  // Reset audio transmuxer so when switching back to main audio we're not still appending where we left off
32635
32646
  this.resetTransmuxer();
32636
32647
  }
32637
- var hls = this.hls;
32638
32648
  // If switching from alt to main audio, flush all audio and trigger track switched
32639
32649
  if (fromAltAudio) {
32640
32650
  hls.trigger(Events.BUFFER_FLUSHING, {
@@ -32650,8 +32660,7 @@
32650
32660
  }
32651
32661
  };
32652
32662
  _proto.onAudioTrackSwitched = function onAudioTrackSwitched(event, data) {
32653
- var trackId = data.id;
32654
- var altAudio = !!this.hls.audioTracks[trackId].url;
32663
+ var altAudio = useAlternateAudio(data.url, this.hls);
32655
32664
  if (altAudio) {
32656
32665
  var videoBuffer = this.videoBuffer;
32657
32666
  // if we switched on alternate audio, ensure that main fragment scheduling is synced with video sourcebuffer buffered