diff options
author | minje.ahn <minje.ahn@samsung.com> | 2024-03-13 15:46:33 +0900 |
---|---|---|
committer | Minje Ahn <minje.ahn@samsung.com> | 2024-03-20 08:14:07 +0900 |
commit | 4a198893b7b867c0fd7de10a8b133334efafeb35 (patch) | |
tree | f6c0e5a6c81ecb1e3c468174eb8e25cd17247a02 | |
parent | 9999ab8dec056a7325449cde40fbfc9ac98c5dc6 (diff) | |
download | libmedia-service-4a198893b7b867c0fd7de10a8b133334efafeb35.tar.gz libmedia-service-4a198893b7b867c0fd7de10a8b133334efafeb35.tar.bz2 libmedia-service-4a198893b7b867c0fd7de10a8b133334efafeb35.zip |
Remove deprecated fields
These fields have not been removed yet, but are unused.
So the extraction code is removed.
After remove ACR, remaining code including DB fields will be removed.
Change-Id: Ia9df85138158b3b2f18135b93f26db555e8d55a5
Signed-off-by: minje.ahn <minje.ahn@samsung.com>
-rw-r--r-- | packaging/libmedia-service.spec | 2 | ||||
-rwxr-xr-x | src/common/media-svc-db-utils.c | 4 | ||||
-rwxr-xr-x | src/common/media-svc-media-folder.c | 2 | ||||
-rwxr-xr-x | src/common/media-svc-media.c | 8 | ||||
-rw-r--r-- | src/common/media-svc-util.c | 176 | ||||
-rwxr-xr-x | src/common/media-svc.c | 6 | ||||
-rwxr-xr-x | src/include/common/media-svc-util.h | 4 |
7 files changed, 56 insertions, 146 deletions
diff --git a/packaging/libmedia-service.spec b/packaging/libmedia-service.spec index 3be3e72..dc05164 100644 --- 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.5.3 +Version: 0.5.4 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 diff --git a/src/common/media-svc-db-utils.c b/src/common/media-svc-db-utils.c index 12529a7..4ed4cdb 100755 --- a/src/common/media-svc-db-utils.c +++ b/src/common/media-svc-db-utils.c @@ -374,8 +374,8 @@ int _media_svc_init_table_query(void) __add_column_info(&column_list[DB_LIST_MEDIA], "media_genre", DB_TYPE_TEXT, NULL, false, false, true); __add_column_info(&column_list[DB_LIST_MEDIA], "media_composer", DB_TYPE_TEXT, "DEFAULT ''", false, false, true); __add_column_info(&column_list[DB_LIST_MEDIA], "media_year", DB_TYPE_TEXT, NULL, false, false, true); - __add_column_info(&column_list[DB_LIST_MEDIA], "media_recorded_date", DB_TYPE_TEXT, NULL, false, false, true); - __add_column_info(&column_list[DB_LIST_MEDIA], "media_copyright", DB_TYPE_TEXT, NULL, false, false, true); + __add_column_info(&column_list[DB_LIST_MEDIA], "media_recorded_date", DB_TYPE_TEXT, "DEFAULT ''", false, false, true); + __add_column_info(&column_list[DB_LIST_MEDIA], "media_copyright", DB_TYPE_TEXT, "DEFAULT ''", false, false, true); __add_column_info(&column_list[DB_LIST_MEDIA], "media_track_num", DB_TYPE_TEXT, NULL, false, false, true); __add_column_info(&column_list[DB_LIST_MEDIA], "media_description", DB_TYPE_TEXT, "DEFAULT ''", false, false, true); __add_column_info(&column_list[DB_LIST_MEDIA], "media_bitrate", DB_TYPE_INT, "DEFAULT -1", false, false, true); diff --git a/src/common/media-svc-media-folder.c b/src/common/media-svc-media-folder.c index 64e9441..e594cc2 100755 --- a/src/common/media-svc-media-folder.c +++ b/src/common/media-svc-media-folder.c @@ -54,7 +54,7 @@ static int __media_svc_append_folder(bool is_direct, const char *storage_id, con folder_modified_date = _media_svc_get_file_time(folder_path); /* Sometime SQLITE3 returns NO_RECORD, so need to consider conflict case.. */ - char *sql = sqlite3_mprintf("INSERT OR IGNORE INTO %q (folder_path, folder_name, storage_uuid, folder_modified_time) VALUES (%Q, %Q, %Q, '%d');", + char *sql = sqlite3_mprintf("INSERT OR IGNORE INTO %q(folder_path, folder_name, storage_uuid, folder_modified_time) VALUES (%Q, %Q, %Q, %d);", DB_TABLE_FOLDER, folder_path, folder_name, storage_id, folder_modified_date); if (is_direct) diff --git a/src/common/media-svc-media.c b/src/common/media-svc-media.c index 66318df..d752e58 100755 --- a/src/common/media-svc-media.c +++ b/src/common/media-svc-media.c @@ -69,7 +69,7 @@ int _media_svc_get_modified_time(sqlite3 *handle, const char *path, int *modifie static char *__media_svc_make_insert_query(media_svc_content_info_s *content_info) { - return sqlite3_mprintf("INSERT INTO %q(media_id, media_path, media_display_name, media_type, media_mime_type, media_size, media_modified_time, folder_id, media_thumbnail_path, media_title, album_id, media_album, media_artist, media_album_artist, media_genre, media_year, media_recorded_date, media_copyright, media_track_num, media_width, media_height, media_datetaken, media_orientation, storage_uuid) VALUES (%Q, %Q, %Q, %d, %Q, %lld, %d, %lld, %Q, %Q, %d, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %d, %d, %Q, %d, %Q);", + return sqlite3_mprintf("INSERT INTO %q(media_id, media_path, media_display_name, media_type, media_mime_type, media_size, media_modified_time, folder_id, media_thumbnail_path, media_title, album_id, media_album, media_artist, media_album_artist, media_genre, media_year, media_track_num, media_width, media_height, media_datetaken, media_orientation, storage_uuid) VALUES (%Q, %Q, %Q, %d, %Q, %lld, %d, %lld, %Q, %Q, %d, %Q, %Q, %Q, %Q, %Q, %Q, %d, %d, %Q, %d, %Q);", DB_TABLE_MEDIA, content_info->media_uuid, content_info->path, @@ -87,8 +87,6 @@ static char *__media_svc_make_insert_query(media_svc_content_info_s *content_inf content_info->media_meta.album_artist, content_info->media_meta.genre, content_info->media_meta.year, - content_info->media_meta.recorded_date, - content_info->media_meta.copyright, content_info->media_meta.track_num, content_info->media_meta.width, content_info->media_meta.height, @@ -126,7 +124,7 @@ int _media_svc_update_item_with_data(bool is_direct, media_svc_content_info_s *c { int ret = MS_MEDIA_ERR_NONE; - char *sql = sqlite3_mprintf("UPDATE %q SET media_size=%lld, media_modified_time=%d, media_thumbnail_path=%Q, media_title=%Q, album_id=%d, media_album=%Q, media_artist=%Q, media_album_artist=%Q, media_genre=%Q, media_year=%Q, media_recorded_date=%Q, media_copyright=%Q, media_track_num=%Q, media_width=%d, media_height=%d, media_datetaken=%Q, media_orientation=%d, validity=1 WHERE media_path=%Q;", + char *sql = sqlite3_mprintf("UPDATE %q SET media_size=%lld, media_modified_time=%d, media_thumbnail_path=%Q, media_title=%Q, album_id=%d, media_album=%Q, media_artist=%Q, media_album_artist=%Q, media_genre=%Q, media_year=%Q, media_track_num=%Q, media_width=%d, media_height=%d, media_datetaken=%Q, media_orientation=%d, validity=1 WHERE media_path=%Q;", DB_TABLE_MEDIA, content_info->size, content_info->modified_time, @@ -138,8 +136,6 @@ int _media_svc_update_item_with_data(bool is_direct, media_svc_content_info_s *c content_info->media_meta.album_artist, content_info->media_meta.genre, content_info->media_meta.year, - content_info->media_meta.recorded_date, - content_info->media_meta.copyright, content_info->media_meta.track_num, content_info->media_meta.width, content_info->media_meta.height, diff --git a/src/common/media-svc-util.c b/src/common/media-svc-util.c index 4d80371..5a1956f 100644 --- a/src/common/media-svc-util.c +++ b/src/common/media-svc-util.c @@ -128,34 +128,45 @@ RETRY_GEN: return g_strdup(uuid_unparsed); } -static int __media_svc_get_exif_info(ExifData *ed, char *buf, int *i_value, ExifTag tagtype) +static char * __media_svc_get_exif_datetaken(ExifData *ed) { ExifEntry *entry; - ExifByteOrder mByteOrder; + char tmp[MEDIA_SVC_METADATA_LEN_MAX + 1] = { 0, }; - media_svc_retv_if(!ed, MS_MEDIA_ERR_INVALID_PARAMETER); + media_svc_retv_if(!ed, NULL); - entry = exif_data_get_entry(ed, tagtype); - media_svc_retv_if(!entry, MS_MEDIA_ERR_NONE); - - switch (tagtype) { - case EXIF_TAG_ORIENTATION: - case EXIF_TAG_PIXEL_X_DIMENSION: - case EXIF_TAG_PIXEL_Y_DIMENSION: - 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; - default: - media_svc_retvm_if(!buf, MS_MEDIA_ERR_INVALID_PARAMETER, "buf is NULL"); - - exif_entry_get_value(entry, buf, MEDIA_SVC_METADATA_LEN_MAX); - buf[strlen(buf)] = '\0'; + entry = exif_data_get_entry(ed, EXIF_TAG_DATE_TIME_ORIGINAL); + if (entry) { + exif_entry_get_value(entry, tmp, MEDIA_SVC_METADATA_LEN_MAX); + if (strlen(tmp) > 0) + return g_strdup(tmp); } - return MS_MEDIA_ERR_NONE; + entry = exif_data_get_entry(ed, EXIF_TAG_DATE_TIME); + if (entry) { + exif_entry_get_value(entry, tmp, MEDIA_SVC_METADATA_LEN_MAX); + if (strlen(tmp) > 0) + return g_strdup(tmp); + } + + return NULL; +} + +static bool __media_svc_get_exif_int(ExifData *ed, ExifTag tagtype, int *value) +{ + ExifEntry *entry; + + media_svc_retv_if(!ed, false); + media_svc_retvm_if(!value, false, "value is NULL"); + + entry = exif_data_get_entry(ed, tagtype); + media_svc_retv_if(!entry, false); + + short exif_value = exif_get_short(entry->data, exif_data_get_byte_order(ed)); + media_svc_retv_if(exif_value < 0, false); + *value = (int)exif_value; + + return true; } static int __media_svc_get_media_type(const char *path, const char *mime_type, media_svc_media_type_e *media_type) @@ -449,70 +460,34 @@ int _media_svc_extract_image_metadata(media_svc_content_info_s *content_info) int exif_width = 0; int exif_height = 0; ExifData *ed = NULL; - bool has_datetaken = false; - char *path = NULL; - - char buf[MEDIA_SVC_METADATA_LEN_MAX + 1] = { '\0' }; media_svc_retvm_if(!content_info, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid content_info"); - media_svc_retvm_if(content_info->media_type != MEDIA_SVC_MEDIA_TYPE_IMAGE, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid media_type [%d]", content_info->media_type); + media_svc_retvm_if(content_info->media_type != MEDIA_SVC_MEDIA_TYPE_IMAGE, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid media_type"); 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_from_filename(content_info->file_name); /* Load an ExifData object from an EXIF file */ - ed = exif_data_new_from_file(path); + ed = exif_data_new_from_file(content_info->path); if (!ed) { - media_svc_sec_debug("There is no exif data in [ %s ]", path); + media_svc_sec_debug("There is no exif data in [ %s ]", content_info->path); goto GET_WIDTH_HEIGHT; } - memset(buf, 0x00, sizeof(buf)); - if (!has_datetaken && __media_svc_get_exif_info(ed, buf, NULL, EXIF_TAG_DATE_TIME_ORIGINAL) == MS_MEDIA_ERR_NONE) { - if (strlen(buf) > 0) { - has_datetaken = true; - content_info->media_meta.datetaken = g_strdup(buf); - - /* This is same as recorded_date */ - content_info->media_meta.recorded_date = g_strdup(buf); - } - } - - memset(buf, 0x00, sizeof(buf)); - 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); - - /* This is same as recorded_date */ - content_info->media_meta.recorded_date = g_strdup(buf); - } - } + content_info->media_meta.datetaken = __media_svc_get_exif_datetaken(ed); - if (content_info->media_meta.recorded_date == NULL) - content_info->media_meta.recorded_date = g_strdup(MEDIA_SVC_TAG_UNKNOWN); - - /* Get orientation value from exif. */ - if (__media_svc_get_exif_info(ed, NULL, &orient_value, EXIF_TAG_ORIENTATION) == MS_MEDIA_ERR_NONE) { + if (__media_svc_get_exif_int(ed, EXIF_TAG_ORIENTATION, &orient_value)) { 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, EXIF_TAG_PIXEL_X_DIMENSION) == MS_MEDIA_ERR_NONE) { - if (exif_width > 0) - content_info->media_meta.width = exif_width; - } + if (__media_svc_get_exif_int(ed, EXIF_TAG_PIXEL_X_DIMENSION, &exif_width)) + content_info->media_meta.width = exif_width; - /* Get height value from exif. */ - 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; - } + if (__media_svc_get_exif_int(ed, EXIF_TAG_PIXEL_Y_DIMENSION, &exif_height)) + content_info->media_meta.height = exif_height; - if (ed) - exif_data_unref(ed); + exif_data_unref(ed); GET_WIDTH_HEIGHT: if (content_info->media_meta.width == 0 || content_info->media_meta.height == 0) { @@ -520,7 +495,7 @@ GET_WIDTH_HEIGHT: unsigned int img_width = 0; unsigned int img_height = 0; - if (get_image_info(path, &img_width, &img_height) != THUMB_OK) + if (get_image_info(content_info->path, &img_width, &img_height) != THUMB_OK) return MS_MEDIA_ERR_NONE; if (content_info->media_meta.width == 0) @@ -600,22 +575,6 @@ void _media_svc_extract_audio_metadata(sqlite3 *handle, bool is_direct, media_sv 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.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 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 (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) @@ -641,45 +600,9 @@ void _media_svc_extract_audio_metadata(sqlite3 *handle, bool is_direct, media_sv media_svc_error("destroy failed"); } -int _media_svc_extract_video_metadata(media_svc_content_info_s *content_info) +void _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; - - mmf_error = mm_file_create_tag_attrs_no_albumart(&tag, content_info->path); - - if (mmf_error == FILEINFO_ERROR_NONE) { - mmf_error = mm_file_get_attrs(tag, MM_FILE_TAG_RECDATE, &p, &size, NULL); - if ((mmf_error == FILEINFO_ERROR_NONE) && (size > 0)) { - if (g_str_has_suffix(content_info->mime_type, "mp4") || g_str_has_suffix(content_info->mime_type, "3gpp")) { - /*Creation time format is 20130101 00:00:00 +0000. change it to 2013:01:01 00:00:00 +0000 like exif time format*/ - content_info->media_meta.recorded_date = g_strdelimit(g_strdup(p), "-", ':'); - } else { - content_info->media_meta.recorded_date = g_strdup(p); - } - } - - 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); - } - /*Get Content attribute ===========*/ - mmf_error = mm_file_create_content_attrs_simple(&content, content_info->path); - media_svc_retvm_if(mmf_error != FILEINFO_ERROR_NONE, MS_MEDIA_ERR_NONE, "mm_file_create_content_attrs failed"); - - mm_file_get_attrs(content, MM_FILE_CONTENT_VIDEO_WIDTH, &content_info->media_meta.width, - MM_FILE_CONTENT_VIDEO_HEIGHT, &content_info->media_meta.height, - NULL); - - mm_file_destroy_content_attrs(content); - + /* All metadata fields must be empty strings until media_video is deleted */ 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); @@ -687,10 +610,7 @@ int _media_svc_extract_video_metadata(media_svc_content_info_s *content_info) 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; } static gchar * __media_svc_get_zipfile_string(zip_t *z, const char *fname) @@ -857,8 +777,6 @@ static gboolean __media_svc_get_xml_metadata(const xmlChar *buffer, gboolean is_ 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"); xmlFreeDoc(doc); @@ -1011,8 +929,6 @@ void _media_svc_destroy_content_info(media_svc_content_info_s *content_info) g_free(content_info->media_meta.album_artist); g_free(content_info->media_meta.genre); 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.datetaken); } diff --git a/src/common/media-svc.c b/src/common/media-svc.c index 088d441..1e47c7a 100755 --- a/src/common/media-svc.c +++ b/src/common/media-svc.c @@ -205,7 +205,7 @@ int media_svc_insert_item_bulk(sqlite3 *handle, const char *storage_id, const ch ret = _media_svc_extract_image_metadata(&content_info); break; case MEDIA_SVC_MEDIA_TYPE_VIDEO: - ret = _media_svc_extract_video_metadata(&content_info); + _media_svc_extract_video_metadata(&content_info); break; case MEDIA_SVC_MEDIA_TYPE_SOUND: case MEDIA_SVC_MEDIA_TYPE_MUSIC: @@ -272,7 +272,7 @@ int media_svc_insert_item_immediately(sqlite3 *handle, const char *storage_id, c ret = _media_svc_extract_image_metadata(&content_info); break; case MEDIA_SVC_MEDIA_TYPE_VIDEO: - ret = _media_svc_extract_video_metadata(&content_info); + _media_svc_extract_video_metadata(&content_info); break; case MEDIA_SVC_MEDIA_TYPE_SOUND: case MEDIA_SVC_MEDIA_TYPE_MUSIC: @@ -478,7 +478,7 @@ int media_svc_refresh_item(sqlite3 *handle, bool is_direct, const char *storage_ ret = _media_svc_extract_image_metadata(&content_info); break; case MEDIA_SVC_MEDIA_TYPE_VIDEO: - ret = _media_svc_extract_video_metadata(&content_info); + _media_svc_extract_video_metadata(&content_info); break; case MEDIA_SVC_MEDIA_TYPE_SOUND: case MEDIA_SVC_MEDIA_TYPE_MUSIC: diff --git a/src/include/common/media-svc-util.h b/src/include/common/media-svc-util.h index 4849395..ee22a5b 100755 --- a/src/include/common/media-svc-util.h +++ b/src/include/common/media-svc-util.h @@ -46,8 +46,6 @@ typedef struct { char *album_artist; /**< artist name*/ char *genre; /**< genre of track*/ char *year; /**< year*/ - char *recorded_date; /**< recorded date*/ - char *copyright; /**< copyright*/ char *track_num; /**< track number*/ int width; /**< width*/ int height; /**< height*/ @@ -96,7 +94,7 @@ char * _media_svc_get_title_from_filename(const char *filename); int _media_svc_set_media_info(media_svc_content_info_s *content_info, const char *storage_id, const char *path, bool refresh); int _media_svc_extract_image_metadata(media_svc_content_info_s *content_info); void _media_svc_extract_audio_metadata(sqlite3 *handle, bool is_direct, media_svc_content_info_s *content_info, uid_t uid); -int _media_svc_extract_video_metadata(media_svc_content_info_s *content_info); +void _media_svc_extract_video_metadata(media_svc_content_info_s *content_info); int _media_svc_extract_book_metadata(media_svc_content_info_s *content_info); void _media_svc_destroy_content_info(media_svc_content_info_s *content_info); int _media_svc_create_thumbnail(const char *path, char *thumb_path, media_svc_media_type_e media_type, uid_t uid); |