Merge "add service_profile field for pvr table" into tizen
[platform/core/api/media-content.git] / test / media-content_test.c
index 25e973e..50c1444 100755 (executable)
 #include <pthread.h>
 #include <glib.h>
 #include <tzplatform_config.h>
+#include <media_content_internal.h>
+
 
 filter_h g_filter = NULL;
-filter_h g_filter_g = NULL;    //filter for group like folder, tag, playlist, album, year ...
+filter_h g_filter_g = NULL;    /*filter for group like folder, tag, playlist, album, year ... */
 
 GMainLoop *g_loop = NULL;
 static int g_cnt = 0;
 static int g_media_cnt = 0;
 
-#define test_audio_id  "0f999626-6218-450c-a4ad-181a3bab6ebf"
-#define test_video_id  "c1a92494-cc5b-4d74-aa7d-253199234548"
+#define test_audio_id  "3304285f-1070-41af-8b4e-f0086cc768f3"
+#define test_video_id  "53c43e7e-53d2-4194-80a6-55d5dcde0def"
 #define test_image_id "db1c184c-6f31-43b4-b924-8c00ac5b6197"
 media_folder_h g_folder = NULL;
 
@@ -41,7 +43,6 @@ bool get_audio_meta(audio_meta_h audio)
 {
        char *c_value = NULL;
        int i_value = 0;
-       time_t t_value = 0;
        int ret = MEDIA_CONTENT_ERROR_NONE;
 
        media_content_debug("=== audio meta ===");
@@ -126,21 +127,6 @@ bool get_audio_meta(audio_meta_h audio)
                media_content_error("error when get meta : [%d]", ret);
        media_content_debug("duration : [%d]", i_value);
 
-       ret = audio_meta_get_played_count(audio, &i_value);
-       if (ret != MEDIA_CONTENT_ERROR_NONE)
-               media_content_error("error when get meta : [%d]", ret);
-       media_content_debug("played_count : [%d]", i_value);
-
-       ret = audio_meta_get_played_time(audio, &t_value);
-       if (ret != MEDIA_CONTENT_ERROR_NONE)
-               media_content_error("error when get meta : [%d]", ret);
-       media_content_debug("played_time : [%d]", t_value);
-
-       ret = audio_meta_get_played_position(audio, &i_value);
-       if (ret != MEDIA_CONTENT_ERROR_NONE)
-               media_content_error("error when get meta : [%d]", ret);
-       media_content_debug("played_position : [%d]", i_value);
-
        return true;
 }
 
@@ -148,7 +134,6 @@ bool get_video_meta(video_meta_h video)
 {
        char *c_value = NULL;
        int i_value = 0;
-       time_t t_value = 0;
        int ret = MEDIA_CONTENT_ERROR_NONE;
 
        media_content_debug("=== video meta ===");
@@ -233,21 +218,6 @@ bool get_video_meta(video_meta_h video)
                media_content_error("error when get meta : [%d]", ret);
        media_content_debug("height : [%d]", i_value);
 
-       ret = video_meta_get_played_count(video, &i_value);
-       if (ret != MEDIA_CONTENT_ERROR_NONE)
-               media_content_error("error when get meta : [%d]", ret);
-       media_content_debug("played_count : [%d]", i_value);
-
-       ret = video_meta_get_played_time(video, &t_value);
-       if (ret != MEDIA_CONTENT_ERROR_NONE)
-               media_content_error("error when get meta : [%d]", ret);
-       media_content_debug("played_time : [%d]", t_value);
-
-       ret = video_meta_get_played_position(video, &i_value);
-       if (ret != MEDIA_CONTENT_ERROR_NONE)
-               media_content_error("error when get meta : [%d]", ret);
-       media_content_debug("played_position : [%d]", i_value);
-
        return true;
 }
 
@@ -265,10 +235,14 @@ bool gallery_folder_list_cb(media_folder_h folder, void *user_data)
 bool gallery_media_item_cb(media_info_h media, void *user_data)
 {
        media_info_h new_media = NULL;
-       media_info_clone(&new_media, media);
+       int ret = MEDIA_CONTENT_ERROR_NONE;
 
-       GList **list = (GList**)user_data;
-       *list = g_list_append(*list, new_media);
+       ret = media_info_clone(&new_media, media);
+
+       if (ret != MEDIA_CONTENT_ERROR_NONE) {
+               GList **list = (GList**)user_data;
+               *list = g_list_append(*list, new_media);
+       }
 
        return true;
 }
