hls.js 1.5.2 → 1.5.4

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
@@ -552,7 +552,7 @@
552
552
  // Some browsers don't allow to use bind on console object anyway
553
553
  // fallback to default if needed
554
554
  try {
555
- exportedLogger.log("Debug logs enabled for \"" + id + "\" in hls.js version " + "1.5.2");
555
+ exportedLogger.log("Debug logs enabled for \"" + id + "\" in hls.js version " + "1.5.4");
556
556
  } catch (e) {
557
557
  exportedLogger = fakeLogger;
558
558
  }
@@ -1774,6 +1774,12 @@
1774
1774
  var val = readSint32(buffer, offset);
1775
1775
  return val < 0 ? 4294967296 + val : val;
1776
1776
  }
1777
+ function readUint64(buffer, offset) {
1778
+ var result = readUint32(buffer, offset);
1779
+ result *= Math.pow(2, 32);
1780
+ result += readUint32(buffer, offset + 4);
1781
+ return result;
1782
+ }
1777
1783
  function readSint32(buffer, offset) {
1778
1784
  return buffer[offset] << 24 | buffer[offset + 1] << 16 | buffer[offset + 2] << 8 | buffer[offset + 3];
1779
1785
  }
@@ -1836,15 +1842,14 @@
1836
1842
  var index = 8;
1837
1843
  var timescale = readUint32(sidx, index);
1838
1844
  index += 4;
1839
-
1840
- // TODO: parse earliestPresentationTime and firstOffset
1841
- // usually zero in our case
1842
1845
  var earliestPresentationTime = 0;
1843
1846
  var firstOffset = 0;
1844
1847
  if (version === 0) {
1845
- index += 8;
1848
+ earliestPresentationTime = readUint32(sidx, index += 4);
1849
+ firstOffset = readUint32(sidx, index += 4);
1846
1850
  } else {
1847
- index += 16;
1851
+ earliestPresentationTime = readUint64(sidx, index += 8);
1852
+ firstOffset = readUint64(sidx, index += 8);
1848
1853
  }
1849
1854
 
1850
1855
  // skip reserved
@@ -2294,17 +2299,24 @@
2294
2299
  }
