hls.js 1.5.9-0.canary.10181 → 1.5.9-0.canary.10182

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.mjs CHANGED
@@ -512,7 +512,7 @@ function enableLogs(debugConfig, context, id) {
512
512
  // Some browsers don't allow to use bind on console object anyway
513
513
  // fallback to default if needed
514
514
  try {
515
- newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.5.9-0.canary.10181"}`);
515
+ newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.5.9-0.canary.10182"}`);
516
516
  } catch (e) {
517
517
  /* log fn threw an exception. All logger methods are no-ops. */
518
518
  return createLogger();
@@ -11815,20 +11815,6 @@ class BaseVideoParser {
11815
11815
  length: 0
11816
11816
  };
11817
11817
  }
11818
- getLastNalUnit(samples) {
11819
- var _VideoSample;
11820
- let VideoSample = this.VideoSample;
11821
- let lastUnit;
11822
- // try to fallback to previous sample if current one is empty
11823
- if (!VideoSample || VideoSample.units.length === 0) {
11824
- VideoSample = samples[samples.length - 1];
11825
- }
11826
- if ((_VideoSample = VideoSample) != null && _VideoSample.units) {
11827
- const units = VideoSample.units;
11828
- lastUnit = units[units.length - 1];
11829
- }
11830
- return lastUnit;
11831
- }
11832
11818
  pushAccessUnit(VideoSample, videoTrack) {
11833
11819
  if (VideoSample.units.length && VideoSample.frame) {
11834
11820
  // if sample does not have PTS/DTS, patch with last sample PTS/DTS
@@ -11851,7 +11837,7 @@ class BaseVideoParser {
11851
11837
  logger.log(VideoSample.pts + '/' + VideoSample.dts + ':' + VideoSample.debug);
11852
11838
  }
11853
11839
  }
11854
- parseNALu(track, array) {
11840
+ parseNALu(track, array, last) {
11855
11841
  const len = array.byteLength;
11856
11842
  let state = track.naluState || 0;
11857
11843
  const lastState = state;
@@ -11893,6 +11879,10 @@ class BaseVideoParser {
11893
11879
  data: array.subarray(lastUnitStart, overflow),
11894
11880
  type: lastUnitType
11895
11881
  };
11882
+ if (track.lastNalu) {
11883
+ units.push(track.lastNalu);
11884
+ track.lastNalu = null;
11885
+ }
11896
11886
  // logger.log('pushing NALU, type/size:' + unit.type + '/' + unit.data.byteLength);
11897
11887
  units.push(unit);
11898
11888
  } else {
@@ -11900,7 +11890,7 @@ class BaseVideoParser {
11900
11890
  // first check if start code delimiter is overlapping between 2 PES packets,
11901
11891
  // ie it started in last packet (lastState not zero)
11902
11892
  // and ended at the beginning of this PES packet (i <= 4 - lastState)
11903
- const lastUnit = this.getLastNalUnit(track.samples);
11893
+ const lastUnit = track.lastNalu;
11904
11894
  if (lastUnit) {
11905
11895
  if (lastState && i <= 4 - lastState) {
11906
11896
  // start delimiter overlapping between PES packets
@@ -11917,6 +11907,8 @@ class BaseVideoParser {
11917
11907
  // logger.log('first NALU found with overflow:' + overflow);
11918
11908
  lastUnit.data = appendUint8Array(lastUnit.data, array.subarray(0, overflow));
11919
11909
  lastUnit.state = 0;
11910
+ units.push(lastUnit);
11911
+ track.lastNalu = null;
11920
11912
  }
11921
11913
  }
11922
11914
  }
@@ -11941,15 +11933,21 @@ class BaseVideoParser {
11941
11933
  type: lastUnitType,
11942
11934
  state: state
11943
11935
  };
11944
- units.push(unit);
11945
- // logger.log('pushing NALU, type/size/state:' + unit.type + '/' + unit.data.byteLength + '/' + state);
11946
- }
11947
- // no NALu found
11948
- if (units.length === 0) {
11936
+ if (!last) {
11937
+ track.lastNalu = unit;
11938
+ // logger.log('store NALu to push it on next PES');
11939
+ } else {
11940
+ units.push(unit);
11941
+ // logger.log('pushing NALU, type/size/state:' + unit.type + '/' + unit.data.byteLength + '/' + state);
11942
+ }
11943
+ } else if (units.length === 0) {
11944
+ // no NALu found
11949
11945
  // append pes.data to previous NAL unit
11950
- const lastUnit = this.getLastNalUnit(track.samples);
11946
+ const lastUnit = track.lastNalu;
11951
11947
  if (lastUnit) {
11952
11948
  lastUnit.data = appendUint8Array(lastUnit.data, array);
11949
+ units.push(lastUnit);
11950
+ track.lastNalu = null;
11953
11951
  }
11954
11952
  }
11955
11953
  track.naluState = state;
@@ -12101,7 +12099,7 @@ class ExpGolomb {
12101
12099
 
12102
12100
  class AvcVideoParser extends BaseVideoParser {
12103
12101
  parsePES(track, textTrack, pes, last, duration) {
12104
- const units = this.parseNALu(track, pes.data);
12102
+ const units = this.parseNALu(track, pes.data, last);
12105
12103
  let VideoSample = this.VideoSample;
12106
12104
  let push;
12107
12105
  let spsfound = false;
@@ -12431,7 +12429,7 @@ class HevcVideoParser extends BaseVideoParser {
12431
12429
  this.initVPS = null;
12432
12430
  }
12433
12431
  parsePES(track, textTrack, pes, last, duration) {
12434
- const units = this.parseNALu(track, pes.data);
12432
+ const units = this.parseNALu(track, pes.data, last);
12435
12433
  let VideoSample = this.VideoSample;
12436
12434
  let push;
12437
12435
  let spsfound = false;
@@ -29012,7 +29010,7 @@ class Hls {
29012
29010
  * Get the video-dev/hls.js package version.
29013
29011
  */
29014
29012
  static get version() {
29015
- return "1.5.9-0.canary.10181";
29013
+ return "1.5.9-0.canary.10182";
29016
29014
  }
29017
29015
 
29018
29016
  /**