@@ -347,9 +321,6 @@ bool media_item_cb(media_info_h media, void *user_data)
        } else if (media_type == MEDIA_CONTENT_TYPE_IMAGE) {
                image_meta_h image;
                media_content_orientation_e orientation = 0;
-               bool is_burst_shot = false;
-               char *burst_id = NULL;
-               char *weather = NULL;
 
                if (media_info_get_image(media, &image) == MEDIA_CONTENT_ERROR_NONE) {
                        ret = image_meta_get_orientation(image, &orientation);
@@ -358,19 +329,6 @@ bool media_item_cb(media_info_h media, void *user_data)
                        else
                                media_content_debug("[image] orientation : %d", orientation);
 
-                       ret = image_meta_is_burst_shot(image, &is_burst_shot);
-                       if (ret != MEDIA_CONTENT_ERROR_NONE)
-                               media_content_error("error image_meta_is_burst_shot : [%d]", ret);
-                       if (is_burst_shot) {
-                               ret = image_meta_get_burst_id(image, &burst_id);
-                               if (ret != MEDIA_CONTENT_ERROR_NONE)
-                                       media_content_error("error image_meta_get_burst_id : [%d]", ret);
-                               else
-                                       media_content_debug("[image] burst_id : [%s]", burst_id);
-
-                               SAFE_FREE(burst_id);
-                       }
-
                        ret = image_meta_destroy(image);
                        if (ret != MEDIA_CONTENT_ERROR_NONE)
                                media_content_error("error image_meta_destroy : [%d]", ret);
@@ -423,48 +381,6 @@ bool media_item_cb(media_info_h media, void *user_data)
        media_content_debug("description : [%s]", c_value);
        SAFE_FREE(c_value);
 
-       ret = media_info_get_author(media, &c_value);
-       if (ret != MEDIA_CONTENT_ERROR_NONE)
-               media_content_error("error when get info : [%d]", ret);
-       media_content_debug("author : [%s]", c_value);
-       SAFE_FREE(c_value);
-
-       ret = media_info_get_provider(media, &c_value);
-       if (ret != MEDIA_CONTENT_ERROR_NONE)
-               media_content_error("error when get info : [%d]", ret);
-       media_content_debug("provider : [%s]", c_value);
-       SAFE_FREE(c_value);
-
-       ret = media_info_get_content_name(media, &c_value);
-       if (ret != MEDIA_CONTENT_ERROR_NONE)
-               media_content_error("error when get info : [%d]", ret);
-       media_content_debug("content_name : [%s]", c_value);
-       SAFE_FREE(c_value);
-
-       ret = media_info_get_category(media, &c_value);
-       if (ret != MEDIA_CONTENT_ERROR_NONE)
-               media_content_error("error when get info : [%d]", ret);
-       media_content_debug("category : [%s]", c_value);
-       SAFE_FREE(c_value);
-
-       ret = media_info_get_location_tag(media, &c_value);
-       if (ret != MEDIA_CONTENT_ERROR_NONE)
-               media_content_error("error when get info : [%d]", ret);
-       media_content_debug("location_tag : [%s]", c_value);
-       SAFE_FREE(c_value);
-
-       ret = media_info_get_age_rating(media, &c_value);
-       if (ret != MEDIA_CONTENT_ERROR_NONE)
-               media_content_error("error when get info : [%d]", ret);
-       media_content_debug("age_rating : [%s]", c_value);
-       SAFE_FREE(c_value);
-
-       ret = media_info_get_keyword(media, &c_value);
-       if (ret != MEDIA_CONTENT_ERROR_NONE)
-               media_content_error("error when get info : [%d]", ret);
-       media_content_debug("keyword : [%s]", c_value);
-       SAFE_FREE(c_value);
-
        ret = media_info_get_size(media, &size);
        if (ret != MEDIA_CONTENT_ERROR_NONE)
                media_content_error("error when get info : [%d]", ret);
@@ -473,17 +389,17 @@ bool media_item_cb(media_info_h media, void *user_data)
        ret = media_info_get_added_time(media, &t_value);
        if (ret != MEDIA_CONTENT_ERROR_NONE)
                media_content_error("error when get info : [%d]", ret);
-       media_content_debug("added_time : [%d]", t_value);
+       media_content_debug("added_time : [%ld]", t_value);
 
        ret = media_info_get_modified_time(media, &t_value);
        if (ret != MEDIA_CONTENT_ERROR_NONE)
                media_content_error("error when get info : [%d]", ret);
-       media_content_debug("modified_time : [%d]", t_value);
+       media_content_debug("modified_time : [%ld]", t_value);
 
        ret = media_info_get_timeline(media, &t_value);
        if (ret != MEDIA_CONTENT_ERROR_NONE)
                media_content_error("error when get info : [%d]", ret);
-       media_content_debug("timeline : [%d]", t_value);
+       media_content_debug("timeline : [%ld]", t_value);
 
        ret = media_info_get_rating(media, &i_value);
        if (ret != MEDIA_CONTENT_ERROR_NONE)
@@ -500,20 +416,22 @@ bool media_item_cb(media_info_h media, void *user_data)
                media_content_error("error when get info : [%d]", ret);
        media_content_debug("is_drm : [%d]", b_value);
 
-       ret = media_info_set_weather(media, "Sunny");
-       if (ret != MEDIA_CONTENT_ERROR_NONE) {
-               media_content_error("Fail to set weather");
-               return ret;
+       ret = media_info_is_360_content(media, &b_value);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get info : [%d]", ret);
+       media_content_debug("is_360 : [%d]", b_value);
 
-       ret = media_info_get_weather(media, &c_value);
+       ret = media_info_get_stitched_state(media, &i_value);
        if (ret != MEDIA_CONTENT_ERROR_NONE)
                media_content_error("error when get info : [%d]", ret);
-       media_content_debug("weather : [%s]", c_value);
-       SAFE_FREE(c_value);
+       media_content_debug("360 stitched : [%d]", i_value);
+
+       ret = media_info_get_stitched_engine(media, &i_value);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get info : [%d]", ret);
+       media_content_debug("360 engine : [%d]", i_value);
 
-       /* Media server can't update when another db handle holds DB connection by sqlite3_prepare */
-       //ret = media_info_set_location_tag(media, "Test location tag");
-       //media_info_update_to_db(media);
+       /*media_info_update_to_db(media);*/
        SAFE_FREE(media_id);
 #endif
        SAFE_FREE(media_id);
@@ -525,7 +443,6 @@ bool folder_list_cb(media_folder_h folder, void *user_data)
        int item_count = 0;
        char *folder_id = NULL;
        char *str_val = NULL;
-       int int_val = -1;
        media_content_storage_e storage_type;
        bool ret;
        media_folder_h *_folder = (media_folder_h*)user_data;
@@ -541,12 +458,6 @@ bool folder_list_cb(media_folder_h folder, void *user_data)
                }
                media_content_debug("folder_id = [%s]", folder_id);
 
-               if (media_folder_get_parent_folder_id(folder, &str_val) != MEDIA_CONTENT_ERROR_NONE) {
-                       media_content_error("[ERROR] media_folder_get_parent_folder_id is failed");
-                       return false;
-               }
-               media_content_debug("parent_folder_id = [%s]", str_val);
-
                if (media_folder_get_path(folder, &str_val) != MEDIA_CONTENT_ERROR_NONE) {
                        SAFE_FREE(folder_id);
                        media_content_error("[ERROR] media_folder_get_path is failed");
@@ -576,12 +487,8 @@ bool folder_list_cb(media_folder_h folder, void *user_data)
                        return false;
                }
                media_content_debug("storage_id = [%s]", str_val);
+               SAFE_FREE(str_val);
 
-               if (media_folder_get_order(folder, &int_val) != MEDIA_CONTENT_ERROR_NONE) {
-                       media_content_error("[ERROR] media_folder_get_order is failed");
-                       return false;
-               }
-               media_content_debug("folder_order = [%d]", int_val);
 #if 1
                if (media_folder_get_media_count_from_db(folder_id, g_filter, &item_count) != MEDIA_CONTENT_ERROR_NONE) {
                        SAFE_FREE(folder_id);
@@ -651,6 +558,7 @@ bool test_album_from_db(int album_id)
 
 bool playlist_list_cb(media_playlist_h playlist, void *user_data)
 {
+       int ret = MEDIA_CONTENT_ERROR_NONE;
        int playlist_id = 0;
        char *playlist_name = NULL;
        media_playlist_h playlist_h;
@@ -666,24 +574,37 @@ bool playlist_list_cb(media_playlist_h playlist, void *user_data)
                return false;
        }
 
-       media_playlist_get_playlist_id(playlist, &playlist_id);
+       ret = media_playlist_get_playlist_id(playlist, &playlist_id);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_playlist_get_playlist_id : [%d]", ret);
+
        media_content_debug("playlist_id : %d", playlist_id);
        /* 64bit build issue */
 #if 0
        if (user_data != NULL)
                *list = g_list_append(*list, (gpointer)playlist_id);
 #endif
-       media_playlist_get_name(playlist, &playlist_name);
+       ret = media_playlist_get_name(playlist, &playlist_name);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_playlist_get_name : [%d]", ret);
+
        media_content_debug("playlist_name : %s", playlist_name);
        SAFE_FREE(playlist_name);
 
-       media_playlist_get_thumbnail_path(playlist, &playlist_thumbnail_path);
+       ret = media_playlist_get_thumbnail_path(playlist, &playlist_thumbnail_path);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_playlist_get_thumbnail_path : [%d]", ret);
+
        media_content_debug("playlist_thumbnail_path : %s", playlist_thumbnail_path);
        SAFE_FREE(playlist_thumbnail_path);
 
-       media_playlist_get_playlist_from_db(playlist_id, &playlist_h);
+       ret = media_playlist_get_playlist_from_db(playlist_id, &playlist_h);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_playlist_get_playlist_from_db : [%d]", ret);
 
-       media_playlist_destroy(playlist_h);
+       ret = media_playlist_destroy(playlist_h);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_playlist_destroy : [%d]", ret);
 
        return true;
 }
@@ -720,6 +641,14 @@ bool bookmarks_cb(media_bookmark_h bookmark, void *user_data)
        media_bookmark_h *_bookmark = (media_bookmark_h*)bookmark;
        int ret = MEDIA_CONTENT_ERROR_NONE;
 
+       if (_bookmark != NULL && user_data != NULL) {
+               media_bookmark_h new_bookmark;
+
+               media_bookmark_clone(&new_bookmark, bookmark);
+               GList **list = (GList**)user_data;
+               *list = g_list_append(*list, new_bookmark);
+       }
+
        if (_bookmark != NULL) {
                char *name = NULL;
                time_t time = 0;
@@ -742,7 +671,16 @@ bool bookmarks_cb(media_bookmark_h bookmark, void *user_data)
                if (ret != MEDIA_CONTENT_ERROR_NONE)
                        media_content_error("error media_bookmark_get_marked_time : [%d]", ret);
                else
-                       media_content_debug("bookmark marked_time : %d", time);
+                       media_content_debug("bookmark marked_time : %ld", time);
+
+               ret = media_bookmark_get_name(bookmark, &name);
+               if (ret != MEDIA_CONTENT_ERROR_NONE)
+                       media_content_error("error media_bookmark_get_name : [%d]", ret);
+               else
+                       media_content_debug("bookmark name : %s", name);
+
+               SAFE_FREE(name);
+
        }
 
        return true;
@@ -860,7 +798,7 @@ bool playlist_item_cb(int playlist_member_id, media_info_h media, void *user_dat
 
        *list = g_list_append(*list, (gpointer)playlist_member_id);
 #endif
-       //media_item_cb(media, user_data);
+       /*media_item_cb(media, user_data);*/
 
        return true;
 }
@@ -873,7 +811,7 @@ int test_filter_create(void)
 
        /* Filter for media */
        const char *condition = "MEDIA_TYPE=3"; /*MEDIA_TYPE 0-image, 1-video, 2-sound, 3-music, 4-other*/
-       //const char *condition = "MEDIA_TYPE IS NOT 0 AND MEDIA_DESCRIPTION IS NOT NULL";      /*MEDIA_TYPE 0-image, 1-video, 2-sound, 3-music, 4-other*/
+       /*const char *condition = "MEDIA_TYPE IS NOT 0 AND MEDIA_DESCRIPTION IS NOT NULL"; */   /*MEDIA_TYPE 0-image, 1-video, 2-sound, 3-music, 4-other*/
 
        ret = media_filter_create(&g_filter);
 
@@ -895,18 +833,18 @@ int test_filter_create(void)
         * call media_filter_set_order(g_filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_ARTIST, MEDIA_CONTENT_COLLATE_DEFAULT);
         */
        /* Able to set multi column to set order */
-       //ret = media_filter_set_order(g_filter, MEDIA_CONTENT_ORDER_ASC, "MEDIA_MODIFIED_TIME, MEDIA_DISPLAY_NAME", MEDIA_CONTENT_COLLATE_DEFAULT);
-       //ret = media_filter_set_order(g_filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_ARTIST, MEDIA_CONTENT_COLLATE_DEFAULT);
-       //ret = media_filter_set_order(g_filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_TRACK_NUM_INT, MEDIA_CONTENT_COLLATE_DEFAULT);
-       //ret = media_filter_set_storage(g_filter, "cfbf3d2c-71c5-4611-bccc-7cbac890146e");
+#if 0
+       ret = media_filter_set_order(g_filter, MEDIA_CONTENT_ORDER_ASC, "MEDIA_MODIFIED_TIME, MEDIA_DISPLAY_NAME", MEDIA_CONTENT_COLLATE_DEFAULT);
+       ret = media_filter_set_order(g_filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_ARTIST, MEDIA_CONTENT_COLLATE_DEFAULT);
+       ret = media_filter_set_order(g_filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_TRACK_NUM_INT, MEDIA_CONTENT_COLLATE_DEFAULT);
+       ret = media_filter_set_storage(g_filter, "cfbf3d2c-71c5-4611-bccc-7cbac890146e");
 
        /* Filter for group */
-       //const char *g_condition = "TAG_NAME like \"\%my\%\"";
-       //const char *g_condition = "BOOKMARK_MARKED_TIME > 300";
-
+       const char *g_condition = "TAG_NAME like \"\%my\%\"";
+       const char *g_condition = "BOOKMARK_MARKED_TIME > 300";
+#endif
        ret = media_filter_create(&g_filter_g);
 
-       //ret = media_filter_set_condition(g_filter_g, g_condition, MEDIA_CONTENT_COLLATE_DEFAULT);
        ret = media_filter_set_order(g_filter_g, MEDIA_CONTENT_ORDER_DESC, TAG_NAME, MEDIA_CONTENT_COLLATE_DEFAULT);
 
        return ret;
@@ -1052,7 +990,6 @@ int test_gallery_scenario(void)
                                int width = 0, height = 0;
                                media_content_orientation_e orientation = 0;
                                char *datetaken = NULL;
-                               char *burst_id = NULL;
 
                                ret = media_info_get_image(media_handle, &image_handle);
                                if (ret != MEDIA_CONTENT_ERROR_NONE) {
@@ -1070,16 +1007,12 @@ int test_gallery_scenario(void)
                                        ret = image_meta_get_date_taken(image_handle, &datetaken);
                                        if (ret != MEDIA_CONTENT_ERROR_NONE)
                                                media_content_error("error image_meta_get_date_taken : [%d]", ret);
-                                       ret = image_meta_get_burst_id(image_handle, &burst_id);
-                                       if (ret != MEDIA_CONTENT_ERROR_NONE)
-                                               media_content_error("error image_meta_get_burst_id : [%d]", ret);
 
                                        media_content_debug("This is Image");
                                        media_content_debug("Width : %d, Height : %d, Orientation : %d, Date taken : %s", width, height, orientation, datetaken);
                                }
 
                                SAFE_FREE(datetaken);
-                               SAFE_FREE(burst_id);
                                ret = image_meta_destroy(image_handle);
                                if (ret != MEDIA_CONTENT_ERROR_NONE)
                                        media_content_error("error image_meta_destroy : [%d]", ret);
@@ -1088,7 +1021,6 @@ int test_gallery_scenario(void)
                                video_meta_h video_handle;
                                char *title = NULL, *artist = NULL, *album = NULL, *album_artist = NULL;
                                int duration = 0;
-                               time_t time_played = 0;
 
                                ret = media_info_get_video(media_handle, &video_handle);
                                if (ret != MEDIA_CONTENT_ERROR_NONE) {
@@ -1106,12 +1038,9 @@ int test_gallery_scenario(void)
                                        ret = video_meta_get_duration(video_handle, &duration);
                                        if (ret != MEDIA_CONTENT_ERROR_NONE)
                                                media_content_error("error video_meta_get_duration : [%d]", ret);
-                                       ret = video_meta_get_played_time(video_handle, &time_played);
-                                       if (ret != MEDIA_CONTENT_ERROR_NONE)
-                                               media_content_error("error video_meta_get_played_time : [%d]", ret);
 
                                        media_content_debug("This is Video");
-                                       media_content_debug("Title: %s, Album: %s, Artist: %s, Album_artist: %s \n Duration: %d, Played time: %d", title, album, artist, album_artist, duration, time_played);
+                                       media_content_debug("Title: %s, Album: %s, Artist: %s, Album_artist: %s \n Duration: %d", title, album, artist, album_artist, duration);
                                }
 
                                SAFE_FREE(title);
@@ -1123,9 +1052,6 @@ int test_gallery_scenario(void)
                                if (ret != MEDIA_CONTENT_ERROR_NONE)
                                        media_content_error("error video_meta_destroy : [%d]", ret);
                        }
-                       //media_content_debug("media_id [%d] : %s", i, media_id);
-                       //media_content_debug("media_name [%d] : %s", i, media_name);
-                       //media_content_debug("media_path [%d] : %s", i, media_path);
 
                        SAFE_FREE(media_id);
                        SAFE_FREE(media_name);
@@ -1161,7 +1087,7 @@ int test_gallery_scenario(void)
                        media_content_error("media_folder_foreach_media_from_db failed: %d", ret);
                        return -1;
                } else {
-                       media_content_error("media_folder_foreach_media_from_db success!", ret);
+                       media_content_error("media_folder_foreach_media_from_db success!");
                        char *media_id = NULL;
                        char *media_name = NULL;
                        char *media_path = NULL;
@@ -1224,7 +1150,6 @@ int test_gallery_scenario(void)
                                        video_meta_h video_handle;
                                        char *title = NULL, *artist = NULL, *album = NULL, *album_artist = NULL;;
                                        int duration = 0;
-                                       time_t time_played;
 
                                        ret = media_info_get_video(media_handle, &video_handle);
                                        if (ret != MEDIA_CONTENT_ERROR_NONE) {
@@ -1242,12 +1167,9 @@ int test_gallery_scenario(void)
                                                ret = video_meta_get_duration(video_handle, &duration);
                                                if (ret != MEDIA_CONTENT_ERROR_NONE)
                                                        media_content_error("error video_meta_get_duration : [%d]", ret);
-                                               ret = video_meta_get_played_time(video_handle, &time_played);
-                                               if (ret != MEDIA_CONTENT_ERROR_NONE)
-                                                       media_content_error("error video_meta_get_played_time : [%d]", ret);
 
                                                media_content_debug("This is Video");
-                                               media_content_debug("Title: %s, Album: %s, Artist: %s, Album_artist: %s \n Duration: %d, Played time: %d\n", title, album, artist, album_artist, duration, time_played);
+                                               media_content_debug("Title: %s, Album: %s, Artist: %s, Album_artist: %s \n Duration: %d\n", title, album, artist, album_artist, duration);
                                        }
 
                                        SAFE_FREE(title);
@@ -1283,7 +1205,7 @@ int test_gallery_scenario(void)
                                                        if (ret != MEDIA_CONTENT_ERROR_NONE)
                                                                media_content_error("error media_bookmark_get_thumbnail_path : [%d]", ret);
 
-                                                       media_content_debug("Bookmark time : %d\nBookmar thumb: %s", marked_time, thumb_path);
+                                                       media_content_debug("Bookmark time : %ld\nBookmar thumb: %s", marked_time, thumb_path);
                                                        SAFE_FREE(thumb_path);
                                                }
 
