use of com.google.android.exoplayer2.RendererCapabilities 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.RendererCapabilities 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);
}
use of com.google.android.exoplayer2.RendererCapabilities in project ExoPlayer by google.
the class DefaultTrackSelectorTest method selectTracksWithMultipleVideoTracks.
@Test
public void selectTracksWithMultipleVideoTracks() throws Exception {
Format.Builder formatBuilder = VIDEO_FORMAT.buildUpon();
TrackGroupArray trackGroups = singleTrackGroup(formatBuilder.setId("0").build(), formatBuilder.setId("1").build());
TrackSelectorResult 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 selectTracksSelectPreferredAudioLanguageOverSelectionFlag.
/**
* Tests that track selector will prefer selecting audio track with language that match preferred
* language given by {@link Parameters} over track with {@link C#SELECTION_FLAG_DEFAULT}.
*/
@Test
public void selectTracksSelectPreferredAudioLanguageOverSelectionFlag() throws Exception {
Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
Format frDefaultFormat = formatBuilder.setLanguage("fra").setSelectionFlags(C.SELECTION_FLAG_DEFAULT).build();
Format enNonDefaultFormat = formatBuilder.setLanguage("eng").setSelectionFlags(0).build();
TrackGroupArray trackGroups = wrapFormats(frDefaultFormat, enNonDefaultFormat);
trackSelector.setParameters(defaultParameters.buildUpon().setPreferredAudioLanguage("eng"));
TrackSelectorResult result = trackSelector.selectTracks(new RendererCapabilities[] { ALL_AUDIO_FORMAT_SUPPORTED_RENDERER_CAPABILITIES }, trackGroups, periodId, TIMELINE);
assertFixedSelection(result.selections[0], trackGroups, enNonDefaultFormat);
}
use of com.google.android.exoplayer2.RendererCapabilities in project ExoPlayer by google.
the class DefaultTrackSelectorTest method selectPreferredAudioTrackMultipleRenderers.
/**
* Tests audio track selection when there are multiple audio renderers.
*/
@Test
public void selectPreferredAudioTrackMultipleRenderers() throws Exception {
Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
Format english = formatBuilder.setId("en").setLanguage("en").build();
Format german = formatBuilder.setId("de").setLanguage("de").build();
// First renderer handles english.
Map<String, Integer> firstRendererMappedCapabilities = new HashMap<>();
firstRendererMappedCapabilities.put(english.id, FORMAT_HANDLED);
firstRendererMappedCapabilities.put(german.id, FORMAT_UNSUPPORTED_SUBTYPE);
RendererCapabilities firstRendererCapabilities = new FakeMappedRendererCapabilities(C.TRACK_TYPE_AUDIO, firstRendererMappedCapabilities);
// Second renderer handles german.
Map<String, Integer> secondRendererMappedCapabilities = new HashMap<>();
secondRendererMappedCapabilities.put(english.id, FORMAT_UNSUPPORTED_SUBTYPE);
secondRendererMappedCapabilities.put(german.id, FORMAT_HANDLED);
RendererCapabilities secondRendererCapabilities = new FakeMappedRendererCapabilities(C.TRACK_TYPE_AUDIO, secondRendererMappedCapabilities);
RendererCapabilities[] rendererCapabilities = new RendererCapabilities[] { firstRendererCapabilities, secondRendererCapabilities };
// Without an explicit language preference, prefer the first renderer.
TrackGroupArray trackGroups = wrapFormats(english, german);
TrackSelectorResult result = trackSelector.selectTracks(rendererCapabilities, trackGroups, periodId, TIMELINE);
assertFixedSelection(result.selections[0], trackGroups, english);
assertNoSelection(result.selections[1]);
// Explicit language preference for english. First renderer should be used.
trackSelector.setParameters(defaultParameters.buildUpon().setPreferredAudioLanguage("en"));
result = trackSelector.selectTracks(rendererCapabilities, trackGroups, periodId, TIMELINE);
assertFixedSelection(result.selections[0], trackGroups, english);
assertNoSelection(result.selections[1]);
// Explicit language preference for German. Second renderer should be used.
trackSelector.setParameters(defaultParameters.buildUpon().setPreferredAudioLanguage("de"));
result = trackSelector.selectTracks(rendererCapabilities, trackGroups, periodId, TIMELINE);
assertNoSelection(result.selections[0]);
assertFixedSelection(result.selections[1], trackGroups, german);
}
Aggregations