@Test public void testSelectTracksPreferTrackWithinCapabilitiesOverSelectionFlag() throws Exception { Format exceededWithSelectionFlagFormat = Format.createAudioSampleFormat( "exceededFormat", MimeTypes.AUDIO_AAC, null, Format.NO_VALUE, Format.NO_VALUE, 2, 44100, null, null, C.SELECTION_FLAG_DEFAULT, null); Format supportedFormat = Format.createAudioSampleFormat("supportedFormat", MimeTypes.AUDIO_AAC, null, Format.NO_VALUE, Format.NO_VALUE, 2, 44100, null, null, 0, null); TrackGroupArray trackGroups = wrapFormats(exceededWithSelectionFlagFormat, supportedFormat); Map<String, Integer> mappedCapabilities = new HashMap<>(); mappedCapabilities.put(supportedFormat.id, FORMAT_HANDLED); mappedCapabilities.put(exceededWithSelectionFlagFormat.id, FORMAT_EXCEEDS_CAPABILITIES); RendererCapabilities mappedAudioRendererCapabilities = new FakeMappedRendererCapabilities(C.TRACK_TYPE_AUDIO, mappedCapabilities); TrackSelectorResult result = trackSelector.selectTracks( new RendererCapabilities[] {mappedAudioRendererCapabilities}, trackGroups, periodId, TIMELINE); assertFixedSelection(result.selections.get(0), trackGroups, supportedFormat); }
@Override protected final Pair<@NullableType RendererConfiguration[], @NullableType TrackSelection[]> selectTracks( MappedTrackInfo mappedTrackInfo, int[][][] rendererFormatSupports, int[] rendererMixedMimeTypeAdaptationSupports) throws ExoPlaybackException { Parameters params = parametersReference.get(); int rendererCount = mappedTrackInfo.getRendererCount(); TrackSelection.@NullableType Definition[] definitions = selectAllTracks( mappedTrackInfo, rendererFormatSupports, rendererMixedMimeTypeAdaptationSupports, params); for (int i = 0; i < rendererCount; i++) { if (params.getRendererDisabled(i)) { definitions[i] = null; continue; } TrackGroupArray rendererTrackGroups = mappedTrackInfo.getTrackGroups(i); if (params.hasSelectionOverride(i, rendererTrackGroups)) { SelectionOverride override = params.getSelectionOverride(i, rendererTrackGroups); definitions[i] = override == null ? null : new TrackSelection.Definition( rendererTrackGroups.get(override.groupIndex), override.tracks, override.reason, override.data); } } @NullableType TrackSelection[] rendererTrackSelections = trackSelectionFactory.createTrackSelections(definitions, getBandwidthMeter()); @NullableType RendererConfiguration[] rendererConfigurations = new RendererConfiguration[rendererCount]; for (int i = 0; i < rendererCount; i++) { boolean forceRendererDisabled = params.getRendererDisabled(i); boolean rendererEnabled = !forceRendererDisabled && (mappedTrackInfo.getRendererType(i) == C.TRACK_TYPE_NONE || rendererTrackSelections[i] != null); rendererConfigurations[i] = rendererEnabled ? RendererConfiguration.DEFAULT : null; } maybeConfigureRenderersForTunneling( mappedTrackInfo, rendererFormatSupports, rendererConfigurations, rendererTrackSelections, params.tunnelingAudioSessionId); return Pair.create(rendererConfigurations, rendererTrackSelections); }
DefaultTrackSelector extends MappingTrackSelector { @Override protected final Pair<@NullableType RendererConfiguration[], @NullableType TrackSelection[]> selectTracks( MappedTrackInfo mappedTrackInfo, int[][][] rendererFormatSupports, int[] rendererMixedMimeTypeAdaptationSupports) throws ExoPlaybackException { Parameters params = parametersReference.get(); int rendererCount = mappedTrackInfo.getRendererCount(); TrackSelection.@NullableType Definition[] definitions = selectAllTracks( mappedTrackInfo, rendererFormatSupports, rendererMixedMimeTypeAdaptationSupports, params); for (int i = 0; i < rendererCount; i++) { if (params.getRendererDisabled(i)) { definitions[i] = null; continue; } TrackGroupArray rendererTrackGroups = mappedTrackInfo.getTrackGroups(i); if (params.hasSelectionOverride(i, rendererTrackGroups)) { SelectionOverride override = params.getSelectionOverride(i, rendererTrackGroups); definitions[i] = override == null ? null : new TrackSelection.Definition( rendererTrackGroups.get(override.groupIndex), override.tracks, override.reason, override.data); } } @NullableType TrackSelection[] rendererTrackSelections = trackSelectionFactory.createTrackSelections(definitions, getBandwidthMeter()); @NullableType RendererConfiguration[] rendererConfigurations = new RendererConfiguration[rendererCount]; for (int i = 0; i < rendererCount; i++) { boolean forceRendererDisabled = params.getRendererDisabled(i); boolean rendererEnabled = !forceRendererDisabled && (mappedTrackInfo.getRendererType(i) == C.TRACK_TYPE_NONE || rendererTrackSelections[i] != null); rendererConfigurations[i] = rendererEnabled ? RendererConfiguration.DEFAULT : null; } maybeConfigureRenderersForTunneling( mappedTrackInfo, rendererFormatSupports, rendererConfigurations, rendererTrackSelections, params.tunnelingAudioSessionId); return Pair.create(rendererConfigurations, rendererTrackSelections); } }
DefaultTrackSelector extends MappingTrackSelector { @Override protected final Pair<@NullableType RendererConfiguration[], @NullableType TrackSelection[]> selectTracks( MappedTrackInfo mappedTrackInfo, int[][][] rendererFormatSupports, int[] rendererMixedMimeTypeAdaptationSupports) throws ExoPlaybackException { Parameters params = parametersReference.get(); int rendererCount = mappedTrackInfo.getRendererCount(); TrackSelection.@NullableType Definition[] definitions = selectAllTracks( mappedTrackInfo, rendererFormatSupports, rendererMixedMimeTypeAdaptationSupports, params); for (int i = 0; i < rendererCount; i++) { if (params.getRendererDisabled(i)) { definitions[i] = null; continue; } TrackGroupArray rendererTrackGroups = mappedTrackInfo.getTrackGroups(i); if (params.hasSelectionOverride(i, rendererTrackGroups)) { SelectionOverride override = params.getSelectionOverride(i, rendererTrackGroups); definitions[i] = override == null ? null : new TrackSelection.Definition( rendererTrackGroups.get(override.groupIndex), override.tracks, override.reason, override.data); } } @NullableType TrackSelection[] rendererTrackSelections = trackSelectionFactory.createTrackSelections(definitions, getBandwidthMeter()); @NullableType RendererConfiguration[] rendererConfigurations = new RendererConfiguration[rendererCount]; for (int i = 0; i < rendererCount; i++) { boolean forceRendererDisabled = params.getRendererDisabled(i); boolean rendererEnabled = !forceRendererDisabled && (mappedTrackInfo.getRendererType(i) == C.TRACK_TYPE_NONE || rendererTrackSelections[i] != null); rendererConfigurations[i] = rendererEnabled ? RendererConfiguration.DEFAULT : null; } maybeConfigureRenderersForTunneling( mappedTrackInfo, rendererFormatSupports, rendererConfigurations, rendererTrackSelections, params.tunnelingAudioSessionId); return Pair.create(rendererConfigurations, rendererTrackSelections); } DefaultTrackSelector(); @Deprecated @SuppressWarnings("deprecation")  DefaultTrackSelector(BandwidthMeter bandwidthMeter);  DefaultTrackSelector(TrackSelection.Factory trackSelectionFactory); }
DefaultTrackSelector extends MappingTrackSelector { @Override protected final Pair<@NullableType RendererConfiguration[], @NullableType TrackSelection[]> selectTracks( MappedTrackInfo mappedTrackInfo, int[][][] rendererFormatSupports, int[] rendererMixedMimeTypeAdaptationSupports) throws ExoPlaybackException { Parameters params = parametersReference.get(); int rendererCount = mappedTrackInfo.getRendererCount(); TrackSelection.@NullableType Definition[] definitions = selectAllTracks( mappedTrackInfo, rendererFormatSupports, rendererMixedMimeTypeAdaptationSupports, params); for (int i = 0; i < rendererCount; i++) { if (params.getRendererDisabled(i)) { definitions[i] = null; continue; } TrackGroupArray rendererTrackGroups = mappedTrackInfo.getTrackGroups(i); if (params.hasSelectionOverride(i, rendererTrackGroups)) { SelectionOverride override = params.getSelectionOverride(i, rendererTrackGroups); definitions[i] = override == null ? null : new TrackSelection.Definition( rendererTrackGroups.get(override.groupIndex), override.tracks, override.reason, override.data); } } @NullableType TrackSelection[] rendererTrackSelections = trackSelectionFactory.createTrackSelections(definitions, getBandwidthMeter()); @NullableType RendererConfiguration[] rendererConfigurations = new RendererConfiguration[rendererCount]; for (int i = 0; i < rendererCount; i++) { boolean forceRendererDisabled = params.getRendererDisabled(i); boolean rendererEnabled = !forceRendererDisabled && (mappedTrackInfo.getRendererType(i) == C.TRACK_TYPE_NONE || rendererTrackSelections[i] != null); rendererConfigurations[i] = rendererEnabled ? RendererConfiguration.DEFAULT : null; } maybeConfigureRenderersForTunneling( mappedTrackInfo, rendererFormatSupports, rendererConfigurations, rendererTrackSelections, params.tunnelingAudioSessionId); return Pair.create(rendererConfigurations, rendererTrackSelections); } DefaultTrackSelector(); @Deprecated @SuppressWarnings("deprecation")  DefaultTrackSelector(BandwidthMeter bandwidthMeter);  DefaultTrackSelector(TrackSelection.Factory trackSelectionFactory); void setParameters(Parameters parameters); void setParameters(ParametersBuilder parametersBuilder); Parameters getParameters(); ParametersBuilder buildUponParameters(); @Deprecated final void setRendererDisabled(int rendererIndex, boolean disabled); @Deprecated final boolean getRendererDisabled(int rendererIndex); @Deprecated final void setSelectionOverride(
      int rendererIndex, TrackGroupArray groups, SelectionOverride override); @Deprecated final boolean hasSelectionOverride(int rendererIndex, TrackGroupArray groups); @Deprecated @Nullable final SelectionOverride getSelectionOverride(int rendererIndex, TrackGroupArray groups); @Deprecated final void clearSelectionOverride(int rendererIndex, TrackGroupArray groups); @Deprecated final void clearSelectionOverrides(int rendererIndex); @Deprecated final void clearSelectionOverrides(); @Deprecated void setTunnelingAudioSessionId(int tunnelingAudioSessionId); void experimental_allowMultipleAdaptiveSelections(); }