2295
2300
  if (videoDuration === 0 && audioDuration === 0) {
2296
2301
  // If duration samples are not available in the traf use sidx subsegment_duration
2302
+ var sidxMinStart = Infinity;
2303
+ var sidxMaxEnd = 0;
2297
2304
  var sidxDuration = 0;
2298
2305
  var sidxs = findBox(data, ['sidx']);
2299
2306
  for (var _i2 = 0; _i2 < sidxs.length; _i2++) {
2300
2307
  var sidx = parseSegmentIndex(sidxs[_i2]);
2301
2308
  if (sidx != null && sidx.references) {
2302
- sidxDuration += sidx.references.reduce(function (dur, ref) {
2309
+ sidxMinStart = Math.min(sidxMinStart, sidx.earliestPresentationTime / sidx.timescale);
2310
+ var subSegmentDuration = sidx.references.reduce(function (dur, ref) {
2303
2311
  return dur + ref.info.duration || 0;
2304
2312
  }, 0);
2313
+ sidxMaxEnd = Math.max(sidxMaxEnd, subSegmentDuration + sidx.earliestPresentationTime / sidx.timescale);
2314
+ sidxDuration = sidxMaxEnd - sidxMinStart;
2305
2315
  }
2306
2316
  }
2307
- return sidxDuration;
2317
+ if (sidxDuration && isFiniteNumber(sidxDuration)) {
2318
+ return sidxDuration;
2319
+ }
2308
2320
  }
2309
2321
  if (videoDuration) {
2310
2322
  return videoDuration;
@@ -7613,7 +7625,7 @@
7613
7625
  var ttfbEstimateSec = this.bwEstimator.getEstimateTTFB() / 1000;
7614
7626
  var levelsSkipped = [];
7615
7627
  var _loop = function _loop() {
7616
- var _levelInfo$supportedR, _levelInfo$supportedR2;
7628
+ var _levelInfo$supportedR;
7617
7629
  var levelInfo = levels[i];
7618
7630
  var upSwitch = i > selectionBaseLevel;
7619
7631
  if (!levelInfo) {
@@ -7644,7 +7656,7 @@
7644
7656
 
7645
7657
  // skip candidates which change codec-family or video-range,
7646
7658
  // and which decrease or increase frame-rate for up and down-switch respectfully
7647
- if (currentCodecSet && levelInfo.codecSet !== currentCodecSet || currentVideoRange && levelInfo.videoRange !== currentVideoRange || upSwitch && currentFrameRate > levelInfo.frameRate || !upSwitch && currentFrameRate > 0 && currentFrameRate < levelInfo.frameRate || !((_levelInfo$supportedR = levelInfo.supportedResult) != null && (_levelInfo$supportedR2 = _levelInfo$supportedR.decodingInfoResults) != null && _levelInfo$supportedR2[0].smooth)) {
7659
+ if (currentCodecSet && levelInfo.codecSet !== currentCodecSet || currentVideoRange && levelInfo.videoRange !== currentVideoRange || upSwitch && currentFrameRate > levelInfo.frameRate || !upSwitch && currentFrameRate > 0 && currentFrameRate < levelInfo.frameRate || levelInfo.supportedResult && !((_levelInfo$supportedR = levelInfo.supportedResult.decodingInfoResults) != null && _levelInfo$supportedR[0].smooth)) {
7648
7660
  levelsSkipped.push(i);
7649
7661
  return 0; // continue
7650
7662
  }
@@ -7757,8 +7769,11 @@
7757
7769
  return nextABRAutoLevel;
7758
7770
  },
7759
7771
  set: function set(nextLevel) {
7760
- var value = Math.max(this.hls.minAutoLevel, nextLevel);
7761
- if (this._nextAutoLevel != value) {
7772
+ var _this$hls3 = this.hls,
7773
+ maxAutoLevel = _this$hls3.maxAutoLevel,
7774
+ minAutoLevel = _this$hls3.minAutoLevel;
7775
+ var value = Math.min(Math.max(nextLevel, minAutoLevel), maxAutoLevel);
7776
+ if (this._nextAutoLevel !== value) {
7762
7777
  this.nextAutoLevelKey = '';
7763
7778
  this._nextAutoLevel = value;
7764
7779
  }
@@ -16583,7 +16598,7 @@
16583
16598
 
16584
16599
  // compute start position if we are aligned with the main playlist
16585
16600
  if (!this.startFragRequested && (this.mainDetails || !newDetails.live)) {
16586
- this.setStartPosition(track.details, sliding);
16601
+ this.setStartPosition(this.mainDetails || newDetails, sliding);
16587
16602
  }
16588
16603
  // only switch back to IDLE state if we were waiting for track to start downloading a new fragment
16589
16604
  if (this.state === State.WAITING_TRACK && !this.waitForCdnTuneIn(newDetails)) {
@@ -17486,7 +17501,7 @@
17486
17501
  track.details = newDetails;
17487
17502
  this.levelLastLoaded = track;
17488
17503
  if (!this.startFragRequested && (this.mainDetails || !newDetails.live)) {
17489
- this.setStartPosition(track.details, sliding);
17504
+ this.setStartPosition(this.mainDetails || newDetails, sliding);
17490
17505
  }
17491
17506
 
17492
17507
  // trigger handler right now
@@ -27260,7 +27275,8 @@
27260
27275
  }
27261
27276
  // set new level to playlist loader : this will trigger start level load
27262
27277
  // hls.nextLoadLevel remains until it is set to a new value or until a new frag is successfully loaded
27263
- this.level = hls.nextLoadLevel = startLevel;
27278
+ hls.nextLoadLevel = startLevel;
27279
+ this.level = hls.loadLevel;
27264
27280
  this.loadedmetadata = false;
27265
27281
  }
27266
27282
  // if startPosition undefined but lastCurrentTime set, set startPosition to last currentTime
@@ -29166,7 +29182,7 @@
29166
29182
  * Get the video-dev/hls.js package version.
29167
29183
  */
29168
29184
  function get() {
29169
- return "1.5.2";
29185
+ return "1.5.4";
29170
29186
  }
29171
29187
  }, {
29172
29188
  key: "Events",