Search in sources :

Example 6 with MotionPhotoMetadata

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);
}
Also used : MotionPhotoMetadata(com.google.android.exoplayer2.metadata.mp4.MotionPhotoMetadata) TrackGroupArray(com.google.android.exoplayer2.source.TrackGroupArray) Test(org.junit.Test)

Example 7 with MotionPhotoMetadata

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));
    }
}
Also used : ExtractorOutput(com.google.android.exoplayer2.extractor.ExtractorOutput) Format(com.google.android.exoplayer2.Format) MotionPhotoMetadata(com.google.android.exoplayer2.metadata.mp4.MotionPhotoMetadata) Metadata(com.google.android.exoplayer2.metadata.Metadata) SeekMap(com.google.android.exoplayer2.extractor.SeekMap) TrackOutput(com.google.android.exoplayer2.extractor.TrackOutput) Nullable(androidx.annotation.Nullable)

Aggregations

Nullable (androidx.annotation.Nullable)6 MotionPhotoMetadata (com.google.android.exoplayer2.metadata.mp4.MotionPhotoMetadata)6 Test (org.junit.Test)5 Format (com.google.android.exoplayer2.Format)1 ExtractorOutput (com.google.android.exoplayer2.extractor.ExtractorOutput)1 SeekMap (com.google.android.exoplayer2.extractor.SeekMap)1 TrackOutput (com.google.android.exoplayer2.extractor.TrackOutput)1 Metadata (com.google.android.exoplayer2.metadata.Metadata)1 TrackGroupArray (com.google.android.exoplayer2.source.TrackGroupArray)1 ParsableByteArray (com.google.android.exoplayer2.util.ParsableByteArray)1