modify DB schema 98/37298/1 submit/tizen/20150324.093028
authorji.yong.seo <ji.yong.seo@samsung.com>
Tue, 24 Mar 2015 09:02:09 +0000 (18:02 +0900)
committerji.yong.seo <ji.yong.seo@samsung.com>
Tue, 24 Mar 2015 09:02:25 +0000 (18:02 +0900)
Change-Id: I7ca3f2f87ae4a116a39db60a76a0ea2bc2b6cefd

src/common/media-svc-db-utils.c
src/common/media-svc-media.c
src/common/media-svc-util.c
src/include/common/media-svc-env.h

index 5fc3272..db18750 100755 (executable)
@@ -55,6 +55,7 @@ static int __media_svc_create_update_media_table(sqlite3 *db_handle);
                                track_num                       TEXT, \
                                description                     TEXT, \
                                bitrate                         INTEGER DEFAULT -1, \
+                               bitpersample            INTEGER DEFAULT 0, \
                                samplerate                      INTEGER DEFAULT -1, \
                                channel                         INTEGER DEFAULT -1, \
                                duration                        INTEGER DEFAULT -1, \
@@ -338,16 +339,16 @@ int _media_svc_create_playlist_table(sqlite3 *db_handle, uid_t uid)
        /* Create playlist_view*/
        sql = sqlite3_mprintf(" \
                CREATE VIEW IF NOT EXISTS playlist_view AS \
-               SELECT p.playlist_id, p.name, p.thumbnail_path, media_count, pm._id as pm_id, pm.play_order, m.media_uuid, path, file_name, media_type, mime_type, size, added_time, modified_time, m.thumbnail_path, description, rating, favourite, author, provider, content_name, category, location_tag, age_rating, keyword, is_drm, storage_type, longitude, latitude, altitude, width, height, datetaken, orientation, title, album, artist, album_artist, genre, composer, year, recorded_date, copyright, track_num, bitrate, duration, played_count, last_played_time, last_played_position, samplerate, channel, weather, timeline, sync_status FROM playlist AS p \
+               SELECT p.playlist_id, p.name, p.thumbnail_path AS p_thumbnail_path, media_count, pm._id as pm_id, pm.play_order, m.media_uuid, path, file_name, media_type, mime_type, size, added_time, modified_time, m.thumbnail_path, description, rating, favourite, author, provider, content_name, category, location_tag, age_rating, keyword, is_drm, storage_type, longitude, latitude, altitude, width, height, datetaken, orientation, title, album, artist, album_artist, genre, composer, year, recorded_date, copyright, track_num, bitrate, duration, played_count, last_played_time, last_played_position, samplerate, channel, weather, burst_id, timeline, sync_status, bitpersample FROM playlist AS p \
                INNER JOIN playlist_map AS pm \
                INNER JOIN media AS m \
                INNER JOIN (SELECT count(playlist_id) as media_count, playlist_id FROM playlist_map group by playlist_id) as cnt_tbl \
                                ON (p.playlist_id=pm.playlist_id AND pm.media_uuid = m.media_uuid AND cnt_tbl.playlist_id=pm.playlist_id AND m.validity=1) \
                UNION \
-                       SELECT playlist_id, name, thumbnail_path, 0, 0, -1, NULL, NULL, -1, -1, -1, -1, -1, NULL, NULL, -1, -1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -1, -1, 0, -1, -1, -1, -1, -1, -1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -1, -1, -1, -1, -1, -1, NULL, -1, NULL, -1, 0 FROM playlist \
+                       SELECT playlist_id, name, thumbnail_path, 0, 0, -1, NULL, NULL, -1, -1, -1, -1, -1, NULL, NULL, -1, -1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -1, -1, 0, -1, -1, -1, -1, -1, -1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -1, -1, -1, -1, -1, -1, NULL, -1, NULL, NULL, -1, 0, 0 FROM playlist \
                                WHERE playlist_id NOT IN (select playlist_id from playlist_map) \
                UNION \
-                       SELECT playlist_id, name, thumbnail_path, 0, 0, -1, NULL, NULL, -1, -1, -1, -1, -1, NULL, NULL, -1, -1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -1, -1, 0, -1, -1, -1, -1, -1, -1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -1, -1, -1, -1, -1, -1, NULL, -1, NULL, -1, 0 FROM playlist \
+                       SELECT playlist_id, name, thumbnail_path, 0, 0, -1, NULL, NULL, -1, -1, -1, -1, -1, NULL, NULL, -1, -1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -1, -1, 0, -1, -1, -1, -1, -1, -1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -1, -1, -1, -1, -1, -1, NULL, -1, NULL, NULL, -1, 0, 0 FROM playlist \
                                WHERE playlist_id IN (select pm.playlist_id from playlist_map AS pm INNER JOIN media AS m ON (pm.media_uuid= m.media_uuid) AND m.validity=0); \
                ");
 
