Commit ede62e97 by olly Committed by Oliver Woodman

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
parent 4fe14c76
...@@ -1651,9 +1651,10 @@ public class DefaultTrackSelector extends MappingTrackSelector { ...@@ -1651,9 +1651,10 @@ public class DefaultTrackSelector extends MappingTrackSelector {
} }
boolean selectTrack = trackScore > selectedTrackScore; boolean selectTrack = trackScore > selectedTrackScore;
if (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. // Use bitrate as a tie breaker, preferring the lower bitrate.
selectTrack = compareFormatValues(format.bitrate, selectedBitrate) < 0; selectTrack = bitrateComparison < 0;
} else { } else {
// Use the pixel count as a tie breaker (or bitrate if pixel counts are tied). If // 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 // we're within constraints prefer a higher pixel count (or bitrate), else prefer a
...@@ -2173,25 +2174,31 @@ public class DefaultTrackSelector extends MappingTrackSelector { ...@@ -2173,25 +2174,31 @@ public class DefaultTrackSelector extends MappingTrackSelector {
if (this.withinRendererCapabilitiesScore != other.withinRendererCapabilitiesScore) { if (this.withinRendererCapabilitiesScore != other.withinRendererCapabilitiesScore) {
return compareInts(this.withinRendererCapabilitiesScore, return compareInts(this.withinRendererCapabilitiesScore,
other.withinRendererCapabilitiesScore); other.withinRendererCapabilitiesScore);
} else if (this.matchLanguageScore != other.matchLanguageScore) { }
if (this.matchLanguageScore != other.matchLanguageScore) {
return compareInts(this.matchLanguageScore, other.matchLanguageScore); return compareInts(this.matchLanguageScore, other.matchLanguageScore);
} else if (this.defaultSelectionFlagScore != other.defaultSelectionFlagScore) { }
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); return compareInts(this.defaultSelectionFlagScore, other.defaultSelectionFlagScore);
} else if (parameters.forceLowestBitrate) { }
return compareInts(other.bitrate, this.bitrate); // If the formats are within renderer capabilities then prefer higher values of channel count,
} 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. // sample rate and bit rate in that order. Otherwise, prefer lower values.
int resultSign = withinRendererCapabilitiesScore == 1 ? 1 : -1; int resultSign = withinRendererCapabilitiesScore == 1 ? 1 : -1;
if (this.channelCount != other.channelCount) { if (this.channelCount != other.channelCount) {
return resultSign * compareInts(this.channelCount, other.channelCount); return resultSign * compareInts(this.channelCount, other.channelCount);
} else if (this.sampleRate != other.sampleRate) { }
if (this.sampleRate != other.sampleRate) {
return resultSign * compareInts(this.sampleRate, other.sampleRate); return resultSign * compareInts(this.sampleRate, other.sampleRate);
} }
return resultSign * compareInts(this.bitrate, other.bitrate); return resultSign * compareInts(this.bitrate, other.bitrate);
} }
} }
}
/** /**
* Compares two integers in a safe way and avoiding potential overflow. * Compares two integers in a safe way and avoiding potential overflow.
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<string name="exo_controls_repeat_all_description">تكرار الكل</string> <string name="exo_controls_repeat_all_description">تكرار الكل</string>
<string name="exo_controls_shuffle_description">ترتيب عشوائي</string> <string name="exo_controls_shuffle_description">ترتيب عشوائي</string>
<string name="exo_controls_fullscreen_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_description">تنزيل</string>
<string name="exo_download_notification_channel_name">التنزيلات</string> <string name="exo_download_notification_channel_name">التنزيلات</string>
<string name="exo_download_downloading">جارٍ التنزيل.</string> <string name="exo_download_downloading">جارٍ التنزيل.</string>
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<string name="exo_controls_repeat_all_description">Hamısı təkrarlansın</string> <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_shuffle_description">Qarışdırın</string>
<string name="exo_controls_fullscreen_description">Tam ekran rejimi</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_description">Endirin</string>
<string name="exo_download_notification_channel_name">Endirmələr</string> <string name="exo_download_notification_channel_name">Endirmələr</string>
<string name="exo_download_downloading">Endirilir</string> <string name="exo_download_downloading">Endirilir</string>
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<string name="exo_controls_repeat_all_description">Ponovi sve</string> <string name="exo_controls_repeat_all_description">Ponovi sve</string>
<string name="exo_controls_shuffle_description">Izmiješaj</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_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_description">Preuzmi</string>
<string name="exo_download_notification_channel_name">Preuzimanja</string> <string name="exo_download_notification_channel_name">Preuzimanja</string>
<string name="exo_download_downloading">Preuzimanje</string> <string name="exo_download_downloading">Preuzimanje</string>
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<string name="exo_controls_repeat_all_description">تکرار همه</string> <string name="exo_controls_repeat_all_description">تکرار همه</string>
<string name="exo_controls_shuffle_description">درهم</string> <string name="exo_controls_shuffle_description">درهم</string>
<string name="exo_controls_fullscreen_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_description">بارگیری</string>
<string name="exo_download_notification_channel_name">بارگیری‌ها</string> <string name="exo_download_notification_channel_name">بارگیری‌ها</string>
<string name="exo_download_downloading">درحال بارگیری</string> <string name="exo_download_downloading">درحال بارگیری</string>
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<string name="exo_controls_repeat_all_description">Ponovi sve</string> <string name="exo_controls_repeat_all_description">Ponovi sve</string>
<string name="exo_controls_shuffle_description">Reproduciraj nasumično</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_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_description">Preuzmi</string>
<string name="exo_download_notification_channel_name">Preuzimanja</string> <string name="exo_download_notification_channel_name">Preuzimanja</string>
<string name="exo_download_downloading">Preuzimanje</string> <string name="exo_download_downloading">Preuzimanje</string>
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<string name="exo_controls_repeat_all_description">Ulangi semua</string> <string name="exo_controls_repeat_all_description">Ulangi semua</string>
<string name="exo_controls_shuffle_description">Acak</string> <string name="exo_controls_shuffle_description">Acak</string>
<string name="exo_controls_fullscreen_description">Mode layar penuh</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_description">Download</string>
<string name="exo_download_notification_channel_name">Download</string> <string name="exo_download_notification_channel_name">Download</string>
<string name="exo_download_downloading">Mendownload</string> <string name="exo_download_downloading">Mendownload</string>
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<string name="exo_controls_repeat_all_description">ყველას გამეორება</string> <string name="exo_controls_repeat_all_description">ყველას გამეორება</string>
<string name="exo_controls_shuffle_description">არეულად დაკვრა</string> <string name="exo_controls_shuffle_description">არეულად დაკვრა</string>
<string name="exo_controls_fullscreen_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_description">ჩამოტვირთვა</string>
<string name="exo_download_notification_channel_name">ჩამოტვირთვები</string> <string name="exo_download_notification_channel_name">ჩამოტვირთვები</string>
<string name="exo_download_downloading">მიმდინარეობს ჩამოტვირთვა</string> <string name="exo_download_downloading">მიმდინარეობს ჩამოტვირთვა</string>
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<string name="exo_controls_repeat_all_description">အားလုံး ပြန်ကျော့ရန်</string> <string name="exo_controls_repeat_all_description">အားလုံး ပြန်ကျော့ရန်</string>
<string name="exo_controls_shuffle_description">ရောသမမွှေ</string> <string name="exo_controls_shuffle_description">ရောသမမွှေ</string>
<string name="exo_controls_fullscreen_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_description">ဒေါင်းလုဒ် လုပ်ရန်</string>
<string name="exo_download_notification_channel_name">ဒေါင်းလုဒ်များ</string> <string name="exo_download_notification_channel_name">ဒေါင်းလုဒ်များ</string>
<string name="exo_download_downloading">ဒေါင်းလုဒ်လုပ်နေသည်</string> <string name="exo_download_downloading">ဒေါင်းလုဒ်လုပ်နေသည်</string>
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<string name="exo_controls_repeat_all_description">Opakovať všetko</string> <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_shuffle_description">Náhodne prehrávať</string>
<string name="exo_controls_fullscreen_description">Režim celej obrazovky</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_description">Stiahnuť</string>
<string name="exo_download_notification_channel_name">Stiahnuté</string> <string name="exo_download_notification_channel_name">Stiahnuté</string>
<string name="exo_download_downloading">Sťahuje sa</string> <string name="exo_download_downloading">Sťahuje sa</string>
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<string name="exo_controls_repeat_all_description">Përsërit të gjitha</string> <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_shuffle_description">Përziej</string>
<string name="exo_controls_fullscreen_description">Modaliteti me ekran të plotë</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_description">Shkarko</string>
<string name="exo_download_notification_channel_name">Shkarkimet</string> <string name="exo_download_notification_channel_name">Shkarkimet</string>
<string name="exo_download_downloading">Po shkarkohet</string> <string name="exo_download_downloading">Po shkarkohet</string>
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<string name="exo_controls_repeat_all_description">Hammasini takrorlash</string> <string name="exo_controls_repeat_all_description">Hammasini takrorlash</string>
<string name="exo_controls_shuffle_description">Aralash</string> <string name="exo_controls_shuffle_description">Aralash</string>
<string name="exo_controls_fullscreen_description">Butun ekran rejimi</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_description">Yuklab olish</string>
<string name="exo_download_notification_channel_name">Yuklanmalar</string> <string name="exo_download_notification_channel_name">Yuklanmalar</string>
<string name="exo_download_downloading">Yuklab olinmoqda</string> <string name="exo_download_downloading">Yuklab olinmoqda</string>
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<string name="exo_controls_repeat_all_description">Phinda konke</string> <string name="exo_controls_repeat_all_description">Phinda konke</string>
<string name="exo_controls_shuffle_description">Shova</string> <string name="exo_controls_shuffle_description">Shova</string>
<string name="exo_controls_fullscreen_description">Imodi yesikrini esigcwele</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_description">Landa</string>
<string name="exo_download_notification_channel_name">Ukulandwa</string> <string name="exo_download_notification_channel_name">Ukulandwa</string>
<string name="exo_download_downloading">Iyalanda</string> <string name="exo_download_downloading">Iyalanda</string>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment