use of androidx.media3.exoplayer.RendererCapabilities 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.RendererCapabilities 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.RendererCapabilities in project media by androidx.
the class MappingTrackSelectorTest method selectTracks_multipleVideoAndAudioTracks_mappedToSameRenderer.
@Test
public void selectTracks_multipleVideoAndAudioTracks_mappedToSameRenderer() throws ExoPlaybackException {
TrackGroup videoGroup0 = VIDEO_TRACK_GROUP.copyWithId("0");
TrackGroup videoGroup1 = VIDEO_TRACK_GROUP.copyWithId("1");
TrackGroup audioGroup0 = AUDIO_TRACK_GROUP.copyWithId("0");
TrackGroup audioGroup1 = AUDIO_TRACK_GROUP.copyWithId("1");
FakeMappingTrackSelector trackSelector = new FakeMappingTrackSelector();
TrackGroupArray trackGroups = new TrackGroupArray(videoGroup0, audioGroup0, audioGroup1, videoGroup1);
RendererCapabilities[] rendererCapabilities = new RendererCapabilities[] { VIDEO_CAPABILITIES, AUDIO_CAPABILITIES, VIDEO_CAPABILITIES, AUDIO_CAPABILITIES };
trackSelector.selectTracks(rendererCapabilities, trackGroups, periodId, TIMELINE);
trackSelector.assertMappedTrackGroups(0, videoGroup0, videoGroup1);
trackSelector.assertMappedTrackGroups(1, audioGroup0, audioGroup1);
}
use of androidx.media3.exoplayer.RendererCapabilities in project media by androidx.
the class MappingTrackSelectorTest method selectTracks_audioAndVideo_reverseOrderToRenderers_mappedToCorrectRenderer.
@Test
public void selectTracks_audioAndVideo_reverseOrderToRenderers_mappedToCorrectRenderer() throws ExoPlaybackException {
FakeMappingTrackSelector trackSelector = new FakeMappingTrackSelector();
TrackGroupArray trackGroups = new TrackGroupArray(VIDEO_TRACK_GROUP, AUDIO_TRACK_GROUP);
RendererCapabilities[] reverseOrderRendererCapabilities = new RendererCapabilities[] { AUDIO_CAPABILITIES, VIDEO_CAPABILITIES };
trackSelector.selectTracks(reverseOrderRendererCapabilities, trackGroups, periodId, TIMELINE);
trackSelector.assertMappedTrackGroups(/* rendererIndex= */
0, AUDIO_TRACK_GROUP);
trackSelector.assertMappedTrackGroups(/* rendererIndex= */
1, VIDEO_TRACK_GROUP);
}
use of androidx.media3.exoplayer.RendererCapabilities 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);
}
Aggregations