@@ -477,14 +478,14 @@ int _media_svc_create_tag_table(sqlite3 *db_handle, uid_t uid)
        sql = sqlite3_mprintf("\
                                CREATE VIEW IF NOT EXISTS tag_view AS \
                                SELECT \
-                                       t.tag_id, t.name, media_count, tm._id as tm_id, m.media_uuid, path, file_name, media_type, mime_type, size, added_time, modified_time, thumbnail_path, description, rating, favourite, author, provider, content_name, category, location_tag, age_rating, keyword, is_drm, storage_type, longitude, latitude, altitude, width, height, datetaken, orientation, title, album, artist, album_artist, genre, composer, year, recorded_date, copyright, track_num, bitrate, duration, played_count, last_played_time, last_played_position, samplerate, channel, weather, timeline, sync_status FROM tag AS t \
+                                       t.tag_id, t.name, media_count, tm._id as tm_id, m.media_uuid, path, file_name, media_type, mime_type, size, added_time, modified_time, thumbnail_path, description, rating, favourite, author, provider, content_name, category, location_tag, age_rating, keyword, is_drm, storage_type, longitude, latitude, altitude, width, height, datetaken, orientation, title, album, artist, album_artist, genre, composer, year, recorded_date, copyright, track_num, bitrate, duration, played_count, last_played_time, last_played_position, samplerate, channel, weather, timeline, sync_status, bitpersample FROM tag AS t \
                                INNER JOIN tag_map AS tm \
                                INNER JOIN media AS m \
                                INNER JOIN (SELECT count(tag_id) as media_count, tag_id FROM tag_map group by tag_id) as cnt_tbl \
                                                 ON (t.tag_id=tm.tag_id AND tm.media_uuid = m.media_uuid AND cnt_tbl.tag_id=tm.tag_id AND m.validity=1) \
                                UNION \
                                SELECT \
-                                       tag_id, name, 0, 0,  NULL, NULL, -1, -1, -1, -1, -1, NULL, NULL, -1, -1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -1, -1,  0, -1, -1, -1, -1, -1, -1, NULL, NULL, NULL, NULL, NULL, NULL,NULL, NULL, NULL, NULL, -1, -1, -1, -1, -1, -1, NULL, -1, NULL, -1, 0 FROM tag \
+                                       tag_id, name, 0, 0,  NULL, NULL, -1, -1, -1, -1, -1, NULL, NULL, -1, -1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -1, -1,  0, -1, -1, -1, -1, -1, -1, NULL, NULL, NULL, NULL, NULL, NULL,NULL, NULL, NULL, NULL, -1, -1, -1, -1, -1, -1, NULL, -1, NULL, -1, 0, 0 FROM tag \
                                WHERE tag_id \
                                NOT IN (select tag_id from tag_map); \
                                ");
