hls.js 1.5.12-0.canary.10349 → 1.5.12-0.canary.10352

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.js CHANGED
@@ -522,7 +522,7 @@
522
522
  // Some browsers don't allow to use bind on console object anyway
523
523
  // fallback to default if needed
524
524
  try {
525
- newLogger.log("Debug logs enabled for \"" + context + "\" in hls.js version " + "1.5.12-0.canary.10349");
525
+ newLogger.log("Debug logs enabled for \"" + context + "\" in hls.js version " + "1.5.12-0.canary.10352");
526
526
  } catch (e) {
527
527
  /* log fn threw an exception. All logger methods are no-ops. */
528
528
  return createLogger();
@@ -7304,12 +7304,9 @@
7304
7304
  }
7305
7305
  if (videoPreference) {
7306
7306
  allowedVideoRanges = videoPreference.allowedVideoRanges || VideoRangeValues.slice(0);
7307
- preferHDR = videoPreference.preferHDR !== undefined ? videoPreference.preferHDR : isHdrSupported();
7308
- if (preferHDR) {
7309
- allowedVideoRanges = allowedVideoRanges.filter(function (range) {
7310
- return range !== 'SDR';
7311
- });
7312
- } else {
7307
+ var allowAutoPreferHDR = allowedVideoRanges.join('') !== 'SDR' && !videoPreference.videoCodec;
7308
+ preferHDR = videoPreference.preferHDR !== undefined ? videoPreference.preferHDR : allowAutoPreferHDR && isHdrSupported();
7309
+ if (!preferHDR) {
7313
7310
  allowedVideoRanges = ['SDR'];
7314
7311
  }
7315
7312
  }
@@ -7323,13 +7320,15 @@
7323
7320
  var codecSets = Object.keys(codecTiers);
7324
7321
  var channelsPreference = audioPreference == null ? void 0 : audioPreference.channels;
7325
7322
  var audioCodecPreference = audioPreference == null ? void 0 : audioPreference.audioCodec;
7323
+ var videoCodecPreference = videoPreference == null ? void 0 : videoPreference.videoCodec;
7326
7324
  var preferStereo = channelsPreference && parseInt(channelsPreference) === 2;
7327
7325
  // Use first level set to determine stereo, and minimum resolution and framerate
7328
- var hasStereo = true;
7326
+ var hasStereo = false;
7329
7327
  var hasCurrentVideoRange = false;
7330
7328
  var minHeight = Infinity;
7331
7329
  var minFramerate = Infinity;
7332
7330
  var minBitrate = Infinity;
7331
+ var minIndex = Infinity;
7333
7332
  var selectedScore = 0;
7334
7333
  var videoRanges = [];
7335
7334
  var _getVideoSelectionOpt = getVideoSelectionOptions(currentVideoRange, videoPreference),
@@ -7337,7 +7336,7 @@
7337
7336
  allowedVideoRanges = _getVideoSelectionOpt.allowedVideoRanges;
7338
7337
  var _loop = function _loop() {
7339
7338
  var tier = codecTiers[codecSets[i]];
7340
- hasStereo = tier.channels[2] > 0;
7339
+ hasStereo || (hasStereo = tier.channels[2] > 0);
7341
7340
  minHeight = Math.min(minHeight, tier.minHeight);
7342
7341
  minFramerate = Math.min(minFramerate, tier.minFramerate);
7343
7342
  minBitrate = Math.min(minBitrate, tier.minBitrate);
@@ -7346,7 +7345,6 @@
7346
7345
  });
7347
7346
  if (matchingVideoRanges.length > 0) {
7348
7347
  hasCurrentVideoRange = true;
7349
- videoRanges = matchingVideoRanges;
7350
7348
  }
7351
7349
  };
