hls.js 1.5.9-0.canary.10267 → 1.5.9-0.canary.10269

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
@@ -637,7 +637,7 @@
637
637
  // Some browsers don't allow to use bind on console object anyway
638
638
  // fallback to default if needed
639
639
  try {
640
- newLogger.log("Debug logs enabled for \"" + context + "\" in hls.js version " + "1.5.9-0.canary.10267");
640
+ newLogger.log("Debug logs enabled for \"" + context + "\" in hls.js version " + "1.5.9-0.canary.10269");
641
641
  } catch (e) {
642
642
  /* log fn threw an exception. All logger methods are no-ops. */
643
643
  return createLogger();
@@ -10044,11 +10044,14 @@
10044
10044
  var fragmentTracker = this.fragmentTracker;
10045
10045
  var fragState = fragmentTracker.getState(frag);
10046
10046
  if (fragState === FragmentState.APPENDING) {
10047
- // Lower the buffer size and try again
10047
+ // Lower the max buffer length and try again
10048
10048
  var playlistType = frag.type;
10049
10049
  var bufferedInfo = this.getFwdBufferInfo(this.mediaBuffer, playlistType);
10050
10050
  var minForwardBufferLength = Math.max(frag.duration, bufferedInfo ? bufferedInfo.len : this.config.maxBufferLength);
10051
- if (this.reduceMaxBufferLength(minForwardBufferLength)) {
10051
+ // If backtracking, always remove from the tracker without reducing max buffer length
10052
+ var backtrackFragment = this.backtrackFragment;
10053
+ var backtracked = backtrackFragment ? frag.sn - backtrackFragment.sn : 0;
10054
+ if (backtracked === 1 || this.reduceMaxBufferLength(minForwardBufferLength)) {
10052
10055
  fragmentTracker.removeFragment(frag);
10053
10056
  }
10054
10057
  } else if (((_this$mediaBuffer = this.mediaBuffer) == null ? void 0 : _this$mediaBuffer.buffered.length) === 0) {
@@ -10549,10 +10552,11 @@
10549
10552
  _proto.reduceMaxBufferLength = function reduceMaxBufferLength(threshold) {
10550
10553
  var config = this.config;
10551
10554
  var minLength = threshold || config.maxBufferLength;
10552
- if (config.maxMaxBufferLength >= minLength) {
10555
+ var reducedLength = config.maxMaxBufferLength / 2;
10556
+ if (reducedLength >= minLength) {
10553
10557
  // reduce max buffer length as it might be too high. we do this to avoid loop flushing ...
10554
- config.maxMaxBufferLength /= 2;
10555
- this.warn("Reduce max buffer length to " + config.maxMaxBufferLength + "s");
10558
+ config.maxMaxBufferLength = reducedLength;
10559
+ this.warn("Reduce max buffer length to " + reducedLength + "s");
10556
10560
  return true;
10557
10561
  }
10558
10562
  return false;
@@ -20720,11 +20724,7 @@
20720
20724
  * Utils
20721
20725
  */
20722
20726
  var getCharForByte = function getCharForByte(_byte) {
20723
- var charCode = _byte;
20724
- if (specialCea608CharsCodes.hasOwnProperty(_byte)) {
20725
- charCode = specialCea608CharsCodes[_byte];
20726
- }
20727
- return String.fromCharCode(charCode);
20727
+ return String.fromCharCode(specialCea608CharsCodes[_byte] || _byte);
20728
20728
  };
20729
20729
  var NR_ROWS = 15;
20730
20730
  var NR_COLS = 100;
@@ -21443,44 +21443,67 @@
21443
21443
  * Add data for time t in forms of list of bytes (unsigned ints). The bytes are treated as pairs.
21444
21444
  */;
21445
21445
  _proto7.addData = function addData(time, byteList) {
21446
- var cmdFound;
21447
- var a;
21448
- var b;
21449
- var charsFound = false;
21446
+ var _this5 = this;
21450
21447
  this.logger.time = time;
21451
- for (var i = 0; i < byteList.length; i += 2) {
21452
- a = byteList[i] & 0x7f;
21453
- b = byteList[i + 1] & 0x7f;
21454
- if (a === 0 && b === 0) {
21455
- continue;
21456
- } else {
21457
- this.logger.log(3, '[' + numArrayToHexArray([byteList[i], byteList[i + 1]]) + '] -> (' + numArrayToHexArray([a, b]) + ')');
21458
- }
21459
- cmdFound = this.parseCmd(a, b);
21460
- if (!cmdFound) {
21461
- cmdFound = this.parseMidrow(a, b);
21462
- }
21463
- if (!cmdFound) {
21464
- cmdFound = this.parsePAC(a, b);
21465
- }
21466
- if (!cmdFound) {
21467
- cmdFound = this.parseBackgroundAttributes(a, b);
21468
- }
21469
- if (!cmdFound) {
21470
- charsFound = this.parseChars(a, b);
21471
- if (charsFound) {
21472
- var currChNr = this.currentChannel;
21473
- if (currChNr && currChNr > 0) {
21474
- var channel = this.channels[currChNr];
21475
- channel.insertChars(charsFound);
21476
- } else {
21477
- this.logger.log(2, 'No channel found yet. TEXT-MODE?');
21448
+ var _loop = function _loop(i) {
21449
+ var a = byteList[i] & 0x7f;
21450
+ var b = byteList[i + 1] & 0x7f;
21451
+ var cmdFound = false;
21452
+ var charsFound = null;
21453
+ if (a === 0 && b === 0) {
21454
+ return 0; // continue
21455
+ } else {
21456
+ _this5.logger.log(3, function () {
21457
+ return '[' + numArrayToHexArray([byteList[i], byteList[i + 1]]) + '] -> (' + numArrayToHexArray([a, b]) + ')';
21458
+ });
21459
+ }
21460
+ var cmdHistory = _this5.cmdHistory;
21461
+ var isControlCode = a >= 0x10 && a <= 0x1f;
21462
+ if (isControlCode) {
21463
+ // Skip redundant control codes
21464
+ if (hasCmdRepeated(a, b, cmdHistory)) {
21465
+ setLastCmd(null, null, cmdHistory);
21466
+ _this5.logger.log(3, function () {
21467
+ return 'Repeated command (' + numArrayToHexArray([a, b]) + ') is dropped';
21468
+ });
21469
+ return 0; // continue
21470
+ }
21471
+ setLastCmd(a, b, _this5.cmdHistory);
21472
+ cmdFound = _this5.parseCmd(a, b);
21473
+ if (!cmdFound) {
21474
+ cmdFound = _this5.parseMidrow(a, b);
21475
+ }
21476
+ if (!cmdFound) {
21477
+ cmdFound = _this5.parsePAC(a, b);
21478
+ }
21479
+ if (!cmdFound) {
21480
+ cmdFound = _this5.parseBackgroundAttributes(a, b);
21481
+ }
21482
+ } else {
21483
+ setLastCmd(null, null, cmdHistory);
21484
+ }
21485
+ if (!cmdFound) {
21486
+ charsFound = _this5.parseChars(a, b);
21487
+ if (charsFound) {
21488
+ var currChNr = _this5.currentChannel;
21489
+ if (currChNr && currChNr > 0) {
21490
+ var channel = _this5.channels[currChNr];
21491
+ channel.insertChars(charsFound);
21492
+ } else {
21493
+ _this5.logger.log(2, 'No channel found yet. TEXT-MODE?');
21494
+ }
21478
21495
  }
21479
21496
  }
21480
- }
21481
- if (!cmdFound && !charsFound) {
21482
- this.logger.log(2, "Couldn't parse cleaned data " + numArrayToHexArray([a, b]) + ' orig: ' + numArrayToHexArray([byteList[i], byteList[i + 1]]));
21483
- }
21497
+ if (!cmdFound && !charsFound) {
21498
+ _this5.logger.log(2, function () {
21499
+ return "Couldn't parse cleaned data " + numArrayToHexArray([a, b]) + ' orig: ' + numArrayToHexArray([byteList[i], byteList[i + 1]]);
21500
+ });
21501
+ }
21502
+ },
21503
+ _ret;
21504
+ for (var i = 0; i < byteList.length; i += 2) {
21505
+ _ret = _loop(i);
21506
+ if (_ret === 0) continue;
21484
21507
  }
21485
21508
  }
21486
21509
 
@@ -21489,17 +21512,11 @@
21489
21512
  * @returns True if a command was found
21490
21513
  */;
21491
21514
  _proto7.parseCmd = function parseCmd(a, b) {
21492
- var cmdHistory = this.cmdHistory;
21493
21515
  var cond1 = (a === 0x14 || a === 0x1c || a === 0x15 || a === 0x1d) && b >= 0x20 && b <= 0x2f;
21494
21516
  var cond2 = (a === 0x17 || a === 0x1f) && b >= 0x21 && b <= 0x23;
21495
21517
  if (!(cond1 || cond2)) {
21496
21518
  return false;
21497
21519
  }
21498
- if (hasCmdRepeated(a, b, cmdHistory)) {
21499
- setLastCmd(null, null, cmdHistory);
21500
- this.logger.log(3, 'Repeated command (' + numArrayToHexArray([a, b]) + ') is dropped');
21501
- return true;
21502
- }
21503
21520
  var chNr = a === 0x14 || a === 0x15 || a === 0x17 ? 1 : 2;
21504
21521
  var channel = this.channels[chNr];
21505
21522
  if (a === 0x14 || a === 0x15 || a === 0x1c || a === 0x1d) {
@@ -21540,7 +21557,6 @@
21540
21557
  // a == 0x17 || a == 0x1F
21541
21558
  channel.ccTO(b - 0x20);
21542
21559
  }
21543
- setLastCmd(a, b, cmdHistory);
21544
21560
  this.currentChannel = chNr;
21545
21561
  return true;
21546
21562
  }
@@ -21565,7 +21581,9 @@
21565
21581
  return false;
21566
21582
  }
21567
21583
  channel.ccMIDROW(b);
21568
- this.logger.log(3, 'MIDROW (' + numArrayToHexArray([a, b]) + ')');
21584
+ this.logger.log(3, function () {
21585
+ return 'MIDROW (' + numArrayToHexArray([a, b]) + ')';
21586
+ });
21569
21587
  return true;
21570
21588
  }
21571
21589
  return false;
@@ -21577,16 +21595,11 @@
21577
21595
  */;
21578
21596
  _proto7.parsePAC = function parsePAC(a, b) {
21579
21597
  var row;
21580
- var cmdHistory = this.cmdHistory;
21581
21598
  var case1 = (a >= 0x11 && a <= 0x17 || a >= 0x19 && a <= 0x1f) && b >= 0x40 && b <= 0x7f;
21582
21599
  var case2 = (a === 0x10 || a === 0x18) && b >= 0x40 && b <= 0x5f;
21583
21600
  if (!(case1 || case2)) {
21584
21601
  return false;
21585
21602
  }
21586
- if (hasCmdRepeated(a, b, cmdHistory)) {
21587
- setLastCmd(null, null, cmdHistory);
21588
- return true; // Repeated commands are dropped (once)
21589
- }
21590
21603
  var chNr = a <= 0x17 ? 1 : 2;
21591
21604
  if (b >= 0x40 && b <= 0x5f) {
21592
21605
  row = chNr === 1 ? rowsLowCh1[a] : rowsLowCh2[a];
@@ -21599,7 +21612,6 @@
21599
21612
  return false;
21600
21613
  }
21601
21614
  channel.setPAC(this.interpretPAC(row, b));
21602
- setLastCmd(a, b, cmdHistory);
21603
21615
  this.currentChannel = chNr;
21604
21616
  return true;
21605
21617
  }
@@ -21659,15 +21671,17 @@
21659
21671
  } else {
21660
21672
  oneCode = b + 0x90;
21661
21673
  }
21662
- this.logger.log(2, "Special char '" + getCharForByte(oneCode) + "' in channel " + channelNr);
21674
+ this.logger.log(2, function () {
21675
+ return "Special char '" + getCharForByte(oneCode) + "' in channel " + channelNr;
21676
+ });
21663
21677
  charCodes = [oneCode];
21664
21678
  } else if (a >= 0x20 && a <= 0x7f) {
21665
21679
  charCodes = b === 0 ? [a] : [a, b];
21666
21680
  }
21667
21681
  if (charCodes) {
21668
- var hexCodes = numArrayToHexArray(charCodes);
21669
- this.logger.log(3, 'Char codes = ' + hexCodes.join(','));
21670
- setLastCmd(a, b, this.cmdHistory);
21682
+ this.logger.log(3, function () {
21683
+ return 'Char codes = ' + numArrayToHexArray(charCodes).join(',');
21684
+ });
21671
21685
  }
21672
21686
  return charCodes;
21673
21687
  }
@@ -21701,7 +21715,6 @@
21701
21715
  var chNr = a <= 0x17 ? 1 : 2;
21702
21716
  var channel = this.channels[chNr];
21703
21717
  channel.setBkgData(bkgData);
21704
- setLastCmd(a, b, this.cmdHistory);
21705
21718
  return true;
21706
21719
  }
21707
21720
 
@@ -21715,7 +21728,7 @@
21715
21728
  channel.reset();
21716
21729
  }
21717
21730
  }
