Code migration
[platform/core/api/media-content.git] / include_product / 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  * @addtogroup CAPI_CONTENT_MEDIA_STORAGE_MODULE
37  * @{
38  */
39
40 /**
41 * @brief Gets media storage from database.
42 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
43 *
44 * @remarks You must release the handle using media_storage_destroy(). \n
45 *
46 * @param[in] storage_id The storage id to get media storage info
47 * @param[out] storage The media storage handle
48 *
49 * @return @c 0 on success,
50 *           otherwise a negative error value
51 *
52 * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
53 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
54 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY     Out of memory
55 * @retval #MEDIA_CONTENT_ERROR_DB_FAILED                 DB Operation failed
56 * @retval #MEDIA_CONTENT_ERROR_DB_BUSY                   DB Operation busy
57 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
58
59 *
60 * @pre This function requires opened connection to content service by media_content_connect().
61 *
62 * @see media_content_connect()
63 */
64 int media_storage_get_storage_info_from_db(const char *storage_id, media_storage_h *storage);
65
66 /**
67 * @brief Gets the count of media storage for the passed @a filter from the media database.
68 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
69 *
70 * @param[in] filter The handle to filter
71 * @param[out] storage_count The count of storage
72 *
73 * @return @c 0 on success,
74 *           otherwise a negative error value
75 *
76 * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
77 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
78 * @retval #MEDIA_CONTENT_ERROR_INVALID_OPERATION Invalid operation
79 * @retval #MEDIA_CONTENT_ERROR_DB_FAILED                 DB Operation failed
80 * @retval #MEDIA_CONTENT_ERROR_DB_BUSY                   DB Operation busy
81 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
82 *
83 * @pre This function requires opened connection to content service by media_content_connect().
84 *
85 * @see media_content_connect()
86 */
87 int media_storage_get_storage_count_from_db(filter_h filter, int *storage_count);
88
89 /**
90  * @brief Iterates through media storage from the media database.
91  * @details This function gets all media storage handles meeting the given @a filter.
92  *          The @a callback function will be invoked for every retrieved media storage.
93  *          If @c NULL is passed to the @a filter, then no filtering is applied.
94  *
95  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
96  *
97  * @param[in] filter    The media storage handle filter
98  * @param[in] callback  The callback function to be invoked
99  * @param[in] user_data The user data to be passed to the callback function
100  *
101  * @return @c 0 on success,
102  *         otherwise a negative error value
103  *
104  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
105  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
106  * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY     Out of memory
107  * @retval #MEDIA_CONTENT_ERROR_DB_FAILED         DB Operation failed
108  * @retval #MEDIA_CONTENT_ERROR_DB_BUSY           DB Operation busy
109  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
110  *
111  * @pre  This function requires opened connection to content service by media_content_connect().
112  * @post This function invokes media_storage_destroy().
113  *
114  * @see media_content_connect()
115  * @see media_storage_destroy()
116  */
117 int media_storage_foreach_storage_from_db(filter_h filter, media_storage_cb callback, void *user_data);
118
119 /**
120  * @brief Gets the count of media files for the passed @a filter in the given @a storage from the media database.
121  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
122  *
123  * @param[in] storage_id    The ID of the media storage
124  * @param[in] filter       The filter of the media content
125  * @param[out] media_count The count of media storage items
126  *
127  * @return @c 0 on success,
128  *         otherwise a negative error value
129  *
130  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
131  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
132  * @retval #MEDIA_CONTENT_ERROR_DB_FAILED         DB Operation failed
133  * @retval #MEDIA_CONTENT_ERROR_DB_BUSY           DB Operation busy
134  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
135  *
136  * @pre This function requires opened connection to content service by media_content_connect().
137  *
138  * @see media_content_connect()
139  */
140 int media_storage_get_media_count_from_db(const char *storage_id, filter_h filter, int *media_count);
141
142 /**
143  * @brief Iterates through the media files with an optional @a filter in the given @a storage from the media database.
144  * @details This function gets all media files associated with the given storage and
145  *          meeting desired filter option and calls registered callback function for
146  *          every retrieved media item. If @c NULL is passed to the @a filter, no filtering is applied.
147  *
148  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
149  *
150  * @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,
151  *                    your callback function is invoked as inline function. \n
152  *                    So, your callback function is in read state in SQLite. When you are in read state, sometimes you do not update DB. \n
153  *                    We do not recommend you call updating DB function in callback of foreach function.
154  *
155  * @param[in] storage_id The ID of the media storage
156  * @param[in] filter    The handle to the media info filter
157  * @param[in] callback  The callback function to be invoked
158  * @param[in] user_data The user data to be passed to the callback function
159  *
160  * @return @c 0 on success,
161  *         otherwise a negative error value
162  *
163  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
164  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
165  * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY     Out of memory
166  * @retval #MEDIA_CONTENT_ERROR_DB_FAILED         DB Operation failed
167  * @retval #MEDIA_CONTENT_ERROR_DB_BUSY           DB Operation busy
168  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
169  *
170  * @pre  This function requires opened connection to content service by media_content_connect().
171  * @post This function invokes media_info_cb().
172  *
173  * @see #media_info_cb
174  * @see media_content_connect()
175  * @see media_filter_create()
176  */
177 int media_storage_foreach_media_from_db(const char *storage_id, filter_h filter, media_info_cb callback, void *user_data);
178
179 /**
180  * @brief Destroys media storage handle.
181  * @details The function frees all resources related to the media storage handle. This handle
182  *          can no longer be used to perform any operation. New media storage handle has to
183  *          be created before the next usage.
184  *
185  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
186  *
187  * @param[in]  storage  The media storage handle
188  *
189  * @return @c 0 on success,
190  *         otherwise a negative error value
191  *
192  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
193  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
194  *
195  * @pre Get copy of media_storage_h handle by calling media_storage_clone().
196  *
197  * @see media_storage_clone()
198  */
199 int media_storage_destroy(media_storage_h storage);
200
201 /**
202  * @brief Clones the media storage handle.
203  *
204  * @details This function copies the media storage handle from a source to the destination.
205  *          There is no media_storage_create() function. The media_storage_h is created internally and
206  *          available through media storage foreach function such as media_storage_foreach_storage_from_db().
207  *          To use this handle outside of these foreach functions, use this function.
208  *
209  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
210  *
211  * @remarks You must release the destination handle using media_storage_destroy().
212  *
213  * @param[out] dst  The destination handle to the media storage
214  * @param[in]  src  The source handle to media storage
215  *
216  * @return @c 0 on success,
217  *         otherwise a negative error value
218  *
219  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
220  * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY     Out of memory
221  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
222  *
223  * @see media_storage_destroy()
224  * @see media_storage_foreach_storage_from_db()
225  * @see media_storage_get_storage_info_from_db()
226  */
227 int media_storage_clone(media_storage_h *dst, media_storage_h src);
228
229 /**
230  * @brief Gets the storage id of media storage.
231  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
232  *
233  * @remarks You must release @a storage_id using free().
234  *
235  * @param[in]  storage The media storage handle
236  * @param[out] storage_id  The storage id of the media storage
237  *
238  * @return @c 0 on success,
239  *         otherwise a negative error value
240  *
241  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
242  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
243  * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY     Out of memory
244  */
245 int media_storage_get_id(media_storage_h storage, char **storage_id);
246
247 /**
248  * @brief Gets the storage name of media storage.
249  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
250  *
251  * @remarks You must release @a storage_name using free().
252  *                   If the requested storage is not the cloud storage, this API returns NULL.
253  *
254  * @param[in]  storage The media storage handle
255  * @param[out] storage_name  The storage name of the media storage
256  *
257  * @return @c 0 on success,
258  *         otherwise a negative error value
259  *
260  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
261  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
262  * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY     Out of memory
263  */
264 int media_storage_get_name(media_storage_h storage, char **storage_name);
265
266 /**
267  * @brief Gets the storage path of media storage.
268  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
269  *
270  * @remarks You must release @a storage_path using free().
271  *
272  * @param[in]  storage The media storage handle
273  * @param[out] storage_path  The storage path of the media storage
274  *
275  * @return @c 0 on success,
276  *         otherwise a negative error value
277  *
278  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
279  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
280  * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY     Out of memory
281  */
282 int media_storage_get_path(media_storage_h storage, char **storage_path);
283
284 /**
285  * @brief Gets the storage type of media storage.
286  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
287  *
288  * @param[in]  storage The media storage handle
289  * @param[out] storage_type  The storage type of the media storage
290  *
291  * @return @c 0 on success,
292  *         otherwise a negative error value
293  *
294  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
295  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
296  */
297 int media_storage_get_type(media_storage_h storage, media_content_storage_e *storage_type);
298
299 /**
300  * @brief Gets the storage scan status of media storage.
301  * @since_tizen 2.4
302  *
303  * @param[in]  storage The media storage handle
304  * @param[out] scan_status  The storage type of the media storage
305  *
306  * @return @c 0 on success,
307  *         otherwise a negative error value
308  *
309  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
310  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
311  */
312 int media_storage_get_scan_status(const char *storage_uuid, media_storage_scan_status_e *scan_status);
313
314
315 /**
316  * @}
317  */
318
319 #ifdef __cplusplus
320 }
321 #endif /* __cplusplus */
322
323 #endif /* __TIZEN_MEDIA_STORAGE_H__ */