Add 360 content feature 39/71539/2 accepted/tizen/common/20160603.150920 accepted/tizen/ivi/20160606.121114 accepted/tizen/mobile/20160606.120745 accepted/tizen/tv/20160606.120929 accepted/tizen/wearable/20160606.121041 submit/tizen/20160603.021103 submit/tizen/20160603.061849
authorMinje Ahn <minje.ahn@samsung.com>
Thu, 26 May 2016 00:47:12 +0000 (09:47 +0900)
committerMinje Ahn <minje.ahn@samsung.com>
Thu, 2 Jun 2016 02:27:28 +0000 (11:27 +0900)
Change-Id: I445695e0fd03eeb48c00419acfc91f92c5063ef2
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
include/media-svc-types.h
packaging/libmedia-service.spec
src/common/media-svc-db-utils.c
src/common/media-svc-media.c
src/common/media-svc-util.c
src/common/media-svc.c

index 959d13d..dd9729a 100755 (executable)
@@ -100,6 +100,7 @@ typedef struct {
        char            *composer_pinyin;                               /**< pinyin for composer*/
        char            *copyright_pinyin;                              /**< pinyin for copyright*/
        char            *description_pinyin;                    /**< pinyin for description*/
+       int             is_360;
 } media_svc_content_meta_s;
 
 /**
index 62ae6b6..5d8a819 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmedia-service
 Summary:    Media information service library for multimedia applications
-Version: 0.2.67
+Version: 0.2.68
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0 and public domain
index b48b32a..e34400e 100755 (executable)
@@ -747,6 +747,7 @@ int _media_svc_init_table_query(const char *event_table_name)
        ret = __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "color_g", MEDIA_SVC_DB_TYPE_INT, NULL, USER_V5, NULL, false, false, false);
        media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
        ret = __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "color_b", MEDIA_SVC_DB_TYPE_INT, NULL, USER_V5, NULL, false, false, false);
+       ret = __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "is_360", MEDIA_SVC_DB_TYPE_INT, "DEFAULT 0", USER_V2, NULL, false, false, true);
        media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
 
        /*folder*/
index 9f033c1..513eebc 100755 (executable)
@@ -226,7 +226,7 @@ int _media_svc_insert_item_with_data(sqlite3 *handle, const char *storage_id, me
                                        category, keyword, location_tag, content_name, age_rating, author, provider, last_played_time, played_count, favourite, \
                                        bitrate, bitpersample, samplerate, channel, duration, longitude, latitude, altitude, exposure_time, fnumber, iso, model, width, height, datetaken, orientation, \
                                        rating, is_drm, storage_type, burst_id, timeline, weather, sync_status, \
-                                       file_name_pinyin, title_pinyin, album_pinyin, artist_pinyin, album_artist_pinyin, genre_pinyin, composer_pinyin, copyright_pinyin, description_pinyin, storage_uuid";
+                                       file_name_pinyin, title_pinyin, album_pinyin, artist_pinyin, album_artist_pinyin, genre_pinyin, composer_pinyin, copyright_pinyin, description_pinyin, storage_uuid, is_360";
 
        /* This sql is due to sqlite3_mprintf's wrong operation when using floating point in the text format */
        /* This code will be removed when sqlite3_mprintf works clearly */
@@ -292,7 +292,7 @@ int _media_svc_insert_item_with_data(sqlite3 *handle, const char *storage_id, me
                                                                                                        %Q, %Q, %Q, %Q, %Q, %Q, %Q, %d, %d, %d, \
                                                                                                        %d, %d, %d, %d, %d, %.6f, %.6f, %.6f, %Q, %.6f, %d, %Q, %d, %d, %Q, %d, \
                                                                                                        %d, %d, %d, %Q, %d, %Q, %d, \
-                                                                                                       %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q);",
+                                                                                                       %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %d);",
                                                                content_info->storage_uuid, db_fields,
                                                                content_info->media_uuid,
                                                                content_info->path,
