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