Improve record date exception handling 49/223549/6
authorMinje Ahn <minje.ahn@samsung.com>
Fri, 31 Jan 2020 00:20:07 +0000 (09:20 +0900)
committerMinje ahn <minje.ahn@samsung.com>
Thu, 6 Feb 2020 00:06:39 +0000 (00:06 +0000)
Change-Id: I49aa5c63454e61fab4e3da7445c91671835e0fc7
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
src/common/media-svc-util.c

index f1cfa64..82ddaaa 100644 (file)
@@ -1239,32 +1239,11 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, bool is_direct, media_svc
 
                mmf_error = mm_file_get_attrs(tag, MM_FILE_TAG_RECDATE, &p, &size, NULL);
                if ((mmf_error == FILEINFO_ERROR_NONE) && (size > 0)) {
-                       char mime_type[255] = {0, };
-                       ret = __media_svc_get_mime_type(content_info->path, mime_type);
-                       /*if 3gp that audio only, media_type is music */
-                       if ((ret == MS_MEDIA_ERR_NONE) &&
-                               ((content_info->media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO && strcmp(mime_type, "video/mp4") == 0) ||
-                               (content_info->media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO && strcmp(mime_type, "video/3gpp") == 0) ||
-                               (content_info->media_type == MEDIA_SVC_MEDIA_TYPE_MUSIC && strcmp(mime_type, "video/3gpp") == 0) ||
-                               (content_info->media_type == MEDIA_SVC_MEDIA_TYPE_MUSIC && strcmp(mime_type, "audio/mp4") == 0))) {
-                               /*Creation time format is 2013-01-01 00:00:00 +0000. change it to 2013:01:01 00:00:00 like exif time format*/
-                               char *time_info = g_strdup_printf("0000:00:00 00:00:00 +0000");
-                               char *p_value = p;
-                               char *time_value = time_info;
-                               if (time_info != NULL) {
-                                       while (*p_value != '\0') {
-                                               if (*p_value == '-')
-                                                       *time_value = ':';
-                                               else
-                                                       *time_value = *p_value;
-                                               time_value++;
-                                               p_value++;
-                                       }
-                                       content_info->media_meta.recorded_date = g_strdup(time_info);
-                                       SAFE_FREE(time_info);
-                               } else {
-                                       media_svc_error("memory allocation error");
-                               }
+                       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*/
+                               char *p_value = g_strdelimit(g_strdup(p), "-", ':');
+                               content_info->media_meta.recorded_date = g_strdup_printf("%s +0000", p_value);
+                               SAFE_FREE(p_value);
                        } else {
                                content_info->media_meta.recorded_date = g_strdup(p);
                        }