use of com.google.android.exoplayer2.source.TrackGroupArray in project ExoPlayer by google.
the class MetadataRetrieverTest method retrieveMetadata_sefSlowMotion_outputsExpectedMetadata.
@Test
public void retrieveMetadata_sefSlowMotion_outputsExpectedMetadata() throws Exception {
MediaItem mediaItem = MediaItem.fromUri(Uri.parse("asset://android_asset/media/mp4/sample_sef_slow_motion.mp4"));
SmtaMetadataEntry expectedSmtaEntry = new SmtaMetadataEntry(/* captureFrameRate= */
240, /* svcTemporalLayerCount= */
4);
List<SlowMotionData.Segment> segments = new ArrayList<>();
segments.add(new SlowMotionData.Segment(/* startTimeMs= */
88, /* endTimeMs= */
879, /* speedDivisor= */
2));
segments.add(new SlowMotionData.Segment(/* startTimeMs= */
1255, /* endTimeMs= */
1970, /* speedDivisor= */
8));
SlowMotionData expectedSlowMotionData = new SlowMotionData(segments);
MdtaMetadataEntry expectedMdtaEntry = new MdtaMetadataEntry(KEY_ANDROID_CAPTURE_FPS, /* value= */
new byte[] { 67, 112, 0, 0 }, /* localeIndicator= */
0, /* typeIndicator= */
23);
ListenableFuture<TrackGroupArray> trackGroupsFuture = retrieveMetadata(context, mediaItem, clock);
ShadowLooper.idleMainLooper();
TrackGroupArray trackGroups = trackGroupsFuture.get(TEST_TIMEOUT_SEC, TimeUnit.SECONDS);
// Video and audio
assertThat(trackGroups.length).isEqualTo(2);
// Audio
assertThat(trackGroups.get(0).getFormat(0).metadata.length()).isEqualTo(2);
assertThat(trackGroups.get(0).getFormat(0).metadata.get(0)).isEqualTo(expectedSmtaEntry);
assertThat(trackGroups.get(0).getFormat(0).metadata.get(1)).isEqualTo(expectedSlowMotionData);
// Video
assertThat(trackGroups.get(1).getFormat(0).metadata.length()).isEqualTo(3);
assertThat(trackGroups.get(1).getFormat(0).metadata.get(0)).isEqualTo(expectedMdtaEntry);
assertThat(trackGroups.get(1).getFormat(0).metadata.get(1)).isEqualTo(expectedSmtaEntry);
assertThat(trackGroups.get(1).getFormat(0).metadata.get(2)).isEqualTo(expectedSlowMotionData);
}
use of com.google.android.exoplayer2.source.TrackGroupArray in project ExoPlayer by google.
the class TrackSelectionDialog method init.
private void init(int titleId, MappedTrackInfo mappedTrackInfo, DefaultTrackSelector.Parameters initialParameters, boolean allowAdaptiveSelections, boolean allowMultipleOverrides, DialogInterface.OnClickListener onClickListener, DialogInterface.OnDismissListener onDismissListener) {
this.titleId = titleId;
this.onClickListener = onClickListener;
this.onDismissListener = onDismissListener;
for (int i = 0; i < mappedTrackInfo.getRendererCount(); i++) {
if (showTabForRenderer(mappedTrackInfo, i)) {
int trackType = mappedTrackInfo.getRendererType(/* rendererIndex= */
i);
TrackGroupArray trackGroupArray = mappedTrackInfo.getTrackGroups(i);
TrackSelectionViewFragment tabFragment = new TrackSelectionViewFragment();
tabFragment.init(mappedTrackInfo, /* rendererIndex= */
i, initialParameters.getRendererDisabled(/* rendererIndex= */
i), initialParameters.getSelectionOverride(/* rendererIndex= */
i, trackGroupArray), allowAdaptiveSelections, allowMultipleOverrides);
tabFragments.put(i, tabFragment);
tabTrackTypes.add(trackType);
}
}
}
use of com.google.android.exoplayer2.source.TrackGroupArray in project ExoPlayer by google.
the class DefaultTrackSelectorTest method selectTracksWithMultipleAudioTracksOverrideReturnsAdaptiveTrackSelection.
@Test
public void selectTracksWithMultipleAudioTracksOverrideReturnsAdaptiveTrackSelection() throws Exception {
Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
TrackGroupArray trackGroups = singleTrackGroup(formatBuilder.setId("0").build(), formatBuilder.setId("1").build(), formatBuilder.setId("2").build());
trackSelector.setParameters(trackSelector.buildUponParameters().setSelectionOverride(/* rendererIndex= */
0, trackGroups, new SelectionOverride(/* groupIndex= */
0, /* tracks=... */
1, 2)));
TrackSelectorResult result = trackSelector.selectTracks(new RendererCapabilities[] { AUDIO_CAPABILITIES }, trackGroups, periodId, TIMELINE);
assertThat(result.length).isEqualTo(1);
assertAdaptiveSelection(result.selections[0], trackGroups.get(0), 1, 2);
}
use of com.google.android.exoplayer2.source.TrackGroupArray 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();
}
use of com.google.android.exoplayer2.source.TrackGroupArray in project ExoPlayer by google.
the class DefaultTrackSelectorTest method selectTracksExceedingCapabilitiesSelectLowerNumChannel.
/**
* Tests that track selector will select audio tracks with lower num channel when other factors
* are the same, and tracks exceed renderer's capabilities.
*/
@Test
public void selectTracksExceedingCapabilitiesSelectLowerNumChannel() throws Exception {
Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
Format higherChannelFormat = formatBuilder.setChannelCount(6).build();
Format lowerChannelFormat = formatBuilder.setChannelCount(2).build();
TrackGroupArray trackGroups = wrapFormats(higherChannelFormat, lowerChannelFormat);
TrackSelectorResult result = trackSelector.selectTracks(new RendererCapabilities[] { ALL_AUDIO_FORMAT_EXCEEDED_RENDERER_CAPABILITIES }, trackGroups, periodId, TIMELINE);
assertFixedSelection(result.selections[0], trackGroups, lowerChannelFormat);
}
Aggregations