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.
package/dist/hls.mjs CHANGED
@@ -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();
@@ -11961,6 +11961,20 @@ class BaseVideoParser {
11961
11961
  length: 0
11962
11962
  };
11963
11963
  }
11964
+ getLastNalUnit(samples) {
11965
+ var _VideoSample;
11966
+ let VideoSample = this.VideoSample;
11967
+ let lastUnit;
11968
+ // try to fallback to previous sample if current one is empty
11969
+ if (!VideoSample || VideoSample.units.length === 0) {
11970
+ VideoSample = samples[samples.length - 1];
11971
+ }
11972
+ if ((_VideoSample = VideoSample) != null && _VideoSample.units) {
11973
+ const units = VideoSample.units;
11974
+ lastUnit = units[units.length - 1];
11975
+ }
11976
+ return lastUnit;
11977
+ }
11964
11978
  pushAccessUnit(VideoSample, videoTrack) {
11965
11979
  if (VideoSample.units.length && VideoSample.frame) {
11966
11980
  // if sample does not have PTS/DTS, patch with last sample PTS/DTS
@@ -11983,7 +11997,7 @@ class BaseVideoParser {
11983
11997
  logger.log(VideoSample.pts + '/' + VideoSample.dts + ':' + VideoSample.debug);
11984
11998
  }
11985
11999
  }
11986
- parseNALu(track, array, last) {
12000
+ parseNALu(track, array, endOfSegment) {
11987
12001
  const len = array.byteLength;
11988
12002
  let state = track.naluState || 0;
11989
12003
  const lastState = state;
@@ -12025,10 +12039,6 @@ class BaseVideoParser {
12025
12039
  data: array.subarray(lastUnitStart, overflow),
12026
12040
  type: lastUnitType
12027
12041
  };
12028
- if (track.lastNalu) {
12029
- units.push(track.lastNalu);
12030
- track.lastNalu = null;
12031
- }
12032
12042
  // logger.log('pushing NALU, type/size:' + unit.type + '/' + unit.data.byteLength);
12033
12043
  units.push(unit);
12034
12044
  } else {
@@ -12036,7 +12046,7 @@ class BaseVideoParser {
12036
12046
  // first check if start code delimiter is overlapping between 2 PES packets,
12037
12047
  // ie it started in last packet (lastState not zero)
12038
12048
  // and ended at the beginning of this PES packet (i <= 4 - lastState)
12039
- const lastUnit = track.lastNalu;
12049
+ const lastUnit = this.getLastNalUnit(track.samples);
12040
12050
  if (lastUnit) {
12041
12051
  if (lastState && i <= 4 - lastState) {
12042
12052
  // start delimiter overlapping between PES packets
@@ -12053,8 +12063,6 @@ class BaseVideoParser {
12053
12063
  // logger.log('first NALU found with overflow:' + overflow);
12054
12064
  lastUnit.data = appendUint8Array(lastUnit.data, array.subarray(0, overflow));
12055
12065
  lastUnit.state = 0;
12056
- units.push(lastUnit);
12057
- track.lastNalu = null;
12058
12066
  }
12059
12067
  }
12060
12068
  }
@@ -12079,21 +12087,15 @@ class BaseVideoParser {
12079
12087
  type: lastUnitType,
12080
12088
  state: state
12081
12089
  };
12082
- if (!last) {
12083
- track.lastNalu = unit;
12084
- // logger.log('store NALu to push it on next PES');
12085
- } else {
12086
- units.push(unit);
12087
- // logger.log('pushing NALU, type/size/state:' + unit.type + '/' + unit.data.byteLength + '/' + state);
12088
- }
12089
- } else if (units.length === 0) {
12090
- // no NALu found
12090
+ units.push(unit);
12091
+ // logger.log('pushing NALU, type/size/state:' + unit.type + '/' + unit.data.byteLength + '/' + state);
12092
+ }
12093
+ // no NALu found
12094
+ if (units.length === 0) {
12091
12095
  // append pes.data to previous NAL unit
12092
- const lastUnit = track.lastNalu;
12096
+ const lastUnit = this.getLastNalUnit(track.samples);
12093
12097
  if (lastUnit) {
12094
12098
  lastUnit.data = appendUint8Array(lastUnit.data, array);
12095
- units.push(lastUnit);
12096
- track.lastNalu = null;
12097
12099
  }
12098
12100
  }
12099
12101
  track.naluState = state;
@@ -12244,8 +12246,8 @@ class ExpGolomb {
12244
12246
  }
12245
12247
 
12246
12248
  class AvcVideoParser extends BaseVideoParser {
12247
- parsePES(track, textTrack, pes, last, duration) {
12248
- const units = this.parseNALu(track, pes.data, last);
12249
+ parsePES(track, textTrack, pes, endOfSegment, duration) {
12250
+ const units = this.parseNALu(track, pes.data, endOfSegment);
12249
12251
  let VideoSample = this.VideoSample;
12250
12252
  let push;
12251
12253
  let spsfound = false;
@@ -12375,7 +12377,7 @@ class AvcVideoParser extends BaseVideoParser {
12375
12377
  }
12376
12378
  });
12377
12379
  // if last PES packet, push samples
12378
- if (last && VideoSample) {
12380
+ if (endOfSegment && VideoSample) {
12379
12381
  this.pushAccessUnit(VideoSample, track);
12380
12382
  this.VideoSample = null;
12381
12383
  }
@@ -12574,8 +12576,8 @@ class HevcVideoParser extends BaseVideoParser {
12574
12576
  super(...args);
12575
12577
  this.initVPS = null;
12576
12578
  }
12577
- parsePES(track, textTrack, pes, last, duration) {
12578
- const units = this.parseNALu(track, pes.data, last);
12579
+ parsePES(track, textTrack, pes, endOfSegment, duration) {
12580
+ const units = this.parseNALu(track, pes.data, endOfSegment);
12579
12581
  let VideoSample = this.VideoSample;
12580
12582
  let push;
12581
12583
  let spsfound = false;
@@ -12737,7 +12739,7 @@ class HevcVideoParser extends BaseVideoParser {
12737
12739
  }
12738
12740
  });
12739
12741
  // if last PES packet, push samples
12740
- if (last && VideoSample) {
12742
+ if (endOfSegment && VideoSample) {
12741
12743
  this.pushAccessUnit(VideoSample, track);
12742
12744
  this.VideoSample = null;
12743
12745
  }
@@ -29169,7 +29171,7 @@ class Hls {
29169
29171
  * Get the video-dev/hls.js package version.
29170
29172
  */
29171
29173
  static get version() {
29172
- return "1.5.12-0.canary.10352";
29174
+ return "1.5.12-0.canary.10355";
29173
29175
  }
29174
29176
 
29175
29177
  /**