hls.js 1.5.5-0.canary.9983 → 1.5.5-0.canary.9985

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.
@@ -370,78 +370,6 @@ let ErrorDetails = /*#__PURE__*/function (ErrorDetails) {
370
370
  return ErrorDetails;
371
371
  }({});
372
372
 
373
- class Logger {
374
- constructor(label, logger) {
375
- this.trace = void 0;
376
- this.debug = void 0;
377
- this.log = void 0;
378
- this.warn = void 0;
379
- this.info = void 0;
380
- this.error = void 0;
381
- const lb = `[${label}]:`;
382
- this.trace = noop;
383
- this.debug = logger.debug.bind(null, lb);
384
- this.log = logger.log.bind(null, lb);
385
- this.warn = logger.warn.bind(null, lb);
386
- this.info = logger.info.bind(null, lb);
387
- this.error = logger.error.bind(null, lb);
388
- }
389
- }
390
- const noop = function noop() {};
391
- const fakeLogger = {
392
- trace: noop,
393
- debug: noop,
394
- log: noop,
395
- warn: noop,
396
- info: noop,
397
- error: noop
398
- };
399
- function createLogger() {
400
- return _extends({}, fakeLogger);
401
- }
402
-
403
- // let lastCallTime;
404
- // function formatMsgWithTimeInfo(type, msg) {
405
- // const now = Date.now();
406
- // const diff = lastCallTime ? '+' + (now - lastCallTime) : '0';
407
- // lastCallTime = now;
408
- // msg = (new Date(now)).toISOString() + ' | [' + type + '] > ' + msg + ' ( ' + diff + ' ms )';
409
- // return msg;
410
- // }
411
-
412
- function consolePrintFn(type, id) {
413
- const func = self.console[type];
414
- return func ? func.bind(self.console, `${id ? '[' + id + '] ' : ''}[${type}] >`) : noop;
415
- }
416
- function getLoggerFn(key, debugConfig, id) {
417
- return debugConfig[key] ? debugConfig[key].bind(debugConfig) : consolePrintFn(key, id);
418
- }
419
- let exportedLogger = createLogger();
420
- function enableLogs(debugConfig, context, id) {
421
- // check that console is available
422
- const newLogger = createLogger();
423
- if (typeof console === 'object' && debugConfig === true || typeof debugConfig === 'object') {
424
- const keys = [
425
- // Remove out from list here to hard-disable a log-level
426
- // 'trace',
427
- 'debug', 'log', 'info', 'warn', 'error'];
428
- keys.forEach(key => {
429
- newLogger[key] = getLoggerFn(key, debugConfig, id);
430
- });
431
- // Some browsers don't allow to use bind on console object anyway
432
- // fallback to default if needed
433
- try {
434
- newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.5.5-0.canary.9983"}`);
435
- } catch (e) {
436
- /* log fn threw an exception. All logger methods are no-ops. */
437
- return createLogger();
438
- }
439
- }
440
- exportedLogger = newLogger;
441
- return newLogger;
442
- }
443
- const logger = exportedLogger;
444
-
445
373
  const DECIMAL_RESOLUTION_REGEX = /^(\d+)x(\d+)$/;
446
374
  const ATTR_LIST_REGEX = /(.+?)=(".*?"|.*?)(?:,|$)/g;
447
375
 
@@ -523,6 +451,79 @@ class AttrList {
523
451
  }
524
452
  }
525
453
 
454
+ class Logger {
455
+ constructor(label, logger) {
456
+ this.trace = void 0;
457
+ this.debug = void 0;
458
+ this.log = void 0;
459
+ this.warn = void 0;
460
+ this.info = void 0;
461
+ this.error = void 0;
462
+ const lb = `[${label}]:`;
463
+ this.trace = noop;
464
+ this.debug = logger.debug.bind(null, lb);
465
+ this.log = logger.log.bind(null, lb);
466
+ this.warn = logger.warn.bind(null, lb);
467
+ this.info = logger.info.bind(null, lb);
468
+ this.error = logger.error.bind(null, lb);
469
+ }
470
+ }
471
+ const noop = function noop() {};
472
+ const fakeLogger = {
473
+ trace: noop,
474
+ debug: noop,
475
+ log: noop,
476
+ warn: noop,
477
+ info: noop,
478
+ error: noop
479
+ };
480
+ function createLogger() {
481
+ return _extends({}, fakeLogger);
482
+ }
483
+
484
+ // let lastCallTime;
485
+ // function formatMsgWithTimeInfo(type, msg) {
486
+ // const now = Date.now();
487
+ // const diff = lastCallTime ? '+' + (now - lastCallTime) : '0';
488
+ // lastCallTime = now;
489
+ // msg = (new Date(now)).toISOString() + ' | [' + type + '] > ' + msg + ' ( ' + diff + ' ms )';
490
+ // return msg;
491
+ // }
492
+
493
+ function consolePrintFn(type, id) {
494
+ const func = self.console[type];
495
+ return func ? func.bind(self.console, `${id ? '[' + id + '] ' : ''}[${type}] >`) : noop;
496
+ }
497
+ function getLoggerFn(key, debugConfig, id) {
498
+ return debugConfig[key] ? debugConfig[key].bind(debugConfig) : consolePrintFn(key, id);
499
+ }
500
+ const exportedLogger = createLogger();
501
+ function enableLogs(debugConfig, context, id) {
502
+ // check that console is available
503
+ const newLogger = createLogger();
504
+ if (typeof console === 'object' && debugConfig === true || typeof debugConfig === 'object') {
505
+ const keys = [
506
+ // Remove out from list here to hard-disable a log-level
507
+ // 'trace',
508
+ 'debug', 'log', 'info', 'warn', 'error'];
509
+ keys.forEach(key => {
510
+ newLogger[key] = getLoggerFn(key, debugConfig, id);
511
+ });
512
+ // Some browsers don't allow to use bind on console object anyway
513
+ // fallback to default if needed
514
+ try {
515
+ newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.5.5-0.canary.9985"}`);
516
+ } catch (e) {
517
+ /* log fn threw an exception. All logger methods are no-ops. */
518
+ return createLogger();
519
+ }
520
+ }
521
+ // global exported logger uses the log methods from last call to `enableLogs`
522
+ _extends(exportedLogger, newLogger);
523
+ return newLogger;
524
+ }
525
+ const logger = exportedLogger;
526
+
526
527
  // Avoid exporting const enum so that these values can be inlined
