hls.js 1.5.8-0.canary.10153 → 1.5.8-0.canary.10155

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 (41) hide show
  1. package/dist/hls.js +764 -517
  2. package/dist/hls.js.map +1 -1
  3. package/dist/hls.light.js +585 -351
  4. package/dist/hls.light.js.map +1 -1
  5. package/dist/hls.light.min.js +1 -1
  6. package/dist/hls.light.min.js.map +1 -1
  7. package/dist/hls.light.mjs +580 -352
  8. package/dist/hls.light.mjs.map +1 -1
  9. package/dist/hls.min.js +1 -1
  10. package/dist/hls.min.js.map +1 -1
  11. package/dist/hls.mjs +789 -548
  12. package/dist/hls.mjs.map +1 -1
  13. package/dist/hls.worker.js +1 -1
  14. package/dist/hls.worker.js.map +1 -1
  15. package/package.json +1 -1
  16. package/src/controller/base-playlist-controller.ts +7 -2
  17. package/src/controller/cmcd-controller.ts +1 -1
  18. package/src/controller/eme-controller.ts +1 -1
  19. package/src/controller/id3-track-controller.ts +4 -3
  20. package/src/controller/level-controller.ts +1 -1
  21. package/src/demux/audio/aacdemuxer.ts +2 -2
  22. package/src/demux/audio/ac3-demuxer.ts +4 -3
  23. package/src/demux/audio/base-audio-demuxer.ts +16 -14
  24. package/src/demux/audio/mp3demuxer.ts +4 -3
  25. package/src/demux/audio/mpegaudio.ts +1 -1
  26. package/src/demux/mp4demuxer.ts +7 -7
  27. package/src/demux/video/hevc-video-parser.ts +4 -1
  28. package/src/events.ts +1 -1
  29. package/src/exports-named.ts +1 -1
  30. package/src/loader/fragment-loader.ts +1 -1
  31. package/src/loader/key-loader.ts +1 -1
  32. package/src/remux/mp4-remuxer.ts +1 -1
  33. package/src/types/component-api.ts +1 -1
  34. package/src/types/remuxer.ts +1 -1
  35. package/src/utils/fetch-loader.ts +1 -1
  36. package/src/utils/imsc1-ttml-parser.ts +1 -1
  37. package/src/utils/keysystem-util.ts +1 -6
  38. package/src/utils/mp4-tools.ts +1 -1
  39. package/src/utils/utf8-utils.ts +18 -0
  40. package/src/utils/webvtt-parser.ts +1 -1
  41. package/src/demux/id3.ts +0 -411
package/package.json CHANGED
@@ -130,5 +130,5 @@
130
130
  "url-toolkit": "2.2.5",
131
131
  "wrangler": "3.45.0"
132
132
  },
133
- "version": "1.5.8-0.canary.10153"
133
+ "version": "1.5.8-0.canary.10155"
134
134
  }
@@ -1,8 +1,13 @@
1
1
  import type Hls from '../hls';
2
2
  import type { NetworkComponentAPI } from '../types/component-api';
3
- import { getSkipValue, HlsSkip, HlsUrlParameters, Level } from '../types/level';
3
+ import {
4
+ getSkipValue,
5
+ HlsSkip,
6
+ HlsUrlParameters,
7
+ type Level,
8
+ } from '../types/level';
4
9
  import { computeReloadInterval, mergeDetails } from '../utils/level-helper';
5
- import { ErrorData } from '../types/events';
10
+ import type { ErrorData } from '../types/events';
6
11
  import { getRetryDelay, isTimeoutError } from '../utils/error-helper';
7
12
  import { NetworkErrorAction } from './error-controller';
8
13
  import { Logger } from '../utils/logger';
@@ -1,5 +1,5 @@
1
1
  import { Events } from '../events';
2
- import Hls from '../hls';
2
+ import type Hls from '../hls';
3
3
  import { Cmcd } from '@svta/common-media-library/cmcd/Cmcd';
4
4
  import { CmcdObjectType } from '@svta/common-media-library/cmcd/CmcdObjectType';
5
5
  import { CmcdStreamingFormat } from '@svta/common-media-library/cmcd/CmcdStreamingFormat';
