hls.js 1.5.12-0.canary.10352 → 1.5.12-0.canary.10355

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.
@@ -420,7 +420,7 @@ function enableLogs(debugConfig, context, id) {
420
420
  // Some browsers don't allow to use bind on console object anyway
421
421
  // fallback to default if needed
422
422
  try {
423
- newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.5.12-0.canary.10352"}`);
423
+ newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.5.12-0.canary.10355"}`);
424
424
  } catch (e) {
425
425
  /* log fn threw an exception. All logger methods are no-ops. */
426
426
  return createLogger();
@@ -14682,6 +14682,20 @@ class BaseVideoParser {
14682
14682
  length: 0
14683
14683
  };
14684
14684
  }
14685
+ getLastNalUnit(samples) {
14686
+ var _VideoSample;
14687
+ let VideoSample = this.VideoSample;
14688
+ let lastUnit;
14689
+ // try to fallback to previous sample if current one is empty
14690
+ if (!VideoSample || VideoSample.units.length === 0) {
14691
+ VideoSample = samples[samples.length - 1];
14692
+ }
14693
+ if ((_VideoSample = VideoSample) != null && _VideoSample.units) {
14694
+ const units = VideoSample.units;
14695
+ lastUnit = units[units.length - 1];
14696
+ }
14697
+ return lastUnit;
14698
+ }
14685
14699
  pushAccessUnit(VideoSample, videoTrack) {
14686
14700
  if (VideoSample.units.length && VideoSample.frame) {
14687
14701
  // if sample does not have PTS/DTS, patch with last sample PTS/DTS
@@ -14704,7 +14718,7 @@ class BaseVideoParser {
14704
14718
  logger.log(VideoSample.pts + '/' + VideoSample.dts + ':' + VideoSample.debug);
14705
14719
  }
14706
14720
  }
14707
- parseNALu(track, array, last) {
14721
+ parseNALu(track, array, endOfSegment) {
14708
14722
  const len = array.byteLength;
14709
14723
  let state = track.naluState || 0;
14710
14724
  const lastState = state;
@@ -14746,10 +14760,6 @@ class BaseVideoParser {
14746
14760
  data: array.subarray(lastUnitStart, overflow),
14747
14761
  type: lastUnitType
14748
14762
  };
14749
- if (track.lastNalu) {
14750
- units.push(track.lastNalu);
14751
- track.lastNalu = null;
14752
- }
14753
14763
  // logger.log('pushing NALU, type/size:' + unit.type + '/' + unit.data.byteLength);
14754
14764
  units.push(unit);
14755
14765
  } else {
@@ -14757,7 +14767,7 @@ class BaseVideoParser {
14757
14767
  // first check if start code delimiter is overlapping between 2 PES packets,
14758
14768
  // ie it started in last packet (lastState not zero)
14759
14769
  // and ended at the beginning of this PES packet (i <= 4 - lastState)
14760
- const lastUnit = track.lastNalu;
14770
+ const lastUnit = this.getLastNalUnit(track.samples);
14761
14771
  if (lastUnit) {
14762
14772
  if (lastState && i <= 4 - lastState) {
14763
14773
  // start delimiter overlapping between PES packets
@@ -14774,8 +14784,6 @@ class BaseVideoParser {
14774
14784
  // logger.log('first NALU found with overflow:' + overflow);
14775
14785
  lastUnit.data = appendUint8Array(lastUnit.data, array.subarray(0, overflow));
14776
14786
  lastUnit.state = 0;
14777
- units.push(lastUnit);
14778
- track.lastNalu = null;
14779
14787
  }
14780
14788
  }
14781
14789
  }
@@ -14800,21 +14808,15 @@ class BaseVideoParser {
14800
14808
  type: lastUnitType,
14801
14809
  state: state
14802
14810
  };
14803
- if (!last) {
14804
- track.lastNalu = unit;
14805
- // logger.log('store NALu to push it on next PES');
14806
- } else {
14807
- units.push(unit);
14808
- // logger.log('pushing NALU, type/size/state:' + unit.type + '/' + unit.data.byteLength + '/' + state);
14809
- }
14810
- } else if (units.length === 0) {
14811
- // no NALu found
14811
+ units.push(unit);
14812
+ // logger.log('pushing NALU, type/size/state:' + unit.type + '/' + unit.data.byteLength + '/' + state);
14813
+ }
14814
+ // no NALu found
14815
+ if (units.length === 0) {
14812
14816
  // append pes.data to previous NAL unit
14813
- const lastUnit = track.lastNalu;
14817
+ const lastUnit = this.getLastNalUnit(track.samples);
14814
14818
  if (lastUnit) {
14815
14819
  lastUnit.data = appendUint8Array(lastUnit.data, array);
14816
- units.push(lastUnit);
14817
- track.lastNalu = null;
14818
14820
  }
14819
14821
  }
14820
14822
  track.naluState = state;
@@ -14965,8 +14967,8 @@ class ExpGolomb {
14965
14967
  }
14966
14968
 
14967
14969
  class AvcVideoParser extends BaseVideoParser {
14968
- parsePES(track, textTrack, pes, last, duration) {
14969
- const units = this.parseNALu(track, pes.data, last);
14970
+ parsePES(track, textTrack, pes, endOfSegment, duration) {
14971
+ const units = this.parseNALu(track, pes.data, endOfSegment);
14970
14972
  let VideoSample = this.VideoSample;
14971
14973
  let push;
14972
14974
  let spsfound = false;
@@ -15096,7 +15098,7 @@ class AvcVideoParser extends BaseVideoParser {
15096
15098
  }
15097
15099
  });
15098
15100
  // if last PES packet, push samples
15099
- if (last && VideoSample) {
15101
+ if (endOfSegment && VideoSample) {
15100
15102
  this.pushAccessUnit(VideoSample, track);
15101
15103
  this.VideoSample = null;
15102
15104
  }
@@ -20576,7 +20578,7 @@ class Hls {
20576
20578
  * Get the video-dev/hls.js package version.
20577
20579
  */
20578
20580
  static get version() {
20579
- return "1.5.12-0.canary.10352";
20581
+ return "1.5.12-0.canary.10355";
20580
20582
  }
20581
20583
 
20582
20584
  /**