7352
7350
  for (var i = codecSets.length; i--;) {
@@ -7361,7 +7359,6 @@
7361
7359
  // If there are no variants with matching preference, set currentVideoRange to undefined
7362
7360
  if (!hasCurrentVideoRange) {
7363
7361
  currentVideoRange = undefined;
7364
- videoRanges = [];
7365
7362
  }
7366
7363
  var codecSet = codecSets.reduce(function (selected, candidate) {
7367
7364
  // Remove candiates which do not meet bitrate, default audio, stereo or channels preference, 1080p or lower, 30fps or lower, or SDR/HDR selection if present
@@ -7369,6 +7366,9 @@
7369
7366
  if (candidate === selected) {
7370
7367
  return selected;
7371
7368
  }
7369
+ videoRanges = hasCurrentVideoRange ? allowedVideoRanges.filter(function (range) {
7370
+ return candidateTier.videoRanges[range] > 0;
7371
+ }) : [];
7372
7372
  if (candidateTier.minBitrate > currentBw) {
7373
7373
  logStartCodecCandidateIgnored(candidate, "min bitrate of " + candidateTier.minBitrate + " > current estimate of " + currentBw);
7374
7374
  return selected;
@@ -7404,6 +7404,10 @@
7404
7404
  logStartCodecCandidateIgnored(candidate, "no variants with VIDEO-RANGE of " + JSON.stringify(videoRanges) + " found");
7405
7405
  return selected;
7406
7406
  }
7407
+ if (videoCodecPreference && candidate.indexOf(videoCodecPreference.substring(0, 4)) % 5 !== 0) {
7408
+ logStartCodecCandidateIgnored(candidate, "video codec preference \"" + videoCodecPreference + "\" not found");
7409
+ return selected;
7410
+ }
7407
7411
  if (candidateTier.maxScore < selectedScore) {
7408
7412
  logStartCodecCandidateIgnored(candidate, "max score of " + candidateTier.maxScore + " < selected max of " + selectedScore);
7409
7413
  return selected;
@@ -7412,6 +7416,7 @@
7412
7416
  if (selected && (codecsSetSelectionPreferenceValue(candidate) >= codecsSetSelectionPreferenceValue(selected) || candidateTier.fragmentError > codecTiers[selected].fragmentError)) {
7413
7417
  return selected;
7414
7418
  }
7419
+ minIndex = candidateTier.minIndex;
7415
7420
  selectedScore = candidateTier.maxScore;
7416
7421
  return candidate;
7417
7422
  }, undefined);
@@ -7420,7 +7425,8 @@
7420
7425
  videoRanges: videoRanges,
7421
7426
  preferHDR: preferHDR,
7422
7427
  minFramerate: minFramerate,
7423
- minBitrate: minBitrate
7428
+ minBitrate: minBitrate,
7429
+ minIndex: minIndex
7424
7430
  };
7425
7431
  }
7426
7432
  function logStartCodecCandidateIgnored(codeSet, reason) {
@@ -7458,7 +7464,7 @@
7458
7464
  });
7459
7465
  }
