Skip to content

Commit

Permalink
fix(ABR): Fix variant choose when two variants have the same bandwidt…
Browse files Browse the repository at this point in the history
…h but different resolution (#6760)
  • Loading branch information
avelad committed Jun 7, 2024
1 parent 41fdc8b commit ea8b380
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion lib/abr/simple_abr_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@ shaka.abr.SimpleAbrManager = class {

if (currentBandwidth >= minBandwidth &&
currentBandwidth <= maxBandwidth &&
chosen.bandwidth != item.bandwidth) {
(chosen.bandwidth != item.bandwidth ||
this.isSameBandwidthAndHigherResolution_(chosen, item))) {
chosen = item;
}
}
Expand Down Expand Up @@ -532,6 +533,23 @@ shaka.abr.SimpleAbrManager = class {
return v1.width - v2.width;
});
}

/**
* @param {shaka.extern.Variant} chosenVariant
* @param {shaka.extern.Variant} newVariant
* @return {boolean}
* @private
*/
isSameBandwidthAndHigherResolution_(chosenVariant, newVariant) {
if (chosenVariant.bandwidth != newVariant.bandwidth) {
return false;
}
if (!chosenVariant.video || !newVariant.video) {
return false;
}
return chosenVariant.video.width < newVariant.video.width ||
chosenVariant.video.height < newVariant.video.height;
}
};


Expand Down

0 comments on commit ea8b380

Please sign in to comment.