use of com.google.android.exoplayer2.metadata.mp4.MotionPhotoMetadata in project ExoPlayer by google.
the class MotionPhotoDescriptionTest method getMotionPhotoMetadata_withPrimaryAndMultipleSecondaryMediaItems_returnsSecondMediaItemAsVideo.
@Test
public void getMotionPhotoMetadata_withPrimaryAndMultipleSecondaryMediaItems_returnsSecondMediaItemAsVideo() {
MotionPhotoDescription motionPhotoDescription = new MotionPhotoDescription(TEST_PRESENTATION_TIMESTAMP_US, ImmutableList.of(new MotionPhotoDescription.ContainerItem(MimeTypes.IMAGE_JPEG, "Primary", /* length= */
0, TEST_MOTION_PHOTO_PHOTO_PADDING_BYTES), new MotionPhotoDescription.ContainerItem(MimeTypes.VIDEO_MP4, "MotionPhoto", TEST_MOTION_PHOTO_VIDEO_LENGTH_BYTES, /* padding= */
0), new MotionPhotoDescription.ContainerItem(MimeTypes.VIDEO_MP4, "MotionPhoto", TEST_MOTION_PHOTO_VIDEO_LENGTH_BYTES, /* padding= */
0)));
@Nullable MotionPhotoMetadata metadata = motionPhotoDescription.getMotionPhotoMetadata(TEST_MOTION_PHOTO_LENGTH_BYTES);
assertThat(metadata.photoStartPosition).isEqualTo(0);
assertThat(metadata.photoSize).isEqualTo(TEST_MOTION_PHOTO_LENGTH_BYTES - TEST_MOTION_PHOTO_VIDEO_LENGTH_BYTES * 2 - TEST_MOTION_PHOTO_PHOTO_PADDING_BYTES);
assertThat(metadata.photoPresentationTimestampUs).isEqualTo(TEST_PRESENTATION_TIMESTAMP_US);
assertThat(metadata.videoStartPosition).isEqualTo(TEST_MOTION_PHOTO_LENGTH_BYTES - TEST_MOTION_PHOTO_VIDEO_LENGTH_BYTES * 2);
assertThat(metadata.videoSize).isEqualTo(TEST_MOTION_PHOTO_VIDEO_LENGTH_BYTES);
}
use of com.google.android.exoplayer2.metadata.mp4.MotionPhotoMetadata in project ExoPlayer by google.
the class MotionPhotoDescriptionTest method getMotionPhotoMetadata_withPrimaryAndSecondaryMediaItems.
@Test
public void getMotionPhotoMetadata_withPrimaryAndSecondaryMediaItems() {
MotionPhotoDescription motionPhotoDescription = new MotionPhotoDescription(TEST_PRESENTATION_TIMESTAMP_US, ImmutableList.of(new MotionPhotoDescription.ContainerItem(MimeTypes.IMAGE_JPEG, "Primary", /* length= */
0, TEST_MOTION_PHOTO_PHOTO_PADDING_BYTES), new MotionPhotoDescription.ContainerItem(MimeTypes.VIDEO_MP4, "MotionPhoto", TEST_MOTION_PHOTO_VIDEO_LENGTH_BYTES, /* padding= */
0)));
@Nullable MotionPhotoMetadata metadata = motionPhotoDescription.getMotionPhotoMetadata(TEST_MOTION_PHOTO_LENGTH_BYTES);
assertThat(metadata.photoStartPosition).isEqualTo(0);
assertThat(metadata.photoSize).isEqualTo(TEST_MOTION_PHOTO_LENGTH_BYTES - TEST_MOTION_PHOTO_VIDEO_LENGTH_BYTES - TEST_MOTION_PHOTO_PHOTO_PADDING_BYTES);
assertThat(metadata.photoPresentationTimestampUs).isEqualTo(TEST_PRESENTATION_TIMESTAMP_US);
assertThat(metadata.videoStartPosition).isEqualTo(TEST_MOTION_PHOTO_LENGTH_BYTES - TEST_MOTION_PHOTO_VIDEO_LENGTH_BYTES);
assertThat(metadata.videoSize).isEqualTo(TEST_MOTION_PHOTO_VIDEO_LENGTH_BYTES);
}
use of com.google.android.exoplayer2.metadata.mp4.MotionPhotoMetadata in project ExoPlayer by google.
the class MotionPhotoDescriptionTest method getMotionPhotoMetadata_withOnlyPrimaryItem_returnsNull.
@Test
public void getMotionPhotoMetadata_withOnlyPrimaryItem_returnsNull() {
MotionPhotoDescription motionPhotoDescription = new MotionPhotoDescription(TEST_PRESENTATION_TIMESTAMP_US, ImmutableList.of(new MotionPhotoDescription.ContainerItem(MimeTypes.VIDEO_MP4, "Primary", /* length= */
0, TEST_MOTION_PHOTO_PHOTO_PADDING_BYTES)));
@Nullable MotionPhotoMetadata metadata = motionPhotoDescription.getMotionPhotoMetadata(TEST_MOTION_PHOTO_LENGTH_BYTES);
assertThat(metadata).isNull();
}
use of com.google.android.exoplayer2.metadata.mp4.MotionPhotoMetadata in project ExoPlayer by google.
the class JpegExtractor method readSegment.
private void readSegment(ExtractorInput input) throws IOException {
if (marker == MARKER_APP1) {
ParsableByteArray payload = new ParsableByteArray(segmentLength);
input.readFully(payload.getData(), /* offset= */
0, /* length= */
segmentLength);
if (motionPhotoMetadata == null && HEADER_XMP_APP1.equals(payload.readNullTerminatedString())) {
@Nullable String xmpString = payload.readNullTerminatedString();
if (xmpString != null) {
motionPhotoMetadata = getMotionPhotoMetadata(xmpString, input.getLength());
if (motionPhotoMetadata != null) {
mp4StartPosition = motionPhotoMetadata.videoStartPosition;
}
}
}
} else {
input.skipFully(segmentLength);
}
state = STATE_READING_MARKER;
}
use of com.google.android.exoplayer2.metadata.mp4.MotionPhotoMetadata in project ExoPlayer by google.
the class MotionPhotoDescriptionTest method getMotionPhotoMetadata_withPrimaryAndSecondaryItemSharingData_returnsPrimaryItemAsPhotoAndVideo.
@Test
public void getMotionPhotoMetadata_withPrimaryAndSecondaryItemSharingData_returnsPrimaryItemAsPhotoAndVideo() {
// Theoretical example of an HEIF file that has both an image and a video represented in the
// same file, which looks like an MP4.
MotionPhotoDescription motionPhotoDescription = new MotionPhotoDescription(TEST_PRESENTATION_TIMESTAMP_US, ImmutableList.of(new MotionPhotoDescription.ContainerItem(MimeTypes.VIDEO_MP4, "Primary", /* length= */
0, TEST_MOTION_PHOTO_PHOTO_PADDING_BYTES), new MotionPhotoDescription.ContainerItem(MimeTypes.VIDEO_MP4, "MotionPhoto", /* length= */
0, /* padding= */
0)));
@Nullable MotionPhotoMetadata metadata = motionPhotoDescription.getMotionPhotoMetadata(TEST_MOTION_PHOTO_LENGTH_BYTES);
assertThat(metadata.photoStartPosition).isEqualTo(0);
assertThat(metadata.photoSize).isEqualTo(TEST_MOTION_PHOTO_LENGTH_BYTES - TEST_MOTION_PHOTO_PHOTO_PADDING_BYTES);
assertThat(metadata.photoPresentationTimestampUs).isEqualTo(TEST_PRESENTATION_TIMESTAMP_US);
assertThat(metadata.videoStartPosition).isEqualTo(0);
assertThat(metadata.videoSize).isEqualTo(TEST_MOTION_PHOTO_LENGTH_BYTES - TEST_MOTION_PHOTO_PHOTO_PADDING_BYTES);
}
Aggregations