Update header files.
[platform/core/api/media-content.git] / include / media_storage.h
1 /*
2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17
18 #ifndef __TIZEN_MEDIA_STORAGE_H__
19 #define __TIZEN_MEDIA_STORAGE_H__
20
21
22 #include <media_content_type.h>
23
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif /* __cplusplus */
28
29 /**
30  * @file media_storage.h
31  * @brief This file contains API on main functional operations with storage that are related to media resources in the media database. \n
32  *        Operations include: getting number of storages, cloning and destroying storage, getting storage`s ID, name, path and type.
33  */
34
35 /**
36 * @brief Gets media storage from database.
37 * @since_tizen 2.4
38 *
39 * @param[in] storage_id The storage id to get media storage info
40 * @param[out] storage The media storage handle
41 *
42 * @return @c 0 on success,
43 *           otherwise a negative error value
44 *
45 * @retval #MEDIA_CONTENT_ERROR_NONE                      Successful
46 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
47 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY     Out of memory
48 * @retval #MEDIA_CONTENT_ERROR_DB_FAILED                 DB Operation failed
49 * @retval #MEDIA_CONTENT_ERROR_DB_BUSY                   DB Operation busy
50 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
51
52 *
53 * @pre This function requires opened connection to content service by media_content_connect().
54 *
55 * @see media_content_connect()
56 */
57 int media_storage_get_storage_info_from_db(const char *storage_id, media_storage_h *storage);
58
59 /**
60 * @brief Gets the count of media storage for the passed @a filter from the media database.
61 * @since_tizen 2.4
62 *
63 * @param[in] filter The handle to filter
64 * @param[out] storage_count The count of storage
65 *
66 * @return @c 0 on success,
67 *           otherwise a negative error value
68 *
69 * @retval #MEDIA_CONTENT_ERROR_NONE                      Successful
70 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
71 * @retval #MEDIA_CONTENT_ERROR_INVALID_OPERATION Invalid operation
72 * @retval #MEDIA_CONTENT_ERROR_DB_FAILED                 DB Operation failed
73 * @retval #MEDIA_CONTENT_ERROR_DB_BUSY                   DB Operation busy
74 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
75 *
76 * @pre This function requires opened connection to content service by media_content_connect().
77 *
78 * @see media_content_connect()
79 */
80 int media_storage_get_storage_count_from_db(filter_h filter, int *storage_count);
81
82 /**
83  * @brief Iterates through media storage from the media database.
84  * @details This function gets all media storage handles meeting the given @a filter.
85  *          The @a callback function will be invoked for every retrieved media storage.
86  *          If @c NULL is passed to the @a filter, then no filtering is applied.
87  *
88  * @since_tizen 2.4
89  *
90  * @param[in] filter    The media storage handle filter
91  * @param[in] callback  The callback function to be invoked
92  * @param[in] user_data The user data to be passed to the callback function
93  *
94  * @return @c 0 on success,
95  *         otherwise a negative error value
96  *
97  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
98  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
99  * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY     Out of memory
100  * @retval #MEDIA_CONTENT_ERROR_DB_FAILED         DB Operation failed
101  * @retval #MEDIA_CONTENT_ERROR_DB_BUSY           DB Operation busy
102  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
103  *
104  * @pre  This function requires opened connection to content service by media_content_connect().
105  * @post This function invokes media_storage_destroy().
106  *
107  * @see media_content_connect()
108  * @see media_storage_destroy()
109  */
110 int media_storage_foreach_storage_from_db(filter_h filter, media_storage_cb callback, void *user_data);
111
112 /**
113  * @brief Gets the count of media files for the passed @a filter in the given @a storage from the media database.
114  * @since_tizen 2.4
115  *
116  * @param[in] storage_id    The ID of the media storage
117  * @param[in] filter       The filter of the media content
118  * @param[out] media_count The count of media storage items
119  *
120  * @return @c 0 on success,
121  *         otherwise a negative error value
122  *
123  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
124  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
125  * @retval #MEDIA_CONTENT_ERROR_DB_FAILED         DB Operation failed
126  * @retval #MEDIA_CONTENT_ERROR_DB_BUSY           DB Operation busy
127  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
128  *
129  * @pre This function requires opened connection to content service by media_content_connect().
130  *
131  * @see media_content_connect()
132  */
133 int media_storage_get_media_count_from_db(const char *storage_id, filter_h filter, int *media_count);
134
135 /**
136  * @brief Iterates through the media files with an optional @a filter in the given @a storage from the media database.
137  * @details This function gets all media files associated with the given storage and
138  *          meeting desired filter option and calls registered callback function for
139  *          every retrieved media item. If @c NULL is passed to the @a filter, no filtering is applied.
140  *
141  * @since_tizen 2.4
142  *
143  * @remarks   Do not call updating DB function like media_info_update_to_db(), media_info_refresh_metadata_to_db(), audio_meta_update_to_db(), image_meta_update_to_db() and video_meta_update_to_db()  in your callback function,
144  *                    your callback function is invoked as inline function. \n
145  *                    So, your callback function is in read state in SQLite. When you are in read state, sometimes you do not update DB. \n
146  *                    We do not recommend you call updating DB function in callback of foreach function.
147  *
148  * @param[in] storage_id The ID of the media storage
149  * @param[in] filter    The handle to the media info filter
150  * @param[in] callback  The callback function to be invoked
151  * @param[in] user_data The user data to be passed to the callback function
152  *
153  * @return @c 0 on success,
154  *         otherwise a negative error value
155  *
156  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
157  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
158  * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY     Out of memory
159  * @retval #MEDIA_CONTENT_ERROR_DB_FAILED         DB Operation failed
160  * @retval #MEDIA_CONTENT_ERROR_DB_BUSY           DB Operation busy
161  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
162  *
163  * @pre  This function requires opened connection to content service by media_content_connect().
164  * @post This function invokes media_info_cb().
165  *
166  * @see #media_info_cb
167  * @see media_content_connect()
168  * @see media_filter_create()
169  */
170 int media_storage_foreach_media_from_db(const char *storage_id, filter_h filter, media_info_cb callback, void *user_data);
171
172 /**
173  * @brief Destroys media storage handle.
174  * @details The function frees all resources related to the media storage handle. This handle
175  *          can no longer be used to perform any operation. New media storage handle has to
176  *          be created before the next usage.
177  *
178  * @since_tizen 2.4
179  *
180  * @param[in]  storage  The media storage handle
181  *
182  * @return @c 0 on success,
183  *         otherwise a negative error value
184  *
185  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
186  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
187  *
188  * @pre Get copy of media_storage_h handle by calling media_storage_clone().
189  *
190  * @see media_storage_clone()
191  */
192 int media_storage_destroy(media_storage_h storage);
193
194 /**
195  * @brief Clones the media storage handle.
196  *
197  * @details This function copies the media storage handle from a source to the destination.
198  *          There is no media_storage_create() function. The media_storage_h is created internally and
199  *          available through media storage foreach function such as media_storage_foreach_storage_from_db().
200  *          To use this handle outside of these foreach functions, use this function.
201  *
202  * @since_tizen 2.4
203  *
204  * @remarks You must release the destination handle using media_storage_destroy().
205  *
206  * @param[out] dst  The destination handle to the media storage
207  * @param[in]  src  The source handle to media storage
208  *
209  * @return @c 0 on success,
210  *         otherwise a negative error value
211  *
212  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
213  * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY     Out of memory
214  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
215  *
216  * @see media_storage_destroy()
217  * @see media_storage_foreach_storage_from_db()
218  * @see media_storage_get_storage_info_from_db()
219  */
220 int media_storage_clone(media_storage_h *dst, media_storage_h src);
221
222 /**
223  * @brief Gets the storage id of media storage.
224  * @since_tizen 2.4
225  *
226  * @remarks You must release @a storage_id using free().
227  *
228  * @param[in]  storage The media storage handle
229  * @param[out] storage_id  The storage id of the media storage
230  *
231  * @return @c 0 on success, 
232  *         otherwise a negative error value
233  *
234  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
235  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
236  * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY     Out of memory
237  */
238 int media_storage_get_id(media_storage_h storage, char **storage_id);
239
240 /**
241  * @brief Gets the storage name of media storage.
242  * @since_tizen 2.4
243  *
244  * @remarks You must release @a storage_name using free().
245  *
246  * @param[in]  storage The media storage handle
247  * @param[out] storage_name  The storage name of the media storage
248  *
249  * @return @c 0 on success,
250  *         otherwise a negative error value
251  *
252  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
253  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
254  * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY     Out of memory
255  */
256 int media_storage_get_name(media_storage_h storage, char **storage_name);
257
258 /**
259  * @brief Gets the storage path of media storage.
260  * @since_tizen 2.4
261  *
262  * @remarks You must release @a storage_path using free().
263  *
264  * @param[in]  storage The media storage handle
265  * @param[out] storage_path  The storage path of the media storage
266  *
267  * @return @c 0 on success,
268  *         otherwise a negative error value
269  *
270  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
271  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
272  * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY     Out of memory
273  */
274 int media_storage_get_path(media_storage_h storage, char **storage_path);
275
276 /**
277  * @brief Gets the storage type of media storage.
278  * @since_tizen 2.4
279  *
280  * @param[in]  storage The media storage handle
281  * @param[out] storage_type  The storage type of the media storage
282  *
283  * @return @c 0 on success,
284  *         otherwise a negative error value
285  *
286  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
287  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
288  */
289 int media_storage_get_type(media_storage_h storage, media_content_storage_e *storage_type);
290
291 #ifdef __cplusplus
292 }
293 #endif /* __cplusplus */
294
295 #endif /* __TIZEN_MEDIA_STORAGE_H__ */