2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include <media_content.h>
22 #include <media_info_private.h>
24 #include <tzplatform_config.h>
25 #include <media_content_internal.h>
28 static filter_h g_filter = NULL;
30 static GMainLoop *g_loop = NULL;
32 #define test_audio_id "3304285f-1070-41af-8b4e-f0086cc768f3"
33 #define test_video_id "53c43e7e-53d2-4194-80a6-55d5dcde0def"
34 #define test_image_id "db1c184c-6f31-43b4-b924-8c00ac5b6197"
36 static void get_audio_meta(media_info_h media)
38 audio_meta_h audio = NULL;
41 content_debug("=== audio meta ===");
42 if (media_info_get_audio(media, &audio) != MEDIA_CONTENT_ERROR_NONE)
45 if (audio_meta_get_media_id(audio, &c_value) == MEDIA_CONTENT_ERROR_NONE) {
46 content_debug("audio_id : [%s]", c_value);
50 if (audio_meta_get_album(audio, &c_value) == MEDIA_CONTENT_ERROR_NONE) {
51 content_debug("album : [%s]", c_value);
55 if (audio_meta_get_artist(audio, &c_value) == MEDIA_CONTENT_ERROR_NONE) {
56 content_debug("artist : [%s]", c_value);
60 if (audio_meta_get_album_artist(audio, &c_value) == MEDIA_CONTENT_ERROR_NONE) {
61 content_debug("album artist : [%s]", c_value);
65 if (audio_meta_get_genre(audio, &c_value) == MEDIA_CONTENT_ERROR_NONE) {
66 content_debug("genre : [%s]", c_value);
70 if (audio_meta_get_year(audio, &c_value) == MEDIA_CONTENT_ERROR_NONE) {
71 content_debug("year : [%s]", c_value);
75 if (audio_meta_get_track_num(audio, &c_value) == MEDIA_CONTENT_ERROR_NONE) {
76 content_debug("track number : [%s]", c_value);
80 audio_meta_destroy(audio);
83 static void get_image_meta(media_info_h media)
85 image_meta_h image = NULL;
88 media_content_orientation_e orientation;
90 content_debug("=== image meta ===");
91 if (media_info_get_image(media, &image) != MEDIA_CONTENT_ERROR_NONE)
94 if (image_meta_get_width(image, &i_value) == MEDIA_CONTENT_ERROR_NONE)
95 content_debug("width : [%d]", i_value);
97 if (image_meta_get_height(image, &i_value) == MEDIA_CONTENT_ERROR_NONE)
98 content_debug("height : [%d]", i_value);
100 if (image_meta_get_orientation(image, &orientation) == MEDIA_CONTENT_ERROR_NONE)
101 content_debug("orientation : [%d]", orientation);
103 if (image_meta_get_date_taken(image, &c_value) == MEDIA_CONTENT_ERROR_NONE) {
104 content_debug("datetaken : [%s]", c_value);
108 image_meta_destroy(image);
111 static void get_book_meta(media_info_h media)
113 book_meta_h book = NULL;
114 char *c_value = NULL;
116 content_debug("=== book meta ===");
117 if (media_info_get_book(media, &book) != MEDIA_CONTENT_ERROR_NONE)
120 if (book_meta_get_media_id(book, &c_value) == MEDIA_CONTENT_ERROR_NONE) {
121 content_debug("media_id : [%s]", c_value);
125 if (book_meta_get_author(book, &c_value) == MEDIA_CONTENT_ERROR_NONE) {
126 content_debug("author : [%s]", c_value);
130 if (book_meta_get_subject(book, &c_value) == MEDIA_CONTENT_ERROR_NONE) {
131 content_debug("subject : [%s]", c_value);
135 book_meta_destroy(book);
138 static void get_album_meta(media_album_h album)
140 char *c_value = NULL;
143 content_debug("=== album meta ===");
144 if (media_album_get_album_id(album, &i_value) == MEDIA_CONTENT_ERROR_NONE)
145 content_debug("album id : [%d]", i_value);
147 if (media_album_get_name(album, &c_value) == MEDIA_CONTENT_ERROR_NONE) {
148 content_debug("album name : [%s]", c_value);
152 if (media_album_get_artist(album, &c_value) == MEDIA_CONTENT_ERROR_NONE) {
153 content_debug("album artist : [%s]", c_value);
158 static void get_bookmark_meta(media_bookmark_h bookmark)
160 char *c_value = NULL;
164 content_debug("=== bookmark meta ===");
165 if (media_bookmark_get_bookmark_id(bookmark, &i_value) == MEDIA_CONTENT_ERROR_NONE)
166 content_debug("bookmark_id : %d", i_value);
168 if (media_bookmark_get_thumbnail_path(bookmark, &c_value) == MEDIA_CONTENT_ERROR_NONE) {
169 content_debug("bookmark thumbnail_path : %s", c_value);
173 if (media_bookmark_get_marked_time(bookmark, &time) == MEDIA_CONTENT_ERROR_NONE)
174 content_debug("bookmark marked_time : %ld", time);
176 if (media_bookmark_get_name(bookmark, &c_value) == MEDIA_CONTENT_ERROR_NONE) {
177 content_debug("bookmark name : %s", c_value);
182 static void get_folder_meta(media_folder_h folder, char **folder_id)
184 char *c_value = NULL;
186 content_debug("=== folder meta ===");
187 if (media_folder_get_folder_id(folder, &c_value) != MEDIA_CONTENT_ERROR_NONE) {
188 content_debug("folder_id : %s", c_value);
189 *folder_id = c_value;
192 if (media_folder_get_path(folder, &c_value) == MEDIA_CONTENT_ERROR_NONE) {
193 content_debug("folder_path : %s", c_value);
197 if (media_folder_get_name(folder, &c_value) == MEDIA_CONTENT_ERROR_NONE) {
198 content_debug("folder_name : %s", c_value);
203 static void get_media_meta(media_info_h media)
205 char *c_value = NULL;
207 unsigned long long size = 0;
208 media_content_type_e media_type = 0;
209 #ifdef _USE_TVPD_MODE
213 content_debug("=== media meta ===");
214 if (media_info_get_media_type(media, &media_type) == MEDIA_CONTENT_ERROR_NONE)
215 content_debug("media_type : [%d]", media_type);
217 if (media_info_get_media_id(media, &c_value) == MEDIA_CONTENT_ERROR_NONE) {
218 content_debug("media_id : [%s]", c_value);
222 if (media_info_get_file_path(media, &c_value) == MEDIA_CONTENT_ERROR_NONE) {
223 content_debug("file_path : [%s]", c_value);
227 if (media_info_get_display_name(media, &c_value) == MEDIA_CONTENT_ERROR_NONE) {
228 content_debug("display_name : [%s]", c_value);
232 if (media_info_get_mime_type(media, &c_value) == MEDIA_CONTENT_ERROR_NONE) {
233 content_debug("mime_type : [%s]", c_value);
237 if (media_info_get_thumbnail_path(media, &c_value) == MEDIA_CONTENT_ERROR_NONE) {
238 content_debug("thumbnail_path : [%s]", c_value);
242 if (media_info_get_size(media, &size) == MEDIA_CONTENT_ERROR_NONE)
243 content_debug("size : [%lld]", size);
245 if (media_info_get_added_time(media, &t_value) == MEDIA_CONTENT_ERROR_NONE)
246 content_debug("added_time : [%ld]", t_value);
248 if (media_info_get_modified_time(media, &t_value) == MEDIA_CONTENT_ERROR_NONE)
249 content_debug("modified_time : [%ld]", t_value);
251 #ifdef _USE_TVPD_MODE
252 if (media_info_get_stitched_state(media, &i_value) == MEDIA_CONTENT_ERROR_NONE)
253 content_debug("360 stitched : [%d]", i_value);
256 if (media_type == MEDIA_CONTENT_TYPE_MUSIC)
257 get_audio_meta(media);
259 if (media_type == MEDIA_CONTENT_TYPE_IMAGE)
260 get_image_meta(media);
262 if (media_type == MEDIA_CONTENT_TYPE_BOOK)
263 get_book_meta(media);
265 if (media_type == MEDIA_CONTENT_TYPE_OTHERS)
266 content_debug("Other type");
269 bool media_item_cb(media_info_h media, void *user_data)
272 content_debug("NO Item");
276 get_media_meta(media);
281 bool gallery_folder_list_cb(media_folder_h folder, void *user_data)
283 media_folder_h new_folder = NULL;
284 media_folder_clone(&new_folder, folder);
286 GList **list = (GList**)user_data;
287 *list = g_list_append(*list, new_folder);
292 bool gallery_media_item_cb(media_info_h media, void *user_data)
294 media_info_h new_media = NULL;
295 int ret = MEDIA_CONTENT_ERROR_NONE;
297 ret = media_info_clone(&new_media, media);
299 if (ret != MEDIA_CONTENT_ERROR_NONE) {
300 GList **list = (GList**)user_data;
301 *list = g_list_append(*list, new_media);
307 bool gallery_bookmarks_cb(media_bookmark_h bookmark, void *user_data)
309 media_bookmark_h new_bm = NULL;
310 int ret = MEDIA_CONTENT_ERROR_NONE;
312 ret = media_bookmark_clone(&new_bm, bookmark);
313 if (ret != MEDIA_CONTENT_ERROR_NONE)
314 content_error("error media_bookmark_clone : [%d]", ret);
316 GList **list = (GList**)user_data;
317 *list = g_list_append(*list, new_bm);
322 bool folder_list_cb(media_folder_h folder, void *user_data)
325 char *folder_id = NULL;
326 media_folder_h *_folder = (media_folder_h*)user_data;
328 content_debug("===========================");
329 if (folder != NULL) {
331 media_folder_clone(_folder, folder);
333 get_folder_meta(folder, &folder_id);
335 if (media_folder_get_media_count_from_db(folder_id, g_filter, &item_count) != MEDIA_CONTENT_ERROR_NONE) {
336 SAFE_FREE(folder_id);
337 content_error("[ERROR] media_folder_get_media_count_from_db is failed");
341 if (media_folder_foreach_media_from_db(folder_id, g_filter, media_item_cb, NULL) != MEDIA_CONTENT_ERROR_NONE) {
342 SAFE_FREE(folder_id);
343 content_error("[ERROR] media_folder_foreach_media_from_db is failed");
347 SAFE_FREE(folder_id);
355 bool playlist_list_cb(media_playlist_h playlist, void *user_data)
357 int ret = MEDIA_CONTENT_ERROR_NONE;
359 char *playlist_name = NULL;
360 media_playlist_h playlist_h;
361 char *playlist_thumbnail_path = NULL;
363 content_debug("playlist_list_cb ======");
365 GList **list = (GList**)user_data;
368 if (playlist == NULL) {
369 content_debug(" playlist handle is NULL");
373 ret = media_playlist_get_playlist_id(playlist, &playlist_id);
374 if (ret != MEDIA_CONTENT_ERROR_NONE)
375 content_error("error media_playlist_get_playlist_id : [%d]", ret);
377 content_debug("playlist_id : %d", playlist_id);
378 /* 64bit build issue */
380 if (user_data != NULL)
381 *list = g_list_append(*list, (gpointer)playlist_id);
383 ret = media_playlist_get_name(playlist, &playlist_name);
384 if (ret != MEDIA_CONTENT_ERROR_NONE)
385 content_error("error media_playlist_get_name : [%d]", ret);
387 content_debug("playlist_name : %s", playlist_name);
388 SAFE_FREE(playlist_name);
390 ret = media_playlist_get_thumbnail_path(playlist, &playlist_thumbnail_path);
391 if (ret != MEDIA_CONTENT_ERROR_NONE)
392 content_error("error media_playlist_get_thumbnail_path : [%d]", ret);
394 content_debug("playlist_thumbnail_path : %s", playlist_thumbnail_path);
395 SAFE_FREE(playlist_thumbnail_path);
397 ret = media_playlist_get_playlist_from_db(playlist_id, &playlist_h);
398 if (ret != MEDIA_CONTENT_ERROR_NONE)
399 content_error("error media_playlist_get_playlist_from_db : [%d]", ret);
401 ret = media_playlist_destroy(playlist_h);
402 if (ret != MEDIA_CONTENT_ERROR_NONE)
403 content_error("error media_playlist_destroy : [%d]", ret);
408 bool bookmarks_cb(media_bookmark_h bookmark, void *user_data)
410 if (bookmark != NULL && user_data != NULL) {
411 media_bookmark_h new_bookmark;
413 media_bookmark_clone(&new_bookmark, bookmark);
414 GList **list = (GList**)user_data;
415 *list = g_list_append(*list, new_bookmark);
418 get_bookmark_meta(bookmark);
423 bool album_list_cb(media_album_h album, void *user_data)
427 int ret = MEDIA_CONTENT_ERROR_NONE;
430 get_album_meta(album);
431 media_album_get_album_id(album, &album_id);
433 ret = media_album_get_media_count_from_db(album_id, NULL, &media_count);
434 if (ret != MEDIA_CONTENT_ERROR_NONE)
435 content_error("error media_album_get_media_count_from_db : [%d]", ret);
437 content_debug("media_count : [%d]", media_count);
439 ret = media_album_foreach_media_from_db(album_id, NULL, media_item_cb, NULL);
440 if (ret != MEDIA_CONTENT_ERROR_NONE) {
441 content_error("error media_album_foreach_media_from_db : [%d]", ret);
446 content_error("album item not Found!!");
452 bool group_list_cb(const char *group_name, void *user_data)
455 int *idx = user_data;
457 content_debug("group item : [%s] [%d]", group_name, *idx);
459 if (media_group_get_media_count_from_db(group_name, *idx, g_filter, &media_count) != MEDIA_CONTENT_ERROR_NONE)
462 content_debug("media_count : [%d]", media_count);
464 if (media_group_foreach_media_from_db(group_name, *idx, g_filter, media_item_cb, NULL) != MEDIA_CONTENT_ERROR_NONE)
470 bool playlist_item_cb(int playlist_member_id, media_info_h media, void *user_data)
472 content_debug("playlist_member_id : [%d]", playlist_member_id);
473 /* 64bit build issue */
475 GList **list = (GList**)user_data;
477 *list = g_list_append(*list, (gpointer)playlist_member_id);
479 /*media_item_cb(media, user_data);*/
484 int test_filter_create(void)
486 content_debug("\n============Filter Create============\n\n");
488 int ret = MEDIA_CONTENT_ERROR_NONE;
490 /* Filter for media */
491 const char *condition = "MEDIA_TYPE=3"; /*MEDIA_TYPE 0-image, 1-video, 2-sound, 3-music, 4-other*/
493 ret = media_filter_create(&g_filter);
495 /* Set condition and collate
496 * Condition string : You can make where statement of sql.
497 * Colation : You can use collation when comparing.
498 * Ex) In case of FILE_NAME='Samsung' as condition string,
499 * if you want to compare with NOCASE collation,
500 * call media_filter_set_condition(g_filter, condition, MEDIA_CONTENT_COLLATE_NOCASE);
501 * if you want to compare in case-sensitive,
502 * call media_filter_set_condition(g_filter, condition, MEDIA_CONTENT_COLLATE_DEFAULT);
504 ret = media_filter_set_condition(g_filter, condition, MEDIA_CONTENT_COLLATE_DEFAULT);
509 int test_filter_destroy(void)
511 content_debug("\n============Filter Create============\n\n");
513 int ret = MEDIA_CONTENT_ERROR_NONE;
515 ret = media_filter_destroy(g_filter);
520 int test_connect_database(void)
522 int ret = MEDIA_CONTENT_ERROR_NONE;
524 content_debug("\n============DB Connection Test============\n\n");
526 ret = media_content_connect();
528 if (ret == MEDIA_CONTENT_ERROR_NONE)
529 content_debug("connection is success\n\n");
531 content_error("connection is failed\n\n");
536 int test_gallery_scenario(void)
538 int ret = MEDIA_CONTENT_ERROR_NONE;
540 filter_h filter = NULL;
543 GList *folder_list = NULL;
544 media_folder_h folder_handle = NULL;
546 /* First, Get folder list */
547 ret = media_folder_foreach_folder_from_db(filter, gallery_folder_list_cb, &folder_list);
548 if (ret != MEDIA_CONTENT_ERROR_NONE) {
549 content_error("media_folder_foreach_folder_from_db failed: %d", ret);
552 content_debug("media_folder_foreach_folder_from_db success!!");
553 char *folder_id = NULL;
555 for (i = 0; i < g_list_length(folder_list); i++) {
556 folder_handle = (media_folder_h)g_list_nth_data(folder_list, i);
558 get_folder_meta(folder_handle, &folder_id);
560 ret = media_folder_get_media_count_from_db(folder_id, filter, &count);
561 SAFE_FREE(folder_id);
562 if (ret != MEDIA_CONTENT_ERROR_NONE) {
563 content_error("media_folder_get_media_count_from_db failed: %d", ret);
566 content_debug("media count [%d] : %d", i, count);
571 /* To check performance */
572 struct timeval start, end;
573 gettimeofday(&start, NULL);
575 /* Second, Get all item list */
576 media_info_h media_handle = NULL;
577 GList *all_item_list = NULL;
579 media_content_collation_e collate_type = MEDIA_CONTENT_COLLATE_NOCASE;
580 media_content_order_e order_type = MEDIA_CONTENT_ORDER_DESC;
581 ret = media_filter_create(&filter);
582 if (ret != MEDIA_CONTENT_ERROR_NONE) {
583 content_error("Fail to create filter");
586 ret = media_filter_set_condition(filter, "MEDIA_TYPE = 0", collate_type);
587 if (ret != MEDIA_CONTENT_ERROR_NONE) {
588 media_filter_destroy(filter);
589 content_error("Fail to set condition");
592 ret = media_filter_set_order(filter, order_type, MEDIA_DISPLAY_NAME, collate_type);
593 if (ret != MEDIA_CONTENT_ERROR_NONE) {
594 media_filter_destroy(filter);
595 content_error("Fail to set order");
599 ret = media_info_foreach_media_from_db(filter, gallery_media_item_cb, &all_item_list);
600 if (ret != MEDIA_CONTENT_ERROR_NONE) {
601 content_error("media_info_foreach_media_from_db failed: %d", ret);
602 media_filter_destroy(filter);
605 content_debug("media_info_foreach_media_from_db success");
607 for (i = 0; i < g_list_length(all_item_list); i++) {
608 media_handle = (media_info_h)g_list_nth_data(all_item_list, i);
609 get_media_meta(media_handle);
613 media_filter_destroy(filter);
616 /* To check performance */
617 gettimeofday(&end, NULL);
618 long time = (end.tv_sec * 1000000 + end.tv_usec) - (start.tv_sec * 1000000 + start.tv_usec);
619 content_debug("Time : %ld\n", time);
621 /* Third, Get item list of a folder */
622 GList *item_list = NULL;
624 for (i = 0; i < g_list_length(folder_list); i++) {
626 char *folder_id = NULL;
627 folder_handle = (media_folder_h)g_list_nth_data(folder_list, i);
629 get_folder_meta(folder_handle, &folder_id);
631 ret = media_folder_foreach_media_from_db(folder_id, filter, gallery_media_item_cb, &item_list);
632 SAFE_FREE(folder_id);
634 if (ret != MEDIA_CONTENT_ERROR_NONE) {
635 content_error("media_folder_foreach_media_from_db failed: %d", ret);
638 content_error("media_folder_foreach_media_from_db success!");
640 for (j = 0; j < g_list_length(item_list); j++) {
641 media_handle = (media_info_h)g_list_nth_data(item_list, j);
642 get_media_meta(media_handle);
647 /* Remove folder list */
649 for (i = 0; i < g_list_length(folder_list); i++) {
650 folder_handle = (media_folder_h)g_list_nth_data(folder_list, i);
651 media_folder_destroy(folder_handle);
654 g_list_free(folder_list);
657 /* Remove all items list */
659 for (i = 0; i < g_list_length(all_item_list); i++) {
660 media_handle = (media_info_h)g_list_nth_data(all_item_list, i);
661 ret = media_info_destroy(media_handle);
662 if (ret != MEDIA_CONTENT_ERROR_NONE)
663 content_error("media_info_destroy failed: %d", ret);
666 g_list_free(all_item_list);
669 /* Remove items list */
671 for (i = 0; i < g_list_length(item_list); i++) {
672 media_handle = (media_info_h)g_list_nth_data(item_list, i);
673 ret = media_info_destroy(media_handle);
674 if (ret != MEDIA_CONTENT_ERROR_NONE)
675 content_error("media_info_destroy failed: %d", ret);
678 g_list_free(item_list);
681 return MEDIA_CONTENT_ERROR_NONE;
684 /*Get All Music file. sort by Title and not case sensitive*/
685 int test_get_all_music_files(void)
687 int ret = MEDIA_CONTENT_ERROR_NONE;
692 const char *condition = "MEDIA_TYPE=3"; /*0-image, 1-video, 2-sound, 3-music, 4-other*/
694 ret = media_filter_create(&filter);
695 if (ret != MEDIA_CONTENT_ERROR_NONE) {
696 content_error("Fail to create filter");
699 ret = media_filter_set_condition(filter, condition, MEDIA_CONTENT_COLLATE_LOCALIZED);
700 if (ret != MEDIA_CONTENT_ERROR_NONE) {
701 media_filter_destroy(filter);
702 content_error("Fail to set condition");
705 ret = media_filter_set_order(filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_TITLE, MEDIA_CONTENT_COLLATE_LOCALIZED);
706 if (ret != MEDIA_CONTENT_ERROR_NONE) {
707 media_filter_destroy(filter);
708 content_error("Fail to set order");
713 ret = media_info_get_media_count_from_db(filter, &media_count);
714 if (ret != MEDIA_CONTENT_ERROR_NONE) {
715 media_filter_destroy(filter);
716 content_error("Fail to get media count");
720 content_debug("media_count : [%d]", media_count);
722 ret = media_info_foreach_media_from_db(filter, media_item_cb, NULL);
723 if (ret != MEDIA_CONTENT_ERROR_NONE) {
724 media_filter_destroy(filter);
725 content_error("Fail to get media");
729 ret = media_filter_destroy(filter);
734 int test_media_info_operation(void)
736 int ret = MEDIA_CONTENT_ERROR_NONE;
739 content_debug("\n============Media info Test============\n\n");
741 test_filter_create();
743 ret = media_info_get_media_count_from_db(g_filter, &media_count);
744 if (ret != MEDIA_CONTENT_ERROR_NONE)
745 content_error("media_info_get_media_count_from_db failed: %d", ret);
747 content_debug("media_count : [%d]", media_count);
749 ret = media_info_foreach_media_from_db(g_filter, media_item_cb, NULL);
750 if (ret == MEDIA_CONTENT_ERROR_NONE)
751 content_debug("media_info_foreach_media_from_db is success");
753 content_error("media_info_foreach_media_from_db is failed");
755 test_filter_destroy();
760 int test_folder_operation(void)
762 int ret = MEDIA_CONTENT_ERROR_NONE;
763 filter_h filter = NULL;
764 media_folder_h folder = NULL;
765 char *folder_id = NULL;
768 content_debug("\n============Folder Test============\n\n");
770 test_filter_create();
772 ret = media_filter_create(&filter);
773 if (ret != MEDIA_CONTENT_ERROR_NONE) {
774 content_error("[ERROR] media_folder_filter_create is failed");
778 media_filter_set_condition(filter, "MEDIA_TYPE = 0 or MEDIA_TYPE = 1", MEDIA_CONTENT_COLLATE_DEFAULT); /*MEDIA_TYPE 0-image, 1-video, 2-sound, 3-music, 4-other*/
779 media_filter_set_offset(filter, 0, 5);
780 media_filter_set_order(filter, MEDIA_CONTENT_ORDER_DESC, MEDIA_PATH, MEDIA_CONTENT_COLLATE_NOCASE);
782 ret = media_folder_get_folder_count_from_db(filter, &count);
783 content_debug("Folder count : [%d]", count);
785 ret = media_folder_foreach_folder_from_db(filter, folder_list_cb, &folder);
787 filter_h m_filter = NULL;
789 ret = media_filter_create(&m_filter);
790 if (ret != MEDIA_CONTENT_ERROR_NONE) {
791 test_filter_destroy();
792 media_filter_destroy(filter);
793 content_error("[ERROR] media_info_filter_create is failed");
797 media_filter_set_condition(m_filter, "MEDIA_TYPE=1", MEDIA_CONTENT_COLLATE_DEFAULT); /*MEDIA_TYPE 0-image, 1-video, 2-sound, 3-music, 4-other*/
798 media_filter_set_offset(m_filter, 0, 5);
799 media_filter_set_order(m_filter, MEDIA_CONTENT_ORDER_DESC, MEDIA_PATH, MEDIA_CONTENT_COLLATE_NOCASE);
801 ret = media_folder_foreach_media_from_db(folder_id, m_filter, media_item_cb, NULL);
802 if (ret != MEDIA_CONTENT_ERROR_NONE)
803 content_error("[ERROR] media_folder_foreach_media_from_db is failed, error code : %d", ret);
805 media_filter_destroy(filter);
806 media_filter_destroy(m_filter);
808 test_filter_destroy();
810 /* fix prevent: Resource Leak */
811 SAFE_FREE(folder_id);
816 int test_playlist_operation(void)
818 int ret = MEDIA_CONTENT_ERROR_NONE;
819 media_playlist_h playlist_1 = NULL;
820 media_playlist_h playlist_2 = NULL;
821 media_playlist_h playlist_3 = NULL;
822 media_playlist_h playlist_4 = NULL;
823 int playlist_id_1 = 0;
824 int playlist_id_2 = 0;
825 int playlist_id_3 = 0;
826 const char *playlist_name_1 = "myPlaylist_1";
827 const char *playlist_name_2 = "myPlaylist_2";
828 const char *playlist_name_3 = "myPlaylist_3";
829 int playlist_count = 0;
836 filter_h filter = NULL;
837 filter_h m_filter = NULL;
839 content_debug("\n============Playlist Test============\n\n");
841 /* Filter for playlist */
843 const char *condition = "(MEDIA_TYPE=1 or MEDIA_TYPE=3)"; /*0-image, 1-video, 2-sound, 3-music, 4-other*/
845 ret = media_filter_create(&filter);
846 ret = media_filter_set_condition(filter, condition, MEDIA_CONTENT_COLLATE_NOCASE);
847 ret = media_filter_set_order(filter, MEDIA_CONTENT_ORDER_ASC, PLAYLIST_NAME, MEDIA_CONTENT_COLLATE_NOCASE);
849 /* Create Playlist */
850 media_playlist_insert_to_db(playlist_name_1, &playlist_1);
851 media_playlist_insert_to_db(playlist_name_2, &playlist_2);
852 media_playlist_insert_to_db(playlist_name_3, &playlist_3);
854 if (playlist_1 != NULL) {
855 /* Add media to Playlist */
856 media_playlist_add_media(playlist_1, test_audio_id);
857 media_playlist_add_media(playlist_1, test_audio_id);
858 media_playlist_add_media(playlist_1, test_video_id);
861 char *playlist_thumb_path = tzplatform_mkpath(TZ_USER_IMAGES, "Default.jpg"));
862 media_playlist_set_thumbnail_path(playlist_1, playlist_thumb_path);
865 media_playlist_update_to_db(playlist_1);
868 if (playlist_2 != NULL) {
869 media_playlist_add_media(playlist_2, test_audio_id);
870 media_playlist_add_media(playlist_2, test_audio_id);
871 media_playlist_update_to_db(playlist_2);
874 /* Get Playlist Count*/
875 ret = media_playlist_get_playlist_count_from_db(filter, &playlist_count);
877 content_debug("playlist_count [%d]", playlist_count);
880 GList *playlist_id_list = NULL;
881 media_playlist_foreach_playlist_from_db(filter, playlist_list_cb, &playlist_id_list);
882 /* 64bit build issue */
885 playlist_id_1 = (int)g_list_nth_data(playlist_id_list, 0);
886 playlist_id_2 = (int)g_list_nth_data(playlist_id_list, 1);
887 playlist_id_3 = (int)g_list_nth_data(playlist_id_list, 2);
889 content_debug("playlist_id_1 [%d]", playlist_id_1);
890 content_debug("playlist_id_2 [%d]", playlist_id_2);
891 content_debug("playlist_id_3 [%d]", playlist_id_3);
893 /* Export and import playlist */
894 media_playlist_export_to_file(playlist_3, tzplatform_mkpath(TZ_USER_MUSIC, "playlist.m3u"));
895 media_playlist_import_from_file(tzplatform_mkpath(TZ_USER_MUSIC, "playlist.m3u"), "playlist_4", &playlist_4);
897 /* Filter for media*/
898 ret = media_filter_create(&m_filter);
900 ret = media_filter_set_condition(m_filter, condition, MEDIA_CONTENT_COLLATE_DEFAULT);
902 ret = media_filter_set_order(m_filter, MEDIA_CONTENT_ORDER_ASC, PLAYLIST_MEMBER_ORDER, MEDIA_CONTENT_COLLATE_DEFAULT);
904 /* Get media count */
905 media_playlist_get_media_count_from_db(playlist_id_1, m_filter, &media_count);
906 content_debug("playlist_1_media_count [%d]", media_count);
908 media_playlist_get_media_count_from_db(playlist_id_2, m_filter, &media_count);
909 content_debug("playlist_2_media_count [%d]", media_count);
911 media_playlist_get_media_count_from_db(playlist_id_3, m_filter, &media_count);
912 content_debug("playlist_3_media_count [%d]", media_count);
914 /* Get media of playlist */
915 GList *playlist_member_id_list = NULL;
916 GList *playlist_member_id_list_1 = NULL;
918 media_playlist_foreach_media_from_db(playlist_id_1, m_filter, playlist_item_cb, &playlist_member_id_list);
919 media_playlist_foreach_media_from_db(playlist_id_2, m_filter, playlist_item_cb, &playlist_member_id_list_1);
921 int playlist_member_id_1_1 = 0;
922 int playlist_member_id_1_2 = 0;
923 int playlist_member_id_1_3 = 0;
924 int playlist_member_id_2_1 = 0;
925 int playlist_member_id_2_2 = 0;
926 /* 64bit build issue */
928 playlist_member_id_1_1 = (int)g_list_nth_data(playlist_member_id_list, 0);
929 playlist_member_id_1_2 = (int)g_list_nth_data(playlist_member_id_list, 1);
930 playlist_member_id_1_3 = (int)g_list_nth_data(playlist_member_id_list, 2);
931 playlist_member_id_2_1 = (int)g_list_nth_data(playlist_member_id_list_1, 0);
932 playlist_member_id_2_2 = (int)g_list_nth_data(playlist_member_id_list_1, 1);
934 content_debug("playlist_member_id_1_1 [%d]", playlist_member_id_1_1);
935 content_debug("playlist_member_id_1_2 [%d]", playlist_member_id_1_2);
936 content_debug("playlist_member_id_1_3 [%d]", playlist_member_id_1_3);
937 content_debug("playlist_member_id_2_1 [%d]", playlist_member_id_2_1);
938 content_debug("playlist_member_id_2_2 [%d]", playlist_member_id_2_2);
940 media_playlist_get_play_order(playlist_1, playlist_member_id_1_1, &order_1);
941 media_playlist_get_play_order(playlist_1, playlist_member_id_1_2, &order_2);
942 media_playlist_get_play_order(playlist_1, playlist_member_id_1_3, &order_3);
943 media_playlist_get_play_order(playlist_2, playlist_member_id_2_1, &order_4);
944 media_playlist_get_play_order(playlist_2, playlist_member_id_2_2, &order_5);
945 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);
947 /* Update Playlist */
948 media_playlist_remove_media(playlist_2, playlist_member_id_2_1);
949 media_playlist_add_media(playlist_2, test_video_id);
950 media_playlist_set_name(playlist_2, "test_playlist");
951 media_playlist_set_play_order(playlist_2, playlist_member_id_2_2, order_5+100);
952 media_playlist_update_to_db(playlist_2);
954 /* Get Updated Playlist*/
955 media_playlist_foreach_playlist_from_db(filter, playlist_list_cb, NULL);
957 /* deletes the playlist */
959 media_playlist_delete_from_db(playlist_id_1);
960 media_playlist_delete_from_db(playlist_id_2);
963 if (playlist_1 != NULL)
964 media_playlist_destroy(playlist_1);
965 if (playlist_2 != NULL)
966 media_playlist_destroy(playlist_2);
967 if (playlist_3 != NULL)
968 media_playlist_destroy(playlist_3);
969 if (playlist_4 != NULL)
970 media_playlist_destroy(playlist_4);
972 g_list_free(playlist_id_list);
973 g_list_free(playlist_member_id_list);
974 g_list_free(playlist_member_id_list_1);
977 ret = media_filter_destroy(filter);
978 if (m_filter != NULL)
979 ret = media_filter_destroy(m_filter);
984 int test_playlist_operation_v2(void)
986 int ret = MEDIA_CONTENT_ERROR_NONE;
987 media_playlist_h playlist_1 = NULL;
988 const char *playlist_name_1 = "myPlaylist_1";
989 const char *playlist_thumb_path = tzplatform_mkpath(TZ_USER_IMAGES, "Default.jpg");
992 content_debug("\n============Playlist Test V2============\n\n");
994 ret = media_playlist_create(&playlist_1);
995 if (ret != MEDIA_CONTENT_ERROR_NONE)
996 content_error("error media_playlist_create : [%d]", ret);
998 ret = media_playlist_set_name(playlist_1, playlist_name_1);
999 if (ret != MEDIA_CONTENT_ERROR_NONE)
1000 content_error("error media_playlist_set_name : [%d]", ret);
1002 ret = media_playlist_set_thumbnail_path(playlist_1, playlist_thumb_path);
1003 if (ret != MEDIA_CONTENT_ERROR_NONE)
1004 content_error("error media_playlist_set_thumbnail_path : [%d]", ret);
1006 ret = media_playlist_insert_to_db_v2(playlist_1);
1007 if (ret != MEDIA_CONTENT_ERROR_NONE)
1008 content_error("error media_playlist_insert_to_db_v2 : [%d]", ret);
1010 ret = media_playlist_set_name(playlist_1, "myPlaylist_3");
1011 if (ret != MEDIA_CONTENT_ERROR_NONE)
1012 content_error("error media_playlist_set_name : [%d]", ret);
1014 ret = media_playlist_get_playlist_id(playlist_1, &playlist_id);
1015 if (ret != MEDIA_CONTENT_ERROR_NONE)
1016 content_error("error media_playlist_get_playlist_id : [%d]", ret);
1018 ret = media_playlist_update_to_db_v2(playlist_id, playlist_1);
1019 if (ret != MEDIA_CONTENT_ERROR_NONE)
1020 content_error("error media_playlist_update_to_db_v2 : [%d]", ret);
1022 ret = media_playlist_destroy(playlist_1);
1023 if (ret != MEDIA_CONTENT_ERROR_NONE)
1024 content_error("error media_playlist_destroy : [%d]", ret);
1029 static void __bookmark_handle_free(gpointer data)
1031 media_bookmark_h handle = (media_bookmark_h) data;
1032 media_bookmark_destroy(handle);
1035 int test_bookmark_operation(void)
1037 /* bookmark is only supported for video information. */
1038 int ret = MEDIA_CONTENT_ERROR_NONE;
1039 int bookmark_count = 0;
1041 GList *all_item_list = NULL;
1044 content_debug("\n============Bookmark Test============\n\n");
1046 const char *g_condition = "BOOKMARK_MARKED_TIME > 300";
1048 ret = media_filter_create(&filter);
1049 if (ret != MEDIA_CONTENT_ERROR_NONE)
1050 content_error("error media_filter_create : [%d]", ret);
1052 ret = media_filter_set_condition(filter, g_condition, MEDIA_CONTENT_COLLATE_DEFAULT);
1053 if (ret != MEDIA_CONTENT_ERROR_NONE)
1054 content_error("error media_filter_set_condition : [%d]", ret);
1056 ret = media_filter_set_order(filter, MEDIA_CONTENT_ORDER_DESC, BOOKMARK_MARKED_TIME, MEDIA_CONTENT_COLLATE_DEFAULT);
1057 if (ret != MEDIA_CONTENT_ERROR_NONE)
1058 content_error("error media_filter_set_order : [%d]", ret);
1060 /* insert bookmark to video */
1061 const char *thumbnail_path1 = tzplatform_mkpath(TZ_USER_VIDEOS, "teat11.jpg");
1062 ret = media_bookmark_insert_to_db(test_video_id, 400, thumbnail_path1);
1063 if (ret != MEDIA_CONTENT_ERROR_NONE)
1064 content_error("error media_bookmark_insert_to_db : [%d]", ret);
1066 ret = media_bookmark_insert_to_db(test_video_id, 600, thumbnail_path1);
1067 if (ret != MEDIA_CONTENT_ERROR_NONE)
1068 content_error("error media_bookmark_insert_to_db : [%d]", ret);
1070 ret = media_bookmark_get_bookmark_count_from_db(filter, &bookmark_count);
1071 if (ret != MEDIA_CONTENT_ERROR_NONE)
1072 content_error("error media_bookmark_get_bookmark_count_from_db : [%d]", ret);
1074 content_debug("bookmark_count = [%d]", bookmark_count);
1076 ret = media_info_foreach_bookmark_from_db(test_video_id, NULL, bookmarks_cb, &all_item_list);
1077 if (ret != MEDIA_CONTENT_ERROR_NONE)
1078 content_error("error media_info_foreach_bookmark_from_db : [%d]", ret);
1080 for (idx = 0; idx < g_list_length(all_item_list); idx++) {
1081 media_bookmark_h bookmark_handle;
1082 bookmark_handle = (media_bookmark_h)g_list_nth_data(all_item_list, idx);
1084 ret = media_bookmark_set_name(bookmark_handle, "test 1");
1085 if (ret != MEDIA_CONTENT_ERROR_NONE)
1086 content_error("error media_bookmark_set_name : [%d]", ret);
1088 ret = media_bookmark_update_to_db(bookmark_handle);
1089 if (ret != MEDIA_CONTENT_ERROR_NONE)
1090 content_error("error media_bookmark_update_to_db : [%d]", ret);
1094 g_list_free_full(all_item_list, __bookmark_handle_free);
1096 ret = media_info_foreach_bookmark_from_db(test_video_id, NULL, bookmarks_cb, NULL);
1097 if (ret != MEDIA_CONTENT_ERROR_NONE)
1098 content_error("error media_info_foreach_bookmark_from_db : [%d]", ret);
1100 ret = media_filter_destroy(filter);
1101 if (ret != MEDIA_CONTENT_ERROR_NONE)
1102 content_error("error media_filter_destroy : [%d]", ret);
1107 int test_bookmark_operation_v2(void)
1109 content_debug("\n============Bookmark Test V2============\n\n");
1111 int ret = MEDIA_CONTENT_ERROR_NONE;
1112 media_bookmark_h bookmark = NULL;
1113 const char *thumbnail_path1 = tzplatform_mkpath(TZ_USER_VIDEOS, "teat11.jpg");
1115 ret = media_bookmark_create(test_video_id, 400, &bookmark);
1116 if (ret != MEDIA_CONTENT_ERROR_NONE)
1117 content_error("error media_bookmark_create : [%d]", ret);
1119 ret = media_bookmark_set_name(bookmark, "test bookmark");
1120 if (ret != MEDIA_CONTENT_ERROR_NONE)
1121 content_error("error media_bookmark_set_name : [%d]", ret);
1123 ret = media_bookmark_set_thumbnail_path(bookmark, thumbnail_path1);
1124 if (ret != MEDIA_CONTENT_ERROR_NONE)
1125 content_error("error media_bookmark_set_thumbnail_path : [%d]", ret);
1127 ret = media_bookmark_insert_to_db_v2(bookmark);
1128 if (ret != MEDIA_CONTENT_ERROR_NONE)
1129 content_error("error media_bookmark_insert_to_db_v2 : [%d]", ret);
1131 ret = media_bookmark_set_name(bookmark, "test bookmark 2");
1132 if (ret != MEDIA_CONTENT_ERROR_NONE)
1133 content_error("error media_bookmark_set_name : [%d]", ret);
1135 ret = media_bookmark_update_to_db(bookmark);
1136 if (ret != MEDIA_CONTENT_ERROR_NONE)
1137 content_error("error media_bookmark_update_to_db : [%d]", ret);
1139 ret = media_bookmark_destroy(bookmark);
1140 if (ret != MEDIA_CONTENT_ERROR_NONE)
1141 content_error("error media_bookmark_destroy : [%d]", ret);
1146 int test_album_list(void)
1148 content_debug("\n============Album Test============\n\n");
1150 int ret = MEDIA_CONTENT_ERROR_NONE;
1151 int album_count = 0;
1155 const char *condition = "MEDIA_TYPE=3"; /*0-image, 1-video, 2-sound, 3-music, 4-other*/
1157 ret = media_filter_create(&filter);
1158 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1159 content_error("Fail to create filter");
1162 ret = media_filter_set_condition(filter, condition, MEDIA_CONTENT_COLLATE_DEFAULT);
1163 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1164 media_filter_destroy(filter);
1165 content_error("Fail to set condition");
1168 ret = media_filter_set_order(filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_ALBUM, MEDIA_CONTENT_COLLATE_NOCASE);
1169 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1170 media_filter_destroy(filter);
1171 content_error("Fail to set order");
1175 ret = media_album_get_album_count_from_db(filter, &album_count);
1176 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1177 media_filter_destroy(filter);
1180 content_debug("album_count [%d]", album_count);
1183 ret = media_album_foreach_album_from_db(filter, album_list_cb, NULL);
1184 if (ret != MEDIA_CONTENT_ERROR_NONE)
1185 content_error("error media_album_foreach_album_from_db : [%d]", ret);
1187 ret = media_filter_destroy(filter);
1188 if (ret != MEDIA_CONTENT_ERROR_NONE)
1189 content_error("error media_filter_destroy : [%d]", ret);
1194 int test_group_operation(void)
1196 content_debug("\n============Group Test============\n\n");
1198 int ret = MEDIA_CONTENT_ERROR_NONE;
1199 int group_count = 0;
1202 ret = test_filter_create();
1203 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1204 content_error("[error(0x%08x)", ret);
1208 for (idx = 0; idx < MEDIA_CONTENT_GROUP_MAX; idx++) {
1209 ret = media_group_get_group_count_from_db(g_filter, idx, &group_count);
1210 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1211 test_filter_destroy();
1212 content_error("media_group_get_group_count_from_db fail. ret=[%d] idx=[%d]", ret, idx);
1215 content_debug("[%2d]group_count [%d]", idx, group_count);
1218 ret = media_group_foreach_group_from_db(g_filter, idx, group_list_cb, &idx);
1219 if (ret != MEDIA_CONTENT_ERROR_NONE)
1220 content_error("media_group_foreach_group_from_db failed: %d", ret);
1222 ret = test_filter_destroy();
1227 int test_update_operation()
1229 int ret = MEDIA_CONTENT_ERROR_NONE;
1231 media_info_h media_handle = NULL;
1232 GList *all_item_list = NULL;
1234 /* Get all item list */
1235 ret = media_info_foreach_media_from_db(NULL, gallery_media_item_cb, &all_item_list);
1236 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1237 content_error("media_info_foreach_media_from_db failed: %d", ret);
1240 content_debug("media_info_foreach_media_from_db success");
1242 for (i = 0; i < g_list_length(all_item_list); i++) {
1243 media_handle = (media_info_h)g_list_nth_data(all_item_list, i);
1244 get_media_meta(media_handle);
1248 return MEDIA_CONTENT_ERROR_NONE;
1251 int test_insert(void)
1253 int ret = MEDIA_CONTENT_ERROR_NONE;
1254 const char *path = tzplatform_mkpath(TZ_USER_IMAGES, "Default.jpg");
1256 const char *path = tzplatform_mkpath(TZ_USER_DOCUMENTS, "other.txt"));
1259 media_info_h media_item = NULL;
1260 content_debug("\n============DB Insert Test============\n\n");
1262 ret = media_info_insert_to_db(path, &media_item);
1264 if ((ret == MEDIA_CONTENT_ERROR_NONE) && (media_item != NULL)) {
1265 content_debug("Insertion is success");
1267 content_error("Insertion is failed");
1268 ret = media_info_destroy(media_item);
1272 char *media_id = NULL;
1274 ret = media_info_get_media_id(media_item, &media_id);
1275 if (ret != MEDIA_CONTENT_ERROR_NONE)
1276 content_error("media_info_get_media_id failed: %d", ret);
1278 content_debug("Media ID: %s", media_id);
1280 SAFE_FREE(media_id);
1282 ret = media_info_destroy(media_item);
1283 if (ret != MEDIA_CONTENT_ERROR_NONE)
1284 content_error("media_info_destroy failed: %d", ret);
1291 int ret = MEDIA_CONTENT_ERROR_NONE;
1292 const char *move_media_id = "60aea677-4742-408e-b5f7-f2628062d06d";
1293 const char *dst_path = tzplatform_mkpath(TZ_USER_IMAGES, "XX/Default1.jpg");
1294 media_info_h move_media = NULL;
1296 ret = media_info_get_media_from_db(move_media_id, &move_media);
1297 if (ret == MEDIA_CONTENT_ERROR_NONE)
1298 content_debug("media_info_get_media_from_db success");
1300 content_error("media_info_get_media_from_db failed: %d", ret);
1302 content_debug("\n============DB Move Test============\n\n");
1305 ret = media_info_move_to_db(move_media, dst_path);
1307 if (ret == MEDIA_CONTENT_ERROR_NONE)
1308 content_debug("Move is success");
1310 content_error("Move is failed");
1312 ret = media_info_destroy(move_media);
1314 content_debug("There is no item : %s", move_media_id);
1320 int test_create_thumbnail(const char *path)
1322 int ret = MEDIA_CONTENT_ERROR_NONE;
1324 char *thumb_path = NULL;
1326 ret = media_info_insert_to_db(path, &media);
1327 content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "media_info_insert_to_db failed [%d]", ret);
1329 ret = media_info_generate_thumbnail(media);
1330 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1331 content_error("media_info_generate_thumbnail failed [%d]", ret);
1335 ret = media_info_get_thumbnail_path(media, &thumb_path);
1336 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1337 content_error("media_info_get_thumbnail_path failed [%d]", ret);
1341 content_debug("Thumbnail Path [%s]", thumb_path);
1346 media_info_destroy(media);
1350 int test_ebook_text_finder(const char *keyword)
1352 int ret = MEDIA_CONTENT_ERROR_NONE;
1353 char **book_path_list = NULL;
1354 unsigned int book_path_len = 0;
1356 media_info_h media = NULL;
1357 book_meta_h book = NULL;
1358 char *s_value = NULL;
1359 long long ms_time = 0;
1360 struct timeval start_time;
1361 struct timeval end_time;
1363 gettimeofday(&start_time, NULL);
1365 ret = book_meta_get_path_with_keyword(keyword, &book_path_list, &book_path_len);
1366 if (ret == MEDIA_CONTENT_ERROR_NONE)
1367 content_debug("book_meta_get_path_with_keyword is success");
1369 content_error("book_meta_get_path_with_keyword is failed");
1371 gettimeofday(&end_time, NULL);
1373 for (i = 0; i < book_path_len; i++) {
1374 ret = media_info_get_media_from_db_by_path(book_path_list[i], &media);
1375 if (ret != MEDIA_CONTENT_ERROR_NONE)
1378 content_debug("===============================");
1379 content_debug("[%d] %s", i, book_path_list[i]);
1380 content_debug("===============================");
1381 media_info_get_title(media, &s_value);
1382 content_debug("Title : %s", s_value);
1386 ret = media_info_get_book(media, &book);
1387 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1388 media_info_destroy(media);
1392 ret = book_meta_get_author(book, &s_value);
1393 if (ret == MEDIA_CONTENT_ERROR_NONE && s_value) {
1394 content_debug("Author : %s", s_value);
1399 ret = book_meta_get_date(book, &s_value);
1400 if (ret == MEDIA_CONTENT_ERROR_NONE && s_value) {
1401 content_debug("Date : %s", s_value);
1406 content_debug("===============================");
1407 ret = book_meta_destroy(book);
1408 if (ret != MEDIA_CONTENT_ERROR_NONE)
1409 content_error("book_meta_destroy failed");
1411 ret = media_info_destroy(media);
1412 if (ret != MEDIA_CONTENT_ERROR_NONE)
1413 content_error("media_info_destroy failed");
1415 g_free(book_path_list[i]);
1418 ms_time = (end_time.tv_sec * 1000LL + end_time.tv_usec / 1000) - (start_time.tv_sec * 1000LL + start_time.tv_usec/ 1000);
1419 content_debug("Search Time [%lld]", ms_time);
1421 g_free(book_path_list);
1425 int test_disconnect_database(void)
1427 int ret = MEDIA_CONTENT_ERROR_NONE;
1428 content_debug("\n============DB Disconnection Test============\n\n");
1430 ret = media_content_disconnect();
1432 if (ret == MEDIA_CONTENT_ERROR_NONE)
1433 content_debug("disconnection is success");
1435 content_error("disconnection is failed");
1440 static int g_total_photo_size = 0;
1441 static int g_total_video_size = 0;
1442 static int g_total_mp3_size = 0;
1443 static int g_total_voice_memo_size = 0;
1445 bool dft_cb(media_info_h media, void *user_data)
1447 unsigned long long file_size = 0;
1448 media_content_type_e media_type = -1;
1449 char *mime_type = NULL;
1450 int ret = MEDIA_CONTENT_ERROR_NONE;
1455 ret = media_info_get_media_type(media, &media_type);
1456 if (ret != MEDIA_CONTENT_ERROR_NONE)
1457 content_error("media_info_get_media_type failed: %d", ret);
1458 ret = media_info_get_size(media, &file_size);
1459 if (ret != MEDIA_CONTENT_ERROR_NONE)
1460 content_error("media_info_get_size failed: %d", ret);
1461 ret = media_info_get_mime_type(media, &mime_type);
1462 if (ret != MEDIA_CONTENT_ERROR_NONE)
1463 content_error("media_info_get_mime_type failed: %d", ret);
1465 if (media_type == MEDIA_CONTENT_TYPE_IMAGE)
1466 g_total_photo_size += file_size;
1467 else if (media_type == MEDIA_CONTENT_TYPE_VIDEO)
1468 g_total_video_size += file_size;
1469 else if (media_type == MEDIA_CONTENT_TYPE_SOUND)
1470 g_total_voice_memo_size += file_size;
1471 else if (media_type == MEDIA_CONTENT_TYPE_MUSIC) {
1472 if ((mime_type != NULL) && (!strcmp("audio/mpeg", mime_type)))
1473 g_total_mp3_size += file_size;
1475 g_total_voice_memo_size += file_size;
1477 content_debug("invalid media_type");
1479 SAFE_FREE(mime_type);
1487 int ret = MEDIA_CONTENT_ERROR_NONE;
1488 content_debug("\n============DFT_test============\n\n");
1490 filter_h filter = NULL;
1493 /*MEDIA_TYPE 0-image, 1-video, 2-sound, 3-music, 4-other*/
1495 ret = media_filter_create(&filter);
1498 content_debug("[Internal Memory]\n");
1499 /*1. Photo ============================================================*/
1500 ret = media_filter_set_condition(filter, "MEDIA_TYPE=0", MEDIA_CONTENT_COLLATE_DEFAULT);
1503 ret = media_info_get_media_count_from_db(filter, &media_cnt);
1504 content_debug("Photo count = [%d]\n", media_cnt);
1507 ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
1508 content_debug("Photo size = [%d]\n", g_total_photo_size);
1510 /*2. Video ============================================================*/
1511 ret = media_filter_set_condition(filter, "MEDIA_TYPE=1", MEDIA_CONTENT_COLLATE_DEFAULT);
1514 ret = media_info_get_media_count_from_db(filter, &media_cnt);
1515 content_debug("Video count = [%d]\n", media_cnt);
1518 ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
1519 content_debug("Video size = [%d]\n", g_total_video_size);
1521 /*3. MP3 ============================================================*/
1522 ret = media_filter_set_condition(filter, "MEDIA_TYPE=3 AND MEDIA_MIME_TYPE=\"audio/mpeg\"", MEDIA_CONTENT_COLLATE_DEFAULT);
1525 ret = media_info_get_media_count_from_db(filter, &media_cnt);
1526 content_debug("MP3 count = [%d]\n", media_cnt);
1529 ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
1530 content_debug("MP3 size = [%d]\n", g_total_mp3_size);
1532 /*4. Voice Memo ============================================================*/
1533 ret = media_filter_set_condition(filter, "(MEDIA_MIME_TYPE=\"audio/AMR\" OR MEDIA_MIME_TYPE=\"audio/mp4\")", MEDIA_CONTENT_COLLATE_DEFAULT);
1535 /*Get Voice Memo Count*/
1536 ret = media_info_get_media_count_from_db(filter, &media_cnt);
1537 content_debug("Voice Memo count = [%d]\n", media_cnt);
1539 /*Get Voice Memo Size*/
1540 ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
1541 content_debug("Voice Memo size = [%d]\n", g_total_voice_memo_size);
1543 g_total_photo_size = 0;
1544 g_total_video_size = 0;
1545 g_total_mp3_size = 0;
1546 g_total_voice_memo_size = 0;
1549 content_debug("\n[External Memory]\n");
1550 /*1. Photo ============================================================*/
1551 ret = media_filter_set_condition(filter, "MEDIA_TYPE=0", MEDIA_CONTENT_COLLATE_DEFAULT);
1554 ret = media_info_get_media_count_from_db(filter, &media_cnt);
1555 content_debug("Photo count = [%d]\n", media_cnt);
1558 ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
1559 content_debug("Photo size = [%d]\n", g_total_photo_size);
1561 /*2. Video ============================================================*/
1562 ret = media_filter_set_condition(filter, "MEDIA_TYPE=1", MEDIA_CONTENT_COLLATE_DEFAULT);
1565 ret = media_info_get_media_count_from_db(filter, &media_cnt);
1566 content_debug("Video count = [%d]\n", media_cnt);
1569 ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
1570 content_debug("Video size = [%d]\n", g_total_video_size);
1572 /*3. MP3 ============================================================*/
1573 ret = media_filter_set_condition(filter, "MEDIA_TYPE=3 AND MEDIA_MIME_TYPE=\"audio/mpeg\"", MEDIA_CONTENT_COLLATE_DEFAULT);
1576 ret = media_info_get_media_count_from_db(filter, &media_cnt);
1577 content_debug("MP3 count = [%d]\n", media_cnt);
1580 ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
1581 content_debug("MP3 size = [%d]\n", g_total_mp3_size);
1583 /*4. Voice Memo ============================================================*/
1584 ret = media_filter_set_condition(filter, "(MEDIA_MIME_TYPE=\"audio/AMR\" OR MEDIA_MIME_TYPE=\"audio/mp4\")", MEDIA_CONTENT_COLLATE_DEFAULT);
1586 /*Get Voice Memo Count*/
1587 ret = media_info_get_media_count_from_db(filter, &media_cnt);
1588 content_debug("Voice Memo count = [%d]\n", media_cnt);
1590 /*Get Voice Memo Size*/
1591 ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
1592 content_debug("Voice Memo size = [%d]\n", g_total_voice_memo_size);
1593 ret = media_filter_destroy(filter);
1598 void insert_batch_cb(media_content_error_e error, void * user_data)
1600 content_debug("media_info_insert_batch_to_db completed!\n");
1603 int test_batch_operations()
1607 char *file_list[10];
1609 for (i = 0; i < 10; i++) {
1610 file_list[i] = g_strdup_printf("%s%d.jpg", tzplatform_mkpath(TZ_USER_CONTENT, "test/image"), i+1);
1611 content_debug("File : %s\n", file_list[i]);
1614 ret = media_info_insert_batch_to_db((const char **)file_list, 10, insert_batch_cb, NULL);
1615 if (ret != MEDIA_CONTENT_ERROR_NONE)
1616 content_error("media_info_insert_batch_to_db failed : %d\n", ret);
1618 for (i = 0; i < 10; i++)
1619 g_free(file_list[i]);
1624 void _scan_cb(media_content_error_e err, void *user_data)
1626 content_debug("scan callback is called : %d\n", err);
1627 g_main_loop_quit(g_loop);
1632 int test_scan_file()
1636 const char *file_path = tzplatform_mkpath(TZ_USER_CONTENT, "test/image1.jpg");
1637 ret = media_content_scan_file(file_path);
1638 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1639 content_error("Fail to media_content_scan_file : %d", ret);
1646 gboolean test_scan_dir_start(gpointer data)
1650 const char *dir_path = tzplatform_getenv(TZ_USER_CONTENT);
1652 ret = media_content_scan_folder(dir_path, TRUE, _scan_cb, NULL);
1654 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1655 content_error("Fail to test_scan_dir_start : %d", ret);
1662 gboolean cancel_scan_dir_start(gpointer data)
1664 int ret = MEDIA_CONTENT_ERROR_NONE;
1666 const char *dir_path = tzplatform_getenv(TZ_USER_IMAGES);
1668 ret = media_content_cancel_scan_folder(dir_path);
1670 if (ret == MEDIA_CONTENT_ERROR_NONE)
1671 content_debug("media_content_cancel_scan_folder is success");
1673 content_error("media_content_cancel_scan_folder is failed");
1678 int test_scan_dir(int cancel)
1680 GSource *source = NULL;
1681 GMainContext *context = NULL;
1683 g_loop = g_main_loop_new(NULL, FALSE);
1684 context = g_main_loop_get_context(g_loop);
1685 source = g_idle_source_new();
1686 g_source_set_callback(source, test_scan_dir_start, NULL, NULL);
1687 g_source_attach(source, context);
1690 GSource *cancel_src = NULL;
1691 cancel_src = g_idle_source_new();
1692 g_source_set_callback(cancel_src, cancel_scan_dir_start, NULL, NULL);
1693 g_source_attach(cancel_src, context);
1696 g_main_loop_run(g_loop);
1697 g_main_loop_unref(g_loop);
1702 void _noti_cb(media_content_error_e error,
1704 media_content_db_update_item_type_e update_item,
1705 media_content_db_update_type_e update_type,
1706 media_content_type_e media_type,
1713 content_debug("noti success! : %d\n", error);
1715 content_debug("error occurred! : %d\n", error);
1717 content_debug("Noti from PID(%d)\n", pid);
1719 if (update_item == MEDIA_ITEM_FILE)
1720 content_debug("Noti item : MEDIA_ITEM_FILE\n");
1721 else if (update_item == MEDIA_ITEM_DIRECTORY)
1722 content_debug("Noti item : MEDIA_ITEM_DIRECTORY\n");
1724 if (update_type == MEDIA_CONTENT_INSERT)
1725 content_debug("Noti type : MEDIA_CONTENT_INSERT\n");
1726 else if (update_type == MEDIA_CONTENT_DELETE)
1727 content_debug("Noti type : MEDIA_CONTENT_DELETE\n");
1728 else if (update_type == MEDIA_CONTENT_UPDATE)
1729 content_debug("Noti type : MEDIA_CONTENT_UPDATE\n");
1731 content_debug("content type : %d\n", media_type);
1734 content_debug("path : %s\n", path);
1736 content_debug("path not\n");
1739 content_debug("uuid : %s\n", uuid);
1741 content_debug("uuid not\n");
1744 content_debug("mime_type : %s\n", mime_type);
1746 content_debug("mime not\n");
1748 if (user_data) content_debug("String : %s\n", (char *)user_data);
1753 void _noti_cb_2(media_content_error_e error,
1755 media_content_db_update_item_type_e update_item,
1756 media_content_db_update_type_e update_type,
1757 media_content_type_e media_type,
1764 content_debug("noti_2 success! : %d\n", error);
1766 content_debug("error occurred! : %d\n", error);
1768 content_debug("Noti_2 from PID(%d)\n", pid);
1770 g_main_loop_quit(g_loop);
1774 static media_content_noti_h noti_h;
1775 static media_content_noti_h noti_h_2;
1777 gboolean _send_noti_operations(gpointer data)
1779 int ret = MEDIA_CONTENT_ERROR_NONE;
1781 /* First of all, noti subscription */
1782 char *user_str = strdup("hi");
1783 media_content_add_db_updated_cb(_noti_cb, (void*)user_str, ¬i_h);
1784 media_content_add_db_updated_cb(_noti_cb_2, (void*)user_str, ¬i_h_2);
1786 /* media_info_insert_to_db */
1787 media_info_h media_item = NULL;
1788 const char *path = tzplatform_mkpath(TZ_USER_CONTENT, "test/image1.jpg");
1790 ret = media_info_insert_to_db(path, &media_item);
1791 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1792 content_error("media_info_insert_to_db failed : %d", ret);
1793 media_info_destroy(media_item);
1797 content_debug("media_info_insert_to_db success");
1799 media_content_remove_db_updated_cb(noti_h);
1801 media_info_destroy(media_item);
1808 int ret = MEDIA_CONTENT_ERROR_NONE;
1809 GSource *source = NULL;
1810 GMainContext *context = NULL;
1812 g_loop = g_main_loop_new(NULL, FALSE);
1813 context = g_main_loop_get_context(g_loop);
1814 source = g_idle_source_new();
1815 g_source_set_callback(source, _send_noti_operations, NULL, NULL);
1816 g_source_attach(source, context);
1818 g_main_loop_run(g_loop);
1819 g_main_loop_unref(g_loop);
1821 test_filter_destroy();
1822 media_content_remove_db_updated_cb(noti_h_2);
1826 #ifdef _USE_TVPD_MODE
1827 filter_h g_tv_filter = NULL;
1829 int test_tv_filter_create(void)
1831 content_debug("\n============Filter Create============\n\n");
1833 int ret = MEDIA_CONTENT_ERROR_NONE;
1835 ret = media_filter_create(&g_tv_filter);
1837 ret = media_filter_set_storage(g_tv_filter, "0a22a163-e634-4a2e-ba14-0469a969eea0");
1839 ret = media_filter_set_order(g_tv_filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_TITLE, MEDIA_CONTENT_COLLATE_DEFAULT);
1844 int test_tv_filter_destroy(void)
1846 content_debug("\n============Filter Destroy============\n\n");
1848 int ret = MEDIA_CONTENT_ERROR_NONE;
1850 ret = media_filter_destroy(g_tv_filter);
1855 bool pvr_item_cb(media_pvr_h pvr, void *user_data)
1857 int ret = MEDIA_CONTENT_ERROR_NONE;
1858 char *c_value = NULL;
1860 bool b_value = false;
1861 unsigned long long l_value = 0;
1864 content_debug("NO Item");
1868 ret = media_pvr_get_media_id(pvr, &c_value);
1869 if (ret != MEDIA_CONTENT_ERROR_NONE)
1870 content_error("Fail to media_pvr_get_media_id");
1871 content_debug("media_id [%s]", c_value);
1874 ret = media_pvr_get_channel_name(pvr, &c_value);
1875 if (ret != MEDIA_CONTENT_ERROR_NONE)
1876 content_error("Fail to media_pvr_get_channel_name");
1877 content_debug("channel_name [%s]", c_value);
1880 ret = media_pvr_get_program_title(pvr, &c_value);
1881 if (ret != MEDIA_CONTENT_ERROR_NONE)
1882 content_error("Fail to media_pvr_get_program_title");
1883 content_debug("program_title [%s]", c_value);
1886 ret = media_pvr_get_program_crid(pvr, &c_value);
1887 if (ret != MEDIA_CONTENT_ERROR_NONE)
1888 content_error("Fail to media_pvr_get_program_crid");
1889 content_debug("program_crid [%s]", c_value);
1892 ret = media_pvr_get_guidance(pvr, &c_value);
1893 if (ret != MEDIA_CONTENT_ERROR_NONE)
1894 content_error("Fail to media_pvr_get_guidance");
1895 content_debug("guidance [%s]", c_value);
1898 ret = media_pvr_get_synopsis(pvr, &c_value);
1899 if (ret != MEDIA_CONTENT_ERROR_NONE)
1900 content_error("Fail to media_pvr_get_synopsis");
1901 content_debug("synopsis [%s]", c_value);
1904 ret = media_pvr_get_genre(pvr, &c_value);
1905 if (ret != MEDIA_CONTENT_ERROR_NONE)
1906 content_error("Fail to media_pvr_get_synopsis");
1907 content_debug("genre [%s]", c_value);
1910 ret = media_pvr_get_language(pvr, &c_value);
1911 if (ret != MEDIA_CONTENT_ERROR_NONE)
1912 content_error("Fail to media_pvr_get_language");
1913 content_debug("language [%s]", c_value);
1916 ret = media_pvr_get_path(pvr, &c_value);
1917 if (ret != MEDIA_CONTENT_ERROR_NONE)
1918 content_error("Fail to media_pvr_get_path");
1919 content_debug("path [%s]", c_value);
1922 ret = media_pvr_get_storage_id(pvr, &c_value);
1923 if (ret != MEDIA_CONTENT_ERROR_NONE)
1924 content_error("Fail to media_pvr_get_storage_id");
1925 content_debug("storage_id [%s]", c_value);
1928 ret = media_pvr_get_size(pvr, &l_value);
1929 if (ret != MEDIA_CONTENT_ERROR_NONE)
1930 content_error("Fail to media_pvr_get_size");
1931 content_debug("size [%lld]", l_value);
1933 ret = media_pvr_get_timezone(pvr, &i_value);
1934 if (ret != MEDIA_CONTENT_ERROR_NONE)
1935 content_error("Fail to media_pvr_get_timezone");
1936 content_debug("timezone [%d]", i_value);
1938 ret = media_pvr_get_ptc(pvr, &i_value);
1939 if (ret != MEDIA_CONTENT_ERROR_NONE)
1940 content_error("Fail to media_pvr_get_ptc");
1941 content_debug("ptc [%d]", i_value);
1943 ret = media_pvr_get_major(pvr, &i_value);
1944 if (ret != MEDIA_CONTENT_ERROR_NONE)
1945 content_error("Fail to media_pvr_get_major");
1946 content_debug("[%d]", i_value);
1948 ret = media_pvr_get_minor(pvr, &i_value);
1949 if (ret != MEDIA_CONTENT_ERROR_NONE)
1950 content_error("Fail to media_pvr_get_minor");
1951 content_debug("minor [%d]", i_value);
1953 ret = media_pvr_get_channel_type(pvr, &i_value);
1954 if (ret != MEDIA_CONTENT_ERROR_NONE)
1955 content_error("Fail to media_pvr_get_channel_type");
1956 content_debug("channel_type [%d]", i_value);
1958 ret = media_pvr_get_program_num(pvr, &i_value);
1959 if (ret != MEDIA_CONTENT_ERROR_NONE)
1960 content_error("Fail to media_pvr_get_program_num");
1961 content_debug("program_num [%d]", i_value);
1963 unsigned int ui_value = 0;
1964 ret = media_pvr_get_service_profile(pvr, &ui_value);
1965 if (ret != MEDIA_CONTENT_ERROR_NONE)
1966 content_error("Fail to media_pvr_get_service_profile");
1967 content_debug("service_profile [%u]", ui_value);
1969 ret = media_pvr_get_duration(pvr, &i_value);
1970 if (ret != MEDIA_CONTENT_ERROR_NONE)
1971 content_error("Fail to media_pvr_get_duration");
1972 content_debug("duration [%d]", i_value);
1974 ret = media_pvr_get_embargo_time(pvr, &i_value);
1975 if (ret != MEDIA_CONTENT_ERROR_NONE)
1976 content_error("Fail to media_pvr_get_embargo_time");
1977 content_debug("embargo_time [%d]", i_value);
1979 ret = media_pvr_get_expiry_time(pvr, &i_value);
1980 if (ret != MEDIA_CONTENT_ERROR_NONE)
1981 content_error("Fail to media_pvr_get_expiry_time");
1982 content_debug("expiry_time [%d]", i_value);
1984 ret = media_pvr_get_parental_rating(pvr, &i_value);
1985 if (ret != MEDIA_CONTENT_ERROR_NONE)
1986 content_error("Fail to media_pvr_get_parental_rating");
1987 content_debug("parental_rating [%d]", i_value);
1989 ret = media_pvr_get_start_time(pvr, &i_value);
1990 if (ret != MEDIA_CONTENT_ERROR_NONE)
1991 content_error("Fail to media_pvr_get_start_time");
1992 content_debug("start_time [%d]", i_value);
1994 ret = media_pvr_get_program_start_time(pvr, &i_value);
1995 if (ret != MEDIA_CONTENT_ERROR_NONE)
1996 content_error("Fail to media_pvr_get_program_start_time");
1997 content_debug("program_start_time [%d]", i_value);
1999 ret = media_pvr_get_program_end_time(pvr, &i_value);
2000 if (ret != MEDIA_CONTENT_ERROR_NONE)
2001 content_error("Fail to media_pvr_get_program_end_time");
2002 content_debug("program_end_time [%d]", i_value);
2004 ret = media_pvr_get_program_date(pvr, &i_value);
2005 if (ret != MEDIA_CONTENT_ERROR_NONE)
2006 content_error("Fail to media_pvr_get_program_date");
2007 content_debug("program_date [%d]", i_value);
2009 ret = media_pvr_get_timer_record(pvr, &b_value);
2010 if (ret != MEDIA_CONTENT_ERROR_NONE)
2011 content_error("Fail to media_pvr_get_timer_record");
2012 content_debug("timer_record [%d]", b_value);
2014 ret = media_pvr_get_series_record(pvr, &b_value);
2015 if (ret != MEDIA_CONTENT_ERROR_NONE)
2016 content_error("Fail to media_pvr_get_series_record");
2017 content_debug("series_record [%d]", b_value);
2019 ret = media_pvr_get_hd(pvr, &i_value);
2020 if (ret != MEDIA_CONTENT_ERROR_NONE)
2021 content_error("Fail to media_pvr_get_hd");
2022 content_debug("hd [%d]", i_value);
2024 ret = media_pvr_get_subtitle(pvr, &b_value);
2025 if (ret != MEDIA_CONTENT_ERROR_NONE)
2026 content_error("Fail to media_pvr_get_subtitle");
2027 content_debug("subtitle [%d]", b_value);
2029 ret = media_pvr_get_ttx(pvr, &b_value);
2030 if (ret != MEDIA_CONTENT_ERROR_NONE)
2031 content_error("Fail to media_pvr_get_ttx");
2032 content_debug("ttx [%d]", b_value);
2034 ret = media_pvr_get_ad(pvr, &b_value);
2035 if (ret != MEDIA_CONTENT_ERROR_NONE)
2036 content_error("Fail to media_pvr_get_ad");
2037 content_debug("ad [%d]", b_value);
2039 ret = media_pvr_get_hard_of_hearing_radio(pvr, &b_value);
2040 if (ret != MEDIA_CONTENT_ERROR_NONE)
2041 content_error("Fail to media_pvr_get_hard_of_hearing_radio");
2042 content_debug("hard_of_hearing_radio [%d]", b_value);
2044 ret = media_pvr_get_data_service(pvr, &b_value);
2045 if (ret != MEDIA_CONTENT_ERROR_NONE)
2046 content_error("Fail to media_pvr_get_data_service");
2047 content_debug("data_service [%d]", b_value);
2049 ret = media_pvr_get_content_lock(pvr, &b_value);
2050 if (ret != MEDIA_CONTENT_ERROR_NONE)
2051 content_error("Fail to media_pvr_get_content_lock");
2052 content_debug("content_lock [%d]", b_value);
2054 ret = media_pvr_get_content_watch(pvr, &b_value);
2055 if (ret != MEDIA_CONTENT_ERROR_NONE)
2056 content_error("Fail to media_pvr_get_content_watch");
2057 content_debug("content_watch [%d]", b_value);
2059 ret = media_pvr_get_has_audio_only(pvr, &b_value);
2060 if (ret != MEDIA_CONTENT_ERROR_NONE)
2061 content_error("Fail to media_pvr_get_has_audio_only");
2062 content_debug("has_audio_only [%d]", b_value);
2064 ret = media_pvr_get_is_local_record(pvr, &b_value);
2065 if (ret != MEDIA_CONTENT_ERROR_NONE)
2066 content_error("Fail to media_pvr_get_is_local_record");
2067 content_debug("is_local_record [%d]", b_value);
2069 ret = media_pvr_get_resolution(pvr, (media_pvr_resolution_e*)&i_value);
2070 if (ret != MEDIA_CONTENT_ERROR_NONE)
2071 content_error("Fail to media_pvr_get_resolution");
2072 content_debug("resolution [%d]", i_value);
2074 ret = media_pvr_get_aspectratio(pvr, (media_pvr_aspectratio_e*)&i_value);
2075 if (ret != MEDIA_CONTENT_ERROR_NONE)
2076 content_error("Fail to media_pvr_get_aspectratio");
2077 content_debug("aspectratio [%d]", i_value);
2079 ret = media_pvr_get_highlight(pvr, &b_value);
2080 if (ret != MEDIA_CONTENT_ERROR_NONE)
2081 content_error("Fail to media_pvr_get_highlight");
2082 content_debug("highlight [%d]", b_value);
2090 int ret = MEDIA_CONTENT_ERROR_NONE;
2091 int media_count = 0;
2093 content_debug("\n============PVR Test============\n\n");
2095 test_tv_filter_create();
2097 ret = media_pvr_get_media_count_from_db(g_tv_filter, &media_count);
2098 if (ret != MEDIA_CONTENT_ERROR_NONE)
2099 content_error("media_pvr_get_media_count_from_db failed: %d", ret);
2101 content_debug("media_count : [%d]", media_count);
2103 ret = media_pvr_foreach_media_from_db(g_tv_filter, pvr_item_cb, NULL);
2104 if (ret != MEDIA_CONTENT_ERROR_NONE)
2105 content_error("media_pvr_foreach_media_from_db is failed");
2107 test_tv_filter_destroy();
2112 int test_pvr_update_db(void)
2114 int ret = MEDIA_CONTENT_ERROR_NONE;
2115 media_pvr_h pvr = NULL;
2117 ret = media_pvr_get_pvr_from_db("ff9b5a9a-a7b4-47f4-8255-84e007e25f13", &pvr);
2118 if (ret != MEDIA_CONTENT_ERROR_NONE)
2119 content_error("media_pvr_get_pvr_from_db failed: %d", ret);
2121 ret = media_pvr_set_content_lock(pvr, TRUE);
2122 if (ret != MEDIA_CONTENT_ERROR_NONE)
2123 content_error("Fail to media_pvr_set_content_lock");
2125 ret = media_pvr_set_content_watch(pvr, TRUE);
2126 if (ret != MEDIA_CONTENT_ERROR_NONE)
2127 content_error("Fail to media_pvr_set_content_watch");
2129 ret = media_pvr_set_program_title(pvr, "TEST TITLE");
2130 if (ret != MEDIA_CONTENT_ERROR_NONE)
2131 content_error("Fail to media_pvr_set_program_title");
2133 ret = media_pvr_set_highlight(pvr, TRUE);
2134 if (ret != MEDIA_CONTENT_ERROR_NONE)
2135 content_error("Fail to media_pvr_set_highlight");
2137 ret = media_pvr_update_to_db(pvr);
2138 if (ret != MEDIA_CONTENT_ERROR_NONE)
2139 content_error("Fail to media_pvr_update_to_db");
2142 media_pvr_destroy(pvr);
2148 int main(int argc, char *argv[])
2150 int ret = MEDIA_CONTENT_ERROR_NONE;
2152 content_debug("--- content manager test start ---\n\n");
2154 ret = test_connect_database();
2155 if (ret != MEDIA_CONTENT_ERROR_NONE)
2156 return MEDIA_CONTENT_ERROR_NONE;
2157 #ifdef _USE_TVPD_MODE
2160 test_pvr_update_db();
2167 ret = test_ebook_text_finder(argv[1]);
2168 if (ret != MEDIA_CONTENT_ERROR_NONE)
2173 if (ret != MEDIA_CONTENT_ERROR_NONE)
2176 ret = test_gallery_scenario();
2177 if (ret != MEDIA_CONTENT_ERROR_NONE)
2180 ret = test_get_all_music_files();
2181 if (ret != MEDIA_CONTENT_ERROR_NONE)
2184 ret = test_media_info_operation();
2185 if (ret != MEDIA_CONTENT_ERROR_NONE)
2188 ret = test_folder_operation();
2189 if (ret != MEDIA_CONTENT_ERROR_NONE)
2192 ret = test_playlist_operation();
2193 if (ret != MEDIA_CONTENT_ERROR_NONE)
2196 ret = test_bookmark_operation();
2197 if (ret != MEDIA_CONTENT_ERROR_NONE)
2200 ret = test_album_list();
2201 if (ret != MEDIA_CONTENT_ERROR_NONE)
2204 ret = test_group_operation();
2205 if (ret != MEDIA_CONTENT_ERROR_NONE)
2208 ret = test_update_operation();
2209 if (ret != MEDIA_CONTENT_ERROR_NONE)
2212 ret = test_insert();
2213 if (ret != MEDIA_CONTENT_ERROR_NONE)
2217 if (ret != MEDIA_CONTENT_ERROR_NONE)
2221 ret = test_create_thumbnail(argv[1]);
2222 if (ret != MEDIA_CONTENT_ERROR_NONE)
2227 if (ret != MEDIA_CONTENT_ERROR_NONE)
2230 ret = test_batch_operations();
2231 if (ret != MEDIA_CONTENT_ERROR_NONE)
2232 return MEDIA_CONTENT_ERROR_NONE;
2234 ret = test_scan_file();
2235 if (ret != MEDIA_CONTENT_ERROR_NONE)
2236 return MEDIA_CONTENT_ERROR_NONE;
2238 ret = test_scan_dir(true);
2239 if (ret != MEDIA_CONTENT_ERROR_NONE)
2240 return MEDIA_CONTENT_ERROR_NONE;
2243 if (ret != MEDIA_CONTENT_ERROR_NONE)
2244 return MEDIA_CONTENT_ERROR_NONE;
2246 ret = test_playlist_operation_v2();
2247 if (ret != MEDIA_CONTENT_ERROR_NONE)
2248 return MEDIA_CONTENT_ERROR_NONE;
2250 ret = test_bookmark_operation_v2();
2251 if (ret != MEDIA_CONTENT_ERROR_NONE)
2252 return MEDIA_CONTENT_ERROR_NONE;
2255 ret = test_disconnect_database();
2256 if (ret != MEDIA_CONTENT_ERROR_NONE)
2259 content_debug("--- content manager test end ---\n");