7460
7466
  function getCodecTiers(levels, audioTracksByGroup, minAutoLevel, maxAutoLevel) {
7461
- return levels.slice(minAutoLevel, maxAutoLevel + 1).reduce(function (tiers, level) {
7467
+ return levels.slice(minAutoLevel, maxAutoLevel + 1).reduce(function (tiers, level, index) {
7462
7468
  if (!level.codecSet) {
7463
7469
  return tiers;
7464
7470
  }
@@ -7469,6 +7475,7 @@
7469
7475
  minBitrate: Infinity,
7470
7476
  minHeight: Infinity,
7471
7477
  minFramerate: Infinity,
7478
+ minIndex: index,
7472
7479
  maxScore: 0,
7473
7480
  videoRanges: {
7474
7481
  SDR: 0
@@ -7484,6 +7491,7 @@
7484
7491
  var lesserWidthOrHeight = Math.min(level.height, level.width);
7485
7492
  tier.minHeight = Math.min(tier.minHeight, lesserWidthOrHeight);
7486
7493
  tier.minFramerate = Math.min(tier.minFramerate, level.frameRate);
7494
+ tier.minIndex = Math.min(tier.minIndex, index);
7487
7495
  tier.maxScore = Math.max(tier.maxScore, level.score);
7488
7496
  tier.fragmentError += level.fragmentError;
7489
7497
  tier.videoRanges[level.videoRange] = (tier.videoRanges[level.videoRange] || 0) + 1;
@@ -8037,6 +8045,7 @@
8037
8045
  var audioPreference = config.audioPreference,
8038
8046
  videoPreference = config.videoPreference;
8039
8047
  var audioTracksByGroup = this.audioTracksByGroup || (this.audioTracksByGroup = getAudioTracksByGroup(allAudioTracks));
8048
+ var minStartIndex = -1;
8040
8049
  if (firstSelection) {
8041
8050
  if (this.firstSelection !== -1) {
8042
8051
  return this.firstSelection;
@@ -8047,7 +8056,9 @@
8047
8056
  videoRanges = startTier.videoRanges,
8048
8057
  minFramerate = startTier.minFramerate,
8049
8058
  minBitrate = startTier.minBitrate,
8059
+ minIndex = startTier.minIndex,
8050
8060
  preferHDR = startTier.preferHDR;
8061
+ minStartIndex = minIndex;
8051
8062
  currentCodecSet = codecSet;
8052
8063
  currentVideoRange = preferHDR ? videoRanges[videoRanges.length - 1] : videoRanges[0];
8053
8064
  currentFrameRate = minFramerate;
@@ -8096,8 +8107,10 @@
8096
8107
  // skip candidates which change codec-family or video-range,
8097
8108
  // and which decrease or increase frame-rate for up and down-switch respectfully
8098
8109
  if (currentCodecSet && levelInfo.codecSet !== currentCodecSet || currentVideoRange && levelInfo.videoRange !== currentVideoRange || upSwitch && currentFrameRate > levelInfo.frameRate || !upSwitch && currentFrameRate > 0 && currentFrameRate < levelInfo.frameRate || levelInfo.supportedResult && !((_levelInfo$supportedR = levelInfo.supportedResult.decodingInfoResults) != null && _levelInfo$supportedR[0].smooth)) {
8099
- levelsSkipped.push(i);
8100
- return 0; // continue
8110
+ if (firstSelection && i !== minStartIndex) {
8111
+ levelsSkipped.push(i);
8112
+ return 0; // continue
8113
+ }
8101
8114
  }
8102
8115
  var levelDetails = levelInfo.details;
8103
8116
  var avgDuration = (partCurrent ? levelDetails == null ? void 0 : levelDetails.partTarget : levelDetails == null ? void 0 : levelDetails.averagetargetduration) || currentFragDuration;
@@ -8132,7 +8145,7 @@
8132
8145
  if (levelsSkipped.length) {
8133
8146
  _this3.trace("Skipped level(s) " + levelsSkipped.join(',') + " of " + maxAutoLevel + " max with CODECS and VIDEO-RANGE:\"" + levels[levelsSkipped[0]].codecs + "\" " + levels[levelsSkipped[0]].videoRange + "; not compatible with \"" + level.codecs + "\" " + currentVideoRange);
8134
8147
  }
8135
- _this3.info("switch candidate:" + selectionBaseLevel + "->" + i + " adjustedbw(" + Math.round(adjustedbw) + ")-bitrate=" + Math.round(adjustedbw - bitrate) + " ttfb:" + ttfbEstimateSec.toFixed(1) + " avgDuration:" + avgDuration.toFixed(1) + " maxFetchDuration:" + maxFetchDuration.toFixed(1) + " fetchDuration:" + fetchDuration.toFixed(1) + " firstSelection:" + firstSelection + " codecSet:" + currentCodecSet + " videoRange:" + currentVideoRange + " hls.loadLevel:" + loadLevel);
8148
+ _this3.info("switch candidate:" + selectionBaseLevel + "->" + i + " adjustedbw(" + Math.round(adjustedbw) + ")-bitrate=" + Math.round(adjustedbw - bitrate) + " ttfb:" + ttfbEstimateSec.toFixed(1) + " avgDuration:" + avgDuration.toFixed(1) + " maxFetchDuration:" + maxFetchDuration.toFixed(1) + " fetchDuration:" + fetchDuration.toFixed(1) + " firstSelection:" + firstSelection + " codecSet:" + level.codecSet + " videoRange:" + level.videoRange + " hls.loadLevel:" + loadLevel);
8136
8149
  }
8137
8150
  if (firstSelection) {
8138
8151
  _this3.firstSelection = i;
@@ -30129,7 +30142,7 @@
30129
30142
  */
30130
30143
  _proto.setAudioOption = function setAudioOption(audioOption) {
30131
30144
  var _this$audioTrackContr;
30132
- return (_this$audioTrackContr = this.audioTrackController) == null ? void 0 : _this$audioTrackContr.setAudioOption(audioOption);
30145
+ return ((_this$audioTrackContr = this.audioTrackController) == null ? void 0 : _this$audioTrackContr.setAudioOption(audioOption)) || null;
30133
30146
  }
30134
30147
  /**
30135
30148
  * Find and select the best matching subtitle track, making a level switch when a Group change is necessary.
@@ -30137,8 +30150,7 @@
30137
30150
  */;
30138
30151
  _proto.setSubtitleOption = function setSubtitleOption(subtitleOption) {
30139
30152
  var _this$subtitleTrackCo;
30140
- (_this$subtitleTrackCo = this.subtitleTrackController) == null ? void 0 : _this$subtitleTrackCo.setSubtitleOption(subtitleOption);
30141
- return null;
30153
+ return ((_this$subtitleTrackCo = this.subtitleTrackController) == null ? void 0 : _this$subtitleTrackCo.setSubtitleOption(subtitleOption)) || null;
30142
30154
  }
30143
30155
 
30144
30156
  /**
@@ -30663,7 +30675,7 @@
30663
30675
  * Get the video-dev/hls.js package version.
30664
30676
  */
30665
30677
  function get() {
30666
- return "1.5.12-0.canary.10349";
30678
+ return "1.5.12-0.canary.10352";
30667
30679
  }
30668
30680
  }, {
30669
30681
  key: "Events",
package/dist/hls.js.d.ts CHANGED
@@ -3156,6 +3156,7 @@ declare const VideoRangeValues: readonly ["SDR", "PQ", "HLG"];
3156
3156
  export declare type VideoSelectionOption = {
3157
3157
  preferHDR?: boolean;
3158
3158
  allowedVideoRanges?: Array<VideoRange>;
3159
+ videoCodec?: string;
3159
3160
  };
3160
3161
 
3161
3162
  export { }