Search in sources :

Example 1 with TrackSelectionOverride

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

the class TrackSelectionParametersTest method parametersSet_fromDefault_isAsExpected.

@Test
public void parametersSet_fromDefault_isAsExpected() {
    TrackSelectionOverrides trackSelectionOverrides = new TrackSelectionOverrides.Builder().addOverride(new TrackSelectionOverride(new TrackGroup(new Format.Builder().build()))).addOverride(new TrackSelectionOverride(new TrackGroup(new Format.Builder().setId(4).build(), new Format.Builder().setId(5).build()), /* trackIndices= */
    ImmutableList.of(1))).build();
    TrackSelectionParameters parameters = TrackSelectionParameters.DEFAULT_WITHOUT_CONTEXT.buildUpon().setMaxVideoSize(/* maxVideoWidth= */
    0, /* maxVideoHeight= */
    1).setMaxVideoFrameRate(2).setMaxVideoBitrate(3).setMinVideoSize(/* minVideoWidth= */
    4, /* minVideoHeight= */
    5).setMinVideoFrameRate(6).setMinVideoBitrate(7).setViewportSize(/* viewportWidth= */
    8, /* viewportHeight= */
    9, /* viewportOrientationMayChange= */
    true).setPreferredVideoMimeTypes(MimeTypes.VIDEO_AV1, MimeTypes.VIDEO_H264).setPreferredAudioLanguages("zh", "jp").setPreferredAudioRoleFlags(C.ROLE_FLAG_COMMENTARY).setMaxAudioChannelCount(10).setMaxAudioBitrate(11).setPreferredAudioMimeTypes(MimeTypes.AUDIO_AC3, MimeTypes.AUDIO_E_AC3).setPreferredTextLanguages("de", "en").setPreferredTextRoleFlags(C.ROLE_FLAG_CAPTION).setSelectUndeterminedTextLanguage(true).setForceLowestBitrate(false).setForceHighestSupportedBitrate(true).setTrackSelectionOverrides(trackSelectionOverrides).setDisabledTrackTypes(ImmutableSet.of(C.TRACK_TYPE_AUDIO, C.TRACK_TYPE_TEXT)).build();
    // Video
    assertThat(parameters.maxVideoWidth).isEqualTo(0);
    assertThat(parameters.maxVideoHeight).isEqualTo(1);
    assertThat(parameters.maxVideoFrameRate).isEqualTo(2);
    assertThat(parameters.maxVideoBitrate).isEqualTo(3);
    assertThat(parameters.minVideoWidth).isEqualTo(4);
    assertThat(parameters.minVideoHeight).isEqualTo(5);
    assertThat(parameters.minVideoFrameRate).isEqualTo(6);
    assertThat(parameters.minVideoBitrate).isEqualTo(7);
    assertThat(parameters.viewportWidth).isEqualTo(8);
    assertThat(parameters.viewportHeight).isEqualTo(9);
    assertThat(parameters.viewportOrientationMayChange).isTrue();
    assertThat(parameters.preferredVideoMimeTypes).containsExactly(MimeTypes.VIDEO_AV1, MimeTypes.VIDEO_H264).inOrder();
    // Audio
    assertThat(parameters.preferredAudioLanguages).containsExactly("zh", "jp").inOrder();
    assertThat(parameters.preferredAudioRoleFlags).isEqualTo(C.ROLE_FLAG_COMMENTARY);
    assertThat(parameters.maxAudioChannelCount).isEqualTo(10);
    assertThat(parameters.maxAudioBitrate).isEqualTo(11);
    assertThat(parameters.preferredAudioMimeTypes).containsExactly(MimeTypes.AUDIO_AC3, MimeTypes.AUDIO_E_AC3).inOrder();
    // Text
    assertThat(parameters.preferredTextLanguages).containsExactly("de", "en").inOrder();
    assertThat(parameters.preferredTextRoleFlags).isEqualTo(C.ROLE_FLAG_CAPTION);
    assertThat(parameters.selectUndeterminedTextLanguage).isTrue();
    // General
    assertThat(parameters.forceLowestBitrate).isFalse();
    assertThat(parameters.forceHighestSupportedBitrate).isTrue();
    assertThat(parameters.trackSelectionOverrides).isEqualTo(trackSelectionOverrides);
    assertThat(parameters.disabledTrackTypes).containsExactly(C.TRACK_TYPE_AUDIO, C.TRACK_TYPE_TEXT);
}
Also used : TrackGroup(com.google.android.exoplayer2.source.TrackGroup) TrackSelectionOverride(com.google.android.exoplayer2.trackselection.TrackSelectionOverrides.TrackSelectionOverride) Test(org.junit.Test)

Example 2 with TrackSelectionOverride

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

the class TrackSelectionOverridesTest method addOverride_onSameGroup_replacesOverride.

@Test
public void addOverride_onSameGroup_replacesOverride() {
    TrackGroup trackGroup = newTrackGroupWithIds(1, 2, 3);
    TrackSelectionOverride override1 = new TrackSelectionOverride(trackGroup, /* trackIndices= */
    ImmutableList.of(0));
    TrackSelectionOverride override2 = new TrackSelectionOverride(trackGroup, /* trackIndices= */
    ImmutableList.of(1));
    TrackSelectionOverrides trackSelectionOverrides = new TrackSelectionOverrides.Builder().addOverride(override1).addOverride(override2).build();
    assertThat(trackSelectionOverrides.asList()).containsExactly(override2);
    assertThat(trackSelectionOverrides.getOverride(override2.trackGroup)).isEqualTo(override2);
}
Also used : TrackGroup(com.google.android.exoplayer2.source.TrackGroup) TrackSelectionOverride(com.google.android.exoplayer2.trackselection.TrackSelectionOverrides.TrackSelectionOverride) Test(org.junit.Test)

Example 3 with TrackSelectionOverride

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

the class TrackSelectionOverridesTest method setOverrideForType_onSameType_replacesOverride.

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

Example 4 with TrackSelectionOverride

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

the class TrackSelectionOverridesTest method newTrackSelectionOverride_with0Tracks_selectsAllSpecifiedTracks.

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

Example 5 with TrackSelectionOverride

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

the class DefaultTrackSelector method maybeUpdateApplicableOverrides.

private void maybeUpdateApplicableOverrides(SparseArray<Pair<TrackSelectionOverride, Integer>> applicableOverrides, @Nullable TrackSelectionOverride override, int rendererIndex) {
    if (override == null) {
        return;
    }
    @C.TrackType int trackType = override.getTrackType();
    @Nullable Pair<TrackSelectionOverride, Integer> existingOverride = applicableOverrides.get(trackType);
    if (existingOverride == null || existingOverride.first.trackIndices.isEmpty()) {
        // We only need to choose one non-empty override per type.
        applicableOverrides.put(trackType, Pair.create(override, rendererIndex));
    }
}
Also used : TrackSelectionOverride(com.google.android.exoplayer2.trackselection.TrackSelectionOverrides.TrackSelectionOverride) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point) Nullable(androidx.annotation.Nullable)

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