hls.js 1.5.8-0.canary.10170 → 1.5.8

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.
Files changed (87) hide show
  1. package/README.md +3 -4
  2. package/dist/hls-demo.js +3 -12
  3. package/dist/hls-demo.js.map +1 -1
  4. package/dist/hls.js +2366 -3626
  5. package/dist/hls.js.d.ts +84 -98
  6. package/dist/hls.js.map +1 -1
  7. package/dist/hls.light.js +1643 -2278
  8. package/dist/hls.light.js.map +1 -1
  9. package/dist/hls.light.min.js +1 -1
  10. package/dist/hls.light.min.js.map +1 -1
  11. package/dist/hls.light.mjs +1258 -1903
  12. package/dist/hls.light.mjs.map +1 -1
  13. package/dist/hls.min.js +1 -1
  14. package/dist/hls.min.js.map +1 -1
  15. package/dist/hls.mjs +1531 -2794
  16. package/dist/hls.mjs.map +1 -1
  17. package/dist/hls.worker.js +1 -1
  18. package/dist/hls.worker.js.map +1 -1
  19. package/package.json +30 -30
  20. package/src/config.ts +2 -3
  21. package/src/controller/abr-controller.ts +20 -24
  22. package/src/controller/audio-stream-controller.ts +74 -68
  23. package/src/controller/audio-track-controller.ts +1 -1
  24. package/src/controller/base-playlist-controller.ts +10 -27
  25. package/src/controller/base-stream-controller.ts +38 -160
  26. package/src/controller/buffer-controller.ts +92 -230
  27. package/src/controller/buffer-operation-queue.ts +19 -16
  28. package/src/controller/cap-level-controller.ts +2 -3
  29. package/src/controller/cmcd-controller.ts +9 -30
  30. package/src/controller/content-steering-controller.ts +6 -8
  31. package/src/controller/eme-controller.ts +23 -10
  32. package/src/controller/error-controller.ts +8 -6
  33. package/src/controller/fps-controller.ts +3 -8
  34. package/src/controller/fragment-tracker.ts +11 -15
  35. package/src/controller/gap-controller.ts +16 -43
  36. package/src/controller/id3-track-controller.ts +7 -7
  37. package/src/controller/latency-controller.ts +11 -9
  38. package/src/controller/level-controller.ts +19 -13
  39. package/src/controller/stream-controller.ts +32 -37
  40. package/src/controller/subtitle-stream-controller.ts +40 -28
  41. package/src/controller/subtitle-track-controller.ts +3 -5
  42. package/src/controller/timeline-controller.ts +31 -25
  43. package/src/crypt/aes-crypto.ts +2 -21
  44. package/src/crypt/decrypter.ts +18 -32
  45. package/src/crypt/fast-aes-key.ts +5 -24
  46. package/src/demux/audio/aacdemuxer.ts +2 -2
  47. package/src/demux/audio/ac3-demuxer.ts +3 -4
  48. package/src/demux/audio/adts.ts +4 -9
  49. package/src/demux/audio/base-audio-demuxer.ts +14 -16
  50. package/src/demux/audio/mp3demuxer.ts +3 -4
  51. package/src/demux/audio/mpegaudio.ts +1 -1
  52. package/src/demux/id3.ts +411 -0
  53. package/src/demux/mp4demuxer.ts +7 -7
  54. package/src/demux/sample-aes.ts +0 -2
  55. package/src/demux/transmuxer-interface.ts +12 -4
  56. package/src/demux/transmuxer-worker.ts +4 -4
  57. package/src/demux/transmuxer.ts +3 -16
  58. package/src/demux/tsdemuxer.ts +37 -71
  59. package/src/demux/video/avc-video-parser.ts +119 -208
  60. package/src/demux/video/base-video-parser.ts +2 -134
  61. package/src/demux/video/exp-golomb.ts +208 -0
  62. package/src/events.ts +1 -8
  63. package/src/exports-named.ts +1 -1
  64. package/src/hls.ts +37 -49
  65. package/src/loader/fragment-loader.ts +3 -10
  66. package/src/loader/key-loader.ts +1 -3
  67. package/src/loader/level-key.ts +9 -10
  68. package/src/loader/playlist-loader.ts +5 -4
  69. package/src/remux/mp4-generator.ts +1 -196
  70. package/src/remux/mp4-remuxer.ts +8 -24
  71. package/src/task-loop.ts +2 -5
  72. package/src/types/component-api.ts +1 -3
  73. package/src/types/demuxer.ts +0 -3
  74. package/src/types/events.ts +0 -4
  75. package/src/types/remuxer.ts +1 -1
  76. package/src/utils/buffer-helper.ts +31 -12
  77. package/src/utils/codecs.ts +5 -34
  78. package/src/utils/fetch-loader.ts +1 -1
  79. package/src/utils/imsc1-ttml-parser.ts +1 -1
  80. package/src/utils/keysystem-util.ts +6 -1
  81. package/src/utils/logger.ts +23 -58
  82. package/src/utils/mp4-tools.ts +3 -5
  83. package/src/utils/webvtt-parser.ts +1 -1
  84. package/src/crypt/decrypter-aes-mode.ts +0 -4
  85. package/src/demux/video/hevc-video-parser.ts +0 -749
  86. package/src/utils/encryption-methods-util.ts +0 -21
  87. package/src/utils/utf8-utils.ts +0 -18
