Skip to content

Commit

Permalink
Use average for level sorting and abandon rules check (#6135) (#6146)
Browse files Browse the repository at this point in the history
Fixes #6122
  • Loading branch information
robwalch authored Jan 26, 2024
1 parent 6b2bb87 commit b0b0c7a
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
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ class AbrController extends Logger 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 @@ -347,7 +347,7 @@ class AbrController extends Logger 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
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,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 b0b0c7a

Please sign in to comment.