From 1a5fec1ac508281a1e99af102306726f23822b8a Mon Sep 17 00:00:00 2001 From: Hyunjun Ko Date: Wed, 20 Mar 2013 10:27:35 +0900 Subject: [PATCH] 1. Thumbnail extracting is enabled for burst shot 2. change some API to reduce DRM fuction call Change-Id: Ib928e1de33cf3cdb19e6de05fbb2482844ec3f12 --- CMakeLists.txt | 2 +- include/media-svc.h | 6 +- packaging/libmedia-service.spec | 2 +- plugin/media-content-plugin.c | 158 +++------------------------------ src/common/media-svc-media.c | 22 +++++ src/common/media-svc-util.c | 172 ++++++++++++++++++++++-------------- src/common/media-svc.c | 96 ++++++-------------- src/include/common/media-svc-util.h | 12 ++- test/media-service-test.c | 121 ++++++++++--------------- 9 files changed, 226 insertions(+), 365 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fe3b0da..f81ef49 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -89,7 +89,7 @@ SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--hash-style=both") CONFIGURE_FILE(libmedia-service.pc.in libmedia-service.pc @ONLY) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libmedia-service.pc DESTINATION lib/pkgconfig) -ADD_SUBDIRECTORY(test) +#ADD_SUBDIRECTORY(test) LINK_DIRECTORIES(lib) diff --git a/include/media-svc.h b/include/media-svc.h index 0a44d8b..61002c7 100755 --- a/include/media-svc.h +++ b/include/media-svc.h @@ -193,9 +193,9 @@ int media_svc_insert_item_begin(MediaSvcHandle *handle, int with_noti, int data_ int media_svc_insert_item_end(MediaSvcHandle *handle); -int media_svc_insert_item_bulk(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, const char *path, const char *mime_type, media_svc_media_type_e media_type, int is_burst); +int media_svc_insert_item_bulk(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, const char *path, int is_burst); -int media_svc_insert_item_immediately(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, const char *path, const char *mime_type, media_svc_media_type_e media_type); +int media_svc_insert_item_immediately(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, const char *path); int media_svc_move_item_begin(MediaSvcHandle *handle, int data_cnt); @@ -221,7 +221,7 @@ int media_svc_set_all_storage_items_validity(MediaSvcHandle *handle, media_svc_s int media_svc_set_folder_items_validity(MediaSvcHandle *handle, const char *folder_path, int validity, int recursive); -int media_svc_refresh_item(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, const char *path, media_svc_media_type_e media_type); +int media_svc_refresh_item(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, const char *path); int media_svc_rename_folder(MediaSvcHandle *handle, const char *src_path, const char *dst_path); diff --git a/packaging/libmedia-service.spec b/packaging/libmedia-service.spec index a6c5f00..87c1a8f 100755 --- a/packaging/libmedia-service.spec +++ b/packaging/libmedia-service.spec @@ -1,6 +1,6 @@ Name: libmedia-service Summary: Media information service library for multimedia applications. -Version: 0.2.29 +Version: 0.2.30 Release: 1 Group: System/Libraries License: Apache License, Version 2.0 diff --git a/plugin/media-content-plugin.c b/plugin/media-content-plugin.c index 5e63f9b..366c10e 100755 --- a/plugin/media-content-plugin.c +++ b/plugin/media-content-plugin.c @@ -112,99 +112,8 @@ static const char sound_mime_table[SOUND_MIME_NUM][MIME_LENGTH] = { "x-smaf", }; -static int __get_content_type_from_mime(const char * path, const char * mimetype, int * category); -static int __get_content_type(const char * file_path, const char * mime_type); static void __set_error_message(int err_type, char ** err_msg); -static int __get_content_type_from_mime(const char * path, const char * mimetype, int * category) -{ - int i = 0; - int err = 0; - - *category = MS_CATEGORY_UNKNOWN; - - //MS_DBG("mime type : %s", mimetype); - - /*categorize from mimetype */ - for (i = 0; i < CONTENT_TYPE_NUM; i++) { - if (strstr(mimetype, content_category[i].content_type) != NULL) { - *category = (*category | content_category[i].category_by_mime); - break; - } - } - - /*in application type, exitst sound file ex) x-smafs */ - if (*category & MS_CATEGORY_ETC) { - int prefix_len = strlen(content_category[0].content_type); - - for (i = 0; i < SOUND_MIME_NUM; i++) { - if (strstr(mimetype + prefix_len, sound_mime_table[i]) != NULL) { - *category ^= MS_CATEGORY_ETC; - *category |= MS_CATEGORY_SOUND; - break; - } - } - } - - /*check music file in soun files. */ - if (*category & MS_CATEGORY_SOUND) { - int prefix_len = strlen(content_category[0].content_type) + 1; - - //MS_DBG("mime_type : %s", mimetype + prefix_len); - - for (i = 0; i < MUSIC_MIME_NUM; i++) { - if (strcmp(mimetype + prefix_len, music_mime_table[i]) == 0) { - *category ^= MS_CATEGORY_SOUND; - *category |= MS_CATEGORY_MUSIC; - break; - } - } - - /*m3u file is playlist but mime type is "audio/x-mpegurl". but It has to be classified into MS_CATEGORY_ETC since playlist is not a sound track*/ - if(strncasecmp(mimetype, "audio/x-mpegurl", strlen("audio/x-mpegurl")) == 0) { - *category ^= MS_CATEGORY_SOUND; - *category |= MS_CATEGORY_ETC; - } - } else if (*category & MS_CATEGORY_VIDEO) { - /*some video files don't have video stream. in this case it is categorize as music. */ - /*"3gp" and "mp4" must check video stream and then categorize in directly. */ - char file_ext[10] = {0}; - memset(file_ext, 0, sizeof(file_ext)); - if((_media_svc_get_file_ext(path, file_ext)) && strlen(file_ext) > 0) { - if ((strncasecmp(file_ext, _3GP_FILE, 4) == 0) || (strncasecmp(file_ext, _MP4_FILE, 5) == 0)) { - int audio = 0; - int video = 0; - - err = mm_file_get_stream_info(path, &audio, &video); - if (err == 0) { - if (audio > 0 && video == 0) { - *category ^= MS_CATEGORY_VIDEO; - *category |= MS_CATEGORY_MUSIC; - } - } - } - } - } - - //MS_DBG("category_from_ext : %d", *category); - - return err; -} - -static int __get_content_type(const char * file_path, const char * mime_type) -{ - int ret = MEDIA_SVC_PLUGIN_ERROR_NONE; - int category = 0; - - ret = __get_content_type_from_mime(file_path, mime_type, &category); - - if (category & MS_CATEGORY_SOUND) return MEDIA_SVC_MEDIA_TYPE_SOUND; - else if (category & MS_CATEGORY_MUSIC) return MEDIA_SVC_MEDIA_TYPE_MUSIC; - else if (category & MS_CATEGORY_IMAGE) return MEDIA_SVC_MEDIA_TYPE_IMAGE; - else if (category & MS_CATEGORY_VIDEO) return MEDIA_SVC_MEDIA_TYPE_VIDEO; - else return MEDIA_SVC_MEDIA_TYPE_OTHER; -} - static void __set_error_message(int err_type, char ** err_msg) { if (err_msg) @@ -244,18 +153,13 @@ static void __set_error_message(int err_type, char ** err_msg) return; } -int check_item(const char *file_path, const char * mime_type, char ** err_msg) +int check_item(const char *file_path, char ** err_msg) { if (!STRING_VALID(file_path)) { __set_error_message(ERR_FILE_PATH, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } - if (!STRING_VALID(mime_type)) { - __set_error_message(ERR_MIME_TYPE, err_msg); - return MEDIA_SVC_PLUGIN_ERROR; - } - return MEDIA_SVC_PLUGIN_ERROR_NONE; } @@ -353,7 +257,7 @@ int insert_item_end(void * handle, char ** err_msg) return MEDIA_SVC_PLUGIN_ERROR_NONE; } -int insert_item(void * handle, const char *file_path, int storage_type, const char * mime_type, char ** err_msg) +int insert_item(void * handle, const char *file_path, int storage_type, char ** err_msg) { int ret = MEDIA_SVC_PLUGIN_ERROR_NONE; @@ -367,19 +271,12 @@ int insert_item(void * handle, const char *file_path, int storage_type, const ch return MEDIA_SVC_PLUGIN_ERROR; } - if (!STRING_VALID(mime_type)) { - __set_error_message(ERR_MIME_TYPE, err_msg); - return MEDIA_SVC_PLUGIN_ERROR; - } - if(!STORAGE_VALID(storage_type)) { __set_error_message(ERR_STORAGE_TYPE, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } - media_svc_media_type_e content_type = __get_content_type(file_path, mime_type); - - ret = media_svc_insert_item_bulk(handle, storage_type, file_path, mime_type, content_type, FALSE); + ret = media_svc_insert_item_bulk(handle, storage_type, file_path, FALSE); if(ret < 0) { __set_error_message(ret, err_msg); return MEDIA_SVC_PLUGIN_ERROR; @@ -388,7 +285,7 @@ int insert_item(void * handle, const char *file_path, int storage_type, const ch return MEDIA_SVC_PLUGIN_ERROR_NONE; } -int insert_item_immediately(void * handle, const char *file_path, int storage_type, const char * mime_type, char ** err_msg) +int insert_item_immediately(void * handle, const char *file_path, int storage_type, char ** err_msg) { int ret = MEDIA_SVC_PLUGIN_ERROR_NONE; @@ -402,20 +299,12 @@ int insert_item_immediately(void * handle, const char *file_path, int storage_ty return MEDIA_SVC_PLUGIN_ERROR; } - if (!STRING_VALID(mime_type)) { - __set_error_message(ERR_MIME_TYPE, err_msg); - return MEDIA_SVC_PLUGIN_ERROR; - } - if(!STORAGE_VALID(storage_type)) { __set_error_message(ERR_STORAGE_TYPE, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } - media_svc_media_type_e content_type = __get_content_type(file_path, mime_type); - - ret = media_svc_insert_item_immediately(handle, storage_type, file_path, mime_type, content_type); - + ret = media_svc_insert_item_immediately(handle, storage_type, file_path); if(ret < 0) { __set_error_message(ret, err_msg); return MEDIA_SVC_PLUGIN_ERROR; @@ -424,7 +313,7 @@ int insert_item_immediately(void * handle, const char *file_path, int storage_ty return MEDIA_SVC_PLUGIN_ERROR_NONE; } -int insert_burst_item(void * handle, const char *file_path, int storage_type, const char * mime_type, char ** err_msg) +int insert_burst_item(void * handle, const char *file_path, int storage_type, char ** err_msg) { int ret = MEDIA_SVC_PLUGIN_ERROR_NONE; @@ -438,19 +327,12 @@ int insert_burst_item(void * handle, const char *file_path, int storage_type, co return MEDIA_SVC_PLUGIN_ERROR; } - if (!STRING_VALID(mime_type)) { - __set_error_message(ERR_MIME_TYPE, err_msg); - return MEDIA_SVC_PLUGIN_ERROR; - } - if(!STORAGE_VALID(storage_type)) { __set_error_message(ERR_STORAGE_TYPE, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } - media_svc_media_type_e content_type = __get_content_type(file_path, mime_type); - - ret = media_svc_insert_item_bulk(handle, storage_type, file_path, mime_type, content_type, TRUE); + ret = media_svc_insert_item_bulk(handle, storage_type, file_path, TRUE); if(ret < 0) { __set_error_message(ret, err_msg); return MEDIA_SVC_PLUGIN_ERROR; @@ -495,7 +377,7 @@ int move_item_end(void * handle, char ** err_msg) return MEDIA_SVC_PLUGIN_ERROR_NONE; } -int move_item(void * handle, const char *src_path, int src_storage_type, const char *dest_path, int dest_storage_type, const char * mime_type, char ** err_msg) +int move_item(void * handle, const char *src_path, int src_storage_type, const char *dest_path, int dest_storage_type, char ** err_msg) { int ret = MEDIA_SVC_PLUGIN_ERROR_NONE; @@ -509,11 +391,6 @@ int move_item(void * handle, const char *src_path, int src_storage_type, const c return MEDIA_SVC_PLUGIN_ERROR; } - if (!STRING_VALID(mime_type)) { - __set_error_message(ERR_MIME_TYPE, err_msg); - return MEDIA_SVC_PLUGIN_ERROR; - } - if((!STORAGE_VALID(src_storage_type)) || (!STORAGE_VALID(dest_storage_type))) { __set_error_message(ERR_STORAGE_TYPE, err_msg); return MEDIA_SVC_PLUGIN_ERROR; @@ -610,7 +487,7 @@ int set_item_validity_end(void * handle, char ** err_msg) return MEDIA_SVC_PLUGIN_ERROR_NONE; } -int set_item_validity(void * handle, const char *file_path, int storage_type, const char * mime_type, int validity, char ** err_msg) +int set_item_validity(void * handle, const char *file_path, int storage_type, int validity, char ** err_msg) { int ret = MEDIA_SVC_PLUGIN_ERROR_NONE; @@ -624,11 +501,6 @@ int set_item_validity(void * handle, const char *file_path, int storage_type, co return MEDIA_SVC_PLUGIN_ERROR; } - if (!STRING_VALID(mime_type)) { - __set_error_message(ERR_MIME_TYPE, err_msg); - return MEDIA_SVC_PLUGIN_ERROR; - } - if(!STORAGE_VALID(storage_type)) { __set_error_message(ERR_STORAGE_TYPE, err_msg); return MEDIA_SVC_PLUGIN_ERROR; @@ -768,7 +640,7 @@ int delete_all_items(void * handle, char ** err_msg) return MEDIA_SVC_PLUGIN_ERROR_NONE; } -int refresh_item(void * handle, const char *file_path, int storage_type, const char * mime_type, char ** err_msg) +int refresh_item(void * handle, const char *file_path, int storage_type, char ** err_msg) { int ret = MEDIA_SVC_PLUGIN_ERROR_NONE; @@ -782,20 +654,12 @@ int refresh_item(void * handle, const char *file_path, int storage_type, const c return MEDIA_SVC_PLUGIN_ERROR; } - if (!STRING_VALID(mime_type)) { - __set_error_message(ERR_MIME_TYPE, err_msg); - return MEDIA_SVC_PLUGIN_ERROR; - } - if(!STORAGE_VALID(storage_type)) { __set_error_message(ERR_STORAGE_TYPE, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } - media_svc_media_type_e content_type = __get_content_type(file_path, mime_type); - - ret = media_svc_refresh_item(handle, storage_type, file_path, content_type); - + ret = media_svc_refresh_item(handle, storage_type, file_path); if(ret < 0) { __set_error_message(ret, err_msg); return MEDIA_SVC_PLUGIN_ERROR; diff --git a/src/common/media-svc-media.c b/src/common/media-svc-media.c index 3422807..321ebec 100755 --- a/src/common/media-svc-media.c +++ b/src/common/media-svc-media.c @@ -191,6 +191,28 @@ int _media_svc_insert_item_with_data(sqlite3 *handle, media_svc_content_info_s * media_svc_debug("Burst id : %d", burst_id_int); burst_id = sqlite3_mprintf("%d", burst_id_int); } + + /* Get thumbnail for burst shot */ + char thumb_path[MEDIA_SVC_PATHNAME_SIZE + 1] = {0, }; + int width = 0; + int height = 0; + + err = thumbnail_request_from_db_with_size(content_info->path, thumb_path, sizeof(thumb_path), &width, &height); + if (err < 0) { + media_svc_error("thumbnail_request_from_db failed: %d", err); + } else { + media_svc_debug("thumbnail_request_from_db success: %s", thumb_path); + err = __media_svc_malloc_and_strncpy(&(content_info->thumbnail_path), thumb_path); + if (err < 0) { + content_info->thumbnail_path = NULL; + } + } + + if (content_info->media_meta.width <= 0) + content_info->media_meta.width = width; + + if (content_info->media_meta.height <= 0) + content_info->media_meta.height = height; } char *sql = sqlite3_mprintf("INSERT INTO %s (%s) VALUES (%Q, %Q, %Q, %d, %Q, %lld, %d, %d, %Q, \ diff --git a/src/common/media-svc-util.c b/src/common/media-svc-util.c index 50cb6f0..60e0763 100755 --- a/src/common/media-svc-util.c +++ b/src/common/media-svc-util.c @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include #include @@ -543,13 +543,14 @@ int _media_svc_get_file_time(const char *full_path) } int _media_svc_set_media_info(media_svc_content_info_s *content_info, media_svc_storage_type_e storage_type, - const char *path, const char *mime_type, media_svc_media_type_e media_type, bool refresh) + const char *path, media_svc_media_type_e *media_type, bool refresh, drm_content_info_s **drm_contentInfo) { int ret = MEDIA_INFO_ERROR_NONE; char * media_uuid = NULL; char * file_name = NULL; struct stat st; - drm_bool_type_e drm_type; + drm_bool_type_e drm_type = DRM_FALSE; + char mime_type[256] = {0}; ret = __media_svc_malloc_and_strncpy(&content_info->path, path); media_svc_retv_del_if(ret != MEDIA_INFO_ERROR_NONE, ret, content_info); @@ -602,7 +603,6 @@ int _media_svc_set_media_info(media_svc_content_info_s *content_info, media_svc_ return MEDIA_INFO_ERROR_NONE; } - content_info->media_type = media_type; content_info->storage_type = storage_type; time(&content_info->added_time); @@ -612,22 +612,36 @@ int _media_svc_set_media_info(media_svc_content_info_s *content_info, media_svc_ ret = __media_svc_malloc_and_strncpy(&content_info->media_uuid, media_uuid); media_svc_retv_del_if(ret != MEDIA_INFO_ERROR_NONE, ret, content_info); - ret = __media_svc_malloc_and_strncpy(&content_info->mime_type, mime_type); - media_svc_retv_del_if(ret != MEDIA_INFO_ERROR_NONE, ret, content_info); - file_name = g_path_get_basename(path); ret = __media_svc_malloc_and_strncpy(&content_info->file_name, file_name); SAFE_FREE(file_name); media_svc_retv_del_if(ret != MEDIA_INFO_ERROR_NONE, ret, content_info); - ret = drm_is_drm_file(content_info->path, &drm_type); + /* if the file is DRM file, drm_type value is DRM_TRUE(1). + if drm_contentinfo is not NULL, the file is OMA DRM.*/ + ret = _media_svc_get_mime_type(path, mime_type, &drm_type, drm_contentInfo); if (ret < 0) { - media_svc_error("drm_is_drm_file falied : %d", ret); - drm_type = DRM_FALSE; + media_svc_error("media_svc_get_mime_type failed : %d (%s)", ret, path); + return MEDIA_INFO_ERROR_INVALID_PATH; } + media_svc_error("mime [%s]", mime_type); content_info->is_drm = drm_type; + ret = _media_svc_get_media_type(path, mime_type, media_type); + media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret); + if ((*media_type < MEDIA_SVC_MEDIA_TYPE_IMAGE) || (*media_type > MEDIA_SVC_MEDIA_TYPE_OTHER)) { + media_svc_error("invalid media_type condition[%d]", *media_type); + return MEDIA_INFO_ERROR_INVALID_PARAMETER; + } + + ret = __media_svc_malloc_and_strncpy(&content_info->mime_type, mime_type); + media_svc_retv_del_if(ret != MEDIA_INFO_ERROR_NONE, ret, content_info); + + media_svc_debug("storage[%d], path[%s], media_type[%d]", storage_type, path, *media_type); + + content_info->media_type = *media_type; + content_info->played_count = 0; content_info->last_played_time= 0; content_info->last_played_position= 0; @@ -800,7 +814,7 @@ int _media_svc_extract_image_metadata(media_svc_content_info_s *content_info, me return MEDIA_INFO_ERROR_NONE; } -int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s *content_info, media_svc_media_type_e media_type) +int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s *content_info, media_svc_media_type_e media_type, drm_content_info_s *drm_contentInfo) { MMHandleType content = 0; MMHandleType tag = 0; @@ -817,86 +831,61 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s int album_id = 0; double gps_value = 0.0; int ret = MEDIA_INFO_ERROR_NONE; - drm_bool_type_e drm_type; char *path = content_info->path; - ret = drm_is_drm_file(path, &drm_type); - if (ret < 0) { - media_svc_error("drm_is_drm_file falied : %d", ret); - drm_type = DRM_FALSE; - } - /*To do - code for DRM content*/ - if (drm_type) { - bool invalid_file = FALSE; + if (content_info->is_drm) { drm_file_type_e drm_file_type; - drm_permission_type_e drm_perm_type = DRM_PERMISSION_TYPE_PLAY; - drm_content_info_s contentInfo; - drm_license_status_e license_status; - memset(&contentInfo, 0x00, sizeof(drm_content_info_s)); ret = drm_get_file_type(path, &drm_file_type); if (ret < 0) { media_svc_error("drm_get_file_type falied : %d", ret); drm_file_type = DRM_TYPE_UNDEFINED; - invalid_file = TRUE; - } - - ret = drm_get_content_info(path, &contentInfo); - if (ret != DRM_RETURN_SUCCESS) { - media_svc_error("drm_get_content_info() fails. : %d", ret); - invalid_file = TRUE; } - ret = drm_get_license_status(path, drm_perm_type, &license_status); - if (ret != DRM_RETURN_SUCCESS) { - media_svc_error("drm_get_license_status() fails. : %d", ret); - invalid_file = TRUE; - } - - if ((!invalid_file) && (license_status != DRM_LICENSE_STATUS_VALID)) { + /* if drm_contentinfo is not NULL, the file is OMA DRM.*/ + if (drm_contentInfo != NULL) { if (drm_file_type == DRM_TYPE_OMA_V1) { - - if (strlen(contentInfo.title) > 0) { - ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, contentInfo.title); + if (strlen(drm_contentInfo->title) > 0) { + ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, drm_contentInfo->title); if(ret != MEDIA_INFO_ERROR_NONE) media_svc_error("strcpy error"); extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_TITLE; } - if (strlen(contentInfo.description) > 0) { - ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.description, contentInfo.description); + if (strlen(drm_contentInfo->description) > 0) { + ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.description, drm_contentInfo->description); if(ret != MEDIA_INFO_ERROR_NONE) media_svc_error("strcpy error"); extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_DESC; } } else if (drm_file_type == DRM_TYPE_OMA_V2) { - if (strlen(contentInfo.title) > 0) { - ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, contentInfo.title); + if (strlen(drm_contentInfo->title) > 0) { + ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, drm_contentInfo->title); if(ret != MEDIA_INFO_ERROR_NONE) media_svc_error("strcpy error"); extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_TITLE; } - if (strlen(contentInfo.description) > 0) { - ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.description, contentInfo.description); + if (strlen(drm_contentInfo->description) > 0) { + ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.description, drm_contentInfo->description); if(ret != MEDIA_INFO_ERROR_NONE) media_svc_error("strcpy error"); extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_DESC; } - if (strlen(contentInfo.copyright) > 0) { - ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.copyright, contentInfo.copyright); + if (strlen(drm_contentInfo->copyright) > 0) { + ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.copyright, drm_contentInfo->copyright); if(ret != MEDIA_INFO_ERROR_NONE) media_svc_error("strcpy error"); extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_COPYRIGHT; } - if (strlen(contentInfo.author) > 0) { - ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.composer, contentInfo.author); + if (strlen(drm_contentInfo->author) > 0) { + ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.composer, drm_contentInfo->author); if(ret != MEDIA_INFO_ERROR_NONE) media_svc_error("strcpy error"); - ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.artist, contentInfo.author); + ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.artist, drm_contentInfo->author); if(ret != MEDIA_INFO_ERROR_NONE) media_svc_error("strcpy error"); @@ -904,9 +893,7 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_ARTIST; } } - } - if (invalid_file) { if (!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_TITLE)) { title = _media_svc_get_title_from_filepath(path); if (title) { @@ -920,8 +907,7 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s } return MEDIA_INFO_ERROR_NONE; - } - else { + } else { media_svc_debug("Some Not OMA Content's metadata is not incrypted so fileinfo can extracted metadata"); } } @@ -1056,7 +1042,7 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s //media_svc_debug("genre : %s", content_info->media_meta.genre); /* If genre is Ringtone, it's categorized as sound. But this logic is commented */ /* - if ((strcasecmp("Ringtone", metadata.subBox.genre.str) == 0) | (strcasecmp("Alert tone", metadata.subBox.genre.str) == 0)) { + if ((strcasecmp("Ringtone", metadata.subBox.genre.str) == 0) | (strcasecmp("Alert tone", metadata.subBox.genre.str) == 0)) { content_info->media_type = MEDIA_SVC_MEDIA_TYPE_SOUND; } */ @@ -1870,10 +1856,9 @@ bool _media_svc_is_drm_file(const char *path) return FALSE; } -int _media_svc_get_mime_in_drm_info(const char *path, char *mime) +int _media_svc_get_mime_in_drm_info(const char *path, char *mime, drm_content_info_s **drm_contentInfo) { int ret = MEDIA_INFO_ERROR_NONE; - drm_content_info_s contentInfo; drm_file_type_e file_type = DRM_TYPE_UNDEFINED; if (path == NULL || mime == NULL) @@ -1887,21 +1872,27 @@ int _media_svc_get_mime_in_drm_info(const char *path, char *mime) if (file_type == DRM_TYPE_OMA_V1 || file_type == DRM_TYPE_OMA_V2 || file_type == DRM_TYPE_OMA_PD) { - memset(&contentInfo,0x0,sizeof(drm_content_info_s)); - ret = drm_get_content_info(path, &contentInfo); + *drm_contentInfo = malloc(sizeof(drm_content_info_s)); + memset(*drm_contentInfo,0x0,sizeof(drm_content_info_s)); + ret = drm_get_content_info(path, *drm_contentInfo); if (ret != DRM_RETURN_SUCCESS) { media_svc_error("drm_svc_get_content_info() fails :%d ", ret); + free(*drm_contentInfo); + *drm_contentInfo = NULL; return MEDIA_INFO_ERROR_INVALID_MEDIA; } - if (STRING_VALID(contentInfo.mime_type)) { - strncpy(mime, contentInfo.mime_type, MEDIA_SVC_METADATA_LEN_MAX); - media_svc_debug("DRM contentType : %s", contentInfo.mime_type); + if (STRING_VALID((*drm_contentInfo)->mime_type)) { + strncpy(mime,(*drm_contentInfo)->mime_type, MEDIA_SVC_METADATA_LEN_MAX); + media_svc_debug("DRM contentType : %s",(*drm_contentInfo)->mime_type); } else { + free(*drm_contentInfo); + *drm_contentInfo = NULL; return MEDIA_INFO_ERROR_INVALID_MEDIA; } } else { media_svc_error("THIS IS DRM BUT YOU SHOULD USE API OF AUL LIBRARY"); + *drm_contentInfo = NULL; return MEDIA_INFO_ERROR_INVALID_MEDIA; } } @@ -1977,3 +1968,56 @@ int _media_svc_get_content_type_from_mime(const char * path, const char * mimety return err; } + +/* +drm_contentifo is not NULL, if the file is OMA DRM. +If the file is not OMA DRM, drm_contentinfo must be NULL. +*/ +int _media_svc_get_mime_type(const char *path, char *mimetype, drm_bool_type_e *is_drm, drm_content_info_s **drm_contentInfo) +{ + int ret = MEDIA_INFO_ERROR_NONE; + + if (path == NULL) + return MEDIA_INFO_ERROR_INVALID_PARAMETER; + + /* In case of drm file. */ + if (_media_svc_is_drm_file(path)) { + *is_drm = DRM_TRUE; + ret = _media_svc_get_mime_in_drm_info(path, mimetype, drm_contentInfo); + if (ret == MEDIA_INFO_ERROR_NONE) { + return ret; + } + } + + /*in case of normal files or failure to get mime in drm */ + if (aul_get_mime_from_file(path, mimetype, 255) < 0) { + media_svc_error("aul_get_mime_from_file fail"); + return MEDIA_INFO_ERROR_INVALID_MEDIA; + } + + return MEDIA_INFO_ERROR_NONE; +} + +int _media_svc_get_media_type(const char *path, const char *mime_type, media_svc_media_type_e *media_type) +{ + int ret = MEDIA_INFO_ERROR_NONE; + int category = 0; + + media_svc_media_type_e type; + + ret = _media_svc_get_content_type_from_mime(path, mime_type, &category); + if (ret < 0) { + media_svc_error("_media_svc_get_content_type_from_mime failed : %d", ret); + } + + if (category & MEDIA_SVC_CATEGORY_SOUND) type = MEDIA_SVC_MEDIA_TYPE_SOUND; + else if (category & MEDIA_SVC_CATEGORY_MUSIC) type = MEDIA_SVC_MEDIA_TYPE_MUSIC; + else if (category & MEDIA_SVC_CATEGORY_IMAGE) type = MEDIA_SVC_MEDIA_TYPE_IMAGE; + else if (category & MEDIA_SVC_CATEGORY_VIDEO) type = MEDIA_SVC_MEDIA_TYPE_VIDEO; + else type = MEDIA_SVC_MEDIA_TYPE_OTHER; + + *media_type = type; + + return ret; +} + diff --git a/src/common/media-svc.c b/src/common/media-svc.c index 4dd92e8..ed4e60e 100755 --- a/src/common/media-svc.c +++ b/src/common/media-svc.c @@ -20,7 +20,7 @@ */ #include -#include +#include #include #include "media-svc.h" #include "media-svc-media.h" @@ -145,48 +145,21 @@ int media_svc_get_storage_type(const char *path, media_svc_storage_type_e *stora int media_svc_get_mime_type(const char *path, char *mimetype) { int ret = MEDIA_INFO_ERROR_NONE; + drm_bool_type_e is_drm = DRM_FALSE; + drm_content_info_s *drm_contentInfo = NULL; - if (path == NULL) - return MEDIA_INFO_ERROR_INVALID_PARAMETER; + ret = _media_svc_get_mime_type(path, mimetype, &is_drm, &drm_contentInfo); - /* In case of drm file. */ - if (_media_svc_is_drm_file(path)) { - ret = _media_svc_get_mime_in_drm_info(path, mimetype); - if (ret != MEDIA_INFO_ERROR_NONE) { - media_svc_error("Fail to get mime in DRM"); - } else { - return ret; - } - } + SAFE_FREE(drm_contentInfo); - /*in case of normal files or failure to get mime in drm */ - if (aul_get_mime_from_file(path, mimetype, 255) < 0) { - media_svc_error("aul_get_mime_from_file fail"); - return MEDIA_INFO_ERROR_INVALID_MEDIA; - } - - return MEDIA_INFO_ERROR_NONE; + return ret; } int media_svc_get_media_type(const char *path, const char *mime_type, media_svc_media_type_e *media_type) { int ret = MEDIA_INFO_ERROR_NONE; - int category = 0; - - media_svc_media_type_e type; - - ret = _media_svc_get_content_type_from_mime(path, mime_type, &category); - if (ret < 0) { - media_svc_error("_media_svc_get_content_type_from_mime failed : %d", ret); - } - if (category & MEDIA_SVC_CATEGORY_SOUND) type = MEDIA_SVC_MEDIA_TYPE_SOUND; - else if (category & MEDIA_SVC_CATEGORY_MUSIC) type = MEDIA_SVC_MEDIA_TYPE_MUSIC; - else if (category & MEDIA_SVC_CATEGORY_IMAGE) type = MEDIA_SVC_MEDIA_TYPE_IMAGE; - else if (category & MEDIA_SVC_CATEGORY_VIDEO) type = MEDIA_SVC_MEDIA_TYPE_VIDEO; - else type = MEDIA_SVC_MEDIA_TYPE_OTHER; - - *media_type = type; + ret = _media_svc_get_media_type(path, mime_type, media_type); return ret; } @@ -267,45 +240,39 @@ int media_svc_insert_item_end(MediaSvcHandle *handle) return ret; } -int media_svc_insert_item_bulk(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, - const char *path, const char *mime_type, media_svc_media_type_e media_type, int is_burst) +int media_svc_insert_item_bulk(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, const char *path, int is_burst) { int ret = MEDIA_INFO_ERROR_NONE; sqlite3 * db_handle = (sqlite3 *)handle; char folder_uuid[MEDIA_SVC_UUID_SIZE+1] = {0,}; + media_svc_media_type_e media_type; + drm_content_info_s *drm_contentInfo = NULL; media_svc_retvm_if(db_handle == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "Handle is NULL"); media_svc_retvm_if(!STRING_VALID(path), MEDIA_INFO_ERROR_INVALID_PARAMETER, "path is NULL"); - media_svc_retvm_if(!STRING_VALID(mime_type), MEDIA_INFO_ERROR_INVALID_PARAMETER, "mime_type is NULL"); if ((storage_type != MEDIA_SVC_STORAGE_INTERNAL) && (storage_type != MEDIA_SVC_STORAGE_EXTERNAL)) { media_svc_error("storage type is incorrect[%d]", storage_type); return MEDIA_INFO_ERROR_INVALID_PARAMETER; } - if ((media_type < MEDIA_SVC_MEDIA_TYPE_IMAGE) || (media_type > MEDIA_SVC_MEDIA_TYPE_OTHER)) { - media_svc_error("invalid media_type condition[%d]", media_type); - return MEDIA_INFO_ERROR_INVALID_PARAMETER; - } - - media_svc_debug("storage[%d], path[%s], media_type[%d]", storage_type, path, media_type); - media_svc_content_info_s content_info; memset(&content_info, 0, sizeof(media_svc_content_info_s)); /*Set media info*/ - ret = _media_svc_set_media_info(&content_info, storage_type, path, mime_type, media_type, FALSE); + /* if drm_contentinfo is not NULL, the file is OMA DRM.*/ + ret = _media_svc_set_media_info(&content_info, storage_type, path, &media_type, FALSE, &drm_contentInfo); media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret); if(media_type == MEDIA_SVC_MEDIA_TYPE_OTHER) { /*Do nothing.*/ } else if(media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE) { ret = _media_svc_extract_image_metadata(&content_info, media_type); - media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret); } else { - ret = _media_svc_extract_media_metadata(handle, &content_info, media_type); - media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret); + ret = _media_svc_extract_media_metadata(handle, &content_info, media_type, drm_contentInfo); } + SAFE_FREE(drm_contentInfo); + media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret); /*Set or Get folder id*/ ret = _media_svc_get_and_append_folder_id_by_path(handle, path, storage_type, folder_uuid); @@ -366,34 +333,27 @@ int media_svc_insert_item_bulk(MediaSvcHandle *handle, media_svc_storage_type_e return MEDIA_INFO_ERROR_NONE; } -int media_svc_insert_item_immediately(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, - const char *path, const char *mime_type, media_svc_media_type_e media_type) +int media_svc_insert_item_immediately(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, const char *path) { int ret = MEDIA_INFO_ERROR_NONE; sqlite3 * db_handle = (sqlite3 *)handle; char folder_uuid[MEDIA_SVC_UUID_SIZE+1] = {0,}; + media_svc_media_type_e media_type; + drm_content_info_s *drm_contentInfo = NULL; media_svc_retvm_if(db_handle == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "Handle is NULL"); media_svc_retvm_if(!STRING_VALID(path), MEDIA_INFO_ERROR_INVALID_PARAMETER, "path is NULL"); - media_svc_retvm_if(!STRING_VALID(mime_type), MEDIA_INFO_ERROR_INVALID_PARAMETER, "mime_type is NULL"); if ((storage_type != MEDIA_SVC_STORAGE_INTERNAL) && (storage_type != MEDIA_SVC_STORAGE_EXTERNAL)) { media_svc_error("storage type is incorrect[%d]", storage_type); return MEDIA_INFO_ERROR_INVALID_PARAMETER; } - if ((media_type < MEDIA_SVC_MEDIA_TYPE_IMAGE) || (media_type > MEDIA_SVC_MEDIA_TYPE_OTHER)) { - media_svc_error("invalid media_type condition[%d]", media_type); - return MEDIA_INFO_ERROR_INVALID_PARAMETER; - } - - media_svc_debug("storage[%d], path[%s], media_type[%d]", storage_type, path, media_type); - media_svc_content_info_s content_info; memset(&content_info, 0, sizeof(media_svc_content_info_s)); /*Set media info*/ - ret = _media_svc_set_media_info(&content_info, storage_type, path, mime_type, media_type, FALSE); + ret = _media_svc_set_media_info(&content_info, storage_type, path, &media_type, FALSE, &drm_contentInfo); media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret); if(media_type == MEDIA_SVC_MEDIA_TYPE_OTHER) { @@ -402,7 +362,7 @@ int media_svc_insert_item_immediately(MediaSvcHandle *handle, media_svc_storage_ ret = _media_svc_extract_image_metadata(&content_info, media_type); media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret); } else { - ret = _media_svc_extract_media_metadata(handle, &content_info, media_type); + ret = _media_svc_extract_media_metadata(handle, &content_info, media_type, drm_contentInfo); media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret); } @@ -875,11 +835,12 @@ int media_svc_set_folder_items_validity(MediaSvcHandle *handle, const char *fold return _media_svc_update_folder_item_validity(db_handle, folder_path, validity); } -int media_svc_refresh_item(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, - const char *path, media_svc_media_type_e media_type) +int media_svc_refresh_item(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, const char *path) { int ret = MEDIA_INFO_ERROR_NONE; sqlite3 * db_handle = (sqlite3 *)handle; + media_svc_media_type_e media_type; + drm_content_info_s *drm_contentInfo = NULL; media_svc_retvm_if(db_handle == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "Handle is NULL"); media_svc_retvm_if(!STRING_VALID(path), MEDIA_INFO_ERROR_INVALID_PARAMETER, "path is NULL"); @@ -889,13 +850,6 @@ int media_svc_refresh_item(MediaSvcHandle *handle, media_svc_storage_type_e stor return MEDIA_INFO_ERROR_INVALID_PARAMETER; } - if ((media_type < MEDIA_SVC_MEDIA_TYPE_IMAGE) || (media_type > MEDIA_SVC_MEDIA_TYPE_OTHER)) { - media_svc_error("invalid media_type condition[%d]", media_type); - return MEDIA_INFO_ERROR_INVALID_PARAMETER; - } - - media_svc_debug("storage[%d], path[%s], media_type[%d]", storage_type, path, media_type); - /* Get notification info */ media_svc_noti_item *noti_item = NULL; ret = _media_svc_get_noti_info(handle, path, MS_MEDIA_ITEM_FILE, ¬i_item); @@ -905,7 +859,7 @@ int media_svc_refresh_item(MediaSvcHandle *handle, media_svc_storage_type_e stor memset(&content_info, 0, sizeof(media_svc_content_info_s)); /*Set media info*/ - ret = _media_svc_set_media_info(&content_info, storage_type, path, NULL, media_type, TRUE); + ret = _media_svc_set_media_info(&content_info, storage_type, path, &media_type, TRUE, &drm_contentInfo); media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret); /* Initialize thumbnail information to remake thumbnail. */ @@ -927,7 +881,7 @@ int media_svc_refresh_item(MediaSvcHandle *handle, media_svc_storage_type_e stor ret = _media_svc_extract_image_metadata(&content_info, media_type); media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret); } else { - ret = _media_svc_extract_media_metadata(handle, &content_info, media_type); + ret = _media_svc_extract_media_metadata(handle, &content_info, media_type, drm_contentInfo); media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret); } #if 1 diff --git a/src/include/common/media-svc-util.h b/src/include/common/media-svc-util.h index cd1f80f..1272641 100755 --- a/src/include/common/media-svc-util.h +++ b/src/include/common/media-svc-util.h @@ -27,6 +27,7 @@ #include #include #include +#include #include "media-svc-types.h" #include "media-svc-env.h" @@ -57,9 +58,10 @@ int _media_svc_save_image(void *image, int size, char *image_path); bool _media_svc_get_thumbnail_path(media_svc_storage_type_e storage_type, char *thumb_path, const char *pathname, const char *img_format); bool _media_svc_get_file_ext(const char *file_path, char *file_ext); int _media_svc_get_file_time(const char *full_path); -int _media_svc_set_media_info(media_svc_content_info_s *content_info, media_svc_storage_type_e storage_type, const char *path, const char *mime_type, media_svc_media_type_e media_type, bool refresh); +int _media_svc_set_media_info(media_svc_content_info_s *content_info, media_svc_storage_type_e storage_type, + const char *path, media_svc_media_type_e *media_type, bool refresh, drm_content_info_s **drm_contentInfo); int _media_svc_extract_image_metadata(media_svc_content_info_s *content_info, media_svc_media_type_e media_type); -int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s *content_info, media_svc_media_type_e media_type); +int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s *content_info, media_svc_media_type_e media_type, drm_content_info_s *drm_contentInfo); int __media_svc_malloc_and_strncpy(char **dst, const char *src); void _media_svc_destroy_content_info(media_svc_content_info_s *content_info); int _media_svc_get_store_type_by_path(const char *path, media_svc_storage_type_e *storage_type); @@ -136,9 +138,13 @@ static const char sound_mime_table[SOUND_MIME_NUM][MIME_LENGTH] = { }; bool _media_svc_is_drm_file(const char *path); -int _media_svc_get_mime_in_drm_info(const char *path, char *mime); +int _media_svc_get_mime_in_drm_info(const char *path, char *mime, drm_content_info_s **drm_contentInfo); int _media_svc_get_content_type_from_mime(const char * path, const char * mimetype, int * category); +int _media_svc_get_mime_type(const char *path, char *mimetype, drm_bool_type_e *is_drm, drm_content_info_s **drm_contentInfo); + +int _media_svc_get_media_type(const char *path, const char *mime_type, media_svc_media_type_e *media_type); + #ifdef __cplusplus } #endif diff --git a/test/media-service-test.c b/test/media-service-test.c index 5410f21..3d7a51a 100644 --- a/test/media-service-test.c +++ b/test/media-service-test.c @@ -63,9 +63,7 @@ gboolean _send_noti_batch_operations(gpointer data) /* 1. media_svc_insert_item_immediately */ char *path = "/opt/usr/media/test/image1.jpg"; - media_svc_media_type_e media_type; media_svc_storage_type_e storage_type; - char mime_type[255] = {0, }; ret = media_svc_get_storage_type(path, &storage_type); if (ret < MEDIA_INFO_ERROR_NONE) { @@ -73,18 +71,6 @@ gboolean _send_noti_batch_operations(gpointer data) return FALSE; } - ret = media_svc_get_mime_type(path, mime_type); - if (ret < MEDIA_INFO_ERROR_NONE) { - media_svc_error("media_svc_get_mime_type failed : %d (%s)", ret, path); - return FALSE; - } - - ret = media_svc_get_media_type(path, mime_type, &media_type); - if (ret < MEDIA_INFO_ERROR_NONE) { - media_svc_error("media_svc_get_media_type failed : %d (%s)", ret, path); - return FALSE; - } - int i; char *file_list[10]; @@ -95,7 +81,7 @@ gboolean _send_noti_batch_operations(gpointer data) snprintf(filepath, sizeof(filepath), "%s%d.jpg", "/opt/usr/media/test/image", i+1); media_svc_debug("File : %s\n", filepath); file_list[i] = strdup(filepath); - ret = media_svc_insert_item_bulk(g_db_handle, storage_type, file_list[i], mime_type, media_type, FALSE); + ret = media_svc_insert_item_bulk(g_db_handle, storage_type, file_list[i], FALSE); if (ret != 0) { media_svc_error("media_svc_insert_item_bulk[%d] failed", i); } else { @@ -111,96 +97,81 @@ gboolean _send_noti_batch_operations(gpointer data) gboolean _send_noti_operations(gpointer data) { - int ret = MEDIA_INFO_ERROR_NONE; - - /* First of all, noti subscription */ - char *user_str = strdup("hi"); - media_db_update_subscribe(_noti_cb, (void*)user_str); + int ret = MEDIA_INFO_ERROR_NONE; - /* 1. media_svc_insert_item_immediately */ - char *path = "/opt/usr/media/test/image1.jpg"; + /* First of all, noti subscription */ + char *user_str = strdup("hi"); + media_db_update_subscribe(_noti_cb, (void*)user_str); - media_svc_media_type_e media_type; + /* 1. media_svc_insert_item_immediately */ + char *path = "/opt/usr/media/test/image1.jpg"; media_svc_storage_type_e storage_type; - char mime_type[255] = {0, }; ret = media_svc_get_storage_type(path, &storage_type); if (ret < MEDIA_INFO_ERROR_NONE) { media_svc_error("media_svc_get_storage_type failed : %d (%s)", ret, path); - return FALSE; + return FALSE; } - ret = media_svc_get_mime_type(path, mime_type); + ret = media_svc_insert_item_immediately(g_db_handle, storage_type, path); if (ret < MEDIA_INFO_ERROR_NONE) { - media_svc_error("media_svc_get_mime_type failed : %d (%s)", ret, path); - return FALSE; + media_svc_error("media_svc_insert_item_immediately failed : %d", ret); + return FALSE; } - ret = media_svc_get_media_type(path, mime_type, &media_type); - if (ret < MEDIA_INFO_ERROR_NONE) { - media_svc_error("media_svc_get_media_type failed : %d (%s)", ret, path); - return FALSE; - } - - ret = media_svc_insert_item_immediately(g_db_handle, storage_type, path, mime_type, media_type); - if (ret < MEDIA_INFO_ERROR_NONE) { - media_svc_error("media_svc_insert_item_immediately failed : %d", ret); - return FALSE; - } - - media_svc_debug("media_svc_insert_item_immediately success"); + media_svc_debug("media_svc_insert_item_immediately success"); /* 2. media_svc_refresh_item */ - ret = media_svc_refresh_item(g_db_handle, storage_type, path, media_type); - if (ret < MEDIA_INFO_ERROR_NONE) { - media_svc_error("media_svc_refresh_item failed : %d", ret); - return FALSE; - } - media_svc_debug("media_svc_refresh_item success"); + ret = media_svc_refresh_item(g_db_handle, storage_type, path); + if (ret < MEDIA_INFO_ERROR_NONE) { + media_svc_error("media_svc_refresh_item failed : %d", ret); + return FALSE; + } + media_svc_debug("media_svc_refresh_item success"); /* 2. media_svc_move_item */ const char *dst_path = "/opt/usr/media/test/image11.jpg"; - ret = media_svc_move_item(g_db_handle, storage_type, path, storage_type, dst_path); - if (ret < MEDIA_INFO_ERROR_NONE) { - media_svc_error("media_svc_move_item failed : %d", ret); - return FALSE; - } - media_svc_debug("media_svc_move_item success"); + ret = media_svc_move_item(g_db_handle, storage_type, path, storage_type, dst_path); + if (ret < MEDIA_INFO_ERROR_NONE) { + media_svc_error("media_svc_move_item failed : %d", ret); + return FALSE; + } + media_svc_debug("media_svc_move_item success"); - ret = media_svc_move_item(g_db_handle, storage_type, dst_path, storage_type, path); - if (ret < MEDIA_INFO_ERROR_NONE) { - media_svc_error("media_svc_move_item failed : %d", ret); - return FALSE; - } - media_svc_debug("media_svc_move_item success"); + ret = media_svc_move_item(g_db_handle, storage_type, dst_path, storage_type, path); + if (ret < MEDIA_INFO_ERROR_NONE) { + media_svc_error("media_svc_move_item failed : %d", ret); + return FALSE; + } + media_svc_debug("media_svc_move_item success"); /* 4. media_svc_delete_item_by_path */ ret = media_svc_delete_item_by_path(g_db_handle, path); - if (ret < MEDIA_INFO_ERROR_NONE) { - media_svc_error("media_svc_delete_item_by_path failed : %d", ret); - return FALSE; - } - media_svc_debug("media_svc_delete_item_by_path success"); + if (ret < MEDIA_INFO_ERROR_NONE) { + media_svc_error("media_svc_delete_item_by_path failed : %d", ret); + return FALSE; + } + media_svc_debug("media_svc_delete_item_by_path success"); /* Rename folder */ const char *src_folder_path = "/opt/usr/media/test"; const char *dst_folder_path = "/opt/usr/media/test_test"; ret = media_svc_rename_folder(g_db_handle, src_folder_path, dst_folder_path); - if (ret < MEDIA_INFO_ERROR_NONE) { - media_svc_error("media_svc_rename_folder failed : %d", ret); - return FALSE; - } - media_svc_debug("media_svc_rename_folder success"); + if (ret < MEDIA_INFO_ERROR_NONE) { + media_svc_error("media_svc_rename_folder failed : %d", ret); + return FALSE; + } + media_svc_debug("media_svc_rename_folder success"); /* Rename folder again */ ret = media_svc_rename_folder(g_db_handle, dst_folder_path, src_folder_path); - if (ret < MEDIA_INFO_ERROR_NONE) { - media_svc_error("media_svc_rename_folder failed : %d", ret); - return FALSE; - } - media_svc_debug("media_svc_rename_folder success"); + if (ret < MEDIA_INFO_ERROR_NONE) { + media_svc_error("media_svc_rename_folder failed : %d", ret); + return FALSE; + } + media_svc_debug("media_svc_rename_folder success"); - return FALSE; + return FALSE; } int test_noti() -- 2.7.4