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

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
@@ -522,7 +522,7 @@
522
522
  // Some browsers don't allow to use bind on console object anyway
523
523
  // fallback to default if needed
524
524
  try {
525
- newLogger.log("Debug logs enabled for \"" + context + "\" in hls.js version " + "1.5.12-0.canary.10352");
525
+ newLogger.log("Debug logs enabled for \"" + context + "\" in hls.js version " + "1.5.12-0.canary.10353");
526
526
  } catch (e) {
527
527
  /* log fn threw an exception. All logger methods are no-ops. */
528
528
  return createLogger();
@@ -12288,6 +12288,20 @@
12288
12288
  length: 0
12289
12289
  };
12290
12290
  };
12291
+ _proto.getLastNalUnit = function getLastNalUnit(samples) {
12292
+ var _VideoSample;
12293
+ var VideoSample = this.VideoSample;
12294
+ var lastUnit;
12295
+ // try to fallback to previous sample if current one is empty
12296
+ if (!VideoSample || VideoSample.units.length === 0) {
12297
+ VideoSample = samples[samples.length - 1];
12298
+ }
12299
+ if ((_VideoSample = VideoSample) != null && _VideoSample.units) {
12300
+ var units = VideoSample.units;
12301
+ lastUnit = units[units.length - 1];
12302
+ }
12303
+ return lastUnit;
12304
+ };
12291
12305
  _proto.pushAccessUnit = function pushAccessUnit(VideoSample, videoTrack) {
12292
12306
  if (VideoSample.units.length && VideoSample.frame) {
12293
12307
  // if sample does not have PTS/DTS, patch with last sample PTS/DTS
@@ -12310,7 +12324,7 @@
12310
12324
  logger.log(VideoSample.pts + '/' + VideoSample.dts + ':' + VideoSample.debug);
12311
12325
  }
12312
12326
  };
12313
- _proto.parseNALu = function parseNALu(track, array, last) {
12327
+ _proto.parseNALu = function parseNALu(track, array, endOfSegment) {
12314
12328
  var len = array.byteLength;
12315
12329
  var state = track.naluState || 0;
12316
12330
  var lastState = state;
@@ -12352,10 +12366,6 @@
12352
12366
  data: array.subarray(lastUnitStart, overflow),
12353
12367
  type: lastUnitType
12354
12368
  };
12355
- if (track.lastNalu) {
12356
- units.push(track.lastNalu);
12357
- track.lastNalu = null;
12358
- }
12359
12369
  // logger.log('pushing NALU, type/size:' + unit.type + '/' + unit.data.byteLength);
12360
12370
  units.push(unit);
12361
12371
  } else {
@@ -12363,7 +12373,7 @@
12363
12373
  // first check if start code delimiter is overlapping between 2 PES packets,
12364
12374
  // ie it started in last packet (lastState not zero)
12365
12375
  // and ended at the beginning of this PES packet (i <= 4 - lastState)
12366
- var lastUnit = track.lastNalu;
12376
+ var lastUnit = this.getLastNalUnit(track.samples);
12367
12377
  if (lastUnit) {
12368
12378
  if (lastState && i <= 4 - lastState) {
12369
12379
  // start delimiter overlapping between PES packets
@@ -12380,8 +12390,6 @@
12380
12390
  // logger.log('first NALU found with overflow:' + overflow);
12381
12391
  lastUnit.data = appendUint8Array(lastUnit.data, array.subarray(0, overflow));
12382
12392
  lastUnit.state = 0;
12383
- units.push(lastUnit);
12384
- track.lastNalu = null;
12385
12393
  }
12386
12394
  }
12387
12395
  }
@@ -12406,21 +12414,15 @@
12406
12414
  type: lastUnitType,
12407
12415
  state: state
12408
12416
  };
12409
- if (!last) {
12410
- track.lastNalu = _unit;
12411
- // logger.log('store NALu to push it on next PES');
12412
- } else {
12413
- units.push(_unit);
12414
- // logger.log('pushing NALU, type/size/state:' + unit.type + '/' + unit.data.byteLength + '/' + state);
12415
- }
12416
- } else if (units.length === 0) {
12417
- // no NALu found
12417
+ units.push(_unit);
12418
+ // logger.log('pushing NALU, type/size/state:' + unit.type + '/' + unit.data.byteLength + '/' + state);
12419
+ }
12420
+ // no NALu found
12421
+ if (units.length === 0) {
12418
12422
  // append pes.data to previous NAL unit
12419
- var _lastUnit = track.lastNalu;
12423
+ var _lastUnit = this.getLastNalUnit(track.samples);
12420
12424
  if (_lastUnit) {
12421
12425
  _lastUnit.data = appendUint8Array(_lastUnit.data, array);
12422
- units.push(_lastUnit);
12423
- track.lastNalu = null;
12424
12426
  }
12425
12427
  }
12426
12428
  track.naluState = state;
@@ -12590,9 +12592,9 @@
12590
12592
  }
12591
12593
  _inheritsLoose(AvcVideoParser, _BaseVideoParser);
12592
12594
  var _proto = AvcVideoParser.prototype;
12593
- _proto.parsePES = function parsePES(track, textTrack, pes, last, duration) {
12595
+ _proto.parsePES = function parsePES(track, textTrack, pes, endOfSegment, duration) {
12594
12596
  var _this = this;
12595
- var units = this.parseNALu(track, pes.data, last);
12597
+ var units = this.parseNALu(track, pes.data, endOfSegment);
12596
12598
  var VideoSample = this.VideoSample;
12597
12599
  var push;
12598
12600
  var spsfound = false;
@@ -12722,7 +12724,7 @@
12722
12724
  }
12723
12725
  });
12724
12726
  // if last PES packet, push samples
12725
- if (last && VideoSample) {
12727
+ if (endOfSegment && VideoSample) {
12726
12728
  this.pushAccessUnit(VideoSample, track);
12727
12729
  this.VideoSample = null;
12728
12730
  }
@@ -12929,9 +12931,9 @@
12929
12931
  }
12930
12932
  _inheritsLoose(HevcVideoParser, _BaseVideoParser);
12931
12933
  var _proto = HevcVideoParser.prototype;
12932
- _proto.parsePES = function parsePES(track, textTrack, pes, last, duration) {
12934
+ _proto.parsePES = function parsePES(track, textTrack, pes, endOfSegment, duration) {
12933
12935
  var _this2 = this;
12934
- var units = this.parseNALu(track, pes.data, last);
12936
+ var units = this.parseNALu(track, pes.data, endOfSegment);
12935
12937
  var VideoSample = this.VideoSample;
12936
12938
  var push;
12937
12939
  var spsfound = false;
@@ -13093,7 +13095,7 @@
13093
13095
  }
13094
13096
  });
13095
13097
  // if last PES packet, push samples
13096
- if (last && VideoSample) {
13098
+ if (endOfSegment && VideoSample) {
13097
13099
  this.pushAccessUnit(VideoSample, track);
13098
13100
  this.VideoSample = null;
13099
13101
  }
@@ -30675,7 +30677,7 @@
30675
30677
  * Get the video-dev/hls.js package version.
30676
30678
  */
30677
30679
  function get() {
30678
- return "1.5.12-0.canary.10352";
30680
+ return "1.5.12-0.canary.10353";
30679
30681
  }
30680
30682
  }, {
30681
30683
  key: "Events",