@@ -1521,7 +1443,7 @@ int test_media_info_operation_2(void)
 
 #if 0
        /* Bookmark */
-       char *thumbnail_path1 = tzplatform_mkpath(TZ_USER_CONTENT, "Images and videos/My video clips/teat11.jpg"));
+       char *thumbnail_path1 = tzplatform_mkpath(TZ_USER_VIDEOS, "teat11.jpg");
        media_bookmark_insert_to_db(test_video_id, 100, thumbnail_path1);
        media_bookmark_insert_to_db(test_video_id, 200, thumbnail_path1);
 
@@ -1576,7 +1498,6 @@ int test_folder_operation(void)
 
        ret = media_folder_foreach_folder_from_db(filter, folder_list_cb, &folder);
 
-       //test.3 get the media list in first folder
        filter_h m_filter = NULL;
 
        ret = media_filter_create(&m_filter);
@@ -1606,79 +1527,6 @@ int test_folder_operation(void)
        return ret;
 }
 
-bool folder_update_cb(media_folder_h folder, void *user_data)
-{
-       char *folder_id = NULL;
-       char *folder_path = NULL;
-       char *folder_name = NULL;
-       int folder_order = -1;
-       bool ret = true;
-
-       if (folder != NULL) {
-               ret = media_folder_get_folder_id(folder, &folder_id);
-               media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
-               media_content_debug("folder_id = [%s]", folder_id);
-               SAFE_FREE(folder_id);
-
-               ret = media_folder_get_path(folder, &folder_path);
-               media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
-               media_content_debug("folder_path = [%s]", folder_path);
-               SAFE_FREE(folder_path);
-
-               ret = media_folder_get_name(folder, &folder_name);
-               media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
-               media_content_debug("folder_name = [%s]", folder_name);
-               SAFE_FREE(folder_name);
-
-               ret = media_folder_get_order(folder, &folder_order);
-               media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
-               media_content_debug("folder_order = [%d]", folder_order);
-
-               ret = media_folder_clone(&g_folder, folder);
-               media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
-
-               ret = true;
-       } else {
-               ret = false;
-       }
-
-       return ret;
-}
-
-
-int test_folder_update(void)
-{
-       int ret = MEDIA_CONTENT_ERROR_NONE;
-       filter_h filter;
-       int folder_count = 0;
-
-       media_content_debug("\n============Folder Update Test============\n\n");
-
-       ret = media_filter_create(&filter);
-       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
-
-       ret = media_filter_set_condition(filter, "MEDIA_TYPE=0 and MEDIA_STORAGE_TYPE=0", MEDIA_CONTENT_COLLATE_DEFAULT);       /*MEDIA_TYPE 0-image, 1-video, 2-sound, 3-music, 4-other*/
-       ret = media_filter_set_order(filter, MEDIA_CONTENT_ORDER_DESC, FOLDER_ORDER, MEDIA_CONTENT_COLLATE_NOCASE);
-
-       ret = media_folder_get_folder_count_from_db(filter, &folder_count);
-
-       media_content_debug("Folder count : %d", folder_count);
-
-       ret = media_folder_foreach_folder_from_db(filter, folder_update_cb, NULL);
-
-       media_filter_destroy(filter);
-
-       ret = media_folder_set_name(g_folder, "test_folder");
-
-       ret = media_folder_set_order(g_folder, 200);
-
-       ret = media_folder_update_to_db(g_folder);
-
-       ret = media_folder_destroy(g_folder);
-
-       return ret;
-}
-
 int test_playlist_operation(void)
 {
        int ret = MEDIA_CONTENT_ERROR_NONE;
@@ -1724,7 +1572,7 @@ int test_playlist_operation(void)
                media_playlist_add_media(playlist_1, test_video_id);
 
                #if 0
-               char *playlist_thumb_path = tzplatform_mkpath(TZ_USER_CONTENT, "Images/Default.jpg"));
+               char *playlist_thumb_path = tzplatform_mkpath(TZ_USER_IMAGES, "Default.jpg"));
                media_playlist_set_thumbnail_path(playlist_1, playlist_thumb_path);
                #endif
 
@@ -1757,8 +1605,8 @@ int test_playlist_operation(void)
        media_content_debug("playlist_id_3 [%d]", playlist_id_3);
 
        /* Export and import playlist */
-       media_playlist_export_to_file(playlist_3, "/opt/usr/media/Music/playlist.m3u");
-       media_playlist_import_from_file("/opt/usr/media/Music/playlist.m3u", "playlist_4", &playlist_4);
+       media_playlist_export_to_file(playlist_3, tzplatform_mkpath(TZ_USER_MUSIC, "playlist.m3u"));
+       media_playlist_import_from_file(tzplatform_mkpath(TZ_USER_MUSIC, "playlist.m3u"), "playlist_4", &playlist_4);
 
        /* Filter for media*/
        ret = media_filter_create(&m_filter);
@@ -1821,8 +1669,10 @@ int test_playlist_operation(void)
        media_playlist_foreach_playlist_from_db(filter, playlist_list_cb, NULL);
 
        /* deletes the playlist */
-       //media_playlist_delete_from_db(playlist_id_1);
-       //media_playlist_delete_from_db(playlist_id_2);
+#if 0
+       media_playlist_delete_from_db(playlist_id_1);
+       media_playlist_delete_from_db(playlist_id_2);
+#endif
 
        if (playlist_1 != NULL)
                media_playlist_destroy(playlist_1);
@@ -1845,6 +1695,51 @@ int test_playlist_operation(void)
        return ret;
 }
 
