Use get_image_info instead
[platform/core/multimedia/libmedia-service.git] / src / common / media-svc-util.c
index 1c61cf4..8fbb2a8 100644 (file)
 
 #include <unistd.h>
 #include <stdlib.h>
-#ifndef __USE_XOPEN
-#define DEF_XOPEN
-#define __USE_XOPEN /* needed for strptime */
-#endif
-#include <time.h>
-#ifdef DEF_XOPEN
-#undef __USE_XOPEN
-#endif
 #include <string.h>
-#include <sys/vfs.h>
-#include <glib/gstdio.h>
+#include <fcntl.h>
 #include <sys/stat.h>
-#include <dirent.h>
+#include <sys/vfs.h>
 #include <ctype.h>
 #include <aul/aul.h>
 #include <mm_file.h>
 #include <libexif/exif-data.h>
 #include <media-util.h>
 #include <uuid/uuid.h>
-#include <mm_util_magick.h>
 #include <media-thumbnail.h>
-#include "media-util-err.h"
 #include "media-svc-util.h"
 #include "media-svc-db-utils.h"
 #include "media-svc-debug.h"
 #include "media-svc-env.h"
-#include "media-svc-hash.h"
 #include "media-svc-album.h"
 /*For ebook metadata */
 #include <zip.h>
@@ -58,7 +46,6 @@
 
 #define MUSIC_MIME_NUM 29
 #define SOUND_MIME_NUM 2
-#define THUMB_HASH_LEN 256
 #define MIME_LENGTH 50
 #define MEDIA_SVC_DEFAULT_FORMAT_LEN 19
 #define IMAGE_PREFIX "image/"
@@ -175,58 +162,6 @@ static int __media_svc_get_exif_info(ExifData *ed, char *buf, int *i_value, Exif
        return MS_MEDIA_ERR_NONE;
 }
 
