From 9f017d71ef96b02b7ea365221c254ad9ff633c5d Mon Sep 17 00:00:00 2001 From: aquilescanta Date: Thu, 30 Jun 2016 11:34:50 -0700 Subject: [PATCH] Add HD content filtering to DefaultTrackSelectionPolicy ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=126324788 --- .../android/exoplayer/DefaultTrackSelectionPolicy.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/library/src/main/java/com/google/android/exoplayer/DefaultTrackSelectionPolicy.java b/library/src/main/java/com/google/android/exoplayer/DefaultTrackSelectionPolicy.java index 6c32a7b7c7..0091769676 100644 --- a/library/src/main/java/com/google/android/exoplayer/DefaultTrackSelectionPolicy.java +++ b/library/src/main/java/com/google/android/exoplayer/DefaultTrackSelectionPolicy.java @@ -27,6 +27,7 @@ public class DefaultTrackSelectionPolicy extends TrackSelectionPolicy { private String preferredLanguage; private boolean allowMixedMimeAdaptiveness; private boolean allowNonSeamlessAdaptiveness; + private boolean filterHdFormats; private int maxVideoWidth; private int maxVideoHeight; @@ -43,6 +44,13 @@ public class DefaultTrackSelectionPolicy extends TrackSelectionPolicy { } } + public void setFilterHdFormats(boolean filterHdFormats) { + if (this.filterHdFormats != filterHdFormats) { + this.filterHdFormats = filterHdFormats; + invalidate(); + } + } + public void allowMixedMimeAdaptiveness(boolean allowMixedMimeAdaptiveness) { if (this.allowMixedMimeAdaptiveness != allowMixedMimeAdaptiveness) { this.allowMixedMimeAdaptiveness = allowMixedMimeAdaptiveness; @@ -99,6 +107,8 @@ public class DefaultTrackSelectionPolicy extends TrackSelectionPolicy { int requiredAdaptiveSupport = allowNonSeamlessAdaptiveness ? TrackRenderer.ADAPTIVE_NOT_SEAMLESS | TrackRenderer.ADAPTIVE_SEAMLESS : TrackRenderer.ADAPTIVE_SEAMLESS; + int maxVideoWidth = Math.min(this.maxVideoWidth, filterHdFormats ? 1279 : Integer.MAX_VALUE); + int maxVideoHeight = Math.min(this.maxVideoHeight, filterHdFormats ? 719 : Integer.MAX_VALUE); boolean allowMixedMimeTypes = allowMixedMimeAdaptiveness && (renderer.supportsMixedMimeTypeAdaptation() & requiredAdaptiveSupport) != 0; int largestAdaptiveGroup = -1;