Modified to compensate for time zone 86/166986/1 accepted/tizen/4.0/unified/20180116.022711 submit/tizen_4.0/20180115.013348 tizen_4.0.IoT.p2_release
authorMinje Ahn <minje.ahn@samsung.com>
Fri, 27 Oct 2017 05:09:24 +0000 (14:09 +0900)
committerhj kim <backto.kim@samsung.com>
Mon, 15 Jan 2018 01:26:00 +0000 (10:26 +0900)
Change-Id: Id6ca590a246b2454852993876623c74e85a3dae4
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
packaging/libmedia-service.spec
src/common/media-svc-util.c

index 0da3b0e..5a57b67 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmedia-service
 Summary:    Media information service library for multimedia applications
-Version: 0.3.19
+Version: 0.3.20
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0 and PD
index 7f6ef83..26112f7 100755 (executable)
@@ -76,6 +76,8 @@
 #define _MP4_FILE ".mp4"
 #define _ASF_FILE ".asf"
 #define MEDIA_SVC_ARTWORK_SIZE 2000
+#define MEDIA_SVC_DEFAULT_FORMAT_LEN 19
+
 
 static int media_svc_pinyin_support = -1;
 
@@ -300,7 +302,21 @@ time_t __media_svc_get_timeline_from_str(const char *timstr)
                if (t.tm_isdst != 0)
                        media_svc_debug("DST %d", t.tm_isdst);
 
-               modified_t = mktime(&t);
+               /* 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)) {
+                       GTimeVal timeval;
+                       char tim_tmp_str[255] = { 0, };
+
+                       /* ISO8601 Time string format */
+                       strftime(tim_tmp_str, 255, "%Y-%m-%dT%H:%M:%S%z", &t);
+                       g_time_val_from_iso8601(tim_tmp_str, &timeval);
+                       modified_t = timeval.tv_sec;
+                       media_svc_debug("Calibrated timeval : [%d][%s]", modified_t, tim_tmp_str);
+               } else {
+                       /* Just localtime */
+                       modified_t = mktime(&t);
+               }
+
                if (modified_t > 0)
                        return modified_t;
                else
@@ -1581,9 +1597,16 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s
 
                mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_RECDATE, &p, &size, NULL);
                if ((mmf_error == FILEINFO_ERROR_NONE) && (size > 0)) {
-                       if (content_info->media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO) {
+                       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. change it to 2013:01:01 00:00:00 like exif time format*/
-                               char *time_info = (char*)calloc(1, (size + 1));
+                               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) {
@@ -1595,7 +1618,6 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s
                                                time_value++;
                                                p_value++;
                                        }
-                                       *time_value = '\0';
                                        content_info->media_meta.recorded_date = g_strdup(time_info);
                                        SAFE_FREE(time_info);
                                } else {
@@ -1607,14 +1629,21 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s
                        }
 
                        if (STRING_VALID(content_info->media_meta.recorded_date)) {
-                               /* This is same as datetaken */
-                               content_info->media_meta.datetaken = g_strdup(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;
                                else
                                        media_svc_debug("Timeline : %ld", content_info->timeline);
+
+                               /* 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_SAFE_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);
+                               }
                        }
                } else {
                        SAFE_FREE(err_attr_name);