@@ -358,7 +358,8 @@ int _media_svc_insert_item_with_data(sqlite3 *handle, const char *storage_id, me
                                                                content_info->media_meta.composer_pinyin,
                                                                content_info->media_meta.copyright_pinyin,
                                                                content_info->media_meta.description_pinyin,
-                                                               content_info->storage_uuid
+                                                               content_info->storage_uuid,
+                                                               content_info->media_meta.is_360
                                );
 
        if (burst_id) {
@@ -1126,7 +1127,7 @@ int _media_svc_insert_item_pass2(const char *storage_id, media_svc_content_info_
                recorded_date=%Q, copyright=%Q, track_num=%Q, description=%Q, bitrate=%d, bitpersample=%d, samplerate=%d, channel=%d, \
                duration=%d, longitude=%.6f, latitude=%.6f, altitude=%.6f, width=%d, height=%d, datetaken=%Q, orientation=%d, exposure_time=%Q,\
                fnumber=%.6f, iso=%d, model=%Q, rating=%d, weather=%Q, file_name_pinyin=%Q, title_pinyin=%Q, album_pinyin=%Q, \
-               artist_pinyin=%Q, album_artist_pinyin=%Q, genre_pinyin=%Q, composer_pinyin=%Q, copyright_pinyin=%Q, description_pinyin=%Q WHERE path=%Q;",
+               artist_pinyin=%Q, album_artist_pinyin=%Q, genre_pinyin=%Q, composer_pinyin=%Q, copyright_pinyin=%Q, description_pinyin=%Q, is_360=%d WHERE path=%Q;",
                storage_id,
                //content_info->folder_uuid,
                content_info->thumbnail_path,
@@ -1169,6 +1170,7 @@ int _media_svc_insert_item_pass2(const char *storage_id, media_svc_content_info_
                content_info->media_meta.composer_pinyin,
                content_info->media_meta.copyright_pinyin,
                content_info->media_meta.description_pinyin,
+               content_info->media_meta.is_360,
                content_info->path
                );
 
index f25b3d3..d6ab53d 100755 (executable)
@@ -1230,6 +1230,90 @@ int _media_svc_set_media_info(media_svc_content_info_s *content_info, const char
        return MS_MEDIA_ERR_NONE;
 }
 
+int image_360_check(char *path)
+{
+       FILE *fp = NULL;
+       long app1_size = 0;
+       int size = 1;
+       unsigned char exif_header[4];
+       unsigned char exif_app1[2];
+       unsigned char *exif_app1_data;
+       unsigned char exif_app1_xmp[2];
+       long exif_app1_xmp_size = 0;
+       unsigned char exif_app1_xmp_t[2];
+       char *xmp_data = 0;
+       int size1 = 0;
+       int size2 = 0;
+       char ch;
+       int temp = 0;
+
+       fp = fopen(path, "rb");
+       if (fp == NULL)
+               return 0;
+
+       size = fread(exif_header, 1, sizeof (exif_header), fp);
+       if (size <= 0)
+               return 0;
+
+       if ((exif_header[0] == 0xff) && (exif_header[1] == 0xd8) && (exif_header[2] == 0xff) && (exif_header[3] == 0xe1)) {
+               size = fread(exif_app1, 1, sizeof (exif_app1), fp);
+               if (size <= 0)
+                       return 0;
+
+               size1 = exif_app1[0];
+               size2 = exif_app1[1];
+
+               app1_size = size1 * 256 + size2 - 2;
+
+               if (fseek(fp, app1_size, SEEK_CUR) != 0)
+                       return 0;
+
+               size = fread(exif_app1_xmp, 1, sizeof (exif_app1_xmp), fp);
+               if (size <= 0)
+                       return 0;
+
+               if ((exif_app1_xmp[0] == 0xff) && (exif_app1_xmp[1] == 0xe1)) {
+                       int result = 0;
+                       size = fread(exif_app1_xmp_t, 1, sizeof (exif_app1_xmp_t), fp);
+                       if (size <= 0)
+                               return 0;
+
+                       size1 = exif_app1_xmp_t[0];
+                       size2 = exif_app1_xmp_t[1];
+
+                       exif_app1_xmp_size = size1 * 256 + size2 - 2;
+
+                       xmp_data = (char *)malloc(exif_app1_xmp_size);
+                       memset(xmp_data, 0x00, exif_app1_xmp_size);
+                       while (exif_app1_xmp_size >= 0) {
+                               exif_app1_xmp_size--;
+                               ch = (char)fgetc(fp);
+                               if (ch == '\0')
+                                       continue;
+                               *xmp_data = ch;
+                               xmp_data++;
+                               temp++;
+                       }
+                       xmp_data = xmp_data - temp;
+
+                       if(strstr(xmp_data, "UsePanoramaViewer")
+                       && strstr(xmp_data, "True")
+                       && strstr(xmp_data, "ProjectionType")
+                       && strstr(xmp_data, "equirectangular"))
+                               result = 1;
+
+                       free(xmp_data);
+
+                       return result;
+               } else {
+                       return 0;
+               }
+       } else {
+               return 0;
+       }
+       return 0;
+}
+
 int _media_svc_extract_image_metadata(sqlite3 *handle, media_svc_content_info_s *content_info)
 {
        int ret = MS_MEDIA_ERR_NONE;
@@ -1273,6 +1357,8 @@ int _media_svc_extract_image_metadata(sqlite3 *handle, media_svc_content_info_s
                goto GET_WIDTH_HEIGHT;
        }
 
+       content_info->media_meta.is_360 = image_360_check(path);
+
        if (__media_svc_get_exif_info(ed, NULL, NULL, &value, EXIF_TAG_GPS_LATITUDE) == MS_MEDIA_ERR_NONE) {
                if (__media_svc_get_exif_info(ed, buf, NULL, NULL, EXIF_TAG_GPS_LATITUDE_REF) == MS_MEDIA_ERR_NONE) {
                        if (strlen(buf) > 0) {
@@ -1785,6 +1871,12 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s
                        SAFE_FREE(err_attr_name);
                }
 
+               mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_360, &content_info->media_meta.is_360, NULL);
+
+               if (mmf_error != FILEINFO_ERROR_NONE) {
+                       SAFE_FREE(err_attr_name);
+               }
+
                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) {
index e00d8b0..5e4e18c 100755 (executable)
@@ -1630,6 +1630,7 @@ static int __media_svc_copy_para_to_content(media_svc_content_info_s *content_in
                }
        }
 
+       new_content_info->media_meta.is_360= content_info->media_meta.is_360;
        //new_content_info->media_meta.bitrate = content_info->media_meta.bitrate;
        //new_content_info->media_meta.samplerate = content_info->media_meta.samplerate;
        //new_content_info->media_meta.channel = content_info->media_meta.channel;