use of com.google.android.exoplayer2.trackselection.TrackSelectionOverrides.TrackSelectionOverride in project ExoPlayer by google.
the class DefaultTrackSelectorTest method selectTracks_withEmptyTrackOverrideForDifferentTracks_hasNoEffect.
/**
* Tests that an empty override is not applied for a different set of available track groups.
*/
@Test
public void selectTracks_withEmptyTrackOverrideForDifferentTracks_hasNoEffect() throws ExoPlaybackException {
TrackGroup videoGroup0 = VIDEO_TRACK_GROUP.copyWithId("0");
TrackGroup videoGroup1 = VIDEO_TRACK_GROUP.copyWithId("1");
trackSelector.setParameters(trackSelector.buildUponParameters().setTrackSelectionOverrides(new TrackSelectionOverrides.Builder().setOverrideForType(new TrackSelectionOverride(new TrackGroup(VIDEO_FORMAT, VIDEO_FORMAT), ImmutableList.of())).build()));
TrackSelectorResult result = trackSelector.selectTracks(RENDERER_CAPABILITIES, new TrackGroupArray(videoGroup0, AUDIO_TRACK_GROUP, videoGroup1), periodId, TIMELINE);
assertThat(result.selections).asList().containsExactly(new FixedTrackSelection(videoGroup0, /* track= */
0), new FixedTrackSelection(AUDIO_TRACK_GROUP, /* track= */
0)).inOrder();
assertThat(result.rendererConfigurations).isEqualTo(new RendererConfiguration[] { DEFAULT, DEFAULT });
}
use of com.google.android.exoplayer2.trackselection.TrackSelectionOverrides.TrackSelectionOverride 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.TrackSelectionOverrides.TrackSelectionOverride 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.TrackSelectionOverrides.TrackSelectionOverride in project ExoPlayer by google.
the class TrackSelectionOverridesTest method roundTripViaBundle_withOverrides_yieldsEqualInstance.
@Test
public void roundTripViaBundle_withOverrides_yieldsEqualInstance() {
TrackSelectionOverrides trackSelectionOverrides = new TrackSelectionOverrides.Builder().setOverrideForType(new TrackSelectionOverride(newTrackGroupWithIds(3, 4), ImmutableList.of(1))).addOverride(new TrackSelectionOverride(newTrackGroupWithIds(5, 6))).build();
TrackSelectionOverrides fromBundle = TrackSelectionOverrides.CREATOR.fromBundle(trackSelectionOverrides.toBundle());
assertThat(fromBundle).isEqualTo(trackSelectionOverrides);
assertThat(fromBundle.asList()).isEqualTo(trackSelectionOverrides.asList());
}
use of com.google.android.exoplayer2.trackselection.TrackSelectionOverrides.TrackSelectionOverride in project ExoPlayer by google.
the class TrackSelectionOverridesTest method clearOverridesOfType_ofTypeAudio_removesAudioOverride.
@Test
public void clearOverridesOfType_ofTypeAudio_removesAudioOverride() {
TrackSelectionOverride override1 = new TrackSelectionOverride(AAC_TRACK_GROUP);
TrackSelectionOverride override2 = new TrackSelectionOverride(newTrackGroupWithIds(1));
TrackSelectionOverrides trackSelectionOverrides = new TrackSelectionOverrides.Builder().addOverride(override1).addOverride(override2).clearOverridesOfType(C.TRACK_TYPE_AUDIO).build();
assertThat(trackSelectionOverrides.asList()).containsExactly(override2);
assertThat(trackSelectionOverrides.getOverride(override2.trackGroup)).isEqualTo(override2);
}
Aggregations