use of androidx.media3.exoplayer.trackselection.TrackSelectorResult in project media by androidx.
the class DefaultTrackSelectorTest method selectTracksWithMultipleVideoTracksWithNonSeamlessAdaptiveness.
@Test
public void selectTracksWithMultipleVideoTracksWithNonSeamlessAdaptiveness() throws Exception {
FakeRendererCapabilities nonSeamlessVideoCapabilities = new FakeRendererCapabilities(C.TRACK_TYPE_VIDEO, RendererCapabilities.create(FORMAT_HANDLED, ADAPTIVE_NOT_SEAMLESS, TUNNELING_NOT_SUPPORTED));
// Should do non-seamless adaptiveness by default, so expect an adaptive selection.
Format.Builder formatBuilder = VIDEO_FORMAT.buildUpon();
TrackGroupArray trackGroups = singleTrackGroup(formatBuilder.setId("0").build(), formatBuilder.setId("1").build());
trackSelector.setParameters(defaultParameters.buildUpon().setAllowVideoNonSeamlessAdaptiveness(true));
TrackSelectorResult result = trackSelector.selectTracks(new RendererCapabilities[] { nonSeamlessVideoCapabilities }, trackGroups, periodId, TIMELINE);
assertThat(result.length).isEqualTo(1);
assertAdaptiveSelection(result.selections[0], trackGroups.get(0), 0, 1);
// If we explicitly disable non-seamless adaptiveness, expect a fixed selection.
trackSelector.setParameters(defaultParameters.buildUpon().setAllowVideoNonSeamlessAdaptiveness(false));
result = trackSelector.selectTracks(new RendererCapabilities[] { nonSeamlessVideoCapabilities }, trackGroups, periodId, TIMELINE);
assertThat(result.length).isEqualTo(1);
assertFixedSelection(result.selections[0], trackGroups.get(0), 0);
}
use of androidx.media3.exoplayer.trackselection.TrackSelectorResult in project media by androidx.
the class DefaultTrackSelectorTest method selectTracks_multipleRenderer_allSelected.
/**
* Tests audio track selection when there are multiple audio renderers.
*/
@Test
public void selectTracks_multipleRenderer_allSelected() throws Exception {
RendererCapabilities[] rendererCapabilities = new RendererCapabilities[] { VIDEO_CAPABILITIES, AUDIO_CAPABILITIES, AUDIO_CAPABILITIES };
TrackGroupArray trackGroups = new TrackGroupArray(AUDIO_TRACK_GROUP);
TrackSelectorResult result = trackSelector.selectTracks(rendererCapabilities, trackGroups, periodId, TIMELINE);
assertThat(result.length).isEqualTo(3);
assertThat(result.rendererConfigurations).asList().containsExactly(null, DEFAULT, null).inOrder();
assertThat(result.selections[0]).isNull();
assertFixedSelection(result.selections[1], trackGroups, trackGroups.get(0).getFormat(0));
assertThat(result.selections[2]).isNull();
ImmutableList<TracksInfo.TrackGroupInfo> trackGroupInfos = result.tracksInfo.getTrackGroupInfos();
assertThat(trackGroupInfos).hasSize(1);
assertThat(trackGroupInfos.get(0).getTrackGroup()).isEqualTo(AUDIO_TRACK_GROUP);
assertThat(trackGroupInfos.get(0).isTrackSelected(0)).isTrue();
assertThat(trackGroupInfos.get(0).getTrackSupport(0)).isEqualTo(FORMAT_HANDLED);
}
use of androidx.media3.exoplayer.trackselection.TrackSelectorResult in project media by androidx.
the class DefaultTrackSelectorTest method selectVideoAudioTracks_withDisabledAudioType_onlyVideoIsSelected.
/**
* Tests disabling a track type.
*/
@Test
public void selectVideoAudioTracks_withDisabledAudioType_onlyVideoIsSelected() throws ExoPlaybackException {
trackSelector.setParameters(defaultParameters.buildUpon().setDisabledTrackTypes(ImmutableSet.of(C.TRACK_TYPE_AUDIO)));
TrackSelectorResult result = trackSelector.selectTracks(RENDERER_CAPABILITIES, new TrackGroupArray(VIDEO_TRACK_GROUP, AUDIO_TRACK_GROUP), periodId, TIMELINE);
assertThat(result.selections).asList().containsExactly(VIDEO_TRACK_SELECTION, null).inOrder();
assertThat(result.rendererConfigurations).asList().containsExactly(DEFAULT, null);
}
use of androidx.media3.exoplayer.trackselection.TrackSelectorResult in project media by androidx.
the class DefaultTrackSelectorTest method selectTracksExceedingCapabilitiesPreferLowerNumChannelBeforeSampleRate.
/**
* Tests that track selector will prefer audio tracks with lower channel count over tracks with
* lower sample rate when other factors are the same, and tracks are within renderer's
* capabilities.
*/
@Test
public void selectTracksExceedingCapabilitiesPreferLowerNumChannelBeforeSampleRate() throws Exception {
Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
Format lowerChannelHigherSampleRateFormat = formatBuilder.setChannelCount(2).setSampleRate(44100).build();
Format higherChannelLowerSampleRateFormat = formatBuilder.setChannelCount(6).setSampleRate(22050).build();
TrackGroupArray trackGroups = wrapFormats(higherChannelLowerSampleRateFormat, lowerChannelHigherSampleRateFormat);
TrackSelectorResult result = trackSelector.selectTracks(new RendererCapabilities[] { ALL_AUDIO_FORMAT_EXCEEDED_RENDERER_CAPABILITIES }, trackGroups, periodId, TIMELINE);
assertFixedSelection(result.selections[0], trackGroups, lowerChannelHigherSampleRateFormat);
}
use of androidx.media3.exoplayer.trackselection.TrackSelectorResult in project media by androidx.
the class DefaultTrackSelectorTest method selectTracksWithinCapabilitiesSelectHigherSampleRate.
/**
* Tests that track selector will select audio tracks with higher sample rate when other factors
* are the same, and tracks are within renderer's capabilities.
*/
@Test
public void selectTracksWithinCapabilitiesSelectHigherSampleRate() throws Exception {
Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
Format higherSampleRateFormat = formatBuilder.setSampleRate(44100).build();
Format lowerSampleRateFormat = formatBuilder.setSampleRate(22050).build();
TrackGroupArray trackGroups = wrapFormats(higherSampleRateFormat, lowerSampleRateFormat);
TrackSelectorResult result = trackSelector.selectTracks(new RendererCapabilities[] { ALL_AUDIO_FORMAT_SUPPORTED_RENDERER_CAPABILITIES }, trackGroups, periodId, TIMELINE);
assertFixedSelection(result.selections[0], trackGroups, higherSampleRateFormat);
}
Aggregations