Search in sources :

Example 11 with TrackSelectionOverride

use of com.google.android.exoplayer2.trackselection.TrackSelectionOverrides.TrackSelectionOverride in project ExoPlayer by google.

the class TrackSelectionOverridesTest method newTrackSelectionOverride_withJustTrackGroup_selectsAllTracks.

@Test
public void newTrackSelectionOverride_withJustTrackGroup_selectsAllTracks() {
    TrackSelectionOverride trackSelectionOverride = new TrackSelectionOverride(newTrackGroupWithIds(1, 2));
    assertThat(trackSelectionOverride.trackGroup).isEqualTo(newTrackGroupWithIds(1, 2));
    assertThat(trackSelectionOverride.trackIndices).containsExactly(0, 1).inOrder();
}
Also used : TrackSelectionOverride(com.google.android.exoplayer2.trackselection.TrackSelectionOverrides.TrackSelectionOverride) Test(org.junit.Test)

Example 12 with TrackSelectionOverride

use of com.google.android.exoplayer2.trackselection.TrackSelectionOverrides.TrackSelectionOverride in project ExoPlayer by google.

the class TrackSelectionOverridesTest method clearOverride_ofTypeGroup_removesOverride.

@Test
public void clearOverride_ofTypeGroup_removesOverride() {
    TrackSelectionOverride override1 = new TrackSelectionOverride(AAC_TRACK_GROUP);
    TrackSelectionOverride override2 = new TrackSelectionOverride(newTrackGroupWithIds(1));
    TrackSelectionOverrides trackSelectionOverrides = new TrackSelectionOverrides.Builder().addOverride(override1).addOverride(override2).clearOverride(override2.trackGroup).build();
    assertThat(trackSelectionOverrides.asList()).containsExactly(override1);
    assertThat(trackSelectionOverrides.getOverride(override1.trackGroup)).isEqualTo(override1);
}
Also used : TrackSelectionOverride(com.google.android.exoplayer2.trackselection.TrackSelectionOverrides.TrackSelectionOverride) Test(org.junit.Test)

Example 13 with TrackSelectionOverride

use of com.google.android.exoplayer2.trackselection.TrackSelectionOverrides.TrackSelectionOverride in project ExoPlayer by google.

the class TrackSelectionOverridesTest method addOverride_onDifferentGroups_addsOverride.

@Test
public void addOverride_onDifferentGroups_addsOverride() {
    TrackSelectionOverride override1 = new TrackSelectionOverride(newTrackGroupWithIds(1));
    TrackSelectionOverride override2 = new TrackSelectionOverride(newTrackGroupWithIds(2));
    TrackSelectionOverrides trackSelectionOverrides = new TrackSelectionOverrides.Builder().addOverride(override1).addOverride(override2).build();
    assertThat(trackSelectionOverrides.asList()).containsExactly(override1, override2);
    assertThat(trackSelectionOverrides.getOverride(override1.trackGroup)).isEqualTo(override1);
    assertThat(trackSelectionOverrides.getOverride(override2.trackGroup)).isEqualTo(override2);
}
Also used : TrackSelectionOverride(com.google.android.exoplayer2.trackselection.TrackSelectionOverrides.TrackSelectionOverride) Test(org.junit.Test)

Example 14 with TrackSelectionOverride

use of com.google.android.exoplayer2.trackselection.TrackSelectionOverrides.TrackSelectionOverride in project ExoPlayer by google.

the class TrackSelectionOverridesTest method newTrackSelectionOverride_withTracks_selectsOnlySpecifiedTracks.

@Test
public void newTrackSelectionOverride_withTracks_selectsOnlySpecifiedTracks() {
    TrackSelectionOverride trackSelectionOverride = new TrackSelectionOverride(newTrackGroupWithIds(1, 2), ImmutableList.of(1));
    assertThat(trackSelectionOverride.trackGroup).isEqualTo(newTrackGroupWithIds(1, 2));
    assertThat(trackSelectionOverride.trackIndices).containsExactly(1);
}
Also used : TrackSelectionOverride(com.google.android.exoplayer2.trackselection.TrackSelectionOverrides.TrackSelectionOverride) Test(org.junit.Test)

Example 15 with TrackSelectionOverride

use of com.google.android.exoplayer2.trackselection.TrackSelectionOverrides.TrackSelectionOverride in project ExoPlayer by google.

the class DefaultTrackSelectorTest method selectTrack_withMixedEmptyAndNonEmptyTrackOverrides_appliesNonEmptyOverride.

@Test
public void selectTrack_withMixedEmptyAndNonEmptyTrackOverrides_appliesNonEmptyOverride() throws Exception {
    TrackGroup videoGroupHighBitrate = new TrackGroup(VIDEO_FORMAT.buildUpon().setAverageBitrate(1_000_000).build());
    TrackGroup videoGroupMidBitrate = new TrackGroup(VIDEO_FORMAT.buildUpon().setAverageBitrate(500_000).build());
    TrackGroup videoGroupLowBitrate = new TrackGroup(VIDEO_FORMAT.buildUpon().setAverageBitrate(100_000).build());
    trackSelector.setParameters(trackSelector.buildUponParameters().setTrackSelectionOverrides(new TrackSelectionOverrides.Builder().addOverride(new TrackSelectionOverride(videoGroupHighBitrate, /* trackIndices= */
    ImmutableList.of())).addOverride(new TrackSelectionOverride(videoGroupMidBitrate, /* trackIndices= */
    ImmutableList.of(0))).addOverride(new TrackSelectionOverride(videoGroupLowBitrate, /* trackIndices= */
    ImmutableList.of())).build()));
    TrackSelectorResult result = trackSelector.selectTracks(RENDERER_CAPABILITIES, new TrackGroupArray(videoGroupHighBitrate, videoGroupMidBitrate, videoGroupLowBitrate), periodId, TIMELINE);
    assertThat(result.selections).asList().containsExactly(new FixedTrackSelection(videoGroupMidBitrate, /* track= */
    0), null).inOrder();
}
Also used : TrackGroup(com.google.android.exoplayer2.source.TrackGroup) ParametersBuilder(com.google.android.exoplayer2.trackselection.DefaultTrackSelector.ParametersBuilder) TrackGroupArray(com.google.android.exoplayer2.source.TrackGroupArray) TrackSelectionOverride(com.google.android.exoplayer2.trackselection.TrackSelectionOverrides.TrackSelectionOverride) Test(org.junit.Test)

Aggregations

TrackSelectionOverride (com.google.android.exoplayer2.trackselection.TrackSelectionOverrides.TrackSelectionOverride)16 Test (org.junit.Test)14 TrackGroup (com.google.android.exoplayer2.source.TrackGroup)6 TrackGroupArray (com.google.android.exoplayer2.source.TrackGroupArray)5 ParametersBuilder (com.google.android.exoplayer2.trackselection.DefaultTrackSelector.ParametersBuilder)4 SuppressLint (android.annotation.SuppressLint)3 Point (android.graphics.Point)3 Pair (android.util.Pair)2 Format (com.google.android.exoplayer2.Format)2 RendererCapabilities (com.google.android.exoplayer2.RendererCapabilities)2 SparseArray (android.util.SparseArray)1 Nullable (androidx.annotation.Nullable)1 RendererConfiguration (com.google.android.exoplayer2.RendererConfiguration)1 NullableType (org.checkerframework.checker.nullness.compatqual.NullableType)1