527
528
 
528
529
  function isDateRangeCueAttribute(attrName) {
@@ -3498,10 +3499,10 @@ class PlaylistLoader {
3498
3499
  const loaderContext = loader.context;
3499
3500
  if (loaderContext && loaderContext.url === context.url && loaderContext.level === context.level) {
3500
3501
  // same URL can't overlap
3501
- logger.trace('[playlist-loader]: playlist request ongoing');
3502
+ this.hls.logger.trace('[playlist-loader]: playlist request ongoing');
3502
3503
  return;
3503
3504
  }
3504
- logger.log(`[playlist-loader]: aborting previous loader for type: ${context.type}`);
3505
+ this.hls.logger.log(`[playlist-loader]: aborting previous loader for type: ${context.type}`);
3505
3506
  loader.abort();
3506
3507
  }
3507
3508
 
@@ -3611,7 +3612,7 @@ class PlaylistLoader {
3611
3612
  // alt audio rendition in which quality levels (main)
3612
3613
  // contains both audio+video. but with mixed audio track not signaled
3613
3614
  if (!embeddedAudioFound && levels[0].audioCodec && !levels[0].attrs.AUDIO) {
3614
- logger.log('[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one');
3615
+ this.hls.logger.log('[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one');
3615
3616
  audioTracks.unshift({
3616
3617
  type: 'main',
3617
3618
  name: 'main',
@@ -3710,7 +3711,7 @@ class PlaylistLoader {
3710
3711
  message += ` id: ${context.id} group-id: "${context.groupId}"`;
3711
3712
  }
3712
3713
  const error = new Error(message);
3713
- logger.warn(`[playlist-loader]: ${message}`);
3714
+ this.hls.logger.warn(`[playlist-loader]: ${message}`);
3714
3715
  let details = ErrorDetails.UNKNOWN;
3715
3716
  let fatal = false;
3716
3717
  const loader = this.getInternalLoader(context);
@@ -5712,7 +5713,12 @@ class BasePlaylistController extends Logger {
5712
5713
  const cdnAge = lastAdvanced + details.ageHeader;
5713
5714
  let currentGoal = Math.min(cdnAge - details.partTarget, details.targetduration * 1.5);
5714
5715
  if (currentGoal > 0) {
5715
- if (previousDetails && currentGoal > previousDetails.tuneInGoal) {
5716
+ if (cdnAge > details.targetduration * 3) {
5717
+ // Omit segment and part directives when the last response was more than 3 target durations ago,
5718
+ this.log(`Playlist last advanced ${lastAdvanced.toFixed(2)}s ago. Omitting segment and part directives.`);
5719
+ msn = undefined;
5720
+ part = undefined;
5721
+ } else if (previousDetails != null && previousDetails.tuneInGoal && cdnAge - details.partTarget > previousDetails.tuneInGoal) {
5716
5722
  // If we attempted to get the next or latest playlist update, but currentGoal increased,
5717
5723
  // then we either can't catchup, or the "age" header cannot be trusted.
5718
5724
  this.warn(`CDN Tune-in goal increased from: ${previousDetails.tuneInGoal} to: ${currentGoal} with playlist age: ${details.age}`);
@@ -10058,7 +10064,12 @@ class LevelController extends BasePlaylistController {
10058
10064
  if (curLevel.fragmentError === 0) {
10059
10065
  curLevel.loadError = 0;
10060
10066
  }
10061
- this.playlistLoaded(level, data, curLevel.details);
10067
+ // Ignore matching details populated by loading a Media Playlist directly
10068
+ let previousDetails = curLevel.details;
10069
+ if (previousDetails === data.details && previousDetails.advanced) {
10070
+ previousDetails = undefined;
10071
+ }
10072
+ this.playlistLoaded(level, data, previousDetails);
10062
10073
  } else if ((_data$deliveryDirecti2 = data.deliveryDirectives) != null && _data$deliveryDirecti2.skip) {
10063
10074
  // received a delta playlist update that cannot be merged
10064
10075
  details.deltaUpdateFailed = true;
@@ -19923,7 +19934,7 @@ class Hls {
19923
19934
  * Get the video-dev/hls.js package version.
19924
19935
  */
19925
19936
  static get version() {
19926
- return "1.5.5-0.canary.9983";
19937
+ return "1.5.5-0.canary.9985";
19927
19938
  }
19928
19939
 
19929
19940
  /**