- media_filter_set_storage(filter, "cfbf3d2c-71c5-4611-bccc-7cbac890146e");
-
- ret = media_folder_get_folder_count_from_db(filter, &count);
- content_debug("Folder count : [%d]", count);
-
- ret = media_folder_foreach_folder_from_db(filter, folder_list_cb, &folder);
-
- filter_h m_filter = NULL;
-
- ret = media_filter_create(&m_filter);
- if (ret != MEDIA_CONTENT_ERROR_NONE) {
- test_filter_destroy();
- media_filter_destroy(filter);
- content_error("[ERROR] media_info_filter_create is failed");
- return ret;
- }
-
- media_filter_set_condition(m_filter, "MEDIA_TYPE=1 and MEDIA_STORAGE_TYPE=0", MEDIA_CONTENT_COLLATE_DEFAULT); /*MEDIA_TYPE 0-image, 1-video, 2-sound, 3-music, 4-other*/
- media_filter_set_offset(m_filter, 0, 5);
- media_filter_set_order(m_filter, MEDIA_CONTENT_ORDER_DESC, MEDIA_PATH, MEDIA_CONTENT_COLLATE_NOCASE);
-
- ret = media_folder_foreach_media_from_db(folder_id, m_filter, media_item_cb, NULL);
- if (ret != MEDIA_CONTENT_ERROR_NONE)
- content_error("[ERROR] media_folder_foreach_media_from_db is failed, error code : %d", ret);
-
- media_filter_destroy(filter);
- media_filter_destroy(m_filter);
-
- test_filter_destroy();
-
- /* fix prevent: Resource Leak */
- SAFE_FREE(folder_id);
-
- return ret;
-}
-
-int test_playlist_operation(void)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_playlist_h playlist_1 = NULL;
- media_playlist_h playlist_2 = NULL;
- media_playlist_h playlist_3 = NULL;
- media_playlist_h playlist_4 = NULL;
- int playlist_id_1 = 0;
- int playlist_id_2 = 0;
- int playlist_id_3 = 0;
- const char *playlist_name_1 = "myPlaylist_1";
- const char *playlist_name_2 = "myPlaylist_2";
- const char *playlist_name_3 = "myPlaylist_3";
- int playlist_count = 0;
- int media_count = 0;
- int order_1 = 0;
- int order_2 = 0;
- int order_3 = 0;
- int order_4 = 0;
- int order_5 = 0;
- filter_h filter = NULL;
- filter_h m_filter = NULL;
-
- content_debug("\n============Playlist Test============\n\n");
-
- /* Filter for playlist */
-
- const char *condition = "(MEDIA_TYPE=1 or MEDIA_TYPE=3)"; /*0-image, 1-video, 2-sound, 3-music, 4-other*/
-
- ret = media_filter_create(&filter);
- ret = media_filter_set_condition(filter, condition, MEDIA_CONTENT_COLLATE_NOCASE);
- ret = media_filter_set_order(filter, MEDIA_CONTENT_ORDER_ASC, PLAYLIST_NAME, MEDIA_CONTENT_COLLATE_NOCASE);
-
- /* Create Playlist */
- media_playlist_insert_to_db(playlist_name_1, &playlist_1);
- media_playlist_insert_to_db(playlist_name_2, &playlist_2);
- media_playlist_insert_to_db(playlist_name_3, &playlist_3);
-
- if (playlist_1 != NULL) {
- /* Add media to Playlist */
- media_playlist_add_media(playlist_1, test_audio_id);
- media_playlist_add_media(playlist_1, test_audio_id);
- media_playlist_add_media(playlist_1, test_video_id);
-
- #if 0
- char *playlist_thumb_path = tzplatform_mkpath(TZ_USER_IMAGES, "Default.jpg"));
- media_playlist_set_thumbnail_path(playlist_1, playlist_thumb_path);
- #endif
-
- media_playlist_update_to_db(playlist_1);
- }
-
- if (playlist_2 != NULL) {
- media_playlist_add_media(playlist_2, test_audio_id);
- media_playlist_add_media(playlist_2, test_audio_id);
- media_playlist_update_to_db(playlist_2);
- }
-
- /* Get Playlist Count*/
- ret = media_playlist_get_playlist_count_from_db(filter, &playlist_count);
- if (ret == 0)
- content_debug("playlist_count [%d]", playlist_count);
-
- /* Get Playlist*/
- GList *playlist_id_list = NULL;
- media_playlist_foreach_playlist_from_db(filter, playlist_list_cb, &playlist_id_list);
- /* 64bit build issue */
-#if 0
- /* Get Playlist id*/
- playlist_id_1 = (int)g_list_nth_data(playlist_id_list, 0);
- playlist_id_2 = (int)g_list_nth_data(playlist_id_list, 1);
- playlist_id_3 = (int)g_list_nth_data(playlist_id_list, 2);
-#endif
- content_debug("playlist_id_1 [%d]", playlist_id_1);
- content_debug("playlist_id_2 [%d]", playlist_id_2);
- content_debug("playlist_id_3 [%d]", playlist_id_3);
-
- /* Export and import playlist */
- 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);
-
- ret = media_filter_set_condition(m_filter, condition, MEDIA_CONTENT_COLLATE_DEFAULT);
-
- ret = media_filter_set_order(m_filter, MEDIA_CONTENT_ORDER_ASC, PLAYLIST_MEMBER_ORDER, MEDIA_CONTENT_COLLATE_DEFAULT);
-
- /* Get media count */
- media_playlist_get_media_count_from_db(playlist_id_1, m_filter, &media_count);
- content_debug("playlist_1_media_count [%d]", media_count);
-
- media_playlist_get_media_count_from_db(playlist_id_2, m_filter, &media_count);
- content_debug("playlist_2_media_count [%d]", media_count);
-
- media_playlist_get_media_count_from_db(playlist_id_3, m_filter, &media_count);
- content_debug("playlist_3_media_count [%d]", media_count);
-
- /* Get media of playlist */
- GList *playlist_member_id_list = NULL;
- GList *playlist_member_id_list_1 = NULL;
-
- media_playlist_foreach_media_from_db(playlist_id_1, m_filter, playlist_item_cb, &playlist_member_id_list);
- media_playlist_foreach_media_from_db(playlist_id_2, m_filter, playlist_item_cb, &playlist_member_id_list_1);
-
- int playlist_member_id_1_1 = 0;
- int playlist_member_id_1_2 = 0;
- int playlist_member_id_1_3 = 0;
- int playlist_member_id_2_1 = 0;
- int playlist_member_id_2_2 = 0;
- /* 64bit build issue */
-#if 0
- playlist_member_id_1_1 = (int)g_list_nth_data(playlist_member_id_list, 0);
- playlist_member_id_1_2 = (int)g_list_nth_data(playlist_member_id_list, 1);
- playlist_member_id_1_3 = (int)g_list_nth_data(playlist_member_id_list, 2);
- playlist_member_id_2_1 = (int)g_list_nth_data(playlist_member_id_list_1, 0);
- playlist_member_id_2_2 = (int)g_list_nth_data(playlist_member_id_list_1, 1);
-#endif
- content_debug("playlist_member_id_1_1 [%d]", playlist_member_id_1_1);
- content_debug("playlist_member_id_1_2 [%d]", playlist_member_id_1_2);
- content_debug("playlist_member_id_1_3 [%d]", playlist_member_id_1_3);
- content_debug("playlist_member_id_2_1 [%d]", playlist_member_id_2_1);
- content_debug("playlist_member_id_2_2 [%d]", playlist_member_id_2_2);
-
- media_playlist_get_play_order(playlist_1, playlist_member_id_1_1, &order_1);
- media_playlist_get_play_order(playlist_1, playlist_member_id_1_2, &order_2);
- media_playlist_get_play_order(playlist_1, playlist_member_id_1_3, &order_3);
- media_playlist_get_play_order(playlist_2, playlist_member_id_2_1, &order_4);
- media_playlist_get_play_order(playlist_2, playlist_member_id_2_2, &order_5);
- content_debug("order_1 [%d] order_2 [%d] order_3 [%d] order_4 [%d] order_5 [%d]", order_1, order_2, order_3, order_4, order_5);
-
- /* Update Playlist */
- media_playlist_remove_media(playlist_2, playlist_member_id_2_1);
- media_playlist_add_media(playlist_2, test_video_id);
- media_playlist_set_name(playlist_2, "test_playlist");
- media_playlist_set_play_order(playlist_2, playlist_member_id_2_2, order_5+100);
- media_playlist_update_to_db(playlist_2);
-
- /* Get Updated Playlist*/
- media_playlist_foreach_playlist_from_db(filter, playlist_list_cb, NULL);
-
- /* deletes the playlist */
-#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);
- if (playlist_2 != NULL)
- media_playlist_destroy(playlist_2);
- if (playlist_3 != NULL)
- media_playlist_destroy(playlist_3);
- if (playlist_4 != NULL)
- media_playlist_destroy(playlist_4);
-
- g_list_free(playlist_id_list);
- g_list_free(playlist_member_id_list);
- g_list_free(playlist_member_id_list_1);
-
- if (filter != NULL)
- ret = media_filter_destroy(filter);
- if (m_filter != NULL)
- ret = media_filter_destroy(m_filter);
-
- 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;
-
- content_debug("\n============Playlist Test V2============\n\n");
-
- ret = media_playlist_create(&playlist_1);
- if (ret != MEDIA_CONTENT_ERROR_NONE)
- content_error("error media_playlist_create : [%d]", ret);
-
- ret = media_playlist_set_name(playlist_1, playlist_name_1);
- if (ret != MEDIA_CONTENT_ERROR_NONE)
- 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)
- 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)
- 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)
- 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)
- 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)
- content_error("error media_playlist_update_to_db_v2 : [%d]", ret);
-
- ret = media_playlist_destroy(playlist_1);
- if (ret != MEDIA_CONTENT_ERROR_NONE)
- content_error("error media_playlist_destroy : [%d]", ret);
-
- return ret;
-}
-
-int test_tag_operation(void)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_tag_h tag_1;
- media_tag_h tag_2;
- media_tag_h tag_3;
- int tag_id_1 = 0;
- int tag_id_2 = 0;
- int tag_id_3 = 0;
- const char *tag_name_1 = "myTag_1";
- const char *tag_name_2 = "myTag_2";
- const char *tag_name_3 = "myTag_3";
- int tag_count = 0;
- int media_count = 0;
- filter_h filter;
-
- content_debug("\n============Tag Test============\n\n");
-
- const char *g_condition = "TAG_NAME like \"%%my%%\"";
-
- ret = media_filter_create(&filter);
-
- ret = media_filter_set_condition(filter, g_condition, MEDIA_CONTENT_COLLATE_DEFAULT);
-
- ret = media_filter_set_order(filter, MEDIA_CONTENT_ORDER_DESC, TAG_NAME, MEDIA_CONTENT_COLLATE_DEFAULT);
-
- /* Create Tag */
- ret = media_tag_insert_to_db(tag_name_1, &tag_1);
- if (ret != MEDIA_CONTENT_ERROR_NONE)
- content_error("error media_tag_insert_to_db : [%d]", ret);
- ret = media_tag_insert_to_db(tag_name_2, &tag_2);
- if (ret != MEDIA_CONTENT_ERROR_NONE)
- content_error("error media_tag_insert_to_db : [%d]", ret);
- ret = media_tag_insert_to_db(tag_name_3, &tag_3);
- if (ret != MEDIA_CONTENT_ERROR_NONE)
- content_error("error media_tag_insert_to_db : [%d]", ret);
-
- /* Add media to Tag */
- ret = media_tag_add_media(tag_1, test_audio_id);
- if (ret != MEDIA_CONTENT_ERROR_NONE)
- 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)
- content_error("error media_tag_add_media : [%d]", ret);
- ret = media_tag_update_to_db(tag_1);
- if (ret != MEDIA_CONTENT_ERROR_NONE)
- content_error("error media_tag_update_to_db : [%d]", ret);
-
- ret = media_tag_add_media(tag_2, test_audio_id);
- if (ret != MEDIA_CONTENT_ERROR_NONE)
- content_error("error media_tag_add_media : [%d]", ret);
- ret = media_tag_update_to_db(tag_2);
- if (ret != MEDIA_CONTENT_ERROR_NONE)
- content_error("error media_tag_update_to_db : [%d]", ret);
-
- /* Get Tag Count*/
- ret = media_tag_get_tag_count_from_db(filter, &tag_count);
- if (ret != MEDIA_CONTENT_ERROR_NONE)
- content_error("error media_tag_get_tag_count_from_db : [%d]", ret);
- else
- content_debug("tag_count [%d]", tag_count);
-
- /* Get Tag*/
- ret = media_tag_foreach_tag_from_db(filter, tag_list_cb, NULL);
- if (ret != MEDIA_CONTENT_ERROR_NONE)
- content_error("error media_tag_foreach_tag_from_db : [%d]", ret);
-
- /* Get Tag id*/
- ret = media_tag_get_tag_id(tag_1, &tag_id_1);
- if (ret != MEDIA_CONTENT_ERROR_NONE)
- content_error("error media_tag_get_tag_id : [%d]", ret);
- else
- content_debug("tag_id_1 [%d]", tag_id_1);
-
- ret = media_tag_get_tag_id(tag_2, &tag_id_2);
- if (ret != MEDIA_CONTENT_ERROR_NONE)
- content_error("error media_tag_get_tag_id : [%d]", ret);
- else
- content_debug("tag_id_2 [%d]", tag_id_2);
-
- ret = media_tag_get_tag_id(tag_3, &tag_id_3);
- if (ret != MEDIA_CONTENT_ERROR_NONE)
- content_error("error media_tag_get_tag_id : [%d]", ret);
- else
- content_debug("tag_id_3 [%d]", tag_id_3);
-
- /* Get media count */
- ret = media_tag_get_media_count_from_db(tag_id_1, NULL, &media_count);
- if (ret != MEDIA_CONTENT_ERROR_NONE)
- content_error("error media_tag_get_media_count_from_db : [%d]", ret);
- else
- content_debug("tag_1_media_count [%d]", media_count);
-
- ret = media_tag_get_media_count_from_db(tag_id_2, NULL, &media_count);
- if (ret != MEDIA_CONTENT_ERROR_NONE)
- content_error("error media_tag_get_media_count_from_db : [%d]", ret);
- else
- content_debug("tag_2_media_count [%d]", media_count);
-
- /* Get media of Tag */
- ret = media_tag_foreach_media_from_db(tag_id_1, NULL, media_item_cb, NULL);
- if (ret != MEDIA_CONTENT_ERROR_NONE)
- content_error("error media_tag_foreach_media_from_db : [%d]", ret);
-
- ret = media_tag_foreach_media_from_db(tag_id_2, NULL, media_item_cb, NULL);
- if (ret != MEDIA_CONTENT_ERROR_NONE)
- content_error("error media_tag_foreach_media_from_db : [%d]", ret);
-
- /* Update Tag */
- ret = media_tag_add_media(tag_2, test_video_id);
- if (ret != MEDIA_CONTENT_ERROR_NONE)
- content_error("error media_tag_add_media : [%d]", ret);
- ret = media_tag_set_name(tag_2, "test_tag");
- if (ret != MEDIA_CONTENT_ERROR_NONE)
- content_error("error media_tag_set_name : [%d]", ret);
- ret = media_tag_update_to_db(tag_2);
- if (ret != MEDIA_CONTENT_ERROR_NONE)
- content_error("error media_tag_update_to_db : [%d]", ret);
-
- /* Get Updated Tag*/
- ret = media_tag_foreach_tag_from_db(filter, tag_list_cb, NULL);
- if (ret != MEDIA_CONTENT_ERROR_NONE)
- content_error("error media_tag_foreach_tag_from_db : [%d]", ret);
-
- /* deletes the tag */
- ret = media_tag_delete_from_db(tag_id_1);
- if (ret != MEDIA_CONTENT_ERROR_NONE)
- content_error("error media_tag_delete_from_db : [%d]", ret);
- ret = media_tag_delete_from_db(tag_id_2);
- if (ret != MEDIA_CONTENT_ERROR_NONE)
- content_error("error media_tag_delete_from_db : [%d]", ret);
-
- ret = media_tag_destroy(tag_1);
- if (ret != MEDIA_CONTENT_ERROR_NONE)
- content_error("error media_tag_destroy : [%d]", ret);
- ret = media_tag_destroy(tag_2);
- if (ret != MEDIA_CONTENT_ERROR_NONE)
- content_error("error media_tag_destroy : [%d]", ret);
- ret = media_tag_destroy(tag_3);
- if (ret != MEDIA_CONTENT_ERROR_NONE)
- content_error("error media_tag_destroy : [%d]", ret);
- ret = media_filter_destroy(filter);
- if (ret != MEDIA_CONTENT_ERROR_NONE)
- content_error("error media_filter_destroy : [%d]", ret);
-
- 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;
-
- content_debug("\n============Tag Test V2============\n\n");
-
- /* Create Tag */
- ret = media_tag_create(&tag_1);
- if (ret != MEDIA_CONTENT_ERROR_NONE)
- content_error("error media_tag_create : [%d]", ret);
-
- ret = media_tag_set_name(tag_1, tag_name_1);
- if (ret != MEDIA_CONTENT_ERROR_NONE)
- 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)
- 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)
- content_error("error media_tag_add_media : [%d]", ret);
-
- ret = media_tag_insert_to_db_v2(tag_1);
- if (ret != MEDIA_CONTENT_ERROR_NONE)
- 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)
- 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)
- 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)
- content_error("error media_tag_update_to_db_v2 : [%d]", ret);
-#endif
-
- ret = media_tag_destroy(tag_1);
- if (ret != MEDIA_CONTENT_ERROR_NONE)
- content_error("error media_tag_destroy : [%d]", ret);
-
- return ret;
-}
-
-int test_bookmark_operation(void)
-{
- /* 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;
-
- content_debug("\n============Bookmark Test============\n\n");
-
- const char *g_condition = "BOOKMARK_MARKED_TIME > 300";
-
- ret = media_filter_create(&filter);
- if (ret != MEDIA_CONTENT_ERROR_NONE)
- content_error("error media_filter_create : [%d]", ret);
-
- ret = media_filter_set_condition(filter, g_condition, MEDIA_CONTENT_COLLATE_DEFAULT);
- if (ret != MEDIA_CONTENT_ERROR_NONE)
- content_error("error media_filter_set_condition : [%d]", ret);
-
- ret = media_filter_set_order(filter, MEDIA_CONTENT_ORDER_DESC, BOOKMARK_MARKED_TIME, MEDIA_CONTENT_COLLATE_DEFAULT);
- if (ret != MEDIA_CONTENT_ERROR_NONE)
- content_error("error media_filter_set_order : [%d]", ret);
-
- /* 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)
- content_error("error media_bookmark_insert_to_db : [%d]", ret);
-
- ret = media_bookmark_insert_to_db(test_video_id, 600, thumbnail_path1);
- if (ret != MEDIA_CONTENT_ERROR_NONE)
- content_error("error media_bookmark_insert_to_db : [%d]", ret);
-
- ret = media_bookmark_get_bookmark_count_from_db(filter, &bookmark_count);
- if (ret != MEDIA_CONTENT_ERROR_NONE)
- content_error("error media_bookmark_get_bookmark_count_from_db : [%d]", ret);
- else
- 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)
- 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)
- content_error("error media_bookmark_set_name : [%d]", ret);
-
- ret = media_bookmark_update_to_db(bookmark_handle);
- if (ret != MEDIA_CONTENT_ERROR_NONE)
- 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)
- content_error("error media_info_foreach_bookmark_from_db : [%d]", ret);
-
- ret = media_filter_destroy(filter);
- if (ret != MEDIA_CONTENT_ERROR_NONE)
- content_error("error media_filter_destroy : [%d]", ret);
-
- return ret;
-}