hls.js 1.6.0-beta.3.0.canary.10978 → 1.6.0-beta.3.0.canary.10980

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.
@@ -15,6 +15,7 @@ import {
15
15
  isCompatibleTrackChange,
16
16
  isManagedMediaSource,
17
17
  } from '../utils/mediasource-helper';
18
+ import { stringify } from '../utils/safe-json-stringify';
18
19
  import type { FragmentTracker } from './fragment-tracker';
19
20
  import type { HlsConfig } from '../config';
20
21
  import type Hls from '../hls';
@@ -353,8 +354,8 @@ export default class BufferController extends Logger implements ComponentAPI {
353
354
  }
354
355
  this
355
356
  .log(`attachTransferred: (bufferCodecEventsTotal ${this.bufferCodecEventsTotal})
356
- required tracks: ${JSON.stringify(requiredTracks, (key, value) => (key === 'initSegment' ? undefined : value))};
357
- transfer tracks: ${JSON.stringify(transferredTracks, (key, value) => (key === 'initSegment' ? undefined : value))}}`);
357
+ required tracks: ${stringify(requiredTracks, (key, value) => (key === 'initSegment' ? undefined : value))};
358
+ transfer tracks: ${stringify(transferredTracks, (key, value) => (key === 'initSegment' ? undefined : value))}}`);
358
359
  if (!isCompatibleTrackChange(transferredTracks, requiredTracks)) {
359
360
  // destroy attaching media source
360
361
  data.mediaSource = null;
@@ -1322,7 +1323,7 @@ transfer tracks: ${JSON.stringify(transferredTracks, (key, value) => (key === 'i
1322
1323
  private checkPendingTracks() {
1323
1324
  const { bufferCodecEventsTotal, pendingTrackCount, tracks } = this;
1324
1325
  this.log(
1325
- `checkPendingTracks (pending: ${pendingTrackCount} codec events expected: ${bufferCodecEventsTotal}) ${JSON.stringify(tracks)}`,
1326
+ `checkPendingTracks (pending: ${pendingTrackCount} codec events expected: ${bufferCodecEventsTotal}) ${stringify(tracks)}`,
1326
1327
  );
1327
1328
  // Check if we've received all of the expected bufferCodec events. When none remain, create all the sourceBuffers at once.
1328
1329
  // This is important because the MSE spec allows implementations to throw QuotaExceededErrors if creating new sourceBuffers after
@@ -1391,7 +1392,7 @@ transfer tracks: ${JSON.stringify(transferredTracks, (key, value) => (key === 'i
1391
1392
  const mimeType = `${track.container};codecs=${codec}`;
1392
1393
  track.codec = codec;
1393
1394
  this.log(
1394
- `creating sourceBuffer(${mimeType})${this.currentOp(type) ? ' Queued' : ''} ${JSON.stringify(track)}`,
1395
+ `creating sourceBuffer(${mimeType})${this.currentOp(type) ? ' Queued' : ''} ${stringify(track)}`,
1395
1396
  );
1396
1397
  try {
1397
1398
  const sb = mediaSource.addSourceBuffer(
@@ -13,6 +13,7 @@ import {
13
13
  import { AttrList } from '../utils/attr-list';
14
14
  import { reassignFragmentLevelIndexes } from '../utils/level-helper';
15
15
  import { Logger } from '../utils/logger';
16
+ import { stringify } from '../utils/safe-json-stringify';
16
17
  import type { RetryConfig } from '../config';
17
18
  import type Hls from '../hls';
18
19
  import type { NetworkComponentAPI } from '../types/component-api';
@@ -221,9 +222,9 @@ export default class ContentSteeringController
221
222
  data.error.message
222
223
  }") with content-steering for Pathway: ${errorPathway} levels: ${
223
224
  levels ? levels.length : levels
224
- } priorities: ${JSON.stringify(
225
+ } priorities: ${stringify(
225
226
  pathwayPriority,
226
- )} penalized: ${JSON.stringify(this.penalizedPathways)}`,
227
+ )} penalized: ${stringify(this.penalizedPathways)}`,
227
228
  );
228
229
  }
229
230
  }
@@ -27,6 +27,7 @@ import {
27
27
  type PsshInvalidResult,
28
28
  } from '../utils/mp4-tools';
29
29
  import { base64Decode } from '../utils/numeric-encoding-utils';
30
+ import { stringify } from '../utils/safe-json-stringify';
30
31
  import { strToUtf8array } from '../utils/utf8-utils';
31
32
  import type { EMEControllerConfig, HlsConfig, LoadPolicy } from '../config';
32
33
  import type Hls from '../hls';
@@ -254,7 +255,7 @@ class EMEController extends Logger implements ComponentAPI {
254
255
  let keySystemAccess = keySystemAccessPromises?.keySystemAccess;
255
256
  if (!keySystemAccess) {
256
257
  this.log(
257
- `Requesting encrypted media "${keySystem}" key-system access with config: ${JSON.stringify(
258
+ `Requesting encrypted media "${keySystem}" key-system access with config: ${stringify(
258
259
  mediaKeySystemConfigs,
259
260
  )}`,
260
261
  );
@@ -519,7 +520,7 @@ class EMEController extends Logger implements ComponentAPI {
519
520
  details: ErrorDetails.KEY_SYSTEM_NO_CONFIGURED_LICENSE,
520
521
  fatal: true,
521
522
  },
522
- `Missing key-system license configuration options ${JSON.stringify({
523
+ `Missing key-system license configuration options ${stringify({
523
524
  drmSystems: this.config.drmSystems,
524
525
  })}`,
525
526
  );
@@ -8,6 +8,7 @@ import {
8
8
  addEventListener,
9
9
  removeEventListener,
10
10
  } from '../utils/event-listener-helper';
11
+ import { stringify } from '../utils/safe-json-stringify';
11
12
  import type { InFlightData } from './base-stream-controller';
12
13
  import type { InFlightFragments } from '../hls';
13
14
  import type Hls from '../hls';
@@ -486,7 +487,7 @@ export default class GapController extends TaskLoop {
486
487
  const error = new Error(
487
488
  `Playback stalling at @${
488
489
  media.currentTime
489
- } due to low buffer (${JSON.stringify(bufferInfo)})`,
490
+ } due to low buffer (${stringify(bufferInfo)})`,
490
491
  );
