Modify _media_svc_extract_book_metadata()
[platform/core/multimedia/libmedia-service.git] / src / common / media-svc-util.c
index 0427a85..c9e9b2d 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-util-user.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>
 #include <libxml/HTMLparser.h>
 #include <dlfcn.h>
 
-#define MEDIA_SVC_FILE_EXT_LEN_MAX                             6                       /**< Maximum file ext lenth*/
+#define MEDIA_SVC_FILE_EXT_LEN_MAX 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/"
-#define IMAGE_PREFIX_LEN 6
 #define AUDIO_PREFIX "audio/"
-#define AUDIO_PREFIX_LEN 6
 #define VIDEO_PREFIX "video/"
-#define VIDEO_PREFIX_LEN 6
-
-#define MEDIA_SVC_DEFAULT_GPS_VALUE                    -200                    /**< Default GPS Value*/
+#define PREFIX_LEN 6
 
 #define MEDIA_SVC_PDF_TAG_TAIL_LEN 12
 #define MEDIA_SVC_PDF_BUF_SIZE 256
@@ -115,7 +97,6 @@ static const char music_mime_table[MUSIC_MIME_NUM][MIME_LENGTH] = {
        "x-ape",
        "x-ms-asx",
        "vnd.rn-realaudio",
-
        "x-vorbis", /*alias of audio/x-vorbis+ogg*/
        "vorbis", /*alias of audio/x-vorbis+ogg*/
        "x-oggflac",
@@ -147,63 +128,10 @@ RETRY_GEN:
        return g_strdup(uuid_unparsed);
 }
 