+int test_playlist_operation_v2(void)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_playlist_h playlist_1 = NULL;
+       const char *playlist_name_1 = "myPlaylist_1";
+       const char *playlist_thumb_path = tzplatform_mkpath(TZ_USER_IMAGES, "Default.jpg");
+       int playlist_id = 0;
+
+       media_content_debug("\n============Playlist Test V2============\n\n");
+
+       ret = media_playlist_create(&playlist_1);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_playlist_create : [%d]", ret);
+
+       ret = media_playlist_set_name(playlist_1, playlist_name_1);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_playlist_set_name : [%d]", ret);
+
+       ret = media_playlist_set_thumbnail_path(playlist_1, playlist_thumb_path);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_playlist_set_thumbnail_path : [%d]", ret);
+
+       ret = media_playlist_insert_to_db_v2(playlist_1);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_playlist_insert_to_db_v2 : [%d]", ret);
+
+       ret = media_playlist_set_name(playlist_1, "myPlaylist_3");
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_playlist_set_name : [%d]", ret);
+
+       ret = media_playlist_get_playlist_id(playlist_1, &playlist_id);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_playlist_get_playlist_id : [%d]", ret);
+
+       ret = media_playlist_update_to_db_v2(playlist_id, playlist_1);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_playlist_update_to_db_v2 : [%d]", ret);
+
+       ret = media_playlist_destroy(playlist_1);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_playlist_destroy : [%d]", ret);
+
+       return ret;
+}
+
 int test_tag_operation(void)
 {
        int ret = MEDIA_CONTENT_ERROR_NONE;
@@ -1957,7 +1852,7 @@ int test_tag_operation(void)
        ret = media_tag_add_media(tag_2, test_video_id);
        if (ret != MEDIA_CONTENT_ERROR_NONE)
                media_content_error("error media_tag_add_media : [%d]", ret);
-       ret = media_tag_set_name(tag_2, (char *)"test_tag");
+       ret = media_tag_set_name(tag_2, "test_tag");
        if (ret != MEDIA_CONTENT_ERROR_NONE)
                media_content_error("error media_tag_set_name : [%d]", ret);
        ret = media_tag_update_to_db(tag_2);
@@ -1983,6 +1878,9 @@ int test_tag_operation(void)
        ret = media_tag_destroy(tag_2);
        if (ret != MEDIA_CONTENT_ERROR_NONE)
                media_content_error("error media_tag_destroy : [%d]", ret);
+       ret = media_tag_destroy(tag_3);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_tag_destroy : [%d]", ret);
        ret = media_filter_destroy(filter);
        if (ret != MEDIA_CONTENT_ERROR_NONE)
                media_content_error("error media_filter_destroy : [%d]", ret);
@@ -1990,13 +1888,66 @@ int test_tag_operation(void)
        return ret;
 }
 
+int test_tag_operation_v2(void)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_tag_h tag_1;
+       const char *tag_name_1 = "myTag_1";
+       int tag_id = -1;
+
+       media_content_debug("\n============Tag Test V2============\n\n");
+
+       /* Create Tag */
+       ret = media_tag_create(&tag_1);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_tag_create : [%d]", ret);
+
+       ret = media_tag_set_name(tag_1, tag_name_1);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_tag_set_name : [%d]", ret);
+
+       /* Add media to Tag */
+       ret = media_tag_add_media(tag_1, test_audio_id);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_tag_add_media : [%d]", ret);
+
+       ret = media_tag_add_media(tag_1, test_video_id);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_tag_add_media : [%d]", ret);
+
+       ret = media_tag_insert_to_db_v2(tag_1);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_tag_insert_to_db_v2 : [%d]", ret);
+
+#if 1
+       ret = media_tag_get_tag_id(tag_1, &tag_id);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_tag_get_tag_id : [%d]", ret);
+
+       ret = media_tag_remove_media(tag_1, test_video_id);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_tag_add_media : [%d]", ret);
+
+       ret = media_tag_update_to_db_v2(tag_id, tag_1);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_tag_update_to_db_v2 : [%d]", ret);
+#endif
+
+       ret = media_tag_destroy(tag_1);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_tag_destroy : [%d]", ret);
+
+       return ret;
+}
 
 int test_bookmark_operation(void)
 {
-       //bookmark is only supported for video information.
+       /* bookmark is only supported for video information. */
        int ret = MEDIA_CONTENT_ERROR_NONE;
        int bookmark_count = 0;
        filter_h filter;
+       GList *all_item_list = NULL;
+       int idx = 0;
 
        media_content_debug("\n============Bookmark Test============\n\n");
 
@@ -2014,8 +1965,8 @@ int test_bookmark_operation(void)
        if (ret != MEDIA_CONTENT_ERROR_NONE)
                media_content_error("error media_filter_set_order : [%d]", ret);
 
-       //insert bookmark to video
-       const char *thumbnail_path1 = tzplatform_mkpath(TZ_USER_CONTENT, "Images and videos/My video clips/teat11.jpg");
+       /* insert bookmark to video */
+       const char *thumbnail_path1 = tzplatform_mkpath(TZ_USER_VIDEOS, "teat11.jpg");
        ret = media_bookmark_insert_to_db(test_video_id, 400, thumbnail_path1);
        if (ret != MEDIA_CONTENT_ERROR_NONE)
                media_content_error("error media_bookmark_insert_to_db : [%d]", ret);
@@ -2030,6 +1981,27 @@ int test_bookmark_operation(void)
        else
                media_content_debug("bookmark_count = [%d]", bookmark_count);
 
+       ret = media_info_foreach_bookmark_from_db(test_video_id, NULL, bookmarks_cb, &all_item_list);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_info_foreach_bookmark_from_db : [%d]", ret);
+
+       for (idx = 0; idx < g_list_length(all_item_list); idx++) {
+               media_bookmark_h bookmark_handle;
+               bookmark_handle = (media_bookmark_h)g_list_nth_data(all_item_list, idx);
+
+               ret = media_bookmark_set_name(bookmark_handle, "test 1");
+               if (ret != MEDIA_CONTENT_ERROR_NONE)
+                       media_content_error("error media_bookmark_set_name : [%d]", ret);
+
+               ret = media_bookmark_update_to_db(bookmark_handle);
+               if (ret != MEDIA_CONTENT_ERROR_NONE)
+                       media_content_error("error media_bookmark_update_to_db : [%d]", ret);
+       }
+
+       ret = media_info_foreach_bookmark_from_db(test_video_id, NULL, bookmarks_cb, NULL);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_info_foreach_bookmark_from_db : [%d]", ret);
+
        ret = media_filter_destroy(filter);
        if (ret != MEDIA_CONTENT_ERROR_NONE)
                media_content_error("error media_filter_destroy : [%d]", ret);
@@ -2037,6 +2009,45 @@ int test_bookmark_operation(void)
        return ret;
 }
 
+int test_bookmark_operation_v2(void)
+{
+       media_content_debug("\n============Bookmark Test V2============\n\n");
+
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_bookmark_h bookmark = NULL;
+       const char *thumbnail_path1 = tzplatform_mkpath(TZ_USER_VIDEOS, "teat11.jpg");
+
+       ret = media_bookmark_create(test_video_id, 400, &bookmark);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_bookmark_create : [%d]", ret);
+
+       ret = media_bookmark_set_name(bookmark, "test bookmark");
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_bookmark_set_name : [%d]", ret);
+
+       ret = media_bookmark_set_thumbnail_path(bookmark, thumbnail_path1);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_bookmark_set_thumbnail_path : [%d]", ret);
+
+       ret = media_bookmark_insert_to_db_v2(bookmark);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_bookmark_insert_to_db_v2 : [%d]", ret);
+
+       ret = media_bookmark_set_name(bookmark, "test bookmark 2");
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_bookmark_set_name : [%d]", ret);
+
+       ret = media_bookmark_update_to_db(bookmark);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_bookmark_update_to_db : [%d]", ret);
+
+       ret = media_bookmark_destroy(bookmark);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_bookmark_destroy : [%d]", ret);
+
+       return ret;
+}
+
 int test_album_list(void)
 {
        media_content_debug("\n============Album Test============\n\n");
@@ -2103,13 +2114,15 @@ int test_group_operation(void)
                ret = media_group_get_group_count_from_db(g_filter, idx, &group_count);
                if (ret != MEDIA_CONTENT_ERROR_NONE) {
                        test_filter_destroy();
-                       media_content_error("media_group_get_group_count_from_db fail. idx=[%d]", ret, idx);
+                       media_content_error("media_group_get_group_count_from_db fail. ret=[%d] idx=[%d]", ret, idx);
                        return ret;
                } else {
                        media_content_debug("[%2d]group_count [%d]", idx, group_count);
                }
 
                ret = media_group_foreach_group_from_db(g_filter, idx, group_list_cb, &idx);
+               if (ret != MEDIA_CONTENT_ERROR_NONE)
+                       media_content_error("media_group_foreach_group_from_db failed: %d", ret);
        }
        ret = test_filter_destroy();
 
@@ -2161,16 +2174,15 @@ int test_update_operation()
                                } else {
                                        media_content_debug("media_info_get_image success");
 
-                                       //update image meta
+                                       /* update image meta */
                                        orientation = MEDIA_CONTENT_ORIENTATION_ROT_180;
                                        image_meta_set_orientation(image_handle, orientation);
 
                                        ret = image_meta_update_to_db(image_handle);
-                                       if (ret != MEDIA_CONTENT_ERROR_NONE) {
+                                       if (ret != MEDIA_CONTENT_ERROR_NONE)
                                                media_content_error("image_meta_update_to_db failed: %d", ret);
-                                       } else {
+                                       else
                                                media_content_debug("image_meta_update_to_db success");
-                                       }
                                }
 
                        } else if (media_type == MEDIA_CONTENT_TYPE_VIDEO) {
@@ -2182,20 +2194,16 @@ int test_update_operation()
                                } else {
                                        media_content_debug("media_info_get_video success");
 
-                                       //update video meta
-                                       video_meta_set_played_count(video_handle, 5);
-                                       video_meta_set_played_time(video_handle, 5);
-                                       video_meta_set_played_position(video_handle, 5);
+                                       /* update video meta */
                                        video_meta_update_to_db(video_handle);
 
                                        ret = video_meta_update_to_db(video_handle);
-                                       if (ret != MEDIA_CONTENT_ERROR_NONE) {
+                                       if (ret != MEDIA_CONTENT_ERROR_NONE)
                                                media_content_error("video_meta_update_to_db failed: %d", ret);
-                                       } else {
+                                       else
                                                media_content_debug("video_meta_update_to_db success");
-                                       }
                                }
