use of com.google.android.exoplayer2.source.TrackGroupArray in project ExoPlayer by google.
the class ExoPlayerImplInternal method handlePositionDiscontinuity.
@CheckResult
private PlaybackInfo handlePositionDiscontinuity(MediaPeriodId mediaPeriodId, long positionUs, long requestedContentPositionUs, long discontinuityStartPositionUs, boolean reportDiscontinuity, @DiscontinuityReason int discontinuityReason) {
deliverPendingMessageAtStartPositionRequired = deliverPendingMessageAtStartPositionRequired || positionUs != playbackInfo.positionUs || !mediaPeriodId.equals(playbackInfo.periodId);
resetPendingPauseAtEndOfPeriod();
TrackGroupArray trackGroupArray = playbackInfo.trackGroups;
TrackSelectorResult trackSelectorResult = playbackInfo.trackSelectorResult;
List<Metadata> staticMetadata = playbackInfo.staticMetadata;
if (mediaSourceList.isPrepared()) {
@Nullable MediaPeriodHolder playingPeriodHolder = queue.getPlayingPeriod();
trackGroupArray = playingPeriodHolder == null ? TrackGroupArray.EMPTY : playingPeriodHolder.getTrackGroups();
trackSelectorResult = playingPeriodHolder == null ? emptyTrackSelectorResult : playingPeriodHolder.getTrackSelectorResult();
staticMetadata = extractMetadataFromTrackSelectionArray(trackSelectorResult.selections);
// Ensure the media period queue requested content position matches the new playback info.
if (playingPeriodHolder != null && playingPeriodHolder.info.requestedContentPositionUs != requestedContentPositionUs) {
playingPeriodHolder.info = playingPeriodHolder.info.copyWithRequestedContentPositionUs(requestedContentPositionUs);
}
} else if (!mediaPeriodId.equals(playbackInfo.periodId)) {
// Reset previously kept track info if unprepared and the period changes.
trackGroupArray = TrackGroupArray.EMPTY;
trackSelectorResult = emptyTrackSelectorResult;
staticMetadata = ImmutableList.of();
}
if (reportDiscontinuity) {
playbackInfoUpdate.setPositionDiscontinuity(discontinuityReason);
}
return playbackInfo.copyWithNewPosition(mediaPeriodId, positionUs, requestedContentPositionUs, discontinuityStartPositionUs, getTotalBufferedDurationUs(), trackGroupArray, trackSelectorResult, staticMetadata);
}
use of com.google.android.exoplayer2.source.TrackGroupArray in project ExoPlayer by google.
the class DashMediaPeriodTest method cea708AccessibilityDescriptor_createsCea708TrackGroup.
@Test
public void cea708AccessibilityDescriptor_createsCea708TrackGroup() throws IOException {
DashManifest manifest = parseManifest("media/mpd/sample_mpd_cea_708_accessibility");
DashMediaPeriod dashMediaPeriod = createDashMediaPeriod(manifest, 0);
List<AdaptationSet> adaptationSets = manifest.getPeriod(0).adaptationSets;
// We expect two adaptation sets. The first containing the video representations, and the second
// containing the embedded CEA-708 tracks.
Format.Builder cea608FormatBuilder = new Format.Builder().setSampleMimeType(MimeTypes.APPLICATION_CEA708);
TrackGroupArray expectedTrackGroups = new TrackGroupArray(new TrackGroup(/* id= */
"123", adaptationSets.get(0).representations.get(0).format, adaptationSets.get(0).representations.get(1).format), new TrackGroup(/* id= */
"123:cc", cea608FormatBuilder.setId("123:cea708:1").setLanguage("eng").setAccessibilityChannel(1).build(), cea608FormatBuilder.setId("123:cea708:2").setLanguage("deu").setAccessibilityChannel(2).build()));
MediaPeriodAsserts.assertTrackGroups(dashMediaPeriod, expectedTrackGroups);
}
use of com.google.android.exoplayer2.source.TrackGroupArray in project ExoPlayer by google.
the class DashMediaPeriodTest method adaptationSetSwitchingProperty_mergesTrackGroups.
@Test
public void adaptationSetSwitchingProperty_mergesTrackGroups() throws IOException {
DashManifest manifest = parseManifest("media/mpd/sample_mpd_switching_property");
DashMediaPeriod dashMediaPeriod = createDashMediaPeriod(manifest, 0);
List<AdaptationSet> adaptationSets = manifest.getPeriod(0).adaptationSets;
// We expect the three adaptation sets with the switch descriptor to be merged, retaining the
// representations in their original order.
TrackGroupArray expectedTrackGroups = new TrackGroupArray(new TrackGroup(/* id= */
"0", adaptationSets.get(0).representations.get(0).format, adaptationSets.get(0).representations.get(1).format, adaptationSets.get(2).representations.get(0).format, adaptationSets.get(2).representations.get(1).format, adaptationSets.get(3).representations.get(0).format), new TrackGroup(/* id= */
"3", adaptationSets.get(1).representations.get(0).format));
MediaPeriodAsserts.assertTrackGroups(dashMediaPeriod, expectedTrackGroups);
}
use of com.google.android.exoplayer2.source.TrackGroupArray in project ExoPlayer by google.
the class DashMediaPeriodTest method cea608AccessibilityDescriptor_createsCea608TrackGroup.
@Test
public void cea608AccessibilityDescriptor_createsCea608TrackGroup() throws IOException {
DashManifest manifest = parseManifest("media/mpd/sample_mpd_cea_608_accessibility");
DashMediaPeriod dashMediaPeriod = createDashMediaPeriod(manifest, 0);
List<AdaptationSet> adaptationSets = manifest.getPeriod(0).adaptationSets;
// We expect two adaptation sets. The first containing the video representations, and the second
// containing the embedded CEA-608 tracks.
Format.Builder cea608FormatBuilder = new Format.Builder().setSampleMimeType(MimeTypes.APPLICATION_CEA608);
TrackGroupArray expectedTrackGroups = new TrackGroupArray(new TrackGroup(/* id= */
"123", adaptationSets.get(0).representations.get(0).format, adaptationSets.get(0).representations.get(1).format), new TrackGroup(/* id= */
"123:cc", cea608FormatBuilder.setId("123:cea608:1").setLanguage("eng").setAccessibilityChannel(1).build(), cea608FormatBuilder.setId("123:cea608:3").setLanguage("deu").setAccessibilityChannel(3).build()));
MediaPeriodAsserts.assertTrackGroups(dashMediaPeriod, expectedTrackGroups);
}
use of com.google.android.exoplayer2.source.TrackGroupArray in project ExoPlayer by google.
the class MetadataRetrieverTest method retrieveMetadata_heicMotionPhoto_outputsExpectedMetadata.
@Test
public void retrieveMetadata_heicMotionPhoto_outputsExpectedMetadata() throws Exception {
MediaItem mediaItem = MediaItem.fromUri(Uri.parse("asset://android_asset/media/mp4/sample_MP.heic"));
MotionPhotoMetadata expectedMotionPhotoMetadata = new MotionPhotoMetadata(/* photoStartPosition= */
0, /* photoSize= */
28_853, /* photoPresentationTimestampUs= */
C.TIME_UNSET, /* videoStartPosition= */
28_869, /* videoSize= */
28_803);
ListenableFuture<TrackGroupArray> trackGroupsFuture = retrieveMetadata(context, mediaItem, clock);
ShadowLooper.idleMainLooper();
TrackGroupArray trackGroups = trackGroupsFuture.get(TEST_TIMEOUT_SEC, TimeUnit.SECONDS);
assertThat(trackGroups.length).isEqualTo(1);
assertThat(trackGroups.get(0).length).isEqualTo(1);
assertThat(trackGroups.get(0).getFormat(0).metadata.length()).isEqualTo(1);
assertThat(trackGroups.get(0).getFormat(0).metadata.get(0)).isEqualTo(expectedMotionPhotoMetadata);
}
Aggregations