Commit 2bd12c22 by aquilescanta Committed by Oliver Woodman

Move DefaultTrackSelector.Parameters out of DefaultTrackSelector

Including ParametersBuilder and TrackSelectionOverride.

PiperOrigin-RevId: 231609249
parent ab67ab1a
...@@ -159,10 +159,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { ...@@ -159,10 +159,7 @@ public class DefaultTrackSelector extends MappingTrackSelector {
* A builder for {@link Parameters}. See the {@link Parameters} documentation for explanations of * A builder for {@link Parameters}. See the {@link Parameters} documentation for explanations of
* the parameters that can be configured using this builder. * the parameters that can be configured using this builder.
*/ */
public static final class ParametersBuilder { public static final class ParametersBuilder extends TrackSelectionParameters.Builder {
private final SparseArray<Map<TrackGroupArray, SelectionOverride>> selectionOverrides;
private final SparseBooleanArray rendererDisabledFlags;
// Video // Video
private int maxVideoWidth; private int maxVideoWidth;
...@@ -176,22 +173,20 @@ public class DefaultTrackSelector extends MappingTrackSelector { ...@@ -176,22 +173,20 @@ public class DefaultTrackSelector extends MappingTrackSelector {
private int viewportHeight; private int viewportHeight;
private boolean viewportOrientationMayChange; private boolean viewportOrientationMayChange;
// Audio // Audio
@Nullable private String preferredAudioLanguage;
private int maxAudioChannelCount; private int maxAudioChannelCount;
private int maxAudioBitrate; private int maxAudioBitrate;
private boolean exceedAudioConstraintsIfNecessary; private boolean exceedAudioConstraintsIfNecessary;
private boolean allowAudioMixedMimeTypeAdaptiveness; private boolean allowAudioMixedMimeTypeAdaptiveness;
private boolean allowAudioMixedSampleRateAdaptiveness; private boolean allowAudioMixedSampleRateAdaptiveness;
// Text
@Nullable private String preferredTextLanguage;
private boolean selectUndeterminedTextLanguage;
private int disabledTextTrackSelectionFlags;
// General // General
private boolean forceLowestBitrate; private boolean forceLowestBitrate;
private boolean forceHighestSupportedBitrate; private boolean forceHighestSupportedBitrate;
private boolean exceedRendererCapabilitiesIfNecessary; private boolean exceedRendererCapabilitiesIfNecessary;
private int tunnelingAudioSessionId; private int tunnelingAudioSessionId;
private final SparseArray<Map<TrackGroupArray, SelectionOverride>> selectionOverrides;
private final SparseBooleanArray rendererDisabledFlags;
/** Creates a builder with default initial values. */ /** Creates a builder with default initial values. */
public ParametersBuilder() { public ParametersBuilder() {
this(Parameters.DEFAULT); this(Parameters.DEFAULT);
...@@ -202,6 +197,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { ...@@ -202,6 +197,7 @@ public class DefaultTrackSelector extends MappingTrackSelector {
* obtained. * obtained.
*/ */
private ParametersBuilder(Parameters initialValues) { private ParametersBuilder(Parameters initialValues) {
super(initialValues);
// Video // Video
maxVideoWidth = initialValues.maxVideoWidth; maxVideoWidth = initialValues.maxVideoWidth;
maxVideoHeight = initialValues.maxVideoHeight; maxVideoHeight = initialValues.maxVideoHeight;
...@@ -214,16 +210,11 @@ public class DefaultTrackSelector extends MappingTrackSelector { ...@@ -214,16 +210,11 @@ public class DefaultTrackSelector extends MappingTrackSelector {
viewportHeight = initialValues.viewportHeight; viewportHeight = initialValues.viewportHeight;
viewportOrientationMayChange = initialValues.viewportOrientationMayChange; viewportOrientationMayChange = initialValues.viewportOrientationMayChange;
// Audio // Audio
preferredAudioLanguage = initialValues.preferredAudioLanguage;
maxAudioChannelCount = initialValues.maxAudioChannelCount; maxAudioChannelCount = initialValues.maxAudioChannelCount;
maxAudioBitrate = initialValues.maxAudioBitrate; maxAudioBitrate = initialValues.maxAudioBitrate;
exceedAudioConstraintsIfNecessary = initialValues.exceedAudioConstraintsIfNecessary; exceedAudioConstraintsIfNecessary = initialValues.exceedAudioConstraintsIfNecessary;
allowAudioMixedMimeTypeAdaptiveness = initialValues.allowAudioMixedMimeTypeAdaptiveness; allowAudioMixedMimeTypeAdaptiveness = initialValues.allowAudioMixedMimeTypeAdaptiveness;
allowAudioMixedSampleRateAdaptiveness = initialValues.allowAudioMixedSampleRateAdaptiveness; allowAudioMixedSampleRateAdaptiveness = initialValues.allowAudioMixedSampleRateAdaptiveness;
// Text
preferredTextLanguage = initialValues.preferredTextLanguage;
selectUndeterminedTextLanguage = initialValues.selectUndeterminedTextLanguage;
disabledTextTrackSelectionFlags = initialValues.disabledTextTrackSelectionFlags;
// General // General
forceLowestBitrate = initialValues.forceLowestBitrate; forceLowestBitrate = initialValues.forceLowestBitrate;
forceHighestSupportedBitrate = initialValues.forceHighestSupportedBitrate; forceHighestSupportedBitrate = initialValues.forceHighestSupportedBitrate;
...@@ -362,15 +353,9 @@ public class DefaultTrackSelector extends MappingTrackSelector { ...@@ -362,15 +353,9 @@ public class DefaultTrackSelector extends MappingTrackSelector {
// Audio // Audio
/** @Override
* See {@link Parameters#preferredAudioLanguage}.
*
* @param preferredAudioLanguage Preferred audio language as an ISO 639-1 two-letter or ISO
* 639-2 three-letter code.
* @return This builder.
*/
public ParametersBuilder setPreferredAudioLanguage(String preferredAudioLanguage) { public ParametersBuilder setPreferredAudioLanguage(String preferredAudioLanguage) {
this.preferredAudioLanguage = preferredAudioLanguage; super.setPreferredAudioLanguage(preferredAudioLanguage);
return this; return this;
} }
...@@ -429,40 +414,25 @@ public class DefaultTrackSelector extends MappingTrackSelector { ...@@ -429,40 +414,25 @@ public class DefaultTrackSelector extends MappingTrackSelector {
// Text // Text
/** @Override
* See {@link Parameters#preferredTextLanguage}.
*
* @param preferredTextLanguage Preferred text language as an ISO 639-1 two-letter or ISO 639-2
* three-letter code.
* @return This builder.
*/
public ParametersBuilder setPreferredTextLanguage(String preferredTextLanguage) { public ParametersBuilder setPreferredTextLanguage(String preferredTextLanguage) {
this.preferredTextLanguage = preferredTextLanguage; super.setPreferredTextLanguage(preferredTextLanguage);
return this; return this;
} }
/** @Override
* See {@link Parameters#selectUndeterminedTextLanguage}.
*
* @return This builder.
*/
public ParametersBuilder setSelectUndeterminedTextLanguage( public ParametersBuilder setSelectUndeterminedTextLanguage(
boolean selectUndeterminedTextLanguage) { boolean selectUndeterminedTextLanguage) {
this.selectUndeterminedTextLanguage = selectUndeterminedTextLanguage; super.setSelectUndeterminedTextLanguage(selectUndeterminedTextLanguage);
return this; return this;
} }
/** @Override
* See {@link Parameters#disabledTextTrackSelectionFlags}.
*
* @return This builder.
*/
public ParametersBuilder setDisabledTextTrackSelectionFlags( public ParametersBuilder setDisabledTextTrackSelectionFlags(
int disabledTextTrackSelectionFlags) { @C.SelectionFlags int disabledTextTrackSelectionFlags) {
this.disabledTextTrackSelectionFlags = disabledTextTrackSelectionFlags; super.setDisabledTextTrackSelectionFlags(disabledTextTrackSelectionFlags);
return this; return this;
} }
// General // General
/** /**
...@@ -526,10 +496,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { ...@@ -526,10 +496,7 @@ public class DefaultTrackSelector extends MappingTrackSelector {
* C#AUDIO_SESSION_ID_UNSET} to disable tunneling. * C#AUDIO_SESSION_ID_UNSET} to disable tunneling.
*/ */
public ParametersBuilder setTunnelingAudioSessionId(int tunnelingAudioSessionId) { public ParametersBuilder setTunnelingAudioSessionId(int tunnelingAudioSessionId) {
if (this.tunnelingAudioSessionId != tunnelingAudioSessionId) { this.tunnelingAudioSessionId = tunnelingAudioSessionId;
this.tunnelingAudioSessionId = tunnelingAudioSessionId;
return this;
}
return this; return this;
} }
...@@ -670,7 +637,6 @@ public class DefaultTrackSelector extends MappingTrackSelector { ...@@ -670,7 +637,6 @@ public class DefaultTrackSelector extends MappingTrackSelector {
forceHighestSupportedBitrate, forceHighestSupportedBitrate,
exceedRendererCapabilitiesIfNecessary, exceedRendererCapabilitiesIfNecessary,
tunnelingAudioSessionId, tunnelingAudioSessionId,
// Overrides
selectionOverrides, selectionOverrides,
rendererDisabledFlags); rendererDisabledFlags);
} }
...@@ -685,16 +651,15 @@ public class DefaultTrackSelector extends MappingTrackSelector { ...@@ -685,16 +651,15 @@ public class DefaultTrackSelector extends MappingTrackSelector {
} }
} }
/** Constraint parameters for {@link DefaultTrackSelector}. */ /**
public static final class Parameters implements Parcelable { * Extends {@link TrackSelectionParameters} by adding fields that are specific to {@link
* DefaultTrackSelector}.
*/
public static final class Parameters extends TrackSelectionParameters {
/** An instance with default values. */ /** An instance with default values. */
public static final Parameters DEFAULT = new Parameters(); public static final Parameters DEFAULT = new Parameters();
// Overrides
private final SparseArray<Map<TrackGroupArray, SelectionOverride>> selectionOverrides;
private final SparseBooleanArray rendererDisabledFlags;
// Video // Video
/** /**
* Maximum allowed video width. The default value is {@link Integer#MAX_VALUE} (i.e. no * Maximum allowed video width. The default value is {@link Integer#MAX_VALUE} (i.e. no
...@@ -759,15 +724,8 @@ public class DefaultTrackSelector extends MappingTrackSelector { ...@@ -759,15 +724,8 @@ public class DefaultTrackSelector extends MappingTrackSelector {
* The default value is {@code true}. * The default value is {@code true}.
*/ */
public final boolean viewportOrientationMayChange; public final boolean viewportOrientationMayChange;
// Audio // Audio
/** /**
* The preferred language for audio and forced text tracks, as an ISO 639-2/T tag. {@code null}
* selects the default track, or the first track if there's no default. The default value is
* {@code null}.
*/
@Nullable public final String preferredAudioLanguage;
/**
* Maximum allowed audio channel count. The default value is {@link Integer#MAX_VALUE} (i.e. no * Maximum allowed audio channel count. The default value is {@link Integer#MAX_VALUE} (i.e. no
* constraint). * constraint).
*/ */
...@@ -792,24 +750,6 @@ public class DefaultTrackSelector extends MappingTrackSelector { ...@@ -792,24 +750,6 @@ public class DefaultTrackSelector extends MappingTrackSelector {
*/ */
public final boolean allowAudioMixedSampleRateAdaptiveness; public final boolean allowAudioMixedSampleRateAdaptiveness;
// Text
/**
* The preferred language for text tracks as an ISO 639-2/T tag. {@code null} selects the
* default track if there is one, or no track otherwise. The default value is {@code null}.
*/
@Nullable public final String preferredTextLanguage;
/**
* Whether a text track with undetermined language should be selected if no track with {@link
* #preferredTextLanguage} is available, or if {@link #preferredTextLanguage} is unset. The
* default value is {@code false}.
*/
public final boolean selectUndeterminedTextLanguage;
/**
* Bitmask of selection flags that are disabled for text track selections. See {@link
* C.SelectionFlags}. The default value is {@code 0} (i.e. no flags).
*/
public final int disabledTextTrackSelectionFlags;
// General // General
/** /**
* Whether to force selection of the single lowest bitrate audio and video tracks that comply * Whether to force selection of the single lowest bitrate audio and video tracks that comply
...@@ -845,6 +785,10 @@ public class DefaultTrackSelector extends MappingTrackSelector { ...@@ -845,6 +785,10 @@ public class DefaultTrackSelector extends MappingTrackSelector {
*/ */
public final int tunnelingAudioSessionId; public final int tunnelingAudioSessionId;
// Overrides
private final SparseArray<Map<TrackGroupArray, SelectionOverride>> selectionOverrides;
private final SparseBooleanArray rendererDisabledFlags;
private Parameters() { private Parameters() {
this( this(
// Video // Video
...@@ -859,24 +803,23 @@ public class DefaultTrackSelector extends MappingTrackSelector { ...@@ -859,24 +803,23 @@ public class DefaultTrackSelector extends MappingTrackSelector {
/* viewportHeight= */ Integer.MAX_VALUE, /* viewportHeight= */ Integer.MAX_VALUE,
/* viewportOrientationMayChange= */ true, /* viewportOrientationMayChange= */ true,
// Audio // Audio
/* preferredAudioLanguage= */ null, TrackSelectionParameters.DEFAULT.preferredAudioLanguage,
/* maxAudioChannelCount= */ Integer.MAX_VALUE, /* maxAudioChannelCount= */ Integer.MAX_VALUE,
/* maxAudioBitrate= */ Integer.MAX_VALUE, /* maxAudioBitrate= */ Integer.MAX_VALUE,
/* exceedAudioConstraintsIfNecessary= */ true, /* exceedAudioConstraintsIfNecessary= */ true,
/* allowAudioMixedMimeTypeAdaptiveness= */ false, /* allowAudioMixedMimeTypeAdaptiveness= */ false,
/* allowAudioMixedSampleRateAdaptiveness= */ false, /* allowAudioMixedSampleRateAdaptiveness= */ false,
// Text // Text
/* preferredTextLanguage= */ null, TrackSelectionParameters.DEFAULT.preferredTextLanguage,
/* selectUndeterminedTextLanguage= */ false, TrackSelectionParameters.DEFAULT.selectUndeterminedTextLanguage,
/* disabledTextTrackSelectionFlags= */ 0, TrackSelectionParameters.DEFAULT.disabledTextTrackSelectionFlags,
// General // General
/* forceLowestBitrate= */ false, /* forceLowestBitrate= */ false,
/* forceHighestSupportedBitrate= */ false, /* forceHighestSupportedBitrate= */ false,
/* exceedRendererCapabilitiesIfNecessary= */ true, /* exceedRendererCapabilitiesIfNecessary= */ true,
/* tunnelingAudioSessionId= */ C.AUDIO_SESSION_ID_UNSET, /* tunnelingAudioSessionId= */ C.AUDIO_SESSION_ID_UNSET,
// Overrides new SparseArray<>(),
/* selectionOverrides= */ new SparseArray<>(), new SparseBooleanArray());
/* rendererDisabledFlags= */ new SparseBooleanArray());
} }
/* package */ Parameters( /* package */ Parameters(
...@@ -901,7 +844,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { ...@@ -901,7 +844,7 @@ public class DefaultTrackSelector extends MappingTrackSelector {
// Text // Text
@Nullable String preferredTextLanguage, @Nullable String preferredTextLanguage,
boolean selectUndeterminedTextLanguage, boolean selectUndeterminedTextLanguage,
int disabledTextTrackSelectionFlags, @C.SelectionFlags int disabledTextTrackSelectionFlags,
// General // General
boolean forceLowestBitrate, boolean forceLowestBitrate,
boolean forceHighestSupportedBitrate, boolean forceHighestSupportedBitrate,
...@@ -910,6 +853,11 @@ public class DefaultTrackSelector extends MappingTrackSelector { ...@@ -910,6 +853,11 @@ public class DefaultTrackSelector extends MappingTrackSelector {
// Overrides // Overrides
SparseArray<Map<TrackGroupArray, SelectionOverride>> selectionOverrides, SparseArray<Map<TrackGroupArray, SelectionOverride>> selectionOverrides,
SparseBooleanArray rendererDisabledFlags) { SparseBooleanArray rendererDisabledFlags) {
super(
preferredAudioLanguage,
preferredTextLanguage,
selectUndeterminedTextLanguage,
disabledTextTrackSelectionFlags);
// Video // Video
this.maxVideoWidth = maxVideoWidth; this.maxVideoWidth = maxVideoWidth;
this.maxVideoHeight = maxVideoHeight; this.maxVideoHeight = maxVideoHeight;
...@@ -922,30 +870,26 @@ public class DefaultTrackSelector extends MappingTrackSelector { ...@@ -922,30 +870,26 @@ public class DefaultTrackSelector extends MappingTrackSelector {
this.viewportHeight = viewportHeight; this.viewportHeight = viewportHeight;
this.viewportOrientationMayChange = viewportOrientationMayChange; this.viewportOrientationMayChange = viewportOrientationMayChange;
// Audio // Audio
this.preferredAudioLanguage = Util.normalizeLanguageCode(preferredAudioLanguage);
this.maxAudioChannelCount = maxAudioChannelCount; this.maxAudioChannelCount = maxAudioChannelCount;
this.maxAudioBitrate = maxAudioBitrate; this.maxAudioBitrate = maxAudioBitrate;
this.exceedAudioConstraintsIfNecessary = exceedAudioConstraintsIfNecessary; this.exceedAudioConstraintsIfNecessary = exceedAudioConstraintsIfNecessary;
this.allowAudioMixedMimeTypeAdaptiveness = allowAudioMixedMimeTypeAdaptiveness; this.allowAudioMixedMimeTypeAdaptiveness = allowAudioMixedMimeTypeAdaptiveness;
this.allowAudioMixedSampleRateAdaptiveness = allowAudioMixedSampleRateAdaptiveness; this.allowAudioMixedSampleRateAdaptiveness = allowAudioMixedSampleRateAdaptiveness;
// Text
this.preferredTextLanguage = Util.normalizeLanguageCode(preferredTextLanguage);
this.selectUndeterminedTextLanguage = selectUndeterminedTextLanguage;
this.disabledTextTrackSelectionFlags = disabledTextTrackSelectionFlags;
// General // General
this.forceLowestBitrate = forceLowestBitrate; this.forceLowestBitrate = forceLowestBitrate;
this.forceHighestSupportedBitrate = forceHighestSupportedBitrate; this.forceHighestSupportedBitrate = forceHighestSupportedBitrate;
this.exceedRendererCapabilitiesIfNecessary = exceedRendererCapabilitiesIfNecessary; this.exceedRendererCapabilitiesIfNecessary = exceedRendererCapabilitiesIfNecessary;
this.tunnelingAudioSessionId = tunnelingAudioSessionId; this.tunnelingAudioSessionId = tunnelingAudioSessionId;
// Overrides
this.selectionOverrides = selectionOverrides;
this.rendererDisabledFlags = rendererDisabledFlags;
// Deprecated fields. // Deprecated fields.
this.allowMixedMimeAdaptiveness = allowVideoMixedMimeTypeAdaptiveness; this.allowMixedMimeAdaptiveness = allowVideoMixedMimeTypeAdaptiveness;
this.allowNonSeamlessAdaptiveness = allowVideoNonSeamlessAdaptiveness; this.allowNonSeamlessAdaptiveness = allowVideoNonSeamlessAdaptiveness;
// Overrides
this.selectionOverrides = selectionOverrides;
this.rendererDisabledFlags = rendererDisabledFlags;
} }
/* package */ Parameters(Parcel in) { /* package */ Parameters(Parcel in) {
super(in);
// Video // Video
this.maxVideoWidth = in.readInt(); this.maxVideoWidth = in.readInt();
this.maxVideoHeight = in.readInt(); this.maxVideoHeight = in.readInt();
...@@ -958,16 +902,11 @@ public class DefaultTrackSelector extends MappingTrackSelector { ...@@ -958,16 +902,11 @@ public class DefaultTrackSelector extends MappingTrackSelector {
this.viewportHeight = in.readInt(); this.viewportHeight = in.readInt();
this.viewportOrientationMayChange = Util.readBoolean(in); this.viewportOrientationMayChange = Util.readBoolean(in);
// Audio // Audio
this.preferredAudioLanguage = in.readString();
this.maxAudioChannelCount = in.readInt(); this.maxAudioChannelCount = in.readInt();
this.maxAudioBitrate = in.readInt(); this.maxAudioBitrate = in.readInt();
this.exceedAudioConstraintsIfNecessary = Util.readBoolean(in); this.exceedAudioConstraintsIfNecessary = Util.readBoolean(in);
this.allowAudioMixedMimeTypeAdaptiveness = Util.readBoolean(in); this.allowAudioMixedMimeTypeAdaptiveness = Util.readBoolean(in);
this.allowAudioMixedSampleRateAdaptiveness = Util.readBoolean(in); this.allowAudioMixedSampleRateAdaptiveness = Util.readBoolean(in);
// Text
this.preferredTextLanguage = in.readString();
this.selectUndeterminedTextLanguage = Util.readBoolean(in);
this.disabledTextTrackSelectionFlags = in.readInt();
// General // General
this.forceLowestBitrate = Util.readBoolean(in); this.forceLowestBitrate = Util.readBoolean(in);
this.forceHighestSupportedBitrate = Util.readBoolean(in); this.forceHighestSupportedBitrate = Util.readBoolean(in);
...@@ -1016,9 +955,8 @@ public class DefaultTrackSelector extends MappingTrackSelector { ...@@ -1016,9 +955,8 @@ public class DefaultTrackSelector extends MappingTrackSelector {
return overrides != null ? overrides.get(groups) : null; return overrides != null ? overrides.get(groups) : null;
} }
/** /** Creates a new {@link ParametersBuilder}, copying the initial values from this instance. */
* Creates a new {@link ParametersBuilder}, copying the initial values from this instance. @Override
*/
public ParametersBuilder buildUpon() { public ParametersBuilder buildUpon() {
return new ParametersBuilder(this); return new ParametersBuilder(this);
} }
...@@ -1032,7 +970,9 @@ public class DefaultTrackSelector extends MappingTrackSelector { ...@@ -1032,7 +970,9 @@ public class DefaultTrackSelector extends MappingTrackSelector {
return false; return false;
} }
Parameters other = (Parameters) obj; Parameters other = (Parameters) obj;
return maxVideoWidth == other.maxVideoWidth return super.equals(obj)
// Video
&& maxVideoWidth == other.maxVideoWidth
&& maxVideoHeight == other.maxVideoHeight && maxVideoHeight == other.maxVideoHeight
&& maxVideoFrameRate == other.maxVideoFrameRate && maxVideoFrameRate == other.maxVideoFrameRate
&& maxVideoBitrate == other.maxVideoBitrate && maxVideoBitrate == other.maxVideoBitrate
...@@ -1043,16 +983,11 @@ public class DefaultTrackSelector extends MappingTrackSelector { ...@@ -1043,16 +983,11 @@ public class DefaultTrackSelector extends MappingTrackSelector {
&& viewportWidth == other.viewportWidth && viewportWidth == other.viewportWidth
&& viewportHeight == other.viewportHeight && viewportHeight == other.viewportHeight
// Audio // Audio
&& TextUtils.equals(preferredAudioLanguage, other.preferredAudioLanguage)
&& maxAudioChannelCount == other.maxAudioChannelCount && maxAudioChannelCount == other.maxAudioChannelCount
&& maxAudioBitrate == other.maxAudioBitrate && maxAudioBitrate == other.maxAudioBitrate
&& exceedAudioConstraintsIfNecessary == other.exceedAudioConstraintsIfNecessary && exceedAudioConstraintsIfNecessary == other.exceedAudioConstraintsIfNecessary
&& allowAudioMixedMimeTypeAdaptiveness == other.allowAudioMixedMimeTypeAdaptiveness && allowAudioMixedMimeTypeAdaptiveness == other.allowAudioMixedMimeTypeAdaptiveness
&& allowAudioMixedSampleRateAdaptiveness == other.allowAudioMixedSampleRateAdaptiveness && allowAudioMixedSampleRateAdaptiveness == other.allowAudioMixedSampleRateAdaptiveness
// Text
&& TextUtils.equals(preferredTextLanguage, other.preferredTextLanguage)
&& selectUndeterminedTextLanguage == other.selectUndeterminedTextLanguage
&& disabledTextTrackSelectionFlags == other.disabledTextTrackSelectionFlags
// General // General
&& forceLowestBitrate == other.forceLowestBitrate && forceLowestBitrate == other.forceLowestBitrate
&& forceHighestSupportedBitrate == other.forceHighestSupportedBitrate && forceHighestSupportedBitrate == other.forceHighestSupportedBitrate
...@@ -1065,7 +1000,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { ...@@ -1065,7 +1000,7 @@ public class DefaultTrackSelector extends MappingTrackSelector {
@Override @Override
public int hashCode() { public int hashCode() {
int result = 1; int result = super.hashCode();
// Video // Video
result = 31 * result + maxVideoWidth; result = 31 * result + maxVideoWidth;
result = 31 * result + maxVideoHeight; result = 31 * result + maxVideoHeight;
...@@ -1078,17 +1013,11 @@ public class DefaultTrackSelector extends MappingTrackSelector { ...@@ -1078,17 +1013,11 @@ public class DefaultTrackSelector extends MappingTrackSelector {
result = 31 * result + viewportWidth; result = 31 * result + viewportWidth;
result = 31 * result + viewportHeight; result = 31 * result + viewportHeight;
// Audio // Audio
result =
31 * result + (preferredAudioLanguage == null ? 0 : preferredAudioLanguage.hashCode());
result = 31 * result + maxAudioChannelCount; result = 31 * result + maxAudioChannelCount;
result = 31 * result + maxAudioBitrate; result = 31 * result + maxAudioBitrate;
result = 31 * result + (exceedAudioConstraintsIfNecessary ? 1 : 0); result = 31 * result + (exceedAudioConstraintsIfNecessary ? 1 : 0);
result = 31 * result + (allowAudioMixedMimeTypeAdaptiveness ? 1 : 0); result = 31 * result + (allowAudioMixedMimeTypeAdaptiveness ? 1 : 0);
result = 31 * result + (allowAudioMixedSampleRateAdaptiveness ? 1 : 0); result = 31 * result + (allowAudioMixedSampleRateAdaptiveness ? 1 : 0);
// Text
result = 31 * result + (preferredTextLanguage == null ? 0 : preferredTextLanguage.hashCode());
result = 31 * result + (selectUndeterminedTextLanguage ? 1 : 0);
result = 31 * result + disabledTextTrackSelectionFlags;
// General // General
result = 31 * result + (forceLowestBitrate ? 1 : 0); result = 31 * result + (forceLowestBitrate ? 1 : 0);
result = 31 * result + (forceHighestSupportedBitrate ? 1 : 0); result = 31 * result + (forceHighestSupportedBitrate ? 1 : 0);
...@@ -1107,6 +1036,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { ...@@ -1107,6 +1036,7 @@ public class DefaultTrackSelector extends MappingTrackSelector {
@Override @Override
public void writeToParcel(Parcel dest, int flags) { public void writeToParcel(Parcel dest, int flags) {
super.writeToParcel(dest, flags);
// Video // Video
dest.writeInt(maxVideoWidth); dest.writeInt(maxVideoWidth);
dest.writeInt(maxVideoHeight); dest.writeInt(maxVideoHeight);
...@@ -1119,16 +1049,11 @@ public class DefaultTrackSelector extends MappingTrackSelector { ...@@ -1119,16 +1049,11 @@ public class DefaultTrackSelector extends MappingTrackSelector {
dest.writeInt(viewportHeight); dest.writeInt(viewportHeight);
Util.writeBoolean(dest, viewportOrientationMayChange); Util.writeBoolean(dest, viewportOrientationMayChange);
// Audio // Audio
dest.writeString(preferredAudioLanguage);
dest.writeInt(maxAudioChannelCount); dest.writeInt(maxAudioChannelCount);
dest.writeInt(maxAudioBitrate); dest.writeInt(maxAudioBitrate);
Util.writeBoolean(dest, exceedAudioConstraintsIfNecessary); Util.writeBoolean(dest, exceedAudioConstraintsIfNecessary);
Util.writeBoolean(dest, allowAudioMixedMimeTypeAdaptiveness); Util.writeBoolean(dest, allowAudioMixedMimeTypeAdaptiveness);
Util.writeBoolean(dest, allowAudioMixedSampleRateAdaptiveness); Util.writeBoolean(dest, allowAudioMixedSampleRateAdaptiveness);
// Text
dest.writeString(preferredTextLanguage);
Util.writeBoolean(dest, selectUndeterminedTextLanguage);
dest.writeInt(disabledTextTrackSelectionFlags);
// General // General
Util.writeBoolean(dest, forceLowestBitrate); Util.writeBoolean(dest, forceLowestBitrate);
Util.writeBoolean(dest, forceHighestSupportedBitrate); Util.writeBoolean(dest, forceHighestSupportedBitrate);
......
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.exoplayer2.trackselection;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.util.Util;
/** Constraint parameters for track selection. */
public class TrackSelectionParameters implements Parcelable {
/**
* A builder for {@link TrackSelectionParameters}. See the {@link TrackSelectionParameters}
* documentation for explanations of the parameters that can be configured using this builder.
*/
public static class Builder {
// Audio
@Nullable /* package */ String preferredAudioLanguage;
// Text
@Nullable /* package */ String preferredTextLanguage;
/* package */ boolean selectUndeterminedTextLanguage;
@C.SelectionFlags /* package */ int disabledTextTrackSelectionFlags;
/** Creates a builder with default initial values. */
public Builder() {
this(DEFAULT);
}
/**
* @param initialValues The {@link TrackSelectionParameters} from which the initial values of
* the builder are obtained.
*/
/* package */ Builder(TrackSelectionParameters initialValues) {
// Audio
preferredAudioLanguage = initialValues.preferredAudioLanguage;
// Text
preferredTextLanguage = initialValues.preferredTextLanguage;
selectUndeterminedTextLanguage = initialValues.selectUndeterminedTextLanguage;
disabledTextTrackSelectionFlags = initialValues.disabledTextTrackSelectionFlags;
}
/**
* See {@link TrackSelectionParameters#preferredAudioLanguage}.
*
* @param preferredAudioLanguage Preferred audio language as an ISO 639-1 two-letter or ISO
* 639-2 three-letter code.
* @return This builder.
*/
public Builder setPreferredAudioLanguage(String preferredAudioLanguage) {
this.preferredAudioLanguage = preferredAudioLanguage;
return this;
}
// Text
/**
* See {@link TrackSelectionParameters#preferredTextLanguage}.
*
* @param preferredTextLanguage Preferred text language as an ISO 639-1 two-letter or ISO 639-2
* three-letter code.
* @return This builder.
*/
public Builder setPreferredTextLanguage(String preferredTextLanguage) {
this.preferredTextLanguage = preferredTextLanguage;
return this;
}
/**
* See {@link TrackSelectionParameters#selectUndeterminedTextLanguage}.
*
* @return This builder.
*/
public Builder setSelectUndeterminedTextLanguage(boolean selectUndeterminedTextLanguage) {
this.selectUndeterminedTextLanguage = selectUndeterminedTextLanguage;
return this;
}
/**
* See {@link TrackSelectionParameters#disabledTextTrackSelectionFlags}.
*
* @return This builder.
*/
public Builder setDisabledTextTrackSelectionFlags(
@C.SelectionFlags int disabledTextTrackSelectionFlags) {
this.disabledTextTrackSelectionFlags = disabledTextTrackSelectionFlags;
return this;
}
/** Builds a {@link TrackSelectionParameters} instance with the selected values. */
public TrackSelectionParameters build() {
return new TrackSelectionParameters(
// Audio
preferredAudioLanguage,
// Text
preferredTextLanguage,
selectUndeterminedTextLanguage,
disabledTextTrackSelectionFlags);
}
}
/** An instance with default values. */
public static final TrackSelectionParameters DEFAULT = new TrackSelectionParameters();
/**
* The preferred language for audio and forced text tracks, as an ISO 639-2/T tag. {@code null}
* selects the default track, or the first track if there's no default. The default value is
* {@code null}.
*/
@Nullable public final String preferredAudioLanguage;
// Text
/**
* The preferred language for text tracks as an ISO 639-2/T tag. {@code null} selects the default
* track if there is one, or no track otherwise. The default value is {@code null}.
*/
@Nullable public final String preferredTextLanguage;
/**
* Whether a text track with undetermined language should be selected if no track with {@link
* #preferredTextLanguage} is available, or if {@link #preferredTextLanguage} is unset. The
* default value is {@code false}.
*/
public final boolean selectUndeterminedTextLanguage;
/**
* Bitmask of selection flags that are disabled for text track selections. See {@link
* C.SelectionFlags}. The default value is {@code 0} (i.e. no flags).
*/
@C.SelectionFlags public final int disabledTextTrackSelectionFlags;
/* package */ TrackSelectionParameters() {
this(
/* preferredAudioLanguage= */ null,
// Text
/* preferredTextLanguage= */ null,
/* selectUndeterminedTextLanguage= */ false,
/* disabledTextTrackSelectionFlags= */ 0);
}
/* package */ TrackSelectionParameters(
@Nullable String preferredAudioLanguage,
@Nullable String preferredTextLanguage,
boolean selectUndeterminedTextLanguage,
@C.SelectionFlags int disabledTextTrackSelectionFlags) {
// Audio
this.preferredAudioLanguage = Util.normalizeLanguageCode(preferredAudioLanguage);
// Text
this.preferredTextLanguage = Util.normalizeLanguageCode(preferredTextLanguage);
this.selectUndeterminedTextLanguage = selectUndeterminedTextLanguage;
this.disabledTextTrackSelectionFlags = disabledTextTrackSelectionFlags;
}
/* package */ TrackSelectionParameters(Parcel in) {
// Audio
this.preferredAudioLanguage = in.readString();
// Text
this.preferredTextLanguage = in.readString();
this.selectUndeterminedTextLanguage = Util.readBoolean(in);
this.disabledTextTrackSelectionFlags = in.readInt();
}
/** Creates a new {@link Builder}, copying the initial values from this instance. */
public Builder buildUpon() {
return new Builder(this);
}
@Override
@SuppressWarnings("EqualsGetClass")
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
TrackSelectionParameters other = (TrackSelectionParameters) obj;
return TextUtils.equals(preferredAudioLanguage, other.preferredAudioLanguage)
// Text
&& TextUtils.equals(preferredTextLanguage, other.preferredTextLanguage)
&& selectUndeterminedTextLanguage == other.selectUndeterminedTextLanguage
&& disabledTextTrackSelectionFlags == other.disabledTextTrackSelectionFlags;
}
@Override
public int hashCode() {
int result = 1;
// Audio
result = 31 * result + (preferredAudioLanguage == null ? 0 : preferredAudioLanguage.hashCode());
// Text
result = 31 * result + (preferredTextLanguage == null ? 0 : preferredTextLanguage.hashCode());
result = 31 * result + (selectUndeterminedTextLanguage ? 1 : 0);
result = 31 * result + disabledTextTrackSelectionFlags;
return result;
}
// Parcelable implementation.
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
// Audio
dest.writeString(preferredAudioLanguage);
// Text
dest.writeString(preferredTextLanguage);
Util.writeBoolean(dest, selectUndeterminedTextLanguage);
dest.writeInt(disabledTextTrackSelectionFlags);
}
public static final Creator<TrackSelectionParameters> CREATOR =
new Creator<TrackSelectionParameters>() {
@Override
public TrackSelectionParameters createFromParcel(Parcel in) {
return new TrackSelectionParameters(in);
}
@Override
public TrackSelectionParameters[] newArray(int size) {
return new TrackSelectionParameters[size];
}
};
}
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