index d7a8862..36899ac 100755 (executable)
@@ -212,7 +212,7 @@ int _media_svc_insert_item_with_data(sqlite3 *handle, media_svc_content_info_s *
 
        char * db_fields = "media_uuid, path, file_name, media_type, mime_type, size, added_time, modified_time, folder_uuid, \
                                        thumbnail_path, title, album_id, album, artist, album_artist, genre, composer, year, recorded_date, copyright, track_num, description,\
-                                       bitrate, samplerate, channel, duration, longitude, latitude, altitude, width, height, datetaken, orientation,\
+                                       bitrate, bitpersample, samplerate, channel, duration, longitude, latitude, altitude, 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 ";
 
@@ -281,7 +281,7 @@ int _media_svc_insert_item_with_data(sqlite3 *handle, media_svc_content_info_s *
 
        char *sql = sqlite3_mprintf("INSERT INTO %s (%s) VALUES (%Q, %Q, %Q, %d, %Q, %lld, %d, %d, %Q, \
                                                                                                        %Q, %Q, %d, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, \
-                                                                                                       %d, %d, %d, %d, %.6f, %.6f, %.6f, %d, %d, %Q, %d, \
+                                                                                                       %d, %d, %d, %d, %d, %.6f, %.6f, %.6f, %d, %d, %Q, %d, \
                                                                                                        %d, %d, %d, %Q, %d, %Q, %d, \
                                                                                                        %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q);",
                MEDIA_SVC_DB_TABLE_MEDIA, db_fields,
@@ -308,6 +308,7 @@ int _media_svc_insert_item_with_data(sqlite3 *handle, media_svc_content_info_s *
                content_info->media_meta.track_num,
                content_info->media_meta.description,   //
                content_info->media_meta.bitrate,
+               content_info->media_meta.bitpersample,
                content_info->media_meta.samplerate,
                content_info->media_meta.channel,
                content_info->media_meta.duration,
@@ -388,7 +389,7 @@ int _media_svc_update_item_with_data(sqlite3 *handle, media_svc_content_info_s *
        char *sql = sqlite3_mprintf("UPDATE %s SET \
                size=%lld, modified_time=%d, thumbnail_path=%Q, title=%Q, album_id=%d, album=%Q, artist=%Q, album_artist=%Q, genre=%Q, \
                composer=%Q, year=%Q, recorded_date=%Q, copyright=%Q, track_num=%Q, description=%Q, \
-               bitrate=%d, samplerate=%d, channel=%d, duration=%d, longitude=%f, latitude=%f, altitude=%f, width=%d, height=%d, datetaken=%Q, \
+               bitrate=%d, bitpersample=%d, samplerate=%d, channel=%d, duration=%d, longitude=%f, latitude=%f, altitude=%f, width=%d, height=%d, datetaken=%Q, \
                                                                                                        orientation=%d WHERE path=%Q",
                MEDIA_SVC_DB_TABLE_MEDIA,
                content_info->size,
@@ -407,6 +408,7 @@ int _media_svc_update_item_with_data(sqlite3 *handle, media_svc_content_info_s *
                content_info->media_meta.track_num,
                content_info->media_meta.description,
                content_info->media_meta.bitrate,
+               content_info->media_meta.bitpersample,
                content_info->media_meta.samplerate,
                content_info->media_meta.channel,
                content_info->media_meta.duration,
index 49f5744..7722b38 100755 (executable)
@@ -1125,6 +1125,14 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s
                        } else {
                                //media_svc_debug("channel : %d", content_info->media_meta.channel);
                        }
+
+                       mmf_error = mm_file_get_attrs(content, &err_attr_name, MM_FILE_CONTENT_AUDIO_BITPERSAMPLE, &content_info->media_meta.bitpersample, NULL);
+                       if (mmf_error != MM_ERROR_NONE) {
+                               SAFE_FREE(err_attr_name);
+                               media_svc_debug("fail to get audio bit per sample attr - err(%x)", mmf_error);
+                       } else {
+                               media_svc_debug("bitpersample : %d", content_info->media_meta.bitpersample);
+                       }
                }else if(media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO)      {       /*Video attribute*/
                        int audio_bitrate = 0;
                        int video_bitrate = 0;
index e9cac88..889e6ce 100755 (executable)
@@ -168,6 +168,7 @@ typedef struct {
        int             orientation;                    /**< orientation*/
        int             rating;                         /**< user defined rating */
        char    *       weather;                                /**< weather of image */
+       int             bitpersample;                           /**< bitrate*/
 
        char    *       file_name_pinyin;                               /**< pinyin for file_name*/
        char    *       title_pinyin;                                   /**< pinyin for title*/