-                       } else if (media_type == MEDIA_CONTENT_TYPE_MUSIC) {//update audio meta
+                       } else if (media_type == MEDIA_CONTENT_TYPE_MUSIC) {
                                audio_meta_h audio_handle = NULL;
                                ret = media_info_get_audio(media_handle, &audio_handle);
                                if (ret != MEDIA_CONTENT_ERROR_NONE) {
@@ -2203,16 +2211,11 @@ int test_update_operation()
                                } else {
                                        media_content_debug("media_info_get_audio success");
 
-                                       audio_meta_set_played_count(audio_handle, 5);
-                                       audio_meta_set_played_time(audio_handle, 1000);
-                                       audio_meta_set_played_position(audio_handle, 180);
-
                                        ret = audio_meta_update_to_db(audio_handle);
-                                       if (ret != MEDIA_CONTENT_ERROR_NONE) {
+                                       if (ret != MEDIA_CONTENT_ERROR_NONE)
                                                media_content_error("audio_meta_update_to_db failed: %d", ret);
-                                       } else {
+                                       else
                                                media_content_debug("audio_meta_update_to_db success");
-                                       }
                                }
 
                        }
@@ -2230,9 +2233,11 @@ int test_update_operation()
 int test_insert(void)
 {
        int ret = MEDIA_CONTENT_ERROR_NONE;
-       const char *path = "/opt/usr/media/Images/Default.jpg";
-       //const char *path = "/opt/usr/media/Others/other.txt";
-       //char *path = NULL;
+       const char *path = tzplatform_mkpath(TZ_USER_IMAGES, "Default.jpg");
+#if 0
+       const char *path = tzplatform_mkpath(TZ_USER_DOCUMENTS, "other.txt"));
+       char *path = NULL;
+#endif
        media_info_h media_item = NULL;
        media_content_debug("\n============DB Insert Test============\n\n");
 
@@ -2273,7 +2278,7 @@ int test_move(void)
 {
        int ret = MEDIA_CONTENT_ERROR_NONE;
        const char *move_media_id = "60aea677-4742-408e-b5f7-f2628062d06d";
-       const char *dst_path = tzplatform_mkpath(TZ_USER_CONTENT, "Images/XX/Default1.jpg");
+       const char *dst_path = tzplatform_mkpath(TZ_USER_IMAGES, "XX/Default1.jpg");
        media_info_h move_media = NULL;
 
        ret = media_info_get_media_from_db(move_media_id, &move_media);
@@ -2465,6 +2470,202 @@ int test_create_thumbnail(int cancel)
        return ret;
 }
 
