hls.js 1.5.9-0.canary.10268 → 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.mjs CHANGED
@@ -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.10268"}`);
515
+ newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.5.9-0.canary.10269"}`);
516
516
  } catch (e) {
517
517
  /* log fn threw an exception. All logger methods are no-ops. */
518
518
  return createLogger();
@@ -20207,13 +20207,7 @@ const specialCea608CharsCodes = {
20207
20207
  /**
20208
20208
  * Utils
20209
20209
  */
20210
- const getCharForByte = function getCharForByte(byte) {
20211
- let charCode = byte;
20212
- if (specialCea608CharsCodes.hasOwnProperty(byte)) {
20213
- charCode = specialCea608CharsCodes[byte];
20214
- }
20215
- return String.fromCharCode(charCode);
20216
- };
20210
+ const getCharForByte = byte => String.fromCharCode(specialCea608CharsCodes[byte] || byte);
20217
20211
  const NR_ROWS = 15;
20218
20212
  const NR_COLS = 100;
20219
20213
  // Tables to look up row from PAC data
@@ -20901,28 +20895,39 @@ class Cea608Parser {
20901
20895
  * Add data for time t in forms of list of bytes (unsigned ints). The bytes are treated as pairs.
20902
20896
  */
20903
20897
  addData(time, byteList) {
20904
- let cmdFound;
20905
- let a;
20906
- let b;
20907
- let charsFound = false;
20908
20898
  this.logger.time = time;
20909
20899
  for (let i = 0; i < byteList.length; i += 2) {
20910
- a = byteList[i] & 0x7f;
20911
- b = byteList[i + 1] & 0x7f;
20900
+ const a = byteList[i] & 0x7f;
20901
+ const b = byteList[i + 1] & 0x7f;
20902
+ let cmdFound = false;
20903
+ let charsFound = null;
20912
20904
  if (a === 0 && b === 0) {
20913
20905
  continue;
20914
20906
  } else {
20915
- this.logger.log(3, '[' + numArrayToHexArray([byteList[i], byteList[i + 1]]) + '] -> (' + numArrayToHexArray([a, b]) + ')');
20916
- }
20917
- cmdFound = this.parseCmd(a, b);
20918
- if (!cmdFound) {
20919
- cmdFound = this.parseMidrow(a, b);
20920
- }
20921
- if (!cmdFound) {
20922
- cmdFound = this.parsePAC(a, b);
20923
- }
20924
- if (!cmdFound) {
20925
- cmdFound = this.parseBackgroundAttributes(a, b);
20907
+ this.logger.log(3, () => '[' + numArrayToHexArray([byteList[i], byteList[i + 1]]) + '] -> (' + numArrayToHexArray([a, b]) + ')');
20908
+ }
20909
+ const cmdHistory = this.cmdHistory;
20910
+ const isControlCode = a >= 0x10 && a <= 0x1f;
20911
+ if (isControlCode) {
20912
+ // Skip redundant control codes
20913
+ if (hasCmdRepeated(a, b, cmdHistory)) {
20914
+ setLastCmd(null, null, cmdHistory);
20915
+ this.logger.log(3, () => 'Repeated command (' + numArrayToHexArray([a, b]) + ') is dropped');
20916
+ continue;
20917
+ }
20918
+ setLastCmd(a, b, this.cmdHistory);
20919
+ cmdFound = this.parseCmd(a, b);
20920
+ if (!cmdFound) {
20921
+ cmdFound = this.parseMidrow(a, b);
20922
+ }
20923
+ if (!cmdFound) {
20924
+ cmdFound = this.parsePAC(a, b);
20925
+ }
20926
+ if (!cmdFound) {
20927
+ cmdFound = this.parseBackgroundAttributes(a, b);
20928
+ }
20929
+ } else {
20930
+ setLastCmd(null, null, cmdHistory);
20926
20931
  }
20927
20932
  if (!cmdFound) {
20928
20933
  charsFound = this.parseChars(a, b);
@@ -20937,7 +20942,7 @@ class Cea608Parser {
20937
20942
  }
20938
20943
  }
20939
20944
  if (!cmdFound && !charsFound) {
20940
- this.logger.log(2, "Couldn't parse cleaned data " + numArrayToHexArray([a, b]) + ' orig: ' + numArrayToHexArray([byteList[i], byteList[i + 1]]));
20945
+ this.logger.log(2, () => "Couldn't parse cleaned data " + numArrayToHexArray([a, b]) + ' orig: ' + numArrayToHexArray([byteList[i], byteList[i + 1]]));
20941
20946
  }
20942
20947
  }
20943
20948
  }
@@ -20947,19 +20952,11 @@ class Cea608Parser {
20947
20952
  * @returns True if a command was found
20948
20953
  */
20949
20954
  parseCmd(a, b) {
20950
- const {
20951
- cmdHistory
20952
- } = this;
20953
20955
  const cond1 = (a === 0x14 || a === 0x1c || a === 0x15 || a === 0x1d) && b >= 0x20 && b <= 0x2f;
20954
20956
  const cond2 = (a === 0x17 || a === 0x1f) && b >= 0x21 && b <= 0x23;
20955
20957
  if (!(cond1 || cond2)) {
20956
20958
  return false;
20957
20959
  }
20958
- if (hasCmdRepeated(a, b, cmdHistory)) {
20959
- setLastCmd(null, null, cmdHistory);
20960
- this.logger.log(3, 'Repeated command (' + numArrayToHexArray([a, b]) + ') is dropped');
20961
- return true;
20962
- }
20963
20960
  const chNr = a === 0x14 || a === 0x15 || a === 0x17 ? 1 : 2;
20964
20961
  const channel = this.channels[chNr];
20965
20962
  if (a === 0x14 || a === 0x15 || a === 0x1c || a === 0x1d) {
@@ -21000,7 +20997,6 @@ class Cea608Parser {
21000
20997
  // a == 0x17 || a == 0x1F
21001
20998
  channel.ccTO(b - 0x20);
21002
20999
  }
21003
- setLastCmd(a, b, cmdHistory);
21004
21000
  this.currentChannel = chNr;
21005
21001
  return true;
21006
21002
  }
@@ -21025,7 +21021,7 @@ class Cea608Parser {
21025
21021
  return false;
21026
21022
  }
21027
21023
  channel.ccMIDROW(b);
21028
- this.logger.log(3, 'MIDROW (' + numArrayToHexArray([a, b]) + ')');
21024
+ this.logger.log(3, () => 'MIDROW (' + numArrayToHexArray([a, b]) + ')');
21029
21025
  return true;
21030
21026
  }
21031
21027
  return false;
@@ -21037,16 +21033,11 @@ class Cea608Parser {
21037
21033
  */
21038
21034
  parsePAC(a, b) {
21039
21035
  let row;
21040
- const cmdHistory = this.cmdHistory;
21041
21036
  const case1 = (a >= 0x11 && a <= 0x17 || a >= 0x19 && a <= 0x1f) && b >= 0x40 && b <= 0x7f;
21042
21037
  const case2 = (a === 0x10 || a === 0x18) && b >= 0x40 && b <= 0x5f;
21043
21038
  if (!(case1 || case2)) {
21044
21039
  return false;
21045
21040
  }
21046
- if (hasCmdRepeated(a, b, cmdHistory)) {
21047
- setLastCmd(null, null, cmdHistory);
21048
- return true; // Repeated commands are dropped (once)
21049
- }
21050
21041
  const chNr = a <= 0x17 ? 1 : 2;
21051
21042
  if (b >= 0x40 && b <= 0x5f) {
21052
21043
  row = chNr === 1 ? rowsLowCh1[a] : rowsLowCh2[a];
@@ -21059,7 +21050,6 @@ class Cea608Parser {
21059
21050
  return false;
21060
21051
  }
21061
21052
  channel.setPAC(this.interpretPAC(row, b));
21062
- setLastCmd(a, b, cmdHistory);
21063
21053
  this.currentChannel = chNr;
21064
21054
  return true;
21065
21055
  }
@@ -21119,15 +21109,13 @@ class Cea608Parser {
21119
21109
  } else {
21120
21110
  oneCode = b + 0x90;
21121
21111
  }
21122
- this.logger.log(2, "Special char '" + getCharForByte(oneCode) + "' in channel " + channelNr);
21112
+ this.logger.log(2, () => "Special char '" + getCharForByte(oneCode) + "' in channel " + channelNr);
21123
21113
  charCodes = [oneCode];
21124
21114
  } else if (a >= 0x20 && a <= 0x7f) {
21125
21115
  charCodes = b === 0 ? [a] : [a, b];
21126
21116
  }
21127
21117
  if (charCodes) {
21128
- const hexCodes = numArrayToHexArray(charCodes);
21129
- this.logger.log(3, 'Char codes = ' + hexCodes.join(','));
21130
- setLastCmd(a, b, this.cmdHistory);
21118
+ this.logger.log(3, () => 'Char codes = ' + numArrayToHexArray(charCodes).join(','));
21131
21119
  }
21132
21120
  return charCodes;
21133
21121
  }
@@ -21161,7 +21149,6 @@ class Cea608Parser {
21161
21149
  const chNr = a <= 0x17 ? 1 : 2;
21162
21150
  const channel = this.channels[chNr];
21163
21151
  channel.setBkgData(bkgData);
21164
- setLastCmd(a, b, this.cmdHistory);
21165
21152
  return true;
21166
21153
  }
21167
21154
 
@@ -21175,7 +21162,7 @@ class Cea608Parser {
21175
21162
  channel.reset();
21176
21163
  }
21177
21164
  }
21178
- this.cmdHistory = createCmdHistory();
21165
+ setLastCmd(null, null, this.cmdHistory);
21179
21166
  }
21180
21167
 
21181
21168
  /**
@@ -22648,17 +22635,16 @@ class TimelineController {
22648
22635
  cea608Parser2,
22649
22636
  lastSn
22650
22637
  } = this;
22651
- if (!cea608Parser1 || !cea608Parser2) {
22652
- return;
22653
- }
22654
22638
  const {
22655
22639
  cc,
22656
22640
  sn
22657
22641
  } = data.frag;
22658
22642
  const partIndex = (_data$part$index = (_data$part = data.part) == null ? void 0 : _data$part.index) != null ? _data$part$index : -1;
22659
- if (!(sn === lastSn + 1 || sn === lastSn && partIndex === this.lastPartIndex + 1 || cc === this.lastCc)) {
22660
- cea608Parser1.reset();
22661
- cea608Parser2.reset();
22643
+ if (cea608Parser1 && cea608Parser2) {
22644
+ if (sn !== lastSn + 1 || sn === lastSn && partIndex !== this.lastPartIndex + 1 || cc !== this.lastCc) {
22645
+ cea608Parser1.reset();
22646
+ cea608Parser2.reset();
22647
+ }
22662
22648
  }
22663
22649
  this.lastCc = cc;
22664
22650
  this.lastSn = sn;
@@ -29028,7 +29014,7 @@ class Hls {
29028
29014
  * Get the video-dev/hls.js package version.
29029
29015
  */
29030
29016
  static get version() {
29031
- return "1.5.9-0.canary.10268";
29017
+ return "1.5.9-0.canary.10269";
29032
29018
  }
29033
29019
 
29034
29020
  /**