Fix track selection when forceLowestBitrate is enabled:

- Only use bitrate when comparing two tracks if their bitrates are
  actually different.
- For audio, prefer to use bitrate over selection flags.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=218660886
This commit is contained in:
olly 2018-10-25 03:41:44 -07:00 committed by Oliver Woodman
parent 4fe14c7693
commit ede62e97b2
13 changed files with 37 additions and 30 deletions

View file

@ -1651,9 +1651,10 @@ public class DefaultTrackSelector extends MappingTrackSelector {
}
boolean selectTrack = trackScore > selectedTrackScore;
if (trackScore == selectedTrackScore) {
if (params.forceLowestBitrate) {
int bitrateComparison = compareFormatValues(format.bitrate, selectedBitrate);
if (params.forceLowestBitrate && bitrateComparison != 0) {
// Use bitrate as a tie breaker, preferring the lower bitrate.
selectTrack = compareFormatValues(format.bitrate, selectedBitrate) < 0;
selectTrack = bitrateComparison < 0;
} else {
// Use the pixel count as a tie breaker (or bitrate if pixel counts are tied). If
// we're within constraints prefer a higher pixel count (or bitrate), else prefer a
@ -2173,23 +2174,29 @@ public class DefaultTrackSelector extends MappingTrackSelector {
if (this.withinRendererCapabilitiesScore != other.withinRendererCapabilitiesScore) {
return compareInts(this.withinRendererCapabilitiesScore,
other.withinRendererCapabilitiesScore);
} else if (this.matchLanguageScore != other.matchLanguageScore) {
return compareInts(this.matchLanguageScore, other.matchLanguageScore);
} else if (this.defaultSelectionFlagScore != other.defaultSelectionFlagScore) {
return compareInts(this.defaultSelectionFlagScore, other.defaultSelectionFlagScore);
} else if (parameters.forceLowestBitrate) {
return compareInts(other.bitrate, this.bitrate);
} else {
// If the format are within renderer capabilities, prefer higher values of channel count,
// sample rate and bit rate in that order. Otherwise, prefer lower values.
int resultSign = withinRendererCapabilitiesScore == 1 ? 1 : -1;
if (this.channelCount != other.channelCount) {
return resultSign * compareInts(this.channelCount, other.channelCount);
} else if (this.sampleRate != other.sampleRate) {
return resultSign * compareInts(this.sampleRate, other.sampleRate);
}
return resultSign * compareInts(this.bitrate, other.bitrate);
}
if (this.matchLanguageScore != other.matchLanguageScore) {
return compareInts(this.matchLanguageScore, other.matchLanguageScore);
}
if (parameters.forceLowestBitrate) {
int bitrateComparison = compareFormatValues(bitrate, other.bitrate);
if (bitrateComparison != 0) {
return bitrateComparison > 0 ? -1 : 1;
}
}
if (this.defaultSelectionFlagScore != other.defaultSelectionFlagScore) {
return compareInts(this.defaultSelectionFlagScore, other.defaultSelectionFlagScore);
}
// If the formats are within renderer capabilities then prefer higher values of channel count,
// sample rate and bit rate in that order. Otherwise, prefer lower values.
int resultSign = withinRendererCapabilitiesScore == 1 ? 1 : -1;
if (this.channelCount != other.channelCount) {
return resultSign * compareInts(this.channelCount, other.channelCount);
}
if (this.sampleRate != other.sampleRate) {
return resultSign * compareInts(this.sampleRate, other.sampleRate);
}
return resultSign * compareInts(this.bitrate, other.bitrate);
}
}

View file

@ -12,7 +12,7 @@
<string name="exo_controls_repeat_all_description">تكرار الكل</string>
<string name="exo_controls_shuffle_description">ترتيب عشوائي</string>
<string name="exo_controls_fullscreen_description">وضع ملء الشاشة</string>
<string name="exo_controls_exit_vr_description">Exit VR mode</string>
<string name="exo_controls_exit_vr_description">الخروج من وضع VR</string>
<string name="exo_download_description">تنزيل</string>
<string name="exo_download_notification_channel_name">التنزيلات</string>
<string name="exo_download_downloading">جارٍ التنزيل.</string>

View file

@ -12,7 +12,7 @@
<string name="exo_controls_repeat_all_description">Hamısı təkrarlansın</string>
<string name="exo_controls_shuffle_description">Qarışdırın</string>
<string name="exo_controls_fullscreen_description">Tam ekran rejimi</string>
<string name="exo_controls_exit_vr_description">Exit VR mode</string>
<string name="exo_controls_exit_vr_description">VR rejimdən çıxın</string>
<string name="exo_download_description">Endirin</string>
<string name="exo_download_notification_channel_name">Endirmələr</string>
<string name="exo_download_downloading">Endirilir</string>

View file

@ -12,7 +12,7 @@
<string name="exo_controls_repeat_all_description">Ponovi sve</string>
<string name="exo_controls_shuffle_description">Izmiješaj</string>
<string name="exo_controls_fullscreen_description">Način rada preko cijelog ekrana</string>
<string name="exo_controls_exit_vr_description">Exit VR mode</string>
<string name="exo_controls_exit_vr_description">Izlazak iz VR načina</string>
<string name="exo_download_description">Preuzmi</string>
<string name="exo_download_notification_channel_name">Preuzimanja</string>
<string name="exo_download_downloading">Preuzimanje</string>

View file

@ -12,7 +12,7 @@
<string name="exo_controls_repeat_all_description">تکرار همه</string>
<string name="exo_controls_shuffle_description">درهم</string>
<string name="exo_controls_fullscreen_description">حالت تمام‌صفحه</string>
<string name="exo_controls_exit_vr_description">Exit VR mode</string>
<string name="exo_controls_exit_vr_description">خروج از حالت واقعیت مجازی</string>
<string name="exo_download_description">بارگیری</string>
<string name="exo_download_notification_channel_name">بارگیری‌ها</string>
<string name="exo_download_downloading">درحال بارگیری</string>

View file

@ -12,7 +12,7 @@
<string name="exo_controls_repeat_all_description">Ponovi sve</string>
<string name="exo_controls_shuffle_description">Reproduciraj nasumično</string>
<string name="exo_controls_fullscreen_description">Prikaz na cijelom zaslonu</string>
<string name="exo_controls_exit_vr_description">Exit VR mode</string>
<string name="exo_controls_exit_vr_description">Izlazak iz VR načina</string>
<string name="exo_download_description">Preuzmi</string>
<string name="exo_download_notification_channel_name">Preuzimanja</string>
<string name="exo_download_downloading">Preuzimanje</string>

View file

@ -12,7 +12,7 @@
<string name="exo_controls_repeat_all_description">Ulangi semua</string>
<string name="exo_controls_shuffle_description">Acak</string>
<string name="exo_controls_fullscreen_description">Mode layar penuh</string>
<string name="exo_controls_exit_vr_description">Exit VR mode</string>
<string name="exo_controls_exit_vr_description">Keluar dari mode VR</string>
<string name="exo_download_description">Download</string>
<string name="exo_download_notification_channel_name">Download</string>
<string name="exo_download_downloading">Mendownload</string>

View file

@ -12,7 +12,7 @@
<string name="exo_controls_repeat_all_description">ყველას გამეორება</string>
<string name="exo_controls_shuffle_description">არეულად დაკვრა</string>
<string name="exo_controls_fullscreen_description">სრულეკრანიანი რეჟიმი</string>
<string name="exo_controls_exit_vr_description">Exit VR mode</string>
<string name="exo_controls_exit_vr_description">VR რეჟიმიდან გასვლა</string>
<string name="exo_download_description">ჩამოტვირთვა</string>
<string name="exo_download_notification_channel_name">ჩამოტვირთვები</string>
<string name="exo_download_downloading">მიმდინარეობს ჩამოტვირთვა</string>

View file

@ -12,7 +12,7 @@
<string name="exo_controls_repeat_all_description">အားလုံး ပြန်ကျော့ရန်</string>
<string name="exo_controls_shuffle_description">ရောသမမွှေ</string>
<string name="exo_controls_fullscreen_description">မျက်နှာပြင်အပြည့် မုဒ်</string>
<string name="exo_controls_exit_vr_description">Exit VR mode</string>
<string name="exo_controls_exit_vr_description">VR မုဒ်မှထွက်ပါ</string>
<string name="exo_download_description">ဒေါင်းလုဒ် လုပ်ရန်</string>
<string name="exo_download_notification_channel_name">ဒေါင်းလုဒ်များ</string>
<string name="exo_download_downloading">ဒေါင်းလုဒ်လုပ်နေသည်</string>

View file

@ -12,7 +12,7 @@
<string name="exo_controls_repeat_all_description">Opakovať všetko</string>
<string name="exo_controls_shuffle_description">Náhodne prehrávať</string>
<string name="exo_controls_fullscreen_description">Režim celej obrazovky</string>
<string name="exo_controls_exit_vr_description">Exit VR mode</string>
<string name="exo_controls_exit_vr_description">Ukončiť režim VR</string>
<string name="exo_download_description">Stiahnuť</string>
<string name="exo_download_notification_channel_name">Stiahnuté</string>
<string name="exo_download_downloading">Sťahuje sa</string>

View file

@ -12,7 +12,7 @@
<string name="exo_controls_repeat_all_description">Përsërit të gjitha</string>
<string name="exo_controls_shuffle_description">Përziej</string>
<string name="exo_controls_fullscreen_description">Modaliteti me ekran të plotë</string>
<string name="exo_controls_exit_vr_description">Exit VR mode</string>
<string name="exo_controls_exit_vr_description">Dil nga modaliteti VR</string>
<string name="exo_download_description">Shkarko</string>
<string name="exo_download_notification_channel_name">Shkarkimet</string>
<string name="exo_download_downloading">Po shkarkohet</string>

View file

@ -12,7 +12,7 @@
<string name="exo_controls_repeat_all_description">Hammasini takrorlash</string>
<string name="exo_controls_shuffle_description">Aralash</string>
<string name="exo_controls_fullscreen_description">Butun ekran rejimi</string>
<string name="exo_controls_exit_vr_description">Exit VR mode</string>
<string name="exo_controls_exit_vr_description">VR rejimidan chiqish</string>
<string name="exo_download_description">Yuklab olish</string>
<string name="exo_download_notification_channel_name">Yuklanmalar</string>
<string name="exo_download_downloading">Yuklab olinmoqda</string>

View file

@ -12,7 +12,7 @@
<string name="exo_controls_repeat_all_description">Phinda konke</string>
<string name="exo_controls_shuffle_description">Shova</string>
<string name="exo_controls_fullscreen_description">Imodi yesikrini esigcwele</string>
<string name="exo_controls_exit_vr_description">Exit VR mode</string>
<string name="exo_controls_exit_vr_description">Phuma kumodi ye-VR</string>
<string name="exo_download_description">Landa</string>
<string name="exo_download_notification_channel_name">Ukulandwa</string>
<string name="exo_download_downloading">Iyalanda</string>