+bool face_cb(media_face_h face, void *user_data)
+{
+       if (user_data != NULL) {
+               unsigned x, y, rect_w, rect_h;
+               media_face_get_face_rect(face, &x, &y, &rect_w, &rect_h);
+               media_content_debug("face(%p) x = %d, y = %d [%d, %d]", face, x, y, rect_w, rect_h);
+               return TRUE;
+       }
+       return FALSE;
+}
+
+void face_detection_complete_cb(media_content_error_e error, int count, void *user_data)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       g_cnt++;
+
+       media_content_debug("=================[%d][%d]", g_media_cnt, g_cnt);
+       media_content_debug("error_code [%d]", error);
+       media_content_debug("face_count [%d]", count);
+       if (count == 0) {
+               media_content_debug("No faces are detected!");
+       } else if (user_data != NULL) {
+               media_info_h media = (media_info_h)user_data;
+               char *media_id = NULL;
+               ret = media_info_get_media_id(media, &media_id);
+               if (ret != MEDIA_CONTENT_ERROR_NONE)
+                       media_content_error("media_info_get_media_id failed: %d", ret);
+               if (media_id != NULL) {
+                       ret = media_info_foreach_face_from_db(media_id, NULL, face_cb, NULL);
+                       SAFE_FREE(media_id);
+                       if (ret != MEDIA_CONTENT_ERROR_NONE)
+                               media_content_error("media_info_foreach_face_from_db failed: %d", ret);
+               }
+               ret = media_info_destroy(media);
+               if (ret != MEDIA_CONTENT_ERROR_NONE)
+                       media_content_error("media_info_destroy failed: %d", ret);
+       }
+
+       if (g_cnt == g_media_cnt)
+               g_main_loop_quit(g_loop);
+
+       return;
+}
+
+bool start_face_detection_cb(media_info_h media, void *user_data)
+{
+       char *media_id = NULL;
+       media_info_h dst = NULL;
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       if (media == NULL) {
+               media_content_debug("NO Item");
+               return true;
+       }
+
+       ret = media_info_get_media_id(media, &media_id);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("media_info_get_media_id failed: %d", ret);
+       else
+               media_content_debug("media_id : [%s]", media_id);
+
+       ret = media_info_clone(&dst, media);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("media_info_clone failed: %d", ret);
+
+       GList **list = (GList**)user_data;
+       *list = g_list_append(*list, dst);
+
+       /* fix prevent: Resource leak */
+       SAFE_FREE(media_id);
+
+       return true;
+}
+
+bool cancel_face_detection_cb(media_info_h media, void *user_data)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       char *media_id = NULL;
+       media_info_h dst = NULL;
+
+       g_cnt++;
+
+       if (media == NULL) {
+               media_content_debug("NO Item");
+               return true;
+       }
+
+       ret = media_info_get_media_id(media, &media_id);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("media_info_get_media_id failed: %d", ret);
+       else
+               media_content_debug("media_id : [%s]", media_id);
+
+       ret = media_info_clone(&dst, media);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("media_info_clone failed: %d", ret);
+
+       ret = media_info_cancel_face_detection(dst);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("media_info_cancel_face_detection failed: %d", ret);
+
+       ret = media_info_destroy(dst);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+                       media_content_error("media_info_destroy failed: %d", ret);
+
+       if (g_cnt == g_media_cnt)
+               g_main_loop_quit(g_loop);
+
+       /* fix prevent: Resource leak */
+       SAFE_FREE(media_id);
+
+       return true;
+}
+
+gboolean face_detection_start(gpointer data)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       GList *all_item_list = NULL;
+       int idx = 0;
+
+       ret = media_info_foreach_media_from_db(g_filter, start_face_detection_cb, &all_item_list);
+
+       if (ret == MEDIA_CONTENT_ERROR_NONE)
+               media_content_debug("media_info_foreach_media_from_db is success");
+       else
+               media_content_error("media_info_foreach_media_from_db is failed");
+
+       for (idx = 0; idx < g_list_length(all_item_list); idx++) {
+               media_info_h media_handle = NULL;
+
+               media_handle = (media_info_h)g_list_nth_data(all_item_list, idx);
+
+               ret = media_info_start_face_detection(media_handle, face_detection_complete_cb, NULL);
+               if (ret != MEDIA_CONTENT_ERROR_NONE)
+                       media_content_error("media_info_start_face_detection failed: %d", ret);
+
+       }
+
+       return false;
+}
+
+gboolean face_detection_cancel(gpointer data)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       ret = media_info_foreach_media_from_db(g_filter, cancel_face_detection_cb, NULL);
+
+       if (ret == MEDIA_CONTENT_ERROR_NONE)
+               media_content_debug("media_info_foreach_media_from_db is success");
+       else
+               media_content_error("media_info_foreach_media_from_db is failed");
+
+       return false;
+}
+
+int test_start_face_detection(int cancel)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       GSource *source = NULL;
+       GMainContext *context = NULL;
+
+       test_filter_create();
+
+       ret = media_info_get_media_count_from_db(g_filter, &g_media_cnt);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("media_info_get_media_count_from_db failed: %d", ret);
+       else
+               media_content_debug("media_count : [%d]", g_media_cnt);
+
+       if (g_media_cnt == 0)
+               goto END;
+
+       g_loop = g_main_loop_new(NULL, FALSE);
+       context = g_main_loop_get_context(g_loop);
+       source = g_idle_source_new();
+       g_source_set_callback(source, face_detection_start, NULL, NULL);
+       g_source_attach(source, context);
+
+       /* Logic to cancel */
+       if (cancel) {
+               GSource *cancel_src = NULL;
+               cancel_src = g_idle_source_new();
+               g_source_set_callback(cancel_src, face_detection_cancel, NULL, NULL);
+               g_source_attach(cancel_src, context);
+       }
+
+       g_main_loop_run(g_loop);
+       g_main_loop_unref(g_loop);
+
+END:
+       test_filter_destroy();
+
+       return ret;
+}
+
 int test_disconnect_database(void)
 {
        int ret = MEDIA_CONTENT_ERROR_NONE;
@@ -2484,18 +2685,12 @@ int test_request_update_db(void)
 {
        int ret = MEDIA_CONTENT_ERROR_NONE;
        media_info_h media = NULL;
-       char *content_name = NULL;
        bool favorite = FALSE;
 
-       //get the content of Over the horizon
        ret = media_info_get_media_from_db("71b19196-5b38-4ab1-ab34-bfe05c369614", &media);
        if (ret != MEDIA_CONTENT_ERROR_NONE)
                media_content_error("media_info_get_media_from_db failed: %d", ret);
 
-       ret = media_info_set_content_name(media, "TEST_content_name");
-       if (ret != MEDIA_CONTENT_ERROR_NONE)
-               media_content_error("media_info_set_content_name failed: %d", ret);
-
        ret = media_info_set_favorite(media, TRUE);
        if (ret != MEDIA_CONTENT_ERROR_NONE)
                media_content_error("media_info_set_favorite failed: %d", ret);
@@ -2514,14 +2709,6 @@ int test_request_update_db(void)
        if (ret != MEDIA_CONTENT_ERROR_NONE)
                media_content_error("media_info_get_media_from_db failed: %d", ret);
 
-       ret = media_info_get_content_name(media, &content_name);
-       if (ret != MEDIA_CONTENT_ERROR_NONE)
-               media_content_error("media_info_get_content_name failed: %d", ret);
-       else
-               media_content_debug("content name [%s]", content_name);
-
-       SAFE_FREE(content_name);
-
        ret = media_info_get_favorite(media, &favorite);
        if (ret != MEDIA_CONTENT_ERROR_NONE)
                media_content_error("media_info_get_favorite failed: %d", ret);
@@ -2572,8 +2759,7 @@ bool dft_cb(media_info_h media, void *user_data)
        } else
                media_content_debug("invalid media_type");
 
-       if (mime_type != NULL)
-               free(mime_type);
+       SAFE_FREE(mime_type);
 
        return true;
 
@@ -2700,7 +2886,7 @@ void insert_batch_cb(media_content_error_e error, void * user_data)
 int test_batch_operations()
 {
        int ret = -1;
-       int i;
+       int i = 0;
        char *file_list[10];
 
        for (i = 0; i < 10; i++) {
@@ -2711,82 +2897,12 @@ int test_batch_operations()
        }
 
        ret = media_info_insert_batch_to_db((const char **)file_list, 10, insert_batch_cb, NULL);
-       if (ret != MEDIA_CONTENT_ERROR_NONE) {
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
                media_content_error("media_info_insert_batch_to_db failed : %d\n", ret);
-       }
-
-       filter_h filter;
-       char *condition = "MEDIA_PATH LIKE \'";
-       strncat(condition, tzplatform_mkpath(TZ_USER_CONTENT, "test/image%%jpg\'"), 17);
-       ret = media_filter_create(&filter);
-       if (ret != MEDIA_CONTENT_ERROR_NONE) {
-               media_content_error("Fail to create filter");
-               return ret;
-       }
-
-       ret = media_filter_set_condition(filter, condition, MEDIA_CONTENT_COLLATE_DEFAULT);
-       if (ret != MEDIA_CONTENT_ERROR_NONE) {
-               media_filter_destroy(filter);
-               media_content_error("Fail to set condition");
-               return ret;
-       }
-
-       ret = media_info_delete_batch_from_db(filter);
-       if (ret != MEDIA_CONTENT_ERROR_NONE) {
-               media_filter_destroy(filter);
-               media_content_error("media_info_delete_batch_from_db failed : %d\n", ret);
-               return ret;
-       }
-
-       ret = media_filter_destroy(filter);
-
-       return ret;
-}
-
-void insert_burst_shot_cb(media_content_error_e error, void * user_data)
-{
-       media_content_debug("media_info_insert_burst_shot_to_db completed![%d]\n", error);
-       g_main_loop_quit(g_loop);
-}
-
-gboolean test_insert_burst_shot_to_db_start(gpointer data)
-{
-       int ret = MEDIA_CONTENT_ERROR_NONE;
-       int i = 0;
-       char *file_list[10];
-
-       for (i = 0; i < 10; i++) {
-               char filepath[255] = {0,};
-               snprintf(filepath, sizeof(filepath), "%s%d.jpg", tzplatform_mkpath(TZ_USER_CONTENT, "test/image"), i+1);
-               media_content_debug("File : %s\n", filepath);
-               file_list[i] = strdup(filepath);
-       }
-
-       ret = media_info_insert_burst_shot_to_db((const char **)file_list, 10, insert_burst_shot_cb, NULL);
-       if (ret != MEDIA_CONTENT_ERROR_NONE) {
-               media_content_error("media_info_insert_burst_shot_to_db failed : %d\n", ret);
-       }
 
        return ret;
 }
 
-int test_insert_burst_shot_to_db(void)
-{
-       GSource *source = NULL;
-       GMainContext *context = NULL;
-
-       g_loop = g_main_loop_new(NULL, FALSE);
-       context = g_main_loop_get_context(g_loop);
-       source = g_idle_source_new();
-       g_source_set_callback(source, test_insert_burst_shot_to_db_start, NULL, NULL);
-       g_source_attach(source, context);
-
-       g_main_loop_run(g_loop);
-       g_main_loop_unref(g_loop);
-
-       return 0;
-}
-
 void _scan_cb(media_content_error_e err, void *user_data)
 {
        media_content_debug("scan callback is called : %d\n", err);
@@ -2829,7 +2945,7 @@ gboolean cancel_scan_dir_start(gpointer data)
 {
        int ret = MEDIA_CONTENT_ERROR_NONE;
 
-       const char *dir_path = "/opt/usr/media/Images";
+       const char *dir_path = tzplatform_getenv(TZ_USER_IMAGES);
 
        ret = media_content_cancel_scan_folder(dir_path);
 
@@ -2875,27 +2991,24 @@ void _noti_cb(media_content_error_e error,
                                char *mime_type,
                                void *user_data)
 {
-       if (error == 0) {
+       if (error == 0)
                media_content_debug("noti success! : %d\n", error);
-       } else {
+       else
                media_content_debug("error occured! : %d\n", error);
-       }
 
        media_content_debug("Noti from PID(%d)\n", pid);
 
-       if (update_item == MEDIA_ITEM_FILE) {
+       if (update_item == MEDIA_ITEM_FILE)
                media_content_debug("Noti item : MEDIA_ITEM_FILE\n");
-       } else if (update_item == MEDIA_ITEM_DIRECTORY) {
+       else if (update_item == MEDIA_ITEM_DIRECTORY)
                media_content_debug("Noti item : MEDIA_ITEM_DIRECTORY\n");
-       }
 
-       if (update_type == MEDIA_CONTENT_INSERT) {
+       if (update_type == MEDIA_CONTENT_INSERT)
                media_content_debug("Noti type : MEDIA_CONTENT_INSERT\n");
-       } else if (update_type == MEDIA_CONTENT_DELETE) {
+       else if (update_type == MEDIA_CONTENT_DELETE)
                media_content_debug("Noti type : MEDIA_CONTENT_DELETE\n");
-       } else if (update_type == MEDIA_CONTENT_UPDATE) {
+       else if (update_type == MEDIA_CONTENT_UPDATE)
                media_content_debug("Noti type : MEDIA_CONTENT_UPDATE\n");
-       }
 
        media_content_debug("content type : %d\n", media_type);
 
@@ -2916,21 +3029,45 @@ void _noti_cb(media_content_error_e error,
 
        if (user_data) media_content_debug("String : %s\n", (char *)user_data);
 
-       //g_main_loop_quit(g_loop);
        return;
 }
 
-gboolean _send_noti_operations(gpointer data)
+void _noti_cb_2(media_content_error_e error,
+                               int pid,
+                               media_content_db_update_item_type_e update_item,
+                               media_content_db_update_type_e update_type,
+                               media_content_type_e media_type,
+                               char *uuid,
+                               char *path,
+                               char *mime_type,
+                               void *user_data)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
+       if (error == 0)
+               media_content_debug("noti_2 success! : %d\n", error);
+       else
+               media_content_debug("error occured! : %d\n", error);
 
-       /* First of all, noti subscription */
-       char *user_str = strdup("hi");
-       media_content_set_db_updated_cb(_noti_cb, (void*)user_str);
+       media_content_debug("Noti_2 from PID(%d)\n", pid);
 
-       /* media_info_insert_to_db */
-       media_info_h media_item = NULL;
-       const char *path = tzplatform_mkpath(TZ_USER_CONTENT, "test/image1.jpg");
+       g_main_loop_quit(g_loop);
+       return;
+}
+
+static media_content_noti_h noti_h;
+static media_content_noti_h noti_h_2;
+
+gboolean _send_noti_operations(gpointer data)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       /* First of all, noti subscription */
+       char *user_str = strdup("hi");
+       media_content_add_db_updated_cb(_noti_cb, (void*)user_str, &noti_h);
+       media_content_add_db_updated_cb(_noti_cb_2, (void*)user_str, &noti_h_2);
+
+       /* media_info_insert_to_db */
+       media_info_h media_item = NULL;
+       const char *path = tzplatform_mkpath(TZ_USER_CONTENT, "test/image1.jpg");
 
        ret = media_info_insert_to_db(path, &media_item);
        if (ret != MEDIA_CONTENT_ERROR_NONE) {
@@ -2941,34 +3078,7 @@ gboolean _send_noti_operations(gpointer data)
 
        media_content_debug("media_info_insert_to_db success");
 
-       /* media_info_delete_batch_from_db */
-       filter_h filter;
-       char *condition = "MEDIA_PATH LIKE \'";
-       strncat(condition, tzplatform_mkpath(TZ_USER_CONTENT, "test/image%%jpg\'"), 17);
-
-       ret = media_filter_create(&filter);
-       if (ret != MEDIA_CONTENT_ERROR_NONE) {
-               media_content_error("Fail to create filter");
-               media_info_destroy(media_item);
-               return ret;
-       }
-
-       ret = media_filter_set_condition(filter, condition, MEDIA_CONTENT_COLLATE_DEFAULT);
-       if (ret != MEDIA_CONTENT_ERROR_NONE) {
-               media_filter_destroy(filter);
-               media_info_destroy(media_item);
-               media_content_error("Fail to set condition");
-               return ret;
-       }
-       ret = media_info_delete_batch_from_db(filter);
-       if (ret != MEDIA_CONTENT_ERROR_NONE) {
-               media_filter_destroy(filter);
-               media_info_destroy(media_item);
-               media_content_error("media_info_delete_batch_from_db failed : %d\n", ret);
-               return ret;
-       }
-
-       media_filter_destroy(filter);
+       media_content_remove_db_updated_cb(noti_h);
 
        /* media_info_update_to_db */
        ret = media_info_update_to_db(media_item);
@@ -2999,149 +3109,9 @@ int test_noti()
        g_main_loop_unref(g_loop);
 
        test_filter_destroy();
-       media_content_unset_db_updated_cb();
-
-       return ret;
-}
-
-int test_create_handle(void)
-{
-       int ret = MEDIA_CONTENT_ERROR_NONE;
-       media_info_h media = NULL;
-       const char *path = "/home/owner/content/test/test.txt";
-       char *str_value = NULL;
-       int int_value = -1;
-       bool bool_value = FALSE;
-       unsigned long long content_size = 0;
-       time_t modified_time = 0;
-       double double_value = 0.0;
-
-       ret = media_info_create(path, &media);
-
-       ret = media_info_set_title(media, "test_title");
-       ret = media_info_set_album(media, "test_album");
-       ret = media_info_set_artist(media, "test_artist");
-       ret = media_info_set_genre(media, "test_genre");
-       ret = media_info_set_recorded_date(media, "test_recorded_date");
-       ret = media_info_set_age_rating(media, "test_age_rating");
-       ret = media_info_set_author(media, "test_author");
-       ret = media_info_set_category(media, "test_category");
-       ret = media_info_set_content_name(media, "test_content_name");
-       ret = media_info_set_description(media, "test_description");
-       ret = media_info_set_display_name(media, "test_display_name");
-       ret = media_info_set_keyword(media, "test_keyword");
-       ret = media_info_set_location_tag(media, "test_location_tag");
-       ret = media_info_set_weather(media, "test_weather");
-       ret = media_info_set_provider(media, "test_provider");
-
-       ret = media_info_set_altitude(media, 100.10);
-       ret = media_info_set_latitude(media, 200.20);
-       ret = media_info_set_longitude(media, 300.30);
-       ret = media_info_set_rating(media, 10);
-       ret = media_info_set_played_time(media);
-       ret = media_info_set_favorite(media, TRUE);
-       ret = media_info_increase_played_count(media);
-       ret = media_info_set_added_time(media, 12345);
-
-       ret = media_info_insert_to_db_with_data(media);
-       if (ret != MEDIA_CONTENT_ERROR_NONE) {
-               media_content_error("media_info_insert_to_db_with_data failed : %d\n", ret);
-               media_info_destroy(media);
-               return ret;
-       }
-
-       ret = media_info_get_media_id(media, &str_value);
-       media_content_debug("media_id = [%s]", str_value);
-       SAFE_FREE(str_value);
-
-       ret = media_info_get_file_path(media, &str_value);
-       media_content_debug("file_path = [%s]", str_value);
-       SAFE_FREE(str_value);
-
-       ret = media_info_get_title(media, &str_value);
-       media_content_debug("title = [%s]", str_value);
-       SAFE_FREE(str_value);
-
-       ret = media_info_get_age_rating(media, &str_value);
-       media_content_debug("age_rating = [%s]", str_value);
-       SAFE_FREE(str_value);
-
-       ret = media_info_get_author(media, &str_value);
-       media_content_debug("author = [%s]", str_value);
-       SAFE_FREE(str_value);
-
-       ret = media_info_get_category(media, &str_value);
-       media_content_debug("category = [%s]", str_value);
-       SAFE_FREE(str_value);
-
-       ret = media_info_get_content_name(media, &str_value);
-       media_content_debug("content_name = [%s]", str_value);
-       SAFE_FREE(str_value);
-
-       ret = media_info_get_description(media, &str_value);
-       media_content_debug("description = [%s]", str_value);
-       SAFE_FREE(str_value);
-
-       ret = media_info_get_display_name(media, &str_value);
-       media_content_debug("display_name = [%s]", str_value);
-       SAFE_FREE(str_value);
-
-       ret = media_info_get_keyword(media, &str_value);
-       media_content_debug("keyword = [%s]", str_value);
-       SAFE_FREE(str_value);
-
-       ret = media_info_get_location_tag(media, &str_value);
-       media_content_debug("location_tag = [%s]", str_value);
-       SAFE_FREE(str_value);
-
-       ret = media_info_get_weather(media, &str_value);
-       media_content_debug("weather = [%s]", str_value);
-       SAFE_FREE(str_value);
-
-       ret = media_info_get_provider(media, &str_value);
-       media_content_debug("provider = [%s]", str_value);
-       SAFE_FREE(str_value);
-
-       ret = media_info_get_longitude(media, &double_value);
-       media_content_debug("longitude = [%lf]", double_value);
-
-       ret = media_info_get_latitude(media, &double_value);
-       media_content_debug("latitude = [%lf]", double_value);
-
-       ret = media_info_get_altitude(media, &double_value);
-       media_content_debug("altitud = [%lf]", double_value);
-
-       ret = media_info_get_rating(media, &int_value);
-       media_content_debug("rating = [%d]", int_value);
-
-       ret = media_info_get_favorite(media, &bool_value);
-       media_content_debug("favorite = [%d]", bool_value);
-
-       ret = media_info_get_played_time(media, &modified_time);
-       media_content_debug("played_time = [%d]", modified_time);
-
-       ret = media_info_get_played_count(media, &int_value);
-       media_content_debug("played_count = [%d]", int_value);
-
-       ret = media_info_get_added_time(media, &modified_time);
-       media_content_debug("added_time = [%d]", modified_time);
-
-       ret = media_info_get_size(media, &content_size);
-       media_content_debug("size = [%d]", content_size);
-
-       ret = media_info_get_modified_time(media, &modified_time);
-       media_content_debug("modified_time = [%d]", modified_time);
-
-       ret = media_info_get_media_type(media, (media_content_type_e *)&int_value);
-       media_content_debug("media_type = [%d]", int_value);
-
-       ret = media_info_get_storage_type(media, (media_content_storage_e *)&int_value);
-       media_content_debug("storage_type = [%d]", int_value);
-
-       media_info_destroy(media);
+       media_content_remove_db_updated_cb(noti_h_2);
 
        return ret;
-
 }
 
 bool media_face_test_cb(media_face_h face, void *user_data)
@@ -3247,11 +3217,24 @@ int test_face_add_del(void)
        media_content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "fail media_face_create");
 
        ret = media_face_set_face_rect(face, 10, 12, 50, 100);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("media_face_set_face_rect failed: %d", ret);
+
        ret = media_face_set_orientation(face, 5);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("media_face_set_orientation failed: %d", ret);
+
        ret = media_face_set_tag(face, face_tag);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("media_face_set_tag failed: %d", ret);
 
        ret = media_face_insert_to_db(face);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("media_face_insert_to_db failed: %d", ret);
+
        ret = media_face_destroy(face);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("media_face_destroy failed: %d", ret);
 
        /* Update Test */
        GList *all_item_list = NULL;
@@ -3273,9 +3256,17 @@ int test_face_add_del(void)
                face_handle = (media_face_h)g_list_nth_data(all_item_list, 0);
 
                ret = media_face_set_face_rect(face_handle, 20, 22, 70, 70);
+               if (ret != MEDIA_CONTENT_ERROR_NONE)
+                       media_content_error("media_face_set_face_rect failed: %d", ret);
                ret = media_face_set_orientation(face_handle, 3);
+               if (ret != MEDIA_CONTENT_ERROR_NONE)
+                       media_content_error("media_face_set_orientation failed: %d", ret);
                ret = media_face_set_tag(face_handle, NULL);
+               if (ret != MEDIA_CONTENT_ERROR_NONE)
+                       media_content_error("media_face_set_tag failed: %d", ret);
                ret = media_face_update_to_db(face_handle);
+               if (ret != MEDIA_CONTENT_ERROR_NONE)
+                       media_content_error("media_face_update_to_db failed: %d", ret);
 
                media_face_destroy(face_handle);
        }
@@ -3291,6 +3282,328 @@ int test_face_add_del(void)
        return ret;
 }
 
