sync with tizen_2.0
[platform/core/multimedia/libmedia-service.git] / include / media-svc.h
1 /*
2  * libmedia-service
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
7  *
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
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
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.
19  *
20  */
21
22
23
24 #ifndef _MEDIA_SVC_H_
25 #define _MEDIA_SVC_H_
26
27 #include "media-svc-types.h"
28 #include "media-svc-error.h"
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33
34
35 /**
36         @defgroup       MEDIA_SVC       Media Information Service
37          @{
38           * @file                       media-svc.h
39           * @brief              This file defines API's for media service.
40           * @version            1.0
41  */
42
43 /**
44         @defgroup MEDIA_SVC_API    Media Database API
45         @{
46
47         @par
48         manage the service database.
49  */
50
51
52 /**
53  *      media_svc_connect:
54  *      Connect to the media database. This is the function that an user who wants to get a handle to access the media database. 
55  *
56  *  @param              handle [out]            Handle to access database.
57  *      @return         This function returns zero(MEDIA_INFO_ERROR_NONE) on success, or negative value with error code.
58  *                              Please refer 'media-info-error.h' to know the exact meaning of the error.
59  *      @see            media_svc_disconnect
60  *      @pre            None
61  *      @post           call media_svc_disconnect to disconnect media database.
62  *      @remark The database name is "/opt/usr/dbspace/.media.db".
63  *      @par example
64  *      @code
65
66 #include <media-info.h>
67
68 void connect_media_db()
69 {
70         int ret = MEDIA_INFO_ERROR_NONE;
71         MediaSvcHandle* my_handle = NULL;
72
73         // connect to the media database
74         ret = media_svc_connect(&my_handle);
75
76         if (ret < 0)
77         {
78                 printf("Fatal error to connect DB\n");
79                 return;
80         }
81
82         return;
83 }
84
85  *      @endcode
86  */
87 int media_svc_connect(MediaSvcHandle **handle);
88
89
90 /**
91  *      media_svc_disconnect:
92  *      Disconnect to the media database. This is the function that an user who wants to disconnect the media database. 
93  *
94  *  @param              handle [in]             Handle to access database.
95  *      @return         This function returns zero(MEDIA_INFO_ERROR_NONE) on success, or negative value with error code.
96  *                              Please refer 'media-info-error.h' to know the exact meaning of the error.
97  *      @see            media_svc_connect
98  *      @pre            call media_svc_connect to connect media database.
99  *      @post           None
100  *      @remark The database name is "/opt/usr/dbspace/.media.db".
101  *      @par example
102  *      @code
103
104 #include <media-info.h>
105
106 void disconnect_media_db()
107 {
108         int ret = MEDIA_INFO_ERROR_NONE;
109         MediaSvcHandle* my_handle = NULL;
110
111         // connect to the media database
112         ret = media_svc_connect(&my_handle);
113
114         if (ret < 0)
115         {
116                 printf("Fatal error to connect DB\n");
117                 return;
118         }
119
120         //
121         // Do something using my_handle
122         //
123         
124
125         ret = media_svc_disconnect(my_handle);
126         if (ret < 0)
127         {
128                 printf("Fatal error to disconnect DB\n");
129         }
130
131         return;
132 }
133
134  *      @endcode
135  */
136 int media_svc_disconnect(MediaSvcHandle *handle);
137
138
139 /**
140  *      media_svc_create_table:
141  *      Create table of media database and set Index and Triggers.
142  *
143  *  @param              handle [in]             Handle to access database.
144  *      @return         This function returns zero(MEDIA_INFO_ERROR_NONE) on success, or negative value with error code.
145  *                              Please refer 'media-info-error.h' to know the exact meaning of the error.
146  *      @see            None
147  *      @pre            call media_svc_connect to connect media database.
148  *      @post           call media_svc_disconnect to disconnect media database.
149  *      @remark The database name is "/opt/usr/dbspace/.media.db".
150  *      @par example
151  *      @code
152
153 #include <media-info.h>
154
155 void create_media_db_table()
156 {
157         int ret = MEDIA_INFO_ERROR_NONE;
158         MediaSvcHandle* my_handle = NULL;
159
160         // connect to the media database
161         ret = media_svc_connect(&my_handle);
162
163         if (ret < 0)
164         {
165                 printf("Fatal error to connect DB\n");
166                 return;
167         }
168
169         ret = media_svc_create_table(my_handle);
170         if (ret < 0)
171         {
172                 printf("Fatal error to create DB table\n");
173         }
174
175         ret = media_svc_disconnect(my_handle);
176         if (ret < 0)
177         {
178                 printf("Fatal error to disconnect DB\n");
179         }
180
181         return;
182 }
183
184  *      @endcode
185  */
186
187 int media_svc_create_table(MediaSvcHandle *handle);
188
189 int media_svc_check_item_exist_by_path(MediaSvcHandle *handle, const char *path);
190
191 int media_svc_insert_folder(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, const char *path);
192
193 int media_svc_insert_item_begin(MediaSvcHandle *handle, int data_cnt);
194
195 int media_svc_insert_item_end(MediaSvcHandle *handle);
196
197 int media_svc_insert_item_bulk(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, const char *path, const char *mime_type, media_svc_media_type_e media_type);
198
199 int media_svc_insert_item_immediately(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, const char *path, const char *mime_type, media_svc_media_type_e media_type);
200
201 int media_svc_move_item_begin(MediaSvcHandle *handle, int data_cnt);
202
203 int media_svc_move_item_end(MediaSvcHandle *handle);
204
205 int media_svc_move_item(MediaSvcHandle *handle, media_svc_storage_type_e src_storage, const char *src_path, media_svc_storage_type_e dest_storage, const char *dest_path);
206
207 int media_svc_set_item_validity_begin(MediaSvcHandle *handle, int data_cnt);
208
209 int media_svc_set_item_validity_end(MediaSvcHandle *handle);
210
211 int media_svc_set_item_validity(MediaSvcHandle *handle, const char *path, int validity);
212
213 int media_svc_delete_item_by_path(MediaSvcHandle *handle, const char *path);
214
215 int media_svc_delete_all_items_in_storage(MediaSvcHandle *handle, media_svc_storage_type_e storage_type);
216
217 int media_svc_delete_invalid_items_in_storage(MediaSvcHandle *handle, media_svc_storage_type_e storage_type);
218
219 int media_svc_delete_invalid_items_in_folder(MediaSvcHandle *handle, const char *folder_path);
220
221 int media_svc_set_all_storage_items_validity(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, int validity);
222
223 int media_svc_set_folder_items_validity(MediaSvcHandle *handle, const char *folder_path, int validity, int recursive);
224
225 int media_svc_refresh_item(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, const char *path, media_svc_media_type_e media_type);
226
227 int media_svc_rename_folder(MediaSvcHandle *handle, const char *src_path, const char *dst_path);
228
229 int media_svc_request_update_db(const char *db_query);
230
231 int media_svc_get_storage_type(const char *path, media_svc_storage_type_e *storage_type);
232
233 int media_svc_get_mime_type(const char *path, char *mimetype);
234
235 int media_svc_get_media_type(const char *path, const char *mime_type, media_svc_media_type_e *media_type);
236
237 /** @} */
238
239 /**
240         @}
241  */
242
243 #ifdef __cplusplus
244 }
245 #endif
246
247 #endif /*_MEDIA_SVC_H_*/