use of com.google.android.exoplayer2.trackselection.TrackSelectorResult in project ExoPlayer by google.
the class DefaultTrackSelectorTest method selectTracks_withOverrideForUnmappedGroup_disablesAllRenderersOfSameType.
@Test
public void selectTracks_withOverrideForUnmappedGroup_disablesAllRenderersOfSameType() throws Exception {
Format audioSupported = AUDIO_FORMAT.buildUpon().setId("supported").build();
Format audioUnsupported = AUDIO_FORMAT.buildUpon().setId("unsupported").build();
TrackGroup audioGroupSupported = new TrackGroup(audioSupported);
TrackGroup audioGroupUnsupported = new TrackGroup(audioUnsupported);
Map<String, Integer> audioRendererCapabilitiesMap = ImmutableMap.of(audioSupported.id, FORMAT_HANDLED, audioUnsupported.id, FORMAT_UNSUPPORTED_TYPE);
RendererCapabilities audioRendererCapabilties = new FakeMappedRendererCapabilities(C.TRACK_TYPE_AUDIO, audioRendererCapabilitiesMap);
trackSelector.setParameters(trackSelector.buildUponParameters().setTrackSelectionOverrides(new TrackSelectionOverrides.Builder().setOverrideForType(new TrackSelectionOverride(audioGroupUnsupported)).build()));
TrackSelectorResult result = trackSelector.selectTracks(new RendererCapabilities[] { VIDEO_CAPABILITIES, audioRendererCapabilties }, new TrackGroupArray(VIDEO_TRACK_GROUP, audioGroupSupported, audioGroupUnsupported), periodId, TIMELINE);
assertThat(result.selections).asList().containsExactly(VIDEO_TRACK_SELECTION, null).inOrder();
}
use of com.google.android.exoplayer2.trackselection.TrackSelectorResult in project ExoPlayer by google.
the class DefaultTrackSelectorTest method selectAdaptiveAudioTrackGroupWithMaxBitrate.
/**
* Tests that adaptive audio track selections respect the maximum audio bitrate.
*/
@Test
public void selectAdaptiveAudioTrackGroupWithMaxBitrate() throws ExoPlaybackException {
Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
Format format128k = formatBuilder.setAverageBitrate(128 * 1024).build();
Format format192k = formatBuilder.setAverageBitrate(192 * 1024).build();
Format format256k = formatBuilder.setAverageBitrate(256 * 1024).build();
RendererCapabilities[] rendererCapabilities = { ALL_AUDIO_FORMAT_SUPPORTED_RENDERER_CAPABILITIES };
TrackGroupArray trackGroups = new TrackGroupArray(new TrackGroup(format192k, format128k, format256k));
TrackSelectorResult result = trackSelector.selectTracks(rendererCapabilities, trackGroups, periodId, TIMELINE);
assertAdaptiveSelection(result.selections[0], trackGroups.get(0), 2, 0, 1);
trackSelector.setParameters(trackSelector.buildUponParameters().setMaxAudioBitrate(256 * 1024 - 1));
result = trackSelector.selectTracks(rendererCapabilities, trackGroups, periodId, TIMELINE);
assertAdaptiveSelection(result.selections[0], trackGroups.get(0), 0, 1);
trackSelector.setParameters(trackSelector.buildUponParameters().setMaxAudioBitrate(192 * 1024));
result = trackSelector.selectTracks(rendererCapabilities, trackGroups, periodId, TIMELINE);
assertAdaptiveSelection(result.selections[0], trackGroups.get(0), 0, 1);
trackSelector.setParameters(trackSelector.buildUponParameters().setMaxAudioBitrate(192 * 1024 - 1));
result = trackSelector.selectTracks(rendererCapabilities, trackGroups, periodId, TIMELINE);
assertFixedSelection(result.selections[0], trackGroups.get(0), 1);
trackSelector.setParameters(trackSelector.buildUponParameters().setMaxAudioBitrate(10));
result = trackSelector.selectTracks(rendererCapabilities, trackGroups, periodId, TIMELINE);
assertFixedSelection(result.selections[0], trackGroups.get(0), 1);
}
use of com.google.android.exoplayer2.trackselection.TrackSelectorResult in project ExoPlayer by google.
the class DefaultTrackSelectorTest method selectTrack_withOverrideForDifferentRenderer_clearsDefaultSelectionOfSameType.
@Test
public void selectTrack_withOverrideForDifferentRenderer_clearsDefaultSelectionOfSameType() throws Exception {
Format videoFormatH264 = VIDEO_FORMAT.buildUpon().setId("H264").setSampleMimeType(MimeTypes.VIDEO_H264).build();
Format videoFormatAv1 = VIDEO_FORMAT.buildUpon().setId("AV1").setSampleMimeType(MimeTypes.VIDEO_AV1).build();
TrackGroup videoGroupH264 = new TrackGroup(videoFormatH264);
TrackGroup videoGroupAv1 = new TrackGroup(videoFormatAv1);
Map<String, Integer> rendererCapabilitiesMap = ImmutableMap.of(videoFormatH264.id, FORMAT_HANDLED, videoFormatAv1.id, FORMAT_UNSUPPORTED_TYPE);
RendererCapabilities rendererCapabilitiesH264 = new FakeMappedRendererCapabilities(C.TRACK_TYPE_VIDEO, rendererCapabilitiesMap);
rendererCapabilitiesMap = ImmutableMap.of(videoFormatH264.id, FORMAT_UNSUPPORTED_TYPE, videoFormatAv1.id, FORMAT_HANDLED);
RendererCapabilities rendererCapabilitiesAv1 = new FakeMappedRendererCapabilities(C.TRACK_TYPE_VIDEO, rendererCapabilitiesMap);
// Try to force selection of one TrackGroup in both directions to ensure the default gets
// overridden without having to know what the default is.
trackSelector.setParameters(trackSelector.buildUponParameters().setTrackSelectionOverrides(new TrackSelectionOverrides.Builder().setOverrideForType(new TrackSelectionOverride(videoGroupH264)).build()));
TrackSelectorResult result = trackSelector.selectTracks(new RendererCapabilities[] { rendererCapabilitiesH264, rendererCapabilitiesAv1 }, new TrackGroupArray(videoGroupH264, videoGroupAv1), periodId, TIMELINE);
assertThat(result.selections).asList().containsExactly(new FixedTrackSelection(videoGroupH264, /* track= */
0), null).inOrder();
trackSelector.setParameters(trackSelector.buildUponParameters().setTrackSelectionOverrides(new TrackSelectionOverrides.Builder().setOverrideForType(new TrackSelectionOverride(videoGroupAv1)).build()));
result = trackSelector.selectTracks(new RendererCapabilities[] { rendererCapabilitiesH264, rendererCapabilitiesAv1 }, new TrackGroupArray(videoGroupH264, videoGroupAv1), periodId, TIMELINE);
assertThat(result.selections).asList().containsExactly(null, new FixedTrackSelection(videoGroupAv1, /* track= */
0)).inOrder();
}
use of com.google.android.exoplayer2.trackselection.TrackSelectorResult in project ExoPlayer by google.
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 com.google.android.exoplayer2.trackselection.TrackSelectorResult in project ExoPlayer by google.
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);
}
Aggregations