hls.js 1.5.6-0.canary.9999 → 1.5.7-0.canary.10014

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/package.json CHANGED
@@ -114,12 +114,12 @@
114
114
  "lint-staged": "15.2.2",
115
115
  "markdown-styles": "3.2.0",
116
116
  "micromatch": "4.0.5",
117
- "mocha": "10.2.0",
117
+ "mocha": "10.3.0",
118
118
  "node-fetch": "3.3.2",
119
119
  "npm-run-all2": "5.0.2",
120
120
  "prettier": "3.2.4",
121
121
  "promise-polyfill": "8.3.0",
122
- "rollup": "4.9.6",
122
+ "rollup": "4.12.0",
123
123
  "rollup-plugin-istanbul": "5.0.0",
124
124
  "sauce-connect-launcher": "1.3.2",
125
125
  "selenium-webdriver": "4.17.0",
@@ -128,7 +128,7 @@
128
128
  "sinon-chai": "3.7.0",
129
129
  "typescript": "5.3.3",
130
130
  "url-toolkit": "2.2.5",
131
- "wrangler": "3.26.0"
131
+ "wrangler": "3.28.2"
132
132
  },
133
- "version": "1.5.6-0.canary.9999"
133
+ "version": "1.5.7-0.canary.10014"
134
134
  }
@@ -534,27 +534,20 @@ class AbrController extends Logger implements AbrComponentAPI {
534
534
  }
535
535
 
536
536
  private getAutoLevelKey(): string {
537
- return `${this.getBwEstimate()}_${this.hls.mainForwardBufferInfo?.len}`;
537
+ return `${this.getBwEstimate()}_${this.getStarvationDelay().toFixed(2)}`;
538
538
  }
539
539
 
540
540
  private getNextABRAutoLevel(): number {
541
541
  const { fragCurrent, partCurrent, hls } = this;
542
- const { maxAutoLevel, config, minAutoLevel, media } = hls;
542
+ const { maxAutoLevel, config, minAutoLevel } = hls;
543
543
  const currentFragDuration = partCurrent
544
544
  ? partCurrent.duration
545
545
  : fragCurrent
546
546
  ? fragCurrent.duration
547
547
  : 0;
548
-
549
- // playbackRate is the absolute value of the playback rate; if media.playbackRate is 0, we use 1 to load as
550
- // if we're playing back at the normal rate.
551
- const playbackRate =
552
- media && media.playbackRate !== 0 ? Math.abs(media.playbackRate) : 1.0;
553
548
  const avgbw = this.getBwEstimate();
554
549
  // bufferStarvationDelay is the wall-clock time left until the playback buffer is exhausted.
555
- const bufferInfo = hls.mainForwardBufferInfo;
556
- const bufferStarvationDelay =
557
- (bufferInfo ? bufferInfo.len : 0) / playbackRate;
550
+ const bufferStarvationDelay = this.getStarvationDelay();
558
551
 
559
552
  let bwFactor = config.abrBandWidthFactor;
560
553
  let bwUpFactor = config.abrBandWidthUpFactor;
@@ -630,6 +623,20 @@ class AbrController extends Logger implements AbrComponentAPI {
630
623
  return hls.loadLevel;
631
624
  }
632
625
 
626
+ private getStarvationDelay(): number {
627
+ const hls = this.hls;
628
+ const media = hls.media;
629
+ if (!media) {
630
+ return Infinity;
631
+ }
632
+ // playbackRate is the absolute value of the playback rate; if media.playbackRate is 0, we use 1 to load as
633
+ // if we're playing back at the normal rate.
634
+ const playbackRate =
635
+ media && media.playbackRate !== 0 ? Math.abs(media.playbackRate) : 1.0;
636
+ const bufferInfo = hls.mainForwardBufferInfo;
637
+ return (bufferInfo ? bufferInfo.len : 0) / playbackRate;
638
+ }
639
+
633
640
  private getBwEstimate(): number {
634
641
  return this.bwEstimator.canEstimate()
635
642
  ? this.bwEstimator.getEstimate()
@@ -738,6 +745,9 @@ class AbrController extends Logger implements AbrComponentAPI {
738
745
  mediaCapabilities,
739
746
  );
740
747
  levelInfo.supportedPromise.then((decodingInfo) => {
748
+ if (!this.hls) {
749
+ return;
750
+ }
741
751
  levelInfo.supportedResult = decodingInfo;
742
752
  const levels = this.hls.levels;
743
753
  const index = levels.indexOf(levelInfo);
@@ -215,14 +215,13 @@ export default class StreamController
215
215
 
216
216
  private doTickIdle() {
217
217
  const { hls, levelLastLoaded, levels, media } = this;
218
- const { config, nextLoadLevel: level } = hls;
219
218
 
220
219
  // if start level not parsed yet OR
221
220
  // if video not attached AND start fragment already requested OR start frag prefetch not enabled
222
221
  // exit loop, as we either need more info (level not parsed) or we need media to be attached to load new fragment
223
222
  if (
224
223
  levelLastLoaded === null ||
225
- (!media && (this.startFragRequested || !config.startFragPrefetch))
224
+ (!media && (this.startFragRequested || !hls.config.startFragPrefetch))
226
225
  ) {
227
226
  return;
228
227
  }
@@ -232,7 +231,8 @@ export default class StreamController
232
231
  return;
233
232
  }
234
233
 
235
- if (!this.buffering || !levels?.[level]) {
234
+ const level = hls.nextLoadLevel;
235
+ if (!levels?.[level]) {
236
236
  return;
237
237
  }
238
238
 
@@ -136,11 +136,13 @@ export function parseSegmentIndex(sidx: Uint8Array): SidxInfo | null {
136
136
  let firstOffset = 0;
137
137
 
138
138
  if (version === 0) {
139
- earliestPresentationTime = readUint32(sidx, (index += 4));
140
- firstOffset = readUint32(sidx, (index += 4));
139
+ earliestPresentationTime = readUint32(sidx, index);
140
+ firstOffset = readUint32(sidx, index + 4);
141
+ index += 8;
141
142
  } else {
142
- earliestPresentationTime = readUint64(sidx, (index += 8));
143
- firstOffset = readUint64(sidx, (index += 8));
143
+ earliestPresentationTime = readUint64(sidx, index);
144
+ firstOffset = readUint64(sidx, index + 8);
145
+ index += 16;
144
146
  }
145
147
 
146
148
  // skip reserved