DefaultTrackSelector extends MappingTrackSelector { @Override protected final Pair<@NullableType RendererConfiguration[], @NullableType TrackSelection[]> selectTracks( MappedTrackInfo mappedTrackInfo, int[][][] rendererFormatSupports, int[] rendererMixedMimeTypeAdaptationSupports) throws ExoPlaybackException { Parameters params = parametersReference.get(); int rendererCount = mappedTrackInfo.getRendererCount(); TrackSelection.@NullableType Definition[] definitions = selectAllTracks( mappedTrackInfo, rendererFormatSupports, rendererMixedMimeTypeAdaptationSupports, params); for (int i = 0; i < rendererCount; i++) { if (params.getRendererDisabled(i)) { definitions[i] = null; continue; } TrackGroupArray rendererTrackGroups = mappedTrackInfo.getTrackGroups(i); if (params.hasSelectionOverride(i, rendererTrackGroups)) { SelectionOverride override = params.getSelectionOverride(i, rendererTrackGroups); definitions[i] = override == null ? null : new TrackSelection.Definition( rendererTrackGroups.get(override.groupIndex), override.tracks, override.reason, override.data); } } @NullableType TrackSelection[] rendererTrackSelections = trackSelectionFactory.createTrackSelections(definitions, getBandwidthMeter()); @NullableType RendererConfiguration[] rendererConfigurations = new RendererConfiguration[rendererCount]; for (int i = 0; i < rendererCount; i++) { boolean forceRendererDisabled = params.getRendererDisabled(i); boolean rendererEnabled = !forceRendererDisabled && (mappedTrackInfo.getRendererType(i) == C.TRACK_TYPE_NONE || rendererTrackSelections[i] != null); rendererConfigurations[i] = rendererEnabled ? RendererConfiguration.DEFAULT : null; } maybeConfigureRenderersForTunneling( mappedTrackInfo, rendererFormatSupports, rendererConfigurations, rendererTrackSelections, params.tunnelingAudioSessionId); return Pair.create(rendererConfigurations, rendererTrackSelections); } DefaultTrackSelector(); @Deprecated @SuppressWarnings("deprecation")  DefaultTrackSelector(BandwidthMeter bandwidthMeter);  DefaultTrackSelector(TrackSelection.Factory trackSelectionFactory); void setParameters(Parameters parameters); void setParameters(ParametersBuilder parametersBuilder); Parameters getParameters(); ParametersBuilder buildUponParameters(); @Deprecated final void setRendererDisabled(int rendererIndex, boolean disabled); @Deprecated final boolean getRendererDisabled(int rendererIndex); @Deprecated final void setSelectionOverride(
      int rendererIndex, TrackGroupArray groups, SelectionOverride override); @Deprecated final boolean hasSelectionOverride(int rendererIndex, TrackGroupArray groups); @Deprecated @Nullable final SelectionOverride getSelectionOverride(int rendererIndex, TrackGroupArray groups); @Deprecated final void clearSelectionOverride(int rendererIndex, TrackGroupArray groups); @Deprecated final void clearSelectionOverrides(int rendererIndex); @Deprecated final void clearSelectionOverrides(); @Deprecated void setTunnelingAudioSessionId(int tunnelingAudioSessionId); void experimental_allowMultipleAdaptiveSelections();  }