#include <time.h>
#include <errno.h>
#include <Ethumb.h>
-#include <mm_file.h>
-#include <mm_util_jpeg.h>
-#include <mm_error.h>
+#include <metadata_extractor.h>
+#include <image_util.h>
#include <Efreet_Mime.h>
#include <status.h>
{"Video", "video/3gpp", IMGDIR "/U01_icon_video.png", "video-player", NULL, TRUE, FALSE, TRUE},
{"Video", "video/x-ms-asf", IMGDIR "/U01_icon_video.png", "video-player", NULL, TRUE, FALSE, TRUE},
{"Video", "video/x-ms-wmv", IMGDIR "/U01_icon_video.png", "video-player", NULL, TRUE, FALSE, TRUE},
- {"Image", "image/svg+xml", MYFILE_IMGE_PATH "/myfile_icon_svg.png", "svg-viewer", NULL, TRUE, FALSE, FALSE},
{"PDF", "application/pdf", IMGDIR "/U01_icon_pdf.png", "documents", NULL, TRUE, FALSE, FALSE},
{"Doc", "application/msword", IMGDIR "/U01_icon_word.png", "documents", NULL, TRUE, FALSE, FALSE},
{"Doc", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", IMGDIR "/U01_icon_word.png", "documents", NULL, TRUE, FALSE, FALSE},
{"Java", "text/vnd.sun.j2me.app-descriptor", MYFILE_IMGE_PATH "/myfile_icon_java.png", NULL, NULL, FALSE, FALSE, FALSE},
{"Java", "application/x-java-archive", MYFILE_IMGE_PATH "/myfile_icon_java.png", NULL, NULL, FALSE, FALSE, FALSE},
{"SVG", "image/svg+xml", MYFILE_IMGE_PATH "/myfile_icon_svg.png", "svg-viewer", NULL, TRUE, FALSE, FALSE},
- {"ETC", "etc", MYFILE_IMGE_PATH "/myfile_icon_etc.png", NULL, NULL, TRUE, FALSE, FALSE},
{"VCARD", "text/directory", MYFILE_IMGE_PATH "/myfile_icon_etc.png", NULL, NULL, FALSE, FALSE, FALSE},
{"VCALENDAR", "text/calendar", MYFILE_IMGE_PATH "/myfile_icon_etc.png", NULL, NULL, FALSE, FALSE, FALSE},
{NULL, NULL, NULL, NULL}
ethumb_free(e);
} else if (strncmp(mime_type, "video", 5) == 0) {
- int ret = 0;
- int video_track_num = 0;
+ metadata_extractor_h metadata = NULL;
+ int ret = METADATA_EXTRACTOR_ERROR_NONE;
+ char *video_width = NULL;
+ char *video_height = NULL;
+ char *video_track_cnt = NULL;
+ void *video_thumbnail = NULL;
+ int video_thumbnail_len = 0;
int video_w = 0;
int video_h = 0;
- int thumb_len = 0;
- void *stream = NULL;
- MMHandleType content_attrs = 0;
-
- ret = mm_file_create_content_attrs(&content_attrs, path);
-
- if (ret == MM_ERROR_NONE && content_attrs) {
- mm_file_get_attrs(content_attrs, NULL,
- MM_FILE_CONTENT_VIDEO_TRACK_COUNT,
- &video_track_num, NULL);
-
- if (video_track_num) {
- mm_file_get_attrs(content_attrs, NULL,
- MM_FILE_CONTENT_VIDEO_WIDTH, &video_w,
- MM_FILE_CONTENT_VIDEO_HEIGHT, &video_h,
- MM_FILE_CONTENT_VIDEO_THUMBNAIL, &stream,
- &thumb_len, NULL);
-
- if (stream) {
- int mm_ret = 0;
- char filename[1024] = { 0, };
- char *file_name = NULL;
- char *file_ext = NULL;
-
- email_parse_get_filename_n_ext_from_path(path, &file_name, &file_ext);
- snprintf(filename, sizeof(filename), "%s%s%s%s", DATADIR"/", file_name, file_ext, ".jpg");
- g_free(file_name);
- g_free(file_ext);
-
- mm_ret = mm_util_jpeg_encode_to_file(filename, stream,
- video_w, video_h,
- MM_UTIL_JPEG_FMT_RGB888, 70);
-
- if (ecore_file_exists(filename)) {
- snprintf(thumb_path, sizeof(thumb_path), "%s", filename);
- debug_log("file : %s, thumb_path : %s", path, thumb_path);
- }
- }
- }
- mm_file_destroy_content_attrs(content_attrs);
- } else {
- debug_log("fail to mm_file_create_content_attrs - error(%x)", ret);
+ ret = metadata_extractor_create(&metadata);
+ debug_log("metadata_extractor_create: %d", ret);
+ if (!metadata) {
+ debug_log("metadata extractor create failed");
+ return NULL;
}
- } else if (strncmp(mime_type, "audio", 5) == 0) {
- int tag_ret = 0;
- MMHandleType tag_attrs = 0;
- tag_ret = mm_file_create_tag_attrs(&tag_attrs, path);
+ ret = metadata_extractor_set_path(metadata, path);
+ debug_log("metadata_extractor_set_path: %d", ret);
+
+ ret = metadata_extractor_get_metadata(metadata, METADATA_VIDEO_WIDTH, &video_width);
+ debug_log("metadata_extractor_get_metadata: %d [video_width:%s]", ret, video_width);
+ ret = metadata_extractor_get_metadata(metadata, METADATA_VIDEO_HEIGHT, &video_height);
+ debug_log("metadata_extractor_get_metadata: %d [video_height:%s]", ret, video_height);
+ ret = metadata_extractor_get_metadata(metadata, METADATA_HAS_VIDEO, &video_track_cnt);
+ debug_log("metadata_extractor_get_metadata: %d [video_track_cnt:%s]", ret, video_track_cnt);
+
+ ret = metadata_extractor_get_frame(metadata, &video_thumbnail, &video_thumbnail_len);
+ debug_log("metadata_extractor_get_frame: %d (video_thumbnail_len:%d)", ret, video_thumbnail_len);
+
+ if (video_thumbnail) {
+ int mm_ret = 0;
+ char filename[1024] = { 0, };
+ char *file_name = NULL;
+ char *file_ext = NULL;
+
+ email_parse_get_filename_n_ext_from_path(path, &file_name, &file_ext);
+ snprintf(filename, sizeof(filename), "%s%s%s%s", DATADIR"/", file_name, file_ext, ".jpg");
+ g_free(file_name);
+ g_free(file_ext);
+
+ if (video_width)
+ video_w = atoi(video_width);
+ if (video_height)
+ video_h = atoi(video_height);
+ mm_ret = image_util_encode_jpeg(video_thumbnail,
+ video_w, video_h,
+ IMAGE_UTIL_COLORSPACE_RGB888, 70, filename);
+
+ if (ecore_file_exists(filename)) {
+ snprintf(thumb_path, sizeof(thumb_path), "%s", filename);
+ debug_log("file : %s, thumb_path : %s", path, thumb_path);
+ }
+ g_free(video_thumbnail);
+ }
- if (tag_ret == MM_ERROR_NONE && tag_attrs) {
- char *error = NULL;
- char *art_name = NULL;
- int art_len = 0;
- int art_size = 0;
+ if (video_width)
+ g_free(video_width);
+ if (video_height)
+ g_free(video_height);
+ if (video_track_cnt)
+ g_free(video_track_cnt);
- tag_ret = mm_file_get_attrs(tag_attrs, &error,
- MM_FILE_TAG_ARTWORK, &art_name, &art_len,
- MM_FILE_TAG_ARTWORK_SIZE, &art_size, NULL);
+ ret = metadata_extractor_destroy(metadata);
+ debug_log("metadata_extractor_destroy: %d", ret);
+ } else if (strncmp(mime_type, "audio", 5) == 0) {
+ metadata_extractor_h metadata = NULL;
+ int ret = METADATA_EXTRACTOR_ERROR_NONE;
+ void *artwork = NULL;
+ int artwork_size = 0;
+ char *artwork_mime = NULL;
+
+ ret = metadata_extractor_create(&metadata);
+ debug_log("metadata_extractor_create: %d", ret);
+ if (!metadata) {
+ debug_log("metadata extractor create failed");
+ return NULL;
+ }
- if (tag_ret != MM_ERROR_NONE) {
- if (error) {
- debug_log("fail to mm_file_get_attrs() - ret(%x), error(%s)", tag_ret, error);
- free(error);
- } else {
- debug_log("fail to mm_file_get_attrs() - ret(%x)", tag_ret);
- }
- }
+ ret = metadata_extractor_set_path(metadata, path);
+ debug_log("metadata_extractor_set_path: %d", ret);
+
+ ret = metadata_extractor_get_artwork(metadata, &artwork, &artwork_size, &artwork_mime);
+ debug_log("metadata_extractor_get_artwork: %d", ret);
+ debug_log("artwork_mime: %s, artwork_size: %d", artwork_mime, artwork_size);
- if (art_name) {
- gchar *mm_path = NULL;
- int fd = g_file_open_tmp(NULL, &mm_path, NULL);
+ if (artwork) {
+ gchar *mm_path = NULL;
+ int fd = g_file_open_tmp(NULL, &mm_path, NULL);
- if (fd != -1) {
- FILE *fp = fdopen(fd, "w");
- if (fp == NULL) {
- debug_log("fail to fdopen()");
+ if (fd != -1) {
+ FILE *fp = fdopen(fd, "w");
+ if (fp == NULL) {
+ debug_log("fail to fdopen()");
+ close(fd);
+ } else {
+ int n = fwrite((unsigned char *)artwork, sizeof(char), artwork_size, fp);
+ if (n != artwork_size) {
+ debug_log("fail to fwrite()");
+ fclose(fp);
close(fd);
} else {
- int n = fwrite((unsigned char *)art_name, sizeof(char), art_size, fp);
- if (n != art_size) {
- debug_log("fail to fwrite()");
- fclose(fp);
- close(fd);
- } else {
- fflush(fp);
- fclose(fp);
- close(fd);
- }
+ fflush(fp);
+ fclose(fp);
+ close(fd);
}
}
-
- snprintf(thumb_path, sizeof(thumb_path), "%s", mm_path);
- debug_log("file : %s, albumart_path : %s", path, thumb_path);
- if (mm_path)
- g_free(mm_path);
}
+
+ snprintf(thumb_path, sizeof(thumb_path), "%s", mm_path);
+ debug_log("file : %s, album art_path : %s", path, thumb_path);
+
+ if (mm_path)
+ g_free(mm_path);
+
+ g_free(artwork);
}
- mm_file_destroy_tag_attrs(tag_attrs);
+ if (artwork_mime)
+ g_free(artwork_mime);
+
+ ret = metadata_extractor_destroy(metadata);
+ debug_log("metadata_extractor_destroy: %d", ret);
}
if (strlen(thumb_path) > 0) {