Rollback recorded_date for web TC 53/309453/2
authorMinje Ahn <minje.ahn@samsung.com>
Thu, 11 Apr 2024 03:31:15 +0000 (12:31 +0900)
committerMinje ahn <minje.ahn@samsung.com>
Thu, 11 Apr 2024 06:57:25 +0000 (06:57 +0000)
Change-Id: I57066e691a7e950a7b269067fb5e735a39a7fa56
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
include/media-svc-util.h
src/media-svc-media.c
src/media-svc-util.c

index d6f15e2..a907e9f 100755 (executable)
@@ -46,6 +46,7 @@ typedef struct {
        char *album_artist;             /**< artist name*/
        char *genre;                            /**< genre of track*/
        char *year;                             /**< year*/
        char *album_artist;             /**< artist name*/
        char *genre;                            /**< genre of track*/
        char *year;                             /**< year*/
+       char *recorded_date;            /**< recorded date*/
        char *track_num;                        /**< track number*/
        unsigned int width;                             /**< width*/
        unsigned int height;                    /**< height*/
        char *track_num;                        /**< track number*/
        unsigned int width;                             /**< width*/
        unsigned int height;                    /**< height*/
index a24bdab..6c0c311 100755 (executable)
@@ -71,7 +71,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)
 {
 
 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_track_num, media_width, media_height, media_datetaken, 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);",
+       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_track_num, media_width, media_height, media_datetaken, orientation, storage_uuid) VALUES (%Q, %Q, %Q, %d, %Q, %lld, %d, %lld, %Q, %Q, %d, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %d, %d, %Q, %d, %Q);",
                        DB_TABLE_MEDIA,
                        content_info->media_uuid,
                        content_info->path,
                        DB_TABLE_MEDIA,
                        content_info->media_uuid,
                        content_info->path,
@@ -89,6 +89,7 @@ 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.album_artist,
                        content_info->media_meta.genre,
                        content_info->media_meta.year,
+                       content_info->media_meta.recorded_date,
                        content_info->media_meta.track_num,
                        content_info->media_meta.width,
                        content_info->media_meta.height,
                        content_info->media_meta.track_num,
                        content_info->media_meta.width,
                        content_info->media_meta.height,
@@ -126,7 +127,7 @@ int _media_svc_update_item_with_data(bool is_direct, media_svc_content_info_s *c
 {
        int ret = MS_MEDIA_ERR_NONE;
 
 {
        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_track_num=%Q, media_width=%d, media_height=%d, media_datetaken=%Q, 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_recorded_date=%Q, media_track_num=%Q, media_width=%d, media_height=%d, media_datetaken=%Q, orientation=%d, validity=1 WHERE media_path=%Q;",
                                DB_TABLE_MEDIA,
                                content_info->size,
                                content_info->modified_time,
                                DB_TABLE_MEDIA,
                                content_info->size,
                                content_info->modified_time,
@@ -138,6 +139,7 @@ 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.album_artist,
                                content_info->media_meta.genre,
                                content_info->media_meta.year,
+                               content_info->media_meta.recorded_date,
                                content_info->media_meta.track_num,
                                content_info->media_meta.width,
                                content_info->media_meta.height,
                                content_info->media_meta.track_num,
                                content_info->media_meta.width,
                                content_info->media_meta.height,
index a4bed31..ec2f652 100644 (file)
@@ -472,6 +472,7 @@ int _media_svc_extract_image_metadata(media_svc_content_info_s *content_info)
        }
 
        content_info->media_meta.datetaken = __media_svc_get_exif_datetaken(ed);
        }
 
        content_info->media_meta.datetaken = __media_svc_get_exif_datetaken(ed);
+       content_info->media_meta.recorded_date = g_strdup(content_info->media_meta.datetaken);
 
        if (__media_svc_get_exif_short(ed, EXIF_TAG_ORIENTATION, &orient_value)) {
                if (orient_value <= ROT_270)
 
        if (__media_svc_get_exif_short(ed, EXIF_TAG_ORIENTATION, &orient_value)) {
                if (orient_value <= ROT_270)
@@ -573,6 +574,18 @@ void _media_svc_extract_audio_metadata(sqlite3 *handle, bool is_direct, media_sv
        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.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);
 
+       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);
+               }
+       }
+
        mmf_error = mm_file_get_attrs(tag, MM_FILE_TAG_DATE, &p, &size, NULL);
        if (mmf_error == FILEINFO_ERROR_NONE && size == 4)
                content_info->media_meta.year = g_strdup(p);
        mmf_error = mm_file_get_attrs(tag, MM_FILE_TAG_DATE, &p, &size, NULL);
        if (mmf_error == FILEINFO_ERROR_NONE && size == 4)
                content_info->media_meta.year = g_strdup(p);
@@ -599,6 +612,29 @@ void _media_svc_extract_audio_metadata(sqlite3 *handle, bool is_direct, media_sv
 
 void _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;
+       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*/
+                               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);
+                       }
+               }
+
+               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);
+       }
        /* 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);
        /* 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);
@@ -926,6 +962,7 @@ 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.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.track_num);
        g_free(content_info->media_meta.datetaken);
 }
        g_free(content_info->media_meta.track_num);
        g_free(content_info->media_meta.datetaken);
 }