491
492
  this.warn(error.message);
492
493
  hls.trigger(Events.ERROR, {
@@ -6,6 +6,7 @@ import {
6
6
  isSCTE35Attribute,
7
7
  } from '../loader/date-range';
8
8
  import { MetadataSchema } from '../types/demuxer';
9
+ import { stringify } from '../utils/safe-json-stringify';
9
10
  import {
10
11
  clearCurrentCues,
11
12
  removeCuesInRange,
@@ -54,7 +55,7 @@ function createCueWithDataFields(
54
55
  cue = new Cue(
55
56
  startTime,
56
57
  endTime,
57
- JSON.stringify(type ? { type, ...data } : data),
58
+ stringify(type ? { type, ...data } : data),
58
59
  );
59
60
  }
60
61
  return cue;
@@ -12,6 +12,7 @@ import {
12
12
  videoCodecPreferenceValue,
13
13
  } from '../utils/codecs';
14
14
  import { reassignFragmentLevelIndexes } from '../utils/level-helper';
15
+ import { stringify } from '../utils/safe-json-stringify';
15
16
  import type ContentSteeringController from './content-steering-controller';
16
17
  import type Hls from '../hls';
17
18
  import type {
@@ -248,7 +249,7 @@ export default class LevelController extends BasePlaylistController {
248
249
  if (this.hls) {
249
250
  if (data.levels.length) {
250
251
  this.warn(
251
- `One or more CODECS in variant not supported: ${JSON.stringify(
252
+ `One or more CODECS in variant not supported: ${stringify(
252
253
  data.levels[0].attrs,
253
254
  )}`,
254
255
  );
@@ -14,6 +14,7 @@ import { ErrorDetails, ErrorTypes } from '../errors';
14
14
  import { Events } from '../events';
15
15
  import { PlaylistLevelType } from '../types/loader';
16
16
  import { getM2TSSupportedAudioTypes } from '../utils/codecs';
17
+ import { stringify } from '../utils/safe-json-stringify';
17
18
  import type { WorkerContext } from './inject-worker';
18
19
  import type { HlsEventEmitter, HlsListeners } from '../events';
19
20
  import type Hls from '../hls';
@@ -95,7 +96,7 @@ export default class TransmuxerInterface {
95
96
  cmd: 'init',
96
97
  typeSupported: m2tsTypeSupported,
97
98
  id,
98
- config: JSON.stringify(config),
99
+ config: stringify(config),
99
100
  });
100
101
  } catch (err) {
101
102
  logger.warn(
@@ -143,7 +144,7 @@ export default class TransmuxerInterface {
143
144
  resetNo: instanceNo,
144
145
  typeSupported: m2tsTypeSupported,
145
146
  id: this.id,
146
- config: JSON.stringify(config),
147
+ config: stringify(config),
147
148
  });
148
149
  }
149
150
  }
@@ -1,3 +1,4 @@
1
+ import { stringify } from './safe-json-stringify';
1
2
  import { logger } from '../utils/logger';
2
3
  import type OutputFilter from './output-filter';
3
4
 
@@ -593,10 +594,7 @@ export class CaptionScreen {
593
594
  }
594
595
 
595
596
  setPAC(pacData: PACData) {
596
- this.logger.log(
597
- VerboseLevel.INFO,
598
- () => 'pacData = ' + JSON.stringify(pacData),
599
- );
597
+ this.logger.log(VerboseLevel.INFO, () => 'pacData = ' + stringify(pacData));
600
598
  let newRow = pacData.row - 1;
601
599
  if (this.nrRollUpRows && newRow < this.nrRollUpRows - 1) {
602
600
  newRow = this.nrRollUpRows - 1;
@@ -650,10 +648,7 @@ export class CaptionScreen {
650
648
  * Set background/extra foreground, but first do back_space, and then insert space (backwards compatibility).
651
649
  */
652
650
  setBkgData(bkgData: Partial<PenStyles>) {
653
- this.logger.log(
654
- VerboseLevel.INFO,
655
- () => 'bkgData = ' + JSON.stringify(bkgData),
656
- );
651
+ this.logger.log(VerboseLevel.INFO, () => 'bkgData = ' + stringify(bkgData));
657
652
  this.backSpace();
658
653
  this.setPen(bkgData);
659
654
  this.insertChar(0x20); // Space
@@ -951,7 +946,7 @@ class Cea608Channel {
951
946
  } else {
952
947
  styles.foreground = 'white';
953
948
  }
954
- this.logger.log(VerboseLevel.INFO, 'MIDROW: ' + JSON.stringify(styles));
949
+ this.logger.log(VerboseLevel.INFO, 'MIDROW: ' + stringify(styles));
955
950
  this.writeScreen.setPen(styles);
956
951
  }
957
952
 
@@ -3,6 +3,7 @@
3
3
  */
4
4
 
5
5
  import { logger } from './logger';
6
+ import { stringify } from './safe-json-stringify';
6
7
  import { DateRange } from '../loader/date-range';
7
8
  import { assignProgramDateTime, mapDateRanges } from '../loader/m3u8-parser';
8
9
  import type { Fragment, MediaFragment, Part } from '../loader/fragment';
@@ -344,7 +345,7 @@ function mergeDateRanges(
344
345
  }
345
346
  } else {
346
347
  logger.warn(
347
- `Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(
348
+ `Ignoring invalid Playlist Delta Update DATERANGE tag: "${stringify(
348
349
  deltaDateRanges[id].attr,
349
350
  )}"`,
350
351
  );
@@ -1,6 +1,7 @@
1
1
  import { codecsSetSelectionPreferenceValue } from './codecs';
2
2
  import { getVideoSelectionOptions } from './hdr';
3
3
  import { logger } from './logger';
4
+ import { stringify } from './safe-json-stringify';
4
5
  import type Hls from '../hls';
5
6
  import type { Level, VideoRange } from '../types/level';
6
7
  import type {
@@ -165,9 +166,7 @@ export function getStartCodecTier(
165
166
  ) {
166
167
  logStartCodecCandidateIgnored(
167
168
  candidate,
168
- `no variants with VIDEO-RANGE of ${JSON.stringify(
169
- videoRanges,
170
- )} found`,
169
+ `no variants with VIDEO-RANGE of ${stringify(videoRanges)} found`,
171
170
  );
172
171
  return selected;
173
172
  }
@@ -1,6 +1,11 @@
1
- const replacer = () => {
1
+ const omitCircularRefsReplacer = (
2
+ replacer: ((this: any, key: string, value: any) => any) | undefined,
3
+ ) => {
2
4
  const known = new WeakSet();
3
5
  return (_, value) => {
6
+ if (replacer) {
7
+ value = replacer(_, value);
8
+ }
4
9
  if (typeof value === 'object' && value !== null) {
5
10
  if (known.has(value)) {
6
11
  return;
@@ -11,5 +16,7 @@ const replacer = () => {
11
16
  };
12
17
  };
13
18
 
14
- export const stringify = <T>(object: T): string =>
15
- JSON.stringify(object, replacer());
19
+ export const stringify = <T>(
20
+ object: T,
21
+ replacer?: (this: any, key: string, value: any) => any,
22
+ ): string => JSON.stringify(object, omitCircularRefsReplacer(replacer));