+#ifdef _USE_TVPD_MODE
+filter_h g_tv_filter = NULL;
+
+int test_tv_filter_create(void)
+{
+       media_content_debug("\n============Filter Create============\n\n");
+
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       ret = media_filter_create(&g_tv_filter);
+
+       ret = media_filter_set_storage(g_tv_filter, "0a22a163-e634-4a2e-ba14-0469a969eea0");
+
+       ret = media_filter_set_order(g_tv_filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_STORAGE_ID, MEDIA_CONTENT_COLLATE_DEFAULT);
+
+       return ret;
+}
+
+int test_tv_filter_destroy(void)
+{
+       media_content_debug("\n============Filter Destroy============\n\n");
+
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       ret = media_filter_destroy(g_tv_filter);
+
+       return ret;
+}
+
+bool pvr_item_cb(media_pvr_h pvr, void *user_data)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       char *c_value = NULL;
+       int i_value = 0;
+       bool b_value = false;
+       unsigned long long l_value = 0;
+
+       if (pvr == NULL) {
+               media_content_debug("NO Item");
+               return true;
+       }
+
+       ret = media_pvr_get_media_id(pvr, &c_value);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("Fail to media_pvr_get_media_id");
+       media_content_debug("media_id [%s]", c_value);
+       SAFE_FREE(c_value);
+
+       ret = media_pvr_get_channel_name(pvr, &c_value);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("Fail to media_pvr_get_channel_name");
+       media_content_debug("channel_name [%s]", c_value);
+       SAFE_FREE(c_value);
+
+       ret = media_pvr_get_program_title(pvr, &c_value);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("Fail to media_pvr_get_program_title");
+       media_content_debug("program_title [%s]", c_value);
+       SAFE_FREE(c_value);
+
+       ret = media_pvr_get_program_crid(pvr, &c_value);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("Fail to media_pvr_get_program_crid");
+       media_content_debug("program_crid [%s]", c_value);
+       SAFE_FREE(c_value);
+
+       ret = media_pvr_get_guidance(pvr, &c_value);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("Fail to media_pvr_get_guidance");
+       media_content_debug("guidance [%s]", c_value);
+       SAFE_FREE(c_value);
+
+       ret = media_pvr_get_synopsis(pvr, &c_value);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("Fail to media_pvr_get_synopsis");
+       media_content_debug("synopsis [%s]", c_value);
+       SAFE_FREE(c_value);
+
+       ret = media_pvr_get_genre(pvr, &c_value);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("Fail to media_pvr_get_synopsis");
+       media_content_debug("genre [%s]", c_value);
+       SAFE_FREE(c_value);
+
+       ret = media_pvr_get_language(pvr, &c_value);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("Fail to media_pvr_get_language");
+       media_content_debug("language [%s]", c_value);
+       SAFE_FREE(c_value);
+
+       ret = media_pvr_get_path(pvr, &c_value);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("Fail to media_pvr_get_path");
+       media_content_debug("path [%s]", c_value);
+       SAFE_FREE(c_value);
+
+       ret = media_pvr_get_storage_id(pvr, &c_value);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("Fail to media_pvr_get_storage_id");
+       media_content_debug("storage_id [%s]", c_value);
+       SAFE_FREE(c_value);
+
+       ret = media_pvr_get_size(pvr, &l_value);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("Fail to media_pvr_get_size");
+       media_content_debug("size [%lld]", l_value);
+
+       ret = media_pvr_get_timezone(pvr, &i_value);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("Fail to media_pvr_get_timezone");
+       media_content_debug("timezone [%d]", i_value);
+
+       ret = media_pvr_get_ptc(pvr, &i_value);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("Fail to media_pvr_get_ptc");
+       media_content_debug("ptc [%d]", i_value);
+
+       ret = media_pvr_get_major(pvr, &i_value);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("Fail to media_pvr_get_major");
+       media_content_debug("[%d]", i_value);
+
+       ret = media_pvr_get_minor(pvr, &i_value);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("Fail to media_pvr_get_minor");
+       media_content_debug("minor [%d]", i_value);
+
+       ret = media_pvr_get_channel_type(pvr, &i_value);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("Fail to media_pvr_get_channel_type");
+       media_content_debug("channel_type [%d]", i_value);
+
+       ret = media_pvr_get_program_num(pvr, &i_value);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("Fail to media_pvr_get_program_num");
+       media_content_debug("program_num [%d]", i_value);
+
+       unsigned int ui_value = 0;
+       ret = media_pvr_get_service_profile(pvr, &ui_value);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("Fail to media_pvr_get_service_profile");
+       media_content_debug("service_profile [%u]", ui_value);
+
+       ret = media_pvr_get_duration(pvr, &i_value);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("Fail to media_pvr_get_duration");
+       media_content_debug("duration [%d]", i_value);
+
+       ret = media_pvr_get_embargo_time(pvr, &i_value);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("Fail to media_pvr_get_embargo_time");
+       media_content_debug("embargo_time [%d]", i_value);
+
+       ret = media_pvr_get_expiry_time(pvr, &i_value);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("Fail to media_pvr_get_expiry_time");
+       media_content_debug("expiry_time [%d]", i_value);
+
+       ret = media_pvr_get_parental_rating(pvr, &i_value);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("Fail to media_pvr_get_parental_rating");
+       media_content_debug("parental_rating [%d]", i_value);
+
+       ret = media_pvr_get_start_time(pvr, &i_value);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("Fail to media_pvr_get_start_time");
+       media_content_debug("start_time [%d]", i_value);
+
+       ret = media_pvr_get_program_start_time(pvr, &i_value);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("Fail to media_pvr_get_program_start_time");
+       media_content_debug("program_start_time [%d]", i_value);
+
+       ret = media_pvr_get_program_end_time(pvr, &i_value);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("Fail to media_pvr_get_program_end_time");
+       media_content_debug("program_end_time [%d]", i_value);
+
+       ret = media_pvr_get_program_date(pvr, &i_value);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("Fail to media_pvr_get_program_date");
+       media_content_debug("program_date [%d]", i_value);
+
+       ret = media_pvr_get_timer_record(pvr, &b_value);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("Fail to media_pvr_get_timer_record");
+       media_content_debug("timer_record [%d]", b_value);
+
+       ret = media_pvr_get_series_record(pvr, &b_value);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("Fail to media_pvr_get_series_record");
+       media_content_debug("series_record [%d]", b_value);
+
+       ret = media_pvr_get_hd(pvr, &i_value);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("Fail to media_pvr_get_hd");
+       media_content_debug("hd [%d]", i_value);
+
+       ret = media_pvr_get_subtitle(pvr, &b_value);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("Fail to media_pvr_get_subtitle");
+       media_content_debug("subtitle [%d]", b_value);
+
+       ret = media_pvr_get_ttx(pvr, &b_value);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("Fail to media_pvr_get_ttx");
+       media_content_debug("ttx [%d]", b_value);
+
+       ret = media_pvr_get_ad(pvr, &b_value);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("Fail to media_pvr_get_ad");
+       media_content_debug("ad [%d]", b_value);
+
+       ret = media_pvr_get_hard_of_hearing_radio(pvr, &b_value);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("Fail to media_pvr_get_hard_of_hearing_radio");
+       media_content_debug("hard_of_hearing_radio [%d]", b_value);
+
+       ret = media_pvr_get_data_service(pvr, &b_value);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("Fail to media_pvr_get_data_service");
+       media_content_debug("data_service [%d]", b_value);
+
+       ret = media_pvr_get_content_lock(pvr, &b_value);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("Fail to media_pvr_get_content_lock");
+       media_content_debug("content_lock [%d]", b_value);
+
+       ret = media_pvr_get_content_watch(pvr, &b_value);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("Fail to media_pvr_get_content_watch");
+       media_content_debug("content_watch [%d]", b_value);
+
+       ret = media_pvr_get_has_audio_only(pvr, &b_value);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("Fail to media_pvr_get_has_audio_only");
+       media_content_debug("has_audio_only [%d]", b_value);
+
+       ret = media_pvr_get_is_local_record(pvr, &b_value);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("Fail to media_pvr_get_is_local_record");
+       media_content_debug("is_local_record [%d]", b_value);
+
+       ret = media_pvr_get_resolution(pvr, (media_pvr_resolution_e*)&i_value);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("Fail to media_pvr_get_resolution");
+       media_content_debug("resolution [%d]", i_value);
+
+       ret = media_pvr_get_aspectratio(pvr, (media_pvr_aspectratio_e*)&i_value);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("Fail to media_pvr_get_aspectratio");
+       media_content_debug("aspectratio [%d]", i_value);
+
+       ret = media_pvr_get_highlight(pvr, &b_value);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("Fail to media_pvr_get_highlight");
+       media_content_debug("highlight [%d]", b_value);
+
+
+       return TRUE;
+}
+
+int test_pvr()
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       int media_count = 0;
+
+       media_content_debug("\n============PVR Test============\n\n");
+
+       test_tv_filter_create();
+
+       ret = media_pvr_get_media_count_from_db(g_tv_filter, &media_count);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("media_pvr_get_media_count_from_db failed: %d", ret);
+       else
+               media_content_debug("media_count : [%d]", media_count);
+
+       ret = media_pvr_foreach_media_from_db(g_tv_filter, pvr_item_cb, NULL);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("media_pvr_foreach_media_from_db is failed");
+
+       test_tv_filter_destroy();
+
+       return ret;
+}
+
+int test_pvr_update_db(void)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_pvr_h pvr = NULL;
+
+       ret = media_pvr_get_pvr_from_db("ff9b5a9a-a7b4-47f4-8255-84e007e25f13", &pvr);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("media_pvr_get_pvr_from_db failed: %d", ret);
+
+       ret = media_pvr_set_content_lock(pvr, TRUE);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("Fail to media_pvr_set_content_lock");
+
+       ret = media_pvr_set_content_watch(pvr, TRUE);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("Fail to media_pvr_set_content_watch");
+
+       ret = media_pvr_set_program_title(pvr, "TEST TITLE");
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("Fail to media_pvr_set_program_title");
+
+       ret = media_pvr_set_highlight(pvr, TRUE);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("Fail to media_pvr_set_highlight");
+
+       ret = media_pvr_update_to_db(pvr);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("Fail to media_pvr_update_to_db");
+
+       if (pvr != NULL)
+               media_pvr_destroy(pvr);
+
+       return ret;
+}
+#endif
+
 int main(int argc, char *argv[])
 {
        int ret = MEDIA_CONTENT_ERROR_NONE;
@@ -3300,8 +3613,19 @@ int main(int argc, char *argv[])
        ret = test_connect_database();
        if (ret != MEDIA_CONTENT_ERROR_NONE)
                return MEDIA_CONTENT_ERROR_NONE;
+#ifdef _USE_TVPD_MODE
+       test_pvr();
+
+       test_pvr_update_db();
+
+       test_pvr();
+#endif
 
 #if 0
+       ret = test_start_face_detection(FALSE);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               return ret;
+
        ret = test_move();
        if (ret != MEDIA_CONTENT_ERROR_NONE)
                return ret;
@@ -3322,10 +3646,6 @@ int main(int argc, char *argv[])
        if (ret != MEDIA_CONTENT_ERROR_NONE)
                return ret;
 
-       ret = test_folder_update();
-       if (ret != MEDIA_CONTENT_ERROR_NONE)
-               return ret;
-
        ret = test_playlist_operation();
        if (ret != MEDIA_CONTENT_ERROR_NONE)
                return ret;
@@ -3362,6 +3682,10 @@ int main(int argc, char *argv[])
        if (ret != MEDIA_CONTENT_ERROR_NONE)
                return ret;
 
+       ret = test_extrace_face(TRUE);
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               return ret;
+
        ret = test_request_update_db();
        if (ret != MEDIA_CONTENT_ERROR_NONE)
                return ret;
@@ -3374,10 +3698,6 @@ int main(int argc, char *argv[])
        if (ret != MEDIA_CONTENT_ERROR_NONE)
                return MEDIA_CONTENT_ERROR_NONE;
 
-       ret = test_insert_burst_shot_to_db();
-       if (ret != MEDIA_CONTENT_ERROR_NONE)
-               return MEDIA_CONTENT_ERROR_NONE;
-
        ret = test_scan_file();
        if (ret != MEDIA_CONTENT_ERROR_NONE)
                return MEDIA_CONTENT_ERROR_NONE;
@@ -3390,15 +3710,23 @@ int main(int argc, char *argv[])
        if (ret != MEDIA_CONTENT_ERROR_NONE)
                return MEDIA_CONTENT_ERROR_NONE;
 
-       ret = test_create_handle();
+       ret = test_face();
        if (ret != MEDIA_CONTENT_ERROR_NONE)
                return MEDIA_CONTENT_ERROR_NONE;
 
-       ret = test_face();
+       ret = test_face_add_del();
        if (ret != MEDIA_CONTENT_ERROR_NONE)
                return MEDIA_CONTENT_ERROR_NONE;
 
-       ret = test_face_add_del();
+       ret = test_playlist_operation_v2();
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               return MEDIA_CONTENT_ERROR_NONE;
+
+       ret = test_bookmark_operation_v2();
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
+               return MEDIA_CONTENT_ERROR_NONE;
+
+       ret = test_tag_operation_v2();
        if (ret != MEDIA_CONTENT_ERROR_NONE)
                return MEDIA_CONTENT_ERROR_NONE;
 #endif