use of com.google.android.exoplayer2.trackselection.TrackSelectorResult in project ExoPlayer by google.
the class DefaultTrackSelectorTest method selectTracksWithMultipleVideoTracksWithMixedDecoderSupportLevels.
@Test
public void selectTracksWithMultipleVideoTracksWithMixedDecoderSupportLevels() throws Exception {
Format.Builder formatBuilder = VIDEO_FORMAT.buildUpon();
Format format0 = formatBuilder.setId("0").setAverageBitrate(200).build();
Format format1 = formatBuilder.setId("1").setAverageBitrate(400).build();
Format format2 = formatBuilder.setId("2").setAverageBitrate(600).build();
Format format3 = formatBuilder.setId("3").setAverageBitrate(800).build();
TrackGroupArray trackGroups = singleTrackGroup(format0, format1, format2, format3);
@Capabilities int unsupported = RendererCapabilities.create(FORMAT_UNSUPPORTED_TYPE);
@Capabilities int primaryHardware = RendererCapabilities.create(FORMAT_HANDLED, ADAPTIVE_NOT_SEAMLESS, TUNNELING_NOT_SUPPORTED, HARDWARE_ACCELERATION_SUPPORTED, DECODER_SUPPORT_PRIMARY);
@Capabilities int primarySoftware = RendererCapabilities.create(FORMAT_HANDLED, ADAPTIVE_NOT_SEAMLESS, TUNNELING_NOT_SUPPORTED, HARDWARE_ACCELERATION_NOT_SUPPORTED, DECODER_SUPPORT_PRIMARY);
@Capabilities int fallbackHardware = RendererCapabilities.create(FORMAT_HANDLED, ADAPTIVE_NOT_SEAMLESS, TUNNELING_NOT_SUPPORTED, HARDWARE_ACCELERATION_SUPPORTED, DECODER_SUPPORT_FALLBACK);
@Capabilities int fallbackSoftware = RendererCapabilities.create(FORMAT_HANDLED, ADAPTIVE_NOT_SEAMLESS, TUNNELING_NOT_SUPPORTED, HARDWARE_ACCELERATION_NOT_SUPPORTED, DECODER_SUPPORT_FALLBACK);
// Select all tracks supported by primary, hardware decoder by default.
ImmutableMap<String, Integer> rendererCapabilitiesMap = ImmutableMap.of("0", primaryHardware, "1", primaryHardware, "2", primarySoftware, "3", fallbackHardware);
RendererCapabilities rendererCapabilities = new FakeMappedRendererCapabilities(C.TRACK_TYPE_VIDEO, rendererCapabilitiesMap);
TrackSelectorResult result = trackSelector.selectTracks(new RendererCapabilities[] { rendererCapabilities }, trackGroups, periodId, TIMELINE);
assertAdaptiveSelection(result.selections[0], trackGroups.get(0), 1, 0);
// Select all tracks supported by primary, software decoder by default if no primary, hardware
// decoder is available.
rendererCapabilitiesMap = ImmutableMap.of("0", fallbackHardware, "1", fallbackHardware, "2", primarySoftware, "3", fallbackSoftware);
rendererCapabilities = new FakeMappedRendererCapabilities(C.TRACK_TYPE_VIDEO, rendererCapabilitiesMap);
result = trackSelector.selectTracks(new RendererCapabilities[] { rendererCapabilities }, trackGroups, periodId, TIMELINE);
assertFixedSelection(result.selections[0], trackGroups.get(0), 2);
// Select all tracks supported by fallback, hardware decoder if no primary decoder is
// available.
rendererCapabilitiesMap = ImmutableMap.of("0", fallbackHardware, "1", unsupported, "2", fallbackSoftware, "3", fallbackHardware);
rendererCapabilities = new FakeMappedRendererCapabilities(C.TRACK_TYPE_VIDEO, rendererCapabilitiesMap);
result = trackSelector.selectTracks(new RendererCapabilities[] { rendererCapabilities }, trackGroups, periodId, TIMELINE);
assertAdaptiveSelection(result.selections[0], trackGroups.get(0), 3, 0);
// Select all tracks supported by fallback, software decoder if no other decoder is available.
rendererCapabilitiesMap = ImmutableMap.of("0", fallbackSoftware, "1", fallbackSoftware, "2", unsupported, "3", fallbackSoftware);
rendererCapabilities = new FakeMappedRendererCapabilities(C.TRACK_TYPE_VIDEO, rendererCapabilitiesMap);
result = trackSelector.selectTracks(new RendererCapabilities[] { rendererCapabilities }, trackGroups, periodId, TIMELINE);
assertAdaptiveSelection(result.selections[0], trackGroups.get(0), 3, 1, 0);
// Select all tracks if mixed decoder support is allowed.
rendererCapabilitiesMap = ImmutableMap.of("0", primaryHardware, "1", unsupported, "2", primarySoftware, "3", fallbackHardware);
rendererCapabilities = new FakeMappedRendererCapabilities(C.TRACK_TYPE_VIDEO, rendererCapabilitiesMap);
trackSelector.setParameters(defaultParameters.buildUpon().setAllowVideoMixedDecoderSupportAdaptiveness(true));
result = trackSelector.selectTracks(new RendererCapabilities[] { rendererCapabilities }, trackGroups, periodId, TIMELINE);
assertAdaptiveSelection(result.selections[0], trackGroups.get(0), 3, 2, 0);
}
use of com.google.android.exoplayer2.trackselection.TrackSelectorResult in project ExoPlayer by google.
the class DefaultTrackSelectorTest method selectTracks_withoutPreferredAudioRoleFlagsOrDefaultTrack_selectsFirstTrack.
/**
* Tests that track selector with select the first audio track if no role flag preference is
* specified by {@link Parameters} and no default track exists.
*/
@Test
public void selectTracks_withoutPreferredAudioRoleFlagsOrDefaultTrack_selectsFirstTrack() throws Exception {
Format firstFormat = AUDIO_FORMAT;
Format roleFlagFormat = AUDIO_FORMAT.buildUpon().setRoleFlags(C.ROLE_FLAG_CAPTION).build();
TrackGroupArray trackGroups = wrapFormats(firstFormat, roleFlagFormat);
TrackSelectorResult result = trackSelector.selectTracks(new RendererCapabilities[] { ALL_AUDIO_FORMAT_SUPPORTED_RENDERER_CAPABILITIES }, trackGroups, periodId, TIMELINE);
assertFixedSelection(result.selections[0], trackGroups, firstFormat);
}
use of com.google.android.exoplayer2.trackselection.TrackSelectorResult in project ExoPlayer by google.
the class DefaultTrackSelectorTest method selectTracksWithMultipleVideoTracksOverrideReturnsAdaptiveTrackSelection.
@Test
public void selectTracksWithMultipleVideoTracksOverrideReturnsAdaptiveTrackSelection() throws Exception {
Format.Builder formatBuilder = VIDEO_FORMAT.buildUpon();
TrackGroupArray trackGroups = singleTrackGroup(formatBuilder.setId("0").build(), formatBuilder.setId("1").build(), formatBuilder.setId("2").build());
trackSelector.setParameters(trackSelector.buildUponParameters().setSelectionOverride(/* rendererIndex= */
0, trackGroups, new SelectionOverride(/* groupIndex= */
0, /* tracks=... */
1, 2)));
TrackSelectorResult result = trackSelector.selectTracks(new RendererCapabilities[] { VIDEO_CAPABILITIES }, trackGroups, periodId, TIMELINE);
assertThat(result.length).isEqualTo(1);
assertAdaptiveSelection(result.selections[0], trackGroups.get(0), 1, 2);
}
use of com.google.android.exoplayer2.trackselection.TrackSelectorResult in project ExoPlayer by google.
the class DefaultTrackSelectorTest method selectTracksPreferTrackWithinCapabilitiesOverSelectionFlag.
/**
* Tests that track selector will prefer tracks that are within renderer's capabilities over
* tracks that have {@link C#SELECTION_FLAG_DEFAULT} but exceed renderer's capabilities.
*/
@Test
public void selectTracksPreferTrackWithinCapabilitiesOverSelectionFlag() throws Exception {
Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
Format exceededWithSelectionFlagFormat = formatBuilder.setId("exceededFormat").setSelectionFlags(C.SELECTION_FLAG_DEFAULT).build();
Format supportedFormat = formatBuilder.setId("supportedFormat").setSelectionFlags(0).build();
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[0], trackGroups, supportedFormat);
}
use of com.google.android.exoplayer2.trackselection.TrackSelectorResult in project ExoPlayer by google.
the class DefaultTrackSelectorTest method selectTracks_withEmptyTrackOverrideForDifferentTracks_hasNoEffect.
/**
* Tests that an empty override is not applied for a different set of available track groups.
*/
@Test
public void selectTracks_withEmptyTrackOverrideForDifferentTracks_hasNoEffect() throws ExoPlaybackException {
TrackGroup videoGroup0 = VIDEO_TRACK_GROUP.copyWithId("0");
TrackGroup videoGroup1 = VIDEO_TRACK_GROUP.copyWithId("1");
trackSelector.setParameters(trackSelector.buildUponParameters().setTrackSelectionOverrides(new TrackSelectionOverrides.Builder().setOverrideForType(new TrackSelectionOverride(new TrackGroup(VIDEO_FORMAT, VIDEO_FORMAT), ImmutableList.of())).build()));
TrackSelectorResult result = trackSelector.selectTracks(RENDERER_CAPABILITIES, new TrackGroupArray(videoGroup0, AUDIO_TRACK_GROUP, videoGroup1), periodId, TIMELINE);
assertThat(result.selections).asList().containsExactly(new FixedTrackSelection(videoGroup0, /* track= */
0), new FixedTrackSelection(AUDIO_TRACK_GROUP, /* track= */
0)).inOrder();
assertThat(result.rendererConfigurations).isEqualTo(new RendererConfiguration[] { DEFAULT, DEFAULT });
}
Aggregations