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.
@@ -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();
@@ -14482,20 +14482,6 @@ class BaseVideoParser {
14482
14482
  length: 0
14483
14483
  };
14484
14484
  }
14485
- getLastNalUnit(samples) {
14486
- var _VideoSample;
14487
- let VideoSample = this.VideoSample;
14488
- let lastUnit;
14489
- // try to fallback to previous sample if current one is empty
14490
- if (!VideoSample || VideoSample.units.length === 0) {
14491
- VideoSample = samples[samples.length - 1];
14492
- }
14493
- if ((_VideoSample = VideoSample) != null && _VideoSample.units) {
14494
- const units = VideoSample.units;
14495
- lastUnit = units[units.length - 1];
14496
- }
14497
- return lastUnit;
14498
- }
14499
14485
  pushAccessUnit(VideoSample, videoTrack) {
14500
14486
  if (VideoSample.units.length && VideoSample.frame) {
14501
14487
  // if sample does not have PTS/DTS, patch with last sample PTS/DTS
@@ -14518,7 +14504,7 @@ class BaseVideoParser {
14518
14504
  logger.log(VideoSample.pts + '/' + VideoSample.dts + ':' + VideoSample.debug);
14519
14505
  }
14520
14506
  }
14521
- parseNALu(track, array) {
14507
+ parseNALu(track, array, last) {
14522
14508
  const len = array.byteLength;
14523
14509
  let state = track.naluState || 0;
14524
14510
  const lastState = state;
@@ -14560,6 +14546,10 @@ class BaseVideoParser {
14560
14546
  data: array.subarray(lastUnitStart, overflow),
14561
14547
  type: lastUnitType
14562
14548
  };
14549
+ if (track.lastNalu) {
14550
+ units.push(track.lastNalu);
14551
+ track.lastNalu = null;
14552
+ }
14563
14553
  // logger.log('pushing NALU, type/size:' + unit.type + '/' + unit.data.byteLength);
14564
14554
  units.push(unit);
14565
14555
  } else {
@@ -14567,7 +14557,7 @@ class BaseVideoParser {
14567
14557
  // first check if start code delimiter is overlapping between 2 PES packets,
14568
14558
  // ie it started in last packet (lastState not zero)
14569
14559
  // and ended at the beginning of this PES packet (i <= 4 - lastState)
14570
- const lastUnit = this.getLastNalUnit(track.samples);
14560
+ const lastUnit = track.lastNalu;
14571
14561
  if (lastUnit) {
14572
14562
  if (lastState && i <= 4 - lastState) {
14573
14563
  // start delimiter overlapping between PES packets
@@ -14584,6 +14574,8 @@ class BaseVideoParser {
14584
14574
  // logger.log('first NALU found with overflow:' + overflow);
14585
14575
  lastUnit.data = appendUint8Array(lastUnit.data, array.subarray(0, overflow));
14586
14576
  lastUnit.state = 0;
14577
+ units.push(lastUnit);
14578
+ track.lastNalu = null;
14587
14579
  }
14588
14580
  }
14589
14581
  }
@@ -14608,15 +14600,21 @@ class BaseVideoParser {
14608
14600
  type: lastUnitType,
14609
14601
  state: state
14610
14602
  };
14611
- units.push(unit);
14612
- // logger.log('pushing NALU, type/size/state:' + unit.type + '/' + unit.data.byteLength + '/' + state);
14613
- }
14614
- // no NALu found
14615
- if (units.length === 0) {
14603
+ if (!last) {
14604
+ track.lastNalu = unit;
14605
+ // logger.log('store NALu to push it on next PES');
14606
+ } else {
14607
+ units.push(unit);
14608
+ // logger.log('pushing NALU, type/size/state:' + unit.type + '/' + unit.data.byteLength + '/' + state);
14609
+ }
14610
+ } else if (units.length === 0) {
14611
+ // no NALu found
14616
14612
  // append pes.data to previous NAL unit
14617
- const lastUnit = this.getLastNalUnit(track.samples);
14613
+ const lastUnit = track.lastNalu;
14618
14614
  if (lastUnit) {
14619
14615
  lastUnit.data = appendUint8Array(lastUnit.data, array);
14616
+ units.push(lastUnit);
14617
+ track.lastNalu = null;
14620
14618
  }
14621
14619
  }
14622
14620
  track.naluState = state;
@@ -14768,7 +14766,7 @@ class ExpGolomb {
14768
14766
 
14769
14767
  class AvcVideoParser extends BaseVideoParser {
14770
14768
  parsePES(track, textTrack, pes, last, duration) {
14771
- const units = this.parseNALu(track, pes.data);
14769
+ const units = this.parseNALu(track, pes.data, last);
14772
14770
  let VideoSample = this.VideoSample;
14773
14771
  let push;
14774
14772
  let spsfound = false;
@@ -20378,7 +20376,7 @@ class Hls {
20378
20376
  * Get the video-dev/hls.js package version.
20379
20377
  */
20380
20378
  static get version() {
20381
- return "1.5.9-0.canary.10181";
20379
+ return "1.5.9-0.canary.10182";
20382
20380
  }
20383
20381
 
20384
20382
  /**