-/* GPS information is not ExifTag member */
-static int __media_svc_get_exif_gps_double(ExifData *ed, double *value, long tagtype)
-{
-       ExifEntry *entry;
-       char gps_buf[MEDIA_SVC_METADATA_LEN_MAX + 1] = {0, };
-       double tmp_arr[3] = { 0.0, 0.0, 0.0 };
-       int i = 0;
-       char **tmp_split = NULL;
-
-       media_svc_retv_if(!ed, MS_MEDIA_ERR_INVALID_PARAMETER);
-       media_svc_retv_if(!value, MS_MEDIA_ERR_INVALID_PARAMETER);
-
-       entry = exif_data_get_entry(ed, tagtype);
-       media_svc_retv_if(!entry, MS_MEDIA_ERR_INTERNAL);
-
-       exif_entry_get_value(entry, gps_buf, sizeof(gps_buf));
-       gps_buf[strlen(gps_buf)] = '\0';
-
-       tmp_split = g_strsplit(gps_buf, ",", -1);
-       if (g_strv_length(tmp_split) != 3) {
-               g_strfreev(tmp_split);
-               media_svc_error("Wrong GPS format");
-               return MS_MEDIA_ERR_INTERNAL;
-       }
-
-       for (i = 0; i < 3; i++)
-               tmp_arr[i] = g_strtod(tmp_split[i], NULL);
-
-       g_strfreev(tmp_split);
-
-       *value = tmp_arr[0] + tmp_arr[1] / 60 + tmp_arr[2] / 3600;
-
-       return MS_MEDIA_ERR_NONE;
-}
-
-static int __media_svc_get_exif_gps_str(ExifData *ed, char *value, long tagtype)
-{
-       ExifEntry *entry;
-
-       media_svc_retv_if(!ed, MS_MEDIA_ERR_INVALID_PARAMETER);
-       media_svc_retv_if(!value, MS_MEDIA_ERR_INVALID_PARAMETER);
-
-       entry = exif_data_get_entry(ed, tagtype);
-       if (entry) {
-               exif_entry_get_value(entry, value, MEDIA_SVC_METADATA_LEN_MAX);
-               value[strlen(value)] = '\0';
-       }
-
-       return MS_MEDIA_ERR_NONE;
-}
-
-static int __media_svc_get_exif_info(ExifData *ed, char *buf, int *i_value, double *d_value, ExifTag tagtype)
+static int __media_svc_get_exif_info(ExifData *ed, char *buf, int *i_value, ExifTag tagtype)
 {
        ExifEntry *entry;
        ExifByteOrder mByteOrder;
-       ExifRational mRational;
-       long numerator, denominator;
 
        media_svc_retv_if(!ed, MS_MEDIA_ERR_INVALID_PARAMETER);
 
@@ -214,32 +142,12 @@ static int __media_svc_get_exif_info(ExifData *ed, char *buf, int *i_value, doub
        case EXIF_TAG_ORIENTATION:
        case EXIF_TAG_PIXEL_X_DIMENSION:
        case EXIF_TAG_PIXEL_Y_DIMENSION:
-       case EXIF_TAG_ISO_SPEED_RATINGS:
                media_svc_retvm_if(!i_value, MS_MEDIA_ERR_INVALID_PARAMETER, "i_value is NULL");
 
                mByteOrder = exif_data_get_byte_order(ed);
                short exif_value = exif_get_short(entry->data, mByteOrder);
                *i_value = (int)exif_value;
                break;
-       case EXIF_TAG_EXPOSURE_TIME:
-               media_svc_retvm_if(!buf, MS_MEDIA_ERR_INVALID_PARAMETER, "buf is NULL");
-
-               mByteOrder = exif_data_get_byte_order(ed);
-               mRational = exif_get_rational(entry->data, mByteOrder);
-               numerator = mRational.numerator;
-               denominator = mRational.denominator;
-               snprintf(buf, MEDIA_SVC_METADATA_LEN_MAX, "%ld/%ld", numerator, denominator);
-               break;
-       case EXIF_TAG_FNUMBER:
-               media_svc_retvm_if(!d_value, MS_MEDIA_ERR_INVALID_PARAMETER, "d_value is NULL");
-
-               mByteOrder = exif_data_get_byte_order(ed);
-               mRational = exif_get_rational(entry->data, mByteOrder);
-               numerator = mRational.numerator;
-               denominator = mRational.denominator;
-
-               *d_value = ((numerator*1.0)/(denominator*1.0));
-               break;
        default:
                media_svc_retvm_if(!buf, MS_MEDIA_ERR_INVALID_PARAMETER, "buf is NULL");
 
@@ -250,58 +158,6 @@ static int __media_svc_get_exif_info(ExifData *ed, char *buf, int *i_value, doub
        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;
@@ -313,36 +169,36 @@ static int __media_svc_get_media_type(const char *path, const char *mime_type, m
        media_svc_retvm_if(!media_type, MS_MEDIA_ERR_INVALID_PARAMETER, "media_type is null");
 
        /* Image */
-       if (strncmp(mime_type, IMAGE_PREFIX, IMAGE_PREFIX_LEN) == 0) {
+       if (strncmp(mime_type, IMAGE_PREFIX, PREFIX_LEN) == 0) {
                *media_type = MEDIA_SVC_MEDIA_TYPE_IMAGE;
                return MS_MEDIA_ERR_NONE;
        }
 
        /* Audio */
-       if (strncmp(mime_type, AUDIO_PREFIX, AUDIO_PREFIX_LEN) == 0) {
+       if (strncmp(mime_type, AUDIO_PREFIX, PREFIX_LEN) == 0) {
                *media_type = MEDIA_SVC_MEDIA_TYPE_SOUND;
 
                for (idx = 0; idx < MUSIC_MIME_NUM; idx++) {
-                       if (strcmp(mime_type + AUDIO_PREFIX_LEN, music_mime_table[idx]) == 0) {
+                       if (strcmp(mime_type + PREFIX_LEN, music_mime_table[idx]) == 0) {
                                *media_type = MEDIA_SVC_MEDIA_TYPE_MUSIC;
                                break;
                        }
                }
 
                /* audio/x-mpegurl : .m3u file (playlist file) */
-               if (strcmp(mime_type + AUDIO_PREFIX_LEN, "x-mpegurl") == 0)
+               if (strcmp(mime_type + PREFIX_LEN, "x-mpegurl") == 0)
                        *media_type = MEDIA_SVC_MEDIA_TYPE_OTHER;
 
                return MS_MEDIA_ERR_NONE;
        }
 
        /* Video */
-       if (strncmp(mime_type, VIDEO_PREFIX, VIDEO_PREFIX_LEN) == 0) {
+       if (strncmp(mime_type, VIDEO_PREFIX, PREFIX_LEN) == 0) {
                *media_type = MEDIA_SVC_MEDIA_TYPE_VIDEO;
 
                /*some video files don't have video stream. in this case it is categorize as music. */
-               if (strcmp(mime_type + VIDEO_PREFIX_LEN, "3gpp") == 0 ||
-                       strcmp(mime_type + VIDEO_PREFIX_LEN, "mp4") == 0) {
+               if (strcmp(mime_type + PREFIX_LEN, "3gpp") == 0 ||
+                       strcmp(mime_type + PREFIX_LEN, "mp4") == 0) {
                        if (mm_file_get_stream_info(path, &audio, &video) == FILEINFO_ERROR_NONE) {
                                if (audio > 0 && video == 0)
                                        *media_type = MEDIA_SVC_MEDIA_TYPE_MUSIC;
@@ -398,7 +254,7 @@ static bool __media_svc_get_file_ext(const char *file_path, char *file_ext)
 
        for (i = strlen(file_path); i >= 0; i--) {
                if (file_path[i] == '.') {
-                       SAFE_STRLCPY(file_ext, &file_path[i + 1], MEDIA_SVC_FILE_EXT_LEN_MAX);
+                       g_strlcpy(file_ext, &file_path[i + 1], MEDIA_SVC_FILE_EXT_LEN_MAX);
                        return true;
                }
 
@@ -457,22 +313,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);
@@ -489,42 +341,32 @@ 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) {
+               if (!g_str_has_prefix(img_format, IMAGE_PREFIX) || strlen(img_format) == PREFIX_LEN) {
                        media_svc_error("Not proper img format");
-                       g_free(thumb_dir);
                        return MS_MEDIA_ERR_INTERNAL;
                }
 
-               snprintf(thumb_path, MEDIA_SVC_PATHNAME_SIZE, "%s/.%s-%s.%s", thumb_dir, file_ext, hash, img_format + IMAGE_PREFIX_LEN);
+               snprintf(thumb_path, MEDIA_SVC_PATHNAME_SIZE, "%s/.%s-%s.%s", thumb_dir, file_ext, hash, img_format + PREFIX_LEN);
        } else {
                if (strcasecmp(file_ext, "PNG") == 0)
                        snprintf(thumb_path, MEDIA_SVC_PATHNAME_SIZE, "%s/.%s-%s.png", thumb_dir, file_ext, hash);
@@ -532,8 +374,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;
 }
 
@@ -549,13 +389,12 @@ int _media_svc_get_file_time(const char *full_path)
        return statbuf.st_mtime;
 }
 
-int _media_svc_set_media_info(media_svc_content_info_s *content_info, const char *storage_id, ms_user_storage_type_e storage_type, const char *path, bool refresh)
+int _media_svc_set_media_info(media_svc_content_info_s *content_info, const char *storage_id, const char *path, bool refresh)
 {
        int ret = MS_MEDIA_ERR_NONE;
        char mime_type[256] = {0, };
        media_svc_media_type_e media_type;
 
-       media_svc_retvm_if(!_media_svc_is_valid_storage_type(storage_type), MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid storage_type");
        media_svc_retvm_if(!STRING_VALID(path), MS_MEDIA_ERR_INVALID_PARAMETER, "path is NULL");
 
        content_info->path = g_strdup(path);
@@ -580,7 +419,6 @@ int _media_svc_set_media_info(media_svc_content_info_s *content_info, const char
        content_info->storage_uuid = g_strdup(storage_id);
        media_svc_retv_del_if(content_info->storage_uuid == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
 
-       content_info->storage_type = storage_type;
        time(&content_info->added_time);
 
        content_info->media_uuid = __media_info_generate_uuid();
@@ -600,102 +438,18 @@ int _media_svc_set_media_info(media_svc_content_info_s *content_info, const char
        content_info->mime_type = g_strdup(mime_type);
        media_svc_retv_del_if(content_info->mime_type == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
 
-       media_svc_sec_debug("storage[%d], path[%s], media_type[%d]", storage_type, path, media_type);
+       media_svc_sec_debug("path[%s], media_type[%d]", path, media_type);
 
        content_info->media_type = media_type;
 
        return MS_MEDIA_ERR_NONE;
 }
 
-static int __image_360_check(const char *path)
-{
-       FILE *fp = NULL;
-       size_t size = 0, app1_size = 0, exif_app1_xmp_size = 0;
-       unsigned char exif_header[4] = {0, };
-       unsigned char exif_app1[2] = {0, };
-       unsigned char exif_app1_xmp[2] = {0, };
-       unsigned char exif_app1_xmp_t[2] = {0, };
-       GString *xmp_data = NULL;
-       int fdata = 0;
-       int result = 0;
-
-       memset(exif_header, 0x00, sizeof(exif_header));
-       memset(exif_app1, 0x00, sizeof(exif_app1));
-       memset(exif_app1_xmp, 0x00, sizeof(exif_app1_xmp));
-       memset(exif_app1_xmp_t, 0x00, sizeof(exif_app1_xmp_t));
-
-       fp = fopen(path, "rb");
-       if (fp == NULL)
-               goto ERROR;
-
-       size = fread(exif_header, 1, sizeof(exif_header), fp);
-       if (size != sizeof(exif_header))
-               goto ERROR;
-
-       if ((exif_header[0] == 0xff) && (exif_header[1] == 0xd8) && (exif_header[2] == 0xff) && (exif_header[3] == 0xe1)) {
-               size = fread(exif_app1, 1, sizeof(exif_app1), fp);
-               if (size != sizeof(exif_app1))
-                       goto ERROR;
-
-               if ((size_t)((exif_app1[0] << 8) | (exif_app1[1])) <= 2)
-                       goto ERROR;
-
-               app1_size = (size_t)((exif_app1[0] << 8) | (exif_app1[1])) - 2 ;
-               if (fseek(fp, app1_size, SEEK_CUR) != 0)
-                       goto ERROR;
-
-               size = fread(exif_app1_xmp, 1, sizeof(exif_app1_xmp), fp);
-               if (size != sizeof(exif_app1_xmp))
-                       goto ERROR;
-
-               if ((exif_app1_xmp[0] == 0xff) && (exif_app1_xmp[1] == 0xe1)) {
-                       size = fread(exif_app1_xmp_t, 1, sizeof(exif_app1_xmp_t), fp);
-                       if (size != sizeof(exif_app1_xmp_t))
-                               goto ERROR;
-
-                       if ((size_t)((exif_app1_xmp_t[0] << 8) | (exif_app1_xmp_t[1])) <= 2)
-                               goto ERROR;
-
-                       exif_app1_xmp_size = (size_t)((exif_app1_xmp_t[0] << 8) | (exif_app1_xmp_t[1])) - 2;
-
-                       xmp_data = g_string_sized_new(exif_app1_xmp_size);
-
-                       do {
-                               exif_app1_xmp_size--;
-                               fdata = fgetc(fp);
-                               if (fdata == EOF)
-                                       continue;
-                               if (fdata == '\0')
-                                       continue;
-
-                               xmp_data = g_string_append_c(xmp_data, (gchar)fdata);
-                       } while (exif_app1_xmp_size > 0);
-
-                       if (strstr(xmp_data->str, "UsePanoramaViewer") &&
-                               strstr(xmp_data->str, "True") &&
-                               strstr(xmp_data->str, "ProjectionType") &&
-                               strstr(xmp_data->str, "equirectangular"))
-                               result = 1;
-
-                       g_string_free(xmp_data, TRUE);
-               }
-       }
-
-ERROR:
-       if (fp) {
-               fclose(fp);
-               fp = NULL;
-       }
-
-       return result;
-}
-
-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);
@@ -707,31 +461,21 @@ 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)
 {
-       double value = 0.0;
        int orient_value = 0;
        int exif_width = 0;
        int exif_height = 0;
        ExifData *ed = NULL;
        bool has_datetaken = false;
-       double fnumber = 0.0;
-       int iso = 0;
        char *path = NULL;
 
        char buf[MEDIA_SVC_METADATA_LEN_MAX + 1] = { '\0' };
@@ -741,20 +485,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.latitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
-       content_info->media_meta.longitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
-       content_info->media_meta.altitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
+       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 */
@@ -764,37 +502,8 @@ int _media_svc_extract_image_metadata(media_svc_content_info_s *content_info)
                goto GET_WIDTH_HEIGHT;
        }
 
-       content_info->media_meta.is_360 = __image_360_check(path);
-
-       memset(buf, 0x00, sizeof(buf));
-       if (__media_svc_get_exif_gps_double(ed, &value, EXIF_TAG_GPS_LATITUDE) == MS_MEDIA_ERR_NONE) {
-               if (__media_svc_get_exif_gps_str(ed, buf, EXIF_TAG_GPS_LATITUDE_REF) == MS_MEDIA_ERR_NONE) {
-                       if (!g_strcmp0(buf, "S"))
-                               value *= -1;
-                       content_info->media_meta.latitude = value;
-               }
-       }
-
-       memset(buf, 0x00, sizeof(buf));
-       if (__media_svc_get_exif_gps_double(ed, &value, EXIF_TAG_GPS_LONGITUDE) == MS_MEDIA_ERR_NONE) {
-               if (__media_svc_get_exif_gps_str(ed, buf, EXIF_TAG_GPS_LONGITUDE_REF) == MS_MEDIA_ERR_NONE) {
-                       if (!g_strcmp0(buf, "W"))
-                               value *= -1;
-
-                       content_info->media_meta.longitude = value;
-               }
-       }
-
-       memset(buf, 0x00, sizeof(buf));
-       if (__media_svc_get_exif_info(ed, buf, NULL, 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, NULL, EXIF_TAG_DATE_TIME_ORIGINAL) == MS_MEDIA_ERR_NONE) {
+       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;
                        content_info->media_meta.datetaken = g_strdup(buf);
@@ -805,7 +514,7 @@ int _media_svc_extract_image_metadata(media_svc_content_info_s *content_info)
        }
 
        memset(buf, 0x00, sizeof(buf));
-       if (!has_datetaken && __media_svc_get_exif_info(ed, buf, NULL, NULL, EXIF_TAG_DATE_TIME) == MS_MEDIA_ERR_NONE) {
+       if (!has_datetaken && __media_svc_get_exif_info(ed, buf, NULL, EXIF_TAG_DATE_TIME) == MS_MEDIA_ERR_NONE) {
                if (strlen(buf) > 0) {
                        has_datetaken = true;
                        content_info->media_meta.datetaken = g_strdup(buf);
@@ -815,50 +524,23 @@ 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);
-       }
-
-       memset(buf, 0x00, sizeof(buf));
-       /* Get exposure_time value from exif. */
-       if (__media_svc_get_exif_info(ed, buf, NULL, NULL, EXIF_TAG_EXPOSURE_TIME) == MS_MEDIA_ERR_NONE) {
-               if (strlen(buf) > 0)
-                       content_info->media_meta.exposure_time = g_strdup(buf);
-       }
-
-       /* Get fnumber value from exif. */
-       if (__media_svc_get_exif_info(ed, NULL, NULL, &fnumber, EXIF_TAG_FNUMBER) == MS_MEDIA_ERR_NONE)
-               content_info->media_meta.fnumber = fnumber;
-
-       /* Get iso value from exif. */
-       if (__media_svc_get_exif_info(ed, NULL, &iso, NULL, EXIF_TAG_ISO_SPEED_RATINGS) == MS_MEDIA_ERR_NONE)
-               content_info->media_meta.iso = iso;
-
-       memset(buf, 0x00, sizeof(buf));
-       /* Get model value from exif. */
-       if (__media_svc_get_exif_info(ed, buf, NULL, NULL, EXIF_TAG_MODEL) == MS_MEDIA_ERR_NONE) {
-               if (strlen(buf) > 0)
-                       content_info->media_meta.model = g_strdup(buf);
-       }
+       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, NULL, EXIF_TAG_ORIENTATION) == MS_MEDIA_ERR_NONE) {
+       if (__media_svc_get_exif_info(ed, NULL, &orient_value, EXIF_TAG_ORIENTATION) == MS_MEDIA_ERR_NONE) {
                if (orient_value >= NOT_AVAILABLE && orient_value <= ROT_270)
                        content_info->media_meta.orientation = orient_value;
        }
 
        /* Get width value from exif. */
-       if (__media_svc_get_exif_info(ed, NULL, &exif_width, NULL, EXIF_TAG_PIXEL_X_DIMENSION) == MS_MEDIA_ERR_NONE) {
+       if (__media_svc_get_exif_info(ed, NULL, &exif_width, EXIF_TAG_PIXEL_X_DIMENSION) == MS_MEDIA_ERR_NONE) {
                if (exif_width > 0)
                        content_info->media_meta.width = exif_width;
        }
 
        /* Get height value from exif. */
-       if (__media_svc_get_exif_info(ed, NULL, &exif_height, NULL, EXIF_TAG_PIXEL_Y_DIMENSION) == MS_MEDIA_ERR_NONE) {
+       if (__media_svc_get_exif_info(ed, NULL, &exif_height, EXIF_TAG_PIXEL_Y_DIMENSION) == MS_MEDIA_ERR_NONE) {
                if (exif_height > 0)
                        content_info->media_meta.height = exif_height;
        }
@@ -867,14 +549,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;
 
@@ -898,9 +580,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;
@@ -909,52 +590,38 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, bool is_direct, media_svc
        int album_id = 0;
        int ret = MS_MEDIA_ERR_NONE;
        int convert_value = 0;
+       bool support_albumart = ms_user_thumb_support(uid, content_info->path);
 
        /*Get Content Tag attribute ===========*/
-       if (content_info->storage_type == MS_USER_STORAGE_EXTERNAL_USB)
-               mmf_error = mm_file_create_tag_attrs_no_albumart(&tag, content_info->path);
-       else
+       if (support_albumart)
                mmf_error = mm_file_create_tag_attrs(&tag, content_info->path);
+       else
+               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)
@@ -964,18 +631,8 @@ 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;
-               }
-
-               mmf_error = mm_file_get_attrs(tag, MM_FILE_TAG_SPHERICAL, &content_info->media_meta.is_360, NULL);
-
                /*Do not extract artwork for the USB Storage content*/
-               if (content_info->storage_type != MS_USER_STORAGE_EXTERNAL_USB) {
+               if (support_albumart) {
                        mmf_error = mm_file_get_attrs(tag, MM_FILE_TAG_ARTWORK, &image, &size, NULL);
                        if (mmf_error != FILEINFO_ERROR_NONE)
                                media_svc_error("fail to get tag artwork - err(%x)", mmf_error);
@@ -990,7 +647,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 {
@@ -1023,69 +680,66 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, bool is_direct, media_svc
                        content_info->album_id = album_id;
                }
 
-               content_info->media_meta.longitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
-               content_info->media_meta.latitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
-               content_info->media_meta.altitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
+               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_from_filename(content_info->file_name);
+               content_info->album_id = album_id;
+       }
 
-               if (content_info->media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO) {
-                       double longitude = 0.0;
-                       double latitude = 0.0;
-                       double altitude = 0.0;
+       return MS_MEDIA_ERR_NONE;
+}
 
-                       mm_file_get_attrs(tag, MM_FILE_TAG_LONGITUDE, &longitude,
-                               MM_FILE_TAG_LATIDUE, &latitude,
-                               MM_FILE_TAG_ALTIDUE, &altitude,
-                               NULL);
+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;
 
-                       content_info->media_meta.longitude = (longitude == 0.0) ? MEDIA_SVC_DEFAULT_GPS_VALUE : longitude;
-                       content_info->media_meta.latitude = (latitude == 0.0) ? MEDIA_SVC_DEFAULT_GPS_VALUE : latitude;
-                       content_info->media_meta.altitude = (altitude == 0.0) ? MEDIA_SVC_DEFAULT_GPS_VALUE : altitude;
+       mmf_error = mm_file_create_tag_attrs_no_albumart(&tag, content_info->path);
 
-                       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);
+       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.orientation = 0;
-                               media_svc_debug("fail to get video orientation attr - err(%x)", mmf_error);
+                               content_info->media_meta.recorded_date = g_strdup(p);
                        }
                }
 
+               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);
+
                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->album_id = album_id;
        }
-
        /*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");
 
-       if (content_info->media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO) {
-               int audio_bitrate = 0;
-               int video_bitrate = 0;
-
-               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);
-
-               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);
-       }
+       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;
 }
 
@@ -1243,19 +897,18 @@ static gboolean __media_svc_get_xml_metadata(const xmlChar *buffer, gboolean is_
        }
 
        content_info->media_meta.title = __media_svc_find_and_get_value(root, "title");
+       /* In the case of PDF, if there is no title, it may not be a metadata block. Search for the next xml block*/
        if (is_pdf && !content_info->media_meta.title) {
                xmlFreeDoc(doc);
                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);
 
@@ -1371,12 +1024,22 @@ static int __media_svc_get_pdf_metadata(media_svc_content_info_s *content_info)
 
 int _media_svc_extract_book_metadata(media_svc_content_info_s *content_info)
 {
+       int ret = MS_MEDIA_ERR_NONE;
+
        media_svc_retvm_if(!content_info, MS_MEDIA_ERR_INVALID_PARAMETER, "content info is NULL");
 
        if (g_str_has_suffix(content_info->mime_type, "epub+zip"))
-               return __media_svc_get_epub_metadata(content_info);
+               ret = __media_svc_get_epub_metadata(content_info);
        else
-               return __media_svc_get_pdf_metadata(content_info);
+               ret = __media_svc_get_pdf_metadata(content_info);
+
+       media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "failed to extract metadata");
+       if (!content_info->media_meta.title || strlen(content_info->media_meta.title) == 0) {
+               g_free(content_info->media_meta.title);
+               content_info->media_meta.title = __media_svc_get_title_from_filename(content_info->file_name);
+       }
+
+       return MS_MEDIA_ERR_NONE;
 }
 
 void _media_svc_destroy_content_info(media_svc_content_info_s *content_info)
@@ -1397,15 +1060,11 @@ 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);
-       g_free(content_info->media_meta.exposure_time);
-       g_free(content_info->media_meta.model);
 }
 
 int _media_svc_create_thumbnail(const char *path, char *thumb_path, media_svc_media_type_e media_type, uid_t uid)
@@ -1416,30 +1075,24 @@ int _media_svc_create_thumbnail(const char *path, char *thumb_path, media_svc_me
        media_svc_retvm_if(!thumb_path, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid thumb_path");
        media_svc_retvm_if(!g_file_test(path, G_FILE_TEST_IS_REGULAR), MS_MEDIA_ERR_INVALID_PARAMETER, "File doesn't exist[%s]", path);
 
-       ms_user_storage_type_e store_type = -1;
-       ret = ms_user_get_storage_type(uid, path, &store_type);
-
-       if ((ret != MS_MEDIA_ERR_NONE) || ((store_type != MS_USER_STORAGE_INTERNAL) && (store_type != MS_USER_STORAGE_EXTERNAL))) {
-               media_svc_sec_error("origin path(%s) is invalid. err : [%d] store_type [%d]", path, ret, store_type);
+       if (!ms_user_thumb_support(uid, path)) {
+               media_svc_sec_error("origin path(%s) is invalid", path);
                return MS_MEDIA_ERR_INVALID_PARAMETER;
        }
 
        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);
-       if (ret != MS_MEDIA_ERR_NONE) {
-               media_svc_error("_media_svc_get_thumbnail_path failed - %d", ret);
-               SAFE_STRLCPY(thumb_path, "", MAX_FILEPATH_LEN);
-               return ret;
-       }
+       //1. make thumb path
+       ret = __media_svc_get_thumbnail_path(thumb_path, path, NULL, uid);
+       media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "Failed to create thumbnail path[%d]", 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)
@@ -1461,19 +1114,6 @@ int _media_svc_get_media_type(const char *path, int *mediatype)
        return ret;
 }
 
-bool _media_svc_is_valid_storage_type(ms_user_storage_type_e storage_type)
-{
-       switch (storage_type) {
-       case MS_USER_STORAGE_INTERNAL:
-       case MS_USER_STORAGE_EXTERNAL:
-       case MS_USER_STORAGE_EXTERNAL_USB:
-               return true;
-       default:
-               media_svc_error("storage type is incorrect[%d]", storage_type);
-               return false;
-       }
-}
-
 bool _media_svc_is_keyword_included(const char *path, const char *keyword)
 {
        bool ret = false;