use of com.google.android.exoplayer2.trackselection.TrackSelectorResult in project ExoPlayer by google.
the class DefaultTrackSelectorTest method selectTracksWithMultipleAudioTracksOverrideReturnsAdaptiveTrackSelection.
@Test
public void selectTracksWithMultipleAudioTracksOverrideReturnsAdaptiveTrackSelection() throws Exception {
Format.Builder formatBuilder = AUDIO_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[] { AUDIO_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 selectTrack_withMixedEmptyAndNonEmptyTrackOverrides_appliesNonEmptyOverride.
@Test
public void selectTrack_withMixedEmptyAndNonEmptyTrackOverrides_appliesNonEmptyOverride() throws Exception {
TrackGroup videoGroupHighBitrate = new TrackGroup(VIDEO_FORMAT.buildUpon().setAverageBitrate(1_000_000).build());
TrackGroup videoGroupMidBitrate = new TrackGroup(VIDEO_FORMAT.buildUpon().setAverageBitrate(500_000).build());
TrackGroup videoGroupLowBitrate = new TrackGroup(VIDEO_FORMAT.buildUpon().setAverageBitrate(100_000).build());
trackSelector.setParameters(trackSelector.buildUponParameters().setTrackSelectionOverrides(new TrackSelectionOverrides.Builder().addOverride(new TrackSelectionOverride(videoGroupHighBitrate, /* trackIndices= */
ImmutableList.of())).addOverride(new TrackSelectionOverride(videoGroupMidBitrate, /* trackIndices= */
ImmutableList.of(0))).addOverride(new TrackSelectionOverride(videoGroupLowBitrate, /* trackIndices= */
ImmutableList.of())).build()));
TrackSelectorResult result = trackSelector.selectTracks(RENDERER_CAPABILITIES, new TrackGroupArray(videoGroupHighBitrate, videoGroupMidBitrate, videoGroupLowBitrate), periodId, TIMELINE);
assertThat(result.selections).asList().containsExactly(new FixedTrackSelection(videoGroupMidBitrate, /* track= */
0), null).inOrder();
}
use of com.google.android.exoplayer2.trackselection.TrackSelectorResult in project ExoPlayer by google.
the class DefaultTrackSelectorTest method selectTracksExceedingCapabilitiesSelectLowerNumChannel.
/**
* Tests that track selector will select audio tracks with lower num channel when other factors
* are the same, and tracks exceed renderer's capabilities.
*/
@Test
public void selectTracksExceedingCapabilitiesSelectLowerNumChannel() throws Exception {
Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
Format higherChannelFormat = formatBuilder.setChannelCount(6).build();
Format lowerChannelFormat = formatBuilder.setChannelCount(2).build();
TrackGroupArray trackGroups = wrapFormats(higherChannelFormat, lowerChannelFormat);
TrackSelectorResult result = trackSelector.selectTracks(new RendererCapabilities[] { ALL_AUDIO_FORMAT_EXCEEDED_RENDERER_CAPABILITIES }, trackGroups, periodId, TIMELINE);
assertFixedSelection(result.selections[0], trackGroups, lowerChannelFormat);
}
use of com.google.android.exoplayer2.trackselection.TrackSelectorResult in project ExoPlayer by google.
the class DefaultTrackSelectorTest method selectTracksExceedingCapabilitiesSelectLowerSampleRate.
/**
* Tests that track selector will select audio tracks with lower sample rate when other factors
* are the same, and tracks exceed renderer's capabilities.
*/
@Test
public void selectTracksExceedingCapabilitiesSelectLowerSampleRate() throws Exception {
Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
Format lowerSampleRateFormat = formatBuilder.setSampleRate(22050).build();
Format higherSampleRateFormat = formatBuilder.setSampleRate(44100).build();
TrackGroupArray trackGroups = wrapFormats(higherSampleRateFormat, lowerSampleRateFormat);
TrackSelectorResult result = trackSelector.selectTracks(new RendererCapabilities[] { ALL_AUDIO_FORMAT_EXCEEDED_RENDERER_CAPABILITIES }, trackGroups, periodId, TIMELINE);
assertFixedSelection(result.selections[0], trackGroups, lowerSampleRateFormat);
}
use of com.google.android.exoplayer2.trackselection.TrackSelectorResult in project ExoPlayer by google.
the class DefaultTrackSelectorTest method selectTracksSelectPreferredAudioLanguage.
/**
* Tests that track selector will select audio track with language that match preferred language
* given by {@link Parameters}.
*/
@Test
public void selectTracksSelectPreferredAudioLanguage() throws Exception {
Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
Format frAudioFormat = formatBuilder.setLanguage("fra").build();
Format enAudioFormat = formatBuilder.setLanguage("eng").build();
TrackGroupArray trackGroups = wrapFormats(frAudioFormat, enAudioFormat);
trackSelector.setParameters(defaultParameters.buildUpon().setPreferredAudioLanguage("eng"));
TrackSelectorResult result = trackSelector.selectTracks(new RendererCapabilities[] { ALL_AUDIO_FORMAT_SUPPORTED_RENDERER_CAPABILITIES }, wrapFormats(frAudioFormat, enAudioFormat), periodId, TIMELINE);
assertFixedSelection(result.selections[0], trackGroups, enAudioFormat);
}
Aggregations