use of com.google.android.exoplayer2.trackselection.DefaultTrackSelector.Parameters in project ExoPlayer by google.
the class DefaultTrackSelectorTest method setParameterWithNonDefaultParameterNotifyInvalidationListener.
/**
* Tests that track selector will call {@link InvalidationListener#onTrackSelectionsInvalidated()}
* when it's set with non-default values of {@link Parameters}.
*/
@Test
public void setParameterWithNonDefaultParameterNotifyInvalidationListener() {
ParametersBuilder builder = defaultParameters.buildUpon().setPreferredAudioLanguage("eng");
trackSelector.setParameters(builder);
verify(invalidationListener).onTrackSelectionsInvalidated();
}
use of com.google.android.exoplayer2.trackselection.DefaultTrackSelector.Parameters in project ExoPlayer by google.
the class DefaultTrackSelectorTest method selectTracks_withPreferredTextRoleFlags_selectPreferredTrack.
/**
* Tests that track selector will select the text track with the highest number of matching role
* flags given by {@link Parameters}.
*/
@Test
public void selectTracks_withPreferredTextRoleFlags_selectPreferredTrack() throws Exception {
Format.Builder formatBuilder = TEXT_FORMAT.buildUpon();
Format noRoleFlags = formatBuilder.build();
Format lessRoleFlags = formatBuilder.setRoleFlags(C.ROLE_FLAG_CAPTION).build();
Format moreRoleFlags = formatBuilder.setRoleFlags(C.ROLE_FLAG_CAPTION | C.ROLE_FLAG_COMMENTARY | C.ROLE_FLAG_DUB).build();
TrackGroupArray trackGroups = wrapFormats(noRoleFlags, moreRoleFlags, lessRoleFlags);
trackSelector.setParameters(defaultParameters.buildUpon().setPreferredTextRoleFlags(C.ROLE_FLAG_CAPTION | C.ROLE_FLAG_COMMENTARY));
TrackSelectorResult result = trackSelector.selectTracks(new RendererCapabilities[] { ALL_TEXT_FORMAT_SUPPORTED_RENDERER_CAPABILITIES }, trackGroups, periodId, TIMELINE);
assertFixedSelection(result.selections[0], trackGroups, moreRoleFlags);
// Also verify that exact match between parameters and tracks is preferred.
trackSelector.setParameters(defaultParameters.buildUpon().setPreferredTextRoleFlags(C.ROLE_FLAG_CAPTION));
result = trackSelector.selectTracks(new RendererCapabilities[] { ALL_TEXT_FORMAT_SUPPORTED_RENDERER_CAPABILITIES }, trackGroups, periodId, TIMELINE);
assertFixedSelection(result.selections[0], trackGroups, lessRoleFlags);
}
use of com.google.android.exoplayer2.trackselection.DefaultTrackSelector.Parameters in project ExoPlayer by google.
the class DefaultTrackSelectorTest method selectTracksPreferTrackWithinCapabilitiesOverSelectionFlagAndPreferredLanguage.
/**
* Tests that track selector will prefer tracks that are within renderer's capabilities over track
* that have both language matching preferred audio given by {@link Parameters} and {@link
* C#SELECTION_FLAG_DEFAULT}, but exceed renderer's capabilities.
*/
@Test
public void selectTracksPreferTrackWithinCapabilitiesOverSelectionFlagAndPreferredLanguage() throws Exception {
Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
Format exceededDefaultSelectionEnFormat = formatBuilder.setId("exceededFormat").setSelectionFlags(C.SELECTION_FLAG_DEFAULT).setLanguage("eng").build();
Format supportedFrFormat = formatBuilder.setId("supportedFormat").setSelectionFlags(0).setLanguage("fra").build();
TrackGroupArray trackGroups = wrapFormats(exceededDefaultSelectionEnFormat, supportedFrFormat);
Map<String, Integer> mappedCapabilities = new HashMap<>();
mappedCapabilities.put(exceededDefaultSelectionEnFormat.id, FORMAT_EXCEEDS_CAPABILITIES);
mappedCapabilities.put(supportedFrFormat.id, FORMAT_HANDLED);
RendererCapabilities mappedAudioRendererCapabilities = new FakeMappedRendererCapabilities(C.TRACK_TYPE_AUDIO, mappedCapabilities);
trackSelector.setParameters(defaultParameters.buildUpon().setPreferredAudioLanguage("eng"));
TrackSelectorResult result = trackSelector.selectTracks(new RendererCapabilities[] { mappedAudioRendererCapabilities }, trackGroups, periodId, TIMELINE);
assertFixedSelection(result.selections[0], trackGroups, supportedFrFormat);
}
use of com.google.android.exoplayer2.trackselection.DefaultTrackSelector.Parameters in project ExoPlayer by google.
the class DefaultTrackSelectorTest method selectTracks_withPreferredAudioRoleFlags_selectPreferredTrack.
/**
* Tests that track selector will select the audio track with the highest number of matching role
* flags given by {@link Parameters}.
*/
@Test
public void selectTracks_withPreferredAudioRoleFlags_selectPreferredTrack() throws Exception {
Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
Format noRoleFlags = formatBuilder.build();
Format lessRoleFlags = formatBuilder.setRoleFlags(C.ROLE_FLAG_CAPTION).build();
Format moreRoleFlags = formatBuilder.setRoleFlags(C.ROLE_FLAG_CAPTION | C.ROLE_FLAG_COMMENTARY | C.ROLE_FLAG_DUB).build();
TrackGroupArray trackGroups = wrapFormats(noRoleFlags, moreRoleFlags, lessRoleFlags);
trackSelector.setParameters(defaultParameters.buildUpon().setPreferredAudioRoleFlags(C.ROLE_FLAG_CAPTION | C.ROLE_FLAG_COMMENTARY));
TrackSelectorResult result = trackSelector.selectTracks(new RendererCapabilities[] { ALL_AUDIO_FORMAT_SUPPORTED_RENDERER_CAPABILITIES }, trackGroups, periodId, TIMELINE);
assertFixedSelection(result.selections[0], trackGroups, moreRoleFlags);
// Also verify that exact match between parameters and tracks is preferred.
trackSelector.setParameters(defaultParameters.buildUpon().setPreferredAudioRoleFlags(C.ROLE_FLAG_CAPTION));
result = trackSelector.selectTracks(new RendererCapabilities[] { ALL_AUDIO_FORMAT_SUPPORTED_RENDERER_CAPABILITIES }, trackGroups, periodId, TIMELINE);
assertFixedSelection(result.selections[0], trackGroups, lessRoleFlags);
}
use of com.google.android.exoplayer2.trackselection.DefaultTrackSelector.Parameters in project ExoPlayer by google.
the class DefaultTrackSelectorTest method selectTracksWithNoTrackWithinCapabilitiesSelectExceededCapabilityTrack.
/**
* Tests that track selector will select a track that exceeds the renderer's capabilities when
* there are no other choice, given the default {@link Parameters}.
*/
@Test
public void selectTracksWithNoTrackWithinCapabilitiesSelectExceededCapabilityTrack() throws Exception {
TrackGroupArray trackGroups = singleTrackGroup(AUDIO_FORMAT);
TrackSelectorResult result = trackSelector.selectTracks(new RendererCapabilities[] { ALL_AUDIO_FORMAT_EXCEEDED_RENDERER_CAPABILITIES }, trackGroups, periodId, TIMELINE);
assertFixedSelection(result.selections[0], trackGroups, AUDIO_FORMAT);
}
Aggregations