@@ -19,7 +19,7 @@ import {
19
19
  KeySystems,
20
20
  requestMediaKeySystemAccess,
21
21
  } from '../utils/mediakeys-helper';
22
- import { strToUtf8array } from '../utils/keysystem-util';
22
+ import { strToUtf8array } from '../utils/utf8-utils';
23
23
  import { base64Decode } from '../utils/numeric-encoding-utils';
24
24
  import { DecryptData, LevelKey } from '../loader/level-key';
25
25
  import Hex from '../utils/hex';
@@ -4,7 +4,6 @@ import {
4
4
  clearCurrentCues,
5
5
  removeCuesInRange,
6
6
  } from '../utils/texttrack-utils';
7
- import * as ID3 from '../demux/id3';
8
7
  import {
9
8
  DateRange,
10
9
  isDateRangeCueAttribute,
@@ -19,6 +18,8 @@ import type {
19
18
  } from '../types/events';
20
19
  import type { ComponentAPI } from '../types/component-api';
21
20
  import type Hls from '../hls';
21
+ import { getId3Frames } from '@svta/common-media-library/id3/getId3Frames';
22
+ import { isId3TimestampFrame } from '@svta/common-media-library/id3/isId3TimestampFrame';
22
23
 
23
24
  declare global {
24
25
  interface Window {
@@ -210,7 +211,7 @@ class ID3TrackController implements ComponentAPI {
210
211
  continue;
211
212
  }
212
213
 
213
- const frames = ID3.getID3Frames(samples[i].data);
214
+ const frames = getId3Frames(samples[i].data);
214
215
  if (frames) {
215
216
  const startTime = samples[i].pts;
216
217
  let endTime: number = startTime + samples[i].duration;
@@ -227,7 +228,7 @@ class ID3TrackController implements ComponentAPI {
227
228
  for (let j = 0; j < frames.length; j++) {
228
229
  const frame = frames[j];
229
230
  // Safari doesn't put the timestamp frame in the TextTrack
230
- if (!ID3.isTimeStampFrame(frame)) {
231
+ if (!isId3TimestampFrame(frame)) {
231
232
  // add a bounds to any unbounded cues
232
233
  this.updateId3CueEnds(startTime, type);
233
234
  const cue = createCueWithDataFields(
@@ -1,4 +1,4 @@
1
- import {
1
+ import type {
2
2
  ManifestLoadedData,
3
3
  ManifestParsedData,
4
4
  LevelLoadedData,
@@ -5,7 +5,7 @@ import BaseAudioDemuxer from './base-audio-demuxer';
5
5
  import * as ADTS from './adts';
6
6
  import * as MpegAudio from './mpegaudio';
7
7
  import { logger } from '../../utils/logger';
8
- import * as ID3 from '../id3';
8
+ import { getId3Data } from '@svta/common-media-library/id3/getId3Data';
9
9
  import type { HlsEventEmitter } from '../../events';
10
10
  import type { HlsConfig } from '../../config';
11
11
 
@@ -51,7 +51,7 @@ class AACDemuxer extends BaseAudioDemuxer {
51
51
  // Look for ADTS header | 1111 1111 | 1111 X00X | where X can be either 0 or 1
52
52
  // Layer bits (position 14 and 15) in header should be always 0 for ADTS
53
53
  // More info https://wiki.multimedia.cx/index.php?title=ADTS
54
- const id3Data = ID3.getID3Data(data, 0);
54
+ const id3Data = getId3Data(data, 0);
55
55
  let offset = id3Data?.length || 0;
56
56
 
57
57
  if (MpegAudio.probe(data, offset)) {
@@ -1,5 +1,6 @@
1
1
  import BaseAudioDemuxer from './base-audio-demuxer';
2
- import { getID3Data, getTimeStamp } from '../id3';
2
+ import { getId3Data } from '@svta/common-media-library/id3/getId3Data';
3
+ import { getId3Timestamp } from '@svta/common-media-library/id3/getId3Timestamp';
3
4
  import { getAudioBSID } from './dolby';
4
5
  import type { HlsEventEmitter } from '../../events';
5
6
  import type { AudioFrame, DemuxedAudioTrack } from '../../types/demuxer';
@@ -61,7 +62,7 @@ export class AC3Demuxer extends BaseAudioDemuxer {
61
62
  return false;
62
63
  }
63
64
 
64
- const id3Data = getID3Data(data, 0);
65
+ const id3Data = getId3Data(data, 0);
65
66
  if (!id3Data) {
66
67
  return false;
67
68
  }
@@ -71,7 +72,7 @@ export class AC3Demuxer extends BaseAudioDemuxer {
71
72
  if (
72
73
  data[offset] === 0x0b &&
73
74
  data[offset + 1] === 0x77 &&
74
- getTimeStamp(id3Data) !== undefined &&
75
+ getId3Timestamp(id3Data) !== undefined &&
75
76
  // check the bsid to confirm ac-3
76
77
  getAudioBSID(data, offset) < 16
77
78
  ) {
@@ -1,19 +1,21 @@
1
- import * as ID3 from '../id3';
2
1
  import {
3
- DemuxerResult,
4
- Demuxer,
5
- DemuxedAudioTrack,
6
- AudioFrame,
7
- DemuxedMetadataTrack,
8
- DemuxedVideoTrackBase,
9
- DemuxedUserdataTrack,
10
- KeyData,
2
+ type DemuxerResult,
3
+ type Demuxer,
4
+ type DemuxedAudioTrack,
5
+ type AudioFrame,
6
+ type DemuxedMetadataTrack,
7
+ type DemuxedVideoTrackBase,
8
+ type DemuxedUserdataTrack,
9
+ type KeyData,
11
10
  MetadataSchema,
12
11
  } from '../../types/demuxer';
13
12
  import { dummyTrack } from '../dummy-demuxed-track';
14
13
  import { appendUint8Array } from '../../utils/mp4-tools';
15
14
  import { sliceUint8 } from '../../utils/typed-array';
16
15
  import { RationalTimestamp } from '../../utils/timescale-conversion';
16
+ import { getId3Data } from '@svta/common-media-library/id3/getId3Data';
17
+ import { getId3Timestamp } from '@svta/common-media-library/id3/getId3Timestamp';
18
+ import { canParseId3 } from '@svta/common-media-library/id3/canParseId3';
17
19
 
18
20
  class BaseAudioDemuxer implements Demuxer {
19
21
  protected _audioTrack!: DemuxedAudioTrack;
@@ -69,12 +71,12 @@ class BaseAudioDemuxer implements Demuxer {
69
71
  this.cachedData = null;
70
72
  }
71
73
 
72
- let id3Data: Uint8Array | undefined = ID3.getID3Data(data, 0);
74
+ let id3Data: Uint8Array | undefined = getId3Data(data, 0);
73
75
  let offset = id3Data ? id3Data.length : 0;
74
76
  let lastDataIndex;
75
77
  const track = this._audioTrack;
76
78
  const id3Track = this._id3Track;
77
- const timestamp = id3Data ? ID3.getTimeStamp(id3Data) : undefined;
79
+ const timestamp = id3Data ? getId3Timestamp(id3Data) : undefined;
78
80
  const length = data.length;
79
81
 
80
82
  if (
@@ -111,9 +113,9 @@ class BaseAudioDemuxer implements Demuxer {
111
113
  } else {
112
114
  offset = length;
113
115
  }
114
- } else if (ID3.canParse(data, offset)) {
115
- // after a ID3.canParse, a call to ID3.getID3Data *should* always returns some data
116
- id3Data = ID3.getID3Data(data, offset)!;
116
+ } else if (canParseId3(data, offset)) {
117
+ // after a canParse, a call to getId3Data *should* always returns some data
118
+ id3Data = getId3Data(data, offset)!;
117
119
  id3Track.samples.push({
118
120
  pts: this.lastPTS,
119
121
  dts: this.lastPTS,
@@ -2,10 +2,11 @@
2
2
  * MP3 demuxer
3
3
  */
4
4
  import BaseAudioDemuxer from './base-audio-demuxer';
5
- import { getID3Data, getTimeStamp } from '../id3';
6
5
  import { getAudioBSID } from './dolby';
7
6
  import { logger } from '../../utils/logger';
8
7
  import * as MpegAudio from './mpegaudio';
8
+ import { getId3Data } from '@svta/common-media-library/id3/getId3Data';
9
+ import { getId3Timestamp } from '@svta/common-media-library/id3/getId3Timestamp';
9
10
 
10
11
  class MP3Demuxer extends BaseAudioDemuxer {
11
12
  resetInitSegment(
@@ -39,7 +40,7 @@ class MP3Demuxer extends BaseAudioDemuxer {
39
40
  // Look for MPEG header | 1111 1111 | 111X XYZX | where X can be either 0 or 1 and Y or Z should be 1
40
41
  // Layer bits (position 14 and 15) in header should be always different from 0 (Layer I or Layer II or Layer III)
41
42
  // More info http://www.mp3-tech.org/programmer/frame_header.html
42
- const id3Data = getID3Data(data, 0);
43
+ const id3Data = getId3Data(data, 0);
43
44
  let offset = id3Data?.length || 0;
44
45
 
45
46
  // Check for ac-3|ec-3 sync bytes and return false if present
@@ -47,7 +48,7 @@ class MP3Demuxer extends BaseAudioDemuxer {
47
48
  id3Data &&
48
49
  data[offset] === 0x0b &&
49
50
  data[offset + 1] === 0x77 &&
50
- getTimeStamp(id3Data) !== undefined &&
51
+ getId3Timestamp(id3Data) !== undefined &&
51
52
  // check the bsid to confirm ac-3 or ec-3 (not mp3)
52
53
  getAudioBSID(data, offset) <= 16
53
54
  ) {
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * MPEG parser helper
3
3
  */
4
- import { DemuxedAudioTrack } from '../../types/demuxer';
4
+ import type { DemuxedAudioTrack } from '../../types/demuxer';
5
5
 
6
6
  let chromeVersion: number | null = null;
7
7
 
@@ -2,13 +2,13 @@
2
2
  * MP4 demuxer
3
3
  */
4
4
  import {
5
- Demuxer,
6
- DemuxerResult,
7
- PassthroughTrack,
8
- DemuxedAudioTrack,
9
- DemuxedUserdataTrack,
10
- DemuxedMetadataTrack,
11
- KeyData,
5
+ type Demuxer,
6
+ type DemuxerResult,
7
+ type PassthroughTrack,
8
+ type DemuxedAudioTrack,
9
+ type DemuxedUserdataTrack,
10
+ type DemuxedMetadataTrack,
11
+ type KeyData,
12
12
  MetadataSchema,
13
13
  } from '../types/demuxer';
14
14
  import {
@@ -1,5 +1,8 @@
1
1
  import BaseVideoParser from './base-video-parser';
2
- import { DemuxedVideoTrack, DemuxedUserdataTrack } from '../../types/demuxer';
2
+ import type {
3
+ DemuxedVideoTrack,
4
+ DemuxedUserdataTrack,
5
+ } from '../../types/demuxer';
3
6
  import { parseSEIMessageFromNALu } from '../../utils/mp4-tools';
4
7
 
5
8
  import type { PES } from '../tsdemuxer';
package/src/events.ts CHANGED
@@ -1,4 +1,4 @@
1
- import {
1
+ import type {
2
2
  ManifestLoadedData,
3
3
  ManifestLoadingData,
4
4
  MediaAttachedData,
@@ -1,7 +1,7 @@
1
1
  import Hls from './hls';
2
2
  import { Events } from './events';
3
3
  import { ErrorTypes, ErrorDetails } from './errors';
4
- import { Level } from './types/level';
4
+ import type { Level } from './types/level';
5
5
  import AbrController from './controller/abr-controller';
6
6
  import AudioTrackController from './controller/audio-track-controller';
7
7
  import AudioStreamController from './controller/audio-stream-controller';
@@ -1,6 +1,6 @@
1
1
  import { ErrorTypes, ErrorDetails } from '../errors';
2
2
  import { Fragment } from './fragment';
3
- import {
3
+ import type {
4
4
  Loader,
5
5
  LoaderConfiguration,
6
6
  FragmentLoaderContext,
@@ -1,5 +1,5 @@
1
1
  import { ErrorTypes, ErrorDetails } from '../errors';
2
- import {
2
+ import type {
3
3
  LoaderStats,
4
4
  LoaderResponse,
5
5
  LoaderConfiguration,
@@ -4,7 +4,7 @@ import type { HlsEventEmitter } from '../events';
4
4
  import { Events } from '../events';
5
5
  import { ErrorTypes, ErrorDetails } from '../errors';
6
6
  import { logger } from '../utils/logger';
7
- import {
7
+ import type {
8
8
  InitSegmentData,
9
9
  Remuxer,
10
10
  RemuxerResult,
@@ -1,4 +1,4 @@
1
- import EwmaBandWidthEstimator from '../utils/ewma-bandwidth-estimator';
1
+ import type EwmaBandWidthEstimator from '../utils/ewma-bandwidth-estimator';
2
2
 
3
3
  export interface ComponentAPI {
4
4
  destroy(): void;
@@ -1,5 +1,5 @@
1
1
  import type { TrackSet } from './track';
2
- import {
2
+ import type {
3
3
  DemuxedAudioTrack,
4
4
  DemuxedMetadataTrack,
5
5
  DemuxedUserdataTrack,
@@ -1,4 +1,4 @@
1
- import {
1
+ import type {
2
2
  LoaderCallbacks,
3
3
  LoaderContext,
4
4
  Loader,
@@ -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 '../demux/id3';
4
+ import { utf8ArrayToStr } from '@svta/common-media-library/utils/utf8ArrayToStr';
5
5
  import {
6
6
  RationalTimestamp,
7
7
  toTimescaleFromScale,
@@ -1,4 +1,5 @@
1
1
  import { base64Decode } from './numeric-encoding-utils';
2
+ import { strToUtf8array } from './utf8-utils';
2
3
 
3
4
  function getKeyIdBytes(str: string): Uint8Array {
4
5
  const keyIdbytes = strToUtf8array(str).subarray(0, 16);
@@ -40,9 +41,3 @@ export function convertDataUriToArrayBytes(uri: string): Uint8Array | null {
40
41
  }
41
42
  return keydata;
42
43
  }
43
-
44
- export function strToUtf8array(str: string): Uint8Array {
45
- return Uint8Array.from(unescape(encodeURIComponent(str)), (c) =>
46
- c.charCodeAt(0),
47
- );
48
- }
@@ -1,6 +1,6 @@
1
1
  import { ElementaryStreamTypes } from '../loader/fragment';
2
2
  import { sliceUint8 } from './typed-array';
3
- import { utf8ArrayToStr } from '../demux/id3';
3
+ import { utf8ArrayToStr } from '@svta/common-media-library/utils/utf8ArrayToStr';
4
4
  import { logger } from '../utils/logger';
5
5
  import Hex from './hex';
6
6
  import type { PassthroughTrack, UserdataSample } from '../types/demuxer';
@@ -0,0 +1,18 @@
1
+ // breaking up those two types in order to clarify what is happening in the decoding path.
2
+ type DecodedFrame<T> = { key: string; data: T; info?: any };
3
+ export type Frame = DecodedFrame<ArrayBuffer | string>;
4
+ // http://stackoverflow.com/questions/8936984/uint8array-to-string-in-javascript/22373197
5
+ // http://www.onicos.com/staff/iz/amuse/javascript/expert/utf.txt
6
+ /* utf.js - UTF-8 <=> UTF-16 convertion
7
+ *
8
+ * Copyright (C) 1999 Masanao Izumo <iz@onicos.co.jp>
9
+ * Version: 1.0
10
+ * LastModified: Dec 25 1999
11
+ * This library is free. You can redistribute it and/or modify it.
12
+ */
13
+
14
+ export function strToUtf8array(str: string): Uint8Array {
15
+ return Uint8Array.from(unescape(encodeURIComponent(str)), (c) =>
16
+ c.charCodeAt(0),
17
+ );
18
+ }
@@ -1,5 +1,5 @@
1
1
  import { VTTParser } from './vttparser';
2
- import { utf8ArrayToStr } from '../demux/id3';
2
+ import { utf8ArrayToStr } from '@svta/common-media-library/utils/utf8ArrayToStr';
3
3
  import {
4
4
  RationalTimestamp,
5
5
  toMpegTsClockFromTimescale,