use of com.google.android.exoplayer2.trackselection.DefaultTrackSelector.Parameters 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);
}
use of com.google.android.exoplayer2.trackselection.DefaultTrackSelector.Parameters in project ExoPlayer by google.
the class DefaultTrackSelector method getLegacyRendererOverride.
// Calling deprecated getSelectionOverride.
@SuppressWarnings("deprecation")
private ExoTrackSelection.@NullableType Definition getLegacyRendererOverride(MappedTrackInfo mappedTrackInfo, Parameters params, int rendererIndex) {
TrackGroupArray rendererTrackGroups = mappedTrackInfo.getTrackGroups(rendererIndex);
@Nullable SelectionOverride override = params.getSelectionOverride(rendererIndex, rendererTrackGroups);
if (override == null) {
return null;
}
return new ExoTrackSelection.Definition(rendererTrackGroups.get(override.groupIndex), override.tracks, override.type);
}
use of com.google.android.exoplayer2.trackselection.DefaultTrackSelector.Parameters in project ExoPlayer by google.
the class DefaultTrackSelectorTest method selectTracksSelectTrackWithSelectionFlag.
/**
* Tests that track selector will select audio track with {@link C#SELECTION_FLAG_DEFAULT} given
* default values of {@link Parameters}.
*/
@Test
public void selectTracksSelectTrackWithSelectionFlag() throws Exception {
Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
Format audioFormat = formatBuilder.setSelectionFlags(0).build();
Format formatWithSelectionFlag = formatBuilder.setSelectionFlags(C.SELECTION_FLAG_DEFAULT).build();
TrackGroupArray trackGroups = wrapFormats(audioFormat, formatWithSelectionFlag);
TrackSelectorResult result = trackSelector.selectTracks(new RendererCapabilities[] { ALL_AUDIO_FORMAT_SUPPORTED_RENDERER_CAPABILITIES }, trackGroups, periodId, TIMELINE);
assertFixedSelection(result.selections[0], trackGroups, formatWithSelectionFlag);
}
use of com.google.android.exoplayer2.trackselection.DefaultTrackSelector.Parameters in project ExoPlayer by google.
the class DefaultTrackSelectorTest method setParameterWithSameParametersDoesNotNotifyInvalidationListenerAgain.
/**
* Tests that track selector will not call {@link
* InvalidationListener#onTrackSelectionsInvalidated()} again when it's set with the same values
* of {@link Parameters}.
*/
@Test
public void setParameterWithSameParametersDoesNotNotifyInvalidationListenerAgain() {
ParametersBuilder builder = defaultParameters.buildUpon().setPreferredAudioLanguage("eng");
trackSelector.setParameters(builder);
trackSelector.setParameters(builder);
verify(invalidationListener, times(1)).onTrackSelectionsInvalidated();
}
use of com.google.android.exoplayer2.trackselection.DefaultTrackSelector.Parameters in project ExoPlayer by google.
the class DefaultTrackSelectorTest method selectTracks_withoutPreferredAudioRoleFlagsOrDefaultTrack_selectsFirstTrack.
/**
* Tests that track selector with select the first audio track if no role flag preference is
* specified by {@link Parameters} and no default track exists.
*/
@Test
public void selectTracks_withoutPreferredAudioRoleFlagsOrDefaultTrack_selectsFirstTrack() throws Exception {
Format firstFormat = AUDIO_FORMAT;
Format roleFlagFormat = AUDIO_FORMAT.buildUpon().setRoleFlags(C.ROLE_FLAG_CAPTION).build();
TrackGroupArray trackGroups = wrapFormats(firstFormat, roleFlagFormat);
TrackSelectorResult result = trackSelector.selectTracks(new RendererCapabilities[] { ALL_AUDIO_FORMAT_SUPPORTED_RENDERER_CAPABILITIES }, trackGroups, periodId, TIMELINE);
assertFixedSelection(result.selections[0], trackGroups, firstFormat);
}
Aggregations