Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,32 @@ public void isMotionPhoto_withOptions_evaluatesCorrectly() {
}
}

@Test
public void parseMetadata_heicMotionPhoto_isMotionPhoto() throws Exception {
String heicPath = TestUtil.getTestDataPath("motion_photo_single_video_track.MP.heic");

byte[] pathBytes = MetadataEngine.parseMetadata(heicPath);
assertThat(pathBytes).isNotNull();
assertThat(MetadataEngine.isMotionPhoto(pathBytes)).isTrue();

File file = new File(heicPath);
try (ParcelFileDescriptor pfd =
ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY)) {
byte[] fdBytes = MetadataEngine.parseMetadataFd(pfd.getFd(), 0, file.length());
assertThat(fdBytes).isEqualTo(pathBytes);
}
}

@Test
public void parseMetadata_heicWithoutVideo_isNotMotionPhoto() {
// The XMP says motion photo, but the file has no 'mpvd' video box.
byte[] protoBytes =
MetadataEngine.parseMetadata(TestUtil.getTestDataPath("motion_photo_photo_only.heic"));

assertThat(protoBytes).isNotNull();
assertThat(MetadataEngine.isMotionPhoto(protoBytes)).isFalse();
}

@Test
public void extractAgtm_viaPathAndMemory_returnsValidJson() throws Exception {
String agtmJsonPath = MetadataEngine.extractAgtm(agtmPhotoPath);
Expand Down
1 change: 1 addition & 0 deletions lib/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ if (NOT ANDROID)
motion_photo/tests/motion_photo_checker_test.cc
motion_photo/tests/motion_photo_extractor_test.cc
motion_photo/tests/mp4_box_reader_test.cc
motion_photo/tests/heif_container_splitter_test.cc
motion_photo/tests/libmotionphoto_api_test.cc
)
target_include_directories(motion_photo_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/.. motion_photo/includes ${CMAKE_CURRENT_BINARY_DIR})
Expand Down
10 changes: 8 additions & 2 deletions lib/core/motion_photo/includes/motion_photo/container_splitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,14 @@ class ContainerSplitter {
image_io::DataSource* data_source, size_t file_size) = 0;
};

std::unique_ptr<ContainerSplitter> CreateContainerSplitter(
FileType type, image_io::MessageHandler* message_handler);
// Returns a splitter for JPEG images.
std::unique_ptr<ContainerSplitter> CreateJpegContainerSplitter(
image_io::MessageHandler* message_handler);

// Returns a splitter for HEIF-based images (HEIC and AVIF) that does not need
// libheif. It emits the primary image's XMP item as a "standard.xmp" block, and
// only when the file also has a top-level 'mpvd' (motion photo video) box.
std::unique_ptr<ContainerSplitter> CreateHeifContainerSplitter();

} // namespace motion_photo
} // namespace libmotionphoto
Expand Down
Loading
Loading