21718
- this.cmdHistory = createCmdHistory();
21731
+ setLastCmd(null, null, this.cmdHistory);
21719
21732
  }
21720
21733
 
21721
21734
  /**
@@ -23204,16 +23217,15 @@
23204
23217
  var cea608Parser1 = this.cea608Parser1,
23205
23218
  cea608Parser2 = this.cea608Parser2,
23206
23219
  lastSn = this.lastSn;
23207
- if (!cea608Parser1 || !cea608Parser2) {
23208
- return;
23209
- }
23210
23220
  var _data$frag = data.frag,
23211
23221
  cc = _data$frag.cc,
23212
23222
  sn = _data$frag.sn;
23213
23223
  var partIndex = (_data$part$index = (_data$part = data.part) == null ? void 0 : _data$part.index) != null ? _data$part$index : -1;
23214
- if (!(sn === lastSn + 1 || sn === lastSn && partIndex === this.lastPartIndex + 1 || cc === this.lastCc)) {
23215
- cea608Parser1.reset();
23216
- cea608Parser2.reset();
23224
+ if (cea608Parser1 && cea608Parser2) {
23225
+ if (sn !== lastSn + 1 || sn === lastSn && partIndex !== this.lastPartIndex + 1 || cc !== this.lastCc) {
23226
+ cea608Parser1.reset();
23227
+ cea608Parser2.reset();
23228
+ }
23217
23229
  }
23218
23230
  this.lastCc = cc;
23219
23231
  this.lastSn = sn;
@@ -30516,7 +30528,7 @@
30516
30528
  * Get the video-dev/hls.js package version.
30517
30529
  */
30518
30530
  function get() {
30519
- return "1.5.9-0.canary.10267";
30531
+ return "1.5.9-0.canary.10269";
30520
30532
  }
30521
30533
  }, {
30522
30534
  key: "Events",