use of com.google.android.exoplayer2.metadata.mp4.MotionPhotoMetadata 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);
}
use of com.google.android.exoplayer2.metadata.mp4.MotionPhotoMetadata in project ExoPlayer by google.
the class Mp4Extractor method processEndOfStreamReadingAtomHeader.
/**
* Processes the end of stream in case there is not atom left to read.
*/
private void processEndOfStreamReadingAtomHeader() {
if (fileType == FILE_TYPE_HEIC && (flags & FLAG_READ_MOTION_PHOTO_METADATA) != 0) {
// Add image track and prepare media.
ExtractorOutput extractorOutput = checkNotNull(this.extractorOutput);
TrackOutput trackOutput = extractorOutput.track(/* id= */
0, C.TRACK_TYPE_IMAGE);
@Nullable Metadata metadata = motionPhotoMetadata == null ? null : new Metadata(motionPhotoMetadata);
trackOutput.format(new Format.Builder().setMetadata(metadata).build());
extractorOutput.endTracks();
extractorOutput.seekMap(new SeekMap.Unseekable(/* durationUs= */
C.TIME_UNSET));
}
}
Aggregations