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 filter_h g_filter = NULL;
31 filter_h g_filter_g = NULL; /*filter for group like folder, tag, playlist, album, year ... */
33 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"
40 media_folder_h g_folder = NULL;
42 static void get_audio_meta(audio_meta_h audio)
46 int ret = MEDIA_CONTENT_ERROR_NONE;
48 content_debug("=== audio meta ===");
50 ret = audio_meta_get_media_id(audio, &c_value);
51 if (ret != MEDIA_CONTENT_ERROR_NONE)
52 content_error("error when get meta : [%d]", ret);
55 content_debug("audio_id : [%s]", c_value);
58 ret = audio_meta_get_album(audio, &c_value);
59 if (ret != MEDIA_CONTENT_ERROR_NONE)
60 content_error("error when get meta : [%d]", ret);
63 content_debug("album : [%s]", c_value);
66 ret = audio_meta_get_artist(audio, &c_value);
67 if (ret != MEDIA_CONTENT_ERROR_NONE)
68 content_error("error when get meta : [%d]", ret);
71 content_debug("artist : [%s]", c_value);
74 ret = audio_meta_get_album_artist(audio, &c_value);
75 if (ret != MEDIA_CONTENT_ERROR_NONE)
76 content_error("error when get meta : [%d]", ret);
79 content_debug("album_artist : [%s]", c_value);
82 ret = audio_meta_get_genre(audio, &c_value);
83 if (ret != MEDIA_CONTENT_ERROR_NONE)
84 content_error("error when get meta : [%d]", ret);
87 content_debug("genre : [%s]", c_value);
90 ret = audio_meta_get_composer(audio, &c_value);
91 if (ret != MEDIA_CONTENT_ERROR_NONE)
92 content_error("error when get meta : [%d]", ret);
95 content_debug("composer : [%s]", c_value);
98 ret = audio_meta_get_year(audio, &c_value);
99 if (ret != MEDIA_CONTENT_ERROR_NONE)
100 content_error("error when get meta : [%d]", ret);
103 content_debug("year : [%s]", c_value);
106 ret = audio_meta_get_recorded_date(audio, &c_value);
107 if (ret != MEDIA_CONTENT_ERROR_NONE)
108 content_error("error when get meta : [%d]", ret);
111 content_debug("recorded_date : [%s]", c_value);
114 ret = audio_meta_get_copyright(audio, &c_value);
115 if (ret != MEDIA_CONTENT_ERROR_NONE)
116 content_error("error when get meta : [%d]", ret);
119 content_debug("copyright : [%s]", c_value);
122 ret = audio_meta_get_track_num(audio, &c_value);
123 if (ret != MEDIA_CONTENT_ERROR_NONE)
124 content_error("error when get meta : [%d]", ret);
127 content_debug("track_num : [%s]", c_value);
130 ret = audio_meta_get_bit_rate(audio, &i_value);
131 if (ret != MEDIA_CONTENT_ERROR_NONE)
132 content_error("error when get meta : [%d]", ret);
134 content_debug("bitrate : [%d]", i_value);
136 ret = audio_meta_get_sample_rate(audio, &i_value);
137 if (ret != MEDIA_CONTENT_ERROR_NONE)
138 content_error("error when get meta : [%d]", ret);
140 content_debug("samplerate : [%d]", i_value);
142 ret = audio_meta_get_channel(audio, &i_value);
143 if (ret != MEDIA_CONTENT_ERROR_NONE)
144 content_error("error when get meta : [%d]", ret);
146 content_debug("channel : [%d]", i_value);
148 ret = audio_meta_get_duration(audio, &i_value);
149 if (ret != MEDIA_CONTENT_ERROR_NONE)
150 content_error("error when get meta : [%d]", ret);
152 content_debug("duration : [%d]", i_value);
156 static void get_video_meta(video_meta_h video)
158 char *c_value = NULL;
160 int ret = MEDIA_CONTENT_ERROR_NONE;
162 content_debug("=== video meta ===");
164 ret = video_meta_get_media_id(video, &c_value);
165 if (ret != MEDIA_CONTENT_ERROR_NONE)
166 content_error("error when get meta : [%d]", ret);
169 content_debug("video_id : [%s]", c_value);
172 ret = video_meta_get_album(video, &c_value);
173 if (ret != MEDIA_CONTENT_ERROR_NONE)
174 content_error("error when get meta : [%d]", ret);
177 content_debug("album : [%s]", c_value);
180 ret = video_meta_get_artist(video, &c_value);
181 if (ret != MEDIA_CONTENT_ERROR_NONE)
182 content_error("error when get meta : [%d]", ret);
185 content_debug("artist : [%s]", c_value);
188 ret = video_meta_get_album_artist(video, &c_value);
189 if (ret != MEDIA_CONTENT_ERROR_NONE)
190 content_error("error when get meta : [%d]", ret);
193 content_debug("album_artist : [%s]", c_value);
196 ret = video_meta_get_genre(video, &c_value);
197 if (ret != MEDIA_CONTENT_ERROR_NONE)
198 content_error("error when get meta : [%d]", ret);
201 content_debug("genre : [%s]", c_value);
204 ret = video_meta_get_composer(video, &c_value);
205 if (ret != MEDIA_CONTENT_ERROR_NONE)
206 content_error("error when get meta : [%d]", ret);
209 content_debug("omposer : [%s]", c_value);
212 ret = video_meta_get_year(video, &c_value);
213 if (ret != MEDIA_CONTENT_ERROR_NONE)
214 content_error("error when get meta : [%d]", ret);
217 content_debug("year : [%s]", c_value);
220 ret = video_meta_get_recorded_date(video, &c_value);
221 if (ret != MEDIA_CONTENT_ERROR_NONE)
222 content_error("error when get meta : [%d]", ret);
225 content_debug("recorded_date : [%s]", c_value);
228 ret = video_meta_get_copyright(video, &c_value);
229 if (ret != MEDIA_CONTENT_ERROR_NONE)
230 content_error("error when get meta : [%d]", ret);
233 content_debug("copyright : [%s]", c_value);
236 ret = video_meta_get_track_num(video, &c_value);
237 if (ret != MEDIA_CONTENT_ERROR_NONE)
238 content_error("error when get meta : [%d]", ret);
241 content_debug("track_num : [%s]", c_value);
244 ret = video_meta_get_bit_rate(video, &i_value);
245 if (ret != MEDIA_CONTENT_ERROR_NONE)
246 content_error("error when get meta : [%d]", ret);
248 content_debug("bitrate : [%d]", i_value);
250 ret = video_meta_get_duration(video, &i_value);
251 if (ret != MEDIA_CONTENT_ERROR_NONE)
252 content_error("error when get meta : [%d]", ret);
254 content_debug("duration : [%d]", i_value);
256 ret = video_meta_get_width(video, &i_value);
257 if (ret != MEDIA_CONTENT_ERROR_NONE)
258 content_error("error when get meta : [%d]", ret);
260 content_debug("width : [%d]", i_value);
262 ret = video_meta_get_height(video, &i_value);
263 if (ret != MEDIA_CONTENT_ERROR_NONE)
264 content_error("error when get meta : [%d]", ret);
266 content_debug("height : [%d]", i_value);
270 static void get_image_meta(image_meta_h image)
272 char *c_value = NULL;
274 media_content_orientation_e orientation;
275 int ret = MEDIA_CONTENT_ERROR_NONE;
277 content_debug("=== image meta ===");
279 ret = image_meta_get_width(image, &i_value);
280 if (ret != MEDIA_CONTENT_ERROR_NONE)
281 content_error("error image_meta_get_width : [%d]", ret);
283 content_debug("width : [%d]", i_value);
285 ret = image_meta_get_height(image, &i_value);
286 if (ret != MEDIA_CONTENT_ERROR_NONE)
287 content_error("error image_meta_get_height : [%d]", ret);
289 content_debug("height : [%d]", i_value);
291 ret = image_meta_get_orientation(image, &orientation);
292 if (ret != MEDIA_CONTENT_ERROR_NONE)
293 content_error("error image_meta_get_orientation : [%d]", ret);
295 content_debug("orientation : [%d]", orientation);
297 ret = image_meta_get_date_taken(image, &c_value);
298 if (ret != MEDIA_CONTENT_ERROR_NONE)
299 content_error("error image_meta_get_date_taken : [%d]", ret);
302 content_debug("date_taken : [%s]", c_value);
307 static void get_album_meta(media_album_h album)
309 char *c_value = NULL;
311 int ret = MEDIA_CONTENT_ERROR_NONE;
313 content_debug("=== album meta ===");
315 ret = media_album_get_album_id(album, &i_value);
316 if (ret != MEDIA_CONTENT_ERROR_NONE)
317 content_error("error media_album_get_album_id : [%d]", ret);
319 content_debug("album_id : [%d]", i_value);
321 ret = media_album_get_name(album, &c_value);
322 if (ret != MEDIA_CONTENT_ERROR_NONE)
323 content_error("error media_album_get_name : [%d]", ret);
326 content_debug("album_name : [%s]", c_value);
329 ret = media_album_get_artist(album, &c_value);
330 if (ret != MEDIA_CONTENT_ERROR_NONE)
331 content_error("error media_album_get_artist : [%d]", ret);
334 content_debug("album_artist : [%s]", c_value);
339 static void get_bookmark_meta(media_bookmark_h bookmark)
341 char *c_value = NULL;
344 int ret = MEDIA_CONTENT_ERROR_NONE;
346 content_debug("=== bookmark meta ===");
348 ret = media_bookmark_get_bookmark_id(bookmark, &i_value);
349 if (ret != MEDIA_CONTENT_ERROR_NONE)
350 content_error("error media_bookmark_get_bookmark_id : [%d]", ret);
352 content_debug("bookmark_id : %d", i_value);
354 ret = media_bookmark_get_thumbnail_path(bookmark, &c_value);
355 if (ret != MEDIA_CONTENT_ERROR_NONE)
356 content_error("error media_bookmark_get_thumbnail_path : [%d]", ret);
359 content_debug("bookmark thumbnail_path : %s", c_value);
362 ret = media_bookmark_get_marked_time(bookmark, &time);
363 if (ret != MEDIA_CONTENT_ERROR_NONE)
364 content_error("error media_bookmark_get_marked_time : [%d]", ret);
366 content_debug("bookmark marked_time : %ld", time);
368 ret = media_bookmark_get_name(bookmark, &c_value);
369 if (ret != MEDIA_CONTENT_ERROR_NONE)
370 content_error("error media_bookmark_get_name : [%d]", ret);
373 content_debug("bookmark name : %s", c_value);
378 static void get_tag_meta(media_tag_h tag)
380 char *c_value = NULL;
382 int ret = MEDIA_CONTENT_ERROR_NONE;
384 content_debug("=== tag meta ===");
386 ret = media_tag_get_tag_id(tag, &i_value);
387 if (ret != MEDIA_CONTENT_ERROR_NONE)
388 content_error("error media_tag_get_tag_id : [%d]", ret);
390 content_debug("tag_id : %d", i_value);
392 ret = media_tag_get_name(tag, &c_value);
393 if (ret != MEDIA_CONTENT_ERROR_NONE)
394 content_error("error media_tag_get_name : [%d]", ret);
397 content_debug("tag_name : %s", c_value);
402 static void get_face_meta(media_face_h face)
404 char *c_value = NULL;
405 unsigned int rect_x = 0;
406 unsigned int rect_y = 0;
407 unsigned int rect_w = 0;
408 unsigned int rect_h = 0;
409 media_content_orientation_e orientation = 0;
410 int ret = MEDIA_CONTENT_ERROR_NONE;
412 content_debug("=== face meta ===");
414 ret = media_face_get_face_id(face, &c_value);
415 if (ret != MEDIA_CONTENT_ERROR_NONE)
416 content_error("error media_face_get_face_id : [%d]", ret);
419 content_debug("face_id : %s", c_value);
422 ret = media_face_get_media_id(face, &c_value);
423 if (ret != MEDIA_CONTENT_ERROR_NONE)
424 content_error("error media_face_get_media_id : [%d]", ret);
427 content_debug("media_id : %s", c_value);
430 ret = media_face_get_face_rect(face, &rect_x, &rect_y, &rect_w, &rect_h);
431 if (ret != MEDIA_CONTENT_ERROR_NONE)
432 content_error("error media_face_get_face_rect : [%d]", ret);
434 content_debug("face_rect x[%d] y[%d] w[%d] h[%d]", rect_x, rect_y, rect_w, rect_h);
436 ret = media_face_get_orientation(face, &orientation);
437 if (ret != MEDIA_CONTENT_ERROR_NONE)
438 content_error("error media_face_get_orientation : [%d]", ret);
440 content_debug("orientation : %d", orientation);
442 ret = media_face_get_tag(face, &c_value);
443 if (ret != MEDIA_CONTENT_ERROR_NONE)
444 content_error("error media_face_get_tag : [%d]", ret);
447 content_debug("tag : %s", c_value);
452 static void get_folder_meta(media_folder_h folder, char **folder_id)
454 char *c_value = NULL;
455 media_content_storage_e storage_type;
456 int ret = MEDIA_CONTENT_ERROR_NONE;
458 content_debug("=== folder meta ===");
460 ret = media_folder_get_folder_id(folder, &c_value);
461 if (ret != MEDIA_CONTENT_ERROR_NONE)
462 content_error("error media_folder_get_folder_id : [%d]", ret);
465 content_debug("folder_id : %s", c_value);
466 *folder_id = c_value;
469 ret = media_folder_get_path(folder, &c_value);
470 if (ret != MEDIA_CONTENT_ERROR_NONE)
471 content_error("error media_folder_get_path : [%d]", ret);
474 content_debug("folder_path : %s", c_value);
477 ret = media_folder_get_name(folder, &c_value);
478 if (ret != MEDIA_CONTENT_ERROR_NONE)
479 content_error("error media_folder_get_name : [%d]", ret);
482 content_debug("folder_name : %s", c_value);
485 ret = media_folder_get_storage_type(folder, &storage_type);
486 if (ret != MEDIA_CONTENT_ERROR_NONE)
487 content_error("error media_folder_get_storage_type : [%d]", ret);
489 content_debug("storage_type : [%d]", storage_type);
491 ret = media_folder_get_storage_id(folder, &c_value);
492 if (ret != MEDIA_CONTENT_ERROR_NONE)
493 content_error("error media_folder_get_storage_id : [%d]", ret);
496 content_debug("storage_id : %s", c_value);
501 static void get_media_meta(media_info_h media)
503 char *c_value = NULL;
506 bool b_value = false;
507 unsigned long long size = 0;
508 media_content_type_e media_type = 0;
509 int ret = MEDIA_CONTENT_ERROR_NONE;
511 content_debug("=== media meta ===");
513 ret = media_info_get_media_type(media, &media_type);
514 if (ret != MEDIA_CONTENT_ERROR_NONE)
515 content_error("error media_info_get_media_type : [%d]", ret);
517 content_debug("media_type : [%d]", media_type);
519 ret = media_info_get_media_id(media, &c_value);
520 if (ret != MEDIA_CONTENT_ERROR_NONE)
521 content_error("error media_info_get_media_id : [%d]", ret);
524 content_debug("media_id : [%s]", c_value);
527 ret = media_info_get_file_path(media, &c_value);
528 if (ret != MEDIA_CONTENT_ERROR_NONE)
529 content_error("error media_info_get_file_path : [%d]", ret);
532 content_debug("file_path : [%s]", c_value);
535 ret = media_info_get_display_name(media, &c_value);
536 if (ret != MEDIA_CONTENT_ERROR_NONE)
537 content_error("error media_info_get_display_name : [%d]", ret);
540 content_debug("display_name : [%s]", c_value);
543 ret = media_info_get_mime_type(media, &c_value);
544 if (ret != MEDIA_CONTENT_ERROR_NONE)
545 content_error("error media_info_get_mime_type : [%d]", ret);
548 content_debug("mime_type : [%s]", c_value);
551 ret = media_info_get_thumbnail_path(media, &c_value);
552 if (ret != MEDIA_CONTENT_ERROR_NONE)
553 content_error("error media_info_get_thumbnail_path : [%d]", ret);
556 content_debug("thumbnail_path : [%s]", c_value);
559 ret = media_info_get_description(media, &c_value);
560 if (ret != MEDIA_CONTENT_ERROR_NONE)
561 content_error("error media_info_get_description : [%d]", ret);
564 content_debug("description : [%s]", c_value);
567 ret = media_info_get_size(media, &size);
568 if (ret != MEDIA_CONTENT_ERROR_NONE)
569 content_error("error media_info_get_size : [%d]", ret);
571 content_debug("size : [%lld]", size);
573 ret = media_info_get_added_time(media, &t_value);
574 if (ret != MEDIA_CONTENT_ERROR_NONE)
575 content_error("error media_info_get_added_time : [%d]", ret);
577 content_debug("added_time : [%ld]", t_value);
579 ret = media_info_get_modified_time(media, &t_value);
580 if (ret != MEDIA_CONTENT_ERROR_NONE)
581 content_error("error media_info_get_modified_time : [%d]", ret);
583 content_debug("modified_time : [%ld]", t_value);
585 ret = media_info_get_timeline(media, &t_value);
586 if (ret != MEDIA_CONTENT_ERROR_NONE)
587 content_error("error media_info_get_timeline : [%d]", ret);
589 content_debug("timeline : [%ld]", t_value);
591 ret = media_info_get_rating(media, &i_value);
592 if (ret != MEDIA_CONTENT_ERROR_NONE)
593 content_error("error media_info_get_rating : [%d]", ret);
595 content_debug("rating : [%d]", i_value);
597 ret = media_info_get_favorite(media, &b_value);
598 if (ret != MEDIA_CONTENT_ERROR_NONE)
599 content_error("error media_info_get_favorite : [%d]", ret);
601 content_debug("favorite : [%d]", b_value);
603 ret = media_info_is_drm(media, &b_value);
604 if (ret != MEDIA_CONTENT_ERROR_NONE)
605 content_error("error media_info_is_drm : [%d]", ret);
607 content_debug("is_drm : [%d]", b_value);
609 ret = media_info_is_360_content(media, &b_value);
610 if (ret != MEDIA_CONTENT_ERROR_NONE)
611 content_error("error media_info_is_360_content : [%d]", ret);
613 content_debug("is_360 : [%d]", b_value);
615 #ifdef _USE_TVPD_MODE
616 ret = media_info_get_stitched_state(media, &i_value);
617 if (ret != MEDIA_CONTENT_ERROR_NONE)
618 content_error("error media_info_get_stitched_state : [%d]", ret);
620 content_debug("360 stitched : [%d]", i_value);
622 ret = media_info_get_stitched_engine(media, &i_value);
623 if (ret != MEDIA_CONTENT_ERROR_NONE)
624 content_error("error media_info_get_stitched_engine : [%d]", ret);
626 content_debug("360 engine : [%d]", i_value);
629 if (media_type == MEDIA_CONTENT_TYPE_MUSIC) {
632 ret = media_info_get_audio(media, &audio);
633 if (ret != MEDIA_CONTENT_ERROR_NONE)
634 content_error("error media_info_get_audio : [%d]", ret);
636 get_audio_meta(audio);
638 ret = audio_meta_destroy(audio);
639 if (ret != MEDIA_CONTENT_ERROR_NONE)
640 content_error("error audio_meta_destroy : [%d]", ret);
642 } else if (media_type == MEDIA_CONTENT_TYPE_IMAGE) {
645 ret = media_info_get_image(media, &image);
646 if (ret != MEDIA_CONTENT_ERROR_NONE)
647 content_error("error media_info_get_image : [%d]", ret);
649 get_image_meta(image);
651 ret = image_meta_destroy(image);
652 if (ret != MEDIA_CONTENT_ERROR_NONE)
653 content_error("error image_meta_destroy : [%d]", ret);
655 } else if (media_type == MEDIA_CONTENT_TYPE_VIDEO) {
658 ret = media_info_get_video(media, &video);
659 if (ret != MEDIA_CONTENT_ERROR_NONE)
660 content_error("error media_info_get_video : [%d]", ret);
662 get_video_meta(video);
664 ret = video_meta_destroy(video);
665 if (ret != MEDIA_CONTENT_ERROR_NONE)
666 content_error("error video_meta_destroy : [%d]", ret);
669 content_debug("Other Content");
674 bool media_item_cb(media_info_h media, void *user_data)
677 content_debug("NO Item");
681 get_media_meta(media);
686 bool gallery_folder_list_cb(media_folder_h folder, void *user_data)
688 media_folder_h new_folder = NULL;
689 media_folder_clone(&new_folder, folder);
691 GList **list = (GList**)user_data;
692 *list = g_list_append(*list, new_folder);
697 bool gallery_media_item_cb(media_info_h media, void *user_data)
699 media_info_h new_media = NULL;
700 int ret = MEDIA_CONTENT_ERROR_NONE;
702 ret = media_info_clone(&new_media, media);
704 if (ret != MEDIA_CONTENT_ERROR_NONE) {
705 GList **list = (GList**)user_data;
706 *list = g_list_append(*list, new_media);
712 bool gallery_tag_item_cb(media_tag_h tag, void *user_data)
714 media_tag_h new_tag = NULL;
715 media_tag_clone(&new_tag, tag);
717 GList **list = (GList**)user_data;
718 *list = g_list_append(*list, new_tag);
723 bool gallery_bookmarks_cb(media_bookmark_h bookmark, void *user_data)
725 media_bookmark_h new_bm = NULL;
726 int ret = MEDIA_CONTENT_ERROR_NONE;
728 ret = media_bookmark_clone(&new_bm, bookmark);
729 if (ret != MEDIA_CONTENT_ERROR_NONE)
730 content_error("error media_bookmark_clone : [%d]", ret);
732 GList **list = (GList**)user_data;
733 *list = g_list_append(*list, new_bm);
738 bool folder_list_cb(media_folder_h folder, void *user_data)
741 char *folder_id = NULL;
742 media_folder_h *_folder = (media_folder_h*)user_data;
744 content_debug("===========================");
745 if (folder != NULL) {
747 media_folder_clone(_folder, folder);
749 get_folder_meta(folder, &folder_id);
751 if (media_folder_get_media_count_from_db(folder_id, g_filter, &item_count) != MEDIA_CONTENT_ERROR_NONE) {
752 SAFE_FREE(folder_id);
753 content_error("[ERROR] media_folder_get_media_count_from_db is failed");
757 if (media_folder_foreach_media_from_db(folder_id, g_filter, media_item_cb, NULL) != MEDIA_CONTENT_ERROR_NONE) {
758 SAFE_FREE(folder_id);
759 content_error("[ERROR] media_folder_foreach_media_from_db is failed");
763 SAFE_FREE(folder_id);
771 bool playlist_list_cb(media_playlist_h playlist, void *user_data)
773 int ret = MEDIA_CONTENT_ERROR_NONE;
775 char *playlist_name = NULL;
776 media_playlist_h playlist_h;
777 char *playlist_thumbnail_path = NULL;
779 content_debug("playlist_list_cb ======");
781 GList **list = (GList**)user_data;
784 if (playlist == NULL) {
785 content_debug(" playlist handle is NULL");
789 ret = media_playlist_get_playlist_id(playlist, &playlist_id);
790 if (ret != MEDIA_CONTENT_ERROR_NONE)
791 content_error("error media_playlist_get_playlist_id : [%d]", ret);
793 content_debug("playlist_id : %d", playlist_id);
794 /* 64bit build issue */
796 if (user_data != NULL)
797 *list = g_list_append(*list, (gpointer)playlist_id);
799 ret = media_playlist_get_name(playlist, &playlist_name);
800 if (ret != MEDIA_CONTENT_ERROR_NONE)
801 content_error("error media_playlist_get_name : [%d]", ret);
803 content_debug("playlist_name : %s", playlist_name);
804 SAFE_FREE(playlist_name);
806 ret = media_playlist_get_thumbnail_path(playlist, &playlist_thumbnail_path);
807 if (ret != MEDIA_CONTENT_ERROR_NONE)
808 content_error("error media_playlist_get_thumbnail_path : [%d]", ret);
810 content_debug("playlist_thumbnail_path : %s", playlist_thumbnail_path);
811 SAFE_FREE(playlist_thumbnail_path);
813 ret = media_playlist_get_playlist_from_db(playlist_id, &playlist_h);
814 if (ret != MEDIA_CONTENT_ERROR_NONE)
815 content_error("error media_playlist_get_playlist_from_db : [%d]", ret);
817 ret = media_playlist_destroy(playlist_h);
818 if (ret != MEDIA_CONTENT_ERROR_NONE)
819 content_error("error media_playlist_destroy : [%d]", ret);
824 bool tag_list_cb(media_tag_h tag, void *user_data)
827 content_debug(" tag handle is NULL");
836 bool bookmarks_cb(media_bookmark_h bookmark, void *user_data)
838 if (bookmark != NULL && user_data != NULL) {
839 media_bookmark_h new_bookmark;
841 media_bookmark_clone(&new_bookmark, bookmark);
842 GList **list = (GList**)user_data;
843 *list = g_list_append(*list, new_bookmark);
846 get_bookmark_meta(bookmark);
851 bool album_list_cb(media_album_h album, void *user_data)
855 int ret = MEDIA_CONTENT_ERROR_NONE;
858 get_album_meta(album);
859 media_album_get_album_id(album, &album_id);
861 ret = media_album_get_media_count_from_db(album_id, NULL, &media_count);
862 if (ret != MEDIA_CONTENT_ERROR_NONE)
863 content_error("error media_album_get_media_count_from_db : [%d]", ret);
865 content_debug("media_count : [%d]", media_count);
867 ret = media_album_foreach_media_from_db(album_id, NULL, media_item_cb, NULL);
868 if (ret != MEDIA_CONTENT_ERROR_NONE) {
869 content_error("error media_album_foreach_media_from_db : [%d]", ret);
874 content_error("album item not Found!!");
880 bool group_list_cb(const char *group_name, void *user_data)
883 int *idx = user_data;
885 content_debug("group item : [%s] [%d]", group_name, *idx);
887 if (media_group_get_media_count_from_db(group_name, *idx, g_filter, &media_count) != MEDIA_CONTENT_ERROR_NONE)
890 content_debug("media_count : [%d]", media_count);
892 if (media_group_foreach_media_from_db(group_name, *idx, g_filter, media_item_cb, NULL) != MEDIA_CONTENT_ERROR_NONE)
898 bool playlist_item_cb(int playlist_member_id, media_info_h media, void *user_data)
900 content_debug("playlist_member_id : [%d]", playlist_member_id);
901 /* 64bit build issue */
903 GList **list = (GList**)user_data;
905 *list = g_list_append(*list, (gpointer)playlist_member_id);
907 /*media_item_cb(media, user_data);*/
912 int test_filter_create(void)
914 content_debug("\n============Filter Create============\n\n");
916 int ret = MEDIA_CONTENT_ERROR_NONE;
918 /* Filter for media */
919 const char *condition = "MEDIA_TYPE=3"; /*MEDIA_TYPE 0-image, 1-video, 2-sound, 3-music, 4-other*/
920 /*const char *condition = "MEDIA_TYPE IS NOT 0 AND MEDIA_DESCRIPTION IS NOT NULL"; */ /*MEDIA_TYPE 0-image, 1-video, 2-sound, 3-music, 4-other*/
922 ret = media_filter_create(&g_filter);
924 /* Set condition and collate
925 * Condition string : You can make where statement of sql.
926 * Colation : You can use collation when comparing.
927 * Ex) In case of FILE_NAME='Samsung' as condition string,
928 * if you want to compare with NOCASE collation,
929 * call media_filter_set_condition(g_filter, condition, MEDIA_CONTENT_COLLATE_NOCASE);
930 * if you want to compare in case-sensitive,
931 * call media_filter_set_condition(g_filter, condition, MEDIA_CONTENT_COLLATE_DEFAULT);
933 ret = media_filter_set_condition(g_filter, condition, MEDIA_CONTENT_COLLATE_DEFAULT);
935 /* Collation of ordering
936 * If you want to get list, which is sorted by NOCASE,
937 * call media_filter_set_order(g_filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_ARTIST, MEDIA_CONTENT_COLLATE_NOCASE);
939 * call media_filter_set_order(g_filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_ARTIST, MEDIA_CONTENT_COLLATE_DEFAULT);
941 /* Able to set multi column to set order */
943 ret = media_filter_set_order(g_filter, MEDIA_CONTENT_ORDER_ASC, "MEDIA_MODIFIED_TIME, MEDIA_DISPLAY_NAME", MEDIA_CONTENT_COLLATE_DEFAULT);
944 ret = media_filter_set_order(g_filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_ARTIST, MEDIA_CONTENT_COLLATE_DEFAULT);
945 ret = media_filter_set_order(g_filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_TRACK_NUM_INT, MEDIA_CONTENT_COLLATE_DEFAULT);
946 ret = media_filter_set_storage(g_filter, "cfbf3d2c-71c5-4611-bccc-7cbac890146e");
948 /* Filter for group */
949 const char *g_condition = "TAG_NAME like \"\%my\%\"";
950 const char *g_condition = "BOOKMARK_MARKED_TIME > 300";
952 ret = media_filter_create(&g_filter_g);
954 ret = media_filter_set_order(g_filter_g, MEDIA_CONTENT_ORDER_DESC, TAG_NAME, MEDIA_CONTENT_COLLATE_DEFAULT);
959 int test_filter_destroy(void)
961 content_debug("\n============Filter Create============\n\n");
963 int ret = MEDIA_CONTENT_ERROR_NONE;
965 ret = media_filter_destroy(g_filter);
970 int test_connect_database(void)
972 int ret = MEDIA_CONTENT_ERROR_NONE;
974 content_debug("\n============DB Connection Test============\n\n");
976 ret = media_content_connect();
978 if (ret == MEDIA_CONTENT_ERROR_NONE)
979 content_debug("connection is success\n\n");
981 content_error("connection is failed\n\n");
986 int test_gallery_scenario(void)
988 int ret = MEDIA_CONTENT_ERROR_NONE;
990 filter_h filter = NULL;
993 GList *folder_list = NULL;
994 media_folder_h folder_handle = NULL;
996 /* First, Get folder list */
997 ret = media_folder_foreach_folder_from_db(filter, gallery_folder_list_cb, &folder_list);
998 if (ret != MEDIA_CONTENT_ERROR_NONE) {
999 content_error("media_folder_foreach_folder_from_db failed: %d", ret);
1002 content_debug("media_folder_foreach_folder_from_db success!!");
1003 char *folder_id = NULL;
1005 for (i = 0; i < g_list_length(folder_list); i++) {
1006 folder_handle = (media_folder_h)g_list_nth_data(folder_list, i);
1008 get_folder_meta(folder_handle, &folder_id);
1010 ret = media_folder_get_media_count_from_db(folder_id, filter, &count);
1011 SAFE_FREE(folder_id);
1012 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1013 content_error("media_folder_get_media_count_from_db failed: %d", ret);
1016 content_debug("media count [%d] : %d", i, count);
1021 /* To check performance */
1022 struct timeval start, end;
1023 gettimeofday(&start, NULL);
1025 /* Second, Get all item list */
1026 media_info_h media_handle = NULL;
1027 GList *all_item_list = NULL;
1029 media_content_collation_e collate_type = MEDIA_CONTENT_COLLATE_NOCASE;
1030 media_content_order_e order_type = MEDIA_CONTENT_ORDER_DESC;
1031 ret = media_filter_create(&filter);
1032 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1033 content_error("Fail to create filter");
1036 ret = media_filter_set_condition(filter, "MEDIA_TYPE = 0", collate_type);
1037 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1038 media_filter_destroy(filter);
1039 content_error("Fail to set condition");
1042 ret = media_filter_set_order(filter, order_type, MEDIA_DISPLAY_NAME, collate_type);
1043 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1044 media_filter_destroy(filter);
1045 content_error("Fail to set order");
1049 ret = media_info_foreach_media_from_db(filter, gallery_media_item_cb, &all_item_list);
1050 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1051 content_error("media_info_foreach_media_from_db failed: %d", ret);
1052 media_filter_destroy(filter);
1055 content_debug("media_info_foreach_media_from_db success");
1057 for (i = 0; i < g_list_length(all_item_list); i++) {
1058 media_handle = (media_info_h)g_list_nth_data(all_item_list, i);
1059 get_media_meta(media_handle);
1063 media_filter_destroy(filter);
1066 /* To check performance */
1067 gettimeofday(&end, NULL);
1068 long time = (end.tv_sec * 1000000 + end.tv_usec) - (start.tv_sec * 1000000 + start.tv_usec);
1069 content_debug("Time : %ld\n", time);
1071 /* Third, Get item list of a folder */
1072 GList *item_list = NULL;
1074 for (i = 0; i < g_list_length(folder_list); i++) {
1076 char *folder_id = NULL;
1077 folder_handle = (media_folder_h)g_list_nth_data(folder_list, i);
1079 get_folder_meta(folder_handle, &folder_id);
1081 ret = media_folder_foreach_media_from_db(folder_id, filter, gallery_media_item_cb, &item_list);
1082 SAFE_FREE(folder_id);
1084 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1085 content_error("media_folder_foreach_media_from_db failed: %d", ret);
1088 content_error("media_folder_foreach_media_from_db success!");
1090 for (j = 0; j < g_list_length(item_list); j++) {
1091 media_handle = (media_info_h)g_list_nth_data(item_list, j);
1092 get_media_meta(media_handle);
1098 media_tag_h tag_handle = NULL;
1099 GList *tag_list = NULL;
1100 GList *media_list_in_tag = NULL;
1103 ret = media_tag_foreach_tag_from_db(filter, gallery_tag_item_cb, &tag_list);
1105 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1106 content_error("media_tag_foreach_tag_from_db failed: %d", ret);
1109 content_error("media_tag_foreach_tag_from_db success");
1110 for (i = 0; i < g_list_length(tag_list); i++) {
1111 tag_handle = (media_tag_h)g_list_nth_data(tag_list, i);
1112 get_tag_meta(tag_handle);
1114 ret = media_tag_get_tag_id(tag_handle, &tag_id);
1115 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1116 ret = media_tag_foreach_media_from_db(tag_id, filter, gallery_media_item_cb, &media_list_in_tag);
1117 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1118 content_error("media_tag_foreach_media_from_db failed: %d", ret);
1121 content_error("media_tag_foreach_media_from_db success");
1123 media_info_h tag_media_handle;
1125 for (j = 0; j < g_list_length(media_list_in_tag); j++) {
1126 tag_media_handle = (media_info_h)g_list_nth_data(media_list_in_tag, j);
1127 get_media_meta(tag_media_handle);
1134 /* Remove folder list */
1136 for (i = 0; i < g_list_length(folder_list); i++) {
1137 folder_handle = (media_folder_h)g_list_nth_data(folder_list, i);
1138 media_folder_destroy(folder_handle);
1141 g_list_free(folder_list);
1144 /* Remove all items list */
1145 if (all_item_list) {
1146 for (i = 0; i < g_list_length(all_item_list); i++) {
1147 media_handle = (media_info_h)g_list_nth_data(all_item_list, i);
1148 ret = media_info_destroy(media_handle);
1149 if (ret != MEDIA_CONTENT_ERROR_NONE)
1150 content_error("media_info_destroy failed: %d", ret);
1153 g_list_free(all_item_list);
1156 /* Remove items list */
1158 for (i = 0; i < g_list_length(item_list); i++) {
1159 media_handle = (media_info_h)g_list_nth_data(item_list, i);
1160 ret = media_info_destroy(media_handle);
1161 if (ret != MEDIA_CONTENT_ERROR_NONE)
1162 content_error("media_info_destroy failed: %d", ret);
1165 g_list_free(item_list);
1168 /* Remove tag list */
1170 for (i = 0; i < g_list_length(tag_list); i++) {
1171 tag_handle = (media_tag_h)g_list_nth_data(tag_list, i);
1172 ret = media_tag_destroy(tag_handle);
1173 if (ret != MEDIA_CONTENT_ERROR_NONE)
1174 content_error("error media_tag_destroy : [%d]", ret);
1177 g_list_free(tag_list);
1180 /* Remove media list in a tag */
1181 if (media_list_in_tag) {
1182 for (i = 0; i < g_list_length(media_list_in_tag); i++) {
1183 media_handle = (media_info_h)g_list_nth_data(media_list_in_tag, i);
1184 ret = media_info_destroy(media_handle);
1185 if (ret != MEDIA_CONTENT_ERROR_NONE)
1186 content_error("media_info_destroy failed: %d", ret);
1189 g_list_free(media_list_in_tag);
1192 return MEDIA_CONTENT_ERROR_NONE;
1195 /*Get All Music file. sort by Title and not case sensitive*/
1196 int test_get_all_music_files(void)
1198 int ret = MEDIA_CONTENT_ERROR_NONE;
1199 int media_count = 0;
1203 const char *condition = "MEDIA_TYPE=3"; /*0-image, 1-video, 2-sound, 3-music, 4-other*/
1205 ret = media_filter_create(&filter);
1206 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1207 content_error("Fail to create filter");
1210 ret = media_filter_set_condition(filter, condition, MEDIA_CONTENT_COLLATE_LOCALIZED);
1211 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1212 media_filter_destroy(filter);
1213 content_error("Fail to set condition");
1216 ret = media_filter_set_order(filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_TITLE, MEDIA_CONTENT_COLLATE_LOCALIZED);
1217 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1218 media_filter_destroy(filter);
1219 content_error("Fail to set order");
1224 ret = media_info_get_media_count_from_db(filter, &media_count);
1225 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1226 media_filter_destroy(filter);
1227 content_error("Fail to get media count");
1231 content_debug("media_count : [%d]", media_count);
1233 ret = media_info_foreach_media_from_db(filter, media_item_cb, NULL);
1234 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1235 media_filter_destroy(filter);
1236 content_error("Fail to get media");
1240 ret = media_filter_destroy(filter);
1245 int test_media_info_operation(void)
1247 int ret = MEDIA_CONTENT_ERROR_NONE;
1248 int media_count = 0;
1250 content_debug("\n============Media info Test============\n\n");
1252 test_filter_create();
1254 ret = media_info_get_media_count_from_db(g_filter, &media_count);
1255 if (ret != MEDIA_CONTENT_ERROR_NONE)
1256 content_error("media_info_get_media_count_from_db failed: %d", ret);
1258 content_debug("media_count : [%d]", media_count);
1260 ret = media_info_foreach_media_from_db(g_filter, media_item_cb, NULL);
1261 if (ret == MEDIA_CONTENT_ERROR_NONE)
1262 content_debug("media_info_foreach_media_from_db is success");
1264 content_error("media_info_foreach_media_from_db is failed");
1266 test_filter_destroy();
1271 int test_media_info_operation_2(void)
1273 int ret = MEDIA_CONTENT_ERROR_NONE;
1274 int bookmark_count = 0;
1276 content_debug("\n============Media info Test 2============\n\n");
1278 test_filter_create();
1282 char *thumbnail_path1 = tzplatform_mkpath(TZ_USER_VIDEOS, "teat11.jpg");
1283 media_bookmark_insert_to_db(test_video_id, 100, thumbnail_path1);
1284 media_bookmark_insert_to_db(test_video_id, 200, thumbnail_path1);
1286 media_info_get_bookmark_count_from_db(test_video_id, g_filter_g, &bookmark_count);
1288 content_debug("bookmark_count : [%d]", bookmark_count);
1290 ret = media_info_foreach_bookmark_from_db(test_video_id, g_filter_g, bookmarks_cb, NULL);
1294 ret = media_info_get_tag_count_from_db(test_audio_id, g_filter_g, &bookmark_count);
1295 if (ret != MEDIA_CONTENT_ERROR_NONE)
1296 content_error("media_info_get_tag_count_from_db failed: %d", ret);
1298 content_debug("tag_count : [%d]", bookmark_count);
1300 ret = media_info_foreach_tag_from_db(test_audio_id, g_filter_g, tag_list_cb, NULL);
1301 if (ret != MEDIA_CONTENT_ERROR_NONE)
1302 content_error("media_info_foreach_tag_from_db failed: %d", ret);
1304 test_filter_destroy();
1309 int test_folder_operation(void)
1311 int ret = MEDIA_CONTENT_ERROR_NONE;
1312 filter_h filter = NULL;
1313 media_folder_h folder = NULL;
1314 char *folder_id = NULL;
1317 content_debug("\n============Folder Test============\n\n");
1319 test_filter_create();
1321 ret = media_filter_create(&filter);
1322 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1323 content_error("[ERROR] media_folder_filter_create is failed");
1327 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*/
1328 media_filter_set_offset(filter, 0, 5);
1329 media_filter_set_order(filter, MEDIA_CONTENT_ORDER_DESC, MEDIA_PATH, MEDIA_CONTENT_COLLATE_NOCASE);
1330 media_filter_set_storage(filter, "cfbf3d2c-71c5-4611-bccc-7cbac890146e");
1332 ret = media_folder_get_folder_count_from_db(filter, &count);
1333 content_debug("Folder count : [%d]", count);
1335 ret = media_folder_foreach_folder_from_db(filter, folder_list_cb, &folder);
1337 filter_h m_filter = NULL;
1339 ret = media_filter_create(&m_filter);
1340 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1341 test_filter_destroy();
1342 media_filter_destroy(filter);
1343 content_error("[ERROR] media_info_filter_create is failed");
1347 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*/
1348 media_filter_set_offset(m_filter, 0, 5);
1349 media_filter_set_order(m_filter, MEDIA_CONTENT_ORDER_DESC, MEDIA_PATH, MEDIA_CONTENT_COLLATE_NOCASE);
1351 ret = media_folder_foreach_media_from_db(folder_id, m_filter, media_item_cb, NULL);
1352 if (ret != MEDIA_CONTENT_ERROR_NONE)
1353 content_error("[ERROR] media_folder_foreach_media_from_db is failed, error code : %d", ret);
1355 media_filter_destroy(filter);
1356 media_filter_destroy(m_filter);
1358 test_filter_destroy();
1360 /* fix prevent: Resource Leak */
1361 SAFE_FREE(folder_id);
1366 int test_playlist_operation(void)
1368 int ret = MEDIA_CONTENT_ERROR_NONE;
1369 media_playlist_h playlist_1 = NULL;
1370 media_playlist_h playlist_2 = NULL;
1371 media_playlist_h playlist_3 = NULL;
1372 media_playlist_h playlist_4 = NULL;
1373 int playlist_id_1 = 0;
1374 int playlist_id_2 = 0;
1375 int playlist_id_3 = 0;
1376 const char *playlist_name_1 = "myPlaylist_1";
1377 const char *playlist_name_2 = "myPlaylist_2";
1378 const char *playlist_name_3 = "myPlaylist_3";
1379 int playlist_count = 0;
1380 int media_count = 0;
1386 filter_h filter = NULL;
1387 filter_h m_filter = NULL;
1389 content_debug("\n============Playlist Test============\n\n");
1391 /* Filter for playlist */
1393 const char *condition = "(MEDIA_TYPE=1 or MEDIA_TYPE=3)"; /*0-image, 1-video, 2-sound, 3-music, 4-other*/
1395 ret = media_filter_create(&filter);
1396 ret = media_filter_set_condition(filter, condition, MEDIA_CONTENT_COLLATE_NOCASE);
1397 ret = media_filter_set_order(filter, MEDIA_CONTENT_ORDER_ASC, PLAYLIST_NAME, MEDIA_CONTENT_COLLATE_NOCASE);
1399 /* Create Playlist */
1400 media_playlist_insert_to_db(playlist_name_1, &playlist_1);
1401 media_playlist_insert_to_db(playlist_name_2, &playlist_2);
1402 media_playlist_insert_to_db(playlist_name_3, &playlist_3);
1404 if (playlist_1 != NULL) {
1405 /* Add media to Playlist */
1406 media_playlist_add_media(playlist_1, test_audio_id);
1407 media_playlist_add_media(playlist_1, test_audio_id);
1408 media_playlist_add_media(playlist_1, test_video_id);
1411 char *playlist_thumb_path = tzplatform_mkpath(TZ_USER_IMAGES, "Default.jpg"));
1412 media_playlist_set_thumbnail_path(playlist_1, playlist_thumb_path);
1415 media_playlist_update_to_db(playlist_1);
1418 if (playlist_2 != NULL) {
1419 media_playlist_add_media(playlist_2, test_audio_id);
1420 media_playlist_add_media(playlist_2, test_audio_id);
1421 media_playlist_update_to_db(playlist_2);
1424 /* Get Playlist Count*/
1425 ret = media_playlist_get_playlist_count_from_db(filter, &playlist_count);
1427 content_debug("playlist_count [%d]", playlist_count);
1430 GList *playlist_id_list = NULL;
1431 media_playlist_foreach_playlist_from_db(filter, playlist_list_cb, &playlist_id_list);
1432 /* 64bit build issue */
1434 /* Get Playlist id*/
1435 playlist_id_1 = (int)g_list_nth_data(playlist_id_list, 0);
1436 playlist_id_2 = (int)g_list_nth_data(playlist_id_list, 1);
1437 playlist_id_3 = (int)g_list_nth_data(playlist_id_list, 2);
1439 content_debug("playlist_id_1 [%d]", playlist_id_1);
1440 content_debug("playlist_id_2 [%d]", playlist_id_2);
1441 content_debug("playlist_id_3 [%d]", playlist_id_3);
1443 /* Export and import playlist */
1444 media_playlist_export_to_file(playlist_3, tzplatform_mkpath(TZ_USER_MUSIC, "playlist.m3u"));
1445 media_playlist_import_from_file(tzplatform_mkpath(TZ_USER_MUSIC, "playlist.m3u"), "playlist_4", &playlist_4);
1447 /* Filter for media*/
1448 ret = media_filter_create(&m_filter);
1450 ret = media_filter_set_condition(m_filter, condition, MEDIA_CONTENT_COLLATE_DEFAULT);
1452 ret = media_filter_set_order(m_filter, MEDIA_CONTENT_ORDER_ASC, PLAYLIST_MEMBER_ORDER, MEDIA_CONTENT_COLLATE_DEFAULT);
1454 /* Get media count */
1455 media_playlist_get_media_count_from_db(playlist_id_1, m_filter, &media_count);
1456 content_debug("playlist_1_media_count [%d]", media_count);
1458 media_playlist_get_media_count_from_db(playlist_id_2, m_filter, &media_count);
1459 content_debug("playlist_2_media_count [%d]", media_count);
1461 media_playlist_get_media_count_from_db(playlist_id_3, m_filter, &media_count);
1462 content_debug("playlist_3_media_count [%d]", media_count);
1464 /* Get media of playlist */
1465 GList *playlist_member_id_list = NULL;
1466 GList *playlist_member_id_list_1 = NULL;
1468 media_playlist_foreach_media_from_db(playlist_id_1, m_filter, playlist_item_cb, &playlist_member_id_list);
1469 media_playlist_foreach_media_from_db(playlist_id_2, m_filter, playlist_item_cb, &playlist_member_id_list_1);
1471 int playlist_member_id_1_1 = 0;
1472 int playlist_member_id_1_2 = 0;
1473 int playlist_member_id_1_3 = 0;
1474 int playlist_member_id_2_1 = 0;
1475 int playlist_member_id_2_2 = 0;
1476 /* 64bit build issue */
1478 playlist_member_id_1_1 = (int)g_list_nth_data(playlist_member_id_list, 0);
1479 playlist_member_id_1_2 = (int)g_list_nth_data(playlist_member_id_list, 1);
1480 playlist_member_id_1_3 = (int)g_list_nth_data(playlist_member_id_list, 2);
1481 playlist_member_id_2_1 = (int)g_list_nth_data(playlist_member_id_list_1, 0);
1482 playlist_member_id_2_2 = (int)g_list_nth_data(playlist_member_id_list_1, 1);
1484 content_debug("playlist_member_id_1_1 [%d]", playlist_member_id_1_1);
1485 content_debug("playlist_member_id_1_2 [%d]", playlist_member_id_1_2);
1486 content_debug("playlist_member_id_1_3 [%d]", playlist_member_id_1_3);
1487 content_debug("playlist_member_id_2_1 [%d]", playlist_member_id_2_1);
1488 content_debug("playlist_member_id_2_2 [%d]", playlist_member_id_2_2);
1490 media_playlist_get_play_order(playlist_1, playlist_member_id_1_1, &order_1);
1491 media_playlist_get_play_order(playlist_1, playlist_member_id_1_2, &order_2);
1492 media_playlist_get_play_order(playlist_1, playlist_member_id_1_3, &order_3);
1493 media_playlist_get_play_order(playlist_2, playlist_member_id_2_1, &order_4);
1494 media_playlist_get_play_order(playlist_2, playlist_member_id_2_2, &order_5);
1495 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);
1497 /* Update Playlist */
1498 media_playlist_remove_media(playlist_2, playlist_member_id_2_1);
1499 media_playlist_add_media(playlist_2, test_video_id);
1500 media_playlist_set_name(playlist_2, "test_playlist");
1501 media_playlist_set_play_order(playlist_2, playlist_member_id_2_2, order_5+100);
1502 media_playlist_update_to_db(playlist_2);
1504 /* Get Updated Playlist*/
1505 media_playlist_foreach_playlist_from_db(filter, playlist_list_cb, NULL);
1507 /* deletes the playlist */
1509 media_playlist_delete_from_db(playlist_id_1);
1510 media_playlist_delete_from_db(playlist_id_2);
1513 if (playlist_1 != NULL)
1514 media_playlist_destroy(playlist_1);
1515 if (playlist_2 != NULL)
1516 media_playlist_destroy(playlist_2);
1517 if (playlist_3 != NULL)
1518 media_playlist_destroy(playlist_3);
1519 if (playlist_4 != NULL)
1520 media_playlist_destroy(playlist_4);
1522 g_list_free(playlist_id_list);
1523 g_list_free(playlist_member_id_list);
1524 g_list_free(playlist_member_id_list_1);
1527 ret = media_filter_destroy(filter);
1528 if (m_filter != NULL)
1529 ret = media_filter_destroy(m_filter);
1534 int test_playlist_operation_v2(void)
1536 int ret = MEDIA_CONTENT_ERROR_NONE;
1537 media_playlist_h playlist_1 = NULL;
1538 const char *playlist_name_1 = "myPlaylist_1";
1539 const char *playlist_thumb_path = tzplatform_mkpath(TZ_USER_IMAGES, "Default.jpg");
1540 int playlist_id = 0;
1542 content_debug("\n============Playlist Test V2============\n\n");
1544 ret = media_playlist_create(&playlist_1);
1545 if (ret != MEDIA_CONTENT_ERROR_NONE)
1546 content_error("error media_playlist_create : [%d]", ret);
1548 ret = media_playlist_set_name(playlist_1, playlist_name_1);
1549 if (ret != MEDIA_CONTENT_ERROR_NONE)
1550 content_error("error media_playlist_set_name : [%d]", ret);
1552 ret = media_playlist_set_thumbnail_path(playlist_1, playlist_thumb_path);
1553 if (ret != MEDIA_CONTENT_ERROR_NONE)
1554 content_error("error media_playlist_set_thumbnail_path : [%d]", ret);
1556 ret = media_playlist_insert_to_db_v2(playlist_1);
1557 if (ret != MEDIA_CONTENT_ERROR_NONE)
1558 content_error("error media_playlist_insert_to_db_v2 : [%d]", ret);
1560 ret = media_playlist_set_name(playlist_1, "myPlaylist_3");
1561 if (ret != MEDIA_CONTENT_ERROR_NONE)
1562 content_error("error media_playlist_set_name : [%d]", ret);
1564 ret = media_playlist_get_playlist_id(playlist_1, &playlist_id);
1565 if (ret != MEDIA_CONTENT_ERROR_NONE)
1566 content_error("error media_playlist_get_playlist_id : [%d]", ret);
1568 ret = media_playlist_update_to_db_v2(playlist_id, playlist_1);
1569 if (ret != MEDIA_CONTENT_ERROR_NONE)
1570 content_error("error media_playlist_update_to_db_v2 : [%d]", ret);
1572 ret = media_playlist_destroy(playlist_1);
1573 if (ret != MEDIA_CONTENT_ERROR_NONE)
1574 content_error("error media_playlist_destroy : [%d]", ret);
1579 int test_tag_operation(void)
1581 int ret = MEDIA_CONTENT_ERROR_NONE;
1588 const char *tag_name_1 = "myTag_1";
1589 const char *tag_name_2 = "myTag_2";
1590 const char *tag_name_3 = "myTag_3";
1592 int media_count = 0;
1595 content_debug("\n============Tag Test============\n\n");
1597 const char *g_condition = "TAG_NAME like \"%%my%%\"";
1599 ret = media_filter_create(&filter);
1601 ret = media_filter_set_condition(filter, g_condition, MEDIA_CONTENT_COLLATE_DEFAULT);
1603 ret = media_filter_set_order(filter, MEDIA_CONTENT_ORDER_DESC, TAG_NAME, MEDIA_CONTENT_COLLATE_DEFAULT);
1606 ret = media_tag_insert_to_db(tag_name_1, &tag_1);
1607 if (ret != MEDIA_CONTENT_ERROR_NONE)
1608 content_error("error media_tag_insert_to_db : [%d]", ret);
1609 ret = media_tag_insert_to_db(tag_name_2, &tag_2);
1610 if (ret != MEDIA_CONTENT_ERROR_NONE)
1611 content_error("error media_tag_insert_to_db : [%d]", ret);
1612 ret = media_tag_insert_to_db(tag_name_3, &tag_3);
1613 if (ret != MEDIA_CONTENT_ERROR_NONE)
1614 content_error("error media_tag_insert_to_db : [%d]", ret);
1616 /* Add media to Tag */
1617 ret = media_tag_add_media(tag_1, test_audio_id);
1618 if (ret != MEDIA_CONTENT_ERROR_NONE)
1619 content_error("error media_tag_add_media : [%d]", ret);
1620 ret = media_tag_add_media(tag_1, test_video_id);
1621 if (ret != MEDIA_CONTENT_ERROR_NONE)
1622 content_error("error media_tag_add_media : [%d]", ret);
1623 ret = media_tag_update_to_db(tag_1);
1624 if (ret != MEDIA_CONTENT_ERROR_NONE)
1625 content_error("error media_tag_update_to_db : [%d]", ret);
1627 ret = media_tag_add_media(tag_2, test_audio_id);
1628 if (ret != MEDIA_CONTENT_ERROR_NONE)
1629 content_error("error media_tag_add_media : [%d]", ret);
1630 ret = media_tag_update_to_db(tag_2);
1631 if (ret != MEDIA_CONTENT_ERROR_NONE)
1632 content_error("error media_tag_update_to_db : [%d]", ret);
1635 ret = media_tag_get_tag_count_from_db(filter, &tag_count);
1636 if (ret != MEDIA_CONTENT_ERROR_NONE)
1637 content_error("error media_tag_get_tag_count_from_db : [%d]", ret);
1639 content_debug("tag_count [%d]", tag_count);
1642 ret = media_tag_foreach_tag_from_db(filter, tag_list_cb, NULL);
1643 if (ret != MEDIA_CONTENT_ERROR_NONE)
1644 content_error("error media_tag_foreach_tag_from_db : [%d]", ret);
1647 ret = media_tag_get_tag_id(tag_1, &tag_id_1);
1648 if (ret != MEDIA_CONTENT_ERROR_NONE)
1649 content_error("error media_tag_get_tag_id : [%d]", ret);
1651 content_debug("tag_id_1 [%d]", tag_id_1);
1653 ret = media_tag_get_tag_id(tag_2, &tag_id_2);
1654 if (ret != MEDIA_CONTENT_ERROR_NONE)
1655 content_error("error media_tag_get_tag_id : [%d]", ret);
1657 content_debug("tag_id_2 [%d]", tag_id_2);
1659 ret = media_tag_get_tag_id(tag_3, &tag_id_3);
1660 if (ret != MEDIA_CONTENT_ERROR_NONE)
1661 content_error("error media_tag_get_tag_id : [%d]", ret);
1663 content_debug("tag_id_3 [%d]", tag_id_3);
1665 /* Get media count */
1666 ret = media_tag_get_media_count_from_db(tag_id_1, NULL, &media_count);
1667 if (ret != MEDIA_CONTENT_ERROR_NONE)
1668 content_error("error media_tag_get_media_count_from_db : [%d]", ret);
1670 content_debug("tag_1_media_count [%d]", media_count);
1672 ret = media_tag_get_media_count_from_db(tag_id_2, NULL, &media_count);
1673 if (ret != MEDIA_CONTENT_ERROR_NONE)
1674 content_error("error media_tag_get_media_count_from_db : [%d]", ret);
1676 content_debug("tag_2_media_count [%d]", media_count);
1678 /* Get media of Tag */
1679 ret = media_tag_foreach_media_from_db(tag_id_1, NULL, media_item_cb, NULL);
1680 if (ret != MEDIA_CONTENT_ERROR_NONE)
1681 content_error("error media_tag_foreach_media_from_db : [%d]", ret);
1683 ret = media_tag_foreach_media_from_db(tag_id_2, NULL, media_item_cb, NULL);
1684 if (ret != MEDIA_CONTENT_ERROR_NONE)
1685 content_error("error media_tag_foreach_media_from_db : [%d]", ret);
1688 ret = media_tag_add_media(tag_2, test_video_id);
1689 if (ret != MEDIA_CONTENT_ERROR_NONE)
1690 content_error("error media_tag_add_media : [%d]", ret);
1691 ret = media_tag_set_name(tag_2, "test_tag");
1692 if (ret != MEDIA_CONTENT_ERROR_NONE)
1693 content_error("error media_tag_set_name : [%d]", ret);
1694 ret = media_tag_update_to_db(tag_2);
1695 if (ret != MEDIA_CONTENT_ERROR_NONE)
1696 content_error("error media_tag_update_to_db : [%d]", ret);
1698 /* Get Updated Tag*/
1699 ret = media_tag_foreach_tag_from_db(filter, tag_list_cb, NULL);
1700 if (ret != MEDIA_CONTENT_ERROR_NONE)
1701 content_error("error media_tag_foreach_tag_from_db : [%d]", ret);
1703 /* deletes the tag */
1704 ret = media_tag_delete_from_db(tag_id_1);
1705 if (ret != MEDIA_CONTENT_ERROR_NONE)
1706 content_error("error media_tag_delete_from_db : [%d]", ret);
1707 ret = media_tag_delete_from_db(tag_id_2);
1708 if (ret != MEDIA_CONTENT_ERROR_NONE)
1709 content_error("error media_tag_delete_from_db : [%d]", ret);
1711 ret = media_tag_destroy(tag_1);
1712 if (ret != MEDIA_CONTENT_ERROR_NONE)
1713 content_error("error media_tag_destroy : [%d]", ret);
1714 ret = media_tag_destroy(tag_2);
1715 if (ret != MEDIA_CONTENT_ERROR_NONE)
1716 content_error("error media_tag_destroy : [%d]", ret);
1717 ret = media_tag_destroy(tag_3);
1718 if (ret != MEDIA_CONTENT_ERROR_NONE)
1719 content_error("error media_tag_destroy : [%d]", ret);
1720 ret = media_filter_destroy(filter);
1721 if (ret != MEDIA_CONTENT_ERROR_NONE)
1722 content_error("error media_filter_destroy : [%d]", ret);
1727 int test_tag_operation_v2(void)
1729 int ret = MEDIA_CONTENT_ERROR_NONE;
1731 const char *tag_name_1 = "myTag_1";
1734 content_debug("\n============Tag Test V2============\n\n");
1737 ret = media_tag_create(&tag_1);
1738 if (ret != MEDIA_CONTENT_ERROR_NONE)
1739 content_error("error media_tag_create : [%d]", ret);
1741 ret = media_tag_set_name(tag_1, tag_name_1);
1742 if (ret != MEDIA_CONTENT_ERROR_NONE)
1743 content_error("error media_tag_set_name : [%d]", ret);
1745 /* Add media to Tag */
1746 ret = media_tag_add_media(tag_1, test_audio_id);
1747 if (ret != MEDIA_CONTENT_ERROR_NONE)
1748 content_error("error media_tag_add_media : [%d]", ret);
1750 ret = media_tag_add_media(tag_1, test_video_id);
1751 if (ret != MEDIA_CONTENT_ERROR_NONE)
1752 content_error("error media_tag_add_media : [%d]", ret);
1754 ret = media_tag_insert_to_db_v2(tag_1);
1755 if (ret != MEDIA_CONTENT_ERROR_NONE)
1756 content_error("error media_tag_insert_to_db_v2 : [%d]", ret);
1759 ret = media_tag_get_tag_id(tag_1, &tag_id);
1760 if (ret != MEDIA_CONTENT_ERROR_NONE)
1761 content_error("error media_tag_get_tag_id : [%d]", ret);
1763 ret = media_tag_remove_media(tag_1, test_video_id);
1764 if (ret != MEDIA_CONTENT_ERROR_NONE)
1765 content_error("error media_tag_add_media : [%d]", ret);
1767 ret = media_tag_update_to_db_v2(tag_id, tag_1);
1768 if (ret != MEDIA_CONTENT_ERROR_NONE)
1769 content_error("error media_tag_update_to_db_v2 : [%d]", ret);
1772 ret = media_tag_destroy(tag_1);
1773 if (ret != MEDIA_CONTENT_ERROR_NONE)
1774 content_error("error media_tag_destroy : [%d]", ret);
1779 int test_bookmark_operation(void)
1781 /* bookmark is only supported for video information. */
1782 int ret = MEDIA_CONTENT_ERROR_NONE;
1783 int bookmark_count = 0;
1785 GList *all_item_list = NULL;
1788 content_debug("\n============Bookmark Test============\n\n");
1790 const char *g_condition = "BOOKMARK_MARKED_TIME > 300";
1792 ret = media_filter_create(&filter);
1793 if (ret != MEDIA_CONTENT_ERROR_NONE)
1794 content_error("error media_filter_create : [%d]", ret);
1796 ret = media_filter_set_condition(filter, g_condition, MEDIA_CONTENT_COLLATE_DEFAULT);
1797 if (ret != MEDIA_CONTENT_ERROR_NONE)
1798 content_error("error media_filter_set_condition : [%d]", ret);
1800 ret = media_filter_set_order(filter, MEDIA_CONTENT_ORDER_DESC, BOOKMARK_MARKED_TIME, MEDIA_CONTENT_COLLATE_DEFAULT);
1801 if (ret != MEDIA_CONTENT_ERROR_NONE)
1802 content_error("error media_filter_set_order : [%d]", ret);
1804 /* insert bookmark to video */
1805 const char *thumbnail_path1 = tzplatform_mkpath(TZ_USER_VIDEOS, "teat11.jpg");
1806 ret = media_bookmark_insert_to_db(test_video_id, 400, thumbnail_path1);
1807 if (ret != MEDIA_CONTENT_ERROR_NONE)
1808 content_error("error media_bookmark_insert_to_db : [%d]", ret);
1810 ret = media_bookmark_insert_to_db(test_video_id, 600, thumbnail_path1);
1811 if (ret != MEDIA_CONTENT_ERROR_NONE)
1812 content_error("error media_bookmark_insert_to_db : [%d]", ret);
1814 ret = media_bookmark_get_bookmark_count_from_db(filter, &bookmark_count);
1815 if (ret != MEDIA_CONTENT_ERROR_NONE)
1816 content_error("error media_bookmark_get_bookmark_count_from_db : [%d]", ret);
1818 content_debug("bookmark_count = [%d]", bookmark_count);
1820 ret = media_info_foreach_bookmark_from_db(test_video_id, NULL, bookmarks_cb, &all_item_list);
1821 if (ret != MEDIA_CONTENT_ERROR_NONE)
1822 content_error("error media_info_foreach_bookmark_from_db : [%d]", ret);
1824 for (idx = 0; idx < g_list_length(all_item_list); idx++) {
1825 media_bookmark_h bookmark_handle;
1826 bookmark_handle = (media_bookmark_h)g_list_nth_data(all_item_list, idx);
1828 ret = media_bookmark_set_name(bookmark_handle, "test 1");
1829 if (ret != MEDIA_CONTENT_ERROR_NONE)
1830 content_error("error media_bookmark_set_name : [%d]", ret);
1832 ret = media_bookmark_update_to_db(bookmark_handle);
1833 if (ret != MEDIA_CONTENT_ERROR_NONE)
1834 content_error("error media_bookmark_update_to_db : [%d]", ret);
1837 ret = media_info_foreach_bookmark_from_db(test_video_id, NULL, bookmarks_cb, NULL);
1838 if (ret != MEDIA_CONTENT_ERROR_NONE)
1839 content_error("error media_info_foreach_bookmark_from_db : [%d]", ret);
1841 ret = media_filter_destroy(filter);
1842 if (ret != MEDIA_CONTENT_ERROR_NONE)
1843 content_error("error media_filter_destroy : [%d]", ret);
1848 int test_bookmark_operation_v2(void)
1850 content_debug("\n============Bookmark Test V2============\n\n");
1852 int ret = MEDIA_CONTENT_ERROR_NONE;
1853 media_bookmark_h bookmark = NULL;
1854 const char *thumbnail_path1 = tzplatform_mkpath(TZ_USER_VIDEOS, "teat11.jpg");
1856 ret = media_bookmark_create(test_video_id, 400, &bookmark);
1857 if (ret != MEDIA_CONTENT_ERROR_NONE)
1858 content_error("error media_bookmark_create : [%d]", ret);
1860 ret = media_bookmark_set_name(bookmark, "test bookmark");
1861 if (ret != MEDIA_CONTENT_ERROR_NONE)
1862 content_error("error media_bookmark_set_name : [%d]", ret);
1864 ret = media_bookmark_set_thumbnail_path(bookmark, thumbnail_path1);
1865 if (ret != MEDIA_CONTENT_ERROR_NONE)
1866 content_error("error media_bookmark_set_thumbnail_path : [%d]", ret);
1868 ret = media_bookmark_insert_to_db_v2(bookmark);
1869 if (ret != MEDIA_CONTENT_ERROR_NONE)
1870 content_error("error media_bookmark_insert_to_db_v2 : [%d]", ret);
1872 ret = media_bookmark_set_name(bookmark, "test bookmark 2");
1873 if (ret != MEDIA_CONTENT_ERROR_NONE)
1874 content_error("error media_bookmark_set_name : [%d]", ret);
1876 ret = media_bookmark_update_to_db(bookmark);
1877 if (ret != MEDIA_CONTENT_ERROR_NONE)
1878 content_error("error media_bookmark_update_to_db : [%d]", ret);
1880 ret = media_bookmark_destroy(bookmark);
1881 if (ret != MEDIA_CONTENT_ERROR_NONE)
1882 content_error("error media_bookmark_destroy : [%d]", ret);
1887 int test_album_list(void)
1889 content_debug("\n============Album Test============\n\n");
1891 int ret = MEDIA_CONTENT_ERROR_NONE;
1892 int album_count = 0;
1896 const char *condition = "MEDIA_TYPE=3"; /*0-image, 1-video, 2-sound, 3-music, 4-other*/
1898 ret = media_filter_create(&filter);
1899 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1900 content_error("Fail to create filter");
1903 ret = media_filter_set_condition(filter, condition, MEDIA_CONTENT_COLLATE_DEFAULT);
1904 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1905 media_filter_destroy(filter);
1906 content_error("Fail to set condition");
1909 ret = media_filter_set_order(filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_ALBUM, MEDIA_CONTENT_COLLATE_NOCASE);
1910 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1911 media_filter_destroy(filter);
1912 content_error("Fail to set order");
1916 ret = media_album_get_album_count_from_db(filter, &album_count);
1917 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1918 media_filter_destroy(filter);
1921 content_debug("album_count [%d]", album_count);
1924 ret = media_album_foreach_album_from_db(filter, album_list_cb, NULL);
1925 if (ret != MEDIA_CONTENT_ERROR_NONE)
1926 content_error("error media_album_foreach_album_from_db : [%d]", ret);
1928 ret = media_filter_destroy(filter);
1929 if (ret != MEDIA_CONTENT_ERROR_NONE)
1930 content_error("error media_filter_destroy : [%d]", ret);
1935 int test_group_operation(void)
1937 content_debug("\n============Group Test============\n\n");
1939 int ret = MEDIA_CONTENT_ERROR_NONE;
1940 int group_count = 0;
1943 ret = test_filter_create();
1944 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1945 content_error("[error(0x%08x)", ret);
1949 for (idx = 0; idx < MEDIA_CONTENT_GROUP_MAX; idx++) {
1950 ret = media_group_get_group_count_from_db(g_filter, idx, &group_count);
1951 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1952 test_filter_destroy();
1953 content_error("media_group_get_group_count_from_db fail. ret=[%d] idx=[%d]", ret, idx);
1956 content_debug("[%2d]group_count [%d]", idx, group_count);
1959 ret = media_group_foreach_group_from_db(g_filter, idx, group_list_cb, &idx);
1960 if (ret != MEDIA_CONTENT_ERROR_NONE)
1961 content_error("media_group_foreach_group_from_db failed: %d", ret);
1963 ret = test_filter_destroy();
1968 int test_update_operation()
1970 int ret = MEDIA_CONTENT_ERROR_NONE;
1972 media_info_h media_handle = NULL;
1973 GList *all_item_list = NULL;
1975 /* Get all item list */
1976 ret = media_info_foreach_media_from_db(NULL, gallery_media_item_cb, &all_item_list);
1977 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1978 content_error("media_info_foreach_media_from_db failed: %d", ret);
1981 content_debug("media_info_foreach_media_from_db success");
1983 for (i = 0; i < g_list_length(all_item_list); i++) {
1984 media_handle = (media_info_h)g_list_nth_data(all_item_list, i);
1985 get_media_meta(media_handle);
1989 return MEDIA_CONTENT_ERROR_NONE;
1992 int test_insert(void)
1994 int ret = MEDIA_CONTENT_ERROR_NONE;
1995 const char *path = tzplatform_mkpath(TZ_USER_IMAGES, "Default.jpg");
1997 const char *path = tzplatform_mkpath(TZ_USER_DOCUMENTS, "other.txt"));
2000 media_info_h media_item = NULL;
2001 content_debug("\n============DB Insert Test============\n\n");
2003 ret = media_info_insert_to_db(path, &media_item);
2005 if ((ret == MEDIA_CONTENT_ERROR_NONE) && (media_item != NULL)) {
2006 content_debug("Insertion is success");
2008 content_error("Insertion is failed");
2009 ret = media_info_destroy(media_item);
2013 char *media_id = NULL;
2015 ret = media_info_get_media_id(media_item, &media_id);
2016 if (ret != MEDIA_CONTENT_ERROR_NONE)
2017 content_error("media_info_get_media_id failed: %d", ret);
2019 content_debug("Media ID: %s", media_id);
2021 SAFE_FREE(media_id);
2023 ret = media_info_update_to_db(media_item);
2024 if (ret == MEDIA_CONTENT_ERROR_NONE)
2025 content_debug("media_info_update_to_db is success");
2027 content_error("media_info_update_to_db is failed");
2029 ret = media_info_destroy(media_item);
2030 if (ret != MEDIA_CONTENT_ERROR_NONE)
2031 content_error("media_info_destroy failed: %d", ret);
2038 int ret = MEDIA_CONTENT_ERROR_NONE;
2039 const char *move_media_id = "60aea677-4742-408e-b5f7-f2628062d06d";
2040 const char *dst_path = tzplatform_mkpath(TZ_USER_IMAGES, "XX/Default1.jpg");
2041 media_info_h move_media = NULL;
2043 ret = media_info_get_media_from_db(move_media_id, &move_media);
2044 if (ret == MEDIA_CONTENT_ERROR_NONE)
2045 content_debug("media_info_get_media_from_db success");
2047 content_error("media_info_get_media_from_db failed: %d", ret);
2049 content_debug("\n============DB Move Test============\n\n");
2052 ret = media_info_move_to_db(move_media, dst_path);
2054 if (ret == MEDIA_CONTENT_ERROR_NONE)
2055 content_debug("Move is success");
2057 content_error("Move is failed");
2059 ret = media_info_destroy(move_media);
2061 content_debug("There is no item : %s", move_media_id);
2067 void thumbnail_completed_cb(media_content_error_e error, const char *path, void *user_data)
2069 char *thumbnail_path = NULL;
2070 int ret = MEDIA_CONTENT_ERROR_NONE;
2073 content_debug("=================[%d][%d]", g_media_cnt, g_cnt);
2074 content_debug("error_code [%d]", error);
2075 content_debug("thumbnail_path [%s]", path);
2076 if (user_data != NULL) {
2077 media_info_h media = (media_info_h)user_data;
2078 ret = media_info_get_thumbnail_path(media, &thumbnail_path);
2079 if (ret != MEDIA_CONTENT_ERROR_NONE)
2080 content_error("media_info_get_thumbnail_path failed: %d", ret);
2082 content_debug("thumbnail_path get from media[%s]", thumbnail_path);
2083 SAFE_FREE(thumbnail_path);
2084 ret = media_info_destroy(media);
2085 if (ret != MEDIA_CONTENT_ERROR_NONE)
2086 content_error("media_info_destroy failed: %d", ret);
2089 if (g_cnt == g_media_cnt)
2090 g_main_loop_quit(g_loop);
2095 bool thumbnail_create_cb(media_info_h media, void *user_data)
2097 char *media_id = NULL;
2098 media_info_h dst = NULL;
2099 int ret = MEDIA_CONTENT_ERROR_NONE;
2101 if (media == NULL) {
2102 content_debug("NO Item");
2106 ret = media_info_get_media_id(media, &media_id);
2107 if (ret != MEDIA_CONTENT_ERROR_NONE)
2108 content_error("media_info_get_media_id failed: %d", ret);
2110 content_debug("media_id : [%s]", media_id);
2112 ret = media_info_clone(&dst, media);
2113 if (ret != MEDIA_CONTENT_ERROR_NONE)
2114 content_error("media_info_clone failed: %d", ret);
2116 ret = media_info_create_thumbnail(dst, thumbnail_completed_cb, dst);
2117 if (ret != MEDIA_CONTENT_ERROR_NONE)
2118 content_error("media_info_create_thumbnail failed: %d", ret);
2121 /* fix prevent: Resource leak */
2122 SAFE_FREE(media_id);
2127 bool thumbnail_cancel_cb(media_info_h media, void *user_data)
2129 int ret = MEDIA_CONTENT_ERROR_NONE;
2131 char *media_id = NULL;
2132 media_info_h dst = NULL;
2136 if (media == NULL) {
2137 content_debug("NO Item");
2141 ret = media_info_get_media_id(media, &media_id);
2142 if (ret != MEDIA_CONTENT_ERROR_NONE)
2143 content_error("media_info_get_media_id failed: %d", ret);
2145 content_debug("media_id : [%s]", media_id);
2147 ret = media_info_clone(&dst, media);
2148 if (ret != MEDIA_CONTENT_ERROR_NONE)
2149 content_error("media_info_clone failed: %d", ret);
2151 ret = media_info_cancel_thumbnail(dst);
2152 if (ret != MEDIA_CONTENT_ERROR_NONE)
2153 content_error("media_info_cancel_thumbnail failed: %d", ret);
2155 ret = media_info_destroy(dst);
2156 if (ret != MEDIA_CONTENT_ERROR_NONE)
2157 content_error("media_info_destroy failed: %d", ret);
2159 if (g_cnt == g_media_cnt)
2160 g_main_loop_quit(g_loop);
2162 /* fix prevent: Resource leak */
2163 SAFE_FREE(media_id);
2168 gboolean create_thumbnail_start(gpointer data)
2170 int ret = MEDIA_CONTENT_ERROR_NONE;
2172 ret = media_info_foreach_media_from_db(g_filter, thumbnail_create_cb, NULL);
2174 if (ret == MEDIA_CONTENT_ERROR_NONE)
2175 content_debug("media_info_foreach_media_from_db is success");
2177 content_error("media_info_foreach_media_from_db is failed");
2182 gboolean cancel_thumbnail_start(gpointer data)
2184 int ret = MEDIA_CONTENT_ERROR_NONE;
2186 ret = media_info_foreach_media_from_db(g_filter, thumbnail_cancel_cb, NULL);
2188 if (ret == MEDIA_CONTENT_ERROR_NONE)
2189 content_debug("media_info_foreach_media_from_db is success");
2191 content_error("media_info_foreach_media_from_db is failed");
2196 int test_create_thumbnail(int cancel)
2198 int ret = MEDIA_CONTENT_ERROR_NONE;
2199 GSource *source = NULL;
2200 GMainContext *context = NULL;
2202 test_filter_create();
2204 ret = media_info_get_media_count_from_db(g_filter, &g_media_cnt);
2205 if (ret != MEDIA_CONTENT_ERROR_NONE)
2206 content_error("media_info_get_media_count_from_db failed: %d", ret);
2208 content_debug("media_count : [%d]", g_media_cnt);
2210 g_loop = g_main_loop_new(NULL, FALSE);
2211 context = g_main_loop_get_context(g_loop);
2212 source = g_idle_source_new();
2213 g_source_set_callback(source, create_thumbnail_start, NULL, NULL);
2214 g_source_attach(source, context);
2216 /* Logic to cancel */
2218 GSource *cancel_src = NULL;
2219 cancel_src = g_idle_source_new();
2220 g_source_set_callback(cancel_src, cancel_thumbnail_start, NULL, NULL);
2221 g_source_attach(cancel_src, context);
2224 g_main_loop_run(g_loop);
2225 g_main_loop_unref(g_loop);
2227 test_filter_destroy();
2232 bool face_cb(media_face_h face, void *user_data)
2234 get_face_meta(face);
2239 void face_detection_complete_cb(media_content_error_e error, int count, void *user_data)
2241 int ret = MEDIA_CONTENT_ERROR_NONE;
2244 content_debug("=================[%d][%d]", g_media_cnt, g_cnt);
2245 content_debug("error_code [%d]", error);
2246 content_debug("face_count [%d]", count);
2248 content_debug("No faces are detected!");
2249 } else if (user_data != NULL) {
2250 media_info_h media = (media_info_h)user_data;
2251 char *media_id = NULL;
2252 ret = media_info_get_media_id(media, &media_id);
2253 if (ret != MEDIA_CONTENT_ERROR_NONE)
2254 content_error("media_info_get_media_id failed: %d", ret);
2255 if (media_id != NULL) {
2256 ret = media_info_foreach_face_from_db(media_id, NULL, face_cb, NULL);
2257 SAFE_FREE(media_id);
2258 if (ret != MEDIA_CONTENT_ERROR_NONE)
2259 content_error("media_info_foreach_face_from_db failed: %d", ret);
2261 ret = media_info_destroy(media);
2262 if (ret != MEDIA_CONTENT_ERROR_NONE)
2263 content_error("media_info_destroy failed: %d", ret);
2266 if (g_cnt == g_media_cnt)
2267 g_main_loop_quit(g_loop);
2272 bool start_face_detection_cb(media_info_h media, void *user_data)
2274 char *media_id = NULL;
2275 media_info_h dst = NULL;
2276 int ret = MEDIA_CONTENT_ERROR_NONE;
2278 if (media == NULL) {
2279 content_debug("NO Item");
2283 ret = media_info_get_media_id(media, &media_id);
2284 if (ret != MEDIA_CONTENT_ERROR_NONE)
2285 content_error("media_info_get_media_id failed: %d", ret);
2287 content_debug("media_id : [%s]", media_id);
2289 ret = media_info_clone(&dst, media);
2290 if (ret != MEDIA_CONTENT_ERROR_NONE)
2291 content_error("media_info_clone failed: %d", ret);
2293 GList **list = (GList**)user_data;
2294 *list = g_list_append(*list, dst);
2296 /* fix prevent: Resource leak */
2297 SAFE_FREE(media_id);
2302 bool cancel_face_detection_cb(media_info_h media, void *user_data)
2304 int ret = MEDIA_CONTENT_ERROR_NONE;
2306 char *media_id = NULL;
2307 media_info_h dst = NULL;
2311 if (media == NULL) {
2312 content_debug("NO Item");
2316 ret = media_info_get_media_id(media, &media_id);
2317 if (ret != MEDIA_CONTENT_ERROR_NONE)
2318 content_error("media_info_get_media_id failed: %d", ret);
2320 content_debug("media_id : [%s]", media_id);
2322 ret = media_info_clone(&dst, media);
2323 if (ret != MEDIA_CONTENT_ERROR_NONE)
2324 content_error("media_info_clone failed: %d", ret);
2326 ret = media_info_cancel_face_detection(dst);
2327 if (ret != MEDIA_CONTENT_ERROR_NONE)
2328 content_error("media_info_cancel_face_detection failed: %d", ret);
2330 ret = media_info_destroy(dst);
2331 if (ret != MEDIA_CONTENT_ERROR_NONE)
2332 content_error("media_info_destroy failed: %d", ret);
2334 if (g_cnt == g_media_cnt)
2335 g_main_loop_quit(g_loop);
2337 /* fix prevent: Resource leak */
2338 SAFE_FREE(media_id);
2343 gboolean face_detection_start(gpointer data)
2345 int ret = MEDIA_CONTENT_ERROR_NONE;
2346 GList *all_item_list = NULL;
2349 ret = media_info_foreach_media_from_db(g_filter, start_face_detection_cb, &all_item_list);
2351 if (ret == MEDIA_CONTENT_ERROR_NONE)
2352 content_debug("media_info_foreach_media_from_db is success");
2354 content_error("media_info_foreach_media_from_db is failed");
2356 for (idx = 0; idx < g_list_length(all_item_list); idx++) {
2357 media_info_h media_handle = NULL;
2359 media_handle = (media_info_h)g_list_nth_data(all_item_list, idx);
2361 ret = media_info_start_face_detection(media_handle, face_detection_complete_cb, NULL);
2362 if (ret != MEDIA_CONTENT_ERROR_NONE)
2363 content_error("media_info_start_face_detection failed: %d", ret);
2370 gboolean face_detection_cancel(gpointer data)
2372 int ret = MEDIA_CONTENT_ERROR_NONE;
2374 ret = media_info_foreach_media_from_db(g_filter, cancel_face_detection_cb, NULL);
2376 if (ret == MEDIA_CONTENT_ERROR_NONE)
2377 content_debug("media_info_foreach_media_from_db is success");
2379 content_error("media_info_foreach_media_from_db is failed");
2384 int test_start_face_detection(int cancel)
2386 int ret = MEDIA_CONTENT_ERROR_NONE;
2387 GSource *source = NULL;
2388 GMainContext *context = NULL;
2390 test_filter_create();
2392 ret = media_info_get_media_count_from_db(g_filter, &g_media_cnt);
2393 if (ret != MEDIA_CONTENT_ERROR_NONE)
2394 content_error("media_info_get_media_count_from_db failed: %d", ret);
2396 content_debug("media_count : [%d]", g_media_cnt);
2398 if (g_media_cnt == 0)
2401 g_loop = g_main_loop_new(NULL, FALSE);
2402 context = g_main_loop_get_context(g_loop);
2403 source = g_idle_source_new();
2404 g_source_set_callback(source, face_detection_start, NULL, NULL);
2405 g_source_attach(source, context);
2407 /* Logic to cancel */
2409 GSource *cancel_src = NULL;
2410 cancel_src = g_idle_source_new();
2411 g_source_set_callback(cancel_src, face_detection_cancel, NULL, NULL);
2412 g_source_attach(cancel_src, context);
2415 g_main_loop_run(g_loop);
2416 g_main_loop_unref(g_loop);
2419 test_filter_destroy();
2424 int test_ebook_text_finder(const char *keyword)
2426 int ret = MEDIA_CONTENT_ERROR_NONE;
2427 char **book_path_list = NULL;
2428 unsigned int book_path_len = 0;
2430 media_info_h media = NULL;
2431 book_meta_h book = NULL;
2432 char *s_value = NULL;
2433 long long ms_time = 0;
2434 struct timeval start_time;
2435 struct timeval end_time;
2437 gettimeofday(&start_time, NULL);
2439 ret = book_meta_get_path_with_keyword(keyword, &book_path_list, &book_path_len);
2440 if (ret == MEDIA_CONTENT_ERROR_NONE)
2441 content_debug("book_meta_get_path_with_keyword is success");
2443 content_error("book_meta_get_path_with_keyword is failed");
2445 gettimeofday(&end_time, NULL);
2447 for (i = 0; i < book_path_len; i++) {
2448 ret = media_info_get_media_from_db_by_path(book_path_list[i], &media);
2449 if (ret != MEDIA_CONTENT_ERROR_NONE)
2452 content_debug("===============================");
2453 content_debug("[%d] %s", i, book_path_list[i]);
2454 content_debug("===============================");
2455 media_info_get_title(media, &s_value);
2456 content_debug("Title : %s", s_value);
2460 ret = media_info_get_book(media, &book);
2461 if (ret != MEDIA_CONTENT_ERROR_NONE) {
2462 media_info_destroy(media);
2466 ret = book_meta_get_author(book, &s_value);
2467 if (ret == MEDIA_CONTENT_ERROR_NONE && s_value) {
2468 content_debug("Author : %s", s_value);
2473 ret = book_meta_get_date(book, &s_value);
2474 if (ret == MEDIA_CONTENT_ERROR_NONE && s_value) {
2475 content_debug("Date : %s", s_value);
2480 content_debug("===============================");
2481 ret = book_meta_destroy(book);
2482 if (ret != MEDIA_CONTENT_ERROR_NONE)
2483 content_error("book_meta_destroy failed");
2485 ret = media_info_destroy(media);
2486 if (ret != MEDIA_CONTENT_ERROR_NONE)
2487 content_error("media_info_destroy failed");
2489 g_free(book_path_list[i]);
2492 ms_time = (end_time.tv_sec * 1000LL + end_time.tv_usec / 1000) - (start_time.tv_sec * 1000LL + start_time.tv_usec/ 1000);
2493 content_debug("Search Time [%lld]", ms_time);
2495 g_free(book_path_list);
2499 int test_disconnect_database(void)
2501 int ret = MEDIA_CONTENT_ERROR_NONE;
2502 content_debug("\n============DB Disconnection Test============\n\n");
2504 ret = media_content_disconnect();
2506 if (ret == MEDIA_CONTENT_ERROR_NONE)
2507 content_debug("disconnection is success");
2509 content_error("disconnection is failed");
2514 int test_request_update_db(void)
2516 int ret = MEDIA_CONTENT_ERROR_NONE;
2517 media_info_h media = NULL;
2518 bool favorite = FALSE;
2520 ret = media_info_get_media_from_db("71b19196-5b38-4ab1-ab34-bfe05c369614", &media);
2521 if (ret != MEDIA_CONTENT_ERROR_NONE)
2522 content_error("media_info_get_media_from_db failed: %d", ret);
2524 ret = media_info_set_favorite(media, TRUE);
2525 if (ret != MEDIA_CONTENT_ERROR_NONE)
2526 content_error("media_info_set_favorite failed: %d", ret);
2528 ret = media_info_update_to_db(media);
2529 if (ret == MEDIA_CONTENT_ERROR_NONE)
2530 content_debug("media_info_update_to_db is success");
2532 content_error("media_info_update_to_db is failed");
2535 media_info_destroy(media);
2537 /*get the updated value*/
2538 ret = media_info_get_media_from_db("71b19196-5b38-4ab1-ab34-bfe05c369614", &media);
2539 if (ret != MEDIA_CONTENT_ERROR_NONE)
2540 content_error("media_info_get_media_from_db failed: %d", ret);
2542 ret = media_info_get_favorite(media, &favorite);
2543 if (ret != MEDIA_CONTENT_ERROR_NONE)
2544 content_error("media_info_get_favorite failed: %d", ret);
2546 content_debug("favorite [%d]", favorite);
2548 ret = media_info_destroy(media);
2553 int g_total_photo_size = 0;
2554 int g_total_video_size = 0;
2555 int g_total_mp3_size = 0;
2556 int g_total_voice_memo_size = 0;
2558 bool dft_cb(media_info_h media, void *user_data)
2560 unsigned long long file_size = 0;
2561 media_content_type_e media_type = -1;
2562 char *mime_type = NULL;
2563 int ret = MEDIA_CONTENT_ERROR_NONE;
2568 ret = media_info_get_media_type(media, &media_type);
2569 if (ret != MEDIA_CONTENT_ERROR_NONE)
2570 content_error("media_info_get_media_type failed: %d", ret);
2571 ret = media_info_get_size(media, &file_size);
2572 if (ret != MEDIA_CONTENT_ERROR_NONE)
2573 content_error("media_info_get_size failed: %d", ret);
2574 ret = media_info_get_mime_type(media, &mime_type);
2575 if (ret != MEDIA_CONTENT_ERROR_NONE)
2576 content_error("media_info_get_mime_type failed: %d", ret);
2578 if (media_type == MEDIA_CONTENT_TYPE_IMAGE)
2579 g_total_photo_size += file_size;
2580 else if (media_type == MEDIA_CONTENT_TYPE_VIDEO)
2581 g_total_video_size += file_size;
2582 else if (media_type == MEDIA_CONTENT_TYPE_SOUND)
2583 g_total_voice_memo_size += file_size;
2584 else if (media_type == MEDIA_CONTENT_TYPE_MUSIC) {
2585 if ((mime_type != NULL) && (!strcmp("audio/mpeg", mime_type)))
2586 g_total_mp3_size += file_size;
2588 g_total_voice_memo_size += file_size;
2590 content_debug("invalid media_type");
2592 SAFE_FREE(mime_type);
2600 int ret = MEDIA_CONTENT_ERROR_NONE;
2601 content_debug("\n============DFT_test============\n\n");
2603 filter_h filter = NULL;
2606 /*MEDIA_TYPE 0-image, 1-video, 2-sound, 3-music, 4-other*/
2608 ret = media_filter_create(&filter);
2611 content_debug("[Internal Memory]\n");
2612 /*1. Photo ============================================================*/
2613 ret = media_filter_set_condition(filter, "MEDIA_STORAGE_TYPE=0 AND MEDIA_TYPE=0", MEDIA_CONTENT_COLLATE_DEFAULT);
2616 ret = media_info_get_media_count_from_db(filter, &media_cnt);
2617 content_debug("Photo count = [%d]\n", media_cnt);
2620 ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
2621 content_debug("Photo size = [%d]\n", g_total_photo_size);
2623 /*2. Video ============================================================*/
2624 ret = media_filter_set_condition(filter, "MEDIA_STORAGE_TYPE=0 AND MEDIA_TYPE=1", MEDIA_CONTENT_COLLATE_DEFAULT);
2627 ret = media_info_get_media_count_from_db(filter, &media_cnt);
2628 content_debug("Video count = [%d]\n", media_cnt);
2631 ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
2632 content_debug("Video size = [%d]\n", g_total_video_size);
2634 /*3. MP3 ============================================================*/
2635 ret = media_filter_set_condition(filter, "MEDIA_STORAGE_TYPE=0 AND MEDIA_TYPE=3 AND MEDIA_MIME_TYPE=\"audio/mpeg\"", MEDIA_CONTENT_COLLATE_DEFAULT);
2638 ret = media_info_get_media_count_from_db(filter, &media_cnt);
2639 content_debug("MP3 count = [%d]\n", media_cnt);
2642 ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
2643 content_debug("MP3 size = [%d]\n", g_total_mp3_size);
2645 /*4. Voice Memo ============================================================*/
2646 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);
2648 /*Get Voice Memo Count*/
2649 ret = media_info_get_media_count_from_db(filter, &media_cnt);
2650 content_debug("Voice Memo count = [%d]\n", media_cnt);
2652 /*Get Voice Memo Size*/
2653 ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
2654 content_debug("Voice Memo size = [%d]\n", g_total_voice_memo_size);
2656 g_total_photo_size = 0;
2657 g_total_video_size = 0;
2658 g_total_mp3_size = 0;
2659 g_total_voice_memo_size = 0;
2662 content_debug("\n[External Memory]\n");
2663 /*1. Photo ============================================================*/
2664 ret = media_filter_set_condition(filter, "MEDIA_STORAGE_TYPE=1 AND MEDIA_TYPE=0", MEDIA_CONTENT_COLLATE_DEFAULT);
2667 ret = media_info_get_media_count_from_db(filter, &media_cnt);
2668 content_debug("Photo count = [%d]\n", media_cnt);
2671 ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
2672 content_debug("Photo size = [%d]\n", g_total_photo_size);
2674 /*2. Video ============================================================*/
2675 ret = media_filter_set_condition(filter, "MEDIA_STORAGE_TYPE=1 AND MEDIA_TYPE=1", MEDIA_CONTENT_COLLATE_DEFAULT);
2678 ret = media_info_get_media_count_from_db(filter, &media_cnt);
2679 content_debug("Video count = [%d]\n", media_cnt);
2682 ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
2683 content_debug("Video size = [%d]\n", g_total_video_size);
2685 /*3. MP3 ============================================================*/
2686 ret = media_filter_set_condition(filter, "MEDIA_STORAGE_TYPE=1 AND MEDIA_TYPE=3 AND MEDIA_MIME_TYPE=\"audio/mpeg\"", MEDIA_CONTENT_COLLATE_DEFAULT);
2689 ret = media_info_get_media_count_from_db(filter, &media_cnt);
2690 content_debug("MP3 count = [%d]\n", media_cnt);
2693 ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
2694 content_debug("MP3 size = [%d]\n", g_total_mp3_size);
2696 /*4. Voice Memo ============================================================*/
2697 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);
2699 /*Get Voice Memo Count*/
2700 ret = media_info_get_media_count_from_db(filter, &media_cnt);
2701 content_debug("Voice Memo count = [%d]\n", media_cnt);
2703 /*Get Voice Memo Size*/
2704 ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
2705 content_debug("Voice Memo size = [%d]\n", g_total_voice_memo_size);
2706 ret = media_filter_destroy(filter);
2711 void insert_batch_cb(media_content_error_e error, void * user_data)
2713 content_debug("media_info_insert_batch_to_db completed!\n");
2716 int test_batch_operations()
2720 char *file_list[10];
2722 for (i = 0; i < 10; i++) {
2723 file_list[i] = g_strdup_printf("%s%d.jpg", tzplatform_mkpath(TZ_USER_CONTENT, "test/image"), i+1);
2724 content_debug("File : %s\n", file_list[i]);
2727 ret = media_info_insert_batch_to_db((const char **)file_list, 10, insert_batch_cb, NULL);
2728 if (ret != MEDIA_CONTENT_ERROR_NONE)
2729 content_error("media_info_insert_batch_to_db failed : %d\n", ret);
2731 for (i = 0; i < 10; i++)
2732 g_free(file_list[i]);
2737 void _scan_cb(media_content_error_e err, void *user_data)
2739 content_debug("scan callback is called : %d\n", err);
2740 g_main_loop_quit(g_loop);
2745 int test_scan_file()
2749 const char *file_path = tzplatform_mkpath(TZ_USER_CONTENT, "test/image1.jpg");
2750 ret = media_content_scan_file(file_path);
2751 if (ret != MEDIA_CONTENT_ERROR_NONE) {
2752 content_error("Fail to media_content_scan_file : %d", ret);
2759 gboolean test_scan_dir_start(gpointer data)
2763 const char *dir_path = tzplatform_getenv(TZ_USER_CONTENT);
2765 ret = media_content_scan_folder(dir_path, TRUE, _scan_cb, NULL);
2767 if (ret != MEDIA_CONTENT_ERROR_NONE) {
2768 content_error("Fail to test_scan_dir_start : %d", ret);
2775 gboolean cancel_scan_dir_start(gpointer data)
2777 int ret = MEDIA_CONTENT_ERROR_NONE;
2779 const char *dir_path = tzplatform_getenv(TZ_USER_IMAGES);
2781 ret = media_content_cancel_scan_folder(dir_path);
2783 if (ret == MEDIA_CONTENT_ERROR_NONE)
2784 content_debug("media_content_cancel_scan_folder is success");
2786 content_error("media_content_cancel_scan_folder is failed");
2791 int test_scan_dir(int cancel)
2793 GSource *source = NULL;
2794 GMainContext *context = NULL;
2796 g_loop = g_main_loop_new(NULL, FALSE);
2797 context = g_main_loop_get_context(g_loop);
2798 source = g_idle_source_new();
2799 g_source_set_callback(source, test_scan_dir_start, NULL, NULL);
2800 g_source_attach(source, context);
2803 GSource *cancel_src = NULL;
2804 cancel_src = g_idle_source_new();
2805 g_source_set_callback(cancel_src, cancel_scan_dir_start, NULL, NULL);
2806 g_source_attach(cancel_src, context);
2809 g_main_loop_run(g_loop);
2810 g_main_loop_unref(g_loop);
2815 void _noti_cb(media_content_error_e error,
2817 media_content_db_update_item_type_e update_item,
2818 media_content_db_update_type_e update_type,
2819 media_content_type_e media_type,
2826 content_debug("noti success! : %d\n", error);
2828 content_debug("error occurred! : %d\n", error);
2830 content_debug("Noti from PID(%d)\n", pid);
2832 if (update_item == MEDIA_ITEM_FILE)
2833 content_debug("Noti item : MEDIA_ITEM_FILE\n");
2834 else if (update_item == MEDIA_ITEM_DIRECTORY)
2835 content_debug("Noti item : MEDIA_ITEM_DIRECTORY\n");
2837 if (update_type == MEDIA_CONTENT_INSERT)
2838 content_debug("Noti type : MEDIA_CONTENT_INSERT\n");
2839 else if (update_type == MEDIA_CONTENT_DELETE)
2840 content_debug("Noti type : MEDIA_CONTENT_DELETE\n");
2841 else if (update_type == MEDIA_CONTENT_UPDATE)
2842 content_debug("Noti type : MEDIA_CONTENT_UPDATE\n");
2844 content_debug("content type : %d\n", media_type);
2847 content_debug("path : %s\n", path);
2849 content_debug("path not\n");
2852 content_debug("uuid : %s\n", uuid);
2854 content_debug("uuid not\n");
2857 content_debug("mime_type : %s\n", mime_type);
2859 content_debug("mime not\n");
2861 if (user_data) content_debug("String : %s\n", (char *)user_data);
2866 void _noti_cb_2(media_content_error_e error,
2868 media_content_db_update_item_type_e update_item,
2869 media_content_db_update_type_e update_type,
2870 media_content_type_e media_type,
2877 content_debug("noti_2 success! : %d\n", error);
2879 content_debug("error occurred! : %d\n", error);
2881 content_debug("Noti_2 from PID(%d)\n", pid);
2883 g_main_loop_quit(g_loop);
2887 static media_content_noti_h noti_h;
2888 static media_content_noti_h noti_h_2;
2890 gboolean _send_noti_operations(gpointer data)
2892 int ret = MEDIA_CONTENT_ERROR_NONE;
2894 /* First of all, noti subscription */
2895 char *user_str = strdup("hi");
2896 media_content_add_db_updated_cb(_noti_cb, (void*)user_str, ¬i_h);
2897 media_content_add_db_updated_cb(_noti_cb_2, (void*)user_str, ¬i_h_2);
2899 /* media_info_insert_to_db */
2900 media_info_h media_item = NULL;
2901 const char *path = tzplatform_mkpath(TZ_USER_CONTENT, "test/image1.jpg");
2903 ret = media_info_insert_to_db(path, &media_item);
2904 if (ret != MEDIA_CONTENT_ERROR_NONE) {
2905 content_error("media_info_insert_to_db failed : %d", ret);
2906 media_info_destroy(media_item);
2910 content_debug("media_info_insert_to_db success");
2912 media_content_remove_db_updated_cb(noti_h);
2914 /* media_info_update_to_db */
2915 ret = media_info_update_to_db(media_item);
2916 if (ret != MEDIA_CONTENT_ERROR_NONE) {
2917 content_error("media_info_update_to_db failed : %d\n", ret);
2918 media_info_destroy(media_item);
2922 media_info_destroy(media_item);
2929 int ret = MEDIA_CONTENT_ERROR_NONE;
2930 GSource *source = NULL;
2931 GMainContext *context = NULL;
2933 g_loop = g_main_loop_new(NULL, FALSE);
2934 context = g_main_loop_get_context(g_loop);
2935 source = g_idle_source_new();
2936 g_source_set_callback(source, _send_noti_operations, NULL, NULL);
2937 g_source_attach(source, context);
2939 g_main_loop_run(g_loop);
2940 g_main_loop_unref(g_loop);
2942 test_filter_destroy();
2943 media_content_remove_db_updated_cb(noti_h_2);
2948 bool media_face_test_cb(media_face_h face, void *user_data)
2950 get_face_meta(face);
2952 if (user_data != NULL) {
2953 media_face_h new_face = NULL;
2954 media_face_clone(&new_face, face);
2956 GList **list = (GList**)user_data;
2957 *list = g_list_append(*list, new_face);
2965 int ret = MEDIA_CONTENT_ERROR_NONE;
2966 filter_h filter = NULL;
2967 GList *all_item_list = NULL;
2970 ret = media_filter_create(&filter);
2971 content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "fail media_filter_create");
2973 ret = media_filter_set_condition(filter, "MEDIA_TYPE = 0", MEDIA_CONTENT_COLLATE_DEFAULT);
2974 if (ret != MEDIA_CONTENT_ERROR_NONE) {
2975 media_filter_destroy(filter);
2976 content_error("Fail to set condition");
2980 ret = media_info_foreach_media_from_db(filter, gallery_media_item_cb, &all_item_list);
2981 if (ret != MEDIA_CONTENT_ERROR_NONE) {
2982 content_error("media_info_foreach_media_from_db failed: %d", ret);
2983 media_filter_destroy(filter);
2987 for (i = 0; i < g_list_length(all_item_list); i++) {
2988 media_info_h media_handle = NULL;
2989 char *media_id = NULL;
2992 media_handle = (media_info_h)g_list_nth_data(all_item_list, i);
2994 ret = media_info_get_media_id(media_handle, &media_id);
2995 if (ret != MEDIA_CONTENT_ERROR_NONE)
2996 content_error("media_info_get_media_id failed: %d", ret);
2998 ret = media_info_get_face_count_from_db(media_id, filter, &face_count);
2999 if (ret != MEDIA_CONTENT_ERROR_NONE)
3000 content_error("media_info_get_face_count_from_db failed: %d", ret);
3002 content_error("media_id [%s] face_count [%d]", media_id, face_count);
3004 ret = media_info_foreach_face_from_db(media_id, filter, media_face_test_cb, NULL);
3005 if (ret != MEDIA_CONTENT_ERROR_NONE)
3006 content_error("media_info_foreach_face_from_db failed: %d", ret);
3008 media_info_destroy(media_handle);
3011 media_filter_destroy(filter);
3016 int test_face_add_del(void)
3018 int ret = MEDIA_CONTENT_ERROR_NONE;
3019 char *media_id = "ecca7366-e085-41d8-a12b-cbdfc2b9c5fc";
3022 media_face_h face = NULL;
3024 char *face_tag = "test_face_tag";
3026 ret = media_face_create(media_id, &face);
3027 content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "fail media_face_create");
3029 ret = media_face_set_face_rect(face, 10, 12, 50, 100);
3030 if (ret != MEDIA_CONTENT_ERROR_NONE)
3031 content_error("media_face_set_face_rect failed: %d", ret);
3033 ret = media_face_set_orientation(face, 5);
3034 if (ret != MEDIA_CONTENT_ERROR_NONE)
3035 content_error("media_face_set_orientation failed: %d", ret);
3037 ret = media_face_set_tag(face, face_tag);
3038 if (ret != MEDIA_CONTENT_ERROR_NONE)
3039 content_error("media_face_set_tag failed: %d", ret);
3041 ret = media_face_insert_to_db(face);
3042 if (ret != MEDIA_CONTENT_ERROR_NONE)
3043 content_error("media_face_insert_to_db failed: %d", ret);
3045 ret = media_face_destroy(face);
3046 if (ret != MEDIA_CONTENT_ERROR_NONE)
3047 content_error("media_face_destroy failed: %d", ret);
3050 GList *all_item_list = NULL;
3051 filter_h filter = NULL;
3052 ret = media_filter_create(&filter);
3053 content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "fail media_filter_create");
3055 ret = media_filter_set_condition(filter, "MEDIA_FACE_TAG IS NOT NULL", MEDIA_CONTENT_COLLATE_DEFAULT);
3056 if (ret != MEDIA_CONTENT_ERROR_NONE) {
3057 media_filter_destroy(filter);
3058 content_error("Fail to set condition");
3062 ret = media_info_foreach_face_from_db(media_id, filter, media_face_test_cb, &all_item_list);
3064 if (g_list_length(all_item_list) > 0) {
3065 media_face_h face_handle = NULL;
3066 face_handle = (media_face_h)g_list_nth_data(all_item_list, 0);
3068 ret = media_face_set_face_rect(face_handle, 20, 22, 70, 70);
3069 if (ret != MEDIA_CONTENT_ERROR_NONE)
3070 content_error("media_face_set_face_rect failed: %d", ret);
3071 ret = media_face_set_orientation(face_handle, 3);
3072 if (ret != MEDIA_CONTENT_ERROR_NONE)
3073 content_error("media_face_set_orientation failed: %d", ret);
3074 ret = media_face_set_tag(face_handle, NULL);
3075 if (ret != MEDIA_CONTENT_ERROR_NONE)
3076 content_error("media_face_set_tag failed: %d", ret);
3077 ret = media_face_update_to_db(face_handle);
3078 if (ret != MEDIA_CONTENT_ERROR_NONE)
3079 content_error("media_face_update_to_db failed: %d", ret);
3081 media_face_destroy(face_handle);
3084 media_filter_destroy(filter);
3087 char *face_id = "5e58a3a8-f0b2-4c29-b799-b49a70dc2313";
3090 ret = media_face_delete_from_db(face_id);
3095 #ifdef _USE_TVPD_MODE
3096 filter_h g_tv_filter = NULL;
3098 int test_tv_filter_create(void)
3100 content_debug("\n============Filter Create============\n\n");
3102 int ret = MEDIA_CONTENT_ERROR_NONE;
3104 ret = media_filter_create(&g_tv_filter);
3106 ret = media_filter_set_storage(g_tv_filter, "0a22a163-e634-4a2e-ba14-0469a969eea0");
3108 ret = media_filter_set_order(g_tv_filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_STORAGE_ID, MEDIA_CONTENT_COLLATE_DEFAULT);
3113 int test_tv_filter_destroy(void)
3115 content_debug("\n============Filter Destroy============\n\n");
3117 int ret = MEDIA_CONTENT_ERROR_NONE;
3119 ret = media_filter_destroy(g_tv_filter);
3124 bool pvr_item_cb(media_pvr_h pvr, void *user_data)
3126 int ret = MEDIA_CONTENT_ERROR_NONE;
3127 char *c_value = NULL;
3129 bool b_value = false;
3130 unsigned long long l_value = 0;
3133 content_debug("NO Item");
3137 ret = media_pvr_get_media_id(pvr, &c_value);
3138 if (ret != MEDIA_CONTENT_ERROR_NONE)
3139 content_error("Fail to media_pvr_get_media_id");
3140 content_debug("media_id [%s]", c_value);
3143 ret = media_pvr_get_channel_name(pvr, &c_value);
3144 if (ret != MEDIA_CONTENT_ERROR_NONE)
3145 content_error("Fail to media_pvr_get_channel_name");
3146 content_debug("channel_name [%s]", c_value);
3149 ret = media_pvr_get_program_title(pvr, &c_value);
3150 if (ret != MEDIA_CONTENT_ERROR_NONE)
3151 content_error("Fail to media_pvr_get_program_title");
3152 content_debug("program_title [%s]", c_value);
3155 ret = media_pvr_get_program_crid(pvr, &c_value);
3156 if (ret != MEDIA_CONTENT_ERROR_NONE)
3157 content_error("Fail to media_pvr_get_program_crid");
3158 content_debug("program_crid [%s]", c_value);
3161 ret = media_pvr_get_guidance(pvr, &c_value);
3162 if (ret != MEDIA_CONTENT_ERROR_NONE)
3163 content_error("Fail to media_pvr_get_guidance");
3164 content_debug("guidance [%s]", c_value);
3167 ret = media_pvr_get_synopsis(pvr, &c_value);
3168 if (ret != MEDIA_CONTENT_ERROR_NONE)
3169 content_error("Fail to media_pvr_get_synopsis");
3170 content_debug("synopsis [%s]", c_value);
3173 ret = media_pvr_get_genre(pvr, &c_value);
3174 if (ret != MEDIA_CONTENT_ERROR_NONE)
3175 content_error("Fail to media_pvr_get_synopsis");
3176 content_debug("genre [%s]", c_value);
3179 ret = media_pvr_get_language(pvr, &c_value);
3180 if (ret != MEDIA_CONTENT_ERROR_NONE)
3181 content_error("Fail to media_pvr_get_language");
3182 content_debug("language [%s]", c_value);
3185 ret = media_pvr_get_path(pvr, &c_value);
3186 if (ret != MEDIA_CONTENT_ERROR_NONE)
3187 content_error("Fail to media_pvr_get_path");
3188 content_debug("path [%s]", c_value);
3191 ret = media_pvr_get_storage_id(pvr, &c_value);
3192 if (ret != MEDIA_CONTENT_ERROR_NONE)
3193 content_error("Fail to media_pvr_get_storage_id");
3194 content_debug("storage_id [%s]", c_value);
3197 ret = media_pvr_get_size(pvr, &l_value);
3198 if (ret != MEDIA_CONTENT_ERROR_NONE)
3199 content_error("Fail to media_pvr_get_size");
3200 content_debug("size [%lld]", l_value);
3202 ret = media_pvr_get_timezone(pvr, &i_value);
3203 if (ret != MEDIA_CONTENT_ERROR_NONE)
3204 content_error("Fail to media_pvr_get_timezone");
3205 content_debug("timezone [%d]", i_value);
3207 ret = media_pvr_get_ptc(pvr, &i_value);
3208 if (ret != MEDIA_CONTENT_ERROR_NONE)
3209 content_error("Fail to media_pvr_get_ptc");
3210 content_debug("ptc [%d]", i_value);
3212 ret = media_pvr_get_major(pvr, &i_value);
3213 if (ret != MEDIA_CONTENT_ERROR_NONE)
3214 content_error("Fail to media_pvr_get_major");
3215 content_debug("[%d]", i_value);
3217 ret = media_pvr_get_minor(pvr, &i_value);
3218 if (ret != MEDIA_CONTENT_ERROR_NONE)
3219 content_error("Fail to media_pvr_get_minor");
3220 content_debug("minor [%d]", i_value);
3222 ret = media_pvr_get_channel_type(pvr, &i_value);
3223 if (ret != MEDIA_CONTENT_ERROR_NONE)
3224 content_error("Fail to media_pvr_get_channel_type");
3225 content_debug("channel_type [%d]", i_value);
3227 ret = media_pvr_get_program_num(pvr, &i_value);
3228 if (ret != MEDIA_CONTENT_ERROR_NONE)
3229 content_error("Fail to media_pvr_get_program_num");
3230 content_debug("program_num [%d]", i_value);
3232 unsigned int ui_value = 0;
3233 ret = media_pvr_get_service_profile(pvr, &ui_value);
3234 if (ret != MEDIA_CONTENT_ERROR_NONE)
3235 content_error("Fail to media_pvr_get_service_profile");
3236 content_debug("service_profile [%u]", ui_value);
3238 ret = media_pvr_get_duration(pvr, &i_value);
3239 if (ret != MEDIA_CONTENT_ERROR_NONE)
3240 content_error("Fail to media_pvr_get_duration");
3241 content_debug("duration [%d]", i_value);
3243 ret = media_pvr_get_embargo_time(pvr, &i_value);
3244 if (ret != MEDIA_CONTENT_ERROR_NONE)
3245 content_error("Fail to media_pvr_get_embargo_time");
3246 content_debug("embargo_time [%d]", i_value);
3248 ret = media_pvr_get_expiry_time(pvr, &i_value);
3249 if (ret != MEDIA_CONTENT_ERROR_NONE)
3250 content_error("Fail to media_pvr_get_expiry_time");
3251 content_debug("expiry_time [%d]", i_value);
3253 ret = media_pvr_get_parental_rating(pvr, &i_value);
3254 if (ret != MEDIA_CONTENT_ERROR_NONE)
3255 content_error("Fail to media_pvr_get_parental_rating");
3256 content_debug("parental_rating [%d]", i_value);
3258 ret = media_pvr_get_start_time(pvr, &i_value);
3259 if (ret != MEDIA_CONTENT_ERROR_NONE)
3260 content_error("Fail to media_pvr_get_start_time");
3261 content_debug("start_time [%d]", i_value);
3263 ret = media_pvr_get_program_start_time(pvr, &i_value);
3264 if (ret != MEDIA_CONTENT_ERROR_NONE)
3265 content_error("Fail to media_pvr_get_program_start_time");
3266 content_debug("program_start_time [%d]", i_value);
3268 ret = media_pvr_get_program_end_time(pvr, &i_value);
3269 if (ret != MEDIA_CONTENT_ERROR_NONE)
3270 content_error("Fail to media_pvr_get_program_end_time");
3271 content_debug("program_end_time [%d]", i_value);
3273 ret = media_pvr_get_program_date(pvr, &i_value);
3274 if (ret != MEDIA_CONTENT_ERROR_NONE)
3275 content_error("Fail to media_pvr_get_program_date");
3276 content_debug("program_date [%d]", i_value);
3278 ret = media_pvr_get_timer_record(pvr, &b_value);
3279 if (ret != MEDIA_CONTENT_ERROR_NONE)
3280 content_error("Fail to media_pvr_get_timer_record");
3281 content_debug("timer_record [%d]", b_value);
3283 ret = media_pvr_get_series_record(pvr, &b_value);
3284 if (ret != MEDIA_CONTENT_ERROR_NONE)
3285 content_error("Fail to media_pvr_get_series_record");
3286 content_debug("series_record [%d]", b_value);
3288 ret = media_pvr_get_hd(pvr, &i_value);
3289 if (ret != MEDIA_CONTENT_ERROR_NONE)
3290 content_error("Fail to media_pvr_get_hd");
3291 content_debug("hd [%d]", i_value);
3293 ret = media_pvr_get_subtitle(pvr, &b_value);
3294 if (ret != MEDIA_CONTENT_ERROR_NONE)
3295 content_error("Fail to media_pvr_get_subtitle");
3296 content_debug("subtitle [%d]", b_value);
3298 ret = media_pvr_get_ttx(pvr, &b_value);
3299 if (ret != MEDIA_CONTENT_ERROR_NONE)
3300 content_error("Fail to media_pvr_get_ttx");
3301 content_debug("ttx [%d]", b_value);
3303 ret = media_pvr_get_ad(pvr, &b_value);
3304 if (ret != MEDIA_CONTENT_ERROR_NONE)
3305 content_error("Fail to media_pvr_get_ad");
3306 content_debug("ad [%d]", b_value);
3308 ret = media_pvr_get_hard_of_hearing_radio(pvr, &b_value);
3309 if (ret != MEDIA_CONTENT_ERROR_NONE)
3310 content_error("Fail to media_pvr_get_hard_of_hearing_radio");
3311 content_debug("hard_of_hearing_radio [%d]", b_value);
3313 ret = media_pvr_get_data_service(pvr, &b_value);
3314 if (ret != MEDIA_CONTENT_ERROR_NONE)
3315 content_error("Fail to media_pvr_get_data_service");
3316 content_debug("data_service [%d]", b_value);
3318 ret = media_pvr_get_content_lock(pvr, &b_value);
3319 if (ret != MEDIA_CONTENT_ERROR_NONE)
3320 content_error("Fail to media_pvr_get_content_lock");
3321 content_debug("content_lock [%d]", b_value);
3323 ret = media_pvr_get_content_watch(pvr, &b_value);
3324 if (ret != MEDIA_CONTENT_ERROR_NONE)
3325 content_error("Fail to media_pvr_get_content_watch");
3326 content_debug("content_watch [%d]", b_value);
3328 ret = media_pvr_get_has_audio_only(pvr, &b_value);
3329 if (ret != MEDIA_CONTENT_ERROR_NONE)
3330 content_error("Fail to media_pvr_get_has_audio_only");
3331 content_debug("has_audio_only [%d]", b_value);
3333 ret = media_pvr_get_is_local_record(pvr, &b_value);
3334 if (ret != MEDIA_CONTENT_ERROR_NONE)
3335 content_error("Fail to media_pvr_get_is_local_record");
3336 content_debug("is_local_record [%d]", b_value);
3338 ret = media_pvr_get_resolution(pvr, (media_pvr_resolution_e*)&i_value);
3339 if (ret != MEDIA_CONTENT_ERROR_NONE)
3340 content_error("Fail to media_pvr_get_resolution");
3341 content_debug("resolution [%d]", i_value);
3343 ret = media_pvr_get_aspectratio(pvr, (media_pvr_aspectratio_e*)&i_value);
3344 if (ret != MEDIA_CONTENT_ERROR_NONE)
3345 content_error("Fail to media_pvr_get_aspectratio");
3346 content_debug("aspectratio [%d]", i_value);
3348 ret = media_pvr_get_highlight(pvr, &b_value);
3349 if (ret != MEDIA_CONTENT_ERROR_NONE)
3350 content_error("Fail to media_pvr_get_highlight");
3351 content_debug("highlight [%d]", b_value);
3359 int ret = MEDIA_CONTENT_ERROR_NONE;
3360 int media_count = 0;
3362 content_debug("\n============PVR Test============\n\n");
3364 test_tv_filter_create();
3366 ret = media_pvr_get_media_count_from_db(g_tv_filter, &media_count);
3367 if (ret != MEDIA_CONTENT_ERROR_NONE)
3368 content_error("media_pvr_get_media_count_from_db failed: %d", ret);
3370 content_debug("media_count : [%d]", media_count);
3372 ret = media_pvr_foreach_media_from_db(g_tv_filter, pvr_item_cb, NULL);
3373 if (ret != MEDIA_CONTENT_ERROR_NONE)
3374 content_error("media_pvr_foreach_media_from_db is failed");
3376 test_tv_filter_destroy();
3381 int test_pvr_update_db(void)
3383 int ret = MEDIA_CONTENT_ERROR_NONE;
3384 media_pvr_h pvr = NULL;
3386 ret = media_pvr_get_pvr_from_db("ff9b5a9a-a7b4-47f4-8255-84e007e25f13", &pvr);
3387 if (ret != MEDIA_CONTENT_ERROR_NONE)
3388 content_error("media_pvr_get_pvr_from_db failed: %d", ret);
3390 ret = media_pvr_set_content_lock(pvr, TRUE);
3391 if (ret != MEDIA_CONTENT_ERROR_NONE)
3392 content_error("Fail to media_pvr_set_content_lock");
3394 ret = media_pvr_set_content_watch(pvr, TRUE);
3395 if (ret != MEDIA_CONTENT_ERROR_NONE)
3396 content_error("Fail to media_pvr_set_content_watch");
3398 ret = media_pvr_set_program_title(pvr, "TEST TITLE");
3399 if (ret != MEDIA_CONTENT_ERROR_NONE)
3400 content_error("Fail to media_pvr_set_program_title");
3402 ret = media_pvr_set_highlight(pvr, TRUE);
3403 if (ret != MEDIA_CONTENT_ERROR_NONE)
3404 content_error("Fail to media_pvr_set_highlight");
3406 ret = media_pvr_update_to_db(pvr);
3407 if (ret != MEDIA_CONTENT_ERROR_NONE)
3408 content_error("Fail to media_pvr_update_to_db");
3411 media_pvr_destroy(pvr);
3417 int main(int argc, char *argv[])
3419 int ret = MEDIA_CONTENT_ERROR_NONE;
3421 content_debug("--- content manager test start ---\n\n");
3423 ret = test_connect_database();
3424 if (ret != MEDIA_CONTENT_ERROR_NONE)
3425 return MEDIA_CONTENT_ERROR_NONE;
3426 #ifdef _USE_TVPD_MODE
3429 test_pvr_update_db();
3436 ret = test_ebook_text_finder(argv[1]);
3437 if (ret != MEDIA_CONTENT_ERROR_NONE)
3441 ret = test_start_face_detection(FALSE);
3442 if (ret != MEDIA_CONTENT_ERROR_NONE)
3446 if (ret != MEDIA_CONTENT_ERROR_NONE)
3449 ret = test_gallery_scenario();
3450 if (ret != MEDIA_CONTENT_ERROR_NONE)
3453 ret = test_get_all_music_files();
3454 if (ret != MEDIA_CONTENT_ERROR_NONE)
3457 ret = test_media_info_operation();
3458 if (ret != MEDIA_CONTENT_ERROR_NONE)
3461 ret = test_folder_operation();
3462 if (ret != MEDIA_CONTENT_ERROR_NONE)
3465 ret = test_playlist_operation();
3466 if (ret != MEDIA_CONTENT_ERROR_NONE)
3469 ret = test_tag_operation();
3470 if (ret != MEDIA_CONTENT_ERROR_NONE)
3473 ret = test_bookmark_operation();
3474 if (ret != MEDIA_CONTENT_ERROR_NONE)
3477 ret = test_album_list();
3478 if (ret != MEDIA_CONTENT_ERROR_NONE)
3481 ret = test_group_operation();
3482 if (ret != MEDIA_CONTENT_ERROR_NONE)
3485 ret = test_update_operation();
3486 if (ret != MEDIA_CONTENT_ERROR_NONE)
3489 ret = test_insert();
3490 if (ret != MEDIA_CONTENT_ERROR_NONE)
3494 if (ret != MEDIA_CONTENT_ERROR_NONE)
3497 ret = test_create_thumbnail(TRUE);
3498 if (ret != MEDIA_CONTENT_ERROR_NONE)
3501 ret = test_extrace_face(TRUE);
3502 if (ret != MEDIA_CONTENT_ERROR_NONE)
3505 ret = test_request_update_db();
3506 if (ret != MEDIA_CONTENT_ERROR_NONE)
3510 if (ret != MEDIA_CONTENT_ERROR_NONE)
3513 ret = test_batch_operations();
3514 if (ret != MEDIA_CONTENT_ERROR_NONE)
3515 return MEDIA_CONTENT_ERROR_NONE;
3517 ret = test_scan_file();
3518 if (ret != MEDIA_CONTENT_ERROR_NONE)
3519 return MEDIA_CONTENT_ERROR_NONE;
3521 ret = test_scan_dir(true);
3522 if (ret != MEDIA_CONTENT_ERROR_NONE)
3523 return MEDIA_CONTENT_ERROR_NONE;
3526 if (ret != MEDIA_CONTENT_ERROR_NONE)
3527 return MEDIA_CONTENT_ERROR_NONE;
3530 if (ret != MEDIA_CONTENT_ERROR_NONE)
3531 return MEDIA_CONTENT_ERROR_NONE;
3533 ret = test_face_add_del();
3534 if (ret != MEDIA_CONTENT_ERROR_NONE)
3535 return MEDIA_CONTENT_ERROR_NONE;
3537 ret = test_playlist_operation_v2();
3538 if (ret != MEDIA_CONTENT_ERROR_NONE)
3539 return MEDIA_CONTENT_ERROR_NONE;
3541 ret = test_bookmark_operation_v2();
3542 if (ret != MEDIA_CONTENT_ERROR_NONE)
3543 return MEDIA_CONTENT_ERROR_NONE;
3545 ret = test_tag_operation_v2();
3546 if (ret != MEDIA_CONTENT_ERROR_NONE)
3547 return MEDIA_CONTENT_ERROR_NONE;
3550 ret = test_disconnect_database();
3551 if (ret != MEDIA_CONTENT_ERROR_NONE)
3554 content_debug("--- content manager test end ---\n");