Add to dump artwork and thumbnail on testsuite 39/221739/4
authorjiyong.min <jiyong.min@samsung.com>
Tue, 7 Jan 2020 07:32:24 +0000 (16:32 +0900)
committerjiyong.min <jiyong.min@samsung.com>
Wed, 8 Jan 2020 01:12:49 +0000 (10:12 +0900)
Change-Id: I5d4e2e87888b8f18dc4ed6bbae9610bdf4e84711

test/metadata_extractor_test.c

index 7196bdc5b05d3dda150fd2e5fd943c79026ef618..ad11b7ab2efc167ec65d1f4dd191f4552b55d934 100755 (executable)
                }       \
        } while (0)
 
+/* Saves dump artwork and thumbnail to current path */
+#define DUMP_ARTWORK_THUMBNAIL 0       /* disable: 0, enable: 1*/
+#if DUMP_ARTWORK_THUMBNAIL
+#define DUMP_ARTWORK_PATH              "./test_artwork.jpg"
+#define DUMP_THUMBNAIL_PATH            "./test_thumbnail.rgb"
+#endif
+
 static int _is_file_exist(const char *filename);
 static bool __capi_metadata_extractor(metadata_extractor_h metadata);
 
+#if DUMP_ARTWORK_THUMBNAIL
+static void __write_file(const char *path, void *data, size_t length)
+{
+       FILE *fp = NULL;
+       size_t len = 0;
+
+       if (!path || !data || length == 0) {
+               printf("\t[__write_file] invalid data\n");
+               return ;
+       }
+
+       printf("\t[__write_file] %s %p %zu write\n", path, data, length);
+
+       fp = fopen(path, "w");
+       if (!fp) {
+               printf("\t[__write_file] fopen failed (%d)\n", errno);
+               return ;
+       }
+
+       len = fwrite(data, 1, length, fp);
+       if (len != length) {
+               printf("\t[__write_file] fwrite failed\n");
+       }
+
+       fclose(fp);
+       fp = NULL;
+
+       printf("\t[__write_file] %s write DONE\n", path);
+}
+#endif
+
 static int _is_file_exist(const char *filename)
 {
        int ret = 1;
@@ -303,11 +341,19 @@ static bool __capi_metadata_extractor(metadata_extractor_h metadata)
        metadata_extractor_get_artwork(metadata, &artwork, &artwork_size, &artwork_mime);
        printf("artwork = [%p], artwork_size = [%d]\n", artwork, artwork_size);
        printf("artwork_mime = [%s]\n", artwork_mime);
+#if DUMP_ARTWORK_THUMBNAIL
+       if (artwork)
+               __write_file(DUMP_ARTWORK_PATH, artwork, (size_t)artwork_size);
+#endif
 
        if (video_cnt > 0) {
                /*Get Thumbnail*/
                metadata_extractor_get_frame(metadata, &video_thumbnail, &video_thumbnail_len);
                printf("video_thumbnail[%p], video_thumbnail_len = [%d]\n\n", video_thumbnail, video_thumbnail_len);
+#if DUMP_ARTWORK_THUMBNAIL
+               if (video_thumbnail)
+                       __write_file(DUMP_THUMBNAIL_PATH, video_thumbnail, (size_t)video_thumbnail_len);
+#endif
 
                /*Get Video frame at time, extract frame of 22.5 sec and not key frame*/
                metadata_extractor_get_frame_at_time(metadata, 22500, false, &video_frame, &video_frame_len);