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>
26 #include <tzplatform_config.h>
27 #include <media_content_internal.h>
30 static filter_h g_filter = NULL;
31 static filter_h g_filter_g = NULL; /*filter for group like folder, tag, playlist, album, year ... */
33 static GMainLoop *g_loop = NULL;
35 static int g_media_cnt = 0;
37 #define test_audio_id "3304285f-1070-41af-8b4e-f0086cc768f3"
38 #define test_video_id "53c43e7e-53d2-4194-80a6-55d5dcde0def"
39 #define test_image_id "db1c184c-6f31-43b4-b924-8c00ac5b6197"
41 static void get_audio_meta(audio_meta_h audio)
45 int ret = MEDIA_CONTENT_ERROR_NONE;
47 content_debug("=== audio meta ===");
49 ret = audio_meta_get_media_id(audio, &c_value);
50 if (ret != MEDIA_CONTENT_ERROR_NONE)
51 content_error("error when get meta : [%d]", ret);
54 content_debug("audio_id : [%s]", c_value);
57 ret = audio_meta_get_album(audio, &c_value);
58 if (ret != MEDIA_CONTENT_ERROR_NONE)
59 content_error("error when get meta : [%d]", ret);
62 content_debug("album : [%s]", c_value);
65 ret = audio_meta_get_artist(audio, &c_value);
66 if (ret != MEDIA_CONTENT_ERROR_NONE)
67 content_error("error when get meta : [%d]", ret);
70 content_debug("artist : [%s]", c_value);
73 ret = audio_meta_get_album_artist(audio, &c_value);
74 if (ret != MEDIA_CONTENT_ERROR_NONE)
75 content_error("error when get meta : [%d]", ret);
78 content_debug("album_artist : [%s]", c_value);
81 ret = audio_meta_get_genre(audio, &c_value);
82 if (ret != MEDIA_CONTENT_ERROR_NONE)
83 content_error("error when get meta : [%d]", ret);
86 content_debug("genre : [%s]", c_value);
89 ret = audio_meta_get_composer(audio, &c_value);
90 if (ret != MEDIA_CONTENT_ERROR_NONE)
91 content_error("error when get meta : [%d]", ret);
94 content_debug("composer : [%s]", c_value);
97 ret = audio_meta_get_year(audio, &c_value);
98 if (ret != MEDIA_CONTENT_ERROR_NONE)
99 content_error("error when get meta : [%d]", ret);
102 content_debug("year : [%s]", c_value);
105 ret = audio_meta_get_recorded_date(audio, &c_value);
106 if (ret != MEDIA_CONTENT_ERROR_NONE)
107 content_error("error when get meta : [%d]", ret);
110 content_debug("recorded_date : [%s]", c_value);
113 ret = audio_meta_get_copyright(audio, &c_value);
114 if (ret != MEDIA_CONTENT_ERROR_NONE)
115 content_error("error when get meta : [%d]", ret);
118 content_debug("copyright : [%s]", c_value);
121 ret = audio_meta_get_track_num(audio, &c_value);
122 if (ret != MEDIA_CONTENT_ERROR_NONE)
123 content_error("error when get meta : [%d]", ret);
126 content_debug("track_num : [%s]", c_value);
129 ret = audio_meta_get_bit_rate(audio, &i_value);
130 if (ret != MEDIA_CONTENT_ERROR_NONE)
131 content_error("error when get meta : [%d]", ret);
133 content_debug("bitrate : [%d]", i_value);
135 ret = audio_meta_get_sample_rate(audio, &i_value);
136 if (ret != MEDIA_CONTENT_ERROR_NONE)
137 content_error("error when get meta : [%d]", ret);
139 content_debug("samplerate : [%d]", i_value);
141 ret = audio_meta_get_channel(audio, &i_value);
142 if (ret != MEDIA_CONTENT_ERROR_NONE)
143 content_error("error when get meta : [%d]", ret);
145 content_debug("channel : [%d]", i_value);
147 ret = audio_meta_get_duration(audio, &i_value);
148 if (ret != MEDIA_CONTENT_ERROR_NONE)
149 content_error("error when get meta : [%d]", ret);
151 content_debug("duration : [%d]", i_value);
155 static void get_video_meta(video_meta_h video)
157 char *c_value = NULL;
159 int ret = MEDIA_CONTENT_ERROR_NONE;
161 content_debug("=== video meta ===");
163 ret = video_meta_get_media_id(video, &c_value);
164 if (ret != MEDIA_CONTENT_ERROR_NONE)
165 content_error("error when get meta : [%d]", ret);
168 content_debug("video_id : [%s]", c_value);
171 ret = video_meta_get_album(video, &c_value);
172 if (ret != MEDIA_CONTENT_ERROR_NONE)
173 content_error("error when get meta : [%d]", ret);
176 content_debug("album : [%s]", c_value);
179 ret = video_meta_get_artist(video, &c_value);
180 if (ret != MEDIA_CONTENT_ERROR_NONE)
181 content_error("error when get meta : [%d]", ret);
184 content_debug("artist : [%s]", c_value);
187 ret = video_meta_get_album_artist(video, &c_value);
188 if (ret != MEDIA_CONTENT_ERROR_NONE)
189 content_error("error when get meta : [%d]", ret);
192 content_debug("album_artist : [%s]", c_value);
195 ret = video_meta_get_genre(video, &c_value);
196 if (ret != MEDIA_CONTENT_ERROR_NONE)
197 content_error("error when get meta : [%d]", ret);
200 content_debug("genre : [%s]", c_value);
203 ret = video_meta_get_composer(video, &c_value);
204 if (ret != MEDIA_CONTENT_ERROR_NONE)
205 content_error("error when get meta : [%d]", ret);
208 content_debug("omposer : [%s]", c_value);
211 ret = video_meta_get_year(video, &c_value);
212 if (ret != MEDIA_CONTENT_ERROR_NONE)
213 content_error("error when get meta : [%d]", ret);
216 content_debug("year : [%s]", c_value);
219 ret = video_meta_get_recorded_date(video, &c_value);
220 if (ret != MEDIA_CONTENT_ERROR_NONE)
221 content_error("error when get meta : [%d]", ret);
224 content_debug("recorded_date : [%s]", c_value);
227 ret = video_meta_get_copyright(video, &c_value);
228 if (ret != MEDIA_CONTENT_ERROR_NONE)
229 content_error("error when get meta : [%d]", ret);
232 content_debug("copyright : [%s]", c_value);
235 ret = video_meta_get_track_num(video, &c_value);
236 if (ret != MEDIA_CONTENT_ERROR_NONE)
237 content_error("error when get meta : [%d]", ret);
240 content_debug("track_num : [%s]", c_value);
243 ret = video_meta_get_bit_rate(video, &i_value);
244 if (ret != MEDIA_CONTENT_ERROR_NONE)
245 content_error("error when get meta : [%d]", ret);
247 content_debug("bitrate : [%d]", i_value);
249 ret = video_meta_get_duration(video, &i_value);
250 if (ret != MEDIA_CONTENT_ERROR_NONE)
251 content_error("error when get meta : [%d]", ret);
253 content_debug("duration : [%d]", i_value);
255 ret = video_meta_get_width(video, &i_value);
256 if (ret != MEDIA_CONTENT_ERROR_NONE)
257 content_error("error when get meta : [%d]", ret);
259 content_debug("width : [%d]", i_value);
261 ret = video_meta_get_height(video, &i_value);
262 if (ret != MEDIA_CONTENT_ERROR_NONE)
263 content_error("error when get meta : [%d]", ret);
265 content_debug("height : [%d]", i_value);
269 static void get_image_meta(image_meta_h image)
271 char *c_value = NULL;
273 media_content_orientation_e orientation;
274 int ret = MEDIA_CONTENT_ERROR_NONE;
276 content_debug("=== image meta ===");
278 ret = image_meta_get_width(image, &i_value);
279 if (ret != MEDIA_CONTENT_ERROR_NONE)
280 content_error("error image_meta_get_width : [%d]", ret);
282 content_debug("width : [%d]", i_value);
284 ret = image_meta_get_height(image, &i_value);
285 if (ret != MEDIA_CONTENT_ERROR_NONE)
286 content_error("error image_meta_get_height : [%d]", ret);
288 content_debug("height : [%d]", i_value);
290 ret = image_meta_get_orientation(image, &orientation);
291 if (ret != MEDIA_CONTENT_ERROR_NONE)
292 content_error("error image_meta_get_orientation : [%d]", ret);
294 content_debug("orientation : [%d]", orientation);
296 ret = image_meta_get_date_taken(image, &c_value);
297 if (ret != MEDIA_CONTENT_ERROR_NONE)
298 content_error("error image_meta_get_date_taken : [%d]", ret);
301 content_debug("date_taken : [%s]", c_value);
306 static void get_album_meta(media_album_h album)
308 char *c_value = NULL;
310 int ret = MEDIA_CONTENT_ERROR_NONE;
312 content_debug("=== album meta ===");
314 ret = media_album_get_album_id(album, &i_value);
315 if (ret != MEDIA_CONTENT_ERROR_NONE)
316 content_error("error media_album_get_album_id : [%d]", ret);
318 content_debug("album_id : [%d]", i_value);
320 ret = media_album_get_name(album, &c_value);
321 if (ret != MEDIA_CONTENT_ERROR_NONE)
322 content_error("error media_album_get_name : [%d]", ret);
325 content_debug("album_name : [%s]", c_value);
328 ret = media_album_get_artist(album, &c_value);
329 if (ret != MEDIA_CONTENT_ERROR_NONE)
330 content_error("error media_album_get_artist : [%d]", ret);
333 content_debug("album_artist : [%s]", c_value);
338 static void get_bookmark_meta(media_bookmark_h bookmark)
340 char *c_value = NULL;
343 int ret = MEDIA_CONTENT_ERROR_NONE;
345 content_debug("=== bookmark meta ===");
347 ret = media_bookmark_get_bookmark_id(bookmark, &i_value);
348 if (ret != MEDIA_CONTENT_ERROR_NONE)
349 content_error("error media_bookmark_get_bookmark_id : [%d]", ret);
351 content_debug("bookmark_id : %d", i_value);
353 ret = media_bookmark_get_thumbnail_path(bookmark, &c_value);
354 if (ret != MEDIA_CONTENT_ERROR_NONE)
355 content_error("error media_bookmark_get_thumbnail_path : [%d]", ret);
358 content_debug("bookmark thumbnail_path : %s", c_value);
361 ret = media_bookmark_get_marked_time(bookmark, &time);
362 if (ret != MEDIA_CONTENT_ERROR_NONE)
363 content_error("error media_bookmark_get_marked_time : [%d]", ret);
365 content_debug("bookmark marked_time : %ld", time);
367 ret = media_bookmark_get_name(bookmark, &c_value);
368 if (ret != MEDIA_CONTENT_ERROR_NONE)
369 content_error("error media_bookmark_get_name : [%d]", ret);
372 content_debug("bookmark name : %s", c_value);
377 static void get_tag_meta(media_tag_h tag)
379 char *c_value = NULL;
381 int ret = MEDIA_CONTENT_ERROR_NONE;
383 content_debug("=== tag meta ===");
385 ret = media_tag_get_tag_id(tag, &i_value);
386 if (ret != MEDIA_CONTENT_ERROR_NONE)
387 content_error("error media_tag_get_tag_id : [%d]", ret);
389 content_debug("tag_id : %d", i_value);
391 ret = media_tag_get_name(tag, &c_value);
392 if (ret != MEDIA_CONTENT_ERROR_NONE)
393 content_error("error media_tag_get_name : [%d]", ret);
396 content_debug("tag_name : %s", c_value);
401 static void get_face_meta(media_face_h face)
403 char *c_value = NULL;
404 unsigned int rect_x = 0;
405 unsigned int rect_y = 0;
406 unsigned int rect_w = 0;
407 unsigned int rect_h = 0;
408 media_content_orientation_e orientation = 0;
409 int ret = MEDIA_CONTENT_ERROR_NONE;
411 content_debug("=== face meta ===");
413 ret = media_face_get_face_id(face, &c_value);
414 if (ret != MEDIA_CONTENT_ERROR_NONE)
415 content_error("error media_face_get_face_id : [%d]", ret);
418 content_debug("face_id : %s", c_value);
421 ret = media_face_get_media_id(face, &c_value);
422 if (ret != MEDIA_CONTENT_ERROR_NONE)
423 content_error("error media_face_get_media_id : [%d]", ret);
426 content_debug("media_id : %s", c_value);
429 ret = media_face_get_face_rect(face, &rect_x, &rect_y, &rect_w, &rect_h);
430 if (ret != MEDIA_CONTENT_ERROR_NONE)
431 content_error("error media_face_get_face_rect : [%d]", ret);
433 content_debug("face_rect x[%d] y[%d] w[%d] h[%d]", rect_x, rect_y, rect_w, rect_h);
435 ret = media_face_get_orientation(face, &orientation);
436 if (ret != MEDIA_CONTENT_ERROR_NONE)
437 content_error("error media_face_get_orientation : [%d]", ret);
439 content_debug("orientation : %d", orientation);
441 ret = media_face_get_tag(face, &c_value);
442 if (ret != MEDIA_CONTENT_ERROR_NONE)
443 content_error("error media_face_get_tag : [%d]", ret);
446 content_debug("tag : %s", c_value);
451 static void get_folder_meta(media_folder_h folder, char **folder_id)
453 char *c_value = NULL;
454 media_content_storage_e storage_type;
455 int ret = MEDIA_CONTENT_ERROR_NONE;
457 content_debug("=== folder meta ===");
459 ret = media_folder_get_folder_id(folder, &c_value);
460 if (ret != MEDIA_CONTENT_ERROR_NONE)
461 content_error("error media_folder_get_folder_id : [%d]", ret);
464 content_debug("folder_id : %s", c_value);
465 *folder_id = c_value;
468 ret = media_folder_get_path(folder, &c_value);
469 if (ret != MEDIA_CONTENT_ERROR_NONE)
470 content_error("error media_folder_get_path : [%d]", ret);
473 content_debug("folder_path : %s", c_value);
476 ret = media_folder_get_name(folder, &c_value);
477 if (ret != MEDIA_CONTENT_ERROR_NONE)
478 content_error("error media_folder_get_name : [%d]", ret);
481 content_debug("folder_name : %s", c_value);
484 ret = media_folder_get_storage_type(folder, &storage_type);
485 if (ret != MEDIA_CONTENT_ERROR_NONE)
486 content_error("error media_folder_get_storage_type : [%d]", ret);
488 content_debug("storage_type : [%d]", storage_type);
490 ret = media_folder_get_storage_id(folder, &c_value);
491 if (ret != MEDIA_CONTENT_ERROR_NONE)
492 content_error("error media_folder_get_storage_id : [%d]", ret);
495 content_debug("storage_id : %s", c_value);
500 static void get_media_meta(media_info_h media)
502 char *c_value = NULL;
505 bool b_value = false;
506 unsigned long long size = 0;
507 media_content_type_e media_type = 0;
508 int ret = MEDIA_CONTENT_ERROR_NONE;
510 content_debug("=== media meta ===");
512 ret = media_info_get_media_type(media, &media_type);
513 if (ret != MEDIA_CONTENT_ERROR_NONE)
514 content_error("error media_info_get_media_type : [%d]", ret);
516 content_debug("media_type : [%d]", media_type);
518 ret = media_info_get_media_id(media, &c_value);
519 if (ret != MEDIA_CONTENT_ERROR_NONE)
520 content_error("error media_info_get_media_id : [%d]", ret);
523 content_debug("media_id : [%s]", c_value);
526 ret = media_info_get_file_path(media, &c_value);
527 if (ret != MEDIA_CONTENT_ERROR_NONE)
528 content_error("error media_info_get_file_path : [%d]", ret);
531 content_debug("file_path : [%s]", c_value);
534 ret = media_info_get_display_name(media, &c_value);
535 if (ret != MEDIA_CONTENT_ERROR_NONE)
536 content_error("error media_info_get_display_name : [%d]", ret);
539 content_debug("display_name : [%s]", c_value);
542 ret = media_info_get_mime_type(media, &c_value);
543 if (ret != MEDIA_CONTENT_ERROR_NONE)
544 content_error("error media_info_get_mime_type : [%d]", ret);
547 content_debug("mime_type : [%s]", c_value);
550 ret = media_info_get_thumbnail_path(media, &c_value);
551 if (ret != MEDIA_CONTENT_ERROR_NONE)
552 content_error("error media_info_get_thumbnail_path : [%d]", ret);
555 content_debug("thumbnail_path : [%s]", c_value);
558 ret = media_info_get_description(media, &c_value);
559 if (ret != MEDIA_CONTENT_ERROR_NONE)
560 content_error("error media_info_get_description : [%d]", ret);
563 content_debug("description : [%s]", c_value);
566 ret = media_info_get_size(media, &size);
567 if (ret != MEDIA_CONTENT_ERROR_NONE)
568 content_error("error media_info_get_size : [%d]", ret);
570 content_debug("size : [%lld]", size);
572 ret = media_info_get_added_time(media, &t_value);
573 if (ret != MEDIA_CONTENT_ERROR_NONE)
574 content_error("error media_info_get_added_time : [%d]", ret);
576 content_debug("added_time : [%ld]", t_value);
578 ret = media_info_get_modified_time(media, &t_value);
579 if (ret != MEDIA_CONTENT_ERROR_NONE)
580 content_error("error media_info_get_modified_time : [%d]", ret);
582 content_debug("modified_time : [%ld]", t_value);
584 ret = media_info_get_timeline(media, &t_value);
585 if (ret != MEDIA_CONTENT_ERROR_NONE)
586 content_error("error media_info_get_timeline : [%d]", ret);
588 content_debug("timeline : [%ld]", t_value);
590 ret = media_info_get_rating(media, &i_value);
591 if (ret != MEDIA_CONTENT_ERROR_NONE)
592 content_error("error media_info_get_rating : [%d]", ret);
594 content_debug("rating : [%d]", i_value);
596 ret = media_info_get_favorite(media, &b_value);
597 if (ret != MEDIA_CONTENT_ERROR_NONE)
598 content_error("error media_info_get_favorite : [%d]", ret);
600 content_debug("favorite : [%d]", b_value);
602 ret = media_info_is_drm(media, &b_value);
603 if (ret != MEDIA_CONTENT_ERROR_NONE)
604 content_error("error media_info_is_drm : [%d]", ret);
606 content_debug("is_drm : [%d]", b_value);
608 ret = media_info_is_360_content(media, &b_value);
609 if (ret != MEDIA_CONTENT_ERROR_NONE)
610 content_error("error media_info_is_360_content : [%d]", ret);
612 content_debug("is_360 : [%d]", b_value);
614 #ifdef _USE_TVPD_MODE
615 ret = media_info_get_stitched_state(media, &i_value);
616 if (ret != MEDIA_CONTENT_ERROR_NONE)
617 content_error("error media_info_get_stitched_state : [%d]", ret);
619 content_debug("360 stitched : [%d]", i_value);
621 ret = media_info_get_stitched_engine(media, &i_value);
622 if (ret != MEDIA_CONTENT_ERROR_NONE)
623 content_error("error media_info_get_stitched_engine : [%d]", ret);
625 content_debug("360 engine : [%d]", i_value);
628 if (media_type == MEDIA_CONTENT_TYPE_MUSIC) {
631 ret = media_info_get_audio(media, &audio);
632 if (ret != MEDIA_CONTENT_ERROR_NONE)
633 content_error("error media_info_get_audio : [%d]", ret);
635 get_audio_meta(audio);
637 ret = audio_meta_destroy(audio);
638 if (ret != MEDIA_CONTENT_ERROR_NONE)
639 content_error("error audio_meta_destroy : [%d]", ret);
641 } else if (media_type == MEDIA_CONTENT_TYPE_IMAGE) {
644 ret = media_info_get_image(media, &image);
645 if (ret != MEDIA_CONTENT_ERROR_NONE)
646 content_error("error media_info_get_image : [%d]", ret);
648 get_image_meta(image);
650 ret = image_meta_destroy(image);
651 if (ret != MEDIA_CONTENT_ERROR_NONE)
652 content_error("error image_meta_destroy : [%d]", ret);
654 } else if (media_type == MEDIA_CONTENT_TYPE_VIDEO) {
657 ret = media_info_get_video(media, &video);
658 if (ret != MEDIA_CONTENT_ERROR_NONE)
659 content_error("error media_info_get_video : [%d]", ret);
661 get_video_meta(video);
663 ret = video_meta_destroy(video);
664 if (ret != MEDIA_CONTENT_ERROR_NONE)
665 content_error("error video_meta_destroy : [%d]", ret);
668 content_debug("Other Content");
673 bool media_item_cb(media_info_h media, void *user_data)
676 content_debug("NO Item");
680 get_media_meta(media);
685 bool gallery_folder_list_cb(media_folder_h folder, void *user_data)
687 media_folder_h new_folder = NULL;
688 media_folder_clone(&new_folder, folder);
690 GList **list = (GList**)user_data;
691 *list = g_list_append(*list, new_folder);
696 bool gallery_media_item_cb(media_info_h media, void *user_data)
698 media_info_h new_media = NULL;
699 int ret = MEDIA_CONTENT_ERROR_NONE;
701 ret = media_info_clone(&new_media, media);
703 if (ret != MEDIA_CONTENT_ERROR_NONE) {
704 GList **list = (GList**)user_data;
705 *list = g_list_append(*list, new_media);
711 bool gallery_tag_item_cb(media_tag_h tag, void *user_data)
713 media_tag_h new_tag = NULL;
714 media_tag_clone(&new_tag, tag);
716 GList **list = (GList**)user_data;
717 *list = g_list_append(*list, new_tag);
722 bool gallery_bookmarks_cb(media_bookmark_h bookmark, void *user_data)
724 media_bookmark_h new_bm = NULL;
725 int ret = MEDIA_CONTENT_ERROR_NONE;
727 ret = media_bookmark_clone(&new_bm, bookmark);
728 if (ret != MEDIA_CONTENT_ERROR_NONE)
729 content_error("error media_bookmark_clone : [%d]", ret);
731 GList **list = (GList**)user_data;
732 *list = g_list_append(*list, new_bm);
737 bool folder_list_cb(media_folder_h folder, void *user_data)
740 char *folder_id = NULL;
741 media_folder_h *_folder = (media_folder_h*)user_data;
743 content_debug("===========================");
744 if (folder != NULL) {
746 media_folder_clone(_folder, folder);
748 get_folder_meta(folder, &folder_id);
750 if (media_folder_get_media_count_from_db(folder_id, g_filter, &item_count) != MEDIA_CONTENT_ERROR_NONE) {
751 SAFE_FREE(folder_id);
752 content_error("[ERROR] media_folder_get_media_count_from_db is failed");
756 if (media_folder_foreach_media_from_db(folder_id, g_filter, media_item_cb, NULL) != MEDIA_CONTENT_ERROR_NONE) {
757 SAFE_FREE(folder_id);
758 content_error("[ERROR] media_folder_foreach_media_from_db is failed");
762 SAFE_FREE(folder_id);
770 bool playlist_list_cb(media_playlist_h playlist, void *user_data)
772 int ret = MEDIA_CONTENT_ERROR_NONE;
774 char *playlist_name = NULL;
775 media_playlist_h playlist_h;
776 char *playlist_thumbnail_path = NULL;
778 content_debug("playlist_list_cb ======");
780 GList **list = (GList**)user_data;
783 if (playlist == NULL) {
784 content_debug(" playlist handle is NULL");
788 ret = media_playlist_get_playlist_id(playlist, &playlist_id);
789 if (ret != MEDIA_CONTENT_ERROR_NONE)
790 content_error("error media_playlist_get_playlist_id : [%d]", ret);
792 content_debug("playlist_id : %d", playlist_id);
793 /* 64bit build issue */
795 if (user_data != NULL)
796 *list = g_list_append(*list, (gpointer)playlist_id);
798 ret = media_playlist_get_name(playlist, &playlist_name);
799 if (ret != MEDIA_CONTENT_ERROR_NONE)
800 content_error("error media_playlist_get_name : [%d]", ret);
802 content_debug("playlist_name : %s", playlist_name);
803 SAFE_FREE(playlist_name);
805 ret = media_playlist_get_thumbnail_path(playlist, &playlist_thumbnail_path);
806 if (ret != MEDIA_CONTENT_ERROR_NONE)
807 content_error("error media_playlist_get_thumbnail_path : [%d]", ret);
809 content_debug("playlist_thumbnail_path : %s", playlist_thumbnail_path);
810 SAFE_FREE(playlist_thumbnail_path);
812 ret = media_playlist_get_playlist_from_db(playlist_id, &playlist_h);
813 if (ret != MEDIA_CONTENT_ERROR_NONE)
814 content_error("error media_playlist_get_playlist_from_db : [%d]", ret);
816 ret = media_playlist_destroy(playlist_h);
817 if (ret != MEDIA_CONTENT_ERROR_NONE)
818 content_error("error media_playlist_destroy : [%d]", ret);
823 bool tag_list_cb(media_tag_h tag, void *user_data)
826 content_debug(" tag handle is NULL");
835 bool bookmarks_cb(media_bookmark_h bookmark, void *user_data)
837 if (bookmark != NULL && user_data != NULL) {
838 media_bookmark_h new_bookmark;
840 media_bookmark_clone(&new_bookmark, bookmark);
841 GList **list = (GList**)user_data;
842 *list = g_list_append(*list, new_bookmark);
845 get_bookmark_meta(bookmark);
850 bool album_list_cb(media_album_h album, void *user_data)
854 int ret = MEDIA_CONTENT_ERROR_NONE;
857 get_album_meta(album);
858 media_album_get_album_id(album, &album_id);
860 ret = media_album_get_media_count_from_db(album_id, NULL, &media_count);
861 if (ret != MEDIA_CONTENT_ERROR_NONE)
862 content_error("error media_album_get_media_count_from_db : [%d]", ret);
864 content_debug("media_count : [%d]", media_count);
866 ret = media_album_foreach_media_from_db(album_id, NULL, media_item_cb, NULL);
867 if (ret != MEDIA_CONTENT_ERROR_NONE) {
868 content_error("error media_album_foreach_media_from_db : [%d]", ret);
873 content_error("album item not Found!!");
879 bool group_list_cb(const char *group_name, void *user_data)
882 int *idx = user_data;
884 content_debug("group item : [%s] [%d]", group_name, *idx);
886 if (media_group_get_media_count_from_db(group_name, *idx, g_filter, &media_count) != MEDIA_CONTENT_ERROR_NONE)
889 content_debug("media_count : [%d]", media_count);
891 if (media_group_foreach_media_from_db(group_name, *idx, g_filter, media_item_cb, NULL) != MEDIA_CONTENT_ERROR_NONE)
897 bool playlist_item_cb(int playlist_member_id, media_info_h media, void *user_data)
899 content_debug("playlist_member_id : [%d]", playlist_member_id);
900 /* 64bit build issue */
902 GList **list = (GList**)user_data;
904 *list = g_list_append(*list, (gpointer)playlist_member_id);
906 /*media_item_cb(media, user_data);*/
911 int test_filter_create(void)
913 content_debug("\n============Filter Create============\n\n");
915 int ret = MEDIA_CONTENT_ERROR_NONE;
917 /* Filter for media */
918 const char *condition = "MEDIA_TYPE=3"; /*MEDIA_TYPE 0-image, 1-video, 2-sound, 3-music, 4-other*/
920 ret = media_filter_create(&g_filter);
922 /* Set condition and collate
923 * Condition string : You can make where statement of sql.
924 * Colation : You can use collation when comparing.
925 * Ex) In case of FILE_NAME='Samsung' as condition string,
926 * if you want to compare with NOCASE collation,
927 * call media_filter_set_condition(g_filter, condition, MEDIA_CONTENT_COLLATE_NOCASE);
928 * if you want to compare in case-sensitive,
929 * call media_filter_set_condition(g_filter, condition, MEDIA_CONTENT_COLLATE_DEFAULT);
931 ret = media_filter_set_condition(g_filter, condition, MEDIA_CONTENT_COLLATE_DEFAULT);
933 /* Collation of ordering
934 * If you want to get list, which is sorted by NOCASE,
935 * call media_filter_set_order(g_filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_ARTIST, MEDIA_CONTENT_COLLATE_NOCASE);
937 * call media_filter_set_order(g_filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_ARTIST, MEDIA_CONTENT_COLLATE_DEFAULT);
939 /* Able to set multi column to set order */
941 ret = media_filter_set_order(g_filter, MEDIA_CONTENT_ORDER_ASC, "MEDIA_MODIFIED_TIME, MEDIA_DISPLAY_NAME", MEDIA_CONTENT_COLLATE_DEFAULT);
942 ret = media_filter_set_order(g_filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_ARTIST, MEDIA_CONTENT_COLLATE_DEFAULT);
943 ret = media_filter_set_order(g_filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_TRACK_NUM_INT, MEDIA_CONTENT_COLLATE_DEFAULT);
944 ret = media_filter_set_storage(g_filter, "cfbf3d2c-71c5-4611-bccc-7cbac890146e");
946 /* Filter for group */
947 const char *g_condition = "TAG_NAME like \"\%my\%\"";
948 const char *g_condition = "BOOKMARK_MARKED_TIME > 300";
950 ret = media_filter_create(&g_filter_g);
952 ret = media_filter_set_order(g_filter_g, MEDIA_CONTENT_ORDER_DESC, TAG_NAME, MEDIA_CONTENT_COLLATE_DEFAULT);
957 int test_filter_destroy(void)
959 content_debug("\n============Filter Create============\n\n");
961 int ret = MEDIA_CONTENT_ERROR_NONE;
963 ret = media_filter_destroy(g_filter);
968 int test_connect_database(void)
970 int ret = MEDIA_CONTENT_ERROR_NONE;
972 content_debug("\n============DB Connection Test============\n\n");
974 ret = media_content_connect();
976 if (ret == MEDIA_CONTENT_ERROR_NONE)
977 content_debug("connection is success\n\n");
979 content_error("connection is failed\n\n");
984 int test_gallery_scenario(void)
986 int ret = MEDIA_CONTENT_ERROR_NONE;
988 filter_h filter = NULL;
991 GList *folder_list = NULL;
992 media_folder_h folder_handle = NULL;
994 /* First, Get folder list */
995 ret = media_folder_foreach_folder_from_db(filter, gallery_folder_list_cb, &folder_list);
996 if (ret != MEDIA_CONTENT_ERROR_NONE) {
997 content_error("media_folder_foreach_folder_from_db failed: %d", ret);
1000 content_debug("media_folder_foreach_folder_from_db success!!");
1001 char *folder_id = NULL;
1003 for (i = 0; i < g_list_length(folder_list); i++) {
1004 folder_handle = (media_folder_h)g_list_nth_data(folder_list, i);
1006 get_folder_meta(folder_handle, &folder_id);
1008 ret = media_folder_get_media_count_from_db(folder_id, filter, &count);
1009 SAFE_FREE(folder_id);
1010 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1011 content_error("media_folder_get_media_count_from_db failed: %d", ret);
1014 content_debug("media count [%d] : %d", i, count);
1019 /* To check performance */
1020 struct timeval start, end;
1021 gettimeofday(&start, NULL);
1023 /* Second, Get all item list */
1024 media_info_h media_handle = NULL;
1025 GList *all_item_list = NULL;
1027 media_content_collation_e collate_type = MEDIA_CONTENT_COLLATE_NOCASE;
1028 media_content_order_e order_type = MEDIA_CONTENT_ORDER_DESC;
1029 ret = media_filter_create(&filter);
1030 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1031 content_error("Fail to create filter");
1034 ret = media_filter_set_condition(filter, "MEDIA_TYPE = 0", collate_type);
1035 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1036 media_filter_destroy(filter);
1037 content_error("Fail to set condition");
1040 ret = media_filter_set_order(filter, order_type, MEDIA_DISPLAY_NAME, collate_type);
1041 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1042 media_filter_destroy(filter);
1043 content_error("Fail to set order");
1047 ret = media_info_foreach_media_from_db(filter, gallery_media_item_cb, &all_item_list);
1048 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1049 content_error("media_info_foreach_media_from_db failed: %d", ret);
1050 media_filter_destroy(filter);
1053 content_debug("media_info_foreach_media_from_db success");
1055 for (i = 0; i < g_list_length(all_item_list); i++) {
1056 media_handle = (media_info_h)g_list_nth_data(all_item_list, i);
1057 get_media_meta(media_handle);
1061 media_filter_destroy(filter);
1064 /* To check performance */
1065 gettimeofday(&end, NULL);
1066 long time = (end.tv_sec * 1000000 + end.tv_usec) - (start.tv_sec * 1000000 + start.tv_usec);
1067 content_debug("Time : %ld\n", time);
1069 /* Third, Get item list of a folder */
1070 GList *item_list = NULL;
1072 for (i = 0; i < g_list_length(folder_list); i++) {
1074 char *folder_id = NULL;
1075 folder_handle = (media_folder_h)g_list_nth_data(folder_list, i);
1077 get_folder_meta(folder_handle, &folder_id);
1079 ret = media_folder_foreach_media_from_db(folder_id, filter, gallery_media_item_cb, &item_list);
1080 SAFE_FREE(folder_id);
1082 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1083 content_error("media_folder_foreach_media_from_db failed: %d", ret);
1086 content_error("media_folder_foreach_media_from_db success!");
1088 for (j = 0; j < g_list_length(item_list); j++) {
1089 media_handle = (media_info_h)g_list_nth_data(item_list, j);
1090 get_media_meta(media_handle);
1096 media_tag_h tag_handle = NULL;
1097 GList *tag_list = NULL;
1098 GList *media_list_in_tag = NULL;
1101 ret = media_tag_foreach_tag_from_db(filter, gallery_tag_item_cb, &tag_list);
1103 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1104 content_error("media_tag_foreach_tag_from_db failed: %d", ret);
1107 content_error("media_tag_foreach_tag_from_db success");
1108 for (i = 0; i < g_list_length(tag_list); i++) {
1109 tag_handle = (media_tag_h)g_list_nth_data(tag_list, i);
1110 get_tag_meta(tag_handle);
1112 ret = media_tag_get_tag_id(tag_handle, &tag_id);
1113 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1114 ret = media_tag_foreach_media_from_db(tag_id, filter, gallery_media_item_cb, &media_list_in_tag);
1115 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1116 content_error("media_tag_foreach_media_from_db failed: %d", ret);
1119 content_error("media_tag_foreach_media_from_db success");
1121 media_info_h tag_media_handle;
1123 for (j = 0; j < g_list_length(media_list_in_tag); j++) {
1124 tag_media_handle = (media_info_h)g_list_nth_data(media_list_in_tag, j);
1125 get_media_meta(tag_media_handle);
1132 /* Remove folder list */
1134 for (i = 0; i < g_list_length(folder_list); i++) {
1135 folder_handle = (media_folder_h)g_list_nth_data(folder_list, i);
1136 media_folder_destroy(folder_handle);
1139 g_list_free(folder_list);
1142 /* Remove all items list */
1143 if (all_item_list) {
1144 for (i = 0; i < g_list_length(all_item_list); i++) {
1145 media_handle = (media_info_h)g_list_nth_data(all_item_list, i);
1146 ret = media_info_destroy(media_handle);
1147 if (ret != MEDIA_CONTENT_ERROR_NONE)
1148 content_error("media_info_destroy failed: %d", ret);
1151 g_list_free(all_item_list);
1154 /* Remove items list */
1156 for (i = 0; i < g_list_length(item_list); i++) {
1157 media_handle = (media_info_h)g_list_nth_data(item_list, i);
1158 ret = media_info_destroy(media_handle);
1159 if (ret != MEDIA_CONTENT_ERROR_NONE)
1160 content_error("media_info_destroy failed: %d", ret);
1163 g_list_free(item_list);
1166 /* Remove tag list */
1168 for (i = 0; i < g_list_length(tag_list); i++) {
1169 tag_handle = (media_tag_h)g_list_nth_data(tag_list, i);
1170 ret = media_tag_destroy(tag_handle);
1171 if (ret != MEDIA_CONTENT_ERROR_NONE)
1172 content_error("error media_tag_destroy : [%d]", ret);
1175 g_list_free(tag_list);
1178 /* Remove media list in a tag */
1179 if (media_list_in_tag) {
1180 for (i = 0; i < g_list_length(media_list_in_tag); i++) {
1181 media_handle = (media_info_h)g_list_nth_data(media_list_in_tag, i);
1182 ret = media_info_destroy(media_handle);
1183 if (ret != MEDIA_CONTENT_ERROR_NONE)
1184 content_error("media_info_destroy failed: %d", ret);
1187 g_list_free(media_list_in_tag);
1190 return MEDIA_CONTENT_ERROR_NONE;
1193 /*Get All Music file. sort by Title and not case sensitive*/
1194 int test_get_all_music_files(void)
1196 int ret = MEDIA_CONTENT_ERROR_NONE;
1197 int media_count = 0;
1201 const char *condition = "MEDIA_TYPE=3"; /*0-image, 1-video, 2-sound, 3-music, 4-other*/
1203 ret = media_filter_create(&filter);
1204 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1205 content_error("Fail to create filter");
1208 ret = media_filter_set_condition(filter, condition, MEDIA_CONTENT_COLLATE_LOCALIZED);
1209 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1210 media_filter_destroy(filter);
1211 content_error("Fail to set condition");
1214 ret = media_filter_set_order(filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_TITLE, MEDIA_CONTENT_COLLATE_LOCALIZED);
1215 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1216 media_filter_destroy(filter);
1217 content_error("Fail to set order");
1222 ret = media_info_get_media_count_from_db(filter, &media_count);
1223 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1224 media_filter_destroy(filter);
1225 content_error("Fail to get media count");
1229 content_debug("media_count : [%d]", media_count);
1231 ret = media_info_foreach_media_from_db(filter, media_item_cb, NULL);
1232 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1233 media_filter_destroy(filter);
1234 content_error("Fail to get media");
1238 ret = media_filter_destroy(filter);
1243 int test_media_info_operation(void)
1245 int ret = MEDIA_CONTENT_ERROR_NONE;
1246 int media_count = 0;
1248 content_debug("\n============Media info Test============\n\n");
1250 test_filter_create();
1252 ret = media_info_get_media_count_from_db(g_filter, &media_count);
1253 if (ret != MEDIA_CONTENT_ERROR_NONE)
1254 content_error("media_info_get_media_count_from_db failed: %d", ret);
1256 content_debug("media_count : [%d]", media_count);
1258 ret = media_info_foreach_media_from_db(g_filter, media_item_cb, NULL);
1259 if (ret == MEDIA_CONTENT_ERROR_NONE)
1260 content_debug("media_info_foreach_media_from_db is success");
1262 content_error("media_info_foreach_media_from_db is failed");
1264 test_filter_destroy();
1269 int test_media_info_operation_2(void)
1271 int ret = MEDIA_CONTENT_ERROR_NONE;
1272 int bookmark_count = 0;
1274 content_debug("\n============Media info Test 2============\n\n");
1276 test_filter_create();
1280 char *thumbnail_path1 = tzplatform_mkpath(TZ_USER_VIDEOS, "teat11.jpg");
1281 media_bookmark_insert_to_db(test_video_id, 100, thumbnail_path1);
1282 media_bookmark_insert_to_db(test_video_id, 200, thumbnail_path1);
1284 media_info_get_bookmark_count_from_db(test_video_id, g_filter_g, &bookmark_count);
1286 content_debug("bookmark_count : [%d]", bookmark_count);
1288 ret = media_info_foreach_bookmark_from_db(test_video_id, g_filter_g, bookmarks_cb, NULL);
1292 ret = media_info_get_tag_count_from_db(test_audio_id, g_filter_g, &bookmark_count);
1293 if (ret != MEDIA_CONTENT_ERROR_NONE)
1294 content_error("media_info_get_tag_count_from_db failed: %d", ret);
1296 content_debug("tag_count : [%d]", bookmark_count);
1298 ret = media_info_foreach_tag_from_db(test_audio_id, g_filter_g, tag_list_cb, NULL);
1299 if (ret != MEDIA_CONTENT_ERROR_NONE)
1300 content_error("media_info_foreach_tag_from_db failed: %d", ret);
1302 test_filter_destroy();
1307 int test_folder_operation(void)
1309 int ret = MEDIA_CONTENT_ERROR_NONE;
1310 filter_h filter = NULL;
1311 media_folder_h folder = NULL;
1312 char *folder_id = NULL;
1315 content_debug("\n============Folder Test============\n\n");
1317 test_filter_create();
1319 ret = media_filter_create(&filter);
1320 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1321 content_error("[ERROR] media_folder_filter_create is failed");
1325 media_filter_set_condition(filter, "(MEDIA_TYPE = 0 or MEDIA_TYPE = 1) and MEDIA_STORAGE_TYPE=0", MEDIA_CONTENT_COLLATE_DEFAULT); /*MEDIA_TYPE 0-image, 1-video, 2-sound, 3-music, 4-other*/
1326 media_filter_set_offset(filter, 0, 5);
1327 media_filter_set_order(filter, MEDIA_CONTENT_ORDER_DESC, MEDIA_PATH, MEDIA_CONTENT_COLLATE_NOCASE);
1328 media_filter_set_storage(filter, "cfbf3d2c-71c5-4611-bccc-7cbac890146e");
1330 ret = media_folder_get_folder_count_from_db(filter, &count);
1331 content_debug("Folder count : [%d]", count);
1333 ret = media_folder_foreach_folder_from_db(filter, folder_list_cb, &folder);
1335 filter_h m_filter = NULL;
1337 ret = media_filter_create(&m_filter);
1338 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1339 test_filter_destroy();
1340 media_filter_destroy(filter);
1341 content_error("[ERROR] media_info_filter_create is failed");
1345 media_filter_set_condition(m_filter, "MEDIA_TYPE=1 and MEDIA_STORAGE_TYPE=0", MEDIA_CONTENT_COLLATE_DEFAULT); /*MEDIA_TYPE 0-image, 1-video, 2-sound, 3-music, 4-other*/
1346 media_filter_set_offset(m_filter, 0, 5);
1347 media_filter_set_order(m_filter, MEDIA_CONTENT_ORDER_DESC, MEDIA_PATH, MEDIA_CONTENT_COLLATE_NOCASE);
1349 ret = media_folder_foreach_media_from_db(folder_id, m_filter, media_item_cb, NULL);
1350 if (ret != MEDIA_CONTENT_ERROR_NONE)
1351 content_error("[ERROR] media_folder_foreach_media_from_db is failed, error code : %d", ret);
1353 media_filter_destroy(filter);
1354 media_filter_destroy(m_filter);
1356 test_filter_destroy();
1358 /* fix prevent: Resource Leak */
1359 SAFE_FREE(folder_id);
1364 int test_playlist_operation(void)
1366 int ret = MEDIA_CONTENT_ERROR_NONE;
1367 media_playlist_h playlist_1 = NULL;
1368 media_playlist_h playlist_2 = NULL;
1369 media_playlist_h playlist_3 = NULL;
1370 media_playlist_h playlist_4 = NULL;
1371 int playlist_id_1 = 0;
1372 int playlist_id_2 = 0;
1373 int playlist_id_3 = 0;
1374 const char *playlist_name_1 = "myPlaylist_1";
1375 const char *playlist_name_2 = "myPlaylist_2";
1376 const char *playlist_name_3 = "myPlaylist_3";
1377 int playlist_count = 0;
1378 int media_count = 0;
1384 filter_h filter = NULL;
1385 filter_h m_filter = NULL;
1387 content_debug("\n============Playlist Test============\n\n");
1389 /* Filter for playlist */
1391 const char *condition = "(MEDIA_TYPE=1 or MEDIA_TYPE=3)"; /*0-image, 1-video, 2-sound, 3-music, 4-other*/
1393 ret = media_filter_create(&filter);
1394 ret = media_filter_set_condition(filter, condition, MEDIA_CONTENT_COLLATE_NOCASE);
1395 ret = media_filter_set_order(filter, MEDIA_CONTENT_ORDER_ASC, PLAYLIST_NAME, MEDIA_CONTENT_COLLATE_NOCASE);
1397 /* Create Playlist */
1398 media_playlist_insert_to_db(playlist_name_1, &playlist_1);
1399 media_playlist_insert_to_db(playlist_name_2, &playlist_2);
1400 media_playlist_insert_to_db(playlist_name_3, &playlist_3);
1402 if (playlist_1 != NULL) {
1403 /* Add media to Playlist */
1404 media_playlist_add_media(playlist_1, test_audio_id);
1405 media_playlist_add_media(playlist_1, test_audio_id);
1406 media_playlist_add_media(playlist_1, test_video_id);
1409 char *playlist_thumb_path = tzplatform_mkpath(TZ_USER_IMAGES, "Default.jpg"));
1410 media_playlist_set_thumbnail_path(playlist_1, playlist_thumb_path);
1413 media_playlist_update_to_db(playlist_1);
1416 if (playlist_2 != NULL) {
1417 media_playlist_add_media(playlist_2, test_audio_id);
1418 media_playlist_add_media(playlist_2, test_audio_id);
1419 media_playlist_update_to_db(playlist_2);
1422 /* Get Playlist Count*/
1423 ret = media_playlist_get_playlist_count_from_db(filter, &playlist_count);
1425 content_debug("playlist_count [%d]", playlist_count);
1428 GList *playlist_id_list = NULL;
1429 media_playlist_foreach_playlist_from_db(filter, playlist_list_cb, &playlist_id_list);
1430 /* 64bit build issue */
1432 /* Get Playlist id*/
1433 playlist_id_1 = (int)g_list_nth_data(playlist_id_list, 0);
1434 playlist_id_2 = (int)g_list_nth_data(playlist_id_list, 1);
1435 playlist_id_3 = (int)g_list_nth_data(playlist_id_list, 2);
1437 content_debug("playlist_id_1 [%d]", playlist_id_1);
1438 content_debug("playlist_id_2 [%d]", playlist_id_2);
1439 content_debug("playlist_id_3 [%d]", playlist_id_3);
1441 /* Export and import playlist */
1442 media_playlist_export_to_file(playlist_3, tzplatform_mkpath(TZ_USER_MUSIC, "playlist.m3u"));
1443 media_playlist_import_from_file(tzplatform_mkpath(TZ_USER_MUSIC, "playlist.m3u"), "playlist_4", &playlist_4);
1445 /* Filter for media*/
1446 ret = media_filter_create(&m_filter);
1448 ret = media_filter_set_condition(m_filter, condition, MEDIA_CONTENT_COLLATE_DEFAULT);
1450 ret = media_filter_set_order(m_filter, MEDIA_CONTENT_ORDER_ASC, PLAYLIST_MEMBER_ORDER, MEDIA_CONTENT_COLLATE_DEFAULT);
1452 /* Get media count */
1453 media_playlist_get_media_count_from_db(playlist_id_1, m_filter, &media_count);
1454 content_debug("playlist_1_media_count [%d]", media_count);
1456 media_playlist_get_media_count_from_db(playlist_id_2, m_filter, &media_count);
1457 content_debug("playlist_2_media_count [%d]", media_count);
1459 media_playlist_get_media_count_from_db(playlist_id_3, m_filter, &media_count);
1460 content_debug("playlist_3_media_count [%d]", media_count);
1462 /* Get media of playlist */
1463 GList *playlist_member_id_list = NULL;
1464 GList *playlist_member_id_list_1 = NULL;
1466 media_playlist_foreach_media_from_db(playlist_id_1, m_filter, playlist_item_cb, &playlist_member_id_list);
1467 media_playlist_foreach_media_from_db(playlist_id_2, m_filter, playlist_item_cb, &playlist_member_id_list_1);
1469 int playlist_member_id_1_1 = 0;
1470 int playlist_member_id_1_2 = 0;
1471 int playlist_member_id_1_3 = 0;
1472 int playlist_member_id_2_1 = 0;
1473 int playlist_member_id_2_2 = 0;
1474 /* 64bit build issue */
1476 playlist_member_id_1_1 = (int)g_list_nth_data(playlist_member_id_list, 0);
1477 playlist_member_id_1_2 = (int)g_list_nth_data(playlist_member_id_list, 1);
1478 playlist_member_id_1_3 = (int)g_list_nth_data(playlist_member_id_list, 2);
1479 playlist_member_id_2_1 = (int)g_list_nth_data(playlist_member_id_list_1, 0);
1480 playlist_member_id_2_2 = (int)g_list_nth_data(playlist_member_id_list_1, 1);
1482 content_debug("playlist_member_id_1_1 [%d]", playlist_member_id_1_1);
1483 content_debug("playlist_member_id_1_2 [%d]", playlist_member_id_1_2);
1484 content_debug("playlist_member_id_1_3 [%d]", playlist_member_id_1_3);
1485 content_debug("playlist_member_id_2_1 [%d]", playlist_member_id_2_1);
1486 content_debug("playlist_member_id_2_2 [%d]", playlist_member_id_2_2);
1488 media_playlist_get_play_order(playlist_1, playlist_member_id_1_1, &order_1);
1489 media_playlist_get_play_order(playlist_1, playlist_member_id_1_2, &order_2);
1490 media_playlist_get_play_order(playlist_1, playlist_member_id_1_3, &order_3);
1491 media_playlist_get_play_order(playlist_2, playlist_member_id_2_1, &order_4);
1492 media_playlist_get_play_order(playlist_2, playlist_member_id_2_2, &order_5);
1493 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);
1495 /* Update Playlist */
1496 media_playlist_remove_media(playlist_2, playlist_member_id_2_1);
1497 media_playlist_add_media(playlist_2, test_video_id);
1498 media_playlist_set_name(playlist_2, "test_playlist");
1499 media_playlist_set_play_order(playlist_2, playlist_member_id_2_2, order_5+100);
1500 media_playlist_update_to_db(playlist_2);
1502 /* Get Updated Playlist*/
1503 media_playlist_foreach_playlist_from_db(filter, playlist_list_cb, NULL);
1505 /* deletes the playlist */
1507 media_playlist_delete_from_db(playlist_id_1);
1508 media_playlist_delete_from_db(playlist_id_2);
1511 if (playlist_1 != NULL)
1512 media_playlist_destroy(playlist_1);
1513 if (playlist_2 != NULL)
1514 media_playlist_destroy(playlist_2);
1515 if (playlist_3 != NULL)
1516 media_playlist_destroy(playlist_3);
1517 if (playlist_4 != NULL)
1518 media_playlist_destroy(playlist_4);
1520 g_list_free(playlist_id_list);
1521 g_list_free(playlist_member_id_list);
1522 g_list_free(playlist_member_id_list_1);
1525 ret = media_filter_destroy(filter);
1526 if (m_filter != NULL)
1527 ret = media_filter_destroy(m_filter);
1532 int test_playlist_operation_v2(void)
1534 int ret = MEDIA_CONTENT_ERROR_NONE;
1535 media_playlist_h playlist_1 = NULL;
1536 const char *playlist_name_1 = "myPlaylist_1";
1537 const char *playlist_thumb_path = tzplatform_mkpath(TZ_USER_IMAGES, "Default.jpg");
1538 int playlist_id = 0;
1540 content_debug("\n============Playlist Test V2============\n\n");
1542 ret = media_playlist_create(&playlist_1);
1543 if (ret != MEDIA_CONTENT_ERROR_NONE)
1544 content_error("error media_playlist_create : [%d]", ret);
1546 ret = media_playlist_set_name(playlist_1, playlist_name_1);
1547 if (ret != MEDIA_CONTENT_ERROR_NONE)
1548 content_error("error media_playlist_set_name : [%d]", ret);
1550 ret = media_playlist_set_thumbnail_path(playlist_1, playlist_thumb_path);
1551 if (ret != MEDIA_CONTENT_ERROR_NONE)
1552 content_error("error media_playlist_set_thumbnail_path : [%d]", ret);
1554 ret = media_playlist_insert_to_db_v2(playlist_1);
1555 if (ret != MEDIA_CONTENT_ERROR_NONE)
1556 content_error("error media_playlist_insert_to_db_v2 : [%d]", ret);
1558 ret = media_playlist_set_name(playlist_1, "myPlaylist_3");
1559 if (ret != MEDIA_CONTENT_ERROR_NONE)
1560 content_error("error media_playlist_set_name : [%d]", ret);
1562 ret = media_playlist_get_playlist_id(playlist_1, &playlist_id);
1563 if (ret != MEDIA_CONTENT_ERROR_NONE)
1564 content_error("error media_playlist_get_playlist_id : [%d]", ret);
1566 ret = media_playlist_update_to_db_v2(playlist_id, playlist_1);
1567 if (ret != MEDIA_CONTENT_ERROR_NONE)
1568 content_error("error media_playlist_update_to_db_v2 : [%d]", ret);
1570 ret = media_playlist_destroy(playlist_1);
1571 if (ret != MEDIA_CONTENT_ERROR_NONE)
1572 content_error("error media_playlist_destroy : [%d]", ret);
1577 int test_tag_operation(void)
1579 int ret = MEDIA_CONTENT_ERROR_NONE;
1586 const char *tag_name_1 = "myTag_1";
1587 const char *tag_name_2 = "myTag_2";
1588 const char *tag_name_3 = "myTag_3";
1590 int media_count = 0;
1593 content_debug("\n============Tag Test============\n\n");
1595 const char *g_condition = "TAG_NAME like \"%%my%%\"";
1597 ret = media_filter_create(&filter);
1599 ret = media_filter_set_condition(filter, g_condition, MEDIA_CONTENT_COLLATE_DEFAULT);
1601 ret = media_filter_set_order(filter, MEDIA_CONTENT_ORDER_DESC, TAG_NAME, MEDIA_CONTENT_COLLATE_DEFAULT);
1604 ret = media_tag_insert_to_db(tag_name_1, &tag_1);
1605 if (ret != MEDIA_CONTENT_ERROR_NONE)
1606 content_error("error media_tag_insert_to_db : [%d]", ret);
1607 ret = media_tag_insert_to_db(tag_name_2, &tag_2);
1608 if (ret != MEDIA_CONTENT_ERROR_NONE)
1609 content_error("error media_tag_insert_to_db : [%d]", ret);
1610 ret = media_tag_insert_to_db(tag_name_3, &tag_3);
1611 if (ret != MEDIA_CONTENT_ERROR_NONE)
1612 content_error("error media_tag_insert_to_db : [%d]", ret);
1614 /* Add media to Tag */
1615 ret = media_tag_add_media(tag_1, test_audio_id);
1616 if (ret != MEDIA_CONTENT_ERROR_NONE)
1617 content_error("error media_tag_add_media : [%d]", ret);
1618 ret = media_tag_add_media(tag_1, test_video_id);
1619 if (ret != MEDIA_CONTENT_ERROR_NONE)
1620 content_error("error media_tag_add_media : [%d]", ret);
1621 ret = media_tag_update_to_db(tag_1);
1622 if (ret != MEDIA_CONTENT_ERROR_NONE)
1623 content_error("error media_tag_update_to_db : [%d]", ret);
1625 ret = media_tag_add_media(tag_2, test_audio_id);
1626 if (ret != MEDIA_CONTENT_ERROR_NONE)
1627 content_error("error media_tag_add_media : [%d]", ret);
1628 ret = media_tag_update_to_db(tag_2);
1629 if (ret != MEDIA_CONTENT_ERROR_NONE)
1630 content_error("error media_tag_update_to_db : [%d]", ret);
1633 ret = media_tag_get_tag_count_from_db(filter, &tag_count);
1634 if (ret != MEDIA_CONTENT_ERROR_NONE)
1635 content_error("error media_tag_get_tag_count_from_db : [%d]", ret);
1637 content_debug("tag_count [%d]", tag_count);
1640 ret = media_tag_foreach_tag_from_db(filter, tag_list_cb, NULL);
1641 if (ret != MEDIA_CONTENT_ERROR_NONE)
1642 content_error("error media_tag_foreach_tag_from_db : [%d]", ret);
1645 ret = media_tag_get_tag_id(tag_1, &tag_id_1);
1646 if (ret != MEDIA_CONTENT_ERROR_NONE)
1647 content_error("error media_tag_get_tag_id : [%d]", ret);
1649 content_debug("tag_id_1 [%d]", tag_id_1);
1651 ret = media_tag_get_tag_id(tag_2, &tag_id_2);
1652 if (ret != MEDIA_CONTENT_ERROR_NONE)
1653 content_error("error media_tag_get_tag_id : [%d]", ret);
1655 content_debug("tag_id_2 [%d]", tag_id_2);
1657 ret = media_tag_get_tag_id(tag_3, &tag_id_3);
1658 if (ret != MEDIA_CONTENT_ERROR_NONE)
1659 content_error("error media_tag_get_tag_id : [%d]", ret);
1661 content_debug("tag_id_3 [%d]", tag_id_3);
1663 /* Get media count */
1664 ret = media_tag_get_media_count_from_db(tag_id_1, NULL, &media_count);
1665 if (ret != MEDIA_CONTENT_ERROR_NONE)
1666 content_error("error media_tag_get_media_count_from_db : [%d]", ret);
1668 content_debug("tag_1_media_count [%d]", media_count);
1670 ret = media_tag_get_media_count_from_db(tag_id_2, NULL, &media_count);
1671 if (ret != MEDIA_CONTENT_ERROR_NONE)
1672 content_error("error media_tag_get_media_count_from_db : [%d]", ret);
1674 content_debug("tag_2_media_count [%d]", media_count);
1676 /* Get media of Tag */
1677 ret = media_tag_foreach_media_from_db(tag_id_1, NULL, media_item_cb, NULL);
1678 if (ret != MEDIA_CONTENT_ERROR_NONE)
1679 content_error("error media_tag_foreach_media_from_db : [%d]", ret);
1681 ret = media_tag_foreach_media_from_db(tag_id_2, NULL, media_item_cb, NULL);
1682 if (ret != MEDIA_CONTENT_ERROR_NONE)
1683 content_error("error media_tag_foreach_media_from_db : [%d]", ret);
1686 ret = media_tag_add_media(tag_2, test_video_id);
1687 if (ret != MEDIA_CONTENT_ERROR_NONE)
1688 content_error("error media_tag_add_media : [%d]", ret);
1689 ret = media_tag_set_name(tag_2, "test_tag");
1690 if (ret != MEDIA_CONTENT_ERROR_NONE)
1691 content_error("error media_tag_set_name : [%d]", ret);
1692 ret = media_tag_update_to_db(tag_2);
1693 if (ret != MEDIA_CONTENT_ERROR_NONE)
1694 content_error("error media_tag_update_to_db : [%d]", ret);
1696 /* Get Updated Tag*/
1697 ret = media_tag_foreach_tag_from_db(filter, tag_list_cb, NULL);
1698 if (ret != MEDIA_CONTENT_ERROR_NONE)
1699 content_error("error media_tag_foreach_tag_from_db : [%d]", ret);
1701 /* deletes the tag */
1702 ret = media_tag_delete_from_db(tag_id_1);
1703 if (ret != MEDIA_CONTENT_ERROR_NONE)
1704 content_error("error media_tag_delete_from_db : [%d]", ret);
1705 ret = media_tag_delete_from_db(tag_id_2);
1706 if (ret != MEDIA_CONTENT_ERROR_NONE)
1707 content_error("error media_tag_delete_from_db : [%d]", ret);
1709 ret = media_tag_destroy(tag_1);
1710 if (ret != MEDIA_CONTENT_ERROR_NONE)
1711 content_error("error media_tag_destroy : [%d]", ret);
1712 ret = media_tag_destroy(tag_2);
1713 if (ret != MEDIA_CONTENT_ERROR_NONE)
1714 content_error("error media_tag_destroy : [%d]", ret);
1715 ret = media_tag_destroy(tag_3);
1716 if (ret != MEDIA_CONTENT_ERROR_NONE)
1717 content_error("error media_tag_destroy : [%d]", ret);
1718 ret = media_filter_destroy(filter);
1719 if (ret != MEDIA_CONTENT_ERROR_NONE)
1720 content_error("error media_filter_destroy : [%d]", ret);
1725 int test_tag_operation_v2(void)
1727 int ret = MEDIA_CONTENT_ERROR_NONE;
1729 const char *tag_name_1 = "myTag_1";
1732 content_debug("\n============Tag Test V2============\n\n");
1735 ret = media_tag_create(&tag_1);
1736 if (ret != MEDIA_CONTENT_ERROR_NONE)
1737 content_error("error media_tag_create : [%d]", ret);
1739 ret = media_tag_set_name(tag_1, tag_name_1);
1740 if (ret != MEDIA_CONTENT_ERROR_NONE)
1741 content_error("error media_tag_set_name : [%d]", ret);
1743 /* Add media to Tag */
1744 ret = media_tag_add_media(tag_1, test_audio_id);
1745 if (ret != MEDIA_CONTENT_ERROR_NONE)
1746 content_error("error media_tag_add_media : [%d]", ret);
1748 ret = media_tag_add_media(tag_1, test_video_id);
1749 if (ret != MEDIA_CONTENT_ERROR_NONE)
1750 content_error("error media_tag_add_media : [%d]", ret);
1752 ret = media_tag_insert_to_db_v2(tag_1);
1753 if (ret != MEDIA_CONTENT_ERROR_NONE)
1754 content_error("error media_tag_insert_to_db_v2 : [%d]", ret);
1757 ret = media_tag_get_tag_id(tag_1, &tag_id);
1758 if (ret != MEDIA_CONTENT_ERROR_NONE)
1759 content_error("error media_tag_get_tag_id : [%d]", ret);
1761 ret = media_tag_remove_media(tag_1, test_video_id);
1762 if (ret != MEDIA_CONTENT_ERROR_NONE)
1763 content_error("error media_tag_add_media : [%d]", ret);
1765 ret = media_tag_update_to_db_v2(tag_id, tag_1);
1766 if (ret != MEDIA_CONTENT_ERROR_NONE)
1767 content_error("error media_tag_update_to_db_v2 : [%d]", ret);
1770 ret = media_tag_destroy(tag_1);
1771 if (ret != MEDIA_CONTENT_ERROR_NONE)
1772 content_error("error media_tag_destroy : [%d]", ret);
1777 static void __bookmark_handle_free(gpointer data)
1779 media_bookmark_h handle = (media_bookmark_h) data;
1780 media_bookmark_destroy(handle);
1783 int test_bookmark_operation(void)
1785 /* bookmark is only supported for video information. */
1786 int ret = MEDIA_CONTENT_ERROR_NONE;
1787 int bookmark_count = 0;
1789 GList *all_item_list = NULL;
1792 content_debug("\n============Bookmark Test============\n\n");
1794 const char *g_condition = "BOOKMARK_MARKED_TIME > 300";
1796 ret = media_filter_create(&filter);
1797 if (ret != MEDIA_CONTENT_ERROR_NONE)
1798 content_error("error media_filter_create : [%d]", ret);
1800 ret = media_filter_set_condition(filter, g_condition, MEDIA_CONTENT_COLLATE_DEFAULT);
1801 if (ret != MEDIA_CONTENT_ERROR_NONE)
1802 content_error("error media_filter_set_condition : [%d]", ret);
1804 ret = media_filter_set_order(filter, MEDIA_CONTENT_ORDER_DESC, BOOKMARK_MARKED_TIME, MEDIA_CONTENT_COLLATE_DEFAULT);
1805 if (ret != MEDIA_CONTENT_ERROR_NONE)
1806 content_error("error media_filter_set_order : [%d]", ret);
1808 /* insert bookmark to video */
1809 const char *thumbnail_path1 = tzplatform_mkpath(TZ_USER_VIDEOS, "teat11.jpg");
1810 ret = media_bookmark_insert_to_db(test_video_id, 400, thumbnail_path1);
1811 if (ret != MEDIA_CONTENT_ERROR_NONE)
1812 content_error("error media_bookmark_insert_to_db : [%d]", ret);
1814 ret = media_bookmark_insert_to_db(test_video_id, 600, thumbnail_path1);
1815 if (ret != MEDIA_CONTENT_ERROR_NONE)
1816 content_error("error media_bookmark_insert_to_db : [%d]", ret);
1818 ret = media_bookmark_get_bookmark_count_from_db(filter, &bookmark_count);
1819 if (ret != MEDIA_CONTENT_ERROR_NONE)
1820 content_error("error media_bookmark_get_bookmark_count_from_db : [%d]", ret);
1822 content_debug("bookmark_count = [%d]", bookmark_count);
1824 ret = media_info_foreach_bookmark_from_db(test_video_id, NULL, bookmarks_cb, &all_item_list);
1825 if (ret != MEDIA_CONTENT_ERROR_NONE)
1826 content_error("error media_info_foreach_bookmark_from_db : [%d]", ret);
1828 for (idx = 0; idx < g_list_length(all_item_list); idx++) {
1829 media_bookmark_h bookmark_handle;
1830 bookmark_handle = (media_bookmark_h)g_list_nth_data(all_item_list, idx);
1832 ret = media_bookmark_set_name(bookmark_handle, "test 1");
1833 if (ret != MEDIA_CONTENT_ERROR_NONE)
1834 content_error("error media_bookmark_set_name : [%d]", ret);
1836 ret = media_bookmark_update_to_db(bookmark_handle);
1837 if (ret != MEDIA_CONTENT_ERROR_NONE)
1838 content_error("error media_bookmark_update_to_db : [%d]", ret);
1842 g_list_free_full(all_item_list, __bookmark_handle_free);
1844 ret = media_info_foreach_bookmark_from_db(test_video_id, NULL, bookmarks_cb, NULL);
1845 if (ret != MEDIA_CONTENT_ERROR_NONE)
1846 content_error("error media_info_foreach_bookmark_from_db : [%d]", ret);
1848 ret = media_filter_destroy(filter);
1849 if (ret != MEDIA_CONTENT_ERROR_NONE)
1850 content_error("error media_filter_destroy : [%d]", ret);
1855 int test_bookmark_operation_v2(void)
1857 content_debug("\n============Bookmark Test V2============\n\n");
1859 int ret = MEDIA_CONTENT_ERROR_NONE;
1860 media_bookmark_h bookmark = NULL;
1861 const char *thumbnail_path1 = tzplatform_mkpath(TZ_USER_VIDEOS, "teat11.jpg");
1863 ret = media_bookmark_create(test_video_id, 400, &bookmark);
1864 if (ret != MEDIA_CONTENT_ERROR_NONE)
1865 content_error("error media_bookmark_create : [%d]", ret);
1867 ret = media_bookmark_set_name(bookmark, "test bookmark");
1868 if (ret != MEDIA_CONTENT_ERROR_NONE)
1869 content_error("error media_bookmark_set_name : [%d]", ret);
1871 ret = media_bookmark_set_thumbnail_path(bookmark, thumbnail_path1);
1872 if (ret != MEDIA_CONTENT_ERROR_NONE)
1873 content_error("error media_bookmark_set_thumbnail_path : [%d]", ret);
1875 ret = media_bookmark_insert_to_db_v2(bookmark);
1876 if (ret != MEDIA_CONTENT_ERROR_NONE)
1877 content_error("error media_bookmark_insert_to_db_v2 : [%d]", ret);
1879 ret = media_bookmark_set_name(bookmark, "test bookmark 2");
1880 if (ret != MEDIA_CONTENT_ERROR_NONE)
1881 content_error("error media_bookmark_set_name : [%d]", ret);
1883 ret = media_bookmark_update_to_db(bookmark);
1884 if (ret != MEDIA_CONTENT_ERROR_NONE)
1885 content_error("error media_bookmark_update_to_db : [%d]", ret);
1887 ret = media_bookmark_destroy(bookmark);
1888 if (ret != MEDIA_CONTENT_ERROR_NONE)
1889 content_error("error media_bookmark_destroy : [%d]", ret);
1894 int test_album_list(void)
1896 content_debug("\n============Album Test============\n\n");
1898 int ret = MEDIA_CONTENT_ERROR_NONE;
1899 int album_count = 0;
1903 const char *condition = "MEDIA_TYPE=3"; /*0-image, 1-video, 2-sound, 3-music, 4-other*/
1905 ret = media_filter_create(&filter);
1906 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1907 content_error("Fail to create filter");
1910 ret = media_filter_set_condition(filter, condition, MEDIA_CONTENT_COLLATE_DEFAULT);
1911 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1912 media_filter_destroy(filter);
1913 content_error("Fail to set condition");
1916 ret = media_filter_set_order(filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_ALBUM, MEDIA_CONTENT_COLLATE_NOCASE);
1917 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1918 media_filter_destroy(filter);
1919 content_error("Fail to set order");
1923 ret = media_album_get_album_count_from_db(filter, &album_count);
1924 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1925 media_filter_destroy(filter);
1928 content_debug("album_count [%d]", album_count);
1931 ret = media_album_foreach_album_from_db(filter, album_list_cb, NULL);
1932 if (ret != MEDIA_CONTENT_ERROR_NONE)
1933 content_error("error media_album_foreach_album_from_db : [%d]", ret);
1935 ret = media_filter_destroy(filter);
1936 if (ret != MEDIA_CONTENT_ERROR_NONE)
1937 content_error("error media_filter_destroy : [%d]", ret);
1942 int test_group_operation(void)
1944 content_debug("\n============Group Test============\n\n");
1946 int ret = MEDIA_CONTENT_ERROR_NONE;
1947 int group_count = 0;
1950 ret = test_filter_create();
1951 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1952 content_error("[error(0x%08x)", ret);
1956 for (idx = 0; idx < MEDIA_CONTENT_GROUP_MAX; idx++) {
1957 ret = media_group_get_group_count_from_db(g_filter, idx, &group_count);
1958 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1959 test_filter_destroy();
1960 content_error("media_group_get_group_count_from_db fail. ret=[%d] idx=[%d]", ret, idx);
1963 content_debug("[%2d]group_count [%d]", idx, group_count);
1966 ret = media_group_foreach_group_from_db(g_filter, idx, group_list_cb, &idx);
1967 if (ret != MEDIA_CONTENT_ERROR_NONE)
1968 content_error("media_group_foreach_group_from_db failed: %d", ret);
1970 ret = test_filter_destroy();
1975 int test_update_operation()
1977 int ret = MEDIA_CONTENT_ERROR_NONE;
1979 media_info_h media_handle = NULL;
1980 GList *all_item_list = NULL;
1982 /* Get all item list */
1983 ret = media_info_foreach_media_from_db(NULL, gallery_media_item_cb, &all_item_list);
1984 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1985 content_error("media_info_foreach_media_from_db failed: %d", ret);
1988 content_debug("media_info_foreach_media_from_db success");
1990 for (i = 0; i < g_list_length(all_item_list); i++) {
1991 media_handle = (media_info_h)g_list_nth_data(all_item_list, i);
1992 get_media_meta(media_handle);
1996 return MEDIA_CONTENT_ERROR_NONE;
1999 int test_insert(void)
2001 int ret = MEDIA_CONTENT_ERROR_NONE;
2002 const char *path = tzplatform_mkpath(TZ_USER_IMAGES, "Default.jpg");
2004 const char *path = tzplatform_mkpath(TZ_USER_DOCUMENTS, "other.txt"));
2007 media_info_h media_item = NULL;
2008 content_debug("\n============DB Insert Test============\n\n");
2010 ret = media_info_insert_to_db(path, &media_item);
2012 if ((ret == MEDIA_CONTENT_ERROR_NONE) && (media_item != NULL)) {
2013 content_debug("Insertion is success");
2015 content_error("Insertion is failed");
2016 ret = media_info_destroy(media_item);
2020 char *media_id = NULL;
2022 ret = media_info_get_media_id(media_item, &media_id);
2023 if (ret != MEDIA_CONTENT_ERROR_NONE)
2024 content_error("media_info_get_media_id failed: %d", ret);
2026 content_debug("Media ID: %s", media_id);
2028 SAFE_FREE(media_id);
2030 ret = media_info_update_to_db(media_item);
2031 if (ret == MEDIA_CONTENT_ERROR_NONE)
2032 content_debug("media_info_update_to_db is success");
2034 content_error("media_info_update_to_db is failed");
2036 ret = media_info_destroy(media_item);
2037 if (ret != MEDIA_CONTENT_ERROR_NONE)
2038 content_error("media_info_destroy failed: %d", ret);
2045 int ret = MEDIA_CONTENT_ERROR_NONE;
2046 const char *move_media_id = "60aea677-4742-408e-b5f7-f2628062d06d";
2047 const char *dst_path = tzplatform_mkpath(TZ_USER_IMAGES, "XX/Default1.jpg");
2048 media_info_h move_media = NULL;
2050 ret = media_info_get_media_from_db(move_media_id, &move_media);
2051 if (ret == MEDIA_CONTENT_ERROR_NONE)
2052 content_debug("media_info_get_media_from_db success");
2054 content_error("media_info_get_media_from_db failed: %d", ret);
2056 content_debug("\n============DB Move Test============\n\n");
2059 ret = media_info_move_to_db(move_media, dst_path);
2061 if (ret == MEDIA_CONTENT_ERROR_NONE)
2062 content_debug("Move is success");
2064 content_error("Move is failed");
2066 ret = media_info_destroy(move_media);
2068 content_debug("There is no item : %s", move_media_id);
2074 void thumbnail_completed_cb(media_content_error_e error, const char *path, void *user_data)
2076 char *thumbnail_path = NULL;
2077 int ret = MEDIA_CONTENT_ERROR_NONE;
2080 content_debug("=================[%d][%d]", g_media_cnt, g_cnt);
2081 content_debug("error_code [%d]", error);
2082 content_debug("thumbnail_path [%s]", path);
2083 if (user_data != NULL) {
2084 media_info_h media = (media_info_h)user_data;
2085 ret = media_info_get_thumbnail_path(media, &thumbnail_path);
2086 if (ret != MEDIA_CONTENT_ERROR_NONE)
2087 content_error("media_info_get_thumbnail_path failed: %d", ret);
2089 content_debug("thumbnail_path get from media[%s]", thumbnail_path);
2090 SAFE_FREE(thumbnail_path);
2091 ret = media_info_destroy(media);
2092 if (ret != MEDIA_CONTENT_ERROR_NONE)
2093 content_error("media_info_destroy failed: %d", ret);
2096 if (g_cnt == g_media_cnt)
2097 g_main_loop_quit(g_loop);
2102 bool thumbnail_create_cb(media_info_h media, void *user_data)
2104 char *media_id = NULL;
2105 media_info_h dst = NULL;
2106 int ret = MEDIA_CONTENT_ERROR_NONE;
2108 if (media == NULL) {
2109 content_debug("NO Item");
2113 ret = media_info_get_media_id(media, &media_id);
2114 if (ret != MEDIA_CONTENT_ERROR_NONE)
2115 content_error("media_info_get_media_id failed: %d", ret);
2117 content_debug("media_id : [%s]", media_id);
2119 ret = media_info_clone(&dst, media);
2120 if (ret != MEDIA_CONTENT_ERROR_NONE)
2121 content_error("media_info_clone failed: %d", ret);
2123 ret = media_info_create_thumbnail(dst, thumbnail_completed_cb, dst);
2124 if (ret != MEDIA_CONTENT_ERROR_NONE)
2125 content_error("media_info_create_thumbnail failed: %d", ret);
2128 /* fix prevent: Resource leak */
2129 SAFE_FREE(media_id);
2134 bool thumbnail_cancel_cb(media_info_h media, void *user_data)
2136 int ret = MEDIA_CONTENT_ERROR_NONE;
2138 char *media_id = NULL;
2139 media_info_h dst = NULL;
2143 if (media == NULL) {
2144 content_debug("NO Item");
2148 ret = media_info_get_media_id(media, &media_id);
2149 if (ret != MEDIA_CONTENT_ERROR_NONE)
2150 content_error("media_info_get_media_id failed: %d", ret);
2152 content_debug("media_id : [%s]", media_id);
2154 ret = media_info_clone(&dst, media);
2155 if (ret != MEDIA_CONTENT_ERROR_NONE)
2156 content_error("media_info_clone failed: %d", ret);
2158 ret = media_info_cancel_thumbnail(dst);
2159 if (ret != MEDIA_CONTENT_ERROR_NONE)
2160 content_error("media_info_cancel_thumbnail failed: %d", ret);
2162 ret = media_info_destroy(dst);
2163 if (ret != MEDIA_CONTENT_ERROR_NONE)
2164 content_error("media_info_destroy failed: %d", ret);
2166 if (g_cnt == g_media_cnt)
2167 g_main_loop_quit(g_loop);
2169 /* fix prevent: Resource leak */
2170 SAFE_FREE(media_id);
2175 gboolean create_thumbnail_start(gpointer data)
2177 int ret = MEDIA_CONTENT_ERROR_NONE;
2179 ret = media_info_foreach_media_from_db(g_filter, thumbnail_create_cb, NULL);
2181 if (ret == MEDIA_CONTENT_ERROR_NONE)
2182 content_debug("media_info_foreach_media_from_db is success");
2184 content_error("media_info_foreach_media_from_db is failed");
2189 gboolean cancel_thumbnail_start(gpointer data)
2191 int ret = MEDIA_CONTENT_ERROR_NONE;
2193 ret = media_info_foreach_media_from_db(g_filter, thumbnail_cancel_cb, NULL);
2195 if (ret == MEDIA_CONTENT_ERROR_NONE)
2196 content_debug("media_info_foreach_media_from_db is success");
2198 content_error("media_info_foreach_media_from_db is failed");
2203 int test_create_thumbnail(int cancel)
2205 int ret = MEDIA_CONTENT_ERROR_NONE;
2206 GSource *source = NULL;
2207 GMainContext *context = NULL;
2209 test_filter_create();
2211 ret = media_info_get_media_count_from_db(g_filter, &g_media_cnt);
2212 if (ret != MEDIA_CONTENT_ERROR_NONE)
2213 content_error("media_info_get_media_count_from_db failed: %d", ret);
2215 content_debug("media_count : [%d]", g_media_cnt);
2217 g_loop = g_main_loop_new(NULL, FALSE);
2218 context = g_main_loop_get_context(g_loop);
2219 source = g_idle_source_new();
2220 g_source_set_callback(source, create_thumbnail_start, NULL, NULL);
2221 g_source_attach(source, context);
2223 /* Logic to cancel */
2225 GSource *cancel_src = NULL;
2226 cancel_src = g_idle_source_new();
2227 g_source_set_callback(cancel_src, cancel_thumbnail_start, NULL, NULL);
2228 g_source_attach(cancel_src, context);
2231 g_main_loop_run(g_loop);
2232 g_main_loop_unref(g_loop);
2234 test_filter_destroy();
2239 bool face_cb(media_face_h face, void *user_data)
2241 get_face_meta(face);
2246 void face_detection_complete_cb(media_content_error_e error, int count, void *user_data)
2248 int ret = MEDIA_CONTENT_ERROR_NONE;
2251 content_debug("=================[%d][%d]", g_media_cnt, g_cnt);
2252 content_debug("error_code [%d]", error);
2253 content_debug("face_count [%d]", count);
2255 content_debug("No faces are detected!");
2256 } else if (user_data != NULL) {
2257 media_info_h media = (media_info_h)user_data;
2258 char *media_id = NULL;
2259 ret = media_info_get_media_id(media, &media_id);
2260 if (ret != MEDIA_CONTENT_ERROR_NONE)
2261 content_error("media_info_get_media_id failed: %d", ret);
2262 if (media_id != NULL) {
2263 ret = media_info_foreach_face_from_db(media_id, NULL, face_cb, NULL);
2264 SAFE_FREE(media_id);
2265 if (ret != MEDIA_CONTENT_ERROR_NONE)
2266 content_error("media_info_foreach_face_from_db failed: %d", ret);
2268 ret = media_info_destroy(media);
2269 if (ret != MEDIA_CONTENT_ERROR_NONE)
2270 content_error("media_info_destroy failed: %d", ret);
2273 if (g_cnt == g_media_cnt)
2274 g_main_loop_quit(g_loop);
2279 bool start_face_detection_cb(media_info_h media, void *user_data)
2281 char *media_id = NULL;
2282 media_info_h dst = NULL;
2283 int ret = MEDIA_CONTENT_ERROR_NONE;
2285 if (media == NULL) {
2286 content_debug("NO Item");
2290 ret = media_info_get_media_id(media, &media_id);
2291 if (ret != MEDIA_CONTENT_ERROR_NONE)
2292 content_error("media_info_get_media_id failed: %d", ret);
2294 content_debug("media_id : [%s]", media_id);
2296 ret = media_info_clone(&dst, media);
2297 if (ret != MEDIA_CONTENT_ERROR_NONE)
2298 content_error("media_info_clone failed: %d", ret);
2300 GList **list = (GList**)user_data;
2301 *list = g_list_append(*list, dst);
2303 /* fix prevent: Resource leak */
2304 SAFE_FREE(media_id);
2309 bool cancel_face_detection_cb(media_info_h media, void *user_data)
2311 int ret = MEDIA_CONTENT_ERROR_NONE;
2313 char *media_id = NULL;
2314 media_info_h dst = NULL;
2318 if (media == NULL) {
2319 content_debug("NO Item");
2323 ret = media_info_get_media_id(media, &media_id);
2324 if (ret != MEDIA_CONTENT_ERROR_NONE)
2325 content_error("media_info_get_media_id failed: %d", ret);
2327 content_debug("media_id : [%s]", media_id);
2329 ret = media_info_clone(&dst, media);
2330 if (ret != MEDIA_CONTENT_ERROR_NONE)
2331 content_error("media_info_clone failed: %d", ret);
2333 ret = media_info_cancel_face_detection(dst);
2334 if (ret != MEDIA_CONTENT_ERROR_NONE)
2335 content_error("media_info_cancel_face_detection failed: %d", ret);
2337 ret = media_info_destroy(dst);
2338 if (ret != MEDIA_CONTENT_ERROR_NONE)
2339 content_error("media_info_destroy failed: %d", ret);
2341 if (g_cnt == g_media_cnt)
2342 g_main_loop_quit(g_loop);
2344 /* fix prevent: Resource leak */
2345 SAFE_FREE(media_id);
2350 gboolean face_detection_start(gpointer data)
2352 int ret = MEDIA_CONTENT_ERROR_NONE;
2353 GList *all_item_list = NULL;
2356 ret = media_info_foreach_media_from_db(g_filter, start_face_detection_cb, &all_item_list);
2358 if (ret == MEDIA_CONTENT_ERROR_NONE)
2359 content_debug("media_info_foreach_media_from_db is success");
2361 content_error("media_info_foreach_media_from_db is failed");
2363 for (idx = 0; idx < g_list_length(all_item_list); idx++) {
2364 media_info_h media_handle = NULL;
2366 media_handle = (media_info_h)g_list_nth_data(all_item_list, idx);
2368 ret = media_info_start_face_detection(media_handle, face_detection_complete_cb, NULL);
2369 if (ret != MEDIA_CONTENT_ERROR_NONE)
2370 content_error("media_info_start_face_detection failed: %d", ret);
2377 gboolean face_detection_cancel(gpointer data)
2379 int ret = MEDIA_CONTENT_ERROR_NONE;
2381 ret = media_info_foreach_media_from_db(g_filter, cancel_face_detection_cb, NULL);
2383 if (ret == MEDIA_CONTENT_ERROR_NONE)
2384 content_debug("media_info_foreach_media_from_db is success");
2386 content_error("media_info_foreach_media_from_db is failed");
2391 int test_start_face_detection(int cancel)
2393 int ret = MEDIA_CONTENT_ERROR_NONE;
2394 GSource *source = NULL;
2395 GMainContext *context = NULL;
2397 test_filter_create();
2399 ret = media_info_get_media_count_from_db(g_filter, &g_media_cnt);
2400 if (ret != MEDIA_CONTENT_ERROR_NONE)
2401 content_error("media_info_get_media_count_from_db failed: %d", ret);
2403 content_debug("media_count : [%d]", g_media_cnt);
2405 if (g_media_cnt == 0)
2408 g_loop = g_main_loop_new(NULL, FALSE);
2409 context = g_main_loop_get_context(g_loop);
2410 source = g_idle_source_new();
2411 g_source_set_callback(source, face_detection_start, NULL, NULL);
2412 g_source_attach(source, context);
2414 /* Logic to cancel */
2416 GSource *cancel_src = NULL;
2417 cancel_src = g_idle_source_new();
2418 g_source_set_callback(cancel_src, face_detection_cancel, NULL, NULL);
2419 g_source_attach(cancel_src, context);
2422 g_main_loop_run(g_loop);
2423 g_main_loop_unref(g_loop);
2426 test_filter_destroy();
2431 int test_ebook_text_finder(const char *keyword)
2433 int ret = MEDIA_CONTENT_ERROR_NONE;
2434 char **book_path_list = NULL;
2435 unsigned int book_path_len = 0;
2437 media_info_h media = NULL;
2438 book_meta_h book = NULL;
2439 char *s_value = NULL;
2440 long long ms_time = 0;
2441 struct timeval start_time;
2442 struct timeval end_time;
2444 gettimeofday(&start_time, NULL);
2446 ret = book_meta_get_path_with_keyword(keyword, &book_path_list, &book_path_len);
2447 if (ret == MEDIA_CONTENT_ERROR_NONE)
2448 content_debug("book_meta_get_path_with_keyword is success");
2450 content_error("book_meta_get_path_with_keyword is failed");
2452 gettimeofday(&end_time, NULL);
2454 for (i = 0; i < book_path_len; i++) {
2455 ret = media_info_get_media_from_db_by_path(book_path_list[i], &media);
2456 if (ret != MEDIA_CONTENT_ERROR_NONE)
2459 content_debug("===============================");
2460 content_debug("[%d] %s", i, book_path_list[i]);
2461 content_debug("===============================");
2462 media_info_get_title(media, &s_value);
2463 content_debug("Title : %s", s_value);
2467 ret = media_info_get_book(media, &book);
2468 if (ret != MEDIA_CONTENT_ERROR_NONE) {
2469 media_info_destroy(media);
2473 ret = book_meta_get_author(book, &s_value);
2474 if (ret == MEDIA_CONTENT_ERROR_NONE && s_value) {
2475 content_debug("Author : %s", s_value);
2480 ret = book_meta_get_date(book, &s_value);
2481 if (ret == MEDIA_CONTENT_ERROR_NONE && s_value) {
2482 content_debug("Date : %s", s_value);
2487 content_debug("===============================");
2488 ret = book_meta_destroy(book);
2489 if (ret != MEDIA_CONTENT_ERROR_NONE)
2490 content_error("book_meta_destroy failed");
2492 ret = media_info_destroy(media);
2493 if (ret != MEDIA_CONTENT_ERROR_NONE)
2494 content_error("media_info_destroy failed");
2496 g_free(book_path_list[i]);
2499 ms_time = (end_time.tv_sec * 1000LL + end_time.tv_usec / 1000) - (start_time.tv_sec * 1000LL + start_time.tv_usec/ 1000);
2500 content_debug("Search Time [%lld]", ms_time);
2502 g_free(book_path_list);
2506 int test_disconnect_database(void)
2508 int ret = MEDIA_CONTENT_ERROR_NONE;
2509 content_debug("\n============DB Disconnection Test============\n\n");
2511 ret = media_content_disconnect();
2513 if (ret == MEDIA_CONTENT_ERROR_NONE)
2514 content_debug("disconnection is success");
2516 content_error("disconnection is failed");
2521 int test_request_update_db(void)
2523 int ret = MEDIA_CONTENT_ERROR_NONE;
2524 media_info_h media = NULL;
2525 bool favorite = FALSE;
2527 ret = media_info_get_media_from_db("71b19196-5b38-4ab1-ab34-bfe05c369614", &media);
2528 if (ret != MEDIA_CONTENT_ERROR_NONE)
2529 content_error("media_info_get_media_from_db failed: %d", ret);
2531 ret = media_info_set_favorite(media, TRUE);
2532 if (ret != MEDIA_CONTENT_ERROR_NONE)
2533 content_error("media_info_set_favorite failed: %d", ret);
2535 ret = media_info_update_to_db(media);
2536 if (ret == MEDIA_CONTENT_ERROR_NONE)
2537 content_debug("media_info_update_to_db is success");
2539 content_error("media_info_update_to_db is failed");
2542 media_info_destroy(media);
2544 /*get the updated value*/
2545 ret = media_info_get_media_from_db("71b19196-5b38-4ab1-ab34-bfe05c369614", &media);
2546 if (ret != MEDIA_CONTENT_ERROR_NONE)
2547 content_error("media_info_get_media_from_db failed: %d", ret);
2549 ret = media_info_get_favorite(media, &favorite);
2550 if (ret != MEDIA_CONTENT_ERROR_NONE)
2551 content_error("media_info_get_favorite failed: %d", ret);
2553 content_debug("favorite [%d]", favorite);
2555 ret = media_info_destroy(media);
2560 static int g_total_photo_size = 0;
2561 static int g_total_video_size = 0;
2562 static int g_total_mp3_size = 0;
2563 static int g_total_voice_memo_size = 0;
2565 bool dft_cb(media_info_h media, void *user_data)
2567 unsigned long long file_size = 0;
2568 media_content_type_e media_type = -1;
2569 char *mime_type = NULL;
2570 int ret = MEDIA_CONTENT_ERROR_NONE;
2575 ret = media_info_get_media_type(media, &media_type);
2576 if (ret != MEDIA_CONTENT_ERROR_NONE)
2577 content_error("media_info_get_media_type failed: %d", ret);
2578 ret = media_info_get_size(media, &file_size);
2579 if (ret != MEDIA_CONTENT_ERROR_NONE)
2580 content_error("media_info_get_size failed: %d", ret);
2581 ret = media_info_get_mime_type(media, &mime_type);
2582 if (ret != MEDIA_CONTENT_ERROR_NONE)
2583 content_error("media_info_get_mime_type failed: %d", ret);
2585 if (media_type == MEDIA_CONTENT_TYPE_IMAGE)
2586 g_total_photo_size += file_size;
2587 else if (media_type == MEDIA_CONTENT_TYPE_VIDEO)
2588 g_total_video_size += file_size;
2589 else if (media_type == MEDIA_CONTENT_TYPE_SOUND)
2590 g_total_voice_memo_size += file_size;
2591 else if (media_type == MEDIA_CONTENT_TYPE_MUSIC) {
2592 if ((mime_type != NULL) && (!strcmp("audio/mpeg", mime_type)))
2593 g_total_mp3_size += file_size;
2595 g_total_voice_memo_size += file_size;
2597 content_debug("invalid media_type");
2599 SAFE_FREE(mime_type);
2607 int ret = MEDIA_CONTENT_ERROR_NONE;
2608 content_debug("\n============DFT_test============\n\n");
2610 filter_h filter = NULL;
2613 /*MEDIA_TYPE 0-image, 1-video, 2-sound, 3-music, 4-other*/
2615 ret = media_filter_create(&filter);
2618 content_debug("[Internal Memory]\n");
2619 /*1. Photo ============================================================*/
2620 ret = media_filter_set_condition(filter, "MEDIA_STORAGE_TYPE=0 AND MEDIA_TYPE=0", MEDIA_CONTENT_COLLATE_DEFAULT);
2623 ret = media_info_get_media_count_from_db(filter, &media_cnt);
2624 content_debug("Photo count = [%d]\n", media_cnt);
2627 ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
2628 content_debug("Photo size = [%d]\n", g_total_photo_size);
2630 /*2. Video ============================================================*/
2631 ret = media_filter_set_condition(filter, "MEDIA_STORAGE_TYPE=0 AND MEDIA_TYPE=1", MEDIA_CONTENT_COLLATE_DEFAULT);
2634 ret = media_info_get_media_count_from_db(filter, &media_cnt);
2635 content_debug("Video count = [%d]\n", media_cnt);
2638 ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
2639 content_debug("Video size = [%d]\n", g_total_video_size);
2641 /*3. MP3 ============================================================*/
2642 ret = media_filter_set_condition(filter, "MEDIA_STORAGE_TYPE=0 AND MEDIA_TYPE=3 AND MEDIA_MIME_TYPE=\"audio/mpeg\"", MEDIA_CONTENT_COLLATE_DEFAULT);
2645 ret = media_info_get_media_count_from_db(filter, &media_cnt);
2646 content_debug("MP3 count = [%d]\n", media_cnt);
2649 ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
2650 content_debug("MP3 size = [%d]\n", g_total_mp3_size);
2652 /*4. Voice Memo ============================================================*/
2653 ret = media_filter_set_condition(filter, "MEDIA_STORAGE_TYPE=0 AND (MEDIA_MIME_TYPE=\"audio/AMR\" OR MEDIA_MIME_TYPE=\"audio/mp4\")", MEDIA_CONTENT_COLLATE_DEFAULT);
2655 /*Get Voice Memo Count*/
2656 ret = media_info_get_media_count_from_db(filter, &media_cnt);
2657 content_debug("Voice Memo count = [%d]\n", media_cnt);
2659 /*Get Voice Memo Size*/
2660 ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
2661 content_debug("Voice Memo size = [%d]\n", g_total_voice_memo_size);
2663 g_total_photo_size = 0;
2664 g_total_video_size = 0;
2665 g_total_mp3_size = 0;
2666 g_total_voice_memo_size = 0;
2669 content_debug("\n[External Memory]\n");
2670 /*1. Photo ============================================================*/
2671 ret = media_filter_set_condition(filter, "MEDIA_STORAGE_TYPE=1 AND MEDIA_TYPE=0", MEDIA_CONTENT_COLLATE_DEFAULT);
2674 ret = media_info_get_media_count_from_db(filter, &media_cnt);
2675 content_debug("Photo count = [%d]\n", media_cnt);
2678 ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
2679 content_debug("Photo size = [%d]\n", g_total_photo_size);
2681 /*2. Video ============================================================*/
2682 ret = media_filter_set_condition(filter, "MEDIA_STORAGE_TYPE=1 AND MEDIA_TYPE=1", MEDIA_CONTENT_COLLATE_DEFAULT);
2685 ret = media_info_get_media_count_from_db(filter, &media_cnt);
2686 content_debug("Video count = [%d]\n", media_cnt);
2689 ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
2690 content_debug("Video size = [%d]\n", g_total_video_size);
2692 /*3. MP3 ============================================================*/
2693 ret = media_filter_set_condition(filter, "MEDIA_STORAGE_TYPE=1 AND MEDIA_TYPE=3 AND MEDIA_MIME_TYPE=\"audio/mpeg\"", MEDIA_CONTENT_COLLATE_DEFAULT);
2696 ret = media_info_get_media_count_from_db(filter, &media_cnt);
2697 content_debug("MP3 count = [%d]\n", media_cnt);
2700 ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
2701 content_debug("MP3 size = [%d]\n", g_total_mp3_size);
2703 /*4. Voice Memo ============================================================*/
2704 ret = media_filter_set_condition(filter, "MEDIA_STORAGE_TYPE=1 AND (MEDIA_MIME_TYPE=\"audio/AMR\" OR MEDIA_MIME_TYPE=\"audio/mp4\")", MEDIA_CONTENT_COLLATE_DEFAULT);
2706 /*Get Voice Memo Count*/
2707 ret = media_info_get_media_count_from_db(filter, &media_cnt);
2708 content_debug("Voice Memo count = [%d]\n", media_cnt);
2710 /*Get Voice Memo Size*/
2711 ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
2712 content_debug("Voice Memo size = [%d]\n", g_total_voice_memo_size);
2713 ret = media_filter_destroy(filter);
2718 void insert_batch_cb(media_content_error_e error, void * user_data)
2720 content_debug("media_info_insert_batch_to_db completed!\n");
2723 int test_batch_operations()
2727 char *file_list[10];
2729 for (i = 0; i < 10; i++) {
2730 file_list[i] = g_strdup_printf("%s%d.jpg", tzplatform_mkpath(TZ_USER_CONTENT, "test/image"), i+1);
2731 content_debug("File : %s\n", file_list[i]);
2734 ret = media_info_insert_batch_to_db((const char **)file_list, 10, insert_batch_cb, NULL);
2735 if (ret != MEDIA_CONTENT_ERROR_NONE)
2736 content_error("media_info_insert_batch_to_db failed : %d\n", ret);
2738 for (i = 0; i < 10; i++)
2739 g_free(file_list[i]);
2744 void _scan_cb(media_content_error_e err, void *user_data)
2746 content_debug("scan callback is called : %d\n", err);
2747 g_main_loop_quit(g_loop);
2752 int test_scan_file()
2756 const char *file_path = tzplatform_mkpath(TZ_USER_CONTENT, "test/image1.jpg");
2757 ret = media_content_scan_file(file_path);
2758 if (ret != MEDIA_CONTENT_ERROR_NONE) {
2759 content_error("Fail to media_content_scan_file : %d", ret);
2766 gboolean test_scan_dir_start(gpointer data)
2770 const char *dir_path = tzplatform_getenv(TZ_USER_CONTENT);
2772 ret = media_content_scan_folder(dir_path, TRUE, _scan_cb, NULL);
2774 if (ret != MEDIA_CONTENT_ERROR_NONE) {
2775 content_error("Fail to test_scan_dir_start : %d", ret);
2782 gboolean cancel_scan_dir_start(gpointer data)
2784 int ret = MEDIA_CONTENT_ERROR_NONE;
2786 const char *dir_path = tzplatform_getenv(TZ_USER_IMAGES);
2788 ret = media_content_cancel_scan_folder(dir_path);
2790 if (ret == MEDIA_CONTENT_ERROR_NONE)
2791 content_debug("media_content_cancel_scan_folder is success");
2793 content_error("media_content_cancel_scan_folder is failed");
2798 int test_scan_dir(int cancel)
2800 GSource *source = NULL;
2801 GMainContext *context = NULL;
2803 g_loop = g_main_loop_new(NULL, FALSE);
2804 context = g_main_loop_get_context(g_loop);
2805 source = g_idle_source_new();
2806 g_source_set_callback(source, test_scan_dir_start, NULL, NULL);
2807 g_source_attach(source, context);
2810 GSource *cancel_src = NULL;
2811 cancel_src = g_idle_source_new();
2812 g_source_set_callback(cancel_src, cancel_scan_dir_start, NULL, NULL);
2813 g_source_attach(cancel_src, context);
2816 g_main_loop_run(g_loop);
2817 g_main_loop_unref(g_loop);
2822 void _noti_cb(media_content_error_e error,
2824 media_content_db_update_item_type_e update_item,
2825 media_content_db_update_type_e update_type,
2826 media_content_type_e media_type,
2833 content_debug("noti success! : %d\n", error);
2835 content_debug("error occurred! : %d\n", error);
2837 content_debug("Noti from PID(%d)\n", pid);
2839 if (update_item == MEDIA_ITEM_FILE)
2840 content_debug("Noti item : MEDIA_ITEM_FILE\n");
2841 else if (update_item == MEDIA_ITEM_DIRECTORY)
2842 content_debug("Noti item : MEDIA_ITEM_DIRECTORY\n");
2844 if (update_type == MEDIA_CONTENT_INSERT)
2845 content_debug("Noti type : MEDIA_CONTENT_INSERT\n");
2846 else if (update_type == MEDIA_CONTENT_DELETE)
2847 content_debug("Noti type : MEDIA_CONTENT_DELETE\n");
2848 else if (update_type == MEDIA_CONTENT_UPDATE)
2849 content_debug("Noti type : MEDIA_CONTENT_UPDATE\n");
2851 content_debug("content type : %d\n", media_type);
2854 content_debug("path : %s\n", path);
2856 content_debug("path not\n");
2859 content_debug("uuid : %s\n", uuid);
2861 content_debug("uuid not\n");
2864 content_debug("mime_type : %s\n", mime_type);
2866 content_debug("mime not\n");
2868 if (user_data) content_debug("String : %s\n", (char *)user_data);
2873 void _noti_cb_2(media_content_error_e error,
2875 media_content_db_update_item_type_e update_item,
2876 media_content_db_update_type_e update_type,
2877 media_content_type_e media_type,
2884 content_debug("noti_2 success! : %d\n", error);
2886 content_debug("error occurred! : %d\n", error);
2888 content_debug("Noti_2 from PID(%d)\n", pid);
2890 g_main_loop_quit(g_loop);
2894 static media_content_noti_h noti_h;
2895 static media_content_noti_h noti_h_2;
2897 gboolean _send_noti_operations(gpointer data)
2899 int ret = MEDIA_CONTENT_ERROR_NONE;
2901 /* First of all, noti subscription */
2902 char *user_str = strdup("hi");
2903 media_content_add_db_updated_cb(_noti_cb, (void*)user_str, ¬i_h);
2904 media_content_add_db_updated_cb(_noti_cb_2, (void*)user_str, ¬i_h_2);
2906 /* media_info_insert_to_db */
2907 media_info_h media_item = NULL;
2908 const char *path = tzplatform_mkpath(TZ_USER_CONTENT, "test/image1.jpg");
2910 ret = media_info_insert_to_db(path, &media_item);
2911 if (ret != MEDIA_CONTENT_ERROR_NONE) {
2912 content_error("media_info_insert_to_db failed : %d", ret);
2913 media_info_destroy(media_item);
2917 content_debug("media_info_insert_to_db success");
2919 media_content_remove_db_updated_cb(noti_h);
2921 /* media_info_update_to_db */
2922 ret = media_info_update_to_db(media_item);
2923 if (ret != MEDIA_CONTENT_ERROR_NONE) {
2924 content_error("media_info_update_to_db failed : %d\n", ret);
2925 media_info_destroy(media_item);
2929 media_info_destroy(media_item);
2936 int ret = MEDIA_CONTENT_ERROR_NONE;
2937 GSource *source = NULL;
2938 GMainContext *context = NULL;
2940 g_loop = g_main_loop_new(NULL, FALSE);
2941 context = g_main_loop_get_context(g_loop);
2942 source = g_idle_source_new();
2943 g_source_set_callback(source, _send_noti_operations, NULL, NULL);
2944 g_source_attach(source, context);
2946 g_main_loop_run(g_loop);
2947 g_main_loop_unref(g_loop);
2949 test_filter_destroy();
2950 media_content_remove_db_updated_cb(noti_h_2);
2955 bool media_face_test_cb(media_face_h face, void *user_data)
2957 get_face_meta(face);
2959 if (user_data != NULL) {
2960 media_face_h new_face = NULL;
2961 media_face_clone(&new_face, face);
2963 GList **list = (GList**)user_data;
2964 *list = g_list_append(*list, new_face);
2972 int ret = MEDIA_CONTENT_ERROR_NONE;
2973 filter_h filter = NULL;
2974 GList *all_item_list = NULL;
2977 ret = media_filter_create(&filter);
2978 content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "fail media_filter_create");
2980 ret = media_filter_set_condition(filter, "MEDIA_TYPE = 0", MEDIA_CONTENT_COLLATE_DEFAULT);
2981 if (ret != MEDIA_CONTENT_ERROR_NONE) {
2982 media_filter_destroy(filter);
2983 content_error("Fail to set condition");
2987 ret = media_info_foreach_media_from_db(filter, gallery_media_item_cb, &all_item_list);
2988 if (ret != MEDIA_CONTENT_ERROR_NONE) {
2989 content_error("media_info_foreach_media_from_db failed: %d", ret);
2990 media_filter_destroy(filter);
2994 for (i = 0; i < g_list_length(all_item_list); i++) {
2995 media_info_h media_handle = NULL;
2996 char *media_id = NULL;
2999 media_handle = (media_info_h)g_list_nth_data(all_item_list, i);
3001 ret = media_info_get_media_id(media_handle, &media_id);
3002 if (ret != MEDIA_CONTENT_ERROR_NONE)
3003 content_error("media_info_get_media_id failed: %d", ret);
3005 ret = media_info_get_face_count_from_db(media_id, filter, &face_count);
3006 if (ret != MEDIA_CONTENT_ERROR_NONE)
3007 content_error("media_info_get_face_count_from_db failed: %d", ret);
3009 content_error("media_id [%s] face_count [%d]", media_id, face_count);
3011 ret = media_info_foreach_face_from_db(media_id, filter, media_face_test_cb, NULL);
3012 if (ret != MEDIA_CONTENT_ERROR_NONE)
3013 content_error("media_info_foreach_face_from_db failed: %d", ret);
3015 media_info_destroy(media_handle);
3018 media_filter_destroy(filter);
3023 int test_face_add_del(void)
3025 int ret = MEDIA_CONTENT_ERROR_NONE;
3026 char *media_id = "ecca7366-e085-41d8-a12b-cbdfc2b9c5fc";
3029 media_face_h face = NULL;
3031 char *face_tag = "test_face_tag";
3033 ret = media_face_create(media_id, &face);
3034 content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "fail media_face_create");
3036 ret = media_face_set_face_rect(face, 10, 12, 50, 100);
3037 if (ret != MEDIA_CONTENT_ERROR_NONE)
3038 content_error("media_face_set_face_rect failed: %d", ret);
3040 ret = media_face_set_orientation(face, 5);
3041 if (ret != MEDIA_CONTENT_ERROR_NONE)
3042 content_error("media_face_set_orientation failed: %d", ret);
3044 ret = media_face_set_tag(face, face_tag);
3045 if (ret != MEDIA_CONTENT_ERROR_NONE)
3046 content_error("media_face_set_tag failed: %d", ret);
3048 ret = media_face_insert_to_db(face);
3049 if (ret != MEDIA_CONTENT_ERROR_NONE)
3050 content_error("media_face_insert_to_db failed: %d", ret);
3052 ret = media_face_destroy(face);
3053 if (ret != MEDIA_CONTENT_ERROR_NONE)
3054 content_error("media_face_destroy failed: %d", ret);
3057 GList *all_item_list = NULL;
3058 filter_h filter = NULL;
3059 ret = media_filter_create(&filter);
3060 content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "fail media_filter_create");
3062 ret = media_filter_set_condition(filter, "MEDIA_FACE_TAG IS NOT NULL", MEDIA_CONTENT_COLLATE_DEFAULT);
3063 if (ret != MEDIA_CONTENT_ERROR_NONE) {
3064 media_filter_destroy(filter);
3065 content_error("Fail to set condition");
3069 ret = media_info_foreach_face_from_db(media_id, filter, media_face_test_cb, &all_item_list);
3071 if (g_list_length(all_item_list) > 0) {
3072 media_face_h face_handle = NULL;
3073 face_handle = (media_face_h)g_list_nth_data(all_item_list, 0);
3075 ret = media_face_set_face_rect(face_handle, 20, 22, 70, 70);
3076 if (ret != MEDIA_CONTENT_ERROR_NONE)
3077 content_error("media_face_set_face_rect failed: %d", ret);
3078 ret = media_face_set_orientation(face_handle, 3);
3079 if (ret != MEDIA_CONTENT_ERROR_NONE)
3080 content_error("media_face_set_orientation failed: %d", ret);
3081 ret = media_face_set_tag(face_handle, NULL);
3082 if (ret != MEDIA_CONTENT_ERROR_NONE)
3083 content_error("media_face_set_tag failed: %d", ret);
3084 ret = media_face_update_to_db(face_handle);
3085 if (ret != MEDIA_CONTENT_ERROR_NONE)
3086 content_error("media_face_update_to_db failed: %d", ret);
3088 media_face_destroy(face_handle);
3091 media_filter_destroy(filter);
3094 char *face_id = "5e58a3a8-f0b2-4c29-b799-b49a70dc2313";
3097 ret = media_face_delete_from_db(face_id);
3102 #ifdef _USE_TVPD_MODE
3103 filter_h g_tv_filter = NULL;
3105 int test_tv_filter_create(void)
3107 content_debug("\n============Filter Create============\n\n");
3109 int ret = MEDIA_CONTENT_ERROR_NONE;
3111 ret = media_filter_create(&g_tv_filter);
3113 ret = media_filter_set_storage(g_tv_filter, "0a22a163-e634-4a2e-ba14-0469a969eea0");
3115 ret = media_filter_set_order(g_tv_filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_TITLE, MEDIA_CONTENT_COLLATE_DEFAULT);
3120 int test_tv_filter_destroy(void)
3122 content_debug("\n============Filter Destroy============\n\n");
3124 int ret = MEDIA_CONTENT_ERROR_NONE;
3126 ret = media_filter_destroy(g_tv_filter);
3131 bool pvr_item_cb(media_pvr_h pvr, void *user_data)
3133 int ret = MEDIA_CONTENT_ERROR_NONE;
3134 char *c_value = NULL;
3136 bool b_value = false;
3137 unsigned long long l_value = 0;
3140 content_debug("NO Item");
3144 ret = media_pvr_get_media_id(pvr, &c_value);
3145 if (ret != MEDIA_CONTENT_ERROR_NONE)
3146 content_error("Fail to media_pvr_get_media_id");
3147 content_debug("media_id [%s]", c_value);
3150 ret = media_pvr_get_channel_name(pvr, &c_value);
3151 if (ret != MEDIA_CONTENT_ERROR_NONE)
3152 content_error("Fail to media_pvr_get_channel_name");
3153 content_debug("channel_name [%s]", c_value);
3156 ret = media_pvr_get_program_title(pvr, &c_value);
3157 if (ret != MEDIA_CONTENT_ERROR_NONE)
3158 content_error("Fail to media_pvr_get_program_title");
3159 content_debug("program_title [%s]", c_value);
3162 ret = media_pvr_get_program_crid(pvr, &c_value);
3163 if (ret != MEDIA_CONTENT_ERROR_NONE)
3164 content_error("Fail to media_pvr_get_program_crid");
3165 content_debug("program_crid [%s]", c_value);
3168 ret = media_pvr_get_guidance(pvr, &c_value);
3169 if (ret != MEDIA_CONTENT_ERROR_NONE)
3170 content_error("Fail to media_pvr_get_guidance");
3171 content_debug("guidance [%s]", c_value);
3174 ret = media_pvr_get_synopsis(pvr, &c_value);
3175 if (ret != MEDIA_CONTENT_ERROR_NONE)
3176 content_error("Fail to media_pvr_get_synopsis");
3177 content_debug("synopsis [%s]", c_value);
3180 ret = media_pvr_get_genre(pvr, &c_value);
3181 if (ret != MEDIA_CONTENT_ERROR_NONE)
3182 content_error("Fail to media_pvr_get_synopsis");
3183 content_debug("genre [%s]", c_value);
3186 ret = media_pvr_get_language(pvr, &c_value);
3187 if (ret != MEDIA_CONTENT_ERROR_NONE)
3188 content_error("Fail to media_pvr_get_language");
3189 content_debug("language [%s]", c_value);
3192 ret = media_pvr_get_path(pvr, &c_value);
3193 if (ret != MEDIA_CONTENT_ERROR_NONE)
3194 content_error("Fail to media_pvr_get_path");
3195 content_debug("path [%s]", c_value);
3198 ret = media_pvr_get_storage_id(pvr, &c_value);
3199 if (ret != MEDIA_CONTENT_ERROR_NONE)
3200 content_error("Fail to media_pvr_get_storage_id");
3201 content_debug("storage_id [%s]", c_value);
3204 ret = media_pvr_get_size(pvr, &l_value);
3205 if (ret != MEDIA_CONTENT_ERROR_NONE)
3206 content_error("Fail to media_pvr_get_size");
3207 content_debug("size [%lld]", l_value);
3209 ret = media_pvr_get_timezone(pvr, &i_value);
3210 if (ret != MEDIA_CONTENT_ERROR_NONE)
3211 content_error("Fail to media_pvr_get_timezone");
3212 content_debug("timezone [%d]", i_value);
3214 ret = media_pvr_get_ptc(pvr, &i_value);
3215 if (ret != MEDIA_CONTENT_ERROR_NONE)
3216 content_error("Fail to media_pvr_get_ptc");
3217 content_debug("ptc [%d]", i_value);
3219 ret = media_pvr_get_major(pvr, &i_value);
3220 if (ret != MEDIA_CONTENT_ERROR_NONE)
3221 content_error("Fail to media_pvr_get_major");
3222 content_debug("[%d]", i_value);
3224 ret = media_pvr_get_minor(pvr, &i_value);
3225 if (ret != MEDIA_CONTENT_ERROR_NONE)
3226 content_error("Fail to media_pvr_get_minor");
3227 content_debug("minor [%d]", i_value);
3229 ret = media_pvr_get_channel_type(pvr, &i_value);
3230 if (ret != MEDIA_CONTENT_ERROR_NONE)
3231 content_error("Fail to media_pvr_get_channel_type");
3232 content_debug("channel_type [%d]", i_value);
3234 ret = media_pvr_get_program_num(pvr, &i_value);
3235 if (ret != MEDIA_CONTENT_ERROR_NONE)
3236 content_error("Fail to media_pvr_get_program_num");
3237 content_debug("program_num [%d]", i_value);
3239 unsigned int ui_value = 0;
3240 ret = media_pvr_get_service_profile(pvr, &ui_value);
3241 if (ret != MEDIA_CONTENT_ERROR_NONE)
3242 content_error("Fail to media_pvr_get_service_profile");
3243 content_debug("service_profile [%u]", ui_value);
3245 ret = media_pvr_get_duration(pvr, &i_value);
3246 if (ret != MEDIA_CONTENT_ERROR_NONE)
3247 content_error("Fail to media_pvr_get_duration");
3248 content_debug("duration [%d]", i_value);
3250 ret = media_pvr_get_embargo_time(pvr, &i_value);
3251 if (ret != MEDIA_CONTENT_ERROR_NONE)
3252 content_error("Fail to media_pvr_get_embargo_time");
3253 content_debug("embargo_time [%d]", i_value);
3255 ret = media_pvr_get_expiry_time(pvr, &i_value);
3256 if (ret != MEDIA_CONTENT_ERROR_NONE)
3257 content_error("Fail to media_pvr_get_expiry_time");
3258 content_debug("expiry_time [%d]", i_value);
3260 ret = media_pvr_get_parental_rating(pvr, &i_value);
3261 if (ret != MEDIA_CONTENT_ERROR_NONE)
3262 content_error("Fail to media_pvr_get_parental_rating");
3263 content_debug("parental_rating [%d]", i_value);
3265 ret = media_pvr_get_start_time(pvr, &i_value);
3266 if (ret != MEDIA_CONTENT_ERROR_NONE)
3267 content_error("Fail to media_pvr_get_start_time");
3268 content_debug("start_time [%d]", i_value);
3270 ret = media_pvr_get_program_start_time(pvr, &i_value);
3271 if (ret != MEDIA_CONTENT_ERROR_NONE)
3272 content_error("Fail to media_pvr_get_program_start_time");
3273 content_debug("program_start_time [%d]", i_value);
3275 ret = media_pvr_get_program_end_time(pvr, &i_value);
3276 if (ret != MEDIA_CONTENT_ERROR_NONE)
3277 content_error("Fail to media_pvr_get_program_end_time");
3278 content_debug("program_end_time [%d]", i_value);
3280 ret = media_pvr_get_program_date(pvr, &i_value);
3281 if (ret != MEDIA_CONTENT_ERROR_NONE)
3282 content_error("Fail to media_pvr_get_program_date");
3283 content_debug("program_date [%d]", i_value);
3285 ret = media_pvr_get_timer_record(pvr, &b_value);
3286 if (ret != MEDIA_CONTENT_ERROR_NONE)
3287 content_error("Fail to media_pvr_get_timer_record");
3288 content_debug("timer_record [%d]", b_value);
3290 ret = media_pvr_get_series_record(pvr, &b_value);
3291 if (ret != MEDIA_CONTENT_ERROR_NONE)
3292 content_error("Fail to media_pvr_get_series_record");
3293 content_debug("series_record [%d]", b_value);
3295 ret = media_pvr_get_hd(pvr, &i_value);
3296 if (ret != MEDIA_CONTENT_ERROR_NONE)
3297 content_error("Fail to media_pvr_get_hd");
3298 content_debug("hd [%d]", i_value);
3300 ret = media_pvr_get_subtitle(pvr, &b_value);
3301 if (ret != MEDIA_CONTENT_ERROR_NONE)
3302 content_error("Fail to media_pvr_get_subtitle");
3303 content_debug("subtitle [%d]", b_value);
3305 ret = media_pvr_get_ttx(pvr, &b_value);
3306 if (ret != MEDIA_CONTENT_ERROR_NONE)
3307 content_error("Fail to media_pvr_get_ttx");
3308 content_debug("ttx [%d]", b_value);
3310 ret = media_pvr_get_ad(pvr, &b_value);
3311 if (ret != MEDIA_CONTENT_ERROR_NONE)
3312 content_error("Fail to media_pvr_get_ad");
3313 content_debug("ad [%d]", b_value);
3315 ret = media_pvr_get_hard_of_hearing_radio(pvr, &b_value);
3316 if (ret != MEDIA_CONTENT_ERROR_NONE)
3317 content_error("Fail to media_pvr_get_hard_of_hearing_radio");
3318 content_debug("hard_of_hearing_radio [%d]", b_value);
3320 ret = media_pvr_get_data_service(pvr, &b_value);
3321 if (ret != MEDIA_CONTENT_ERROR_NONE)
3322 content_error("Fail to media_pvr_get_data_service");
3323 content_debug("data_service [%d]", b_value);
3325 ret = media_pvr_get_content_lock(pvr, &b_value);
3326 if (ret != MEDIA_CONTENT_ERROR_NONE)
3327 content_error("Fail to media_pvr_get_content_lock");
3328 content_debug("content_lock [%d]", b_value);
3330 ret = media_pvr_get_content_watch(pvr, &b_value);
3331 if (ret != MEDIA_CONTENT_ERROR_NONE)
3332 content_error("Fail to media_pvr_get_content_watch");
3333 content_debug("content_watch [%d]", b_value);
3335 ret = media_pvr_get_has_audio_only(pvr, &b_value);
3336 if (ret != MEDIA_CONTENT_ERROR_NONE)
3337 content_error("Fail to media_pvr_get_has_audio_only");
3338 content_debug("has_audio_only [%d]", b_value);
3340 ret = media_pvr_get_is_local_record(pvr, &b_value);
3341 if (ret != MEDIA_CONTENT_ERROR_NONE)
3342 content_error("Fail to media_pvr_get_is_local_record");
3343 content_debug("is_local_record [%d]", b_value);
3345 ret = media_pvr_get_resolution(pvr, (media_pvr_resolution_e*)&i_value);
3346 if (ret != MEDIA_CONTENT_ERROR_NONE)
3347 content_error("Fail to media_pvr_get_resolution");
3348 content_debug("resolution [%d]", i_value);
3350 ret = media_pvr_get_aspectratio(pvr, (media_pvr_aspectratio_e*)&i_value);
3351 if (ret != MEDIA_CONTENT_ERROR_NONE)
3352 content_error("Fail to media_pvr_get_aspectratio");
3353 content_debug("aspectratio [%d]", i_value);
3355 ret = media_pvr_get_highlight(pvr, &b_value);
3356 if (ret != MEDIA_CONTENT_ERROR_NONE)
3357 content_error("Fail to media_pvr_get_highlight");
3358 content_debug("highlight [%d]", b_value);
3366 int ret = MEDIA_CONTENT_ERROR_NONE;
3367 int media_count = 0;
3369 content_debug("\n============PVR Test============\n\n");
3371 test_tv_filter_create();
3373 ret = media_pvr_get_media_count_from_db(g_tv_filter, &media_count);
3374 if (ret != MEDIA_CONTENT_ERROR_NONE)
3375 content_error("media_pvr_get_media_count_from_db failed: %d", ret);
3377 content_debug("media_count : [%d]", media_count);
3379 ret = media_pvr_foreach_media_from_db(g_tv_filter, pvr_item_cb, NULL);
3380 if (ret != MEDIA_CONTENT_ERROR_NONE)
3381 content_error("media_pvr_foreach_media_from_db is failed");
3383 test_tv_filter_destroy();
3388 int test_pvr_update_db(void)
3390 int ret = MEDIA_CONTENT_ERROR_NONE;
3391 media_pvr_h pvr = NULL;
3393 ret = media_pvr_get_pvr_from_db("ff9b5a9a-a7b4-47f4-8255-84e007e25f13", &pvr);
3394 if (ret != MEDIA_CONTENT_ERROR_NONE)
3395 content_error("media_pvr_get_pvr_from_db failed: %d", ret);
3397 ret = media_pvr_set_content_lock(pvr, TRUE);
3398 if (ret != MEDIA_CONTENT_ERROR_NONE)
3399 content_error("Fail to media_pvr_set_content_lock");
3401 ret = media_pvr_set_content_watch(pvr, TRUE);
3402 if (ret != MEDIA_CONTENT_ERROR_NONE)
3403 content_error("Fail to media_pvr_set_content_watch");
3405 ret = media_pvr_set_program_title(pvr, "TEST TITLE");
3406 if (ret != MEDIA_CONTENT_ERROR_NONE)
3407 content_error("Fail to media_pvr_set_program_title");
3409 ret = media_pvr_set_highlight(pvr, TRUE);
3410 if (ret != MEDIA_CONTENT_ERROR_NONE)
3411 content_error("Fail to media_pvr_set_highlight");
3413 ret = media_pvr_update_to_db(pvr);
3414 if (ret != MEDIA_CONTENT_ERROR_NONE)
3415 content_error("Fail to media_pvr_update_to_db");
3418 media_pvr_destroy(pvr);
3424 int main(int argc, char *argv[])
3426 int ret = MEDIA_CONTENT_ERROR_NONE;
3428 content_debug("--- content manager test start ---\n\n");
3430 ret = test_connect_database();
3431 if (ret != MEDIA_CONTENT_ERROR_NONE)
3432 return MEDIA_CONTENT_ERROR_NONE;
3433 #ifdef _USE_TVPD_MODE
3436 test_pvr_update_db();
3443 ret = test_ebook_text_finder(argv[1]);
3444 if (ret != MEDIA_CONTENT_ERROR_NONE)
3448 ret = test_start_face_detection(FALSE);
3449 if (ret != MEDIA_CONTENT_ERROR_NONE)
3453 if (ret != MEDIA_CONTENT_ERROR_NONE)
3456 ret = test_gallery_scenario();
3457 if (ret != MEDIA_CONTENT_ERROR_NONE)
3460 ret = test_get_all_music_files();
3461 if (ret != MEDIA_CONTENT_ERROR_NONE)
3464 ret = test_media_info_operation();
3465 if (ret != MEDIA_CONTENT_ERROR_NONE)
3468 ret = test_folder_operation();
3469 if (ret != MEDIA_CONTENT_ERROR_NONE)
3472 ret = test_playlist_operation();
3473 if (ret != MEDIA_CONTENT_ERROR_NONE)
3476 ret = test_tag_operation();
3477 if (ret != MEDIA_CONTENT_ERROR_NONE)
3480 ret = test_bookmark_operation();
3481 if (ret != MEDIA_CONTENT_ERROR_NONE)
3484 ret = test_album_list();
3485 if (ret != MEDIA_CONTENT_ERROR_NONE)
3488 ret = test_group_operation();
3489 if (ret != MEDIA_CONTENT_ERROR_NONE)
3492 ret = test_update_operation();
3493 if (ret != MEDIA_CONTENT_ERROR_NONE)
3496 ret = test_insert();
3497 if (ret != MEDIA_CONTENT_ERROR_NONE)
3501 if (ret != MEDIA_CONTENT_ERROR_NONE)
3504 ret = test_create_thumbnail(TRUE);
3505 if (ret != MEDIA_CONTENT_ERROR_NONE)
3508 ret = test_extrace_face(TRUE);
3509 if (ret != MEDIA_CONTENT_ERROR_NONE)
3512 ret = test_request_update_db();
3513 if (ret != MEDIA_CONTENT_ERROR_NONE)
3517 if (ret != MEDIA_CONTENT_ERROR_NONE)
3520 ret = test_batch_operations();
3521 if (ret != MEDIA_CONTENT_ERROR_NONE)
3522 return MEDIA_CONTENT_ERROR_NONE;
3524 ret = test_scan_file();
3525 if (ret != MEDIA_CONTENT_ERROR_NONE)
3526 return MEDIA_CONTENT_ERROR_NONE;
3528 ret = test_scan_dir(true);
3529 if (ret != MEDIA_CONTENT_ERROR_NONE)
3530 return MEDIA_CONTENT_ERROR_NONE;
3533 if (ret != MEDIA_CONTENT_ERROR_NONE)
3534 return MEDIA_CONTENT_ERROR_NONE;
3537 if (ret != MEDIA_CONTENT_ERROR_NONE)
3538 return MEDIA_CONTENT_ERROR_NONE;
3540 ret = test_face_add_del();
3541 if (ret != MEDIA_CONTENT_ERROR_NONE)
3542 return MEDIA_CONTENT_ERROR_NONE;
3544 ret = test_playlist_operation_v2();
3545 if (ret != MEDIA_CONTENT_ERROR_NONE)
3546 return MEDIA_CONTENT_ERROR_NONE;
3548 ret = test_bookmark_operation_v2();
3549 if (ret != MEDIA_CONTENT_ERROR_NONE)
3550 return MEDIA_CONTENT_ERROR_NONE;
3552 ret = test_tag_operation_v2();
3553 if (ret != MEDIA_CONTENT_ERROR_NONE)
3554 return MEDIA_CONTENT_ERROR_NONE;
3557 ret = test_disconnect_database();
3558 if (ret != MEDIA_CONTENT_ERROR_NONE)
3561 content_debug("--- content manager test end ---\n");