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);
255 if (media_info_get_stitched_engine(media, &i_value) == MEDIA_CONTENT_ERROR_NONE)
256 content_debug("360 engine : [%d]", i_value);
259 if (media_type == MEDIA_CONTENT_TYPE_MUSIC)
260 get_audio_meta(media);
262 if (media_type == MEDIA_CONTENT_TYPE_IMAGE)
263 get_image_meta(media);
265 if (media_type == MEDIA_CONTENT_TYPE_BOOK)
266 get_book_meta(media);
268 if (media_type == MEDIA_CONTENT_TYPE_OTHERS)
269 content_debug("Other type");
272 bool media_item_cb(media_info_h media, void *user_data)
275 content_debug("NO Item");
279 get_media_meta(media);
284 bool gallery_folder_list_cb(media_folder_h folder, void *user_data)
286 media_folder_h new_folder = NULL;
287 media_folder_clone(&new_folder, folder);
289 GList **list = (GList**)user_data;
290 *list = g_list_append(*list, new_folder);
295 bool gallery_media_item_cb(media_info_h media, void *user_data)
297 media_info_h new_media = NULL;
298 int ret = MEDIA_CONTENT_ERROR_NONE;
300 ret = media_info_clone(&new_media, media);
302 if (ret != MEDIA_CONTENT_ERROR_NONE) {
303 GList **list = (GList**)user_data;
304 *list = g_list_append(*list, new_media);
310 bool gallery_bookmarks_cb(media_bookmark_h bookmark, void *user_data)
312 media_bookmark_h new_bm = NULL;
313 int ret = MEDIA_CONTENT_ERROR_NONE;
315 ret = media_bookmark_clone(&new_bm, bookmark);
316 if (ret != MEDIA_CONTENT_ERROR_NONE)
317 content_error("error media_bookmark_clone : [%d]", ret);
319 GList **list = (GList**)user_data;
320 *list = g_list_append(*list, new_bm);
325 bool folder_list_cb(media_folder_h folder, void *user_data)
328 char *folder_id = NULL;
329 media_folder_h *_folder = (media_folder_h*)user_data;
331 content_debug("===========================");
332 if (folder != NULL) {
334 media_folder_clone(_folder, folder);
336 get_folder_meta(folder, &folder_id);
338 if (media_folder_get_media_count_from_db(folder_id, g_filter, &item_count) != MEDIA_CONTENT_ERROR_NONE) {
339 SAFE_FREE(folder_id);
340 content_error("[ERROR] media_folder_get_media_count_from_db is failed");
344 if (media_folder_foreach_media_from_db(folder_id, g_filter, media_item_cb, NULL) != MEDIA_CONTENT_ERROR_NONE) {
345 SAFE_FREE(folder_id);
346 content_error("[ERROR] media_folder_foreach_media_from_db is failed");
350 SAFE_FREE(folder_id);
358 bool playlist_list_cb(media_playlist_h playlist, void *user_data)
360 int ret = MEDIA_CONTENT_ERROR_NONE;
362 char *playlist_name = NULL;
363 media_playlist_h playlist_h;
364 char *playlist_thumbnail_path = NULL;
366 content_debug("playlist_list_cb ======");
368 GList **list = (GList**)user_data;
371 if (playlist == NULL) {
372 content_debug(" playlist handle is NULL");
376 ret = media_playlist_get_playlist_id(playlist, &playlist_id);
377 if (ret != MEDIA_CONTENT_ERROR_NONE)
378 content_error("error media_playlist_get_playlist_id : [%d]", ret);
380 content_debug("playlist_id : %d", playlist_id);
381 /* 64bit build issue */
383 if (user_data != NULL)
384 *list = g_list_append(*list, (gpointer)playlist_id);
386 ret = media_playlist_get_name(playlist, &playlist_name);
387 if (ret != MEDIA_CONTENT_ERROR_NONE)
388 content_error("error media_playlist_get_name : [%d]", ret);
390 content_debug("playlist_name : %s", playlist_name);
391 SAFE_FREE(playlist_name);
393 ret = media_playlist_get_thumbnail_path(playlist, &playlist_thumbnail_path);
394 if (ret != MEDIA_CONTENT_ERROR_NONE)
395 content_error("error media_playlist_get_thumbnail_path : [%d]", ret);
397 content_debug("playlist_thumbnail_path : %s", playlist_thumbnail_path);
398 SAFE_FREE(playlist_thumbnail_path);
400 ret = media_playlist_get_playlist_from_db(playlist_id, &playlist_h);
401 if (ret != MEDIA_CONTENT_ERROR_NONE)
402 content_error("error media_playlist_get_playlist_from_db : [%d]", ret);
404 ret = media_playlist_destroy(playlist_h);
405 if (ret != MEDIA_CONTENT_ERROR_NONE)
406 content_error("error media_playlist_destroy : [%d]", ret);
411 bool bookmarks_cb(media_bookmark_h bookmark, void *user_data)
413 if (bookmark != NULL && user_data != NULL) {
414 media_bookmark_h new_bookmark;
416 media_bookmark_clone(&new_bookmark, bookmark);
417 GList **list = (GList**)user_data;
418 *list = g_list_append(*list, new_bookmark);
421 get_bookmark_meta(bookmark);
426 bool album_list_cb(media_album_h album, void *user_data)
430 int ret = MEDIA_CONTENT_ERROR_NONE;
433 get_album_meta(album);
434 media_album_get_album_id(album, &album_id);
436 ret = media_album_get_media_count_from_db(album_id, NULL, &media_count);
437 if (ret != MEDIA_CONTENT_ERROR_NONE)
438 content_error("error media_album_get_media_count_from_db : [%d]", ret);
440 content_debug("media_count : [%d]", media_count);
442 ret = media_album_foreach_media_from_db(album_id, NULL, media_item_cb, NULL);
443 if (ret != MEDIA_CONTENT_ERROR_NONE) {
444 content_error("error media_album_foreach_media_from_db : [%d]", ret);
449 content_error("album item not Found!!");
455 bool group_list_cb(const char *group_name, void *user_data)
458 int *idx = user_data;
460 content_debug("group item : [%s] [%d]", group_name, *idx);
462 if (media_group_get_media_count_from_db(group_name, *idx, g_filter, &media_count) != MEDIA_CONTENT_ERROR_NONE)
465 content_debug("media_count : [%d]", media_count);
467 if (media_group_foreach_media_from_db(group_name, *idx, g_filter, media_item_cb, NULL) != MEDIA_CONTENT_ERROR_NONE)
473 bool playlist_item_cb(int playlist_member_id, media_info_h media, void *user_data)
475 content_debug("playlist_member_id : [%d]", playlist_member_id);
476 /* 64bit build issue */
478 GList **list = (GList**)user_data;
480 *list = g_list_append(*list, (gpointer)playlist_member_id);
482 /*media_item_cb(media, user_data);*/
487 int test_filter_create(void)
489 content_debug("\n============Filter Create============\n\n");
491 int ret = MEDIA_CONTENT_ERROR_NONE;
493 /* Filter for media */
494 const char *condition = "MEDIA_TYPE=3"; /*MEDIA_TYPE 0-image, 1-video, 2-sound, 3-music, 4-other*/
496 ret = media_filter_create(&g_filter);
498 /* Set condition and collate
499 * Condition string : You can make where statement of sql.
500 * Colation : You can use collation when comparing.
501 * Ex) In case of FILE_NAME='Samsung' as condition string,
502 * if you want to compare with NOCASE collation,
503 * call media_filter_set_condition(g_filter, condition, MEDIA_CONTENT_COLLATE_NOCASE);
504 * if you want to compare in case-sensitive,
505 * call media_filter_set_condition(g_filter, condition, MEDIA_CONTENT_COLLATE_DEFAULT);
507 ret = media_filter_set_condition(g_filter, condition, MEDIA_CONTENT_COLLATE_DEFAULT);
512 int test_filter_destroy(void)
514 content_debug("\n============Filter Create============\n\n");
516 int ret = MEDIA_CONTENT_ERROR_NONE;
518 ret = media_filter_destroy(g_filter);
523 int test_connect_database(void)
525 int ret = MEDIA_CONTENT_ERROR_NONE;
527 content_debug("\n============DB Connection Test============\n\n");
529 ret = media_content_connect();
531 if (ret == MEDIA_CONTENT_ERROR_NONE)
532 content_debug("connection is success\n\n");
534 content_error("connection is failed\n\n");
539 int test_gallery_scenario(void)
541 int ret = MEDIA_CONTENT_ERROR_NONE;
543 filter_h filter = NULL;
546 GList *folder_list = NULL;
547 media_folder_h folder_handle = NULL;
549 /* First, Get folder list */
550 ret = media_folder_foreach_folder_from_db(filter, gallery_folder_list_cb, &folder_list);
551 if (ret != MEDIA_CONTENT_ERROR_NONE) {
552 content_error("media_folder_foreach_folder_from_db failed: %d", ret);
555 content_debug("media_folder_foreach_folder_from_db success!!");
556 char *folder_id = NULL;
558 for (i = 0; i < g_list_length(folder_list); i++) {
559 folder_handle = (media_folder_h)g_list_nth_data(folder_list, i);
561 get_folder_meta(folder_handle, &folder_id);
563 ret = media_folder_get_media_count_from_db(folder_id, filter, &count);
564 SAFE_FREE(folder_id);
565 if (ret != MEDIA_CONTENT_ERROR_NONE) {
566 content_error("media_folder_get_media_count_from_db failed: %d", ret);
569 content_debug("media count [%d] : %d", i, count);
574 /* To check performance */
575 struct timeval start, end;
576 gettimeofday(&start, NULL);
578 /* Second, Get all item list */
579 media_info_h media_handle = NULL;
580 GList *all_item_list = NULL;
582 media_content_collation_e collate_type = MEDIA_CONTENT_COLLATE_NOCASE;
583 media_content_order_e order_type = MEDIA_CONTENT_ORDER_DESC;
584 ret = media_filter_create(&filter);
585 if (ret != MEDIA_CONTENT_ERROR_NONE) {
586 content_error("Fail to create filter");
589 ret = media_filter_set_condition(filter, "MEDIA_TYPE = 0", collate_type);
590 if (ret != MEDIA_CONTENT_ERROR_NONE) {
591 media_filter_destroy(filter);
592 content_error("Fail to set condition");
595 ret = media_filter_set_order(filter, order_type, MEDIA_DISPLAY_NAME, collate_type);
596 if (ret != MEDIA_CONTENT_ERROR_NONE) {
597 media_filter_destroy(filter);
598 content_error("Fail to set order");
602 ret = media_info_foreach_media_from_db(filter, gallery_media_item_cb, &all_item_list);
603 if (ret != MEDIA_CONTENT_ERROR_NONE) {
604 content_error("media_info_foreach_media_from_db failed: %d", ret);
605 media_filter_destroy(filter);
608 content_debug("media_info_foreach_media_from_db success");
610 for (i = 0; i < g_list_length(all_item_list); i++) {
611 media_handle = (media_info_h)g_list_nth_data(all_item_list, i);
612 get_media_meta(media_handle);
616 media_filter_destroy(filter);
619 /* To check performance */
620 gettimeofday(&end, NULL);
621 long time = (end.tv_sec * 1000000 + end.tv_usec) - (start.tv_sec * 1000000 + start.tv_usec);
622 content_debug("Time : %ld\n", time);
624 /* Third, Get item list of a folder */
625 GList *item_list = NULL;
627 for (i = 0; i < g_list_length(folder_list); i++) {
629 char *folder_id = NULL;
630 folder_handle = (media_folder_h)g_list_nth_data(folder_list, i);
632 get_folder_meta(folder_handle, &folder_id);
634 ret = media_folder_foreach_media_from_db(folder_id, filter, gallery_media_item_cb, &item_list);
635 SAFE_FREE(folder_id);
637 if (ret != MEDIA_CONTENT_ERROR_NONE) {
638 content_error("media_folder_foreach_media_from_db failed: %d", ret);
641 content_error("media_folder_foreach_media_from_db success!");
643 for (j = 0; j < g_list_length(item_list); j++) {
644 media_handle = (media_info_h)g_list_nth_data(item_list, j);
645 get_media_meta(media_handle);
650 /* Remove folder list */
652 for (i = 0; i < g_list_length(folder_list); i++) {
653 folder_handle = (media_folder_h)g_list_nth_data(folder_list, i);
654 media_folder_destroy(folder_handle);
657 g_list_free(folder_list);
660 /* Remove all items list */
662 for (i = 0; i < g_list_length(all_item_list); i++) {
663 media_handle = (media_info_h)g_list_nth_data(all_item_list, i);
664 ret = media_info_destroy(media_handle);
665 if (ret != MEDIA_CONTENT_ERROR_NONE)
666 content_error("media_info_destroy failed: %d", ret);
669 g_list_free(all_item_list);
672 /* Remove items list */
674 for (i = 0; i < g_list_length(item_list); i++) {
675 media_handle = (media_info_h)g_list_nth_data(item_list, i);
676 ret = media_info_destroy(media_handle);
677 if (ret != MEDIA_CONTENT_ERROR_NONE)
678 content_error("media_info_destroy failed: %d", ret);
681 g_list_free(item_list);
684 return MEDIA_CONTENT_ERROR_NONE;
687 /*Get All Music file. sort by Title and not case sensitive*/
688 int test_get_all_music_files(void)
690 int ret = MEDIA_CONTENT_ERROR_NONE;
695 const char *condition = "MEDIA_TYPE=3"; /*0-image, 1-video, 2-sound, 3-music, 4-other*/
697 ret = media_filter_create(&filter);
698 if (ret != MEDIA_CONTENT_ERROR_NONE) {
699 content_error("Fail to create filter");
702 ret = media_filter_set_condition(filter, condition, MEDIA_CONTENT_COLLATE_LOCALIZED);
703 if (ret != MEDIA_CONTENT_ERROR_NONE) {
704 media_filter_destroy(filter);
705 content_error("Fail to set condition");
708 ret = media_filter_set_order(filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_TITLE, MEDIA_CONTENT_COLLATE_LOCALIZED);
709 if (ret != MEDIA_CONTENT_ERROR_NONE) {
710 media_filter_destroy(filter);
711 content_error("Fail to set order");
716 ret = media_info_get_media_count_from_db(filter, &media_count);
717 if (ret != MEDIA_CONTENT_ERROR_NONE) {
718 media_filter_destroy(filter);
719 content_error("Fail to get media count");
723 content_debug("media_count : [%d]", media_count);
725 ret = media_info_foreach_media_from_db(filter, media_item_cb, NULL);
726 if (ret != MEDIA_CONTENT_ERROR_NONE) {
727 media_filter_destroy(filter);
728 content_error("Fail to get media");
732 ret = media_filter_destroy(filter);
737 int test_media_info_operation(void)
739 int ret = MEDIA_CONTENT_ERROR_NONE;
742 content_debug("\n============Media info Test============\n\n");
744 test_filter_create();
746 ret = media_info_get_media_count_from_db(g_filter, &media_count);
747 if (ret != MEDIA_CONTENT_ERROR_NONE)
748 content_error("media_info_get_media_count_from_db failed: %d", ret);
750 content_debug("media_count : [%d]", media_count);
752 ret = media_info_foreach_media_from_db(g_filter, media_item_cb, NULL);
753 if (ret == MEDIA_CONTENT_ERROR_NONE)
754 content_debug("media_info_foreach_media_from_db is success");
756 content_error("media_info_foreach_media_from_db is failed");
758 test_filter_destroy();
763 int test_folder_operation(void)
765 int ret = MEDIA_CONTENT_ERROR_NONE;
766 filter_h filter = NULL;
767 media_folder_h folder = NULL;
768 char *folder_id = NULL;
771 content_debug("\n============Folder Test============\n\n");
773 test_filter_create();
775 ret = media_filter_create(&filter);
776 if (ret != MEDIA_CONTENT_ERROR_NONE) {
777 content_error("[ERROR] media_folder_filter_create is failed");
781 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*/
782 media_filter_set_offset(filter, 0, 5);
783 media_filter_set_order(filter, MEDIA_CONTENT_ORDER_DESC, MEDIA_PATH, MEDIA_CONTENT_COLLATE_NOCASE);
785 ret = media_folder_get_folder_count_from_db(filter, &count);
786 content_debug("Folder count : [%d]", count);
788 ret = media_folder_foreach_folder_from_db(filter, folder_list_cb, &folder);
790 filter_h m_filter = NULL;
792 ret = media_filter_create(&m_filter);
793 if (ret != MEDIA_CONTENT_ERROR_NONE) {
794 test_filter_destroy();
795 media_filter_destroy(filter);
796 content_error("[ERROR] media_info_filter_create is failed");
800 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*/
801 media_filter_set_offset(m_filter, 0, 5);
802 media_filter_set_order(m_filter, MEDIA_CONTENT_ORDER_DESC, MEDIA_PATH, MEDIA_CONTENT_COLLATE_NOCASE);
804 ret = media_folder_foreach_media_from_db(folder_id, m_filter, media_item_cb, NULL);
805 if (ret != MEDIA_CONTENT_ERROR_NONE)
806 content_error("[ERROR] media_folder_foreach_media_from_db is failed, error code : %d", ret);
808 media_filter_destroy(filter);
809 media_filter_destroy(m_filter);
811 test_filter_destroy();
813 /* fix prevent: Resource Leak */
814 SAFE_FREE(folder_id);
819 int test_playlist_operation(void)
821 int ret = MEDIA_CONTENT_ERROR_NONE;
822 media_playlist_h playlist_1 = NULL;
823 media_playlist_h playlist_2 = NULL;
824 media_playlist_h playlist_3 = NULL;
825 media_playlist_h playlist_4 = NULL;
826 int playlist_id_1 = 0;
827 int playlist_id_2 = 0;
828 int playlist_id_3 = 0;
829 const char *playlist_name_1 = "myPlaylist_1";
830 const char *playlist_name_2 = "myPlaylist_2";
831 const char *playlist_name_3 = "myPlaylist_3";
832 int playlist_count = 0;
839 filter_h filter = NULL;
840 filter_h m_filter = NULL;
842 content_debug("\n============Playlist Test============\n\n");
844 /* Filter for playlist */
846 const char *condition = "(MEDIA_TYPE=1 or MEDIA_TYPE=3)"; /*0-image, 1-video, 2-sound, 3-music, 4-other*/
848 ret = media_filter_create(&filter);
849 ret = media_filter_set_condition(filter, condition, MEDIA_CONTENT_COLLATE_NOCASE);
850 ret = media_filter_set_order(filter, MEDIA_CONTENT_ORDER_ASC, PLAYLIST_NAME, MEDIA_CONTENT_COLLATE_NOCASE);
852 /* Create Playlist */
853 media_playlist_insert_to_db(playlist_name_1, &playlist_1);
854 media_playlist_insert_to_db(playlist_name_2, &playlist_2);
855 media_playlist_insert_to_db(playlist_name_3, &playlist_3);
857 if (playlist_1 != NULL) {
858 /* Add media to Playlist */
859 media_playlist_add_media(playlist_1, test_audio_id);
860 media_playlist_add_media(playlist_1, test_audio_id);
861 media_playlist_add_media(playlist_1, test_video_id);
864 char *playlist_thumb_path = tzplatform_mkpath(TZ_USER_IMAGES, "Default.jpg"));
865 media_playlist_set_thumbnail_path(playlist_1, playlist_thumb_path);
868 media_playlist_update_to_db(playlist_1);
871 if (playlist_2 != NULL) {
872 media_playlist_add_media(playlist_2, test_audio_id);
873 media_playlist_add_media(playlist_2, test_audio_id);
874 media_playlist_update_to_db(playlist_2);
877 /* Get Playlist Count*/
878 ret = media_playlist_get_playlist_count_from_db(filter, &playlist_count);
880 content_debug("playlist_count [%d]", playlist_count);
883 GList *playlist_id_list = NULL;
884 media_playlist_foreach_playlist_from_db(filter, playlist_list_cb, &playlist_id_list);
885 /* 64bit build issue */
888 playlist_id_1 = (int)g_list_nth_data(playlist_id_list, 0);
889 playlist_id_2 = (int)g_list_nth_data(playlist_id_list, 1);
890 playlist_id_3 = (int)g_list_nth_data(playlist_id_list, 2);
892 content_debug("playlist_id_1 [%d]", playlist_id_1);
893 content_debug("playlist_id_2 [%d]", playlist_id_2);
894 content_debug("playlist_id_3 [%d]", playlist_id_3);
896 /* Export and import playlist */
897 media_playlist_export_to_file(playlist_3, tzplatform_mkpath(TZ_USER_MUSIC, "playlist.m3u"));
898 media_playlist_import_from_file(tzplatform_mkpath(TZ_USER_MUSIC, "playlist.m3u"), "playlist_4", &playlist_4);
900 /* Filter for media*/
901 ret = media_filter_create(&m_filter);
903 ret = media_filter_set_condition(m_filter, condition, MEDIA_CONTENT_COLLATE_DEFAULT);
905 ret = media_filter_set_order(m_filter, MEDIA_CONTENT_ORDER_ASC, PLAYLIST_MEMBER_ORDER, MEDIA_CONTENT_COLLATE_DEFAULT);
907 /* Get media count */
908 media_playlist_get_media_count_from_db(playlist_id_1, m_filter, &media_count);
909 content_debug("playlist_1_media_count [%d]", media_count);
911 media_playlist_get_media_count_from_db(playlist_id_2, m_filter, &media_count);
912 content_debug("playlist_2_media_count [%d]", media_count);
914 media_playlist_get_media_count_from_db(playlist_id_3, m_filter, &media_count);
915 content_debug("playlist_3_media_count [%d]", media_count);
917 /* Get media of playlist */
918 GList *playlist_member_id_list = NULL;
919 GList *playlist_member_id_list_1 = NULL;
921 media_playlist_foreach_media_from_db(playlist_id_1, m_filter, playlist_item_cb, &playlist_member_id_list);
922 media_playlist_foreach_media_from_db(playlist_id_2, m_filter, playlist_item_cb, &playlist_member_id_list_1);
924 int playlist_member_id_1_1 = 0;
925 int playlist_member_id_1_2 = 0;
926 int playlist_member_id_1_3 = 0;
927 int playlist_member_id_2_1 = 0;
928 int playlist_member_id_2_2 = 0;
929 /* 64bit build issue */
931 playlist_member_id_1_1 = (int)g_list_nth_data(playlist_member_id_list, 0);
932 playlist_member_id_1_2 = (int)g_list_nth_data(playlist_member_id_list, 1);
933 playlist_member_id_1_3 = (int)g_list_nth_data(playlist_member_id_list, 2);
934 playlist_member_id_2_1 = (int)g_list_nth_data(playlist_member_id_list_1, 0);
935 playlist_member_id_2_2 = (int)g_list_nth_data(playlist_member_id_list_1, 1);
937 content_debug("playlist_member_id_1_1 [%d]", playlist_member_id_1_1);
938 content_debug("playlist_member_id_1_2 [%d]", playlist_member_id_1_2);
939 content_debug("playlist_member_id_1_3 [%d]", playlist_member_id_1_3);
940 content_debug("playlist_member_id_2_1 [%d]", playlist_member_id_2_1);
941 content_debug("playlist_member_id_2_2 [%d]", playlist_member_id_2_2);
943 media_playlist_get_play_order(playlist_1, playlist_member_id_1_1, &order_1);
944 media_playlist_get_play_order(playlist_1, playlist_member_id_1_2, &order_2);
945 media_playlist_get_play_order(playlist_1, playlist_member_id_1_3, &order_3);
946 media_playlist_get_play_order(playlist_2, playlist_member_id_2_1, &order_4);
947 media_playlist_get_play_order(playlist_2, playlist_member_id_2_2, &order_5);
948 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);
950 /* Update Playlist */
951 media_playlist_remove_media(playlist_2, playlist_member_id_2_1);
952 media_playlist_add_media(playlist_2, test_video_id);
953 media_playlist_set_name(playlist_2, "test_playlist");
954 media_playlist_set_play_order(playlist_2, playlist_member_id_2_2, order_5+100);
955 media_playlist_update_to_db(playlist_2);
957 /* Get Updated Playlist*/
958 media_playlist_foreach_playlist_from_db(filter, playlist_list_cb, NULL);
960 /* deletes the playlist */
962 media_playlist_delete_from_db(playlist_id_1);
963 media_playlist_delete_from_db(playlist_id_2);
966 if (playlist_1 != NULL)
967 media_playlist_destroy(playlist_1);
968 if (playlist_2 != NULL)
969 media_playlist_destroy(playlist_2);
970 if (playlist_3 != NULL)
971 media_playlist_destroy(playlist_3);
972 if (playlist_4 != NULL)
973 media_playlist_destroy(playlist_4);
975 g_list_free(playlist_id_list);
976 g_list_free(playlist_member_id_list);
977 g_list_free(playlist_member_id_list_1);
980 ret = media_filter_destroy(filter);
981 if (m_filter != NULL)
982 ret = media_filter_destroy(m_filter);
987 int test_playlist_operation_v2(void)
989 int ret = MEDIA_CONTENT_ERROR_NONE;
990 media_playlist_h playlist_1 = NULL;
991 const char *playlist_name_1 = "myPlaylist_1";
992 const char *playlist_thumb_path = tzplatform_mkpath(TZ_USER_IMAGES, "Default.jpg");
995 content_debug("\n============Playlist Test V2============\n\n");
997 ret = media_playlist_create(&playlist_1);
998 if (ret != MEDIA_CONTENT_ERROR_NONE)
999 content_error("error media_playlist_create : [%d]", ret);
1001 ret = media_playlist_set_name(playlist_1, playlist_name_1);
1002 if (ret != MEDIA_CONTENT_ERROR_NONE)
1003 content_error("error media_playlist_set_name : [%d]", ret);
1005 ret = media_playlist_set_thumbnail_path(playlist_1, playlist_thumb_path);
1006 if (ret != MEDIA_CONTENT_ERROR_NONE)
1007 content_error("error media_playlist_set_thumbnail_path : [%d]", ret);
1009 ret = media_playlist_insert_to_db_v2(playlist_1);
1010 if (ret != MEDIA_CONTENT_ERROR_NONE)
1011 content_error("error media_playlist_insert_to_db_v2 : [%d]", ret);
1013 ret = media_playlist_set_name(playlist_1, "myPlaylist_3");
1014 if (ret != MEDIA_CONTENT_ERROR_NONE)
1015 content_error("error media_playlist_set_name : [%d]", ret);
1017 ret = media_playlist_get_playlist_id(playlist_1, &playlist_id);
1018 if (ret != MEDIA_CONTENT_ERROR_NONE)
1019 content_error("error media_playlist_get_playlist_id : [%d]", ret);
1021 ret = media_playlist_update_to_db_v2(playlist_id, playlist_1);
1022 if (ret != MEDIA_CONTENT_ERROR_NONE)
1023 content_error("error media_playlist_update_to_db_v2 : [%d]", ret);
1025 ret = media_playlist_destroy(playlist_1);
1026 if (ret != MEDIA_CONTENT_ERROR_NONE)
1027 content_error("error media_playlist_destroy : [%d]", ret);
1032 static void __bookmark_handle_free(gpointer data)
1034 media_bookmark_h handle = (media_bookmark_h) data;
1035 media_bookmark_destroy(handle);
1038 int test_bookmark_operation(void)
1040 /* bookmark is only supported for video information. */
1041 int ret = MEDIA_CONTENT_ERROR_NONE;
1042 int bookmark_count = 0;
1044 GList *all_item_list = NULL;
1047 content_debug("\n============Bookmark Test============\n\n");
1049 const char *g_condition = "BOOKMARK_MARKED_TIME > 300";
1051 ret = media_filter_create(&filter);
1052 if (ret != MEDIA_CONTENT_ERROR_NONE)
1053 content_error("error media_filter_create : [%d]", ret);
1055 ret = media_filter_set_condition(filter, g_condition, MEDIA_CONTENT_COLLATE_DEFAULT);
1056 if (ret != MEDIA_CONTENT_ERROR_NONE)
1057 content_error("error media_filter_set_condition : [%d]", ret);
1059 ret = media_filter_set_order(filter, MEDIA_CONTENT_ORDER_DESC, BOOKMARK_MARKED_TIME, MEDIA_CONTENT_COLLATE_DEFAULT);
1060 if (ret != MEDIA_CONTENT_ERROR_NONE)
1061 content_error("error media_filter_set_order : [%d]", ret);
1063 /* insert bookmark to video */
1064 const char *thumbnail_path1 = tzplatform_mkpath(TZ_USER_VIDEOS, "teat11.jpg");
1065 ret = media_bookmark_insert_to_db(test_video_id, 400, thumbnail_path1);
1066 if (ret != MEDIA_CONTENT_ERROR_NONE)
1067 content_error("error media_bookmark_insert_to_db : [%d]", ret);
1069 ret = media_bookmark_insert_to_db(test_video_id, 600, thumbnail_path1);
1070 if (ret != MEDIA_CONTENT_ERROR_NONE)
1071 content_error("error media_bookmark_insert_to_db : [%d]", ret);
1073 ret = media_bookmark_get_bookmark_count_from_db(filter, &bookmark_count);
1074 if (ret != MEDIA_CONTENT_ERROR_NONE)
1075 content_error("error media_bookmark_get_bookmark_count_from_db : [%d]", ret);
1077 content_debug("bookmark_count = [%d]", bookmark_count);
1079 ret = media_info_foreach_bookmark_from_db(test_video_id, NULL, bookmarks_cb, &all_item_list);
1080 if (ret != MEDIA_CONTENT_ERROR_NONE)
1081 content_error("error media_info_foreach_bookmark_from_db : [%d]", ret);
1083 for (idx = 0; idx < g_list_length(all_item_list); idx++) {
1084 media_bookmark_h bookmark_handle;
1085 bookmark_handle = (media_bookmark_h)g_list_nth_data(all_item_list, idx);
1087 ret = media_bookmark_set_name(bookmark_handle, "test 1");
1088 if (ret != MEDIA_CONTENT_ERROR_NONE)
1089 content_error("error media_bookmark_set_name : [%d]", ret);
1091 ret = media_bookmark_update_to_db(bookmark_handle);
1092 if (ret != MEDIA_CONTENT_ERROR_NONE)
1093 content_error("error media_bookmark_update_to_db : [%d]", ret);
1097 g_list_free_full(all_item_list, __bookmark_handle_free);
1099 ret = media_info_foreach_bookmark_from_db(test_video_id, NULL, bookmarks_cb, NULL);
1100 if (ret != MEDIA_CONTENT_ERROR_NONE)
1101 content_error("error media_info_foreach_bookmark_from_db : [%d]", ret);
1103 ret = media_filter_destroy(filter);
1104 if (ret != MEDIA_CONTENT_ERROR_NONE)
1105 content_error("error media_filter_destroy : [%d]", ret);
1110 int test_bookmark_operation_v2(void)
1112 content_debug("\n============Bookmark Test V2============\n\n");
1114 int ret = MEDIA_CONTENT_ERROR_NONE;
1115 media_bookmark_h bookmark = NULL;
1116 const char *thumbnail_path1 = tzplatform_mkpath(TZ_USER_VIDEOS, "teat11.jpg");
1118 ret = media_bookmark_create(test_video_id, 400, &bookmark);
1119 if (ret != MEDIA_CONTENT_ERROR_NONE)
1120 content_error("error media_bookmark_create : [%d]", ret);
1122 ret = media_bookmark_set_name(bookmark, "test bookmark");
1123 if (ret != MEDIA_CONTENT_ERROR_NONE)
1124 content_error("error media_bookmark_set_name : [%d]", ret);
1126 ret = media_bookmark_set_thumbnail_path(bookmark, thumbnail_path1);
1127 if (ret != MEDIA_CONTENT_ERROR_NONE)
1128 content_error("error media_bookmark_set_thumbnail_path : [%d]", ret);
1130 ret = media_bookmark_insert_to_db_v2(bookmark);
1131 if (ret != MEDIA_CONTENT_ERROR_NONE)
1132 content_error("error media_bookmark_insert_to_db_v2 : [%d]", ret);
1134 ret = media_bookmark_set_name(bookmark, "test bookmark 2");
1135 if (ret != MEDIA_CONTENT_ERROR_NONE)
1136 content_error("error media_bookmark_set_name : [%d]", ret);
1138 ret = media_bookmark_update_to_db(bookmark);
1139 if (ret != MEDIA_CONTENT_ERROR_NONE)
1140 content_error("error media_bookmark_update_to_db : [%d]", ret);
1142 ret = media_bookmark_destroy(bookmark);
1143 if (ret != MEDIA_CONTENT_ERROR_NONE)
1144 content_error("error media_bookmark_destroy : [%d]", ret);
1149 int test_album_list(void)
1151 content_debug("\n============Album Test============\n\n");
1153 int ret = MEDIA_CONTENT_ERROR_NONE;
1154 int album_count = 0;
1158 const char *condition = "MEDIA_TYPE=3"; /*0-image, 1-video, 2-sound, 3-music, 4-other*/
1160 ret = media_filter_create(&filter);
1161 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1162 content_error("Fail to create filter");
1165 ret = media_filter_set_condition(filter, condition, MEDIA_CONTENT_COLLATE_DEFAULT);
1166 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1167 media_filter_destroy(filter);
1168 content_error("Fail to set condition");
1171 ret = media_filter_set_order(filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_ALBUM, MEDIA_CONTENT_COLLATE_NOCASE);
1172 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1173 media_filter_destroy(filter);
1174 content_error("Fail to set order");
1178 ret = media_album_get_album_count_from_db(filter, &album_count);
1179 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1180 media_filter_destroy(filter);
1183 content_debug("album_count [%d]", album_count);
1186 ret = media_album_foreach_album_from_db(filter, album_list_cb, NULL);
1187 if (ret != MEDIA_CONTENT_ERROR_NONE)
1188 content_error("error media_album_foreach_album_from_db : [%d]", ret);
1190 ret = media_filter_destroy(filter);
1191 if (ret != MEDIA_CONTENT_ERROR_NONE)
1192 content_error("error media_filter_destroy : [%d]", ret);
1197 int test_group_operation(void)
1199 content_debug("\n============Group Test============\n\n");
1201 int ret = MEDIA_CONTENT_ERROR_NONE;
1202 int group_count = 0;
1205 ret = test_filter_create();
1206 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1207 content_error("[error(0x%08x)", ret);
1211 for (idx = 0; idx < MEDIA_CONTENT_GROUP_MAX; idx++) {
1212 ret = media_group_get_group_count_from_db(g_filter, idx, &group_count);
1213 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1214 test_filter_destroy();
1215 content_error("media_group_get_group_count_from_db fail. ret=[%d] idx=[%d]", ret, idx);
1218 content_debug("[%2d]group_count [%d]", idx, group_count);
1221 ret = media_group_foreach_group_from_db(g_filter, idx, group_list_cb, &idx);
1222 if (ret != MEDIA_CONTENT_ERROR_NONE)
1223 content_error("media_group_foreach_group_from_db failed: %d", ret);
1225 ret = test_filter_destroy();
1230 int test_update_operation()
1232 int ret = MEDIA_CONTENT_ERROR_NONE;
1234 media_info_h media_handle = NULL;
1235 GList *all_item_list = NULL;
1237 /* Get all item list */
1238 ret = media_info_foreach_media_from_db(NULL, gallery_media_item_cb, &all_item_list);
1239 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1240 content_error("media_info_foreach_media_from_db failed: %d", ret);
1243 content_debug("media_info_foreach_media_from_db success");
1245 for (i = 0; i < g_list_length(all_item_list); i++) {
1246 media_handle = (media_info_h)g_list_nth_data(all_item_list, i);
1247 get_media_meta(media_handle);
1251 return MEDIA_CONTENT_ERROR_NONE;
1254 int test_insert(void)
1256 int ret = MEDIA_CONTENT_ERROR_NONE;
1257 const char *path = tzplatform_mkpath(TZ_USER_IMAGES, "Default.jpg");
1259 const char *path = tzplatform_mkpath(TZ_USER_DOCUMENTS, "other.txt"));
1262 media_info_h media_item = NULL;
1263 content_debug("\n============DB Insert Test============\n\n");
1265 ret = media_info_insert_to_db(path, &media_item);
1267 if ((ret == MEDIA_CONTENT_ERROR_NONE) && (media_item != NULL)) {
1268 content_debug("Insertion is success");
1270 content_error("Insertion is failed");
1271 ret = media_info_destroy(media_item);
1275 char *media_id = NULL;
1277 ret = media_info_get_media_id(media_item, &media_id);
1278 if (ret != MEDIA_CONTENT_ERROR_NONE)
1279 content_error("media_info_get_media_id failed: %d", ret);
1281 content_debug("Media ID: %s", media_id);
1283 SAFE_FREE(media_id);
1285 ret = media_info_destroy(media_item);
1286 if (ret != MEDIA_CONTENT_ERROR_NONE)
1287 content_error("media_info_destroy failed: %d", ret);
1294 int ret = MEDIA_CONTENT_ERROR_NONE;
1295 const char *move_media_id = "60aea677-4742-408e-b5f7-f2628062d06d";
1296 const char *dst_path = tzplatform_mkpath(TZ_USER_IMAGES, "XX/Default1.jpg");
1297 media_info_h move_media = NULL;
1299 ret = media_info_get_media_from_db(move_media_id, &move_media);
1300 if (ret == MEDIA_CONTENT_ERROR_NONE)
1301 content_debug("media_info_get_media_from_db success");
1303 content_error("media_info_get_media_from_db failed: %d", ret);
1305 content_debug("\n============DB Move Test============\n\n");
1308 ret = media_info_move_to_db(move_media, dst_path);
1310 if (ret == MEDIA_CONTENT_ERROR_NONE)
1311 content_debug("Move is success");
1313 content_error("Move is failed");
1315 ret = media_info_destroy(move_media);
1317 content_debug("There is no item : %s", move_media_id);
1323 int test_create_thumbnail(const char *path)
1325 int ret = MEDIA_CONTENT_ERROR_NONE;
1327 char *thumb_path = NULL;
1329 ret = media_info_insert_to_db(path, &media);
1330 content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "media_info_insert_to_db failed [%d]", ret);
1332 ret = media_info_generate_thumbnail(media);
1333 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1334 content_error("media_info_generate_thumbnail failed [%d]", ret);
1338 ret = media_info_get_thumbnail_path(media, &thumb_path);
1339 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1340 content_error("media_info_get_thumbnail_path failed [%d]", ret);
1344 content_debug("Thumbnail Path [%s]", thumb_path);
1349 media_info_destroy(media);
1353 int test_ebook_text_finder(const char *keyword)
1355 int ret = MEDIA_CONTENT_ERROR_NONE;
1356 char **book_path_list = NULL;
1357 unsigned int book_path_len = 0;
1359 media_info_h media = NULL;
1360 book_meta_h book = NULL;
1361 char *s_value = NULL;
1362 long long ms_time = 0;
1363 struct timeval start_time;
1364 struct timeval end_time;
1366 gettimeofday(&start_time, NULL);
1368 ret = book_meta_get_path_with_keyword(keyword, &book_path_list, &book_path_len);
1369 if (ret == MEDIA_CONTENT_ERROR_NONE)
1370 content_debug("book_meta_get_path_with_keyword is success");
1372 content_error("book_meta_get_path_with_keyword is failed");
1374 gettimeofday(&end_time, NULL);
1376 for (i = 0; i < book_path_len; i++) {
1377 ret = media_info_get_media_from_db_by_path(book_path_list[i], &media);
1378 if (ret != MEDIA_CONTENT_ERROR_NONE)
1381 content_debug("===============================");
1382 content_debug("[%d] %s", i, book_path_list[i]);
1383 content_debug("===============================");
1384 media_info_get_title(media, &s_value);
1385 content_debug("Title : %s", s_value);
1389 ret = media_info_get_book(media, &book);
1390 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1391 media_info_destroy(media);
1395 ret = book_meta_get_author(book, &s_value);
1396 if (ret == MEDIA_CONTENT_ERROR_NONE && s_value) {
1397 content_debug("Author : %s", s_value);
1402 ret = book_meta_get_date(book, &s_value);
1403 if (ret == MEDIA_CONTENT_ERROR_NONE && s_value) {
1404 content_debug("Date : %s", s_value);
1409 content_debug("===============================");
1410 ret = book_meta_destroy(book);
1411 if (ret != MEDIA_CONTENT_ERROR_NONE)
1412 content_error("book_meta_destroy failed");
1414 ret = media_info_destroy(media);
1415 if (ret != MEDIA_CONTENT_ERROR_NONE)
1416 content_error("media_info_destroy failed");
1418 g_free(book_path_list[i]);
1421 ms_time = (end_time.tv_sec * 1000LL + end_time.tv_usec / 1000) - (start_time.tv_sec * 1000LL + start_time.tv_usec/ 1000);
1422 content_debug("Search Time [%lld]", ms_time);
1424 g_free(book_path_list);
1428 int test_disconnect_database(void)
1430 int ret = MEDIA_CONTENT_ERROR_NONE;
1431 content_debug("\n============DB Disconnection Test============\n\n");
1433 ret = media_content_disconnect();
1435 if (ret == MEDIA_CONTENT_ERROR_NONE)
1436 content_debug("disconnection is success");
1438 content_error("disconnection is failed");
1443 static int g_total_photo_size = 0;
1444 static int g_total_video_size = 0;
1445 static int g_total_mp3_size = 0;
1446 static int g_total_voice_memo_size = 0;
1448 bool dft_cb(media_info_h media, void *user_data)
1450 unsigned long long file_size = 0;
1451 media_content_type_e media_type = -1;
1452 char *mime_type = NULL;
1453 int ret = MEDIA_CONTENT_ERROR_NONE;
1458 ret = media_info_get_media_type(media, &media_type);
1459 if (ret != MEDIA_CONTENT_ERROR_NONE)
1460 content_error("media_info_get_media_type failed: %d", ret);
1461 ret = media_info_get_size(media, &file_size);
1462 if (ret != MEDIA_CONTENT_ERROR_NONE)
1463 content_error("media_info_get_size failed: %d", ret);
1464 ret = media_info_get_mime_type(media, &mime_type);
1465 if (ret != MEDIA_CONTENT_ERROR_NONE)
1466 content_error("media_info_get_mime_type failed: %d", ret);
1468 if (media_type == MEDIA_CONTENT_TYPE_IMAGE)
1469 g_total_photo_size += file_size;
1470 else if (media_type == MEDIA_CONTENT_TYPE_VIDEO)
1471 g_total_video_size += file_size;
1472 else if (media_type == MEDIA_CONTENT_TYPE_SOUND)
1473 g_total_voice_memo_size += file_size;
1474 else if (media_type == MEDIA_CONTENT_TYPE_MUSIC) {
1475 if ((mime_type != NULL) && (!strcmp("audio/mpeg", mime_type)))
1476 g_total_mp3_size += file_size;
1478 g_total_voice_memo_size += file_size;
1480 content_debug("invalid media_type");
1482 SAFE_FREE(mime_type);
1490 int ret = MEDIA_CONTENT_ERROR_NONE;
1491 content_debug("\n============DFT_test============\n\n");
1493 filter_h filter = NULL;
1496 /*MEDIA_TYPE 0-image, 1-video, 2-sound, 3-music, 4-other*/
1498 ret = media_filter_create(&filter);
1501 content_debug("[Internal Memory]\n");
1502 /*1. Photo ============================================================*/
1503 ret = media_filter_set_condition(filter, "MEDIA_TYPE=0", MEDIA_CONTENT_COLLATE_DEFAULT);
1506 ret = media_info_get_media_count_from_db(filter, &media_cnt);
1507 content_debug("Photo count = [%d]\n", media_cnt);
1510 ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
1511 content_debug("Photo size = [%d]\n", g_total_photo_size);
1513 /*2. Video ============================================================*/
1514 ret = media_filter_set_condition(filter, "MEDIA_TYPE=1", MEDIA_CONTENT_COLLATE_DEFAULT);
1517 ret = media_info_get_media_count_from_db(filter, &media_cnt);
1518 content_debug("Video count = [%d]\n", media_cnt);
1521 ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
1522 content_debug("Video size = [%d]\n", g_total_video_size);
1524 /*3. MP3 ============================================================*/
1525 ret = media_filter_set_condition(filter, "MEDIA_TYPE=3 AND MEDIA_MIME_TYPE=\"audio/mpeg\"", MEDIA_CONTENT_COLLATE_DEFAULT);
1528 ret = media_info_get_media_count_from_db(filter, &media_cnt);
1529 content_debug("MP3 count = [%d]\n", media_cnt);
1532 ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
1533 content_debug("MP3 size = [%d]\n", g_total_mp3_size);
1535 /*4. Voice Memo ============================================================*/
1536 ret = media_filter_set_condition(filter, "(MEDIA_MIME_TYPE=\"audio/AMR\" OR MEDIA_MIME_TYPE=\"audio/mp4\")", MEDIA_CONTENT_COLLATE_DEFAULT);
1538 /*Get Voice Memo Count*/
1539 ret = media_info_get_media_count_from_db(filter, &media_cnt);
1540 content_debug("Voice Memo count = [%d]\n", media_cnt);
1542 /*Get Voice Memo Size*/
1543 ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
1544 content_debug("Voice Memo size = [%d]\n", g_total_voice_memo_size);
1546 g_total_photo_size = 0;
1547 g_total_video_size = 0;
1548 g_total_mp3_size = 0;
1549 g_total_voice_memo_size = 0;
1552 content_debug("\n[External Memory]\n");
1553 /*1. Photo ============================================================*/
1554 ret = media_filter_set_condition(filter, "MEDIA_TYPE=0", MEDIA_CONTENT_COLLATE_DEFAULT);
1557 ret = media_info_get_media_count_from_db(filter, &media_cnt);
1558 content_debug("Photo count = [%d]\n", media_cnt);
1561 ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
1562 content_debug("Photo size = [%d]\n", g_total_photo_size);
1564 /*2. Video ============================================================*/
1565 ret = media_filter_set_condition(filter, "MEDIA_TYPE=1", MEDIA_CONTENT_COLLATE_DEFAULT);
1568 ret = media_info_get_media_count_from_db(filter, &media_cnt);
1569 content_debug("Video count = [%d]\n", media_cnt);
1572 ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
1573 content_debug("Video size = [%d]\n", g_total_video_size);
1575 /*3. MP3 ============================================================*/
1576 ret = media_filter_set_condition(filter, "MEDIA_TYPE=3 AND MEDIA_MIME_TYPE=\"audio/mpeg\"", MEDIA_CONTENT_COLLATE_DEFAULT);
1579 ret = media_info_get_media_count_from_db(filter, &media_cnt);
1580 content_debug("MP3 count = [%d]\n", media_cnt);
1583 ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
1584 content_debug("MP3 size = [%d]\n", g_total_mp3_size);
1586 /*4. Voice Memo ============================================================*/
1587 ret = media_filter_set_condition(filter, "(MEDIA_MIME_TYPE=\"audio/AMR\" OR MEDIA_MIME_TYPE=\"audio/mp4\")", MEDIA_CONTENT_COLLATE_DEFAULT);
1589 /*Get Voice Memo Count*/
1590 ret = media_info_get_media_count_from_db(filter, &media_cnt);
1591 content_debug("Voice Memo count = [%d]\n", media_cnt);
1593 /*Get Voice Memo Size*/
1594 ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
1595 content_debug("Voice Memo size = [%d]\n", g_total_voice_memo_size);
1596 ret = media_filter_destroy(filter);
1601 void insert_batch_cb(media_content_error_e error, void * user_data)
1603 content_debug("media_info_insert_batch_to_db completed!\n");
1606 int test_batch_operations()
1610 char *file_list[10];
1612 for (i = 0; i < 10; i++) {
1613 file_list[i] = g_strdup_printf("%s%d.jpg", tzplatform_mkpath(TZ_USER_CONTENT, "test/image"), i+1);
1614 content_debug("File : %s\n", file_list[i]);
1617 ret = media_info_insert_batch_to_db((const char **)file_list, 10, insert_batch_cb, NULL);
1618 if (ret != MEDIA_CONTENT_ERROR_NONE)
1619 content_error("media_info_insert_batch_to_db failed : %d\n", ret);
1621 for (i = 0; i < 10; i++)
1622 g_free(file_list[i]);
1627 void _scan_cb(media_content_error_e err, void *user_data)
1629 content_debug("scan callback is called : %d\n", err);
1630 g_main_loop_quit(g_loop);
1635 int test_scan_file()
1639 const char *file_path = tzplatform_mkpath(TZ_USER_CONTENT, "test/image1.jpg");
1640 ret = media_content_scan_file(file_path);
1641 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1642 content_error("Fail to media_content_scan_file : %d", ret);
1649 gboolean test_scan_dir_start(gpointer data)
1653 const char *dir_path = tzplatform_getenv(TZ_USER_CONTENT);
1655 ret = media_content_scan_folder(dir_path, TRUE, _scan_cb, NULL);
1657 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1658 content_error("Fail to test_scan_dir_start : %d", ret);
1665 gboolean cancel_scan_dir_start(gpointer data)
1667 int ret = MEDIA_CONTENT_ERROR_NONE;
1669 const char *dir_path = tzplatform_getenv(TZ_USER_IMAGES);
1671 ret = media_content_cancel_scan_folder(dir_path);
1673 if (ret == MEDIA_CONTENT_ERROR_NONE)
1674 content_debug("media_content_cancel_scan_folder is success");
1676 content_error("media_content_cancel_scan_folder is failed");
1681 int test_scan_dir(int cancel)
1683 GSource *source = NULL;
1684 GMainContext *context = NULL;
1686 g_loop = g_main_loop_new(NULL, FALSE);
1687 context = g_main_loop_get_context(g_loop);
1688 source = g_idle_source_new();
1689 g_source_set_callback(source, test_scan_dir_start, NULL, NULL);
1690 g_source_attach(source, context);
1693 GSource *cancel_src = NULL;
1694 cancel_src = g_idle_source_new();
1695 g_source_set_callback(cancel_src, cancel_scan_dir_start, NULL, NULL);
1696 g_source_attach(cancel_src, context);
1699 g_main_loop_run(g_loop);
1700 g_main_loop_unref(g_loop);
1705 void _noti_cb(media_content_error_e error,
1707 media_content_db_update_item_type_e update_item,
1708 media_content_db_update_type_e update_type,
1709 media_content_type_e media_type,
1716 content_debug("noti success! : %d\n", error);
1718 content_debug("error occurred! : %d\n", error);
1720 content_debug("Noti from PID(%d)\n", pid);
1722 if (update_item == MEDIA_ITEM_FILE)
1723 content_debug("Noti item : MEDIA_ITEM_FILE\n");
1724 else if (update_item == MEDIA_ITEM_DIRECTORY)
1725 content_debug("Noti item : MEDIA_ITEM_DIRECTORY\n");
1727 if (update_type == MEDIA_CONTENT_INSERT)
1728 content_debug("Noti type : MEDIA_CONTENT_INSERT\n");
1729 else if (update_type == MEDIA_CONTENT_DELETE)
1730 content_debug("Noti type : MEDIA_CONTENT_DELETE\n");
1731 else if (update_type == MEDIA_CONTENT_UPDATE)
1732 content_debug("Noti type : MEDIA_CONTENT_UPDATE\n");
1734 content_debug("content type : %d\n", media_type);
1737 content_debug("path : %s\n", path);
1739 content_debug("path not\n");
1742 content_debug("uuid : %s\n", uuid);
1744 content_debug("uuid not\n");
1747 content_debug("mime_type : %s\n", mime_type);
1749 content_debug("mime not\n");
1751 if (user_data) content_debug("String : %s\n", (char *)user_data);
1756 void _noti_cb_2(media_content_error_e error,
1758 media_content_db_update_item_type_e update_item,
1759 media_content_db_update_type_e update_type,
1760 media_content_type_e media_type,
1767 content_debug("noti_2 success! : %d\n", error);
1769 content_debug("error occurred! : %d\n", error);
1771 content_debug("Noti_2 from PID(%d)\n", pid);
1773 g_main_loop_quit(g_loop);
1777 static media_content_noti_h noti_h;
1778 static media_content_noti_h noti_h_2;
1780 gboolean _send_noti_operations(gpointer data)
1782 int ret = MEDIA_CONTENT_ERROR_NONE;
1784 /* First of all, noti subscription */
1785 char *user_str = strdup("hi");
1786 media_content_add_db_updated_cb(_noti_cb, (void*)user_str, ¬i_h);
1787 media_content_add_db_updated_cb(_noti_cb_2, (void*)user_str, ¬i_h_2);
1789 /* media_info_insert_to_db */
1790 media_info_h media_item = NULL;
1791 const char *path = tzplatform_mkpath(TZ_USER_CONTENT, "test/image1.jpg");
1793 ret = media_info_insert_to_db(path, &media_item);
1794 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1795 content_error("media_info_insert_to_db failed : %d", ret);
1796 media_info_destroy(media_item);
1800 content_debug("media_info_insert_to_db success");
1802 media_content_remove_db_updated_cb(noti_h);
1804 media_info_destroy(media_item);
1811 int ret = MEDIA_CONTENT_ERROR_NONE;
1812 GSource *source = NULL;
1813 GMainContext *context = NULL;
1815 g_loop = g_main_loop_new(NULL, FALSE);
1816 context = g_main_loop_get_context(g_loop);
1817 source = g_idle_source_new();
1818 g_source_set_callback(source, _send_noti_operations, NULL, NULL);
1819 g_source_attach(source, context);
1821 g_main_loop_run(g_loop);
1822 g_main_loop_unref(g_loop);
1824 test_filter_destroy();
1825 media_content_remove_db_updated_cb(noti_h_2);
1829 #ifdef _USE_TVPD_MODE
1830 filter_h g_tv_filter = NULL;
1832 int test_tv_filter_create(void)
1834 content_debug("\n============Filter Create============\n\n");
1836 int ret = MEDIA_CONTENT_ERROR_NONE;
1838 ret = media_filter_create(&g_tv_filter);
1840 ret = media_filter_set_storage(g_tv_filter, "0a22a163-e634-4a2e-ba14-0469a969eea0");
1842 ret = media_filter_set_order(g_tv_filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_TITLE, MEDIA_CONTENT_COLLATE_DEFAULT);
1847 int test_tv_filter_destroy(void)
1849 content_debug("\n============Filter Destroy============\n\n");
1851 int ret = MEDIA_CONTENT_ERROR_NONE;
1853 ret = media_filter_destroy(g_tv_filter);
1858 bool pvr_item_cb(media_pvr_h pvr, void *user_data)
1860 int ret = MEDIA_CONTENT_ERROR_NONE;
1861 char *c_value = NULL;
1863 bool b_value = false;
1864 unsigned long long l_value = 0;
1867 content_debug("NO Item");
1871 ret = media_pvr_get_media_id(pvr, &c_value);
1872 if (ret != MEDIA_CONTENT_ERROR_NONE)
1873 content_error("Fail to media_pvr_get_media_id");
1874 content_debug("media_id [%s]", c_value);
1877 ret = media_pvr_get_channel_name(pvr, &c_value);
1878 if (ret != MEDIA_CONTENT_ERROR_NONE)
1879 content_error("Fail to media_pvr_get_channel_name");
1880 content_debug("channel_name [%s]", c_value);
1883 ret = media_pvr_get_program_title(pvr, &c_value);
1884 if (ret != MEDIA_CONTENT_ERROR_NONE)
1885 content_error("Fail to media_pvr_get_program_title");
1886 content_debug("program_title [%s]", c_value);
1889 ret = media_pvr_get_program_crid(pvr, &c_value);
1890 if (ret != MEDIA_CONTENT_ERROR_NONE)
1891 content_error("Fail to media_pvr_get_program_crid");
1892 content_debug("program_crid [%s]", c_value);
1895 ret = media_pvr_get_guidance(pvr, &c_value);
1896 if (ret != MEDIA_CONTENT_ERROR_NONE)
1897 content_error("Fail to media_pvr_get_guidance");
1898 content_debug("guidance [%s]", c_value);
1901 ret = media_pvr_get_synopsis(pvr, &c_value);
1902 if (ret != MEDIA_CONTENT_ERROR_NONE)
1903 content_error("Fail to media_pvr_get_synopsis");
1904 content_debug("synopsis [%s]", c_value);
1907 ret = media_pvr_get_genre(pvr, &c_value);
1908 if (ret != MEDIA_CONTENT_ERROR_NONE)
1909 content_error("Fail to media_pvr_get_synopsis");
1910 content_debug("genre [%s]", c_value);
1913 ret = media_pvr_get_language(pvr, &c_value);
1914 if (ret != MEDIA_CONTENT_ERROR_NONE)
1915 content_error("Fail to media_pvr_get_language");
1916 content_debug("language [%s]", c_value);
1919 ret = media_pvr_get_path(pvr, &c_value);
1920 if (ret != MEDIA_CONTENT_ERROR_NONE)
1921 content_error("Fail to media_pvr_get_path");
1922 content_debug("path [%s]", c_value);
1925 ret = media_pvr_get_storage_id(pvr, &c_value);
1926 if (ret != MEDIA_CONTENT_ERROR_NONE)
1927 content_error("Fail to media_pvr_get_storage_id");
1928 content_debug("storage_id [%s]", c_value);
1931 ret = media_pvr_get_size(pvr, &l_value);
1932 if (ret != MEDIA_CONTENT_ERROR_NONE)
1933 content_error("Fail to media_pvr_get_size");
1934 content_debug("size [%lld]", l_value);
1936 ret = media_pvr_get_timezone(pvr, &i_value);
1937 if (ret != MEDIA_CONTENT_ERROR_NONE)
1938 content_error("Fail to media_pvr_get_timezone");
1939 content_debug("timezone [%d]", i_value);
1941 ret = media_pvr_get_ptc(pvr, &i_value);
1942 if (ret != MEDIA_CONTENT_ERROR_NONE)
1943 content_error("Fail to media_pvr_get_ptc");
1944 content_debug("ptc [%d]", i_value);
1946 ret = media_pvr_get_major(pvr, &i_value);
1947 if (ret != MEDIA_CONTENT_ERROR_NONE)
1948 content_error("Fail to media_pvr_get_major");
1949 content_debug("[%d]", i_value);
1951 ret = media_pvr_get_minor(pvr, &i_value);
1952 if (ret != MEDIA_CONTENT_ERROR_NONE)
1953 content_error("Fail to media_pvr_get_minor");
1954 content_debug("minor [%d]", i_value);
1956 ret = media_pvr_get_channel_type(pvr, &i_value);
1957 if (ret != MEDIA_CONTENT_ERROR_NONE)
1958 content_error("Fail to media_pvr_get_channel_type");
1959 content_debug("channel_type [%d]", i_value);
1961 ret = media_pvr_get_program_num(pvr, &i_value);
1962 if (ret != MEDIA_CONTENT_ERROR_NONE)
1963 content_error("Fail to media_pvr_get_program_num");
1964 content_debug("program_num [%d]", i_value);
1966 unsigned int ui_value = 0;
1967 ret = media_pvr_get_service_profile(pvr, &ui_value);
1968 if (ret != MEDIA_CONTENT_ERROR_NONE)
1969 content_error("Fail to media_pvr_get_service_profile");
1970 content_debug("service_profile [%u]", ui_value);
1972 ret = media_pvr_get_duration(pvr, &i_value);
1973 if (ret != MEDIA_CONTENT_ERROR_NONE)
1974 content_error("Fail to media_pvr_get_duration");
1975 content_debug("duration [%d]", i_value);
1977 ret = media_pvr_get_embargo_time(pvr, &i_value);
1978 if (ret != MEDIA_CONTENT_ERROR_NONE)
1979 content_error("Fail to media_pvr_get_embargo_time");
1980 content_debug("embargo_time [%d]", i_value);
1982 ret = media_pvr_get_expiry_time(pvr, &i_value);
1983 if (ret != MEDIA_CONTENT_ERROR_NONE)
1984 content_error("Fail to media_pvr_get_expiry_time");
1985 content_debug("expiry_time [%d]", i_value);
1987 ret = media_pvr_get_parental_rating(pvr, &i_value);
1988 if (ret != MEDIA_CONTENT_ERROR_NONE)
1989 content_error("Fail to media_pvr_get_parental_rating");
1990 content_debug("parental_rating [%d]", i_value);
1992 ret = media_pvr_get_start_time(pvr, &i_value);
1993 if (ret != MEDIA_CONTENT_ERROR_NONE)
1994 content_error("Fail to media_pvr_get_start_time");
1995 content_debug("start_time [%d]", i_value);
1997 ret = media_pvr_get_program_start_time(pvr, &i_value);
1998 if (ret != MEDIA_CONTENT_ERROR_NONE)
1999 content_error("Fail to media_pvr_get_program_start_time");
2000 content_debug("program_start_time [%d]", i_value);
2002 ret = media_pvr_get_program_end_time(pvr, &i_value);
2003 if (ret != MEDIA_CONTENT_ERROR_NONE)
2004 content_error("Fail to media_pvr_get_program_end_time");
2005 content_debug("program_end_time [%d]", i_value);
2007 ret = media_pvr_get_program_date(pvr, &i_value);
2008 if (ret != MEDIA_CONTENT_ERROR_NONE)
2009 content_error("Fail to media_pvr_get_program_date");
2010 content_debug("program_date [%d]", i_value);
2012 ret = media_pvr_get_timer_record(pvr, &b_value);
2013 if (ret != MEDIA_CONTENT_ERROR_NONE)
2014 content_error("Fail to media_pvr_get_timer_record");
2015 content_debug("timer_record [%d]", b_value);
2017 ret = media_pvr_get_series_record(pvr, &b_value);
2018 if (ret != MEDIA_CONTENT_ERROR_NONE)
2019 content_error("Fail to media_pvr_get_series_record");
2020 content_debug("series_record [%d]", b_value);
2022 ret = media_pvr_get_hd(pvr, &i_value);
2023 if (ret != MEDIA_CONTENT_ERROR_NONE)
2024 content_error("Fail to media_pvr_get_hd");
2025 content_debug("hd [%d]", i_value);
2027 ret = media_pvr_get_subtitle(pvr, &b_value);
2028 if (ret != MEDIA_CONTENT_ERROR_NONE)
2029 content_error("Fail to media_pvr_get_subtitle");
2030 content_debug("subtitle [%d]", b_value);
2032 ret = media_pvr_get_ttx(pvr, &b_value);
2033 if (ret != MEDIA_CONTENT_ERROR_NONE)
2034 content_error("Fail to media_pvr_get_ttx");
2035 content_debug("ttx [%d]", b_value);
2037 ret = media_pvr_get_ad(pvr, &b_value);
2038 if (ret != MEDIA_CONTENT_ERROR_NONE)
2039 content_error("Fail to media_pvr_get_ad");
2040 content_debug("ad [%d]", b_value);
2042 ret = media_pvr_get_hard_of_hearing_radio(pvr, &b_value);
2043 if (ret != MEDIA_CONTENT_ERROR_NONE)
2044 content_error("Fail to media_pvr_get_hard_of_hearing_radio");
2045 content_debug("hard_of_hearing_radio [%d]", b_value);
2047 ret = media_pvr_get_data_service(pvr, &b_value);
2048 if (ret != MEDIA_CONTENT_ERROR_NONE)
2049 content_error("Fail to media_pvr_get_data_service");
2050 content_debug("data_service [%d]", b_value);
2052 ret = media_pvr_get_content_lock(pvr, &b_value);
2053 if (ret != MEDIA_CONTENT_ERROR_NONE)
2054 content_error("Fail to media_pvr_get_content_lock");
2055 content_debug("content_lock [%d]", b_value);
2057 ret = media_pvr_get_content_watch(pvr, &b_value);
2058 if (ret != MEDIA_CONTENT_ERROR_NONE)
2059 content_error("Fail to media_pvr_get_content_watch");
2060 content_debug("content_watch [%d]", b_value);
2062 ret = media_pvr_get_has_audio_only(pvr, &b_value);
2063 if (ret != MEDIA_CONTENT_ERROR_NONE)
2064 content_error("Fail to media_pvr_get_has_audio_only");
2065 content_debug("has_audio_only [%d]", b_value);
2067 ret = media_pvr_get_is_local_record(pvr, &b_value);
2068 if (ret != MEDIA_CONTENT_ERROR_NONE)
2069 content_error("Fail to media_pvr_get_is_local_record");
2070 content_debug("is_local_record [%d]", b_value);
2072 ret = media_pvr_get_resolution(pvr, (media_pvr_resolution_e*)&i_value);
2073 if (ret != MEDIA_CONTENT_ERROR_NONE)
2074 content_error("Fail to media_pvr_get_resolution");
2075 content_debug("resolution [%d]", i_value);
2077 ret = media_pvr_get_aspectratio(pvr, (media_pvr_aspectratio_e*)&i_value);
2078 if (ret != MEDIA_CONTENT_ERROR_NONE)
2079 content_error("Fail to media_pvr_get_aspectratio");
2080 content_debug("aspectratio [%d]", i_value);
2082 ret = media_pvr_get_highlight(pvr, &b_value);
2083 if (ret != MEDIA_CONTENT_ERROR_NONE)
2084 content_error("Fail to media_pvr_get_highlight");
2085 content_debug("highlight [%d]", b_value);
2093 int ret = MEDIA_CONTENT_ERROR_NONE;
2094 int media_count = 0;
2096 content_debug("\n============PVR Test============\n\n");
2098 test_tv_filter_create();
2100 ret = media_pvr_get_media_count_from_db(g_tv_filter, &media_count);
2101 if (ret != MEDIA_CONTENT_ERROR_NONE)
2102 content_error("media_pvr_get_media_count_from_db failed: %d", ret);
2104 content_debug("media_count : [%d]", media_count);
2106 ret = media_pvr_foreach_media_from_db(g_tv_filter, pvr_item_cb, NULL);
2107 if (ret != MEDIA_CONTENT_ERROR_NONE)
2108 content_error("media_pvr_foreach_media_from_db is failed");
2110 test_tv_filter_destroy();
2115 int test_pvr_update_db(void)
2117 int ret = MEDIA_CONTENT_ERROR_NONE;
2118 media_pvr_h pvr = NULL;
2120 ret = media_pvr_get_pvr_from_db("ff9b5a9a-a7b4-47f4-8255-84e007e25f13", &pvr);
2121 if (ret != MEDIA_CONTENT_ERROR_NONE)
2122 content_error("media_pvr_get_pvr_from_db failed: %d", ret);
2124 ret = media_pvr_set_content_lock(pvr, TRUE);
2125 if (ret != MEDIA_CONTENT_ERROR_NONE)
2126 content_error("Fail to media_pvr_set_content_lock");
2128 ret = media_pvr_set_content_watch(pvr, TRUE);
2129 if (ret != MEDIA_CONTENT_ERROR_NONE)
2130 content_error("Fail to media_pvr_set_content_watch");
2132 ret = media_pvr_set_program_title(pvr, "TEST TITLE");
2133 if (ret != MEDIA_CONTENT_ERROR_NONE)
2134 content_error("Fail to media_pvr_set_program_title");
2136 ret = media_pvr_set_highlight(pvr, TRUE);
2137 if (ret != MEDIA_CONTENT_ERROR_NONE)
2138 content_error("Fail to media_pvr_set_highlight");
2140 ret = media_pvr_update_to_db(pvr);
2141 if (ret != MEDIA_CONTENT_ERROR_NONE)
2142 content_error("Fail to media_pvr_update_to_db");
2145 media_pvr_destroy(pvr);
2151 int main(int argc, char *argv[])
2153 int ret = MEDIA_CONTENT_ERROR_NONE;
2155 content_debug("--- content manager test start ---\n\n");
2157 ret = test_connect_database();
2158 if (ret != MEDIA_CONTENT_ERROR_NONE)
2159 return MEDIA_CONTENT_ERROR_NONE;
2160 #ifdef _USE_TVPD_MODE
2163 test_pvr_update_db();
2170 ret = test_ebook_text_finder(argv[1]);
2171 if (ret != MEDIA_CONTENT_ERROR_NONE)
2176 if (ret != MEDIA_CONTENT_ERROR_NONE)
2179 ret = test_gallery_scenario();
2180 if (ret != MEDIA_CONTENT_ERROR_NONE)
2183 ret = test_get_all_music_files();
2184 if (ret != MEDIA_CONTENT_ERROR_NONE)
2187 ret = test_media_info_operation();
2188 if (ret != MEDIA_CONTENT_ERROR_NONE)
2191 ret = test_folder_operation();
2192 if (ret != MEDIA_CONTENT_ERROR_NONE)
2195 ret = test_playlist_operation();
2196 if (ret != MEDIA_CONTENT_ERROR_NONE)
2199 ret = test_bookmark_operation();
2200 if (ret != MEDIA_CONTENT_ERROR_NONE)
2203 ret = test_album_list();
2204 if (ret != MEDIA_CONTENT_ERROR_NONE)
2207 ret = test_group_operation();
2208 if (ret != MEDIA_CONTENT_ERROR_NONE)
2211 ret = test_update_operation();
2212 if (ret != MEDIA_CONTENT_ERROR_NONE)
2215 ret = test_insert();
2216 if (ret != MEDIA_CONTENT_ERROR_NONE)
2220 if (ret != MEDIA_CONTENT_ERROR_NONE)
2224 ret = test_create_thumbnail(argv[1]);
2225 if (ret != MEDIA_CONTENT_ERROR_NONE)
2230 if (ret != MEDIA_CONTENT_ERROR_NONE)
2233 ret = test_batch_operations();
2234 if (ret != MEDIA_CONTENT_ERROR_NONE)
2235 return MEDIA_CONTENT_ERROR_NONE;
2237 ret = test_scan_file();
2238 if (ret != MEDIA_CONTENT_ERROR_NONE)
2239 return MEDIA_CONTENT_ERROR_NONE;
2241 ret = test_scan_dir(true);
2242 if (ret != MEDIA_CONTENT_ERROR_NONE)
2243 return MEDIA_CONTENT_ERROR_NONE;
2246 if (ret != MEDIA_CONTENT_ERROR_NONE)
2247 return MEDIA_CONTENT_ERROR_NONE;
2249 ret = test_playlist_operation_v2();
2250 if (ret != MEDIA_CONTENT_ERROR_NONE)
2251 return MEDIA_CONTENT_ERROR_NONE;
2253 ret = test_bookmark_operation_v2();
2254 if (ret != MEDIA_CONTENT_ERROR_NONE)
2255 return MEDIA_CONTENT_ERROR_NONE;
2258 ret = test_disconnect_database();
2259 if (ret != MEDIA_CONTENT_ERROR_NONE)
2262 content_debug("--- content manager test end ---\n");