use of com.google.android.exoplayer2.RendererCapabilities in project ExoPlayer by google.
the class DefaultTrackSelectorTest method selectTracksWithMultipleVideoTracksWithMixedMimeTypes.
@Test
public void selectTracksWithMultipleVideoTracksWithMixedMimeTypes() throws Exception {
Format.Builder formatBuilder = VIDEO_FORMAT.buildUpon();
Format h264VideoFormat = formatBuilder.setSampleMimeType(MimeTypes.VIDEO_H264).build();
Format h265VideoFormat = formatBuilder.setSampleMimeType(MimeTypes.VIDEO_H265).build();
// Should not adapt between mixed mime types by default, so we expect a fixed selection
// containing the first stream.
TrackGroupArray trackGroups = singleTrackGroup(h264VideoFormat, h265VideoFormat);
TrackSelectorResult result = trackSelector.selectTracks(new RendererCapabilities[] { VIDEO_CAPABILITIES }, trackGroups, periodId, TIMELINE);
assertThat(result.length).isEqualTo(1);
assertFixedSelection(result.selections[0], trackGroups, h264VideoFormat);
// The same applies if the tracks are provided in the opposite order.
trackGroups = singleTrackGroup(h265VideoFormat, h264VideoFormat);
result = trackSelector.selectTracks(new RendererCapabilities[] { VIDEO_CAPABILITIES }, trackGroups, periodId, TIMELINE);
assertThat(result.length).isEqualTo(1);
assertFixedSelection(result.selections[0], trackGroups, h265VideoFormat);
// If we explicitly enable mixed mime type adaptiveness, expect an adaptive selection.
trackSelector.setParameters(defaultParameters.buildUpon().setAllowVideoMixedMimeTypeAdaptiveness(true));
result = trackSelector.selectTracks(new RendererCapabilities[] { VIDEO_CAPABILITIES }, trackGroups, periodId, TIMELINE);
assertThat(result.length).isEqualTo(1);
assertAdaptiveSelection(result.selections[0], trackGroups.get(0), 0, 1);
}
use of com.google.android.exoplayer2.RendererCapabilities in project ExoPlayer by google.
the class DefaultTrackSelectorTest method selectTracksWithMultipleAudioTracks.
@Test
public void selectTracksWithMultipleAudioTracks() throws Exception {
Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
TrackGroupArray trackGroups = singleTrackGroup(formatBuilder.setId("0").build(), formatBuilder.setId("1").build());
TrackSelectorResult result = trackSelector.selectTracks(new RendererCapabilities[] { AUDIO_CAPABILITIES }, trackGroups, periodId, TIMELINE);
assertThat(result.length).isEqualTo(1);
assertAdaptiveSelection(result.selections[0], trackGroups.get(0), 0, 1);
}
use of com.google.android.exoplayer2.RendererCapabilities in project ExoPlayer by google.
the class DefaultTrackSelectorTest method selectTracks_multipleAudioTracks_selectsAllTracksInBestConfigurationOnly.
@Test
public void selectTracks_multipleAudioTracks_selectsAllTracksInBestConfigurationOnly() throws Exception {
TrackGroupArray trackGroups = singleTrackGroup(buildAudioFormatWithConfiguration(/* id= */
"0", /* channelCount= */
6, MimeTypes.AUDIO_AAC, /* sampleRate= */
44100), buildAudioFormatWithConfiguration(/* id= */
"1", /* channelCount= */
2, MimeTypes.AUDIO_AAC, /* sampleRate= */
44100), buildAudioFormatWithConfiguration(/* id= */
"2", /* channelCount= */
6, MimeTypes.AUDIO_AC3, /* sampleRate= */
44100), buildAudioFormatWithConfiguration(/* id= */
"3", /* channelCount= */
6, MimeTypes.AUDIO_AAC, /* sampleRate= */
22050), buildAudioFormatWithConfiguration(/* id= */
"4", /* channelCount= */
6, MimeTypes.AUDIO_AAC, /* sampleRate= */
22050), buildAudioFormatWithConfiguration(/* id= */
"5", /* channelCount= */
6, MimeTypes.AUDIO_AAC, /* sampleRate= */
22050), buildAudioFormatWithConfiguration(/* id= */
"6", /* channelCount= */
6, MimeTypes.AUDIO_AAC, /* sampleRate= */
44100));
TrackSelectorResult result = trackSelector.selectTracks(new RendererCapabilities[] { AUDIO_CAPABILITIES }, trackGroups, periodId, TIMELINE);
assertThat(result.length).isEqualTo(1);
assertAdaptiveSelection(result.selections[0], trackGroups.get(0), 0, 6);
}
use of com.google.android.exoplayer2.RendererCapabilities in project ExoPlayer by google.
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);
}
use of com.google.android.exoplayer2.RendererCapabilities in project ExoPlayer by google.
the class DefaultTrackSelectorTest method selectUndeterminedTextLanguageAsFallback.
/**
* Tests that the default track selector will select a text track with undetermined language if no
* text track with the preferred language is available but {@link
* Parameters#selectUndeterminedTextLanguage} is true.
*/
@Test
public void selectUndeterminedTextLanguageAsFallback() throws ExoPlaybackException {
Format.Builder formatBuilder = TEXT_FORMAT.buildUpon();
Format spanish = formatBuilder.setLanguage("spa").build();
Format german = formatBuilder.setLanguage("de").build();
Format undeterminedUnd = formatBuilder.setLanguage(C.LANGUAGE_UNDETERMINED).build();
Format undeterminedNull = formatBuilder.setLanguage(null).build();
RendererCapabilities[] textRendererCapabilites = new RendererCapabilities[] { ALL_TEXT_FORMAT_SUPPORTED_RENDERER_CAPABILITIES };
TrackGroupArray trackGroups = wrapFormats(spanish, german, undeterminedUnd, undeterminedNull);
TrackSelectorResult result = trackSelector.selectTracks(textRendererCapabilites, trackGroups, periodId, TIMELINE);
assertNoSelection(result.selections[0]);
trackSelector.setParameters(defaultParameters.buildUpon().setSelectUndeterminedTextLanguage(true));
result = trackSelector.selectTracks(textRendererCapabilites, trackGroups, periodId, TIMELINE);
assertFixedSelection(result.selections[0], trackGroups, undeterminedUnd);
ParametersBuilder builder = defaultParameters.buildUpon().setPreferredTextLanguage("spa");
trackSelector.setParameters(builder);
result = trackSelector.selectTracks(textRendererCapabilites, trackGroups, periodId, TIMELINE);
assertFixedSelection(result.selections[0], trackGroups, spanish);
trackGroups = wrapFormats(german, undeterminedUnd, undeterminedNull);
result = trackSelector.selectTracks(textRendererCapabilites, trackGroups, periodId, TIMELINE);
assertNoSelection(result.selections[0]);
trackSelector.setParameters(builder.setSelectUndeterminedTextLanguage(true));
result = trackSelector.selectTracks(textRendererCapabilites, trackGroups, periodId, TIMELINE);
assertFixedSelection(result.selections[0], trackGroups, undeterminedUnd);
trackGroups = wrapFormats(german, undeterminedNull);
result = trackSelector.selectTracks(textRendererCapabilites, trackGroups, periodId, TIMELINE);
assertFixedSelection(result.selections[0], trackGroups, undeterminedNull);
trackGroups = wrapFormats(german);
result = trackSelector.selectTracks(textRendererCapabilites, trackGroups, periodId, TIMELINE);
assertNoSelection(result.selections[0]);
}
Aggregations