use of com.google.android.exoplayer2.trackselection.TrackSelectorResult in project ExoPlayer by google.
the class DefaultTrackSelectorTest method selectTracks_multipleVideoAndAudioTracks.
@Test
public void selectTracks_multipleVideoAndAudioTracks() throws Exception {
Format videoFormat1 = VIDEO_FORMAT.buildUpon().setAverageBitrate(1000).build();
Format videoFormat2 = VIDEO_FORMAT.buildUpon().setAverageBitrate(2000).build();
Format audioFormat1 = AUDIO_FORMAT.buildUpon().setAverageBitrate(100).build();
Format audioFormat2 = AUDIO_FORMAT.buildUpon().setAverageBitrate(200).build();
TrackGroupArray trackGroups = new TrackGroupArray(new TrackGroup(videoFormat1, videoFormat2), new TrackGroup(audioFormat1, audioFormat2));
// Multiple adaptive selections allowed.
trackSelector.setParameters(trackSelector.buildUponParameters().setAllowMultipleAdaptiveSelections(true));
TrackSelectorResult result = trackSelector.selectTracks(new RendererCapabilities[] { VIDEO_CAPABILITIES, AUDIO_CAPABILITIES }, trackGroups, periodId, TIMELINE);
assertThat(result.length).isEqualTo(2);
assertAdaptiveSelection(result.selections[0], trackGroups.get(0), /* expectedTracks...= */
1, 0);
assertAdaptiveSelection(result.selections[1], trackGroups.get(1), /* expectedTracks...= */
1, 0);
// Multiple adaptive selection disallowed.
trackSelector.setParameters(trackSelector.buildUponParameters().setAllowMultipleAdaptiveSelections(false));
result = trackSelector.selectTracks(new RendererCapabilities[] { VIDEO_CAPABILITIES, AUDIO_CAPABILITIES }, trackGroups, periodId, TIMELINE);
assertThat(result.length).isEqualTo(2);
assertAdaptiveSelection(result.selections[0], trackGroups.get(0), /* expectedTracks...= */
1, 0);
assertFixedSelection(result.selections[1], trackGroups.get(1), /* expectedTrack= */
1);
}
use of com.google.android.exoplayer2.trackselection.TrackSelectorResult in project ExoPlayer by google.
the class DefaultTrackSelectorTest method selectTracksWithNoTrackWithinCapabilitiesAndSetByParamsReturnNoSelection.
/**
* Tests that track selector will return a null track selection for a renderer when all tracks
* exceed that renderer's capabilities when {@link Parameters} does not allow
* exceeding-capabilities tracks.
*/
@Test
public void selectTracksWithNoTrackWithinCapabilitiesAndSetByParamsReturnNoSelection() throws Exception {
TrackGroupArray trackGroups = singleTrackGroup(AUDIO_FORMAT);
trackSelector.setParameters(defaultParameters.buildUpon().setExceedRendererCapabilitiesIfNecessary(false));
TrackSelectorResult result = trackSelector.selectTracks(new RendererCapabilities[] { ALL_AUDIO_FORMAT_EXCEEDED_RENDERER_CAPABILITIES }, trackGroups, periodId, TIMELINE);
assertNoSelection(result.selections[0]);
}
use of com.google.android.exoplayer2.trackselection.TrackSelectorResult in project ExoPlayer by google.
the class DefaultTrackSelectorTest method selectAudioTracks_withinCapabilities_andSameLanguage_selectsHigherBitrate.
/**
* Tests that track selector will select audio tracks with higher bit rate when other factors are
* the same, and tracks are within renderer's capabilities, and have the same language.
*/
@Test
public void selectAudioTracks_withinCapabilities_andSameLanguage_selectsHigherBitrate() throws Exception {
Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon().setLanguage("en");
Format lowerBitrateFormat = formatBuilder.setAverageBitrate(15000).build();
Format higherBitrateFormat = formatBuilder.setAverageBitrate(30000).build();
TrackGroupArray trackGroups = wrapFormats(lowerBitrateFormat, higherBitrateFormat);
TrackSelectorResult result = trackSelector.selectTracks(new RendererCapabilities[] { ALL_AUDIO_FORMAT_SUPPORTED_RENDERER_CAPABILITIES }, trackGroups, periodId, TIMELINE);
assertFixedSelection(result.selections[0], trackGroups, higherBitrateFormat);
}
use of com.google.android.exoplayer2.trackselection.TrackSelectorResult 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.trackselection.TrackSelectorResult 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);
}
Aggregations