Skip to content

Commit

Permalink
Use average for level sorting and abandon rules check (#6135)
Browse files Browse the repository at this point in the history
Fixes #6122
  • Loading branch information
robwalch committed Jan 25, 2024
1 parent cd12094 commit f2f2b4a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/controller/abr-controller.ts
Expand Up @@ -286,7 +286,7 @@ class AbrController implements AbrComponentAPI {
const level = levels[frag.level];
const expectedLen =
stats.total ||
Math.max(stats.loaded, Math.round((duration * level.maxBitrate) / 8));
Math.max(stats.loaded, Math.round((duration * level.averageBitrate) / 8));
let timeStreaming = loadedFirstByte ? timeLoading - ttfb : timeLoading;
if (timeStreaming < 1 && loadedFirstByte) {
timeStreaming = Math.min(timeLoading, (stats.loaded * 8) / bwEstimate);
Expand Down Expand Up @@ -346,7 +346,7 @@ class AbrController implements AbrComponentAPI {
// If there has been no loading progress, sample TTFB
this.bwEstimator.sampleTTFB(timeLoading);
}
const nextLoadLevelBitrate = levels[nextLoadLevel].bitrate;
const nextLoadLevelBitrate = levels[nextLoadLevel].maxBitrate;
if (
this.getBwEstimate() * this.hls.config.abrBandWidthUpFactor >
nextLoadLevelBitrate
Expand Down
4 changes: 2 additions & 2 deletions src/controller/level-controller.ts
Expand Up @@ -307,8 +307,8 @@ export default class LevelController extends BasePlaylistController {
return valueB - valueA;
}
}
if (a.bitrate !== b.bitrate) {
return a.bitrate - b.bitrate;
if (a.averageBitrate !== b.averageBitrate) {
return a.averageBitrate - b.averageBitrate;
}
return 0;
});
Expand Down

0 comments on commit f2f2b4a

Please sign in to comment.