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.light.js CHANGED
@@ -493,7 +493,7 @@
493
493
  // Some browsers don't allow to use bind on console object anyway
494
494
  // fallback to default if needed
495
495
  try {
496
- newLogger.log("Debug logs enabled for \"" + context + "\" in hls.js version " + "1.5.12-0.canary.10352");
496
+ newLogger.log("Debug logs enabled for \"" + context + "\" in hls.js version " + "1.5.12-0.canary.10355");
497
497
  } catch (e) {
498
498
  /* log fn threw an exception. All logger methods are no-ops. */
499
499
  return createLogger();
@@ -14984,6 +14984,20 @@
14984
14984
  length: 0
14985
14985
  };
14986
14986
  };
14987
+ _proto.getLastNalUnit = function getLastNalUnit(samples) {
14988
+ var _VideoSample;
14989
+ var VideoSample = this.VideoSample;
14990
+ var lastUnit;
14991
+ // try to fallback to previous sample if current one is empty
14992
+ if (!VideoSample || VideoSample.units.length === 0) {
14993
+ VideoSample = samples[samples.length - 1];
14994
+ }
14995
+ if ((_VideoSample = VideoSample) != null && _VideoSample.units) {
14996
+ var units = VideoSample.units;
14997
+ lastUnit = units[units.length - 1];
14998
+ }
14999
+ return lastUnit;
15000
+ };
14987
15001
  _proto.pushAccessUnit = function pushAccessUnit(VideoSample, videoTrack) {
14988
15002
  if (VideoSample.units.length && VideoSample.frame) {
14989
15003
  // if sample does not have PTS/DTS, patch with last sample PTS/DTS
@@ -15006,7 +15020,7 @@
15006
15020
  logger.log(VideoSample.pts + '/' + VideoSample.dts + ':' + VideoSample.debug);
15007
15021
  }
15008
15022
  };
15009
- _proto.parseNALu = function parseNALu(track, array, last) {
15023
+ _proto.parseNALu = function parseNALu(track, array, endOfSegment) {
15010
15024
  var len = array.byteLength;
15011
15025
  var state = track.naluState || 0;
15012
15026
  var lastState = state;
@@ -15048,10 +15062,6 @@
15048
15062
  data: array.subarray(lastUnitStart, overflow),
15049
15063
  type: lastUnitType
15050
15064
  };
15051
- if (track.lastNalu) {
15052
- units.push(track.lastNalu);
15053
- track.lastNalu = null;
15054
- }
15055
15065
  // logger.log('pushing NALU, type/size:' + unit.type + '/' + unit.data.byteLength);
15056
15066
  units.push(unit);
15057
15067
  } else {
@@ -15059,7 +15069,7 @@
15059
15069
  // first check if start code delimiter is overlapping between 2 PES packets,
15060
15070
  // ie it started in last packet (lastState not zero)
15061
15071
  // and ended at the beginning of this PES packet (i <= 4 - lastState)
15062
- var lastUnit = track.lastNalu;
15072
+ var lastUnit = this.getLastNalUnit(track.samples);
15063
15073
  if (lastUnit) {
15064
15074
  if (lastState && i <= 4 - lastState) {
15065
15075
  // start delimiter overlapping between PES packets
@@ -15076,8 +15086,6 @@
15076
15086
  // logger.log('first NALU found with overflow:' + overflow);
15077
15087
  lastUnit.data = appendUint8Array(lastUnit.data, array.subarray(0, overflow));
15078
15088
  lastUnit.state = 0;
15079
- units.push(lastUnit);
15080
- track.lastNalu = null;
15081
15089
  }
15082
15090
  }
15083
15091
  }
@@ -15102,21 +15110,15 @@
15102
15110
  type: lastUnitType,
15103
15111
  state: state
15104
15112
  };
15105
- if (!last) {
15106
- track.lastNalu = _unit;
15107
- // logger.log('store NALu to push it on next PES');
15108
- } else {
15109
- units.push(_unit);
15110
- // logger.log('pushing NALU, type/size/state:' + unit.type + '/' + unit.data.byteLength + '/' + state);
15111
- }
15112
- } else if (units.length === 0) {
15113
- // no NALu found
15113
+ units.push(_unit);
15114
+ // logger.log('pushing NALU, type/size/state:' + unit.type + '/' + unit.data.byteLength + '/' + state);
15115
+ }
15116
+ // no NALu found
15117
+ if (units.length === 0) {
15114
15118
  // append pes.data to previous NAL unit
15115
- var _lastUnit = track.lastNalu;
15119
+ var _lastUnit = this.getLastNalUnit(track.samples);
15116
15120
  if (_lastUnit) {
15117
15121
  _lastUnit.data = appendUint8Array(_lastUnit.data, array);
15118
- units.push(_lastUnit);
15119
- track.lastNalu = null;
15120
15122
  }
15121
15123
  }
15122
15124
  track.naluState = state;
@@ -15286,9 +15288,9 @@
15286
15288
  }
15287
15289
  _inheritsLoose(AvcVideoParser, _BaseVideoParser);
15288
15290
  var _proto = AvcVideoParser.prototype;
15289
- _proto.parsePES = function parsePES(track, textTrack, pes, last, duration) {
15291
+ _proto.parsePES = function parsePES(track, textTrack, pes, endOfSegment, duration) {
15290
15292
  var _this = this;
15291
- var units = this.parseNALu(track, pes.data, last);
15293
+ var units = this.parseNALu(track, pes.data, endOfSegment);
15292
15294
  var VideoSample = this.VideoSample;
15293
15295
  var push;
15294
15296
  var spsfound = false;
@@ -15418,7 +15420,7 @@
15418
15420
  }
15419
15421
  });
15420
15422
  // if last PES packet, push samples
15421
- if (last && VideoSample) {
15423
+ if (endOfSegment && VideoSample) {
15422
15424
  this.pushAccessUnit(VideoSample, track);
15423
15425
  this.VideoSample = null;
15424
15426
  }
@@ -21907,7 +21909,7 @@
21907
21909
  * Get the video-dev/hls.js package version.
21908
21910
  */
21909
21911
  function get() {
21910
- return "1.5.12-0.canary.10352";
21912
+ return "1.5.12-0.canary.10355";
21911
21913
  }
21912
21914
  }, {
21913
21915
  key: "Events",