@@ -1,7 +1,7 @@
1
1
  import { findBox } from './mp4-tools';
2
2
  import { parseTimeStamp } from './vttparser';
3
3
  import VTTCue from './vttcue';
4
- import { utf8ArrayToStr } from '@svta/common-media-library/utils/utf8ArrayToStr';
4
+ import { utf8ArrayToStr } from '../demux/id3';
5
5
  import {
6
6
  RationalTimestamp,
7
7
  toTimescaleFromScale,
@@ -1,5 +1,4 @@
1
1
  import { base64Decode } from './numeric-encoding-utils';
2
- import { strToUtf8array } from './utf8-utils';
3
2
 
4
3
  function getKeyIdBytes(str: string): Uint8Array {
5
4
  const keyIdbytes = strToUtf8array(str).subarray(0, 16);
@@ -41,3 +40,9 @@ export function convertDataUriToArrayBytes(uri: string): Uint8Array | null {
41
40
  }
42
41
  return keydata;
43
42
  }
43
+
44
+ export function strToUtf8array(str: string): Uint8Array {
45
+ return Uint8Array.from(unescape(encodeURIComponent(str)), (c) =>
46
+ c.charCodeAt(0),
47
+ );
48
+ }
@@ -11,25 +11,6 @@ export interface ILogger {
11
11
  error: ILogFunction;
12
12
  }
13
13
 
14
- export class Logger implements ILogger {
15
- trace: ILogFunction;
16
- debug: ILogFunction;
17
- log: ILogFunction;
18
- warn: ILogFunction;
19
- info: ILogFunction;
20
- error: ILogFunction;
21
-
22
- constructor(label: string, logger: ILogger) {
23
- const lb = `[${label}]:`;
24
- this.trace = noop;
25
- this.debug = logger.debug.bind(null, lb);
26
- this.log = logger.log.bind(null, lb);
27
- this.warn = logger.warn.bind(null, lb);
28
- this.info = logger.info.bind(null, lb);
29
- this.error = logger.error.bind(null, lb);
30
- }
31
- }
32
-
33
14
  const noop: ILogFunction = function () {};
34
15
 
35
16
  const fakeLogger: ILogger = {
@@ -41,9 +22,7 @@ const fakeLogger: ILogger = {
41
22
  error: noop,
42
23
  };
43
24
 
44
- function createLogger() {
45
- return Object.assign({}, fakeLogger);
46
- }
25
+ let exportedLogger: ILogger = fakeLogger;
47
26
 
48
27
  // let lastCallTime;
49
28
  // function formatMsgWithTimeInfo(type, msg) {
@@ -54,37 +33,33 @@ function createLogger() {
54
33
  // return msg;
55
34
  // }
56
35
 
57
- function consolePrintFn(type: string, id: string | undefined): ILogFunction {
36
+ function consolePrintFn(type: string): ILogFunction {
58
37
  const func: ILogFunction = self.console[type];
59
- return func
60
- ? func.bind(self.console, `${id ? '[' + id + '] ' : ''}[${type}] >`)
61
- : noop;
38
+ if (func) {
39
+ return func.bind(self.console, `[${type}] >`);
40
+ }
41
+ return noop;
62
42
  }
63
43
 
64
- function getLoggerFn(
65
- key: string,
66
- debugConfig: boolean | Partial<ILogger>,
67
- id?: string,
68
- ): ILogFunction {
69
- return debugConfig[key]
70
- ? debugConfig[key].bind(debugConfig)
71
- : consolePrintFn(key, id);
44
+ function exportLoggerFunctions(
45
+ debugConfig: boolean | ILogger,
46
+ ...functions: string[]
47
+ ): void {
48
+ functions.forEach(function (type) {
49
+ exportedLogger[type] = debugConfig[type]
50
+ ? debugConfig[type].bind(debugConfig)
51
+ : consolePrintFn(type);
52
+ });
72
53
  }
73
54
 
74
- const exportedLogger: ILogger = createLogger();
75
-
76
- export function enableLogs(
77
- debugConfig: boolean | ILogger,
78
- context: string,
79
- id?: string | undefined,
80
- ): ILogger {
55
+ export function enableLogs(debugConfig: boolean | ILogger, id: string): void {
81
56
  // check that console is available
82
- const newLogger = createLogger();
83
57
  if (
84
58
  (typeof console === 'object' && debugConfig === true) ||
85
59
  typeof debugConfig === 'object'
86
60
  ) {
87
- const keys: (keyof ILogger)[] = [
61
+ exportLoggerFunctions(
62
+ debugConfig,
88
63
  // Remove out from list here to hard-disable a log-level
89
64
  // 'trace',
90
65
  'debug',
@@ -92,29 +67,19 @@ export function enableLogs(
92
67
  'info',
93
68
  'warn',
94
69
  'error',
95
- ];
96
- keys.forEach((key) => {
97
- newLogger[key] = getLoggerFn(key, debugConfig, id);
98
- });
70
+ );
99
71
  // Some browsers don't allow to use bind on console object anyway
100
72
  // fallback to default if needed
101
73
  try {
102
- newLogger.log(
103
- `Debug logs enabled for "${context}" in hls.js version ${__VERSION__}`,
74
+ exportedLogger.log(
75
+ `Debug logs enabled for "${id}" in hls.js version ${__VERSION__}`,
104
76
  );
105
77
  } catch (e) {
106
- /* log fn threw an exception. All logger methods are no-ops. */
107
- return createLogger();
78
+ exportedLogger = fakeLogger;
108
79
  }
109
- // global exported logger uses the same functions as new logger without `id`
110
- keys.forEach((key) => {
111
- exportedLogger[key] = getLoggerFn(key, debugConfig);
112
- });
113
80
  } else {
114
- // Reset global exported logger
115
- Object.assign(exportedLogger, newLogger);
81
+ exportedLogger = fakeLogger;
116
82
  }
117
- return newLogger;
118
83
  }
119
84
 
120
85
  export const logger: ILogger = exportedLogger;
@@ -1,6 +1,6 @@
1
1
  import { ElementaryStreamTypes } from '../loader/fragment';
2
2
  import { sliceUint8 } from './typed-array';
3
- import { utf8ArrayToStr } from '@svta/common-media-library/utils/utf8ArrayToStr';
3
+ import { utf8ArrayToStr } from '../demux/id3';
4
4
  import { logger } from '../utils/logger';
5
5
  import Hex from './hex';
6
6
  import type { PassthroughTrack, UserdataSample } from '../types/demuxer';
@@ -327,7 +327,7 @@ function parseStsd(stsd: Uint8Array): { codec: string; encrypted: boolean } {
327
327
  case 'mp4a': {
328
328
  const codecBox = findBox(sampleEntries, [fourCC])[0];
329
329
  const esdsBox = findBox(codecBox.subarray(28), ['esds'])[0];
330
- if (esdsBox && esdsBox.length > 7) {
330
+ if (esdsBox && esdsBox.length > 12) {
331
331
  let i = 4;
332
332
  // ES Descriptor tag
333
333
  if (esdsBox[i++] !== 0x03) {
@@ -478,9 +478,7 @@ function parseStsd(stsd: Uint8Array): { codec: string; encrypted: boolean } {
478
478
 
479
479
  function skipBERInteger(bytes: Uint8Array, i: number): number {
480
480
  const limit = i + 5;
481
- while (bytes[i++] & 0x80 && i < limit) {
482
- /* do nothing */
483
- }
481
+ while (bytes[i++] & 0x80 && i < limit) {}
484
482
  return i;
485
483
  }
486
484
 
@@ -1,5 +1,5 @@
1
1
  import { VTTParser } from './vttparser';
2
- import { utf8ArrayToStr } from '@svta/common-media-library/utils/utf8ArrayToStr';
2
+ import { utf8ArrayToStr } from '../demux/id3';
3
3
  import {
4
4
  RationalTimestamp,
5
5
  toMpegTsClockFromTimescale,
@@ -1,4 +0,0 @@
1
- export const enum DecrypterAesMode {
2
- cbc = 0,
3
- ctr = 1,
4
- }