4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
22 #ifndef _VISUAL_SVC_H_
23 #define _VISUAL_SVC_H_
26 * This file defines minfo apis for media service..
29 * @author Hyunjun Ko <zzoon.ko@samsung.com>
31 * @brief This file defines apis for visual media service.
34 #include "media-svc-types.h"
35 #include "visual-svc-types.h"
36 #include "visual-svc-error.h"
41 #endif /* __cplusplus */
47 This document provides necessary visual media information for developers who are
48 going to implement gallery application and ug-imageviewer or other
49 3rd party applications.
54 @defgroup VISUAL_SVC_API Media Service
64 * This function gets mitem list, which include all or portion of a cluster or folder specified by
65 * @p cluster_id. @p filter could specify some filter conditions, like, type of got items, sort by type,
66 * start and end positions of items, including meta data or not, whether just get the favorites, etc.
67 * Menawhile data of each mitem instance mainly derive from media table record. However meta data
68 * is composed of video_meta or image_meta record.
70 * @param mb_svc_handle [in] the handle of DB
71 * @param cluster_id [in] the folder id in which media files are in. if the parameter is NULL, then query all folders.
72 * @param filter [in] the filter to specify some filter conditions, like, type of got items, sort by type, start and end positions of items, including meta data or not, whether just get the favorites, etc.
73 * @param func [in] Iterative callback implemented by a user. This callback is called when an item has to be inserted to user's list.
74 * @param user_data [out] user's data structure to contain items of the type Mitem. It is passed to the iterative callback.
76 * @return This function returns 0 on success, or negative value with error code.
77 * @remarks type of data memeber of list is pointer to the structure type 'Mitem'
78 * when free list, it need free every item first and then free list itself.
85 #include <media-svc.h>
87 int mitem_ite_cb(Mitem *item, void *user_data)
89 GList** list = (GList**)user_data;
90 //append an item to linked list.
91 *list = g_list_append(*list, item);
94 void test_minfo_get_item_list(MediaSvcHandle *mb_svc_handle)
99 const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
101 minfo_item_filter item_filter = {MINFO_ITEM_VIDEO,MINFO_MEDIA_SORT_BY_DATE_ASC,3,10,true,true};
103 ret = minfo_get_item_list(mb_svc_handle, cluster_id, item_filter, mitem_ite_cb, &p_list);
106 printf("minfo_get_item_list error\n");
115 minfo_get_item_list(MediaSvcHandle *mb_svc_handle, const char *cluster_id, const minfo_item_filter filter, minfo_item_ite_cb func, void *user_data);
118 * minfo_get_all_item_list
119 * This function gets mitem list, which include all or portion of a or many clusters or folders specified by
120 * @p cluster_type. @p filter could specify some filter conditions, like, type of got items, sort by type,
121 * start and end positions of items, including meta data or not, whether just get the favorites, etc.
122 * Meanwhile data of each mitem instance mainly derive from media table record. However meta data
123 * is composed of video_meta or image_meta record.
125 * @param mb_svc_handle [in] the handle of DB
126 * @param cluster_type [in] the folder type which specify media files belong to.
127 * @param filter [in] the filter to specify some filter conditions, like, type of got items, sort by type, start and end positions of items, including meta data or not, whether just get the favorites, etc.
128 * @param func [in] Iterative callback implemented by a user. This callback is called when an item has to be inserted to user's list.
129 * @param user_data [out] user's data structure to contain items of the type Mitem. It is passed to the iterative callback.
131 * @return This function returns 0 on success, or negative value with error code.
132 * @remarks type of data memeber of list is pointer to the structure type 'Mitem'
133 * when free list, it need free every item first and then free list itself.
134 * @see minfo_get_item_list.
140 #include <media-svc.h>
142 int mitem_ite_cb(Mitem *item, void *user_data)
144 GList** list = (GList**)user_data;
145 //append an item to linked list.
146 *list = g_list_append(*list, item);
149 void test_minfo_get_all_item_list(MediaSvcHandle *mb_svc_handle)
153 GList *p_list = NULL;
155 minfo_item_filter item_filter = {MINFO_ITEM_VIDEO,MINFO_MEDIA_SORT_BY_DATE_ASC,3,10,true,true};
156 //get a set of items, which all reside on local storage, including MMC and phone.
157 ret = minfo_get_all_item_list(mb_svc_handle, MINFO_CLUSTER_TYPE_LOCAL_ALL, item_filter, mitem_ite_cb, &p_list);
160 printf("minfo_get_item_list error\n");
169 minfo_get_all_item_list(MediaSvcHandle *mb_svc_handle, const minfo_folder_type cluster_type, const minfo_item_filter filter, minfo_item_ite_cb func, void *user_data);
172 * minfo_get_item_list_search
173 * This function gets mitem list, which is searched by string specified by user.
174 * @p search_field is a field to want to search. @p search_str could specify string to search.
175 * Menawhile data of each mitem instance mainly derive from media table record. However meta data
176 * is composed of video_meta or image_meta record.
178 * @param mb_svc_handle [in] the handle of DB
179 * @param search_field [in] A field to want search. Please refer the enum type minfo_search_field_t in 'minfo-types.h'.
180 * @param search_str [in] A string to search.
181 * @param folder_type [in] the folder type which specify media files belong to.
182 * @param filter [in] the filter to specify some filter conditions, like, type of got items, sort by type, start and end positions of items, including meta data or not, whether just get the favorites, etc.
183 * @param func [in] Iterative callback implemented by a user. This callback is called when an item has to be inserted to user's list.
184 * @param user_data [out] user's data structure to contain items of the type Mitem. It is passed to the iterative callback.
186 * @return This function returns 0 on success, or negative value with error code.
187 * Please refer 'media-svc-error.h' to know the exact meaning of the error.
188 * @remarks type of data memeber of list is pointer to the structure type 'Mitem'
189 * when free list, it need free every item first and then free list itself.
196 #include <media-svc.h>
198 int mitem_ite_cb(Mitem *item, void *user_data)
200 GList **list = (GList **)user_data;
201 //append an item to linked list.
202 *list = g_list_append(*list, item);
205 void test_minfo_get_item_list_search(MediaSvcHandle *mb_svc_handle)
208 GList *p_list = NULL;
209 const char *search_str = "Hiphop";
210 minfo_search_field_t search_field = MINFO_SEARCH_BY_NAME;
211 minfo_folder_type folder_type = MINFO_CLUSTER_TYPE_ALL;
213 minfo_item_filter item_filter = {MINFO_ITEM_VIDEO, MINFO_MEDIA_SORT_BY_NAME_ASC, 0, 9, false, MINFO_MEDIA_FAV_ALL};
215 ret = minfo_get_item_list_search(mb_svc_handle, search_field, search_str, folder_type, item_filter, mitem_ite_cb, &p_list);
218 printf("minfo_get_item_list_search error\n");
227 minfo_get_item_list_search(MediaSvcHandle *mb_svc_handle, minfo_search_field_t search_field, const char *search_str, minfo_folder_type folder_type, const minfo_item_filter filter, minfo_item_ite_cb func, void *user_data);
230 * minfo_get_all_item_cnt
231 * This function gets count of all records in media table. This function returns the count of all items, which are unlocked excluding web media.
233 * @param cnt [out] returned value, count of all records
234 * @return This function returns zero(MB_SVC_ERROR_BASE) on success, or negative value with error code.
235 * Please refer 'media-svc-error.h' to know the exact meaning of the error.
244 #include <media-svc.h>
246 void test_minfo_get_all_item_cnt(MediaSvcHandle *mb_svc_handle)
251 ret = minfo_get_all_item_cnt(mb_svc_handle, &cnt);
253 printf("minfo_get_all_item_cnt error\n");
261 minfo_get_all_item_cnt(MediaSvcHandle *mb_svc_handle, int *cnt);
264 * minfo_get_all_item_count
265 * This function gets count of all records in the specific storage.
266 * User can specify folder type like MINFO_CLUSTER_TYPE_ALL, MINFO_CLUSTER_TYPE_LOCAL_PHONE, etc.
267 * Please refer 'visual-svc-types.h' to know what folder type exists.
268 * This function returns the count of all items, which are unlocked.
270 * @param mb_svc_handle [in] the handle of DB
271 * @param folder_type [in] folder type
272 * @param file_type [in] file type
273 * @param fav_type [in] favortie type
274 * @param cnt [out] returned value, count of all records
275 * @return This function returns zero(MB_SVC_ERROR_BASE) on success, or negative value with error code.
276 * Please refer 'media-svc-error.h' to know the exact meaning of the error.
284 #include <media-svc.h>
286 void test_minfo_get_all_item_count(MediaSvcHandle *mb_svc_handle)
290 minfo_folder_type folder_type = MINFO_CLUSTER_TYPE_LOCAL_PHONE;
291 minfo_file_type file_type = MINFO_ITEM_ALL;
292 minfo_media_favorite_type fav_type = MINFO_MEDIA_FAV_ALL;
294 ret = minfo_get_all_item_count(mb_svc_handle, folder_type, file_type, fav_type, &cnt);
296 printf("minfo_get_all_item_cnt error\n");
303 EXPORT_API int minfo_get_all_item_count(
304 MediaSvcHandle *mb_svc_handle,
305 minfo_folder_type folder_type,
306 minfo_file_type file_type,
307 minfo_media_favorite_type fav_type,
312 * This function gets count of matched records in media table with the specified @p filter, which
313 * specify some filter conditions, like, type of got items, sort by type, start and end positions
314 * of items, including meta data or not, whether just get the favorites, etc.
315 * The detail structure type of @p filter, could refer to the defination 'minfo_item_filter'
316 * in header file, minfo-types.h.
318 * @param mb_svc_handle [in] the handle of DB
319 * @param cluster_id [in] the folder id in which media files are in. if the parameter is -1, then query all folders.
320 * @param filter [in] the filter to specify some filter conditions, like, type of got items, sort by type, start and end positions of items, including meta data or not, whether just get the favorites, etc.
321 * @param cnt [out] returned value, count of matched records
323 * @return This function returns 0 on success, or negative value with error code.
324 * @remarks list contains a set of full path string of cover file.
325 * @see minfo_get_item_list.
331 #include <media-svc.h>
333 void test_minfo_get_item_cnt(MediaSvcHandle *mb_svc_handle)
336 const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
338 minfo_item_filter item_filter = {MINFO_ITEM_VIDEO,MINFO_MEDIA_SORT_BY_DATE_ASC,-1,10,true,true};
340 //get count of a set of items.
341 ret = minfo_get_item_cnt(mb_svc_handle, cluster_id, item_filter, &cnt);
343 printf("test_minfo_get_item_cnt error\n");
351 minfo_get_item_cnt(MediaSvcHandle *mb_svc_handle, const char *cluster_id, const minfo_item_filter filter, int *cnt);
355 * minfo_get_cluster_cnt
356 * This function gets count of matched records from folder table with the specified @p filter, which
357 * specify some filter conditions, like, type of got clusters, sort by type, start and end positions
358 * of clusters, etc. The detail structure type of @p filter, could refer to the defination 'minfo_cluster_filter'
359 * in header file, minfo-types.h.
361 * @param mb_svc_handle [in] the handle of DB
362 * @param filter [in] filter to specify some filter conditions, like, type of got clusters, sort by type, start and end positions of clusters
363 * @param cnt [out] returned value, count of matched records
364 * @return This function returns 0 on success, or negative value with error code.
366 * @see minfo_get_cluster_list.
372 #include <media-svc.h>
374 void test_minfo_get_cluster_cnt(MediaSvcHandle *mb_svc_handle)
377 minfo_cluster_filter cluster_filter ={MINFO_CLUSTER_TYPE_ALL,MINFO_CLUSTER_SORT_BY_NONE,-1,10};
379 //get the count of items which is owned by a cluster.
380 ret = minfo_get_cluster_cnt(mb_svc_handle, cluster_filter, &cnt);
382 printf("test_minfo_get_cluster_cnt error\n");
390 minfo_get_cluster_cnt(MediaSvcHandle *mb_svc_handle, const minfo_cluster_filter filter, int *cnt);
394 * minfo_get_cluster_list
395 * This function gets Mcluster instances list. Data of each instance is composed of the matched records from folder table
396 * with the @p filter, which specify some filter conditions, like, type of got clusters, sort by type, start and end positions
397 * The detail structure type of @p filter, could refer to the defination 'minfo_cluster_filter'
398 * in header file, minfo-types.h.
400 * @param mb_svc_handle [in] the handle of DB
401 * @param filter [in] filter to specify some filter conditions, like, type of got clusters, sort by type, start and end positions of clusters
402 * @param func [in] Iterative callback implemented by a user. This callback is called when an item has to be inserted to user's list.
403 * @param user_data [out] user's data structure to contain items of the type Mcluster. It is passed to the iterative callback.
404 * @return This function returns 0 on success, or negative value with error code.
405 * @remarks item type in list is pointer to structure mcluster
406 * when free list, it need free every item first and then free list itself.
413 #include <media-svc.h>
415 int mcluster_ite_cb(Mcluster *cluster, void *user_data)
417 GList** list = (GList**)user_data;
418 *list = g_list_append(*list, cluster);
421 void test_minfo_get_cluster_list(MediaSvcHandle *mb_svc_handle)
426 GList *p_list = NULL;
427 Mcluster* cluster = NULL;
429 //get a linked list which include all of clusters based on a specified filter.
430 minfo_cluster_filter cluster_filter ={MINFO_CLUSTER_TYPE_ALL,MINFO_CLUSTER_SORT_BY_NONE,0,10};
432 ret = minfo_get_cluster_list(mb_svc_handle, cluster_filter, mcluster_ite_cb, &p_list);
442 minfo_get_cluster_list(MediaSvcHandle *mb_svc_handle, const minfo_cluster_filter filter, minfo_cluster_ite_cb func, void *user_data);
446 * minfo_get_meta_info
447 * This function gets matched 'Mmeta' instances. Data of the instance is composed of the matched media record from
448 * 'video_meta'/'image_meta' table, when finish using the Mmeta instance, should call API, minfo_mmeta_destroy to
449 * destroy this created instance.
451 * @param mb_svc_handle [in] the handle of DB
452 * @param media_id [in] specified _id field in media table record
453 * @param meta [out] pointer to pointer of matched Mmeta instance
454 * @return This function returns 0 on success, or negative value with error code.
455 * @remarks after using meta, it must be freed.
462 #include <media-svc.h>
464 void test_minfo_get_meta_info(MediaSvcHandle *mb_svc_handle)
468 const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
470 //get a matched meta data.
471 ret = minfo_get_meta_info(mb_svc_handle, media_id, &mt);
473 printf("minfo_get_meta_info failed\n");
476 minfo_mmeta_destroy(mt);
483 minfo_get_meta_info(MediaSvcHandle *mb_svc_handle, const char *media_id, Mmeta** meta);
486 * minfo_update_image_meta_info_int
487 * This function will update the corresponding field's value in database 'image_meta' table, this will be decided by the
488 * @p meta_field, whose type is 'minfo_image_meta_field_t', and indicate which field will be replaced by the value of int type
489 * pointered to by @p updated_value.
491 * @param mb_svc_handle [in] the handle of DB
492 * @param media_id [in] specified _id field in media table record
493 * @param meta_field [in] the enum value indicate which field of database table will be updated
494 * @param updated_value [in] value of int, which will replace the original value in database image meta table
495 * @return This function returns 0 on success, or negative value with error code.
496 * @remarks after using meta, it must be freed.
503 #include <media-svc.h>
505 void test_minfo_update_image_meta_info_int(MediaSvcHandle *mb_svc_handle)
510 const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
512 // update image meta's 'width and height' member
513 ret = minfo_update_image_meta_info_int(mb_svc_handle, media_id, MINFO_IMAGE_META_WIDTH, width, MINFO_IMAGE_META_HEIGHT, height);
515 printf("minfo_update_image_meta_info_int failed\n");
524 minfo_update_image_meta_info_int(MediaSvcHandle *mb_svc_handle, const char *media_id,
525 minfo_image_meta_field_t meta_field,
526 const int updated_value,
530 * minfo_update_video_meta_info_int
531 * This function will update the corresponding field's value in database 'video_meta' table, this will be decided by the
532 * @p meta_field, whose type is 'minfo_video_meta_field_t', and indicate which field will be replaced by the value of int type
533 * pointered to by @p updated_value.
535 * @param mb_svc_handle [in] the handle of DB
536 * @param media_id [in] specified _id field in media table record
537 * @param meta_field [in] the enum value indicate which field of database table will be updated
538 * @param updated_value [in] value of int, which will replace the original value in database video meta table
539 * @return This function returns 0 on success, or negative value with error code.
540 * @remarks after using meta, it must be freed.
547 #include <media-svc.h>
549 void test_minfo_update_video_meta_info_int(MediaSvcHandle *mb_svc_handle)
553 const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
555 //update video meta's 'last_played_time' member
556 ret = minfo_update_video_meta_info_int(mb_svc_handle, media_id, MINFO_VIDEO_META_BOOKMARK_LAST_PLAYED, _value);
559 printf("minfo_update_video_meta_info_int failed\n");
568 minfo_update_video_meta_info_int(MediaSvcHandle *mb_svc_handle, const char *media_id, minfo_video_meta_field_t meta_field, const int updated_value);
572 * minfo_destroy_mtype_item
573 * This function free an type instantiated object, whose type may be any one recognized by media-svc, these type
574 * will include Mitem, Mimage, Mvideo, Mmeta, Mcluster, etc. In this function, it will check the concrete type for the
575 * @p item, and then decide which free function will really be called.
577 * @return This function returns 0 on success, and negativa value on failure.
578 * @param item [in] the input parameter, inlcuding the instanciated object.
580 * @remarks This function is general one, it will be able to destroy any recognized instantiated object
581 * by media-svc, so when you create or get an instantiated object from media-svc, and then
582 * call this function to free it.
589 #include <media-svc.h>
591 void test_minfo_destroy_mtype_item(void)
596 char* file_url = "/opt/media/Images/Wallpapers/Home_01.png";
597 ret = minfo_get_item(file_url, &mi);
599 //destroy an item whose type is 'Mitem'.
600 ret = minfo_destroy_mtype_item(mi);
611 minfo_destroy_mtype_item(void* item);
615 * minfo_add_media_start
616 * This function inserts new media file information into media table,video_meta table/image_meta table.
617 Or updates file information in these tables if the file is updated
619 * @param mb_svc_handle [in] the handle of DB
620 * @param trans_count [in] count of trasaction user wants
621 * @return This function returns 0/positive on success, or negative value with error code. (0 : added, 1: updated, 2: skipped )
622 * @remarks if invoke this function with same input parameter, it fails
623 * @see minfo_add_media_end, minfo_add_media_batch
629 #include <media-svc.h>
631 void test_minfo_add_media_batch(MediaSvcHandle *mb_svc_handle)
635 err = minfo_add_media_start(mb_svc_handle, 100);
637 printf("minfo_add_media_start failed\n");
641 for (i = 0; i < 200; i++) {
642 err = minfo_add_media_batch(mb_svc_handle, image_files[i], MINFO_ITEM_IMAGE);
645 printf("minfo_add_media_start failed\n");
650 err = minfo_add_media_end(mb_svc_handle);
652 printf("minfo_add_media_end failed\n");
660 minfo_add_media_start(MediaSvcHandle *mb_svc_handle, int trans_count);
664 * minfo_add_media_batch
665 * This function inserts new media file information into media table,video_meta table/image_meta table.
666 Or updates file information in these tables if the file is updated
668 * @param mb_svc_handle [in] the handle of DB
669 * @param file_url [in] the local file full path
670 * @param type [in] the file type, maybe it's video file or image file
671 * @return This function returns 0/positive on success, or negative value with error code. (0 : added, 1: updated, 2: skipped )
672 * @remarks if invoke this function with same input parameter, it fails
673 * @see minfo_add_media_start, minfo_add_media_end
679 #include <media-svc.h>
681 void test_minfo_add_media_batch(MediaSvcHandle *mb_svc_handle)
685 err = minfo_add_media_start(mb_svc_handle, 100);
687 printf("minfo_add_media_start failed\n");
691 for (i = 0; i < 100; i++) {
692 err = minfo_add_media_batch(mb_svc_handle, image_files[i], MINFO_ITEM_IMAGE);
695 printf("minfo_add_media_start failed\n");
700 err = minfo_add_media_end(mb_svc_handle);
702 printf("minfo_add_media_end failed\n");
710 minfo_add_media_batch(MediaSvcHandle *mb_svc_handle, const char* file_url, minfo_file_type content_type);
713 * minfo_add_media_end
714 * This function inserts new media file information into media table,video_meta table/image_meta table.
715 Or updates file information in these tables if the file is updated
717 * @param mb_svc_handle [in] the handle of DB
718 * @return This function returns 0/positive on success, or negative value with error code. (0 : added, 1: updated, 2: skipped )
719 * @remarks if invoke this function with same input parameter, it fails
720 * @see minfo_add_media_start, minfo_add_media_batch
726 #include <media-svc.h>
728 void test_minfo_add_media_batch(MediaSvcHandle *mb_svc_handle)
732 err = minfo_add_media_start(100);
734 printf("minfo_add_media_start failed\n");
738 for (i = 0; i < 200; i++) {
739 err = minfo_add_media_batch(mb_svc_handle, image_files[i], MINFO_ITEM_IMAGE);
742 printf("minfo_add_media_start failed\n");
747 err = minfo_add_media_end();
749 printf("minfo_add_media_end failed\n");
757 minfo_add_media_end(MediaSvcHandle *mb_svc_handle);
761 * This function inserts new media file information into media table,video_meta table/image_meta table.
762 Or updates file information in these tables if the file is updated
764 * @param mb_svc_handle [in] the handle of DB
765 * @param file_url [in] the local file full path
766 * @param type [in] the file type, maybe it's video file or image file
767 * @return This function returns 0/positive on success, or negative value with error code. (0 : added, 1: updated, 2: skipped )
768 * @remarks if invoke this function with same input parameter, it fails
769 * @see minfo_delete_media
775 #include <media-svc.h>
777 void test_minfo_add_media(MediaSvcHandle *mb_svc_handle)
780 char *file_url = "/opt/media/Images/Wallpapers/Home_01.png";
782 //add a new media content whose url is 'file_url'.
783 err = minfo_add_media(mb_svc_handle, file_url, MINFO_ITEM_IMAGE);
786 printf("minfo_add_media failed\n");
795 minfo_add_media(MediaSvcHandle *mb_svc_handle, const char* file_url, minfo_file_type content_type);
801 * This function deletes matched media table record, video_meta/image_meta record. After that, if the folder which this file is in is empty, then delete the folder record.
802 * When user actually delete a media file in file system, he/she should call this function to delete the corresponding record in 'media' table, meanwhile it may delete the
803 * folder record in 'folder' table if this folder will not include any media content.
805 * @param mb_svc_handle [in] the handle of DB
806 * @param file_url [in] matched local file full path
807 * @return This function returns 0 on success, or negative value with error code.
809 * @see minfo_add_media
815 #include <media-svc.h>
817 void test_minfo_delete_media(void)
820 char *file_url = "/opt/media/Images/Wallpapers/Home_01.png";
822 //delete a media reord from 'media' table.
823 ret= minfo_delete_media(file_url);
826 printf("minfo_delete_media failed\n");
834 minfo_delete_media(MediaSvcHandle *mb_svc_handle, const char* file_url);
840 * This function moves the media file to another place. When user actually move a media file ( @p old_file_url )in file system to the destination
841 * pathname ( @p new_file_url ), he/she need to call this function to move the record of 'media' table. Meanwhile user is responsible for identifying
842 * the file's type, like image, video, etc.
843 * @param mb_svc_handle [in] the handle of DB
844 * @param old_file_url [in] old local file full path of the media file
845 * @param new_file_url [in] new local file full path of the media file
846 * @param type [in] media file type,maybe vidoe or image
847 * @return This function returns 0 on success, or negative value with error code.
849 * @see minfo_mv_media, minfo_copy_media, minfo_update_media_name.
855 #include <media-svc.h>
857 void test_minfo_move_media(MediaSvcHandle *mb_svc_handle)
860 char* old_file_url = "/opt/media/Images/Wallpapers/Home_01.png";
861 char* new_file_url = "/opt/media/Images/Wallpapers/Home_01_1.png";
863 //move an item to a specified location.
864 ret = minfo_move_media(mb_svc_handle, old_file_url, new_file_url, MINFO_ITEM_IMAGE);
867 printf("minfo_move_media failed\n");
875 minfo_move_media(MediaSvcHandle *mb_svc_handle, const char* old_file_url, const char *new_file_url, minfo_file_type content_type);
878 * minfo_move_media_start
879 * This function starts to move multiple media files
881 * @param mb_svc_handle [in] the handle of DB
882 * @param trans_count [in] count of trasaction user wants
883 * @return This function returns 0/positive on success, or negative value with error code.
884 * @remarks if invoke this function with same input parameter, it fails
885 * @see minfo_move_media_end, minfo_move_media
891 #include <media-svc.h>
893 void test_minfo_move_media_batch(MediaSvcHandle *mb_svc_handle)
897 err = minfo_move_media_start(mb_svc_handle, 100);
899 printf("minfo_move_media_start failed\n");
903 for (i = 0; i < 200; i++) {
904 err = minfo_move_media(mb_svc_handle, src_image_file_path[i], dst_image_file_path[i], MINFO_ITEM_IMAGE);
907 printf("minfo_move_media failed\n");
912 err = minfo_move_media_end(mb_svc_handle);
914 printf("minfo_move_media_end failed\n");
922 minfo_move_media_start(MediaSvcHandle *mb_svc_handle, int trans_count);
927 * minfo_move_media_end
928 * This function ends to move multiple media files
930 * @param mb_svc_handle [in] the handle of DB
931 * @return This function returns 0/positive on success, or negative value with error code.
932 * @remarks if invoke this function with same input parameter, it fails
933 * @see minfo_add_move_start, minfo_move_media
939 #include <media-svc.h>
941 void test_minfo_move_media_batch(void)
945 err = minfo_move_media_start(mb_svc_handle, 100);
947 printf("minfo_add_media_start failed\n");
951 for (i = 0; i < 200; i++) {
952 err = minfo_move_media(mb_svc_handle, src_image_file_path[i], dst_image_file_path[i], MINFO_ITEM_IMAGE);
955 printf("minfo_move_media failed\n");
960 err = minfo_move_media_end(mb_svc_handle);
962 printf("minfo_move_media_end failed\n");
970 minfo_move_media_end(MediaSvcHandle *mb_svc_handle);
975 * This function copies the media file to another place. User should pass the full pathnames for these parameters, @p old_file_url and @ new_file_url
976 * respectively. The @p old_file_url indicate the original full pathname of this media content, and @ new_file_url indicate the destination full pathname of
978 * @param mb_svc_handle [in] the handle of DB
979 * @param old_file_url [in] old local file full path of the media file
980 * @param new_file_url [in] new local file full path of the media file
981 * @param type [in] media file type, maybe vidoe or image
982 * @return This function returns 0 on success, or negative value with error code.
983 * @remarks This function will not return the thumbnail pathname of new media file, user could get this new thumnail file using the function, minfo_get_thumb_path.
984 * @see minfo_cp_media, minfo_update_media_name, minfo_move_media
990 #include <media-svc.h>
992 void test_minfo_copy_media(MediaSvcHandle *mb_svc_handle)
996 char *file_url = "/opt/media/Images/Wallpapers/Home_01.png";
997 char *new_file_url = "/opt/media/Images/Wallpapers/Home_01_1.png";
999 //copy a media file to other location whos name is specified by 'new_file_url'.
1000 ret = minfo_copy_media(mb_svc_handle, old_file_url, new_file_url, file_type);
1002 printf("minfo_copy_media failed\n");
1011 minfo_copy_media(MediaSvcHandle *mb_svc_handle, const char* old_file_url, const char *new_file_url, minfo_file_type content_type);
1015 * minfo_update_media_name
1016 * This function rename a image or video file. Here this function will assume the folder name of
1017 * file whose name is changed keep unchanged. That is, this file which is changed name still is located in the same folder.
1018 * This function actually call sqlite3
1019 * UPDATE %s SET ... WHERE _id = _id;
1020 * @param mb_svc_handle [in] the handle of DB
1021 * @param media_id [in] the id of specified media file
1022 * @param new_name [in] new name of the media file
1023 * @return This function returns 0 on success, or negative value with error code.
1025 * @see minfo_move_media, minfo_copy_media.
1031 #include <media-svc.h>
1033 void test_minfo_update_media_name(MediaSvcHandle *mb_svc_handle)
1036 const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
1039 ret = minfo_update_media_name(mb_svc_handle, media_id, new_name);
1041 printf("test_minfo_update_media_name failed\n");
1049 minfo_update_media_name(MediaSvcHandle *mb_svc_handle, const char *media_id, const char* new_name);
1052 * minfo_update_media_thumb
1053 * This function updates a thumbpath of the media in DB.
1054 * @param mb_svc_handle [in] the handle of DB
1055 * @param media_id [in] the id of specified media file
1056 * @param thumb_path [in] new thumbnail path of the media file
1057 * @return This function returns 0 on success, or negative value with error code.
1065 #include <media-svc.h>
1067 void test_minfo_update_media_thumb(MediaSvcHandle *mb_svc_handle)
1070 const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
1071 const char *thumb_path = "/opt/media/test.jpg";
1073 //update thumbnail path
1074 ret = minfo_update_media_thumb(mb_svc_handle, media_id, thumb_path);
1076 printf("minfo_update_media_thumb failed\n");
1084 minfo_update_media_thumb(MediaSvcHandle *mb_svc_handle, const char *media_id, const char* thumb_path);
1087 * minfo_update_media_favorite
1088 * This function updates favorite field of image or video file in 'media' table. This function actually call the Sqlite3 UPDATE,
1089 * In Gallery application or ug-imageviewer, user could want to set a media file as favorite or unfovarite, so he/she could call
1090 * this API to do it.
1091 * @param mb_svc_handle [in] the handle of DB
1092 * @param media_id [in] Unique id of the media file
1093 * @param favorite_level [in] new favorite_level of the media file, indicate whether this media content is favorite or unfavorite.
1094 * @return This function returns 0 on success, or negative value with error code.
1102 #include <media-svc.h>
1104 void test_minfo_update_media_favorite(MediaSvcHandle *mb_svc_handle)
1107 const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
1109 //update an item's favorite record
1110 ret = minfo_update_media_favorite(mb_svc_handle, media_id, favorite_level);
1113 printf("minfo_update_media_favorite failed\n");
1121 minfo_update_media_favorite(MediaSvcHandle *mb_svc_handle, const char *media_id, const int favorite_level);
1125 * minfo_update_media_date
1126 * This function updates modified date of image or video file in 'media' table. This function actually call the Sqlite3 UPDATE.
1127 * In Gallery application or ug-imageviewer, user could want to set moedified date of a media, so he/she could call this API to do it.
1128 * @return This function returns zero(MB_SVC_ERROR_BASE) on success, or negative value with error code.
1129 * @param mb_svc_handle [in] the handle of DB
1130 * @param media_id [in] Unique id of the media file
1131 * @param modified_date [in] date to modify, which is a type of time_t
1132 * @return This function returns 0 on success, or negative value with error code.
1140 #include <media-svc.h>
1142 void test_minfo_update_media_date(MediaSvcHandle *mb_svc_handle)
1145 const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
1150 //update an item's date record
1151 ret = minfo_update_media_date(mb_svc_handle, media_id, today);
1153 printf("minfo_update_media_date failed\n");
1161 minfo_update_media_date(MediaSvcHandle *mb_svc_handle, const char *media_id, time_t modified_date);
1166 * This function adds new local folder. This function could be called when user want to add a Album(local folder)
1167 * in Gallery application. This function actually call the sqlite INSERT statement to insert the record in folder
1168 * table. Meanwhile it will return new added local folder's ID to @p id.
1169 * Sqlie3 statement looks like this, INSERT INTO folder (...);
1170 * @param mb_svc_handle [in] the handle of DB
1171 * @param cluster_url [in] the local directory of added folder, it should be full pathname of local folder
1172 * @param id [out] id of the added folder, this function will return a unique ID to calling application
1173 * @return This function returns 0 on success, or negative value with error code.
1174 * @remarks if invoke this function with same input parameter, it fails
1175 * @see minfo_delete_cluster
1181 #include <media-svc.h>
1183 void test_minfo_add_cluster(MediaSvcHandle *mb_svc_handle)
1186 char *cluster_url = "/opt/media/Images/Wallpapers";
1187 char cluster_id[256];
1189 //add a new cluster whose url is 'cluster_url'.
1190 ret = minfo_add_cluster(mb_svc_handle, cluster_url, cluster_id, sizeof(cluster_id));
1192 printf("minfo_add_cluster failed\n");
1200 minfo_add_cluster(MediaSvcHandle *mb_svc_handle, const char* cluster_url, char *id, int max_length);
1204 * minfo_check_cluster_exist
1205 * This function checks to exist the cluster in media database by its path.
1206 * @param mb_svc_handle [in] the handle of DB
1207 * @param path [in] the local directory to check if it exists, it should be full pathname of local folder
1208 * @return This function returns 0 on success, or negative value with error code.
1209 * @remarks if invoke this function with same input parameter, it fails
1210 * @see minfo_check_item_exist
1216 #include <media-svc.h>
1218 void test_minfo_check_cluster_exist(MediaSvcHandle *mb_svc_handle)
1221 char *cluster_url = "/opt/media/Images/Wallpapers";
1223 //check if the cluster exists by path.
1224 ret = minfo_check_cluster_exist(mb_svc_handle, cluster_url);
1226 printf("minfo_check_cluster_exist failed\n");
1234 minfo_check_cluster_exist(MediaSvcHandle *mb_svc_handle, const char *path);
1237 * minfo_check_item_exist
1238 * This function checks to exist the media in media database by its path.
1239 * @param mb_svc_handle [in] the handle of DB
1240 * @param path [in] the local media path to check if it exists, it should be full pathname.
1241 * @return This function returns 0 on success, or negative value with error code.
1242 * @remarks if invoke this function with same input parameter, it fails
1243 * @see minfo_check_cluster_exist
1249 #include <media-svc.h>
1251 void test_minfo_check_item_exist(MediaSvcHandle *mb_svc_handle)
1254 char *media_url = "/opt/media/Images/Wallpapers/Wallpaper1.jpg";
1256 //check if the item exists by path.
1257 ret = minfo_check_item_exist(mb_svc_handle, media_url);
1259 printf("minfo_check_item_exist failed\n");
1267 minfo_check_item_exist(MediaSvcHandle *mb_svc_handle, const char *path);
1270 * minfo_get_item_by_id
1271 * This function gets mitem information. When user could get the unique ID of a media content, he/she
1272 * could get the detail information with the type 'Mitem', which include the below feilds, like, item's unique id,
1273 * media content type, media content's thumbnail name, media content's pathname, etc. The detail defination
1274 * of this structute, could refer to the header, minfo-item.h.
1275 * @param mb_svc_handle [in] the handle of DB
1276 * @param media_id [in] the local file media id
1277 * @param mitem [out] the returned data structure whose type is Mitem.
1278 * @return This function returns 0 on success, or negative value with error code.
1279 * @remarks when invoking this function, *mitem must equals NULL, and
1280 * the @p media_id should be valid ID, if it is invalid, like -1 or 0, this
1281 * function will return @p mitem whose content is NULL. If normally, @p mitem must be freed with minfo_mitem_destroy.
1282 * @see minfo_get_item.
1288 #include <media-svc.h>
1290 void test_minfo_get_item_by_id(MediaSvcHandle *mb_svc_handle)
1293 const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
1296 //get an item based on its media ID.
1297 ret = minfo_get_item_by_id(mb_svc_handle, media_id, &mi);
1302 minfo_destroy_mtype_item(mi);
1308 minfo_get_item_by_id(MediaSvcHandle *mb_svc_handle, const char *media_id, Mitem **mitem);
1313 * This function gets mitem information. When user could get the full pathname of a media content, he/she
1314 * could get the detail information with the type 'Mitem', which include the below feilds, like, item's unique id,
1315 * media content type, media content's thumbnail name, media content's pathname, etc. The detail defination
1316 * of this structute, could refer to the header, minfo-item.h.
1317 * @param mb_svc_handle [in] the handle of DB
1318 * @param file_url [in] the local file full pathname
1319 * @param mitem [out] the returned data structure whose type is Mitem.
1320 * @return This function returns 0 on success, or negative value with error code.
1321 * @remarks when invoking this function, *mitem must equals NULL, and
1322 * after using mitem, it must be freed with minfo_mitem_destroy.
1323 * @see minfo_get_item_by_id.
1329 #include <media-svc.h>
1331 void test_minfo_get_item(MediaSvcHandle *mb_svc_handle)
1335 char* file_url = "/opt/media/Images/Wallpapers/Home_01.png";
1337 //get an item based on its url.
1338 ret = minfo_get_item(mb_svc_handle, file_url, &mi);
1343 minfo_destroy_mtype_item(mi);
1349 minfo_get_item(MediaSvcHandle *mb_svc_handle, const char* file_url, Mitem **mitem);
1352 * minfo_get_item_by_http_url
1353 * This function gets mitem information. When user could get the http url of a media content, which is downloaded from web, he/she
1354 * could get the detail information with the type 'Mitem', which include the below feilds, like, item's unique id,
1355 * media content type, media content's thumbnail name, etc. The detail defination
1356 * of this structute, could refer to the header, minfo_item/minfo-item.h.
1357 * @param mb_svc_handle [in] the handle of DB
1358 * @param http_url [in] the http url of a media, which is downloaded from web.
1359 * @param mitem [out] the returned data structure whose type is Mitem.
1360 * @return This function returns 0 on success, or negative value with error code.
1361 * Please refer 'media-svc-error.h' to know the exact meaning of the error.
1362 * @remarks when invoking this function, *mitem must equals NULL, and
1363 * after using mitem, it must be freed with minfo_mitem_destroy.
1364 * @see minfo_get_item_by_id, minfo_get_item
1370 #include <media-svc.h>
1372 void test_minfo_get_item_by_http_url(MediaSvcHandle *mb_svc_handle)
1376 char* http_url = "http://picasa.com/myaccount/Home_01.png";
1378 //get an item based on its http url.
1379 ret = minfo_get_item_by_http_url(mb_svc_handle, http_url, &mi);
1384 minfo_destroy_mtype_item(mi);
1390 minfo_get_item_by_http_url(MediaSvcHandle *mb_svc_handle, const char* http_url, Mitem **mitem);
1395 * This function gets mcluster information by folder full path or cluster id when user could not know exact url of cluster. When user could get full path of a folder, he/she
1396 * could get the detail information with the type 'Mcluster' about this cluster/local folder, the type 'Mcluster'
1397 * mainly include folder/cluster ID, display name, count of included media content, etc. The detail defination
1398 * of this type could refer to the herder file, minfo-cluster.h.
1400 * @return This function returns 0 on success, or negative value with error code.
1401 * @param mb_svc_handle [in] the handle of DB
1402 * @param cluster_url [in] local folder full path, it indicate which folder user want to get it's detail information
1403 * @param cluster_id [in] the cluster ID which indentify a cluster
1404 * @param mcluster [out] mcluster to be returned, which is a 'Mcluster' type
1406 * @remarks when user could not know exact url of a cluster, he/she could choose alternative way he/she pass cluster id to this function, so that
1407 * this function still could get the wanted cluster.
1408 * when invoking this function, *mcluster must equals NULL, and
1409 * after using mitem, it must be freed with minfo_mcluster_destroy.
1410 * @see minfo_mcluster_destroy
1416 #include <media-svc.h>
1418 void test_minfo_get_cluster(MediaSvcHandle *mb_svc_handle)
1421 Mcluster *mc = NULL;
1422 char *cluster_url = "/opt/media/Images/Wallpapers";
1423 const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
1425 //get a cluster using cluster's url.
1426 ret = minfo_get_cluster(mb_svc_handle, cluster_url, cluster_id, &mc);
1428 printf("minfo_get_cluster fail: %d \n", ret);
1432 printf("minfo_get_cluster: %s \n", mc->display_name);
1433 minfo_mcluster_destroy(mc);
1439 minfo_get_cluster(MediaSvcHandle *mb_svc_handle, const char* cluster_url, const char *cluster_id, Mcluster **mcluster);
1443 * minfo_get_cluster_cover
1444 * This function gets thumbnail path of cover files by cluster id. This function could get the cover of a cluster
1445 * or folder which may include first several items' thumbnails, maybe 5 or other number, user could specify it
1448 * @param mb_svc_handle [in] the handle of DB
1449 * @param cluster_id [in] the folder id in which media files are in. if the parameter is -1, then query all folders.
1450 * @param img_cnt [in] the count of cover thumbnails
1451 * @param func [in] Iterative callback implemented by a user. This callback is called when an thumbnail path has to be inserted to user's list.
1452 * @param user_data [out] user's data structure to contain items of thumbnail path. It is passed to the iterative callback.
1454 * @return This function returns 0 on success, or negative value with error code.
1455 * @remarks type of item is pointer to char*,
1456 * when free list, needn't free every string.
1463 #include <media-svc.h>
1465 int cover_ite_cb(char *thumb_path, void *user_data)
1467 GList** list = (GList**)user_data;
1468 *list = g_list_append(*list, thumb_path);
1471 void test_minfo_get_cluster_cover(MediaSvcHandle *mb_svc_handle)
1474 GList *p_list = NULL;
1476 const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
1478 //get the cover of a cluster.
1479 ret = minfo_get_cluster_cover(mb_svc_handle, cluster_id, img_cnt, cover_ite_cb, &p_list);
1481 printf("test_minfo_get_cluster_cover error\n");
1490 minfo_get_cluster_cover(MediaSvcHandle *mb_svc_handle, const char *cluster_id, const int img_cnt, minfo_cover_ite_cb func, void *user_data);
1494 * minfo_get_bookmark_list
1495 * This function gets the type 'Mbookmark' instances list. Data of each this type instance is
1496 * composed of the matched record indentified by the media id from 'video_bookmark' table.
1497 * The type 'Mbookmark' mainly include the these information, like, bookmark id, media id,
1498 * marked time, corresponding thumbnail pathanme, etc.
1500 * @param mb_svc_handle [in] the handle of DB
1501 * @param media_id [in] media_id field of video_bookmark table record
1502 * @param func [in] Iterative callback implemented by a user. This callback is called when an item has to be inserted to user's list.
1503 * @param user_data [out] User's data structure to contain items of the type Mbookmark. It is passed to the iterative callback.
1504 * @return This function returns 0 on success, or negative value with error code.
1505 * @remarks member data in list is pointer to structure Mbookmark,
1506 * when free list, it need free every item first and then free list itself.
1513 #include <media-svc.h>
1515 int mbookmark_ite_cb(Mbookmark *bm, void *user_data)
1517 GList** list = (GList**)user_data;
1518 *list = g_list_append(*list, bm);
1521 void test_minfo_get_bookmark_list(MediaSvcHandle *mb_svc_handle)
1524 const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
1525 GList *p_list = NULL;
1527 //get a linked list which will include all of bookmarks of a media file.
1528 ret = minfo_get_bookmark_list(mb_svc_handle, media_id, mbookmar_ite_cb, &p_list);
1537 minfo_get_bookmark_list(MediaSvcHandle *mb_svc_handle, const char *media_id, minfo_bm_ite_cb func, void *user_data);
1541 * minfo_get_geo_item_list
1542 * This function gets the type 'Mitem' instances list. Data of each instance is composed of the matched record identified
1543 * by @p filter from 'media' table. Except that the got items pass the criterion of @p filter, they should position where the longitude
1544 * is between @p min_longitude and @p max_longitude, and the latitude is between @p min_latitude and @p max_latitude.
1545 * This function gets 'Mitem' list matched with latitude, longitude, filter and cluster id.
1546 * @param mb_svc_handle [in] the handle of DB
1547 * @param cluster_id [in] indicate the value, 'fold_id' field in 'media' table record
1548 * @param filter [in] specified filter to get matched media record
1549 * @param store_filter [in] specified storage filter to get matched media record
1550 * @param min_longitude [in] minimum value of 'longitude' field in 'vidoe_meta'/'image_meta' table
1551 * @param max_longitude [in] maximum value of longitude field in 'vidoe_meta'/'image_meta' table
1552 * @param min_latitude [in] minimum value of 'latitude' field in 'video_meta'/'image_meta' record
1553 * @param max_latitude [in] maximum value of 'latitude' field in 'video_meta'/'image_meta' record
1554 * @param func [in] Iterative callback implemented by a user. This callback is called when an item has to be inserted to user's list.
1555 * @param user_data [out] user's data structure to contain items of the type Mitem. It is passed to the iterative callback.
1556 * @return This function returns 0 on success, or negative value with error code.
1557 * @remarks item type in list is pointer to structure Mitem,
1558 * when free list, it need free every item first and then free list itself.
1565 #include <media-svc.h>
1567 int mitem_ite_cb(Mitem *item, void *user_data)
1569 GList** list = (GList**)user_data;
1570 *list = g_list_append(*list, item);
1573 void test_minfo_get_geo_item_list(MediaSvcHandle *mb_svc_handle)
1576 const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
1577 int min_longitude = 120.0;
1578 int max_longitude = 123.0;
1579 int min_latitude = 19.0;
1580 int max_latitude = 24.0;
1581 GList *p_list = NULL;
1583 //get a linked list which include a set of items based on their location.
1584 ret = minfo_get_geo_item_list(mb_svc_handle,
1595 printf("minfo_get_geo_item_list failed\n");
1603 minfo_get_geo_item_list(MediaSvcHandle *mb_svc_handle,
1604 const char *cluster_id,
1605 minfo_folder_type store_filter,
1606 minfo_item_filter filter,
1607 double min_longitude,
1608 double max_longitude,
1609 double min_latitude,
1610 double max_latitude,
1611 minfo_item_ite_cb func,
1617 * minfo_get_thumb_path
1618 * This function gets thumbnail path of specified image file. When user could get the full pathname of a image content.
1619 * He/She wants to get the thumbnail file corresponding to the image content identified by the @p file_url.
1620 * User is responsible for allocating the memory for @p thumb_path so that this function could fill up the thumbnail pathname to it.
1621 * @param mb_svc_handle [in] the handle of DB
1622 * @param file_url [in] local file full path, identify a media record in 'media' table
1623 * @param thumb_path [out] the returned thumbnail path of specified file, user is responsible for allocating memory for it first
1624 * @param max_thumb_path [in] The max length of the returned thumbnail path
1626 * @return This function returns 0 on success, or negative value with error code.
1627 * @remarks one file full path always matches one thumbnail path,
1628 here, it returns thumbnail path , but maybe thumbnail file doesn't exist, return NULL.
1629 * @see minfo_get_thumb_path_for_video.
1635 #include <media-svc.h>
1637 void test_minfo_get_thumb_path(MediaSvcHandle *mb_svc_handle)
1640 char thumb_path[256] = {'\0'};
1641 char *file_url = "/opt/media/Images/Wallpapers/Home_01.png";
1643 //get thumbnail pathname of an item.
1644 ret = minfo_get_thumb_path(mb_svc_handle, file_url, thumb_path, sizeof(thumb_path));
1646 printf("minfo_get_thumb_path failed\n");
1654 minfo_get_thumb_path(MediaSvcHandle *mb_svc_handle, const char* file_url, char* thumb_path, size_t max_thumb_path);
1657 * minfo_get_thumb_path_for_video
1658 * This function gets thumbnail path of specified video file. When user could get the full pathname of a video content.
1659 * He/She wants to get the thumbnail file corresponding to the video content identified by the @p file_url.
1660 * User is responsible for allocating the memory for @p thumb_path so that this function could fill up the thumbnail pathname to it.
1661 * @param mb_svc_handle [in] the handle of DB
1662 * @param file_url [in] local file full path, identify a media record in 'media' table
1663 * @param thumb_path [out] the returned thumbnail path of specified file, user is responsible for allocating memory for it first
1664 * @param max_thumb_path [in] The max length of the returned thumbnail path
1666 * @return This function returns 0 on success, or negative value with error code.
1667 * @remarks one file full path always matches one thumbnail path,
1668 here, it returns thumbnail path , but maybe thumbnail file doesn't exist, return NULL.
1669 * @see minfo_get_thumb_path.
1675 #include <media-svc.h>
1677 void test_minfo_get_thumb_path_for_video(MediaSvcHandle *mb_svc_handle)
1680 char thumb_path[256] = {'\0'};
1681 char *file_url = "/opt/media/Images and videos/My video clip/Helicopter.mp4";
1683 //get thumbnail pathname of an item.
1684 ret = minfo_get_thumb_path_for_video(mb_svc_handle, file_url,thumb_path, sizeof(thumb_path));
1686 printf("minfo_get_thumb_path_for_video failed\n");
1694 minfo_get_thumb_path_for_video(MediaSvcHandle *mb_svc_handle, const char* file_url, char* thumb_path, size_t max_thumb_path);
1697 * minfo_delete_media_id
1698 * This function deletes matched record identified by the @p media_id from 'media' table , 'video_meta'/'image_meta' record.
1699 * After that, if the folder which this deleted file is in becomes empty, then delete the folder record from 'folder' table, too.
1700 * In order that user could successfully delete the corresponding record from 'media' table, he/she should be able to the correct _id
1701 * of media content before it.
1703 * @param mb_svc_handle [in] the handle of DB
1704 * @param media_id [in] represent the value, media '_id' in 'media' table record
1705 * @return This function returns 0 on success, or negative value with error code.
1707 * @see minfo_delete_media.
1713 #include <media-svc.h>
1715 void test_minfo_delete_media_id(MediaSvcHandle *mb_svc_handle)
1718 const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
1720 //delete an item according to its ID.
1721 ret = minfo_delete_media_id(mb_svc_handle, media_id);
1723 printf("test_minfo_delete_media_id failed\n");
1731 minfo_delete_media_id(MediaSvcHandle *mb_svc_handle, const char *media_id);
1734 * minfo_delete_all_media_records:\n
1735 * This function delete all media records in a type of storage like phone or MMC.
1736 * This function is always used for MMC card insert/inject operation, in file manager service library.
1738 * @param mb_svc_handle [in] the handle of DB
1739 * @param storage_type [in] information for storage type
1740 * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
1741 * Please refer 'media-svc-error.h' to know the exact meaning of the error.
1749 #include <media-svc.h>
1751 void test_minfo_delete_all_media_records(MediaSvcHandle *mb_svc_handle)
1753 int ret = MB_SVC_ERROR_NONE;
1755 //delete all media records in MMC storage in db.
1756 ret = minfo_delete_all_media_records(mb_svc_handle, MINFO_MMC);
1758 printf( "failed to delete items. error code->%d", ret);
1767 minfo_delete_all_media_records(MediaSvcHandle *mb_svc_handle, const minfo_store_type storage_type);
1771 * This function copies specified media file to another folder, which is identified by the folder id, @p dst_cluster_id. Meanwhile the copied media file
1772 * is identified by it's media id. Compared to API, minfo_copy_media, the different is , this function copy a media content to specified folder,
1773 * according to the media content id and the destination folder's id, however the function, minfo_copy_media, copy a media content to specified folder
1774 * according to the media file's full pathname and folder's full name.
1775 * @param mb_svc_handle [in] the handle of DB
1776 * @param src_media_id [in] id of the source media file, it's value is from '_id' field of the 'media' table
1777 * @param dst_cluster_id [in] id of the destination folder, it's value is from '_id' field of the 'folder' table
1778 * @return This function returns 0 on success, or negative value with error code.
1779 * @remarks This function will implement the same functionality as minfo_copy_media.
1780 * @see minfo_copy_media
1786 #include <media-svc.h>
1788 void test_minfo_cp_media(MediaSvcHandle *mb_svc_handle)
1791 const char *src_media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
1792 const char *dst_cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
1794 //copy the a media file whose ID is specified by, 'src_media_id', to a cluster.
1795 ret = minfo_cp_media(mb_svc_handle, src_media_id, dst_cluster_id);
1797 printf("minfo_cp_media failed\n");
1805 minfo_cp_media(MediaSvcHandle *mb_svc_handle, const char *src_media_id, const char *dst_cluster_id);
1811 * This function moves specified media file to another folder, which is identified by the folder id, @p dst_cluster_id. Meanwhile the moved media file
1812 * is identified by it's media id. Compared to API, minfo_move_media, the difference is that this function moves a media content to specified folder,
1813 * according to the media content id and the destination folder's id, however the function, minfo_move_media, move a media content to specified folder
1814 * according to the media file's full pathname and folder's full name.
1815 * @param mb_svc_handle [in] the handle of DB
1816 * @param src_media_id [in] id of the source media file, it's value is from '_id' field of the 'media' table
1817 * @param dst_cluster_id [in] id of the destination folder, it's value is from '_id' field of the 'folder'
1818 * @return This function returns 0 on success, or negative value with error code.
1820 * @see minfo_move_media.
1826 #include <media-svc.h>
1828 void test_minfo_mv_media(MediaSvcHandle *mb_svc_handle)
1831 const char *src_media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
1832 const char *dst_cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
1834 //move an item to specified cluster.
1835 ret = minfo_mv_media(mb_svc_handle, src_media_id, dst_cluster_id);
1837 printf("minfo_mv_media failed\n");
1846 minfo_mv_media(MediaSvcHandle *mb_svc_handle, const char *src_media_id, const char *dst_cluster_id);
1851 * minfo_delete_cluster
1852 * This function deletes specified cluster, which is identified by the @p cluster_id. When user launch Gallery and in edit 'Albums' mode, if he/she
1853 * want to delete a cluster/folder, so call this function to do it. When delete a cluster/folder, the media-svc will not only delete the record in 'folder' table,
1854 * but delete all of records in 'media' table which are located in this folder, meanwhile delete the corresponding records in 'video_bookmark' table, etc.
1855 * @param mb_svc_handle [in] the handle of DB
1856 * @param cluster_id [in] cluster id, to indicate the deleted folder/cluster
1857 * @return This function returns 0 on success, or negative value with error code.
1858 * @remarks delete all releated contents in cluster together with cluster
1859 * like all media files, image/video meta,bookmark information.
1860 * @see minfo_add_cluster
1867 #include <media-svc.h>
1869 void test_minfo_delete_cluster(MediaSvcHandle *mb_svc_handle)
1872 const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
1874 //delete a cluster record, meanwhile this function will delete all of items owned by this cluster.
1875 ret = minfo_delete_cluster(mb_svc_handle, cluster_id);
1877 printf("minfo_delete_cluster failed\n");
1885 minfo_delete_cluster(MediaSvcHandle *mb_svc_handle, const char *cluster_id);
1890 * minfo_update_cluster_name
1891 * This function updates the specified cluster name using @p new_name, which just indicate the new folder name. User could
1892 * call this function, when he/she wants to change some folder/cluster name. This really update the corresponding record in
1894 * @param mb_svc_handle [in] the handle of DB
1895 * @param cluster_id [in] cluster id, this value is from the '_id' field of 'folder' table
1896 * @param new_name [in] new cluster name
1897 * @return This function returns 0 on success, or negative value with error code.
1905 #include <media-svc.h>
1907 void test_minfo_update_cluster_name(MediaSvcHandle *mb_svc_handle)
1910 const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
1911 char *new_name = "newfolder";
1913 //update a cluster's name
1914 ret = minfo_update_cluster_name(mb_svc_handle, cluster_id,new_name);
1916 printf("minfo_update_cluster_name failed\n");
1924 minfo_update_cluster_name(MediaSvcHandle *mb_svc_handle, const char *cluster_id, const char* new_name);
1927 * minfo_update_cluster_date
1928 * This function updates the specified cluster modified date using @p modified_date, which just indicate the new modified date. User could
1929 * call this function, when he/she wants to change some clsuter's modified date. This really update the corresponding record in the DB
1930 * @param mb_svc_handle [in] the handle of DB
1931 * @param cluster_id [in] cluster id, this value is the identifier of the cluster
1932 * @param modified_date [in] date to modify, which is a type of time_t
1933 * @return This function returns zero(MB_SVC_ERROR_BASE) on success, or negative value with error code.
1934 * Please refer 'media-svc-error.h' to know the exact meaning of the error.
1942 #include <media-svc.h>
1945 void test_minfo_update_cluster_date(void)
1948 const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
1952 //update a cluster's name
1953 ret = minfo_update_cluster_date(cluster_id, today);
1956 printf("minfo_update_cluster_date failed\n");
1964 minfo_update_cluster_date(MediaSvcHandle *mb_svc_handle, const char *cluster_id, time_t modified_date);
1969 * minfo_add_bookmark
1970 * This function inserts new bookmark record into 'video_bookmark' table. The inserted data should include marked time of video content, @p position
1971 * and @p thumb_path, current extracted thumbnail file in marked time, etc. User should use @p media_id to identify the
1972 * video content, so that add bookmark to it.
1973 * @param mb_svc_handle [in] the handle of DB
1974 * @param media_id [in] media file id, uniquely identify the media content
1975 * @param position [in] marked time of the media file
1976 * @param thumb_path [in] the extracted thumbnail path for this marked time
1977 * @return This function returns 0 on success, or negative value with error code.
1978 * @remarks if add same input parameters twice, it fails
1979 * @see minfo_delete_bookmark
1986 #include <media-svc.h>
1988 void test_minfo_add_bookmark(MediaSvcHandle *mb_svc_handle)
1991 int position = 2346;
1992 const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
1993 char *thumb_path = "tmp1";
1995 //add a bookmark which include position, thumbnail, etc. to an item.
1996 ret = minfo_add_bookmark(mb_svc_handle, media_id,position,thumb_path);
1998 printf("minfo_add_bookmark failed\n");
2007 minfo_add_bookmark(MediaSvcHandle *mb_svc_handle, const char *media_id, const int position, const char* thumb_path);
2011 * minfo_delete_bookmark
2012 * This function deletes specified bookmark record from 'video_bookmark' table, the deleted bookmark should be identified by @p bookmark_id.
2013 * This function actually call the sqlite3 statement,
2014 * "DELETE FROM video_bookmark WHERE _id = bookmark_id; "
2015 * In gallery or ug-imageviewer, user could get a linked list bookmark for some media file, so he/she could delete one of them using @p bookmark_id.
2017 * @param mb_svc_handle [in] the handle of DB
2018 * @param bookmark_id [in] _id field in video_bookmark table.
2019 * @return This function returns 0 on success, or negative value with error code.
2020 * @remarks user should give a correct bookmark ID to successfully delete it.
2021 * @see minfo_add_bookmark
2028 #include <media-svc.h>
2030 void test_minfo_delete_bookmark(MediaSvcHandle *mb_svc_handle)
2033 int bookmark_id = 1;
2035 //delete a bookmark record in 'video_bookmark' table.
2036 ret = minfo_delete_bookmark(mb_svc_handle, bookmark_id);
2039 printf("minfo_delete_bookmark failed\n");
2047 minfo_delete_bookmark(MediaSvcHandle *mb_svc_handle, const int bookmark_id);
2053 * minfo_get_cluster_id_by_url
2054 * This function gets some folder's full path. This will be called when user want to know what one folder's unique
2057 * @return This function returns 0 on success, and -1 on failure.
2058 * @param mb_svc_handle [in] the handle of DB
2059 * @param url [in] folder path
2060 * @param cluster_id [out] folder ID
2069 #include <media-svc.h>
2071 void test_minfo_get_cluster_id_by_url(MediaSvcHandle *mb_svc_handle)
2074 char cluster_id[256] = {0,};
2075 char *url = "/opt/media/Images/Wallpapers";
2077 //get cluster's ID using cluster's url.
2078 ret = minfo_get_cluster_id_by_url(url, cluster_id, sizeof(mb_svc_handle, cluster_id));
2080 printf("test_minfo_get_cluster_id_by_url failed\n");
2087 minfo_get_cluster_id_by_url(MediaSvcHandle *mb_svc_handle, const char* url, char* cluster_id, int max_length);
2091 * minfo_get_cluster_name_by_id
2092 * This function gets folder's name. This will be called when user want to know what one folder's name
2094 * @return This function returns 0 on success, and -1 on failure.
2095 * @param[in] mb_svc_handle the handle of DB
2096 * @param[in] cluster_id folder ID
2097 * @param[out] cluster_name folder name
2098 * @param[in] max_length The max length of the returned folder name.
2107 #include <media-svc.h>
2109 void test_minfo_get_cluster_name_by_id(MediaSvcHandle *mb_svc_handle)
2112 const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
2113 char *cluster_name[1024];
2115 //get cluster's name using cluster's id.
2116 ret = minfo_get_cluster_name_by_id(mb_svc_handle, cluster_id, cluster_name, sizeof(cluster_name));
2119 printf("test_minfo_get_cluster_name_by_id failed\n");
2122 printf("cluster name is %s\n", cluster_name);
2129 minfo_get_cluster_name_by_id(MediaSvcHandle *mb_svc_handle, const char *cluster_id, char *cluster_name, int max_length );
2132 * minfo_get_cluster_fullpath_by_id
2133 * This function gets folder's full path. This will be called when user want to know what one folder's full path.
2134 * User should specify the maximum length of the @p folder_path, so as to avoid over flow of the string.
2136 * @return This function returns 0 on success, and -1 on failure.
2137 * @param[in] mb_svc_handle the handle of DB
2138 * @param[in] cluster_id folder ID
2139 * @param[out] folder_path folder path name
2140 * @param[in] max_length specify the maximum length of @p folder_path.
2149 #include <media-svc.h>
2151 void test_minfo_get_cluster_fullpath_by_id(MediaSvcHandle *mb_svc_handle)
2154 const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
2155 char *folder_path[1024];
2157 //get cluster's path name using cluster's id.
2158 ret = minfo_get_cluster_fullpath_by_id(mb_svc_handle, cluster_id, folder_path, sizeof(folder_path));
2161 printf("test_minfo_get_cluster_fullpath_by_id failed\n");
2164 printf("path name is %s\n", cluster_name);
2172 minfo_get_cluster_fullpath_by_id(MediaSvcHandle *mb_svc_handle, const char *cluster_id, char *folder_path, int max_length);
2177 * minfo_set_cluster_lock_status
2178 * @fn int minfo_set_cluster_lock_status( int cluster_id, int lock_status );
2179 * This function set status for lock to DB. This will be called when user want to set to lock an album.
2181 * @return This function returns 0 on success, and -1 on failure.
2182 * @param[in] mb_svc_handle the handle of DB
2183 * @param[in] cluster_id folder ID
2184 * @param[in] lock_status status for lock to be saved ( 0 : unlock, 1 : lock )
2187 * @see minfo_get_cluster_lock_status.
2193 #include <media-svc.h>
2195 void test_minfo_set_cluster_lock_status(MediaSvcHandle *mb_svc_handle)
2199 const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
2201 //set s cluster lock status.
2202 ret = minfo_set_cluster_lock_status(mb_svc_handle, cluster_id, status);
2205 printf("test_minfo_set_cluster_lock_status failed\n");
2213 minfo_set_cluster_lock_status(MediaSvcHandle *mb_svc_handle, const char *cluster_id, int lock_status);
2216 * minfo_get_cluster_lock_status
2217 * @fn int minfo_get_cluster_lock_status( int cluster_id, int *lock_status );
2218 * This function gets status for lock from DB. This will be called when user want to get lock status for an album.
2220 * @return This function returns 0 on success, and -1 on failure.
2221 * @param[in] mb_svc_handle the handle of DB
2222 * @param[in] cluster_id folder ID
2223 * @param[out] lock_status status for cuurent lock status
2226 * @see minfo_set_cluster_lock_status.
2232 #include <media-svc.h>
2234 void test_minfo_get_cluster_lock_status(MediaSvcHandle *mb_svc_handle)
2237 const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
2240 //get a cluster's status.
2241 ret = minfo_get_cluster_lock_status(mb_svc_handle, cluster_id, &status);
2244 printf("test_minfo_get_cluster_lock_status failed\n");
2247 print("Current status : %d\n", status);
2255 minfo_get_cluster_lock_status(MediaSvcHandle *mb_svc_handle, const char *cluster_id, int *lock_status );
2258 * @fn int minfo_get_media_path( minfo_store_type storage_type, char* media_path, size_t max_media_path);
2259 * This function gets the path of media. This will be called when user want to get path of direcotry containing media in device.
2261 * @return This function returns 0 on success, and -1 on failure.
2262 * @param[in] storage_type store type, which means type of device containg media.
2263 * @param[out] media_path path of media
2264 * @param[in] max_media_path The max length of the returned media_path.
2273 #include <media-svc.h>
2275 void test_minfo_get_media_path(void)
2278 char media_path[256] = {'\0'};
2280 //get media's fullpath.
2281 ret = minfo_get_media_path(MINFO_PHONE, media_path, sizeof(media_path));
2284 printf("minfo_get_media_path failed\n");
2287 print("The returned path : %s\n", media_path);
2295 minfo_get_media_path(minfo_store_type storage_type, char* media_path, size_t max_media_path );
2299 * minfo_set_db_valid
2300 * This function set whether all the media contents in a type of storage are valid, like phone or MMC.
2301 * Actually media service will filter all the media contents query from database by the media validation.
2302 * This function is always used for MMC card insert/inject operation, in file manager service library.
2303 * When inject a MMC card, the media records for MMC are not deleted really, but are set to be invalid.
2305 * @param[in] mb_svc_handle the handle of DB
2306 * @param[in] storage_type information for storage type
2307 * @param[in] valid whether the track item is valid.
2308 * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
2309 * Please refer 'media-svc-error.h' to know the exact meaning of the error.
2310 * @see minfo_delete_invalid_media_records.
2317 #include <media-svc.h>
2319 void set_db_valid(MediaSvcHandle *mb_svc_handle)
2321 int ret = MB_SVC_ERROR_NONE;
2324 //set the validation of medias in MMC storage in db.
2325 ret = minfo_set_db_valid(mb_svc_handle, MINFO_MMC, valid);
2327 printf( "failed to set db invalid. error code->%d", ret);
2335 int minfo_set_db_valid(MediaSvcHandle *mb_svc_handle, const minfo_store_type storage_type, int valid);
2338 * minfo_set_item_valid_start
2339 * This function set whether the media content in a type of storage is valid, like phone or MMC.
2340 * Actually media service will filter all the media contents query from database by the media validation.
2342 * @param[in] mb_svc_handle the handle of DB
2343 * @param[in] trans_count count of trasaction user wants
2344 * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
2345 * Please refer 'media-svc-error.h' to know the exact meaning of the error.
2346 * @see minfo_set_item_valid, minfo_set_item_valid_end
2353 #include <media-svc.h>
2355 void set_item_valid_batch(MediaSvcHandle *mb_svc_handle)
2358 int ret = MB_SVC_ERROR_NONE;
2361 ret = minfo_set_item_valid_start(mb_svc_handle, 100);
2363 printf( "minfo_set_item_valid_start failed. error code->%d", ret);
2367 for (i = 0; i < 200; i++) {
2368 //set the validation of a media in MMC storage in db.
2369 ret = minfo_set_item_valid(mb_svc_handle, MINFO_MMC, image_files[i], valid);
2371 printf( "failed to set item valid. error code->%d", ret);
2376 ret = minfo_set_item_valid_end(mb_svc_handle);
2378 printf( "minfo_set_item_valid_end failed. error code->%d", ret);
2388 int minfo_set_item_valid_start(MediaSvcHandle *mb_svc_handle, int trans_count);
2392 * minfo_set_item_valid_end
2393 * This function set whether the media content in a type of storage is valid, like phone or MMC.
2394 * Actually media service will filter all the media contents query from database by the media validation.
2396 * @param[in] mb_svc_handle the handle of DB
2397 * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
2398 * Please refer 'media-svc-error.h' to know the exact meaning of the error.
2399 * @see minfo_set_item_valid_start, minfo_set_item_valid
2406 #include <media-svc.h>
2408 void set_item_valid_batch(MediaSvcHandle *mb_svc_handle)
2411 int ret = MB_SVC_ERROR_NONE;
2414 ret = minfo_set_item_valid_start(mb_svc_handle, 100);
2416 printf( "minfo_set_item_valid_start failed. error code->%d", ret);
2420 for (i = 0; i < 200; i++) {
2421 //set the validation of a media in MMC storage in db.
2422 ret = minfo_set_item_valid(mb_svc_handle, MINFO_MMC, image_files[i], valid);
2424 printf( "failed to set item valid. error code->%d", ret);
2429 ret = minfo_set_item_valid_end(mb_svc_handle);
2431 printf( "minfo_set_item_valid_end failed. error code->%d", ret);
2440 int minfo_set_item_valid_end(MediaSvcHandle *mb_svc_handle);
2444 * minfo_set_item_valid
2445 * This function set whether the media content in a type of storage is valid, like phone or MMC.
2446 * Actually media service will filter all the media contents query from database by the media validation.
2448 * @param[in] mb_svc_handle the handle of DB
2449 * @param[in] storage_type information for storage type
2450 * @param[in] full_path The path of the media
2451 * @param[in] valid whether the track item is valid.
2452 * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
2453 * Please refer 'media-svc-error.h' to know the exact meaning of the error.
2454 * @see minfo_set_item_valid_start, minfo_set_item_valid_end
2461 #include <media-svc.h>
2463 void set_item_valid_batch(MediaSvcHandle *mb_svc_handle)
2466 int ret = MB_SVC_ERROR_NONE;
2469 ret = minfo_set_item_valid_start(mb_svc_handle, 100);
2471 printf( "minfo_set_item_valid_start failed. error code->%d", ret);
2475 for (i = 0; i < 200; i++) {
2476 //set the validation of a media in MMC storage in db.
2477 ret = minfo_set_item_valid(mb_svc_handle, MINFO_MMC, image_files[i], valid);
2479 printf( "failed to set item valid. error code->%d", ret);
2484 ret = minfo_set_item_valid_end(mb_svc_handle);
2486 printf( "minfo_set_item_valid_end failed. error code->%d", ret);
2497 int minfo_set_item_valid(MediaSvcHandle *mb_svc_handle,
2498 const minfo_store_type storage_type,
2499 const char *full_path,
2504 * minfo_delete_invalid_media_records
2505 * This function delete all of invalid media records in a type of storage are valid, like phone or MMC.
2506 * Actually media service will filter all the media contents query from database by the media validation.
2507 * This function is always used for MMC card insert/inject operation, in file manager service library.
2508 * When inject a MMC card, the media records for MMC are not deleted really, but are set to be invalid.
2510 * @param[in] mb_svc_handle the handle of DB
2511 * @param[in] storage_type information for storage type
2512 * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
2513 * Please refer 'media-svc-error.h' to know the exact meaning of the error.
2514 * @see minfo_set_db_valid.
2521 #include <media-svc.h>
2523 void test_minfo_delete_invalid_media_records(MediaSvcHandle *mb_svc_handle)
2525 int ret = MB_SVC_ERROR_NONE;
2527 //delete the invalid media records in MMC storage in db.
2528 ret = minfo_delete_invalid_media_records(mb_svc_handle, MINFO_MMC);
2530 printf( "failed to delete invalid items. error code->%d", ret);
2539 minfo_delete_invalid_media_records(MediaSvcHandle *mb_svc_handle, const minfo_store_type storage_type);
2543 * This function could delete a tag or some member of the tag in 'media_tag' table in database. When user pass @p media_id not equal
2544 * to -1, the tag will be deleted, otherwise some member of the tag will be deleted. Whatever cases, user should pass the correct tag name with
2545 * @p tag_name to successfully delete.
2547 * @param[in] mb_svc_handle the handle of DB
2548 * @param[in] media_id identify a media item with this ID
2549 * @param[in] tag_name name of deleted tag
2550 * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
2551 * Please refer 'media-svc-error.h' to know the exact meaning of the error.
2559 #include <media-svc.h>
2561 void delete_a_tag(MediaSvcHandle *mb_svc_handle)
2563 int ret = MB_SVC_ERROR_NONE;
2565 //delete all tag records in 'media_tag' in db, whose tag name is 'test_tag'.
2566 ret = minfo_delete_tag(mb_svc_handle, -1, "test tag");
2568 printf( "failed to delete a tag record. error code->%d", ret);
2577 minfo_delete_tag(MediaSvcHandle *mb_svc_handle, const char *media_id, const char* tag_name);
2582 * This function could rename a tag_name to another tag_name in 'media_tag' table in database. User need to pass @p src_tagname which indicate original
2583 * tag name, @p dst_tag_name which is new tag name replacing @p src_tagname. This function will check whether the new tag name, @p dst_tag_name, has
2584 * existed in 'media_tag' table. If yes, this function will item by item replace old tag name, if no, this function will directly update old tag name to new tag name.
2586 * @param[in] mb_svc_handle the handle of DB
2587 * @param[in] src_tagname identify original tag name
2588 * @param[in] dst_tag_name new tag name.
2589 * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
2590 * Please refer 'media-svc-error.h' to know the exact meaning of the error.
2598 #include <media-svc.h>
2600 void test_minfo_rename_tag(MediaSvcHandle *mb_svc_handle)
2602 int ret = MB_SVC_ERROR_NONE;
2604 //rename all tag records with new tag name 'test_tag2'.
2605 ret = minfo_rename_tag(mb_svc_handle, "test tag1", "test tag2");
2607 printf( "failed to rename tag records. error code->%d", ret);
2616 minfo_rename_tag(MediaSvcHandle *mb_svc_handle, const char* src_tagname, const char* dst_tag_name);
2619 * minfo_rename_tag_by_id:
2620 * This function could rename a tag_name for some tag record to another tag_name in 'media_tag' table in database. User need to pass @p src_tagname which indicate original
2621 * tag name, @p media_id which combine with the @p src_tagname to indentify one tag record, @p dst_tag_name which is new tag name replacing @p src_tagname.
2622 * This function will check whether the new tag name with @p media_id has existed in 'media_tag' table. If yes, this function will delete old tag record, if no, this function will directly
2623 * update old tag record to new tag record.
2625 * @param[in] mb_svc_handle the handle of DB
2626 * @param[in] media_id identify original tag record with @p src_tagname
2627 * @param[in] src_tagname identify original tag record with @p media_id
2628 * @param[in] dst_tag_name new tag name.
2629 * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
2630 * Please refer 'media-svc-error.h' to know the exact meaning of the error.
2638 #include <media-svc.h>
2640 void test_minfo_rename_tag_by_id(MediaSvcHandle *mb_svc_handle)
2642 int ret = MB_SVC_ERROR_NONE;
2643 const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
2645 //rename some tag record with new tag name 'test_tag2'.
2646 ret = minfo_rename_tag_by_id(mb_svc_handle, media_id, "test tag1", "test tag2");
2648 printf( "failed to rename tag records. error code->%d", ret);
2657 minfo_rename_tag_by_id(MediaSvcHandle *mb_svc_handle, const char *media_id, const char* src_tagname, const char* dst_tag_name);
2664 * This function could add a new tag into 'media_tag' table in database. When user create a new tag and will
2665 * not add any media item to it, he/she should set @p media_id as 0. When user create a new tag and want to add
2666 * some media items to it, he/she should do a loop to insert them into 'media_tag' table in database, meanwhile
2667 * should fill up @p media_id and @p tag_name with appropriate values.
2669 * @param[in] mb_svc_handle the handle of DB
2670 * @param[in] media_id identify a media item with this ID
2671 * @param[in] tag_name name of new added tag
2672 * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
2673 * Please refer 'media-svc-error.h' to know the exact meaning of the error.
2681 #include <media-svc.h>
2683 void add_a_tag(MediaSvcHandle *mb_svc_handle)
2685 int ret = MB_SVC_ERROR_NONE;
2687 //add a tag record in 'media_tag' in db, and not add any media item to it.
2688 ret = minfo_add_tag(mb_svc_handle, NULL, "test tag");
2691 printf( "failed to add a tag record. error code->%d", ret);
2702 minfo_add_tag(MediaSvcHandle *mb_svc_handle, const char *media_id, const char* tag_name);
2705 * minfo_get_media_list_by_tagname:
2706 * This function could get a media items' list who are included to the same tag according to tag name .
2707 * User could dictate whether he/she hope to get meta data of media item with @p with_meta. Yes if TRUE,
2710 * @param[in] mb_svc_handle the handle of DB
2711 * @param[in] tag_name tag name
2712 * @param[in] with_meta indicate whether want to get meta data of media item
2713 * @param[in] func Iterative callback implemented by a user. This callback is called when an item has to be inserted to user's list.
2714 * @param[out] user_data user's data structure to contain items of the type Mitem. It is passed to the iterative callback.
2715 * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
2716 * Please refer 'media-svc-error.h' to know the exact meaning of the error.
2724 #include <media-svc.h>
2726 int mitem_ite_cb(Mitem *item, void *user_data)
2728 GList** list = (GList**)user_data;
2729 *list = g_list_append(*list, item);
2733 void get_media_list_tag_name(MediaSvcHandle *mb_svc_handle)
2735 int ret = MB_SVC_ERROR_NONE;
2736 GList *p_list = NULL;
2738 //get a media items' list who are included to the same tag with 'test tag'.
2739 ret = minfo_get_media_list_by_tagname(mb_svc_handle, "test tag", FALSE, mitem_ite_cb, &p_list);
2741 printf( "failed to get a media items' list. error code->%d", ret);
2750 minfo_get_media_list_by_tagname(MediaSvcHandle *mb_svc_handle, const char* tag_name, bool with_meta, minfo_item_ite_cb func, void* user_data );
2753 * minfo_get_media_list_by_tagname_with_filter:
2754 * This function could get a media items' list who are included to the same tag according to tag name and filter.
2755 * User could dictate whether he/she hope to get meta data of media item with @p with_meta. Yes if TRUE,
2758 * @param[in] mb_svc_handle the handle of DB
2759 * @param[in] tag_name tag name
2760 * @param[in] filter the filter to specify some tag filter conditions, like, type of got items, sort by type, start and end positions of items, including meta data or not, etc.
2761 * @param[in] func Iterative callback implemented by a user. This callback is called when an item has to be inserted to user's list.
2762 * @param[out] user_data user's data structure to contain items of the type Mitem. It is passed to the iterative callback.
2763 * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
2764 * Please refer 'media-svc-error.h' to know the exact meaning of the error.
2772 #include <media-svc.h>
2774 int mitem_ite_cb(Mitem *item, void *user_data)
2776 GList** list = (GList**)user_data;
2777 *list = g_list_append(*list, item);
2781 void get_media_list_by_tagname_with_filter(MediaSvcHandle *mb_svc_handle)
2783 int ret = MB_SVC_ERROR_NONE;
2784 GList *p_list = NULL;
2785 minfo_tag_filter filter;
2787 filter.start_pos = 0;
2789 filter.file_type = MINFO_ITEM_ALL;
2790 filter.with_meta = FALSE;
2792 //get a media items' list who are included to the same tag with 'test tag'.
2793 ret = minfo_get_media_list_by_tagname_with_filter(mb_svc_handle, "test tag", filter, mitem_ite_cb, &p_list);
2795 printf( "failed to get a media items' list. error code->%d", ret);
2804 minfo_get_media_list_by_tagname_with_filter(MediaSvcHandle *mb_svc_handle, const char* tag_name, minfo_tag_filter filter, minfo_item_ite_cb func, void* user_data );
2807 * minfo_get_media_count_by_tagname:
2808 * This function could get count of media items, which are included to the same tag according to tag name .
2809 * User could dictate whether he/she hope to get count of media items.
2811 * @param[in] mb_svc_handle the handle of DB
2812 * @param[in] tag_name tag name
2813 * @param[out] count count of media items
2814 * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
2815 * Please refer 'media-svc-error.h' to know the exact meaning of the error.
2823 #include <media-svc.h>
2825 void test_minfo_get_media_count_by_tagname(MediaSvcHandle *mb_svc_handle)
2827 int ret = MB_SVC_ERROR_NONE;
2830 //get count of media items, which are included to the same tag with 'test tag'.
2831 ret = minfo_get_media_count_by_tagname(mb_svc_handle, "test tag", &count);
2833 printf( "failed to get a media items' list. error code->%d", ret);
2835 printf( "Count is %d\n", count );
2845 minfo_get_media_count_by_tagname(MediaSvcHandle *mb_svc_handle, const char* tag_name, int* count );
2848 * minfo_get_tag_list_by_media_id:
2849 * This function could get a tags' list whose memeber is Mtag type. User should pass @p media_id to indicate which
2850 * media item will be searched. Also he/she should define a callback function to be called by this function.
2852 * @param[in] mb_svc_handle the handle of DB
2853 * @param[in] media_id identify a media item with ID
2854 * @param[in] func Iterative callback implemented by a user. This callback is called when an item has to be inserted to user's list.
2855 * @param[out] user_data user's data structure to contain items of the type Mtag. It is passed to the iterative callback.
2856 * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
2857 * Please refer 'media-svc-error.h' to know the exact meaning of the error.
2858 * @see minfo_set_db_valid.
2865 #include <media-svc.h>
2867 int mtag_ite_cb(Mtag *i_tag, void *user_data)
2869 GList** list = (GList**)user_data;
2870 *list = g_list_append(*list, item);
2874 void get_tag_list_media_id(MediaSvcHandle *mb_svc_handle)
2876 int ret = MB_SVC_ERROR_NONE;
2877 const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
2878 GList *p_list = NULL;
2880 //get a tags' list which include the same media item and it's media_id is b6a4f4ac-26ea-458c-a228-9aef7f70349d.
2881 ret = minfo_get_tag_list_by_media_id(mb_svc_handle, media_id, mtag_ite_cb, &p_list);
2883 printf( "failed to get a tags' list. error code->%d", ret);
2892 minfo_get_tag_list_by_media_id(MediaSvcHandle *mb_svc_handle, const char *media_id, minfo_tag_ite_cb func, void* user_data);
2895 * minfo_add_web_cluster
2896 * This function could add a web album through specifying it's @p name, @p account_id. After adding a web
2897 * album, this function will return @p id.
2899 * @param[in] mb_svc_handle the handle of DB
2900 * @param[in] sns_type sns type, like, facebook, flickr, etc.
2901 * @param[in] name new added web album's name.
2902 * @param[in] account_id account ID.
2903 * @param[out] id return album's id.
2904 * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
2905 * Please refer 'media-svc-error.h' to know the exact meaning of the error.
2906 * @see minfo_add_web_cluster_album_id.
2913 #include <media-svc.h>
2916 void add_web_cluster(MediaSvcHandle *mb_svc_handle)
2918 int ret = MB_SVC_ERROR_NONE;
2919 char cluster_id[256] = {0,};
2922 ret = minfo_add_web_cluster(mb_svc_handle, 1, "web_album", "1", cluster_id, sizeof(cluster_id));
2924 printf( "failed to add a web album. error code->%d", ret);
2934 minfo_add_web_cluster(MediaSvcHandle *mb_svc_handle, int sns_type, const char* name,const char *account_id, char* id, int max_length);
2938 * minfo_add_web_cluster_album_id
2939 * This function could add a web album through specifying it's @p name, @p account_id, @p album_id. After adding a web
2940 * album, this function will return @p id.
2942 * @param[in] mb_svc_handle the handle of DB
2943 * @param[in] sns_type sns type, like, facebook, flickr, etc.
2944 * @param[in] name new added web album's name.
2945 * @param[in] account_id account ID.
2946 * @param[in] album_id web album id
2947 * @param[out] id return album's id.
2948 * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
2949 * Please refer 'media-svc-error.h' to know the exact meaning of the error.
2950 * @see minfo_add_web_cluster.
2957 #include <media-svc.h>
2960 void add_web_cluster_album_id(MediaSvcHandle *mb_svc_handle)
2962 int ret = MB_SVC_ERROR_NONE;
2963 char cluster_id[256] = {0,};
2966 ret = minfo_add_web_cluster_album_id(mb_svc_handle, 1, "web_album", "1", "1", cluster_id, sizeof(cluster_id));
2968 printf( "failed to add a web album. error code->%d", ret);
2979 minfo_add_web_cluster_album_id(MediaSvcHandle *mb_svc_handle, int sns_type, const char* name, const char *account_id, const char *album_id, char *id, int max_length);
2982 * minfo_delete_web_cluster
2983 * This function could delete a web album through specifying @p cluster_id. After deleteing a web
2984 * album, the application will not be able to get this web album displaying.
2986 * @param[in] mb_svc_handle the handle of DB
2987 * @param[in] cluster_id cluster ID identifying a web album.
2988 * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
2989 * Please refer 'media-svc-error.h' to know the exact meaning of the error.
2997 #include <media-svc.h>
2999 void delete_web_cluster(MediaSvcHandle *mb_svc_handle)
3001 int ret = MB_SVC_ERROR_NONE;
3002 const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
3004 //delete a web album.
3005 ret = minfo_delete_web_cluster(mb_svc_handle, cluster_id);
3007 printf( "failed to delete a web album. error code->%d", ret);
3018 minfo_delete_web_cluster(MediaSvcHandle *mb_svc_handle, const char *cluster_id);
3021 * minfo_get_web_cluster_by_web_account_id
3022 * This function gets list of mcluster by web account id. User could get the detail information with
3023 * the type 'Mcluster' about this cluster, the type 'Mcluster' mainly include folder/cluster ID, display name,
3024 * count of included media content, etc. The detail defination of this type could refer to the herder file, minfo_item/minfo-cluster.h.
3026 * @return This function returns 0 on success, or negative value with error code.
3027 * Please refer 'media-svc-error.h' to know the exact meaning of the error.
3028 * @param mb_svc_handle [in] the handle of DB
3029 * @param web_account_id [in] the web account ID which indentify a cluster
3030 * @param func [in] Iterative callback implemented by a user. This callback is called when an item has to be inserted to user's list.
3031 * @param user_data [out] user's data structure to contain items of the type Mcluster. It is passed to the iterative callback.
3033 * @remarks User could pass web account id to this function, so that
3034 * this function still could get the wanted list of clusters
3035 * when invoking this function.
3043 #include <media-svc.h>
3044 int mcluster_ite_cb(Mcluster *cluster, void *user_data)
3046 GList** list = (GList**)user_data;
3047 *list = g_list_append(*list, cluster);
3050 void test_minfo_get_web_cluster_by_web_account_id(MediaSvcHandle *mb_svc_handle)
3053 const char* account_id = "user";
3054 GList *p_list = NULL;
3056 //get a web cluster using account id.
3057 ret = minfo_get_web_cluster_by_web_account_id(mb_svc_handle, account_id, mcluster_ite_cb, &p_list);
3059 printf("minfo_get_web_cluster_by_web_account_id fail: %d \n", ret);
3067 minfo_get_web_cluster_by_web_account_id(MediaSvcHandle *mb_svc_handle, const char* web_account_id, minfo_cluster_ite_cb func, void *user_data);
3070 * minfo_get_web_cluster_web_album_id
3071 * This function gets mcluster information by web cluster id. User could get the detail information with
3072 * the type 'Mcluster' about this cluster, the type 'Mcluster' mainly include folder/cluster ID, display name,
3073 * count of included media content, etc. The detail defination of this type could refer to the herder file, minfo-cluster.h.
3075 * @return This function returns 0 on success, or negative value with error code.
3076 * @param mb_svc_handle [in] the handle of DB
3077 * @param cluster_id [in] the cluster ID which indentify a cluster
3078 * @param mcluster [out] mcluster to be returned, which is a 'Mcluster' type
3080 * @remarks User could pass cluster id to this function, so that
3081 * this function still could get the wanted cluster.
3082 * when invoking this function, *mcluster must equals NULL, and
3083 * after using mitem, it must be freed with minfo_destroy_mtype_item.
3090 #include <media-svc.h>
3092 void test_minfo_get_web_cluster_web_album_id(MediaSvcHandle *mb_svc_handle)
3095 Mcluster *mc = NULL;
3096 const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
3098 //get a cluster using cluster's id.
3099 ret = minfo_get_web_cluster_web_album_id(mb_svc_handle, cluster_id, &mc);
3101 printf("minfo_get_web_cluster_web_album_id fail: %d \n", ret);
3105 minfo_destroy_mtype_item(mc);
3111 minfo_get_web_cluster_web_album_id(MediaSvcHandle *mb_svc_handle, const char *web_album_id, Mcluster **mcluster);
3114 * minfo_add_web_media
3115 * This function could add a web media to web album specified by @p cluster_id, in addition, user need to pass @p http_url, @p file_name
3116 * @p thumb_path. If failed to add it to web album, this function will return an error code.
3118 * @param[in] mb_svc_handle the handle of DB
3119 * @param[in] cluster_id specify cluster id to indentify a web album.
3120 * @param[in] http_url web media's url.
3121 * @param[in] file_name file name.
3122 * @param[in] thumb_path thumbnail full path of this web media
3123 * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
3124 * Please refer 'media-svc-error.h' to know the exact meaning of the error.
3132 #include <media-svc.h>
3134 void test_minfo_add_web_media(MediaSvcHandle *mb_svc_handle)
3136 int ret = MB_SVC_ERROR_NONE;
3137 const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
3139 //add a web media to a web album.
3140 ret = minfo_add_web_media(mb_svc_handle, cluster_id, "http://user/specifying/address", "web_media", "thumbnail path");
3142 printf( "failed to add to a web album. error code->%d", ret);
3153 minfo_add_web_media(MediaSvcHandle *mb_svc_handle, const char *cluster_id, const char* http_url, const char* file_name, const char* thumb_path);
3156 * minfo_add_web_media_with_type
3157 * This function could add a web media to web album specified by @p cluster_id, in addition, user need to pass @p http_url, @p file_name, @p content_type,
3158 * @p thumb_path. If failed to add it to web album, this function will return an error code.
3160 * @param[in] mb_svc_handle the handle of DB
3161 * @param[in] cluster_id specify cluster id to indentify a web album.
3162 * @param[in] http_url web media's url.
3163 * @param[in] file_name file name.
3164 * @param[in] content_type type of the media.
3165 * @param[in] thumb_path thumbnail full path of this web media
3166 * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
3167 * Please refer 'media-svc-error.h' to know the exact meaning of the error.
3175 #include <media-svc.h>
3178 void test_minfo_add_web_media_with_type(MediaSvcHandle *mb_svc_handle)
3180 int ret = MB_SVC_ERROR_NONE;
3181 const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
3183 //add a web media to a web album.
3184 ret = minfo_add_web_media_with_type(mb_svc_handle, cluster_id, "http://user/specifying/address", "web_media", MINFO_ITEM_IMAGE, "thumbnail name");
3186 printf( "failed to add to a web album. error code->%d", ret);
3197 minfo_add_web_media_with_type(MediaSvcHandle *mb_svc_handle, const char *cluster_id, const char* http_url, const char* file_name, minfo_file_type content_type, const char* thumb_path);
3206 #endif /* __cplusplus */
3212 #endif /*_VISUAL_SVC_H_*/