Commit 7c551081 by olly Committed by Oliver Woodman

Only pass RendererCapabilities to TrackSelectors

We should only give a TrackSelector access to what it
needs, not the whole Renderer. This is particular true
if [] happens, since more Renderer methods
will become publicly visible.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=127526473
parent 97d9c94c
...@@ -20,7 +20,6 @@ import com.google.android.exoplayer2.decoder.DecoderInputBuffer; ...@@ -20,7 +20,6 @@ import com.google.android.exoplayer2.decoder.DecoderInputBuffer;
import com.google.android.exoplayer2.source.SampleStream; import com.google.android.exoplayer2.source.SampleStream;
import com.google.android.exoplayer2.util.Assertions; import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.MediaClock; import com.google.android.exoplayer2.util.MediaClock;
import com.google.android.exoplayer2.util.MimeTypes;
import java.io.IOException; import java.io.IOException;
...@@ -35,64 +34,7 @@ import java.io.IOException; ...@@ -35,64 +34,7 @@ import java.io.IOException;
* alt="Renderer state transitions" * alt="Renderer state transitions"
* border="0"/></p> * border="0"/></p>
*/ */
public abstract class Renderer implements ExoPlayerComponent { public abstract class Renderer implements ExoPlayerComponent, RendererCapabilities {
/**
* A mask to apply to the result of {@link #supportsFormat(Format)} to obtain one of
* {@link #FORMAT_HANDLED}, {@link #FORMAT_EXCEEDS_CAPABILITIES},
* {@link #FORMAT_UNSUPPORTED_SUBTYPE} and {@link #FORMAT_UNSUPPORTED_TYPE}.
*/
public static final int FORMAT_SUPPORT_MASK = 0b11;
/**
* The {@link Renderer} is capable of rendering the format.
*/
public static final int FORMAT_HANDLED = 0b11;
/**
* The {@link Renderer} is capable of rendering formats with the same mimeType, but the
* properties of the format exceed the renderer's capability.
* <p>
* Example: The {@link Renderer} is capable of rendering H264 and the format's mimeType is
* {@link MimeTypes#VIDEO_H264}, but the format's resolution exceeds the maximum limit supported
* by the underlying H264 decoder.
*/
public static final int FORMAT_EXCEEDS_CAPABILITIES = 0b10;
/**
* The {@link Renderer} is a general purpose renderer for formats of the same top-level type,
* but is not capable of rendering the format or any other format with the same mimeType because
* the sub-type is not supported.
* <p>
* Example: The {@link Renderer} is a general purpose audio renderer and the format's
* mimeType matches audio/[subtype], but there does not exist a suitable decoder for [subtype].
*/
public static final int FORMAT_UNSUPPORTED_SUBTYPE = 0b01;
/**
* The {@link Renderer} is not capable of rendering the format, either because it does not
* support the format's top-level type, or because it's a specialized renderer for a different
* mimeType.
* <p>
* Example: The {@link Renderer} is a general purpose video renderer, but the format has an
* audio mimeType.
*/
public static final int FORMAT_UNSUPPORTED_TYPE = 0b00;
/**
* A mask to apply to the result of {@link #supportsFormat(Format)} to obtain one of
* {@link #ADAPTIVE_SEAMLESS}, {@link #ADAPTIVE_NOT_SEAMLESS} and {@link #ADAPTIVE_NOT_SUPPORTED}.
*/
public static final int ADAPTIVE_SUPPORT_MASK = 0b1100;
/**
* The {@link Renderer} can seamlessly adapt between formats.
*/
public static final int ADAPTIVE_SEAMLESS = 0b1000;
/**
* The {@link Renderer} can adapt between formats, but may suffer a brief discontinuity
* (~50-100ms) when adaptation occurs.
*/
public static final int ADAPTIVE_NOT_SEAMLESS = 0b0100;
/**
* The {@link Renderer} does not support adaptation between formats.
*/
public static final int ADAPTIVE_NOT_SUPPORTED = 0b0000;
/** /**
* The renderer is disabled. * The renderer is disabled.
...@@ -159,19 +101,6 @@ public abstract class Renderer implements ExoPlayerComponent { ...@@ -159,19 +101,6 @@ public abstract class Renderer implements ExoPlayerComponent {
} }
/** /**
* Returns the extent to which the renderer supports adapting between supported formats that have
* different mimeTypes.
*
* @return The extent to which the renderer supports adapting between supported formats that have
* different mimeTypes. One of {@link #ADAPTIVE_SEAMLESS}, {@link #ADAPTIVE_NOT_SEAMLESS} and
* {@link #ADAPTIVE_NOT_SUPPORTED}.
* @throws ExoPlaybackException If an error occurs.
*/
public int supportsMixedMimeTypeAdaptation() throws ExoPlaybackException {
return ADAPTIVE_NOT_SUPPORTED;
}
/**
* Enable the renderer to consume from the specified {@link SampleStream}. * Enable the renderer to consume from the specified {@link SampleStream}.
* *
* @param formats The enabled formats. * @param formats The enabled formats.
...@@ -383,36 +312,6 @@ public abstract class Renderer implements ExoPlayerComponent { ...@@ -383,36 +312,6 @@ public abstract class Renderer implements ExoPlayerComponent {
// Abstract methods. // Abstract methods.
/** /**
* Returns the track type that the renderer handles. For example, a video renderer will return
* {@link C#TRACK_TYPE_VIDEO}, an audio renderer will return {@link C#TRACK_TYPE_AUDIO}, a text
* renderer will return {@link C#TRACK_TYPE_TEXT}, and so on.
*
* @return One of the {@code TRACK_TYPE_*} constants defined in {@link C}.
*/
public abstract int getTrackType();
/**
* Returns the extent to which the renderer supports a given format.
* <p>
* The returned value is the bitwise OR of two properties:
* <ul>
* <li>The level of support for the format itself. One of {@code}link #FORMAT_HANDLED},
* {@link #FORMAT_EXCEEDS_CAPABILITIES}, {@link #FORMAT_UNSUPPORTED_SUBTYPE} and
* {@link #FORMAT_UNSUPPORTED_TYPE}.</li>
* <li>The level of support for adapting from the format to another format of the same mimeType.
* One of {@link #ADAPTIVE_SEAMLESS}, {@link #ADAPTIVE_NOT_SEAMLESS} and
* {@link #ADAPTIVE_NOT_SUPPORTED}.</li>
* </ul>
* The individual properties can be retrieved by performing a bitwise AND with
* {@link #FORMAT_SUPPORT_MASK} and {@link #ADAPTIVE_SUPPORT_MASK} respectively.
*
* @param format The format.
* @return The extent to which the renderer is capable of supporting the given format.
* @throws ExoPlaybackException If an error occurs.
*/
public abstract int supportsFormat(Format format) throws ExoPlaybackException;
/**
* Incrementally renders the {@link SampleStream}. * Incrementally renders the {@link SampleStream}.
* <p> * <p>
* This method should return quickly, and should not block if the renderer is unable to make * This method should return quickly, and should not block if the renderer is unable to make
...@@ -459,6 +358,13 @@ public abstract class Renderer implements ExoPlayerComponent { ...@@ -459,6 +358,13 @@ public abstract class Renderer implements ExoPlayerComponent {
*/ */
protected abstract boolean isEnded(); protected abstract boolean isEnded();
// RendererCapabilities implementation
@Override
public int supportsMixedMimeTypeAdaptation() throws ExoPlaybackException {
return ADAPTIVE_NOT_SUPPORTED;
}
// ExoPlayerComponent implementation. // ExoPlayerComponent implementation.
@Override @Override
......
/*
* Copyright (C) 2016 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;
import com.google.android.exoplayer2.util.MimeTypes;
/**
* Defines the capabilities of a {@link Renderer}.
*/
public interface RendererCapabilities {
/**
* A mask to apply to the result of {@link #supportsFormat(Format)} to obtain one of
* {@link #FORMAT_HANDLED}, {@link #FORMAT_EXCEEDS_CAPABILITIES},
* {@link #FORMAT_UNSUPPORTED_SUBTYPE} and {@link #FORMAT_UNSUPPORTED_TYPE}.
*/
int FORMAT_SUPPORT_MASK = 0b11;
/**
* The {@link Renderer} is capable of rendering the format.
*/
int FORMAT_HANDLED = 0b11;
/**
* The {@link Renderer} is capable of rendering formats with the same mimeType, but the
* properties of the format exceed the renderer's capability.
* <p>
* Example: The {@link Renderer} is capable of rendering H264 and the format's mimeType is
* {@link MimeTypes#VIDEO_H264}, but the format's resolution exceeds the maximum limit supported
* by the underlying H264 decoder.
*/
int FORMAT_EXCEEDS_CAPABILITIES = 0b10;
/**
* The {@link Renderer} is a general purpose renderer for formats of the same top-level type,
* but is not capable of rendering the format or any other format with the same mimeType because
* the sub-type is not supported.
* <p>
* Example: The {@link Renderer} is a general purpose audio renderer and the format's
* mimeType matches audio/[subtype], but there does not exist a suitable decoder for [subtype].
*/
int FORMAT_UNSUPPORTED_SUBTYPE = 0b01;
/**
* The {@link Renderer} is not capable of rendering the format, either because it does not
* support the format's top-level type, or because it's a specialized renderer for a different
* mimeType.
* <p>
* Example: The {@link Renderer} is a general purpose video renderer, but the format has an
* audio mimeType.
*/
int FORMAT_UNSUPPORTED_TYPE = 0b00;
/**
* A mask to apply to the result of {@link #supportsFormat(Format)} to obtain one of
* {@link #ADAPTIVE_SEAMLESS}, {@link #ADAPTIVE_NOT_SEAMLESS} and {@link #ADAPTIVE_NOT_SUPPORTED}.
*/
int ADAPTIVE_SUPPORT_MASK = 0b1100;
/**
* The {@link Renderer} can seamlessly adapt between formats.
*/
int ADAPTIVE_SEAMLESS = 0b1000;
/**
* The {@link Renderer} can adapt between formats, but may suffer a brief discontinuity
* (~50-100ms) when adaptation occurs.
*/
int ADAPTIVE_NOT_SEAMLESS = 0b0100;
/**
* The {@link Renderer} does not support adaptation between formats.
*/
int ADAPTIVE_NOT_SUPPORTED = 0b0000;
/**
* Returns the track type that the {@link Renderer} handles. For example, a video renderer will
* return {@link C#TRACK_TYPE_VIDEO}, an audio renderer will return {@link C#TRACK_TYPE_AUDIO}, a
* text renderer will return {@link C#TRACK_TYPE_TEXT}, and so on.
*
* @return One of the {@code TRACK_TYPE_*} constants defined in {@link C}.
*/
int getTrackType();
/**
* Returns the extent to which the {@link Renderer} supports a given format.
* <p>
* The returned value is the bitwise OR of two properties:
* <ul>
* <li>The level of support for the format itself. One of {@code}link #FORMAT_HANDLED},
* {@link #FORMAT_EXCEEDS_CAPABILITIES}, {@link #FORMAT_UNSUPPORTED_SUBTYPE} and
* {@link #FORMAT_UNSUPPORTED_TYPE}.</li>
* <li>The level of support for adapting from the format to another format of the same mimeType.
* One of {@link #ADAPTIVE_SEAMLESS}, {@link #ADAPTIVE_NOT_SEAMLESS} and
* {@link #ADAPTIVE_NOT_SUPPORTED}.</li>
* </ul>
* The individual properties can be retrieved by performing a bitwise AND with
* {@link #FORMAT_SUPPORT_MASK} and {@link #ADAPTIVE_SUPPORT_MASK} respectively.
*
* @param format The format.
* @return The extent to which the renderer is capable of supporting the given format.
* @throws ExoPlaybackException If an error occurs.
*/
int supportsFormat(Format format) throws ExoPlaybackException;
/**
* Returns the extent to which the {@link Renderer} supports adapting between supported formats
* that have different mimeTypes.
*
* @return The extent to which the renderer supports adapting between supported formats that have
* different mimeTypes. One of {@link #ADAPTIVE_SEAMLESS}, {@link #ADAPTIVE_NOT_SEAMLESS} and
* {@link #ADAPTIVE_NOT_SUPPORTED}.
* @throws ExoPlaybackException If an error occurs.
*/
int supportsMixedMimeTypeAdaptation() throws ExoPlaybackException;
}
...@@ -18,7 +18,7 @@ package com.google.android.exoplayer2.trackselection; ...@@ -18,7 +18,7 @@ package com.google.android.exoplayer2.trackselection;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlaybackException; import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.Renderer; import com.google.android.exoplayer2.RendererCapabilities;
import com.google.android.exoplayer2.source.TrackGroup; import com.google.android.exoplayer2.source.TrackGroup;
import com.google.android.exoplayer2.source.TrackGroupArray; import com.google.android.exoplayer2.source.TrackGroupArray;
import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.util.Util;
...@@ -131,15 +131,15 @@ public class DefaultTrackSelector extends MappingTrackSelector { ...@@ -131,15 +131,15 @@ public class DefaultTrackSelector extends MappingTrackSelector {
// TrackSelectionPolicy implementation. // TrackSelectionPolicy implementation.
@Override @Override
protected TrackSelection[] selectTracks(Renderer[] renderers, protected TrackSelection[] selectTracks(RendererCapabilities[] rendererCapabilities,
TrackGroupArray[] rendererTrackGroupArrays, int[][][] rendererFormatSupports) TrackGroupArray[] rendererTrackGroupArrays, int[][][] rendererFormatSupports)
throws ExoPlaybackException { throws ExoPlaybackException {
// Make a track selection for each renderer. // Make a track selection for each renderer.
TrackSelection[] rendererTrackSelections = new TrackSelection[renderers.length]; TrackSelection[] rendererTrackSelections = new TrackSelection[rendererCapabilities.length];
for (int i = 0; i < renderers.length; i++) { for (int i = 0; i < rendererCapabilities.length; i++) {
switch (renderers[i].getTrackType()) { switch (rendererCapabilities[i].getTrackType()) {
case C.TRACK_TYPE_VIDEO: case C.TRACK_TYPE_VIDEO:
rendererTrackSelections[i] = selectTrackForVideoRenderer(renderers[i], rendererTrackSelections[i] = selectTrackForVideoRenderer(rendererCapabilities[i],
rendererTrackGroupArrays[i], rendererFormatSupports[i], maxVideoWidth, maxVideoHeight, rendererTrackGroupArrays[i], rendererFormatSupports[i], maxVideoWidth, maxVideoHeight,
allowNonSeamlessAdaptiveness, allowMixedMimeAdaptiveness); allowNonSeamlessAdaptiveness, allowMixedMimeAdaptiveness);
if (rendererTrackSelections[i] == null && exceedVideoConstraintsIfNecessary) { if (rendererTrackSelections[i] == null && exceedVideoConstraintsIfNecessary) {
...@@ -166,15 +166,16 @@ public class DefaultTrackSelector extends MappingTrackSelector { ...@@ -166,15 +166,16 @@ public class DefaultTrackSelector extends MappingTrackSelector {
// Video track selection implementation. // Video track selection implementation.
private static TrackSelection selectTrackForVideoRenderer(Renderer renderer, private static TrackSelection selectTrackForVideoRenderer(
TrackGroupArray trackGroups, int[][] formatSupport, int maxVideoWidth, int maxVideoHeight, RendererCapabilities rendererCapabilities, TrackGroupArray trackGroups,
int[][] formatSupport, int maxVideoWidth, int maxVideoHeight,
boolean allowNonSeamlessAdaptiveness, boolean allowMixedMimeAdaptiveness) boolean allowNonSeamlessAdaptiveness, boolean allowMixedMimeAdaptiveness)
throws ExoPlaybackException { throws ExoPlaybackException {
int requiredAdaptiveSupport = allowNonSeamlessAdaptiveness int requiredAdaptiveSupport = allowNonSeamlessAdaptiveness
? (Renderer.ADAPTIVE_NOT_SEAMLESS | Renderer.ADAPTIVE_SEAMLESS) ? (RendererCapabilities.ADAPTIVE_NOT_SEAMLESS | RendererCapabilities.ADAPTIVE_SEAMLESS)
: Renderer.ADAPTIVE_SEAMLESS; : RendererCapabilities.ADAPTIVE_SEAMLESS;
boolean allowMixedMimeTypes = allowMixedMimeAdaptiveness boolean allowMixedMimeTypes = allowMixedMimeAdaptiveness
&& (renderer.supportsMixedMimeTypeAdaptation() & requiredAdaptiveSupport) != 0; && (rendererCapabilities.supportsMixedMimeTypeAdaptation() & requiredAdaptiveSupport) != 0;
int largestAdaptiveGroup = -1; int largestAdaptiveGroup = -1;
int[] largestAdaptiveGroupTracks = NO_TRACKS; int[] largestAdaptiveGroupTracks = NO_TRACKS;
for (int i = 0; i < trackGroups.length; i++) { for (int i = 0; i < trackGroups.length; i++) {
...@@ -356,7 +357,8 @@ public class DefaultTrackSelector extends MappingTrackSelector { ...@@ -356,7 +357,8 @@ public class DefaultTrackSelector extends MappingTrackSelector {
} }
private static boolean isSupported(int formatSupport) { private static boolean isSupported(int formatSupport) {
return (formatSupport & Renderer.FORMAT_SUPPORT_MASK) == Renderer.FORMAT_HANDLED; return (formatSupport & RendererCapabilities.FORMAT_SUPPORT_MASK)
== RendererCapabilities.FORMAT_HANDLED;
} }
private static boolean formatHasLanguage(Format format, String language) { private static boolean formatHasLanguage(Format format, String language) {
......
...@@ -17,7 +17,7 @@ package com.google.android.exoplayer2.trackselection; ...@@ -17,7 +17,7 @@ package com.google.android.exoplayer2.trackselection;
import com.google.android.exoplayer2.ExoPlaybackException; import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.Renderer; import com.google.android.exoplayer2.RendererCapabilities;
import com.google.android.exoplayer2.source.TrackGroup; import com.google.android.exoplayer2.source.TrackGroup;
import com.google.android.exoplayer2.source.TrackGroupArray; import com.google.android.exoplayer2.source.TrackGroupArray;
import com.google.android.exoplayer2.util.Assertions; import com.google.android.exoplayer2.util.Assertions;
...@@ -35,8 +35,7 @@ import java.util.concurrent.CopyOnWriteArraySet; ...@@ -35,8 +35,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
/** /**
* Base class for {@link TrackSelector}s that first establish a mapping between {@link TrackGroup}s * Base class for {@link TrackSelector}s that first establish a mapping between {@link TrackGroup}s
* and {@link Renderer}s, and then from the mapping create {@link TrackSelection}s for each of the * and renderers, and then from that mapping create a {@link TrackSelection} for each renderer.
* {@link Renderer}s.
*/ */
public abstract class MappingTrackSelector extends TrackSelector { public abstract class MappingTrackSelector extends TrackSelector {
...@@ -226,31 +225,32 @@ public abstract class MappingTrackSelector extends TrackSelector { ...@@ -226,31 +225,32 @@ public abstract class MappingTrackSelector extends TrackSelector {
} }
@Override @Override
public final Pair<TrackSelectionArray, Object> selectTracks(Renderer[] renderers, public final Pair<TrackSelectionArray, Object> selectTracks(
TrackGroupArray trackGroups) throws ExoPlaybackException { RendererCapabilities[] rendererCapabilities, TrackGroupArray trackGroups)
throws ExoPlaybackException {
// Structures into which data will be written during the selection. The extra item at the end // Structures into which data will be written during the selection. The extra item at the end
// of each array is to store data associated with track groups that cannot be associated with // of each array is to store data associated with track groups that cannot be associated with
// any renderer. // any renderer.
int[] rendererTrackGroupCounts = new int[renderers.length + 1]; int[] rendererTrackGroupCounts = new int[rendererCapabilities.length + 1];
TrackGroup[][] rendererTrackGroups = new TrackGroup[renderers.length + 1][]; TrackGroup[][] rendererTrackGroups = new TrackGroup[rendererCapabilities.length + 1][];
int[][][] rendererFormatSupports = new int[renderers.length + 1][][]; int[][][] rendererFormatSupports = new int[rendererCapabilities.length + 1][][];
for (int i = 0; i < rendererTrackGroups.length; i++) { for (int i = 0; i < rendererTrackGroups.length; i++) {
rendererTrackGroups[i] = new TrackGroup[trackGroups.length]; rendererTrackGroups[i] = new TrackGroup[trackGroups.length];
rendererFormatSupports[i] = new int[trackGroups.length][]; rendererFormatSupports[i] = new int[trackGroups.length][];
} }
// Determine the extent to which each renderer supports mixed mimeType adaptation. // Determine the extent to which each renderer supports mixed mimeType adaptation.
int[] mixedMimeTypeAdaptationSupport = getMixedMimeTypeAdaptationSupport(renderers); int[] mixedMimeTypeAdaptationSupport = getMixedMimeTypeAdaptationSupport(rendererCapabilities);
// Associate each track group to a preferred renderer, and evaluate the support that the // Associate each track group to a preferred renderer, and evaluate the support that the
// renderer provides for each track in the group. // renderer provides for each track in the group.
for (int groupIndex = 0; groupIndex < trackGroups.length; groupIndex++) { for (int groupIndex = 0; groupIndex < trackGroups.length; groupIndex++) {
TrackGroup group = trackGroups.get(groupIndex); TrackGroup group = trackGroups.get(groupIndex);
// Associate the group to a preferred renderer. // Associate the group to a preferred renderer.
int rendererIndex = findRenderer(renderers, group); int rendererIndex = findRenderer(rendererCapabilities, group);
// Evaluate the support that the renderer provides for each track in the group. // Evaluate the support that the renderer provides for each track in the group.
int[] rendererFormatSupport = rendererIndex == renderers.length ? new int[group.length] int[] rendererFormatSupport = rendererIndex == rendererCapabilities.length
: getFormatSupport(renderers[rendererIndex], group); ? new int[group.length] : getFormatSupport(rendererCapabilities[rendererIndex], group);
// Stash the results. // Stash the results.
int rendererTrackGroupCount = rendererTrackGroupCounts[rendererIndex]; int rendererTrackGroupCount = rendererTrackGroupCounts[rendererIndex];
rendererTrackGroups[rendererIndex][rendererTrackGroupCount] = group; rendererTrackGroups[rendererIndex][rendererTrackGroupCount] = group;
...@@ -259,8 +259,8 @@ public abstract class MappingTrackSelector extends TrackSelector { ...@@ -259,8 +259,8 @@ public abstract class MappingTrackSelector extends TrackSelector {
} }
// Create a track group array for each renderer, and trim each rendererFormatSupports entry. // Create a track group array for each renderer, and trim each rendererFormatSupports entry.
TrackGroupArray[] rendererTrackGroupArrays = new TrackGroupArray[renderers.length]; TrackGroupArray[] rendererTrackGroupArrays = new TrackGroupArray[rendererCapabilities.length];
for (int i = 0; i < renderers.length; i++) { for (int i = 0; i < rendererCapabilities.length; i++) {
int rendererTrackGroupCount = rendererTrackGroupCounts[i]; int rendererTrackGroupCount = rendererTrackGroupCounts[i];
rendererTrackGroupArrays[i] = new TrackGroupArray( rendererTrackGroupArrays[i] = new TrackGroupArray(
Arrays.copyOf(rendererTrackGroups[i], rendererTrackGroupCount)); Arrays.copyOf(rendererTrackGroups[i], rendererTrackGroupCount));
...@@ -268,15 +268,15 @@ public abstract class MappingTrackSelector extends TrackSelector { ...@@ -268,15 +268,15 @@ public abstract class MappingTrackSelector extends TrackSelector {
} }
// Create a track group array for track groups not associated with a renderer. // Create a track group array for track groups not associated with a renderer.
int unassociatedTrackGroupCount = rendererTrackGroupCounts[renderers.length]; int unassociatedTrackGroupCount = rendererTrackGroupCounts[rendererCapabilities.length];
TrackGroupArray unassociatedTrackGroupArray = new TrackGroupArray( TrackGroupArray unassociatedTrackGroupArray = new TrackGroupArray(Arrays.copyOf(
Arrays.copyOf(rendererTrackGroups[renderers.length], unassociatedTrackGroupCount)); rendererTrackGroups[rendererCapabilities.length], unassociatedTrackGroupCount));
TrackSelection[] rendererTrackSelections = selectTracks(renderers, rendererTrackGroupArrays, TrackSelection[] rendererTrackSelections = selectTracks(rendererCapabilities,
rendererFormatSupports); rendererTrackGroupArrays, rendererFormatSupports);
// Apply track disabling and overriding. // Apply track disabling and overriding.
for (int i = 0; i < renderers.length; i++) { for (int i = 0; i < rendererCapabilities.length; i++) {
if (rendererDisabledFlags.get(i)) { if (rendererDisabledFlags.get(i)) {
rendererTrackSelections[i] = null; rendererTrackSelections[i] = null;
} else { } else {
...@@ -292,8 +292,8 @@ public abstract class MappingTrackSelector extends TrackSelector { ...@@ -292,8 +292,8 @@ public abstract class MappingTrackSelector extends TrackSelector {
// The track selections above index into the track group arrays associated to each renderer, // The track selections above index into the track group arrays associated to each renderer,
// and not to the original track groups passed to this method. Build the corresponding track // and not to the original track groups passed to this method. Build the corresponding track
// selections into the original track groups to pass back as the final selection. // selections into the original track groups to pass back as the final selection.
TrackSelection[] trackSelections = new TrackSelection[renderers.length]; TrackSelection[] trackSelections = new TrackSelection[rendererCapabilities.length];
for (int i = 0; i < renderers.length; i++) { for (int i = 0; i < rendererCapabilities.length; i++) {
TrackSelection selection = rendererTrackSelections[i]; TrackSelection selection = rendererTrackSelections[i];
if (selection != null) { if (selection != null) {
TrackGroup group = rendererTrackGroupArrays[i].get(selection.group); TrackGroup group = rendererTrackGroupArrays[i].get(selection.group);
...@@ -310,17 +310,18 @@ public abstract class MappingTrackSelector extends TrackSelector { ...@@ -310,17 +310,18 @@ public abstract class MappingTrackSelector extends TrackSelector {
} }
/** /**
* Given an array of {@link Renderer}s and a set of {@link TrackGroup}s mapped to each of * Given an array of renderers and a set of {@link TrackGroup}s mapped to each of them, provides a
* them, provides a {@link TrackSelection} per renderer. * {@link TrackSelection} per renderer.
* *
* @param renderers The available {@link Renderer}s. * @param rendererCapabilities The {@link RendererCapabilities} of the renderers for which
* {@link TrackSelection}s are to be generated.
* @param rendererTrackGroupArrays An array of {@link TrackGroupArray}s where each entry * @param rendererTrackGroupArrays An array of {@link TrackGroupArray}s where each entry
* corresponds to the {@link Renderer} of equal index in {@code renderers}. * corresponds to the renderer of equal index in {@code renderers}.
* @param rendererFormatSupports Maps every available track to a specific level of support as * @param rendererFormatSupports Maps every available track to a specific level of support as
* defined by the {@link Renderer} {@code FORMAT_*} constants. * defined by the renderer {@code FORMAT_*} constants.
* @throws ExoPlaybackException If an error occurs while selecting the tracks. * @throws ExoPlaybackException If an error occurs while selecting the tracks.
*/ */
protected abstract TrackSelection[] selectTracks(Renderer[] renderers, protected abstract TrackSelection[] selectTracks(RendererCapabilities[] rendererCapabilities,
TrackGroupArray[] rendererTrackGroupArrays, int[][][] rendererFormatSupports) TrackGroupArray[] rendererTrackGroupArrays, int[][][] rendererFormatSupports)
throws ExoPlaybackException; throws ExoPlaybackException;
...@@ -328,33 +329,34 @@ public abstract class MappingTrackSelector extends TrackSelector { ...@@ -328,33 +329,34 @@ public abstract class MappingTrackSelector extends TrackSelector {
* Finds the renderer to which the provided {@link TrackGroup} should be associated. * Finds the renderer to which the provided {@link TrackGroup} should be associated.
* <p> * <p>
* A {@link TrackGroup} is associated to a renderer that reports * A {@link TrackGroup} is associated to a renderer that reports
* {@link Renderer#FORMAT_HANDLED} support for one or more of the tracks in the group, or * {@link RendererCapabilities#FORMAT_HANDLED} support for one or more of the tracks in the group,
* {@link Renderer#FORMAT_EXCEEDS_CAPABILITIES} if no such renderer exists, or * or {@link RendererCapabilities#FORMAT_EXCEEDS_CAPABILITIES} if no such renderer exists, or
* {@link Renderer#FORMAT_UNSUPPORTED_SUBTYPE} if again no such renderer exists. In the case * {@link RendererCapabilities#FORMAT_UNSUPPORTED_SUBTYPE} if again no such renderer exists. In
* that two or more renderers report the same level of support, the renderer with the lowest index * the case that two or more renderers report the same level of support, the renderer with the
* is associated. * lowest index is associated.
* <p> * <p>
* If all renderers report {@link Renderer#FORMAT_UNSUPPORTED_TYPE} for all of the tracks in * If all renderers report {@link RendererCapabilities#FORMAT_UNSUPPORTED_TYPE} for all of the
* the group, then {@code renderers.length} is returned to indicate that no association was made. * tracks in the group, then {@code renderers.length} is returned to indicate that no association
* was made.
* *
* @param renderers The renderers from which to select. * @param rendererCapabilities The {@link RendererCapabilities} of the renderers.
* @param group The {@link TrackGroup} whose associated renderer is to be found. * @param group The {@link TrackGroup} whose associated renderer is to be found.
* @return The index of the associated renderer, or {@code renderers.length} if no association * @return The index of the associated renderer, or {@code renderers.length} if no
* was made. * association was made.
* @throws ExoPlaybackException If an error occurs finding a renderer. * @throws ExoPlaybackException If an error occurs finding a renderer.
*/ */
private static int findRenderer(Renderer[] renderers, TrackGroup group) private static int findRenderer(RendererCapabilities[] rendererCapabilities, TrackGroup group)
throws ExoPlaybackException { throws ExoPlaybackException {
int bestRendererIndex = renderers.length; int bestRendererIndex = rendererCapabilities.length;
int bestSupportLevel = Renderer.FORMAT_UNSUPPORTED_TYPE; int bestSupportLevel = RendererCapabilities.FORMAT_UNSUPPORTED_TYPE;
for (int rendererIndex = 0; rendererIndex < renderers.length; rendererIndex++) { for (int rendererIndex = 0; rendererIndex < rendererCapabilities.length; rendererIndex++) {
Renderer renderer = renderers[rendererIndex]; RendererCapabilities rendererCapability = rendererCapabilities[rendererIndex];
for (int trackIndex = 0; trackIndex < group.length; trackIndex++) { for (int trackIndex = 0; trackIndex < group.length; trackIndex++) {
int trackSupportLevel = renderer.supportsFormat(group.getFormat(trackIndex)); int trackSupportLevel = rendererCapability.supportsFormat(group.getFormat(trackIndex));
if (trackSupportLevel > bestSupportLevel) { if (trackSupportLevel > bestSupportLevel) {
bestRendererIndex = rendererIndex; bestRendererIndex = rendererIndex;
bestSupportLevel = trackSupportLevel; bestSupportLevel = trackSupportLevel;
if (bestSupportLevel == Renderer.FORMAT_HANDLED) { if (bestSupportLevel == RendererCapabilities.FORMAT_HANDLED) {
// We can't do better. // We can't do better.
return bestRendererIndex; return bestRendererIndex;
} }
...@@ -365,38 +367,38 @@ public abstract class MappingTrackSelector extends TrackSelector { ...@@ -365,38 +367,38 @@ public abstract class MappingTrackSelector extends TrackSelector {
} }
/** /**
* Calls {@link Renderer#supportsFormat(Format)} for each track in the specified * Calls {@link RendererCapabilities#supportsFormat(Format)} for each track in the specified
* {@link TrackGroup}, returning the results in an array. * {@link TrackGroup}, returning the results in an array.
* *
* @param renderer The renderer to evaluate. * @param rendererCapabilities The {@link RendererCapabilities} of the renderer.
* @param group The {@link TrackGroup} to evaluate. * @param group The {@link TrackGroup} to evaluate.
* @return An array containing the result of calling {@link Renderer#supportsFormat(Format)} * @return An array containing the result of calling
* on the renderer for each track in the group. * {@link RendererCapabilities#supportsFormat(Format)} for each track in the group.
* @throws ExoPlaybackException If an error occurs determining the format support. * @throws ExoPlaybackException If an error occurs determining the format support.
*/ */
private static int[] getFormatSupport(Renderer renderer, TrackGroup group) private static int[] getFormatSupport(RendererCapabilities rendererCapabilities, TrackGroup group)
throws ExoPlaybackException { throws ExoPlaybackException {
int[] formatSupport = new int[group.length]; int[] formatSupport = new int[group.length];
for (int i = 0; i < group.length; i++) { for (int i = 0; i < group.length; i++) {
formatSupport[i] = renderer.supportsFormat(group.getFormat(i)); formatSupport[i] = rendererCapabilities.supportsFormat(group.getFormat(i));
} }
return formatSupport; return formatSupport;
} }
/** /**
* Calls {@link Renderer#supportsMixedMimeTypeAdaptation()} for each renderer, returning * Calls {@link RendererCapabilities#supportsMixedMimeTypeAdaptation()} for each renderer,
* the results in an array. * returning the results in an array.
* *
* @param renderers The renderers to evaluate. * @param rendererCapabilities The {@link RendererCapabilities} of the renderers.
* @return An array containing the result of calling * @return An array containing the result of calling
* {@link Renderer#supportsMixedMimeTypeAdaptation()} on each renderer. * {@link RendererCapabilities#supportsMixedMimeTypeAdaptation()} for each renderer.
* @throws ExoPlaybackException If an error occurs determining the adaptation support. * @throws ExoPlaybackException If an error occurs determining the adaptation support.
*/ */
private static int[] getMixedMimeTypeAdaptationSupport(Renderer[] renderers) private static int[] getMixedMimeTypeAdaptationSupport(
throws ExoPlaybackException { RendererCapabilities[] rendererCapabilities) throws ExoPlaybackException {
int[] mixedMimeTypeAdaptationSupport = new int[renderers.length]; int[] mixedMimeTypeAdaptationSupport = new int[rendererCapabilities.length];
for (int i = 0; i < mixedMimeTypeAdaptationSupport.length; i++) { for (int i = 0; i < mixedMimeTypeAdaptationSupport.length; i++) {
mixedMimeTypeAdaptationSupport[i] = renderers[i].supportsMixedMimeTypeAdaptation(); mixedMimeTypeAdaptationSupport[i] = rendererCapabilities[i].supportsMixedMimeTypeAdaptation();
} }
return mixedMimeTypeAdaptationSupport; return mixedMimeTypeAdaptationSupport;
} }
...@@ -432,7 +434,7 @@ public abstract class MappingTrackSelector extends TrackSelector { ...@@ -432,7 +434,7 @@ public abstract class MappingTrackSelector extends TrackSelector {
} }
/** /**
* Provides track information for each {@link Renderer}. * Provides track information for each renderer.
*/ */
public static final class TrackInfo { public static final class TrackInfo {
...@@ -464,9 +466,9 @@ public abstract class MappingTrackSelector extends TrackSelector { ...@@ -464,9 +466,9 @@ public abstract class MappingTrackSelector extends TrackSelector {
* @param trackGroups The {@link TrackGroupArray}s for each renderer. * @param trackGroups The {@link TrackGroupArray}s for each renderer.
* @param trackSelections The current {@link TrackSelection}s for each renderer. * @param trackSelections The current {@link TrackSelection}s for each renderer.
* @param mixedMimeTypeAdaptiveSupport The result of * @param mixedMimeTypeAdaptiveSupport The result of
* {@link Renderer#supportsMixedMimeTypeAdaptation()} for each renderer. * {@link RendererCapabilities#supportsMixedMimeTypeAdaptation()} for each renderer.
* @param formatSupport The result of {@link Renderer#supportsFormat(Format)} for each * @param formatSupport The result of {@link RendererCapabilities#supportsFormat(Format)} for
* track, indexed by renderer index, group index and track index (in that order). * each track, indexed by renderer index, group index and track index (in that order).
* @param unassociatedTrackGroups Contains {@link TrackGroup}s not associated with any renderer. * @param unassociatedTrackGroups Contains {@link TrackGroup}s not associated with any renderer.
*/ */
/* package */ TrackInfo(TrackGroupArray[] trackGroups, TrackSelection[] trackSelections, /* package */ TrackInfo(TrackGroupArray[] trackGroups, TrackSelection[] trackSelections,
...@@ -513,8 +515,8 @@ public abstract class MappingTrackSelector extends TrackSelector { ...@@ -513,8 +515,8 @@ public abstract class MappingTrackSelector extends TrackSelector {
for (int i = 0; i < rendererFormatSupport.length; i++) { for (int i = 0; i < rendererFormatSupport.length; i++) {
for (int j = 0; j < rendererFormatSupport[i].length; j++) { for (int j = 0; j < rendererFormatSupport[i].length; j++) {
hasTracks = true; hasTracks = true;
if ((rendererFormatSupport[i][j] & Renderer.FORMAT_SUPPORT_MASK) if ((rendererFormatSupport[i][j] & RendererCapabilities.FORMAT_SUPPORT_MASK)
== Renderer.FORMAT_HANDLED) { == RendererCapabilities.FORMAT_HANDLED) {
return RENDERER_SUPPORT_PLAYABLE_TRACKS; return RENDERER_SUPPORT_PLAYABLE_TRACKS;
} }
} }
...@@ -528,14 +530,14 @@ public abstract class MappingTrackSelector extends TrackSelector { ...@@ -528,14 +530,14 @@ public abstract class MappingTrackSelector extends TrackSelector {
* @param rendererIndex The renderer index. * @param rendererIndex The renderer index.
* @param groupIndex The index of the group to which the track belongs. * @param groupIndex The index of the group to which the track belongs.
* @param trackIndex The index of the track within the group. * @param trackIndex The index of the track within the group.
* @return One of {@link Renderer#FORMAT_HANDLED}, * @return One of {@link RendererCapabilities#FORMAT_HANDLED},
* {@link Renderer#FORMAT_EXCEEDS_CAPABILITIES}, * {@link RendererCapabilities#FORMAT_EXCEEDS_CAPABILITIES},
* {@link Renderer#FORMAT_UNSUPPORTED_SUBTYPE} and * {@link RendererCapabilities#FORMAT_UNSUPPORTED_SUBTYPE} and
* {@link Renderer#FORMAT_UNSUPPORTED_TYPE}. * {@link RendererCapabilities#FORMAT_UNSUPPORTED_TYPE}.
*/ */
public int getTrackFormatSupport(int rendererIndex, int groupIndex, int trackIndex) { public int getTrackFormatSupport(int rendererIndex, int groupIndex, int trackIndex) {
return formatSupport[rendererIndex][groupIndex][trackIndex] return formatSupport[rendererIndex][groupIndex][trackIndex]
& Renderer.FORMAT_SUPPORT_MASK; & RendererCapabilities.FORMAT_SUPPORT_MASK;
} }
/** /**
...@@ -543,21 +545,21 @@ public abstract class MappingTrackSelector extends TrackSelector { ...@@ -543,21 +545,21 @@ public abstract class MappingTrackSelector extends TrackSelector {
* specified {@link TrackGroup}. * specified {@link TrackGroup}.
* <p> * <p>
* Tracks for which {@link #getTrackFormatSupport(int, int, int)} returns * Tracks for which {@link #getTrackFormatSupport(int, int, int)} returns
* {@link Renderer#FORMAT_HANDLED} are always considered. * {@link RendererCapabilities#FORMAT_HANDLED} are always considered.
* Tracks for which {@link #getTrackFormatSupport(int, int, int)} returns * Tracks for which {@link #getTrackFormatSupport(int, int, int)} returns
* {@link Renderer#FORMAT_UNSUPPORTED_TYPE} or * {@link RendererCapabilities#FORMAT_UNSUPPORTED_TYPE} or
* {@link Renderer#FORMAT_UNSUPPORTED_SUBTYPE} are never considered. * {@link RendererCapabilities#FORMAT_UNSUPPORTED_SUBTYPE} are never considered.
* Tracks for which {@link #getTrackFormatSupport(int, int, int)} returns * Tracks for which {@link #getTrackFormatSupport(int, int, int)} returns
* {@link Renderer#FORMAT_EXCEEDS_CAPABILITIES} are considered only if * {@link RendererCapabilities#FORMAT_EXCEEDS_CAPABILITIES} are considered only if
* {@code includeCapabilitiesExceededTracks} is set to {@code true}. * {@code includeCapabilitiesExceededTracks} is set to {@code true}.
* *
* @param rendererIndex The renderer index. * @param rendererIndex The renderer index.
* @param groupIndex The index of the group. * @param groupIndex The index of the group.
* @param includeCapabilitiesExceededTracks True if formats that exceed the capabilities of the * @param includeCapabilitiesExceededTracks True if formats that exceed the capabilities of the
* renderer should be included when determining support. False otherwise. * renderer should be included when determining support. False otherwise.
* @return One of {@link Renderer#ADAPTIVE_SEAMLESS}, * @return One of {@link RendererCapabilities#ADAPTIVE_SEAMLESS},
* {@link Renderer#ADAPTIVE_NOT_SEAMLESS} and * {@link RendererCapabilities#ADAPTIVE_NOT_SEAMLESS} and
* {@link Renderer#ADAPTIVE_NOT_SUPPORTED}. * {@link RendererCapabilities#ADAPTIVE_NOT_SUPPORTED}.
*/ */
public int getAdaptiveSupport(int rendererIndex, int groupIndex, public int getAdaptiveSupport(int rendererIndex, int groupIndex,
boolean includeCapabilitiesExceededTracks) { boolean includeCapabilitiesExceededTracks) {
...@@ -567,8 +569,9 @@ public abstract class MappingTrackSelector extends TrackSelector { ...@@ -567,8 +569,9 @@ public abstract class MappingTrackSelector extends TrackSelector {
int trackIndexCount = 0; int trackIndexCount = 0;
for (int i = 0; i < trackCount; i++) { for (int i = 0; i < trackCount; i++) {
int fixedSupport = getTrackFormatSupport(rendererIndex, groupIndex, i); int fixedSupport = getTrackFormatSupport(rendererIndex, groupIndex, i);
if (fixedSupport == Renderer.FORMAT_HANDLED || (includeCapabilitiesExceededTracks if (fixedSupport == RendererCapabilities.FORMAT_HANDLED
&& fixedSupport == Renderer.FORMAT_EXCEEDS_CAPABILITIES)) { || (includeCapabilitiesExceededTracks
&& fixedSupport == RendererCapabilities.FORMAT_EXCEEDS_CAPABILITIES)) {
trackIndices[trackIndexCount++] = i; trackIndices[trackIndexCount++] = i;
} }
} }
...@@ -582,17 +585,17 @@ public abstract class MappingTrackSelector extends TrackSelector { ...@@ -582,17 +585,17 @@ public abstract class MappingTrackSelector extends TrackSelector {
* *
* @param rendererIndex The renderer index. * @param rendererIndex The renderer index.
* @param groupIndex The index of the group. * @param groupIndex The index of the group.
* @return One of {@link Renderer#ADAPTIVE_SEAMLESS}, * @return One of {@link RendererCapabilities#ADAPTIVE_SEAMLESS},
* {@link Renderer#ADAPTIVE_NOT_SEAMLESS} and * {@link RendererCapabilities#ADAPTIVE_NOT_SEAMLESS} and
* {@link Renderer#ADAPTIVE_NOT_SUPPORTED}. * {@link RendererCapabilities#ADAPTIVE_NOT_SUPPORTED}.
*/ */
public int getAdaptiveSupport(int rendererIndex, int groupIndex, int[] trackIndices) { public int getAdaptiveSupport(int rendererIndex, int groupIndex, int[] trackIndices) {
TrackGroup trackGroup = trackGroups[rendererIndex].get(groupIndex); TrackGroup trackGroup = trackGroups[rendererIndex].get(groupIndex);
if (!trackGroup.adaptive) { if (!trackGroup.adaptive) {
return Renderer.ADAPTIVE_NOT_SUPPORTED; return RendererCapabilities.ADAPTIVE_NOT_SUPPORTED;
} }
int handledTrackCount = 0; int handledTrackCount = 0;
int adaptiveSupport = Renderer.ADAPTIVE_SEAMLESS; int adaptiveSupport = RendererCapabilities.ADAPTIVE_SEAMLESS;
boolean multipleMimeTypes = false; boolean multipleMimeTypes = false;
String firstSampleMimeType = null; String firstSampleMimeType = null;
for (int i = 0; i < trackIndices.length; i++) { for (int i = 0; i < trackIndices.length; i++) {
...@@ -604,8 +607,8 @@ public abstract class MappingTrackSelector extends TrackSelector { ...@@ -604,8 +607,8 @@ public abstract class MappingTrackSelector extends TrackSelector {
} else { } else {
multipleMimeTypes |= !Util.areEqual(firstSampleMimeType, sampleMimeType); multipleMimeTypes |= !Util.areEqual(firstSampleMimeType, sampleMimeType);
} }
adaptiveSupport = Math.min(adaptiveSupport, adaptiveSupport = Math.min(adaptiveSupport, formatSupport[rendererIndex][groupIndex][i]
formatSupport[rendererIndex][groupIndex][i] & Renderer.ADAPTIVE_SUPPORT_MASK); & RendererCapabilities.ADAPTIVE_SUPPORT_MASK);
} }
return multipleMimeTypes return multipleMimeTypes
? Math.min(adaptiveSupport, mixedMimeTypeAdaptiveSupport[rendererIndex]) ? Math.min(adaptiveSupport, mixedMimeTypeAdaptiveSupport[rendererIndex])
...@@ -613,9 +616,9 @@ public abstract class MappingTrackSelector extends TrackSelector { ...@@ -613,9 +616,9 @@ public abstract class MappingTrackSelector extends TrackSelector {
} }
/** /**
* Gets the {@link TrackGroup}s not associated with any {@link Renderer}. * Gets the {@link TrackGroup}s not associated with any renderer.
* *
* @return The {@link TrackGroup}s not associated with any {@link Renderer}. * @return The {@link TrackGroup}s not associated with any renderer.
*/ */
public TrackGroupArray getUnassociatedTrackGroups() { public TrackGroupArray getUnassociatedTrackGroups() {
return unassociatedTrackGroups; return unassociatedTrackGroups;
......
...@@ -16,13 +16,13 @@ ...@@ -16,13 +16,13 @@
package com.google.android.exoplayer2.trackselection; package com.google.android.exoplayer2.trackselection;
import com.google.android.exoplayer2.ExoPlaybackException; import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.Renderer; import com.google.android.exoplayer2.RendererCapabilities;
import com.google.android.exoplayer2.source.TrackGroupArray; import com.google.android.exoplayer2.source.TrackGroupArray;
import android.util.Pair; import android.util.Pair;
/** /**
* Selects tracks to be consumed by available {@link Renderer}s. * Selects tracks to be consumed by available renderers.
*/ */
public abstract class TrackSelector { public abstract class TrackSelector {
...@@ -56,19 +56,21 @@ public abstract class TrackSelector { ...@@ -56,19 +56,21 @@ public abstract class TrackSelector {
* that the selector wishes to receive in an invocation of {@link #onSelectionActivated(Object)} * that the selector wishes to receive in an invocation of {@link #onSelectionActivated(Object)}
* should the selection be activated. * should the selection be activated.
* *
* @param renderers The renderers. * @param rendererCapabilities The {@link RendererCapabilities} of the renderers for which
* {@link TrackSelection}s are to be generated.
* @param trackGroups The available track groups. * @param trackGroups The available track groups.
* @return A {@link TrackSelectionArray} containing a {@link TrackSelection} for each renderer, * @return A {@link TrackSelectionArray} containing a {@link TrackSelection} for each renderer,
* together with an opaque object that will be passed to {@link #onSelectionActivated(Object)} * together with an opaque object that will be passed to {@link #onSelectionActivated(Object)}
* if the selection is activated. * if the selection is activated.
* @throws ExoPlaybackException If an error occurs selecting tracks. * @throws ExoPlaybackException If an error occurs selecting tracks.
*/ */
public abstract Pair<TrackSelectionArray, Object> selectTracks(Renderer[] renderers, public abstract Pair<TrackSelectionArray, Object> selectTracks(
TrackGroupArray trackGroups) throws ExoPlaybackException; RendererCapabilities[] rendererCapabilities, TrackGroupArray trackGroups)
throws ExoPlaybackException;
/** /**
* Invoked when a selection previously generated by * Invoked when a selection previously generated by
* {@link #selectTracks(Renderer[], TrackGroupArray)} is activated. * {@link #selectTracks(RendererCapabilities[], TrackGroupArray)} is activated.
* *
* @param selectionInfo The opaque object associated with the selection. * @param selectionInfo The opaque object associated with the selection.
*/ */
......
...@@ -19,6 +19,7 @@ import com.google.android.exoplayer2.C; ...@@ -19,6 +19,7 @@ import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlaybackException; import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.Renderer; import com.google.android.exoplayer2.Renderer;
import com.google.android.exoplayer2.RendererCapabilities;
import com.google.android.exoplayer2.decoder.DecoderCounters; import com.google.android.exoplayer2.decoder.DecoderCounters;
import com.google.android.exoplayer2.mediacodec.MediaCodecInfo; import com.google.android.exoplayer2.mediacodec.MediaCodecInfo;
import com.google.android.exoplayer2.mediacodec.MediaCodecUtil; import com.google.android.exoplayer2.mediacodec.MediaCodecUtil;
...@@ -44,7 +45,6 @@ import android.annotation.TargetApi; ...@@ -44,7 +45,6 @@ import android.annotation.TargetApi;
import android.net.Uri; import android.net.Uri;
import android.test.ActivityInstrumentationTestCase2; import android.test.ActivityInstrumentationTestCase2;
import android.util.Log; import android.util.Log;
import junit.framework.AssertionFailedError; import junit.framework.AssertionFailedError;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -492,14 +492,16 @@ public final class DashTest extends ActivityInstrumentationTestCase2<HostActivit ...@@ -492,14 +492,16 @@ public final class DashTest extends ActivityInstrumentationTestCase2<HostActivit
} }
@Override @Override
protected TrackSelection[] selectTracks(Renderer[] renderers, protected TrackSelection[] selectTracks(RendererCapabilities[] rendererCapabilities,
TrackGroupArray[] rendererTrackGroupArrays, int[][][] rendererFormatSupports) TrackGroupArray[] rendererTrackGroupArrays, int[][][] rendererFormatSupports)
throws ExoPlaybackException { throws ExoPlaybackException {
Assertions.checkState(renderers[VIDEO_RENDERER_INDEX].getTrackType() == C.TRACK_TYPE_VIDEO); Assertions.checkState(rendererCapabilities[VIDEO_RENDERER_INDEX].getTrackType()
Assertions.checkState(renderers[AUDIO_RENDERER_INDEX].getTrackType() == C.TRACK_TYPE_AUDIO); == C.TRACK_TYPE_VIDEO);
Assertions.checkState(rendererCapabilities[AUDIO_RENDERER_INDEX].getTrackType()
== C.TRACK_TYPE_AUDIO);
Assertions.checkState(rendererTrackGroupArrays[VIDEO_RENDERER_INDEX].length == 1); Assertions.checkState(rendererTrackGroupArrays[VIDEO_RENDERER_INDEX].length == 1);
Assertions.checkState(rendererTrackGroupArrays[AUDIO_RENDERER_INDEX].length == 1); Assertions.checkState(rendererTrackGroupArrays[AUDIO_RENDERER_INDEX].length == 1);
TrackSelection[] selections = new TrackSelection[renderers.length]; TrackSelection[] selections = new TrackSelection[rendererCapabilities.length];
selections[VIDEO_RENDERER_INDEX] = new TrackSelection(0, selections[VIDEO_RENDERER_INDEX] = new TrackSelection(0,
getTrackIndices(rendererTrackGroupArrays[VIDEO_RENDERER_INDEX].get(0), getTrackIndices(rendererTrackGroupArrays[VIDEO_RENDERER_INDEX].get(0),
rendererFormatSupports[VIDEO_RENDERER_INDEX][0], videoFormatIds, rendererFormatSupports[VIDEO_RENDERER_INDEX][0], videoFormatIds,
......
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