-static time_t __media_svc_get_timeline_from_str(const char *timstr)
-{
-       struct tm t;
-       time_t modified_t = 0;
-       time_t rawtime;
-       struct tm timeinfo;
-
-       if (!STRING_VALID(timstr)) {
-               media_svc_error("Invalid Parameter");
-               return 0;
-       }
-
-       /*Exif Format : %Y:%m:%d %H:%M:%S
-       Videoc Content Creation_time format of FFMpeg : %Y-%m-%d %H:%M:%S*/
-       memset(&t, 0x00, sizeof(struct tm));
-
-       tzset();
-       time(&rawtime);
-       localtime_r(&rawtime, &timeinfo);
-
-       if (strptime(timstr, "%Y:%m:%d %H:%M:%S", &t) || strptime(timstr, "%Y-%m-%d %H:%M:%S", &t)) {
-               t.tm_isdst = timeinfo.tm_isdst;
-               if (t.tm_isdst != 0)
-                       media_svc_debug("DST %d", t.tm_isdst);
-
-               /* If time string has timezone */
-               if (strptime(timstr, "%Y:%m:%d %H:%M:%S %z", &t) || strptime(timstr, "%Y-%m-%d %H:%M:%S %z", &t)) {
-                       char tim_tmp_str[255] = { 0, };
-
-                       /* ISO8601 Time string format */
-                       strftime(tim_tmp_str, 255, "%Y-%m-%dT%H:%M:%S%z", &t);
-                       GDateTime *pdatetime = g_date_time_new_from_iso8601(tim_tmp_str, NULL);
-                       if (pdatetime)
-                               modified_t = g_date_time_to_unix(pdatetime);
-                       g_date_time_unref(pdatetime);
-                       media_svc_debug("Calibrated timeval : [%ld][%s]", modified_t, tim_tmp_str);
-               } else {
-                       /* Just localtime */
-                       modified_t = mktime(&t);
-               }
-
-               if (modified_t > 0)
-                       return modified_t;
-               else
-                       media_svc_debug("Failed to get timeline : [%s] [%d:%d:%d: %d:%d:%d]", timstr, t.tm_year, t.tm_mon, t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec);
-       } else {
-               media_svc_error("Failed to get timeline : [%s]", timstr);
-       }
-
-       return 0;
-}
-
 static int __media_svc_get_media_type(const char *path, const char *mime_type, media_svc_media_type_e *media_type)
 {
        int idx = 0;
@@ -382,22 +317,18 @@ static int __media_svc_save_image(unsigned char *image, unsigned int size, char
        return MS_MEDIA_ERR_NONE;
 }
 
-static char *__media_svc_get_title_from_filepath(const char *path)
+static char *__media_svc_get_title_from_filename(const char *filename)
 {
-       char *filename = NULL;
        char *title = NULL;
        char *last_dot = NULL;
 
-       media_svc_retvm_if(!STRING_VALID(path), NULL, "Invalid path");
-
-       filename = g_path_get_basename(path);
+       media_svc_retvm_if(!STRING_VALID(filename), g_strdup(MEDIA_SVC_TAG_UNKNOWN), "Invalid path");
 
        last_dot = strrchr(filename, '.');
        if (last_dot) {
                title = g_strndup(filename, last_dot - filename);
-               g_free(filename);
        } else {
-               title = filename;
+               title = g_strdup(filename);
        }
 
        media_svc_debug("extract title is [%s]", title);
@@ -414,38 +345,28 @@ void _media_svc_remove_file(const char *path)
                media_svc_stderror("fail to remove file result");
 }
 
-int _media_svc_get_thumbnail_path(char *thumb_path, const char *pathname, const char *img_format, uid_t uid)
+static int __media_svc_get_thumbnail_path(char *thumb_path, const char *pathname, const char *img_format, uid_t uid)
 {
        int ret = MS_MEDIA_ERR_NONE;
        char file_ext[MEDIA_SVC_FILE_EXT_LEN_MAX + 1] = {0, };
-       char hash[THUMB_HASH_LEN] = {0, };
-       char *thumb_dir = NULL;
+       g_autofree gchar *hash = NULL;
+       g_autofree gchar *thumb_dir = NULL;
 
        ret = ms_user_get_root_thumb_store_path(uid, &thumb_dir);
-       media_svc_retvm_if(!STRING_VALID(thumb_dir), MS_MEDIA_ERR_INTERNAL, "ms_user_get_root_thumb_store_path failed");
-
-       if (!g_file_test(thumb_dir, G_FILE_TEST_IS_DIR)) {
-               media_svc_error("Wrong path[%s]", thumb_dir);
-               g_free(thumb_dir);
-               return MS_MEDIA_ERR_INTERNAL;
-       }
+       media_svc_retvm_if(!STRING_VALID(thumb_dir), ret, "ms_user_get_root_thumb_store_path failed");
+       media_svc_retvm_if(!g_file_test(thumb_dir, G_FILE_TEST_IS_DIR), MS_MEDIA_ERR_INTERNAL, "Not a directory");
 
        memset(file_ext, 0, sizeof(file_ext));
        if (!__media_svc_get_file_ext(pathname, file_ext))
                media_svc_error("get file ext fail");
 
-       ret = mb_svc_generate_hash_code(pathname, hash, THUMB_HASH_LEN);
-       if (ret != MS_MEDIA_ERR_NONE) {
-               media_svc_error("mb_svc_generate_hash_code failed : %d", ret);
-               g_free(thumb_dir);
-               return MS_MEDIA_ERR_INTERNAL;
-       }
+       hash = g_compute_checksum_for_string(G_CHECKSUM_MD5, pathname, -1);
+       media_svc_retvm_if(!hash, MS_MEDIA_ERR_INTERNAL, "Failed to create hashname");
 
        if (img_format) {
                /* 'img_format' is mime-type */
                if (!g_str_has_prefix(img_format, IMAGE_PREFIX) || strlen(img_format) == IMAGE_PREFIX_LEN) {
                        media_svc_error("Not proper img format");
-                       g_free(thumb_dir);
                        return MS_MEDIA_ERR_INTERNAL;
                }
 
@@ -457,8 +378,6 @@ int _media_svc_get_thumbnail_path(char *thumb_path, const char *pathname, const
                        snprintf(thumb_path, MEDIA_SVC_PATHNAME_SIZE, "%s/.%s-%s.jpg", thumb_dir, file_ext, hash);
        }
 
-       g_free(thumb_dir);
-
        return MS_MEDIA_ERR_NONE;
 }
 
@@ -530,12 +449,11 @@ int _media_svc_set_media_info(media_svc_content_info_s *content_info, const char
        return MS_MEDIA_ERR_NONE;
 }
 
-static char * __media_svc_get_title(MMHandleType tag, const char *path)
+static char * __media_svc_get_title(MMHandleType tag, const char *filename)
 {
        int ret = FILEINFO_ERROR_NONE;
        char *p = NULL;
        int size = 0;
-       char *title = NULL;
 
        if (tag) {
                ret = mm_file_get_attrs(tag, MM_FILE_TAG_TITLE, &p, &size, NULL);
@@ -547,19 +465,13 @@ static char * __media_svc_get_title(MMHandleType tag, const char *path)
                }
        }
 
-       title = __media_svc_get_title_from_filepath(path);
-       if (title)
-               return title;
-
-       media_svc_error("Can't extract title");
-
-       return g_strdup(MEDIA_SVC_TAG_UNKNOWN);
+       return __media_svc_get_title_from_filename(filename);
 }
 
-char * _media_svc_get_title_by_path(const char *path)
+char * _media_svc_get_title_from_filename(const char *filename)
 {
        /* No MMHandleType in media-svc.c */
-       return __media_svc_get_title(NULL, path);
+       return __media_svc_get_title_from_filename(filename);
 }
 
 int _media_svc_extract_image_metadata(media_svc_content_info_s *content_info)
@@ -578,16 +490,14 @@ int _media_svc_extract_image_metadata(media_svc_content_info_s *content_info)
        media_svc_retvm_if(!STRING_VALID(content_info->path), MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid path");
 
        path = content_info->path;
-       content_info->media_meta.title = __media_svc_get_title(NULL, path);
+       content_info->media_meta.title = __media_svc_get_title_from_filename(content_info->file_name);
 
        /* Not used. But to preserved the behavior, set MEDIA_SVC_TAG_UNKNOWN. */
        content_info->media_meta.album = g_strdup(MEDIA_SVC_TAG_UNKNOWN);
        content_info->media_meta.artist = g_strdup(MEDIA_SVC_TAG_UNKNOWN);
        content_info->media_meta.album_artist = g_strdup(MEDIA_SVC_TAG_UNKNOWN);
        content_info->media_meta.genre = g_strdup(MEDIA_SVC_TAG_UNKNOWN);
-       content_info->media_meta.composer = g_strdup(MEDIA_SVC_TAG_UNKNOWN);
        content_info->media_meta.year = g_strdup(MEDIA_SVC_TAG_UNKNOWN);
-       content_info->media_meta.copyright = g_strdup(MEDIA_SVC_TAG_UNKNOWN);
        content_info->media_meta.track_num = g_strdup(MEDIA_SVC_TAG_UNKNOWN);
 
        /* Load an ExifData object from an EXIF file */
@@ -598,14 +508,6 @@ int _media_svc_extract_image_metadata(media_svc_content_info_s *content_info)
        }
 
        memset(buf, 0x00, sizeof(buf));
-       if (__media_svc_get_exif_info(ed, buf, NULL, EXIF_TAG_IMAGE_DESCRIPTION) == MS_MEDIA_ERR_NONE) {
-               if (strlen(buf) > 0)
-                       content_info->media_meta.description = g_strdup(buf);
-               else
-                       content_info->media_meta.description = g_strdup(MEDIA_SVC_TAG_UNKNOWN);
-       }
-
-       memset(buf, 0x00, sizeof(buf));
        if (!has_datetaken && __media_svc_get_exif_info(ed, buf, NULL, EXIF_TAG_DATE_TIME_ORIGINAL) == MS_MEDIA_ERR_NONE) {
                if (strlen(buf) > 0) {
                        has_datetaken = true;
@@ -627,13 +529,8 @@ int _media_svc_extract_image_metadata(media_svc_content_info_s *content_info)
                }
        }
 
-       if (has_datetaken) {
-               content_info->timeline = __media_svc_get_timeline_from_str(content_info->media_meta.datetaken);
-               if (content_info->timeline == 0)
-                       content_info->timeline = content_info->modified_time;
-               else
-                       media_svc_debug("Timeline : %ld", content_info->timeline);
-       }
+       if (content_info->media_meta.recorded_date == NULL)
+               content_info->media_meta.recorded_date = g_strdup(MEDIA_SVC_TAG_UNKNOWN);
 
        /* Get orientation value from exif. */
        if (__media_svc_get_exif_info(ed, NULL, &orient_value, EXIF_TAG_ORIENTATION) == MS_MEDIA_ERR_NONE) {
@@ -657,14 +554,14 @@ int _media_svc_extract_image_metadata(media_svc_content_info_s *content_info)
                exif_data_unref(ed);
 
 GET_WIDTH_HEIGHT:
-
        if (content_info->media_meta.width == 0 || content_info->media_meta.height == 0) {
                /*Get image width, height*/
                unsigned int img_width = 0;
                unsigned int img_height = 0;
-               mm_util_img_codec_type img_type = IMG_CODEC_UNKNOWN_TYPE;
 
-               mm_util_extract_image_info(path, &img_type, &img_width, &img_height);
+               if (get_image_info(path, &img_width, &img_height) != THUMB_OK)
+                       return MS_MEDIA_ERR_NONE;
+
                if (content_info->media_meta.width == 0)
                        content_info->media_meta.width = img_width;
 
@@ -688,9 +585,8 @@ static char * __media_svc_get_tag_str_value(MMHandleType tag, const char *tag_na
        return g_strdup(MEDIA_SVC_TAG_UNKNOWN);
 }
 
-int _media_svc_extract_media_metadata(sqlite3 *handle, bool is_direct, media_svc_content_info_s *content_info, uid_t uid)
+int _media_svc_extract_audio_metadata(sqlite3 *handle, bool is_direct, media_svc_content_info_s *content_info, uid_t uid)
 {
-       MMHandleType content = 0;
        MMHandleType tag = 0;
        char *p = NULL;
        unsigned char *image = NULL;
@@ -708,44 +604,29 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, bool is_direct, media_svc
                mmf_error = mm_file_create_tag_attrs_no_albumart(&tag, content_info->path);
 
        if (mmf_error == FILEINFO_ERROR_NONE) {
-               content_info->media_meta.title = __media_svc_get_title(tag, content_info->path);
+               content_info->media_meta.title = __media_svc_get_title(tag, content_info->file_name);
                content_info->media_meta.album = __media_svc_get_tag_str_value(tag, MM_FILE_TAG_ALBUM);
                content_info->media_meta.artist = __media_svc_get_tag_str_value(tag, MM_FILE_TAG_ARTIST);
                content_info->media_meta.album_artist = __media_svc_get_tag_str_value(tag, MM_FILE_TAG_ALBUM_ARTIST);
                content_info->media_meta.genre = __media_svc_get_tag_str_value(tag, MM_FILE_TAG_GENRE);
-               content_info->media_meta.description = __media_svc_get_tag_str_value(tag, MM_FILE_TAG_DESCRIPTION);
-               content_info->media_meta.composer = __media_svc_get_tag_str_value(tag, MM_FILE_TAG_AUTHOR);
-               content_info->media_meta.copyright = __media_svc_get_tag_str_value(tag, MM_FILE_TAG_COPYRIGHT);
                content_info->media_meta.track_num = __media_svc_get_tag_str_value(tag, MM_FILE_TAG_TRACK_NUM);
+               content_info->media_meta.copyright = __media_svc_get_tag_str_value(tag, MM_FILE_TAG_COPYRIGHT);
 
                mmf_error = mm_file_get_attrs(tag, MM_FILE_TAG_RECDATE, &p, &size, NULL);
                if ((mmf_error == FILEINFO_ERROR_NONE) && (size > 0)) {
                        if (g_str_has_suffix(content_info->mime_type, "mp4") || g_str_has_suffix(content_info->mime_type, "3gpp")) {
-                               /*Creation time format is 2013-01-01 00:00:00 +0000. change it to 2013:01:01 00:00:00  +0000 like exif time format*/
+                               /*Creation time format is 20130101 00:00:00 +0000. change it to 2013:01:01 00:00:00  +0000 like exif time format*/
                                char *p_value = g_strdelimit(g_strdup(p), "-", ':');
                                content_info->media_meta.recorded_date = g_strdup_printf("%s +0000", p_value);
                                g_free(p_value);
                        } else {
                                content_info->media_meta.recorded_date = g_strdup(p);
                        }
-
-                       if (STRING_VALID(content_info->media_meta.recorded_date)) {
-                               content_info->timeline = __media_svc_get_timeline_from_str(content_info->media_meta.recorded_date);
-                               if (content_info->timeline == 0)
-                                       content_info->timeline = content_info->modified_time;
-
-                               /* This is same as datetaken */
-                               /* Remove compensation string */
-                               if (strlen(content_info->media_meta.recorded_date) > MEDIA_SVC_DEFAULT_FORMAT_LEN) {
-                                       content_info->media_meta.datetaken = g_strndup(content_info->media_meta.recorded_date, MEDIA_SVC_DEFAULT_FORMAT_LEN);
-                                       g_free(content_info->media_meta.recorded_date);
-                                       content_info->media_meta.recorded_date = g_strdup(content_info->media_meta.datetaken);
-                               } else {
-                                       content_info->media_meta.datetaken = g_strdup(content_info->media_meta.recorded_date);
-                               }
-                       }
                }
 
+               if (content_info->media_meta.recorded_date == NULL)
+                       content_info->media_meta.recorded_date = g_strdup(MEDIA_SVC_TAG_UNKNOWN);
+
                mmf_error = mm_file_get_attrs(tag, MM_FILE_TAG_DATE, &p, &size, NULL);
                if (mmf_error == FILEINFO_ERROR_NONE && size == 4) {
                        if (__media_svc_safe_atoi(p, &convert_value) == MS_MEDIA_ERR_NONE)
@@ -755,14 +636,6 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, bool is_direct, media_svc
                if (!content_info->media_meta.year)
                                content_info->media_meta.year = g_strdup(MEDIA_SVC_TAG_UNKNOWN);
 
-               mmf_error = mm_file_get_attrs(tag, MM_FILE_TAG_RATING, &p, &size, NULL);
-               if (mmf_error == FILEINFO_ERROR_NONE && size > 0) {
-                       if (__media_svc_safe_atoi(p, &convert_value) == MS_MEDIA_ERR_NONE)
-                               content_info->media_meta.rating = convert_value;
-               } else {
-                       content_info->media_meta.rating = 0;
-               }
-
                /*Do not extract artwork for the USB Storage content*/
                if (support_albumart) {
                        mmf_error = mm_file_get_attrs(tag, MM_FILE_TAG_ARTWORK, &image, &size, NULL);
@@ -779,7 +652,7 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, bool is_direct, media_svc
 
                                mmf_error = mm_file_get_attrs(tag, MM_FILE_TAG_ARTWORK_MIME, &p, &artwork_mime_size, NULL);
                                if ((mmf_error == FILEINFO_ERROR_NONE) && (artwork_mime_size > 0)) {
-                                       ret = _media_svc_get_thumbnail_path(thumb_path, content_info->path, p, uid);
+                                       ret = __media_svc_get_thumbnail_path(thumb_path, content_info->path, p, uid);
                                        if (ret != MS_MEDIA_ERR_NONE) {
                                                media_svc_error("Fail to Get Thumbnail Path");
                                        } else {
@@ -812,52 +685,66 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, bool is_direct, media_svc
                        content_info->album_id = album_id;
                }
 
-               if (content_info->media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO) {
-                       mmf_error = mm_file_get_attrs(tag, MM_FILE_TAG_ROTATE, &p, &size, NULL);
-                       if ((mmf_error == FILEINFO_ERROR_NONE) && (size > 0)) {
-                               content_info->media_meta.orientation = atoi(p);
-                       } else {
-                               content_info->media_meta.orientation = 0;
-                               media_svc_debug("fail to get video orientation attr - err(%x)", mmf_error);
-                       }
-               }
-
                mmf_error = mm_file_destroy_tag_attrs(tag);
                if (mmf_error != FILEINFO_ERROR_NONE)
                        media_svc_error("fail to free tag attr - err(%x)", mmf_error);
        }       else {
-               content_info->media_meta.title = __media_svc_get_title(NULL, content_info->path);
+               content_info->media_meta.title = __media_svc_get_title_from_filename(content_info->file_name);
                content_info->album_id = album_id;
        }
 
-       /*Get Content attribute ===========*/
-       mmf_error = mm_file_create_content_attrs_simple(&content, content_info->path);
+       return MS_MEDIA_ERR_NONE;
+}
 
-       media_svc_retvm_if(mmf_error != FILEINFO_ERROR_NONE, MS_MEDIA_ERR_NONE, "mm_file_create_content_attrs failed");
+int _media_svc_extract_video_metadata(media_svc_content_info_s *content_info)
+{
+       int mmf_error = FILEINFO_ERROR_NONE;
+       MMHandleType tag = 0;
+       MMHandleType content = 0;
+       char *p = NULL;
+       unsigned int size = 0;
 
-       if (content_info->media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO) {
-               int audio_bitrate = 0;
-               int video_bitrate = 0;
+       mmf_error = mm_file_create_tag_attrs_no_albumart(&tag, content_info->path);
+
+       if (mmf_error == FILEINFO_ERROR_NONE) {
+               mmf_error = mm_file_get_attrs(tag, MM_FILE_TAG_RECDATE, &p, &size, NULL);
+               if ((mmf_error == FILEINFO_ERROR_NONE) && (size > 0)) {
+                       if (g_str_has_suffix(content_info->mime_type, "mp4") || g_str_has_suffix(content_info->mime_type, "3gpp")) {
+                               /*Creation time format is 20130101 00:00:00 +0000. change it to 2013:01:01 00:00:00  +0000 like exif time format*/
+                               content_info->media_meta.recorded_date = g_strdelimit(g_strdup(p), "-", ':');
+                       } else {
+                               content_info->media_meta.recorded_date = g_strdup(p);
+                       }
+               }
 
-               mm_file_get_attrs(content, MM_FILE_CONTENT_DURATION, &content_info->media_meta.duration,
-                       MM_FILE_CONTENT_AUDIO_BITRATE, &audio_bitrate,
-                       MM_FILE_CONTENT_VIDEO_BITRATE, &video_bitrate,
-                       MM_FILE_CONTENT_VIDEO_WIDTH, &content_info->media_meta.width,
-                       MM_FILE_CONTENT_VIDEO_HEIGHT, &content_info->media_meta.height,
-                       NULL);
+               if (content_info->media_meta.recorded_date == NULL)
+                       content_info->media_meta.recorded_date = g_strdup(MEDIA_SVC_TAG_UNKNOWN);
+               content_info->media_meta.datetaken = g_strdup(content_info->media_meta.recorded_date);
 
-               content_info->media_meta.bitrate = audio_bitrate + video_bitrate;
-       } else {
-               mm_file_get_attrs(content, MM_FILE_CONTENT_DURATION, &content_info->media_meta.duration,
-                       MM_FILE_CONTENT_AUDIO_BITRATE, &content_info->media_meta.bitrate,
-                       MM_FILE_CONTENT_AUDIO_SAMPLERATE, &content_info->media_meta.samplerate,
-                       MM_FILE_CONTENT_AUDIO_CHANNELS, &content_info->media_meta.channel,
-                       MM_FILE_CONTENT_AUDIO_BITPERSAMPLE, &content_info->media_meta.bitpersample,
-                       NULL);
+               mmf_error = mm_file_destroy_tag_attrs(tag);
+               if (mmf_error != FILEINFO_ERROR_NONE)
+                       media_svc_error("fail to free tag attr - err(%x)", mmf_error);
        }
+       /*Get Content attribute ===========*/
+       mmf_error = mm_file_create_content_attrs_simple(&content, content_info->path);
+       media_svc_retvm_if(mmf_error != FILEINFO_ERROR_NONE, MS_MEDIA_ERR_NONE, "mm_file_create_content_attrs failed");
+
+       mm_file_get_attrs(content, MM_FILE_CONTENT_VIDEO_WIDTH, &content_info->media_meta.width,
+               MM_FILE_CONTENT_VIDEO_HEIGHT, &content_info->media_meta.height,
+               NULL);
 
        mm_file_destroy_content_attrs(content);
 
+       content_info->media_meta.title = __media_svc_get_title_from_filename(content_info->file_name);
+       content_info->media_meta.album = g_strdup(MEDIA_SVC_TAG_UNKNOWN);
+       content_info->media_meta.artist = g_strdup(MEDIA_SVC_TAG_UNKNOWN);
+       content_info->media_meta.album_artist = g_strdup(MEDIA_SVC_TAG_UNKNOWN);
+       content_info->media_meta.genre = g_strdup(MEDIA_SVC_TAG_UNKNOWN);
+       content_info->media_meta.track_num = g_strdup(MEDIA_SVC_TAG_UNKNOWN);
+       content_info->media_meta.year = g_strdup(MEDIA_SVC_TAG_UNKNOWN);
+       content_info->media_meta.copyright = g_strdup(MEDIA_SVC_TAG_UNKNOWN);
+       content_info->album_id = 0;
+
        return MS_MEDIA_ERR_NONE;
 }
 
@@ -1020,14 +907,12 @@ static gboolean __media_svc_get_xml_metadata(const xmlChar *buffer, gboolean is_
                return FALSE;
        }
 
-       content_info->media_meta.composer = __media_svc_find_and_get_value(root, "creator");
-       if (!content_info->media_meta.composer)
-               content_info->media_meta.composer = __media_svc_find_and_get_value(root, "author");
-
+       content_info->media_meta.artist = __media_svc_find_and_get_value(root, "creator");
+       if (!content_info->media_meta.artist)
+               content_info->media_meta.artist = __media_svc_find_and_get_value(root, "author");
+       content_info->media_meta.genre = __media_svc_find_and_get_value(root, "subject");
        content_info->media_meta.copyright = __media_svc_find_and_get_value(root, "publisher");
        content_info->media_meta.recorded_date = __media_svc_find_and_get_value(root, "date");
-       content_info->media_meta.genre = __media_svc_find_and_get_value(root, "subject");
-       content_info->media_meta.description = __media_svc_find_and_get_value(root, "description");
 
        xmlFreeDoc(doc);
 
@@ -1169,12 +1054,10 @@ void _media_svc_destroy_content_info(media_svc_content_info_s *content_info)
        g_free(content_info->media_meta.artist);
        g_free(content_info->media_meta.album_artist);
        g_free(content_info->media_meta.genre);
-       g_free(content_info->media_meta.composer);
        g_free(content_info->media_meta.year);
        g_free(content_info->media_meta.recorded_date);
        g_free(content_info->media_meta.copyright);
        g_free(content_info->media_meta.track_num);
-       g_free(content_info->media_meta.description);
        g_free(content_info->media_meta.datetaken);
 }
 
@@ -1193,20 +1076,21 @@ int _media_svc_create_thumbnail(const char *path, char *thumb_path, media_svc_me
 
        media_svc_sec_debug("Path[%s] Type[%d]", path, media_type);
 
-       //1. make hash path
-       ret = _media_svc_get_thumbnail_path(thumb_path, path, NULL, uid);
+       //1. make thumb path
+       ret = __media_svc_get_thumbnail_path(thumb_path, path, NULL, uid);
        if (ret != MS_MEDIA_ERR_NONE) {
-               media_svc_error("_media_svc_get_thumbnail_path failed - %d", ret);
+               media_svc_error("Failed to create thumbnail path[%d]", ret);
                SAFE_STRLCPY(thumb_path, "", MAX_FILEPATH_LEN);
                return ret;
        }
 
        //2. save thumbnail
        if (media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE)
-               return create_image_thumbnail_to_file(path, MEDIA_SVC_THUMB_WIDTH, MEDIA_SVC_THUMB_HEIGHT, thumb_path, true);
+               ret = create_image_thumbnail_to_file(path, MEDIA_SVC_THUMB_WIDTH, MEDIA_SVC_THUMB_HEIGHT, thumb_path, true);
        else
-               return create_video_thumbnail_to_file(path, MEDIA_SVC_THUMB_WIDTH, MEDIA_SVC_THUMB_HEIGHT, thumb_path, true);
+               ret = create_video_thumbnail_to_file(path, MEDIA_SVC_THUMB_WIDTH, MEDIA_SVC_THUMB_HEIGHT, thumb_path, true);
 
+       return (ret == THUMB_OK) ? MS_MEDIA_ERR_NONE : MS_MEDIA_ERR_INTERNAL;
 }
 
 int _media_svc_get_media_type(const char *path, int *mediatype)