mirror of
https://github.com/samsonjs/media.git
synced 2026-04-02 10:45:51 +00:00
Sanitize MappedTrackInfo API
Issue: #3915 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=193897041
This commit is contained in:
parent
c116391fe2
commit
d3cdf52591
13 changed files with 266 additions and 195 deletions
|
|
@ -711,11 +711,11 @@ public class PlayerActivity extends Activity
|
|||
if (trackGroups != lastSeenTrackGroupArray) {
|
||||
MappedTrackInfo mappedTrackInfo = trackSelector.getCurrentMappedTrackInfo();
|
||||
if (mappedTrackInfo != null) {
|
||||
if (mappedTrackInfo.getTrackTypeRendererSupport(C.TRACK_TYPE_VIDEO)
|
||||
if (mappedTrackInfo.getTypeSupport(C.TRACK_TYPE_VIDEO)
|
||||
== MappedTrackInfo.RENDERER_SUPPORT_UNSUPPORTED_TRACKS) {
|
||||
showToast(R.string.error_unsupported_video);
|
||||
}
|
||||
if (mappedTrackInfo.getTrackTypeRendererSupport(C.TRACK_TYPE_AUDIO)
|
||||
if (mappedTrackInfo.getTypeSupport(C.TRACK_TYPE_AUDIO)
|
||||
== MappedTrackInfo.RENDERER_SUPPORT_UNSUPPORTED_TRACKS) {
|
||||
showToast(R.string.error_unsupported_audio);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ import java.util.Arrays;
|
|||
trackViewLayoutId, root, false);
|
||||
trackView.setBackgroundResource(selectableItemBackgroundResourceId);
|
||||
trackView.setText(DemoUtil.buildTrackName(group.getFormat(trackIndex)));
|
||||
if (trackInfo.getTrackFormatSupport(rendererIndex, groupIndex, trackIndex)
|
||||
if (trackInfo.getTrackSupport(rendererIndex, groupIndex, trackIndex)
|
||||
== RendererCapabilities.FORMAT_HANDLED) {
|
||||
trackView.setFocusable(true);
|
||||
trackView.setTag(Pair.create(groupIndex, trackIndex));
|
||||
|
|
|
|||
|
|
@ -931,11 +931,14 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
|||
|
||||
@Override
|
||||
protected final Pair<RendererConfiguration[], TrackSelection[]> selectTracks(
|
||||
RendererCapabilities[] rendererCapabilities, MappedTrackInfo mappedTrackInfo)
|
||||
MappedTrackInfo mappedTrackInfo,
|
||||
int[][][] rendererFormatSupports,
|
||||
int[] rendererMixedMimeTypeAdaptationSupports)
|
||||
throws ExoPlaybackException {
|
||||
int rendererCount = rendererCapabilities.length;
|
||||
int rendererCount = mappedTrackInfo.getRendererCount();
|
||||
TrackSelection[] rendererTrackSelections =
|
||||
selectAllTracks(rendererCapabilities, mappedTrackInfo);
|
||||
selectAllTracks(
|
||||
mappedTrackInfo, rendererFormatSupports, rendererMixedMimeTypeAdaptationSupports);
|
||||
|
||||
// Apply track disabling and overriding.
|
||||
for (int i = 0; i < rendererCount; i++) {
|
||||
|
|
@ -962,13 +965,12 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
|||
|
||||
// Initialize the renderer configurations to the default configuration for all renderers with
|
||||
// selections, and null otherwise.
|
||||
RendererConfiguration[] rendererConfigurations =
|
||||
new RendererConfiguration[rendererCapabilities.length];
|
||||
RendererConfiguration[] rendererConfigurations = new RendererConfiguration[rendererCount];
|
||||
for (int i = 0; i < rendererCount; i++) {
|
||||
boolean forceRendererDisabled = rendererDisabledFlags.get(i);
|
||||
boolean rendererEnabled =
|
||||
!forceRendererDisabled
|
||||
&& (rendererCapabilities[i].getTrackType() == C.TRACK_TYPE_NONE
|
||||
&& (mappedTrackInfo.getRendererType(i) == C.TRACK_TYPE_NONE
|
||||
|| rendererTrackSelections[i] != null);
|
||||
rendererConfigurations[i] = rendererEnabled ? RendererConfiguration.DEFAULT : null;
|
||||
}
|
||||
|
|
@ -976,7 +978,7 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
|||
// Configure audio and video renderers to use tunneling if appropriate.
|
||||
maybeConfigureRenderersForTunneling(
|
||||
mappedTrackInfo,
|
||||
rendererCapabilities,
|
||||
rendererFormatSupports,
|
||||
rendererConfigurations,
|
||||
rendererTrackSelections,
|
||||
tunnelingAudioSessionId);
|
||||
|
|
@ -987,35 +989,40 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
|||
// Track selection prior to overrides and disabled flags being applied.
|
||||
|
||||
/**
|
||||
* Called from {@link #selectTracks(RendererCapabilities[], MappedTrackInfo)} to make a track
|
||||
* selection for each renderer, prior to overrides and disabled flags being applied.
|
||||
* Called from {@link #selectTracks(MappedTrackInfo, int[][][], int[])} to make a track selection
|
||||
* for each renderer, prior to overrides and disabled flags being applied.
|
||||
*
|
||||
* <p>The implementation should not account for overrides and disabled flags. Track selections
|
||||
* generated by this method will be overridden to account for these properties.
|
||||
*
|
||||
* @param rendererCapabilities The {@link RendererCapabilities} of each renderer.
|
||||
* @param mappedTrackInfo Mapped track information.
|
||||
* @param rendererFormatSupports The result of {@link RendererCapabilities#supportsFormat} for
|
||||
* each mapped track, indexed by renderer, track group and track (in that order).
|
||||
* @param rendererMixedMimeTypeAdaptationSupports The result of {@link
|
||||
* RendererCapabilities#supportsMixedMimeTypeAdaptation()} for each renderer.
|
||||
* @return Track selections for each renderer. A null selection indicates the renderer should be
|
||||
* disabled, unless RendererCapabilities#getTrackType()} is {@link C#TRACK_TYPE_NONE}.
|
||||
* @throws ExoPlaybackException If an error occurs while selecting the tracks.
|
||||
*/
|
||||
protected TrackSelection[] selectAllTracks(
|
||||
RendererCapabilities[] rendererCapabilities, MappedTrackInfo mappedTrackInfo)
|
||||
MappedTrackInfo mappedTrackInfo,
|
||||
int[][][] rendererFormatSupports,
|
||||
int[] rendererMixedMimeTypeAdaptationSupports)
|
||||
throws ExoPlaybackException {
|
||||
int rendererCount = rendererCapabilities.length;
|
||||
int rendererCount = mappedTrackInfo.getRendererCount();
|
||||
TrackSelection[] rendererTrackSelections = new TrackSelection[rendererCount];
|
||||
Parameters params = paramsReference.get();
|
||||
|
||||
boolean seenVideoRendererWithMappedTracks = false;
|
||||
boolean selectedVideoTracks = false;
|
||||
for (int i = 0; i < rendererCount; i++) {
|
||||
if (C.TRACK_TYPE_VIDEO == rendererCapabilities[i].getTrackType()) {
|
||||
if (C.TRACK_TYPE_VIDEO == mappedTrackInfo.getRendererType(i)) {
|
||||
if (!selectedVideoTracks) {
|
||||
rendererTrackSelections[i] =
|
||||
selectVideoTrack(
|
||||
rendererCapabilities[i],
|
||||
mappedTrackInfo.getTrackGroups(i),
|
||||
mappedTrackInfo.getRendererTrackSupport(i),
|
||||
rendererFormatSupports[i],
|
||||
rendererMixedMimeTypeAdaptationSupports[i],
|
||||
params,
|
||||
adaptiveTrackSelectionFactory);
|
||||
selectedVideoTracks = rendererTrackSelections[i] != null;
|
||||
|
|
@ -1027,7 +1034,8 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
|||
boolean selectedAudioTracks = false;
|
||||
boolean selectedTextTracks = false;
|
||||
for (int i = 0; i < rendererCount; i++) {
|
||||
switch (rendererCapabilities[i].getTrackType()) {
|
||||
int trackType = mappedTrackInfo.getRendererType(i);
|
||||
switch (trackType) {
|
||||
case C.TRACK_TYPE_VIDEO:
|
||||
// Already done. Do nothing.
|
||||
break;
|
||||
|
|
@ -1036,7 +1044,8 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
|||
rendererTrackSelections[i] =
|
||||
selectAudioTrack(
|
||||
mappedTrackInfo.getTrackGroups(i),
|
||||
mappedTrackInfo.getRendererTrackSupport(i),
|
||||
rendererFormatSupports[i],
|
||||
rendererMixedMimeTypeAdaptationSupports[i],
|
||||
params,
|
||||
seenVideoRendererWithMappedTracks ? null : adaptiveTrackSelectionFactory);
|
||||
selectedAudioTracks = rendererTrackSelections[i] != null;
|
||||
|
|
@ -1046,19 +1055,14 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
|||
if (!selectedTextTracks) {
|
||||
rendererTrackSelections[i] =
|
||||
selectTextTrack(
|
||||
mappedTrackInfo.getTrackGroups(i),
|
||||
mappedTrackInfo.getRendererTrackSupport(i),
|
||||
params);
|
||||
mappedTrackInfo.getTrackGroups(i), rendererFormatSupports[i], params);
|
||||
selectedTextTracks = rendererTrackSelections[i] != null;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
rendererTrackSelections[i] =
|
||||
selectOtherTrack(
|
||||
rendererCapabilities[i].getTrackType(),
|
||||
mappedTrackInfo.getTrackGroups(i),
|
||||
mappedTrackInfo.getRendererTrackSupport(i),
|
||||
params);
|
||||
trackType, mappedTrackInfo.getTrackGroups(i), rendererFormatSupports[i], params);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -1069,13 +1073,14 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
|||
// Video track selection implementation.
|
||||
|
||||
/**
|
||||
* Called by {@link #selectTracks(RendererCapabilities[], MappedTrackInfo)} to create a {@link
|
||||
* Called by {@link #selectAllTracks(MappedTrackInfo, int[][][], int[])} to create a {@link
|
||||
* TrackSelection} for a video renderer.
|
||||
*
|
||||
* @param rendererCapabilities The {@link RendererCapabilities} for the renderer.
|
||||
* @param groups The {@link TrackGroupArray} mapped to the renderer.
|
||||
* @param formatSupport The result of {@link RendererCapabilities#supportsFormat} for each mapped
|
||||
* @param formatSupports The result of {@link RendererCapabilities#supportsFormat} for each mapped
|
||||
* track, indexed by track group index and track index (in that order).
|
||||
* @param mixedMimeTypeAdaptationSupports The result of {@link
|
||||
* RendererCapabilities#supportsMixedMimeTypeAdaptation()} for the renderer.
|
||||
* @param params The selector's current constraint parameters.
|
||||
* @param adaptiveTrackSelectionFactory A factory for generating adaptive track selections, or
|
||||
* null if a fixed track selection is required.
|
||||
|
|
@ -1083,31 +1088,41 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
|||
* @throws ExoPlaybackException If an error occurs while selecting the tracks.
|
||||
*/
|
||||
protected TrackSelection selectVideoTrack(
|
||||
RendererCapabilities rendererCapabilities,
|
||||
TrackGroupArray groups,
|
||||
int[][] formatSupport,
|
||||
int[][] formatSupports,
|
||||
int mixedMimeTypeAdaptationSupports,
|
||||
Parameters params,
|
||||
TrackSelection.Factory adaptiveTrackSelectionFactory)
|
||||
throws ExoPlaybackException {
|
||||
TrackSelection selection = null;
|
||||
if (!params.forceLowestBitrate && adaptiveTrackSelectionFactory != null) {
|
||||
selection = selectAdaptiveVideoTrack(rendererCapabilities, groups, formatSupport,
|
||||
params, adaptiveTrackSelectionFactory);
|
||||
selection =
|
||||
selectAdaptiveVideoTrack(
|
||||
groups,
|
||||
formatSupports,
|
||||
mixedMimeTypeAdaptationSupports,
|
||||
params,
|
||||
adaptiveTrackSelectionFactory);
|
||||
}
|
||||
if (selection == null) {
|
||||
selection = selectFixedVideoTrack(groups, formatSupport, params);
|
||||
selection = selectFixedVideoTrack(groups, formatSupports, params);
|
||||
}
|
||||
return selection;
|
||||
}
|
||||
|
||||
private static TrackSelection selectAdaptiveVideoTrack(RendererCapabilities rendererCapabilities,
|
||||
TrackGroupArray groups, int[][] formatSupport, Parameters params,
|
||||
TrackSelection.Factory adaptiveTrackSelectionFactory) throws ExoPlaybackException {
|
||||
private static TrackSelection selectAdaptiveVideoTrack(
|
||||
TrackGroupArray groups,
|
||||
int[][] formatSupport,
|
||||
int mixedMimeTypeAdaptationSupports,
|
||||
Parameters params,
|
||||
TrackSelection.Factory adaptiveTrackSelectionFactory)
|
||||
throws ExoPlaybackException {
|
||||
int requiredAdaptiveSupport = params.allowNonSeamlessAdaptiveness
|
||||
? (RendererCapabilities.ADAPTIVE_NOT_SEAMLESS | RendererCapabilities.ADAPTIVE_SEAMLESS)
|
||||
: RendererCapabilities.ADAPTIVE_SEAMLESS;
|
||||
boolean allowMixedMimeTypes = params.allowMixedMimeAdaptiveness
|
||||
&& (rendererCapabilities.supportsMixedMimeTypeAdaptation() & requiredAdaptiveSupport) != 0;
|
||||
boolean allowMixedMimeTypes =
|
||||
params.allowMixedMimeAdaptiveness
|
||||
&& (mixedMimeTypeAdaptationSupports & requiredAdaptiveSupport) != 0;
|
||||
for (int i = 0; i < groups.length; i++) {
|
||||
TrackGroup group = groups.get(i);
|
||||
int[] adaptiveTracks = getAdaptiveVideoTracksForGroup(group, formatSupport[i],
|
||||
|
|
@ -1200,8 +1215,8 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
|||
&& (format.bitrate == Format.NO_VALUE || format.bitrate <= maxVideoBitrate);
|
||||
}
|
||||
|
||||
private static TrackSelection selectFixedVideoTrack(TrackGroupArray groups,
|
||||
int[][] formatSupport, Parameters params) {
|
||||
private static TrackSelection selectFixedVideoTrack(
|
||||
TrackGroupArray groups, int[][] formatSupports, Parameters params) {
|
||||
TrackGroup selectedGroup = null;
|
||||
int selectedTrackIndex = 0;
|
||||
int selectedTrackScore = 0;
|
||||
|
|
@ -1211,7 +1226,7 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
|||
TrackGroup trackGroup = groups.get(groupIndex);
|
||||
List<Integer> selectedTrackIndices = getViewportFilteredTrackIndices(trackGroup,
|
||||
params.viewportWidth, params.viewportHeight, params.viewportOrientationMayChange);
|
||||
int[] trackFormatSupport = formatSupport[groupIndex];
|
||||
int[] trackFormatSupport = formatSupports[groupIndex];
|
||||
for (int trackIndex = 0; trackIndex < trackGroup.length; trackIndex++) {
|
||||
if (isSupported(trackFormatSupport[trackIndex],
|
||||
params.exceedRendererCapabilitiesIfNecessary)) {
|
||||
|
|
@ -1264,12 +1279,14 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
|||
// Audio track selection implementation.
|
||||
|
||||
/**
|
||||
* Called by {@link #selectTracks(RendererCapabilities[], MappedTrackInfo)} to create a {@link
|
||||
* Called by {@link #selectAllTracks(MappedTrackInfo, int[][][], int[])} to create a {@link
|
||||
* TrackSelection} for an audio renderer.
|
||||
*
|
||||
* @param groups The {@link TrackGroupArray} mapped to the renderer.
|
||||
* @param formatSupport The result of {@link RendererCapabilities#supportsFormat} for each mapped
|
||||
* @param formatSupports The result of {@link RendererCapabilities#supportsFormat} for each mapped
|
||||
* track, indexed by track group index and track index (in that order).
|
||||
* @param mixedMimeTypeAdaptationSupports The result of {@link
|
||||
* RendererCapabilities#supportsMixedMimeTypeAdaptation()} for the renderer.
|
||||
* @param params The selector's current constraint parameters.
|
||||
* @param adaptiveTrackSelectionFactory A factory for generating adaptive track selections, or
|
||||
* null if a fixed track selection is required.
|
||||
|
|
@ -1278,7 +1295,8 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
|||
*/
|
||||
protected TrackSelection selectAudioTrack(
|
||||
TrackGroupArray groups,
|
||||
int[][] formatSupport,
|
||||
int[][] formatSupports,
|
||||
int mixedMimeTypeAdaptationSupports,
|
||||
Parameters params,
|
||||
TrackSelection.Factory adaptiveTrackSelectionFactory)
|
||||
throws ExoPlaybackException {
|
||||
|
|
@ -1287,7 +1305,7 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
|||
AudioTrackScore selectedTrackScore = null;
|
||||
for (int groupIndex = 0; groupIndex < groups.length; groupIndex++) {
|
||||
TrackGroup trackGroup = groups.get(groupIndex);
|
||||
int[] trackFormatSupport = formatSupport[groupIndex];
|
||||
int[] trackFormatSupport = formatSupports[groupIndex];
|
||||
for (int trackIndex = 0; trackIndex < trackGroup.length; trackIndex++) {
|
||||
if (isSupported(trackFormatSupport[trackIndex],
|
||||
params.exceedRendererCapabilitiesIfNecessary)) {
|
||||
|
|
@ -1310,8 +1328,9 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
|||
TrackGroup selectedGroup = groups.get(selectedGroupIndex);
|
||||
if (!params.forceLowestBitrate && adaptiveTrackSelectionFactory != null) {
|
||||
// If the group of the track with the highest score allows it, try to enable adaptation.
|
||||
int[] adaptiveTracks = getAdaptiveAudioTracks(selectedGroup,
|
||||
formatSupport[selectedGroupIndex], params.allowMixedMimeAdaptiveness);
|
||||
int[] adaptiveTracks =
|
||||
getAdaptiveAudioTracks(
|
||||
selectedGroup, formatSupports[selectedGroupIndex], params.allowMixedMimeAdaptiveness);
|
||||
if (adaptiveTracks.length > 0) {
|
||||
return adaptiveTrackSelectionFactory.createTrackSelection(selectedGroup,
|
||||
adaptiveTracks);
|
||||
|
|
@ -1375,7 +1394,7 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
|||
// Text track selection implementation.
|
||||
|
||||
/**
|
||||
* Called by {@link #selectTracks(RendererCapabilities[], MappedTrackInfo)} to create a {@link
|
||||
* Called by {@link #selectAllTracks(MappedTrackInfo, int[][][], int[])} to create a {@link
|
||||
* TrackSelection} for a text renderer.
|
||||
*
|
||||
* @param groups The {@link TrackGroupArray} mapped to the renderer.
|
||||
|
|
@ -1447,7 +1466,7 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
|||
// General track selection methods.
|
||||
|
||||
/**
|
||||
* Called by {@link #selectTracks(RendererCapabilities[], MappedTrackInfo)} to create a {@link
|
||||
* Called by {@link #selectAllTracks(MappedTrackInfo, int[][][], int[])} to create a {@link
|
||||
* TrackSelection} for a renderer whose type is neither video, audio or text.
|
||||
*
|
||||
* @param trackType The type of the renderer.
|
||||
|
|
@ -1495,8 +1514,7 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
|||
* {@code rendererConfigurations} with configurations that enable tunneling on the appropriate
|
||||
* renderers if so.
|
||||
*
|
||||
* @param rendererCapabilities The {@link RendererCapabilities} of the renderers for which {@link
|
||||
* TrackSelection}s are to be generated.
|
||||
* @param mappedTrackInfo Mapped track information.
|
||||
* @param rendererConfigurations The renderer configurations. Configurations may be replaced with
|
||||
* ones that enable tunneling as a result of this call.
|
||||
* @param trackSelections The renderer track selections.
|
||||
|
|
@ -1505,7 +1523,7 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
|||
*/
|
||||
private static void maybeConfigureRenderersForTunneling(
|
||||
MappedTrackInfo mappedTrackInfo,
|
||||
RendererCapabilities[] rendererCapabilities,
|
||||
int[][][] renderererFormatSupports,
|
||||
RendererConfiguration[] rendererConfigurations,
|
||||
TrackSelection[] trackSelections,
|
||||
int tunnelingAudioSessionId) {
|
||||
|
|
@ -1517,15 +1535,13 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
|||
int tunnelingAudioRendererIndex = -1;
|
||||
int tunnelingVideoRendererIndex = -1;
|
||||
boolean enableTunneling = true;
|
||||
for (int i = 0; i < rendererCapabilities.length; i++) {
|
||||
int rendererType = rendererCapabilities[i].getTrackType();
|
||||
for (int i = 0; i < mappedTrackInfo.getRendererCount(); i++) {
|
||||
int rendererType = mappedTrackInfo.getRendererType(i);
|
||||
TrackSelection trackSelection = trackSelections[i];
|
||||
if ((rendererType == C.TRACK_TYPE_AUDIO || rendererType == C.TRACK_TYPE_VIDEO)
|
||||
&& trackSelection != null) {
|
||||
if (rendererSupportsTunneling(
|
||||
mappedTrackInfo.getRendererTrackSupport(i),
|
||||
mappedTrackInfo.getTrackGroups(i),
|
||||
trackSelection)) {
|
||||
renderererFormatSupports[i], mappedTrackInfo.getTrackGroups(i), trackSelection)) {
|
||||
if (rendererType == C.TRACK_TYPE_AUDIO) {
|
||||
if (tunnelingAudioRendererIndex != -1) {
|
||||
enableTunneling = false;
|
||||
|
|
@ -1556,20 +1572,20 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
|||
/**
|
||||
* Returns whether a renderer supports tunneling for a {@link TrackSelection}.
|
||||
*
|
||||
* @param formatSupport The result of {@link RendererCapabilities#supportsFormat} for each track,
|
||||
* @param formatSupports The result of {@link RendererCapabilities#supportsFormat} for each track,
|
||||
* indexed by group index and track index (in that order).
|
||||
* @param trackGroups The {@link TrackGroupArray}s for the renderer.
|
||||
* @param selection The track selection.
|
||||
* @return Whether the renderer supports tunneling for the {@link TrackSelection}.
|
||||
*/
|
||||
private static boolean rendererSupportsTunneling(
|
||||
int[][] formatSupport, TrackGroupArray trackGroups, TrackSelection selection) {
|
||||
int[][] formatSupports, TrackGroupArray trackGroups, TrackSelection selection) {
|
||||
if (selection == null) {
|
||||
return false;
|
||||
}
|
||||
int trackGroupIndex = trackGroups.indexOf(selection.getTrackGroup());
|
||||
for (int i = 0; i < selection.length(); i++) {
|
||||
int trackFormatSupport = formatSupport[trackGroupIndex][selection.getIndexInTrackGroup(i)];
|
||||
int trackFormatSupport = formatSupports[trackGroupIndex][selection.getIndexInTrackGroup(i)];
|
||||
if ((trackFormatSupport & RendererCapabilities.TUNNELING_SUPPORT_MASK)
|
||||
!= RendererCapabilities.TUNNELING_SUPPORTED) {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -52,46 +52,76 @@ public abstract class MappingTrackSelector extends TrackSelector {
|
|||
@interface RendererSupport {}
|
||||
/** The renderer does not have any associated tracks. */
|
||||
public static final int RENDERER_SUPPORT_NO_TRACKS = 0;
|
||||
/** The renderer has associated tracks, but all are of unsupported types. */
|
||||
/**
|
||||
* The renderer has tracks mapped to it, but all are unsupported. In other words, {@link
|
||||
* #getTrackSupport(int, int, int)} returns {@link RendererCapabilities#FORMAT_UNSUPPORTED_DRM},
|
||||
* {@link RendererCapabilities#FORMAT_UNSUPPORTED_SUBTYPE} or {@link
|
||||
* RendererCapabilities#FORMAT_UNSUPPORTED_TYPE} for all tracks mapped to the renderer.
|
||||
*/
|
||||
public static final int RENDERER_SUPPORT_UNSUPPORTED_TRACKS = 1;
|
||||
/**
|
||||
* The renderer has associated tracks and at least one is of a supported type, but all of the
|
||||
* tracks whose types are supported exceed the renderer's capabilities.
|
||||
* The renderer has tracks mapped to it and at least one is of a supported type, but all such
|
||||
* tracks exceed the renderer's capabilities. In other words, {@link #getTrackSupport(int, int,
|
||||
* int)} returns {@link RendererCapabilities##FORMAT_EXCEEDS_CAPABILITIES} for at least one
|
||||
* track mapped to the renderer, but does not return {@link
|
||||
* RendererCapabilities##FORMAT_HANDLED} for any tracks mapped to the renderer.
|
||||
*/
|
||||
public static final int RENDERER_SUPPORT_EXCEEDS_CAPABILITIES_TRACKS = 2;
|
||||
/** The renderer has associated tracks and can play at least one of them. */
|
||||
/**
|
||||
* The renderer has tracks mapped to it, and at least one such track is playable. In other
|
||||
* words, {@link #getTrackSupport(int, int, int)} returns {@link
|
||||
* RendererCapabilities##FORMAT_HANDLED} for at least one track mapped to the renderer.
|
||||
*/
|
||||
public static final int RENDERER_SUPPORT_PLAYABLE_TRACKS = 3;
|
||||
|
||||
/**
|
||||
* The number of renderers to which tracks are mapped.
|
||||
*/
|
||||
public final int length;
|
||||
/** @deprecated Use {@link #getRendererCount()}. */
|
||||
@Deprecated public final int length;
|
||||
|
||||
private final int rendererCount;
|
||||
private final int[] rendererTrackTypes;
|
||||
private final TrackGroupArray[] trackGroups;
|
||||
private final int[] mixedMimeTypeAdaptiveSupport;
|
||||
private final int[][][] formatSupport;
|
||||
private final TrackGroupArray unassociatedTrackGroups;
|
||||
private final TrackGroupArray[] rendererTrackGroups;
|
||||
private final int[] rendererMixedMimeTypeAdaptiveSupports;
|
||||
private final int[][][] rendererFormatSupports;
|
||||
private final TrackGroupArray unmappedTrackGroups;
|
||||
|
||||
/**
|
||||
* @param rendererTrackTypes The track type supported by each renderer.
|
||||
* @param trackGroups The {@link TrackGroup}s mapped to each renderer.
|
||||
* @param mixedMimeTypeAdaptiveSupport The result of
|
||||
* {@link RendererCapabilities#supportsMixedMimeTypeAdaptation()} for each renderer.
|
||||
* @param formatSupport The result of {@link RendererCapabilities#supportsFormat} for each
|
||||
* mapped track, indexed by renderer index, track group index and track index (in that
|
||||
* order).
|
||||
* @param unassociatedTrackGroups Any {@link TrackGroup}s not mapped to any renderer.
|
||||
* @param rendererTrackTypes The track type handled by each renderer.
|
||||
* @param rendererTrackGroups The {@link TrackGroup}s mapped to each renderer.
|
||||
* @param rendererMixedMimeTypeAdaptiveSupports The result of {@link
|
||||
* RendererCapabilities#supportsMixedMimeTypeAdaptation()} for each renderer.
|
||||
* @param rendererFormatSupports The result of {@link RendererCapabilities#supportsFormat} for
|
||||
* each mapped track, indexed by renderer, track group and track (in that order).
|
||||
* @param unmappedTrackGroups {@link TrackGroup}s not mapped to any renderer.
|
||||
*/
|
||||
/* package */ MappedTrackInfo(int[] rendererTrackTypes,
|
||||
TrackGroupArray[] trackGroups, int[] mixedMimeTypeAdaptiveSupport,
|
||||
int[][][] formatSupport, TrackGroupArray unassociatedTrackGroups) {
|
||||
/* package */ MappedTrackInfo(
|
||||
int[] rendererTrackTypes,
|
||||
TrackGroupArray[] rendererTrackGroups,
|
||||
int[] rendererMixedMimeTypeAdaptiveSupports,
|
||||
int[][][] rendererFormatSupports,
|
||||
TrackGroupArray unmappedTrackGroups) {
|
||||
this.rendererTrackTypes = rendererTrackTypes;
|
||||
this.trackGroups = trackGroups;
|
||||
this.formatSupport = formatSupport;
|
||||
this.mixedMimeTypeAdaptiveSupport = mixedMimeTypeAdaptiveSupport;
|
||||
this.unassociatedTrackGroups = unassociatedTrackGroups;
|
||||
this.length = trackGroups.length;
|
||||
this.rendererTrackGroups = rendererTrackGroups;
|
||||
this.rendererFormatSupports = rendererFormatSupports;
|
||||
this.rendererMixedMimeTypeAdaptiveSupports = rendererMixedMimeTypeAdaptiveSupports;
|
||||
this.unmappedTrackGroups = unmappedTrackGroups;
|
||||
this.rendererCount = rendererTrackTypes.length;
|
||||
this.length = rendererCount;
|
||||
}
|
||||
|
||||
/** Returns the number of renderers. */
|
||||
public int getRendererCount() {
|
||||
return rendererCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the track type that the renderer at a given index handles.
|
||||
*
|
||||
* @see Renderer#getTrackType()
|
||||
* @param rendererIndex The renderer index.
|
||||
* @return One of the {@code TRACK_TYPE_*} constants defined in {@link C}.
|
||||
*/
|
||||
public int getRendererType(int rendererIndex) {
|
||||
return rendererTrackTypes[rendererIndex];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -101,23 +131,11 @@ public abstract class MappingTrackSelector extends TrackSelector {
|
|||
* @return The corresponding {@link TrackGroup}s.
|
||||
*/
|
||||
public TrackGroupArray getTrackGroups(int rendererIndex) {
|
||||
return trackGroups[rendererIndex];
|
||||
return rendererTrackGroups[rendererIndex];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the extent to which a renderer can play each of the tracks in the track groups mapped
|
||||
* to it.
|
||||
*
|
||||
* @param rendererIndex The renderer index.
|
||||
* @return The result of {@link RendererCapabilities#supportsFormat} for each track mapped to
|
||||
* the renderer, indexed by track group and track index (in that order).
|
||||
*/
|
||||
public int[][] getRendererTrackSupport(int rendererIndex) {
|
||||
return formatSupport[rendererIndex];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the extent to which a renderer can play the tracks in the track groups mapped to it.
|
||||
* Returns the extent to which a renderer can play the tracks that are mapped to it.
|
||||
*
|
||||
* @param rendererIndex The renderer index.
|
||||
* @return One of {@link #RENDERER_SUPPORT_PLAYABLE_TRACKS}, {@link
|
||||
|
|
@ -126,7 +144,7 @@ public abstract class MappingTrackSelector extends TrackSelector {
|
|||
*/
|
||||
public @RendererSupport int getRendererSupport(int rendererIndex) {
|
||||
int bestRendererSupport = RENDERER_SUPPORT_NO_TRACKS;
|
||||
int[][] rendererFormatSupport = formatSupport[rendererIndex];
|
||||
int[][] rendererFormatSupport = rendererFormatSupports[rendererIndex];
|
||||
for (int i = 0; i < rendererFormatSupport.length; i++) {
|
||||
for (int j = 0; j < rendererFormatSupport[i].length; j++) {
|
||||
int trackRendererSupport;
|
||||
|
|
@ -146,19 +164,26 @@ public abstract class MappingTrackSelector extends TrackSelector {
|
|||
return bestRendererSupport;
|
||||
}
|
||||
|
||||
/** @deprecated Use {@link #getTypeSupport(int)}. */
|
||||
@Deprecated
|
||||
public @RendererSupport int getTrackTypeRendererSupport(int trackType) {
|
||||
return getTypeSupport(trackType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the best level of support obtained from {@link #getRendererSupport(int)} for all
|
||||
* renderers of the specified track type. If no renderers exist for the specified type then
|
||||
* {@link #RENDERER_SUPPORT_NO_TRACKS} is returned.
|
||||
* Returns the extent to which tracks of a specified type are supported. This is the best level
|
||||
* of support obtained from {@link #getRendererSupport(int)} for all renderers that handle the
|
||||
* specified type. If no such renderers exist then {@link #RENDERER_SUPPORT_NO_TRACKS} is
|
||||
* returned.
|
||||
*
|
||||
* @param trackType The track type. One of the {@link C} {@code TRACK_TYPE_*} constants.
|
||||
* @return One of {@link #RENDERER_SUPPORT_PLAYABLE_TRACKS},
|
||||
* {@link #RENDERER_SUPPORT_EXCEEDS_CAPABILITIES_TRACKS},
|
||||
* {@link #RENDERER_SUPPORT_UNSUPPORTED_TRACKS} and {@link #RENDERER_SUPPORT_NO_TRACKS}.
|
||||
* @return One of {@link #RENDERER_SUPPORT_PLAYABLE_TRACKS}, {@link
|
||||
* #RENDERER_SUPPORT_EXCEEDS_CAPABILITIES_TRACKS}, {@link
|
||||
* #RENDERER_SUPPORT_UNSUPPORTED_TRACKS} and {@link #RENDERER_SUPPORT_NO_TRACKS}.
|
||||
*/
|
||||
public int getTrackTypeRendererSupport(int trackType) {
|
||||
public @RendererSupport int getTypeSupport(int trackType) {
|
||||
int bestRendererSupport = RENDERER_SUPPORT_NO_TRACKS;
|
||||
for (int i = 0; i < length; i++) {
|
||||
for (int i = 0; i < rendererCount; i++) {
|
||||
if (rendererTrackTypes[i] == trackType) {
|
||||
bestRendererSupport = Math.max(bestRendererSupport, getRendererSupport(i));
|
||||
}
|
||||
|
|
@ -166,53 +191,58 @@ public abstract class MappingTrackSelector extends TrackSelector {
|
|||
return bestRendererSupport;
|
||||
}
|
||||
|
||||
/** @deprecated Use {@link #getTrackSupport(int, int, int)}. */
|
||||
@Deprecated
|
||||
public int getTrackFormatSupport(int rendererIndex, int groupIndex, int trackIndex) {
|
||||
return getTrackSupport(rendererIndex, groupIndex, trackIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the extent to which an individual track is supported by the renderer.
|
||||
*
|
||||
* @param rendererIndex The renderer index.
|
||||
* @param groupIndex The index of the track group to which the track belongs.
|
||||
* @param trackIndex The index of the track within the track group.
|
||||
* @return One of {@link RendererCapabilities#FORMAT_HANDLED},
|
||||
* {@link RendererCapabilities#FORMAT_EXCEEDS_CAPABILITIES},
|
||||
* {@link RendererCapabilities#FORMAT_UNSUPPORTED_DRM},
|
||||
* {@link RendererCapabilities#FORMAT_UNSUPPORTED_SUBTYPE} and
|
||||
* {@link RendererCapabilities#FORMAT_UNSUPPORTED_TYPE}.
|
||||
* @return One of {@link RendererCapabilities#FORMAT_HANDLED}, {@link
|
||||
* RendererCapabilities#FORMAT_EXCEEDS_CAPABILITIES}, {@link
|
||||
* RendererCapabilities#FORMAT_UNSUPPORTED_DRM}, {@link
|
||||
* RendererCapabilities#FORMAT_UNSUPPORTED_SUBTYPE} and {@link
|
||||
* RendererCapabilities#FORMAT_UNSUPPORTED_TYPE}.
|
||||
*/
|
||||
public int getTrackFormatSupport(int rendererIndex, int groupIndex, int trackIndex) {
|
||||
return formatSupport[rendererIndex][groupIndex][trackIndex]
|
||||
public int getTrackSupport(int rendererIndex, int groupIndex, int trackIndex) {
|
||||
return rendererFormatSupports[rendererIndex][groupIndex][trackIndex]
|
||||
& RendererCapabilities.FORMAT_SUPPORT_MASK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the extent to which a renderer supports adaptation between supported tracks in a
|
||||
* specified {@link TrackGroup}.
|
||||
* <p>
|
||||
* Tracks for which {@link #getTrackFormatSupport(int, int, int)} returns
|
||||
* {@link RendererCapabilities#FORMAT_HANDLED} are always considered.
|
||||
* Tracks for which {@link #getTrackFormatSupport(int, int, int)} returns
|
||||
* {@link RendererCapabilities#FORMAT_UNSUPPORTED_DRM},
|
||||
* {@link RendererCapabilities#FORMAT_UNSUPPORTED_TYPE} or
|
||||
* {@link RendererCapabilities#FORMAT_UNSUPPORTED_SUBTYPE} are never considered.
|
||||
* Tracks for which {@link #getTrackFormatSupport(int, int, int)} returns
|
||||
* {@link RendererCapabilities#FORMAT_EXCEEDS_CAPABILITIES} are considered only if
|
||||
* {@code includeCapabilitiesExceededTracks} is set to {@code true}.
|
||||
*
|
||||
* <p>Tracks for which {@link #getTrackSupport(int, int, int)} returns {@link
|
||||
* RendererCapabilities#FORMAT_HANDLED} are always considered. Tracks for which {@link
|
||||
* #getTrackSupport(int, int, int)} returns {@link
|
||||
* RendererCapabilities#FORMAT_EXCEEDS_CAPABILITIES} are also considered if {@code
|
||||
* includeCapabilitiesExceededTracks} is set to {@code true}. Tracks for which {@link
|
||||
* #getTrackSupport(int, int, int)} returns {@link RendererCapabilities#FORMAT_UNSUPPORTED_DRM},
|
||||
* {@link RendererCapabilities#FORMAT_UNSUPPORTED_TYPE} or {@link
|
||||
* RendererCapabilities#FORMAT_UNSUPPORTED_SUBTYPE} are never considered.
|
||||
*
|
||||
* @param rendererIndex The renderer index.
|
||||
* @param groupIndex The index of the track group.
|
||||
* @param includeCapabilitiesExceededTracks True if formats that exceed the capabilities of the
|
||||
* renderer should be included when determining support. False otherwise.
|
||||
* @return One of {@link RendererCapabilities#ADAPTIVE_SEAMLESS},
|
||||
* {@link RendererCapabilities#ADAPTIVE_NOT_SEAMLESS} and
|
||||
* {@link RendererCapabilities#ADAPTIVE_NOT_SUPPORTED}.
|
||||
* @param includeCapabilitiesExceededTracks Whether tracks that exceed the capabilities of the
|
||||
* renderer are included when determining support.
|
||||
* @return One of {@link RendererCapabilities#ADAPTIVE_SEAMLESS}, {@link
|
||||
* RendererCapabilities#ADAPTIVE_NOT_SEAMLESS} and {@link
|
||||
* RendererCapabilities#ADAPTIVE_NOT_SUPPORTED}.
|
||||
*/
|
||||
public int getAdaptiveSupport(int rendererIndex, int groupIndex,
|
||||
boolean includeCapabilitiesExceededTracks) {
|
||||
int trackCount = trackGroups[rendererIndex].get(groupIndex).length;
|
||||
public int getAdaptiveSupport(
|
||||
int rendererIndex, int groupIndex, boolean includeCapabilitiesExceededTracks) {
|
||||
int trackCount = rendererTrackGroups[rendererIndex].get(groupIndex).length;
|
||||
// Iterate over the tracks in the group, recording the indices of those to consider.
|
||||
int[] trackIndices = new int[trackCount];
|
||||
int trackIndexCount = 0;
|
||||
for (int i = 0; i < trackCount; i++) {
|
||||
int fixedSupport = getTrackFormatSupport(rendererIndex, groupIndex, i);
|
||||
int fixedSupport = getTrackSupport(rendererIndex, groupIndex, i);
|
||||
if (fixedSupport == RendererCapabilities.FORMAT_HANDLED
|
||||
|| (includeCapabilitiesExceededTracks
|
||||
&& fixedSupport == RendererCapabilities.FORMAT_EXCEEDS_CAPABILITIES)) {
|
||||
|
|
@ -224,14 +254,14 @@ public abstract class MappingTrackSelector extends TrackSelector {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the extent to which a renderer supports adaptation between specified tracks within
|
||||
* a {@link TrackGroup}.
|
||||
* Returns the extent to which a renderer supports adaptation between specified tracks within a
|
||||
* {@link TrackGroup}.
|
||||
*
|
||||
* @param rendererIndex The renderer index.
|
||||
* @param groupIndex The index of the track group.
|
||||
* @return One of {@link RendererCapabilities#ADAPTIVE_SEAMLESS},
|
||||
* {@link RendererCapabilities#ADAPTIVE_NOT_SEAMLESS} and
|
||||
* {@link RendererCapabilities#ADAPTIVE_NOT_SUPPORTED}.
|
||||
* @return One of {@link RendererCapabilities#ADAPTIVE_SEAMLESS}, {@link
|
||||
* RendererCapabilities#ADAPTIVE_NOT_SEAMLESS} and {@link
|
||||
* RendererCapabilities#ADAPTIVE_NOT_SUPPORTED}.
|
||||
*/
|
||||
public int getAdaptiveSupport(int rendererIndex, int groupIndex, int[] trackIndices) {
|
||||
int handledTrackCount = 0;
|
||||
|
|
@ -240,26 +270,33 @@ public abstract class MappingTrackSelector extends TrackSelector {
|
|||
String firstSampleMimeType = null;
|
||||
for (int i = 0; i < trackIndices.length; i++) {
|
||||
int trackIndex = trackIndices[i];
|
||||
String sampleMimeType = trackGroups[rendererIndex].get(groupIndex).getFormat(trackIndex)
|
||||
.sampleMimeType;
|
||||
String sampleMimeType =
|
||||
rendererTrackGroups[rendererIndex].get(groupIndex).getFormat(trackIndex).sampleMimeType;
|
||||
if (handledTrackCount++ == 0) {
|
||||
firstSampleMimeType = sampleMimeType;
|
||||
} else {
|
||||
multipleMimeTypes |= !Util.areEqual(firstSampleMimeType, sampleMimeType);
|
||||
}
|
||||
adaptiveSupport = Math.min(adaptiveSupport, formatSupport[rendererIndex][groupIndex][i]
|
||||
& RendererCapabilities.ADAPTIVE_SUPPORT_MASK);
|
||||
adaptiveSupport =
|
||||
Math.min(
|
||||
adaptiveSupport,
|
||||
rendererFormatSupports[rendererIndex][groupIndex][i]
|
||||
& RendererCapabilities.ADAPTIVE_SUPPORT_MASK);
|
||||
}
|
||||
return multipleMimeTypes
|
||||
? Math.min(adaptiveSupport, mixedMimeTypeAdaptiveSupport[rendererIndex])
|
||||
? Math.min(adaptiveSupport, rendererMixedMimeTypeAdaptiveSupports[rendererIndex])
|
||||
: adaptiveSupport;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@link TrackGroup}s not mapped to any renderer.
|
||||
*/
|
||||
/** @deprecated Use {@link #getUnmappedTrackGroups()}. */
|
||||
@Deprecated
|
||||
public TrackGroupArray getUnassociatedTrackGroups() {
|
||||
return unassociatedTrackGroups;
|
||||
return getUnmappedTrackGroups();
|
||||
}
|
||||
|
||||
/** Returns {@link TrackGroup}s not mapped to any renderer. */
|
||||
public TrackGroupArray getUnmappedTrackGroups() {
|
||||
return unmappedTrackGroups;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -296,7 +333,8 @@ public abstract class MappingTrackSelector extends TrackSelector {
|
|||
}
|
||||
|
||||
// Determine the extent to which each renderer supports mixed mimeType adaptation.
|
||||
int[] mixedMimeTypeAdaptationSupport = getMixedMimeTypeAdaptationSupport(rendererCapabilities);
|
||||
int[] rendererMixedMimeTypeAdaptationSupports =
|
||||
getMixedMimeTypeAdaptationSupports(rendererCapabilities);
|
||||
|
||||
// Associate each track group to a preferred renderer, and evaluate the support that the
|
||||
// renderer provides for each track in the group.
|
||||
|
|
@ -325,30 +363,36 @@ public abstract class MappingTrackSelector extends TrackSelector {
|
|||
rendererTrackTypes[i] = rendererCapabilities[i].getTrackType();
|
||||
}
|
||||
|
||||
// Create a track group array for track groups not associated with a renderer.
|
||||
int unassociatedTrackGroupCount = rendererTrackGroupCounts[rendererCapabilities.length];
|
||||
TrackGroupArray unassociatedTrackGroupArray = new TrackGroupArray(Arrays.copyOf(
|
||||
rendererTrackGroups[rendererCapabilities.length], unassociatedTrackGroupCount));
|
||||
// Create a track group array for track groups not mapped to a renderer.
|
||||
int unmappedTrackGroupCount = rendererTrackGroupCounts[rendererCapabilities.length];
|
||||
TrackGroupArray unmappedTrackGroupArray =
|
||||
new TrackGroupArray(
|
||||
Arrays.copyOf(
|
||||
rendererTrackGroups[rendererCapabilities.length], unmappedTrackGroupCount));
|
||||
|
||||
// Package up the track information and selections.
|
||||
MappedTrackInfo mappedTrackInfo =
|
||||
new MappedTrackInfo(
|
||||
rendererTrackTypes,
|
||||
rendererTrackGroupArrays,
|
||||
mixedMimeTypeAdaptationSupport,
|
||||
rendererMixedMimeTypeAdaptationSupports,
|
||||
rendererFormatSupports,
|
||||
unassociatedTrackGroupArray);
|
||||
unmappedTrackGroupArray);
|
||||
|
||||
Pair<RendererConfiguration[], TrackSelection[]> result =
|
||||
selectTracks(rendererCapabilities, mappedTrackInfo);
|
||||
selectTracks(
|
||||
mappedTrackInfo, rendererFormatSupports, rendererMixedMimeTypeAdaptationSupports);
|
||||
return new TrackSelectorResult(result.first, result.second, mappedTrackInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Given mapped track information, returns a track selection and configuration for each renderer.
|
||||
*
|
||||
* @param rendererCapabilities The {@link RendererCapabilities} of each renderer.
|
||||
* @param mappedTrackInfo Mapped track information.
|
||||
* @param rendererFormatSupports The result of {@link RendererCapabilities#supportsFormat} for
|
||||
* each mapped track, indexed by renderer, track group and track (in that order).
|
||||
* @param rendererMixedMimeTypeAdaptationSupport The result of {@link
|
||||
* RendererCapabilities#supportsMixedMimeTypeAdaptation()} for each renderer.
|
||||
* @return A pair consisting of the track selections and configurations for each renderer. A null
|
||||
* configuration indicates the renderer should be disabled, in which case the track selection
|
||||
* will also be null. A track selection may also be null for a non-disabled renderer if {@link
|
||||
|
|
@ -356,7 +400,9 @@ public abstract class MappingTrackSelector extends TrackSelector {
|
|||
* @throws ExoPlaybackException If an error occurs while selecting the tracks.
|
||||
*/
|
||||
protected abstract Pair<RendererConfiguration[], TrackSelection[]> selectTracks(
|
||||
RendererCapabilities[] rendererCapabilities, MappedTrackInfo mappedTrackInfo)
|
||||
MappedTrackInfo mappedTrackInfo,
|
||||
int[][][] rendererFormatSupports,
|
||||
int[] rendererMixedMimeTypeAdaptationSupport)
|
||||
throws ExoPlaybackException;
|
||||
|
||||
/**
|
||||
|
|
@ -425,11 +471,11 @@ public abstract class MappingTrackSelector extends TrackSelector {
|
|||
* returning the results in an array.
|
||||
*
|
||||
* @param rendererCapabilities The {@link RendererCapabilities} of the renderers.
|
||||
* @return An array containing the result of calling
|
||||
* {@link RendererCapabilities#supportsMixedMimeTypeAdaptation()} for each renderer.
|
||||
* @return An array containing the result of calling {@link
|
||||
* RendererCapabilities#supportsMixedMimeTypeAdaptation()} for each renderer.
|
||||
* @throws ExoPlaybackException If an error occurs determining the adaptation support.
|
||||
*/
|
||||
private static int[] getMixedMimeTypeAdaptationSupport(
|
||||
private static int[] getMixedMimeTypeAdaptationSupports(
|
||||
RendererCapabilities[] rendererCapabilities) throws ExoPlaybackException {
|
||||
int[] mixedMimeTypeAdaptationSupport = new int[rendererCapabilities.length];
|
||||
for (int i = 0; i < mixedMimeTypeAdaptationSupport.length; i++) {
|
||||
|
|
|
|||
|
|
@ -170,7 +170,8 @@ public class EventLogger
|
|||
}
|
||||
logd("Tracks [");
|
||||
// Log tracks associated to renderers.
|
||||
for (int rendererIndex = 0; rendererIndex < mappedTrackInfo.length; rendererIndex++) {
|
||||
int rendererCount = mappedTrackInfo.getRendererCount();
|
||||
for (int rendererIndex = 0; rendererIndex < rendererCount; rendererIndex++) {
|
||||
TrackGroupArray rendererTrackGroups = mappedTrackInfo.getTrackGroups(rendererIndex);
|
||||
TrackSelection trackSelection = trackSelections.get(rendererIndex);
|
||||
if (rendererTrackGroups.length > 0) {
|
||||
|
|
@ -186,7 +187,7 @@ public class EventLogger
|
|||
String status = getTrackStatusString(trackSelection, trackGroup, trackIndex);
|
||||
String formatSupport =
|
||||
getFormatSupportString(
|
||||
mappedTrackInfo.getTrackFormatSupport(rendererIndex, groupIndex, trackIndex));
|
||||
mappedTrackInfo.getTrackSupport(rendererIndex, groupIndex, trackIndex));
|
||||
logd(
|
||||
" "
|
||||
+ status
|
||||
|
|
@ -215,7 +216,7 @@ public class EventLogger
|
|||
}
|
||||
}
|
||||
// Log tracks not associated with a renderer.
|
||||
TrackGroupArray unassociatedTrackGroups = mappedTrackInfo.getUnassociatedTrackGroups();
|
||||
TrackGroupArray unassociatedTrackGroups = mappedTrackInfo.getUnmappedTrackGroups();
|
||||
if (unassociatedTrackGroups.length > 0) {
|
||||
logd(" Renderer:None [");
|
||||
for (int groupIndex = 0; groupIndex < unassociatedTrackGroups.length; groupIndex++) {
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ public final class MappingTrackSelectorTest {
|
|||
|
||||
/**
|
||||
* A {@link MappingTrackSelector} that stashes the {@link MappedTrackInfo} passed to {@link
|
||||
* #selectTracks(RendererCapabilities[], MappedTrackInfo)}.
|
||||
* #selectTracks(MappedTrackInfo, int[][][], int[])}.
|
||||
*/
|
||||
private static final class FakeMappingTrackSelector extends MappingTrackSelector {
|
||||
|
||||
|
|
@ -101,12 +101,14 @@ public final class MappingTrackSelectorTest {
|
|||
|
||||
@Override
|
||||
protected Pair<RendererConfiguration[], TrackSelection[]> selectTracks(
|
||||
RendererCapabilities[] rendererCapabilities, MappedTrackInfo mappedTrackInfo)
|
||||
MappedTrackInfo mappedTrackInfo,
|
||||
int[][][] rendererFormatSupports,
|
||||
int[] rendererMixedMimeTypeAdaptationSupports)
|
||||
throws ExoPlaybackException {
|
||||
int rendererCount = mappedTrackInfo.getRendererCount();
|
||||
lastMappedTrackInfo = mappedTrackInfo;
|
||||
return Pair.create(
|
||||
new RendererConfiguration[rendererCapabilities.length],
|
||||
new TrackSelection[rendererCapabilities.length]);
|
||||
new RendererConfiguration[rendererCount], new TrackSelection[rendererCount]);
|
||||
}
|
||||
|
||||
public void assertMappedTrackGroups(int rendererIndex, TrackGroup... expected) {
|
||||
|
|
|
|||
|
|
@ -15,6 +15,6 @@
|
|||
<string name="exo_downloading">Изтегля се</string>
|
||||
<string name="exo_download_completed">Изтеглянето завърши</string>
|
||||
<string name="exo_download_failed">Изтеглянето не бе успешно</string>
|
||||
<string name="exo_track_selection_none">None</string>
|
||||
<string name="exo_track_selection_auto">Auto</string>
|
||||
<string name="exo_track_selection_none">Нищо</string>
|
||||
<string name="exo_track_selection_auto">Автоматично</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -15,6 +15,6 @@
|
|||
<string name="exo_downloading">Mendownload</string>
|
||||
<string name="exo_download_completed">Download selesai</string>
|
||||
<string name="exo_download_failed">Download gagal</string>
|
||||
<string name="exo_track_selection_none">None</string>
|
||||
<string name="exo_track_selection_auto">Auto</string>
|
||||
<string name="exo_track_selection_none">Tidak ada</string>
|
||||
<string name="exo_track_selection_auto">Otomatis</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -15,6 +15,6 @@
|
|||
<string name="exo_downloading">ဒေါင်းလုဒ်လုပ်နေသည်</string>
|
||||
<string name="exo_download_completed">ဒေါင်းလုဒ်လုပ်ပြီးပါပြီ</string>
|
||||
<string name="exo_download_failed">ဒေါင်းလုဒ်လုပ်၍ မရပါ</string>
|
||||
<string name="exo_track_selection_none">None</string>
|
||||
<string name="exo_track_selection_auto">Auto</string>
|
||||
<string name="exo_track_selection_none">မရှိ</string>
|
||||
<string name="exo_track_selection_auto">အလိုအလျောက်</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -15,6 +15,6 @@
|
|||
<string name="exo_downloading">Se descarcă</string>
|
||||
<string name="exo_download_completed">Descărcarea a fost finalizată</string>
|
||||
<string name="exo_download_failed">Descărcarea nu a reușit</string>
|
||||
<string name="exo_track_selection_none">None</string>
|
||||
<string name="exo_track_selection_auto">Auto</string>
|
||||
<string name="exo_track_selection_none">Fără</string>
|
||||
<string name="exo_track_selection_auto">Automat</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -15,6 +15,6 @@
|
|||
<string name="exo_downloading">බාගනිමින්</string>
|
||||
<string name="exo_download_completed">බාගැනීම සම්පූර්ණ කරන ලදී</string>
|
||||
<string name="exo_download_failed">බාගැනීම අසමත් විය</string>
|
||||
<string name="exo_track_selection_none">None</string>
|
||||
<string name="exo_track_selection_auto">Auto</string>
|
||||
<string name="exo_track_selection_none">කිසිවක් නැත</string>
|
||||
<string name="exo_track_selection_auto">ස්වයං</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -395,23 +395,25 @@ public final class DashTestRunner {
|
|||
|
||||
@Override
|
||||
protected TrackSelection[] selectAllTracks(
|
||||
RendererCapabilities[] rendererCapabilities, MappedTrackInfo mappedTrackInfo)
|
||||
MappedTrackInfo mappedTrackInfo,
|
||||
int[][][] rendererFormatSupports,
|
||||
int[] rendererMixedMimeTypeAdaptationSupports)
|
||||
throws ExoPlaybackException {
|
||||
Assertions.checkState(rendererCapabilities[VIDEO_RENDERER_INDEX].getTrackType()
|
||||
== C.TRACK_TYPE_VIDEO);
|
||||
Assertions.checkState(rendererCapabilities[AUDIO_RENDERER_INDEX].getTrackType()
|
||||
== C.TRACK_TYPE_AUDIO);
|
||||
Assertions.checkState(
|
||||
mappedTrackInfo.getRendererType(VIDEO_RENDERER_INDEX) == C.TRACK_TYPE_VIDEO);
|
||||
Assertions.checkState(
|
||||
mappedTrackInfo.getRendererType(AUDIO_RENDERER_INDEX) == C.TRACK_TYPE_AUDIO);
|
||||
TrackGroupArray videoTrackGroups = mappedTrackInfo.getTrackGroups(VIDEO_RENDERER_INDEX);
|
||||
TrackGroupArray audioTrackGroups = mappedTrackInfo.getTrackGroups(AUDIO_RENDERER_INDEX);
|
||||
Assertions.checkState(videoTrackGroups.length == 1);
|
||||
Assertions.checkState(audioTrackGroups.length == 1);
|
||||
TrackSelection[] selections = new TrackSelection[rendererCapabilities.length];
|
||||
TrackSelection[] selections = new TrackSelection[mappedTrackInfo.getRendererCount()];
|
||||
selections[VIDEO_RENDERER_INDEX] =
|
||||
new RandomTrackSelection(
|
||||
videoTrackGroups.get(0),
|
||||
getVideoTrackIndices(
|
||||
videoTrackGroups.get(0),
|
||||
mappedTrackInfo.getRendererTrackSupport(VIDEO_RENDERER_INDEX)[0],
|
||||
rendererFormatSupports[VIDEO_RENDERER_INDEX][0],
|
||||
videoFormatIds,
|
||||
canIncludeAdditionalVideoFormats),
|
||||
0 /* seed */);
|
||||
|
|
@ -423,8 +425,11 @@ public final class DashTestRunner {
|
|||
return selections;
|
||||
}
|
||||
|
||||
private int[] getVideoTrackIndices(TrackGroup trackGroup, int[] formatSupport,
|
||||
String[] formatIds, boolean canIncludeAdditionalFormats) {
|
||||
private int[] getVideoTrackIndices(
|
||||
TrackGroup trackGroup,
|
||||
int[] formatSupports,
|
||||
String[] formatIds,
|
||||
boolean canIncludeAdditionalFormats) {
|
||||
List<Integer> trackIndices = new ArrayList<>();
|
||||
|
||||
// Always select explicitly listed representations.
|
||||
|
|
@ -438,7 +443,7 @@ public final class DashTestRunner {
|
|||
// Select additional video representations, if supported by the device.
|
||||
if (canIncludeAdditionalFormats) {
|
||||
for (int i = 0; i < trackGroup.length; i++) {
|
||||
if (!trackIndices.contains(i) && isFormatHandled(formatSupport[i])) {
|
||||
if (!trackIndices.contains(i) && isFormatHandled(formatSupports[i])) {
|
||||
Log.d(tag, "Adding extra video format: "
|
||||
+ Format.toLogString(trackGroup.getFormat(i)));
|
||||
trackIndices.add(i);
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ package com.google.android.exoplayer2.testutil;
|
|||
|
||||
import android.support.annotation.NonNull;
|
||||
import com.google.android.exoplayer2.ExoPlaybackException;
|
||||
import com.google.android.exoplayer2.RendererCapabilities;
|
||||
import com.google.android.exoplayer2.source.TrackGroup;
|
||||
import com.google.android.exoplayer2.source.TrackGroupArray;
|
||||
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
|
||||
|
|
@ -47,7 +46,9 @@ public class FakeTrackSelector extends DefaultTrackSelector {
|
|||
|
||||
@Override
|
||||
protected TrackSelection[] selectAllTracks(
|
||||
RendererCapabilities[] rendererCapabilities, MappedTrackInfo mappedTrackInfo)
|
||||
MappedTrackInfo mappedTrackInfo,
|
||||
int[][][] rendererFormatSupports,
|
||||
int[] rendererMixedMimeTypeAdaptationSupports)
|
||||
throws ExoPlaybackException {
|
||||
TrackSelection[] selections = new TrackSelection[mappedTrackInfo.length];
|
||||
for (int i = 0; i < mappedTrackInfo.length; i++) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue