2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef __TIZEN_MEDIA_PLAYLIST_H__
18 #define __TIZEN_MEDIA_PLAYLIST_H__
20 #include <media_content_type.h>
24 #endif /* __cplusplus */
28 * @brief This file contains the playlist API and functions related with handling playlists. \n
29 * Functions include operations to get the number of playlists, the number of media-info for the playlist \n
30 * and all media files in the playlist, to clone, destroy, insert and delete playlist from DB, \n
31 * to handle with name, ID, thumbnail, played order and media info of the playlist.
35 * @addtogroup CAPI_CONTENT_MEDIA_PLAYLIST_MODULE
41 * @brief Gets the number of playlists for the passed @a filter from the media database.
44 * @param[in] filter The handle to the filter
45 * @param[out] playlist_count The count of the media playlist
47 * @return @c 0 on success,
48 * otherwise a negative error value
50 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
51 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
52 * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB operation failed
53 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
55 * @pre This function requires opened connection to content service by media_content_connect().
57 * @see media_content_connect()
59 int media_playlist_get_playlist_count_from_db(filter_h filter, int *playlist_count);
62 * @brief Iterates through the media playlists with an optional @a filter from the media database.
63 * @details This function gets all media playlists meeting the given filter.
64 * The callback function will be invoked for every retrieved media playlist.
65 * If @c NULL is passed to the filter, no filtering is applied.
69 * @param[in] filter The handle to the audio filter
70 * @param[in] callback The callback function to be invoked
71 * @param[in] user_data The user data to be passed to the callback function
73 * @return @c 0 on success,
74 * otherwise a negative error value
76 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
77 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
78 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
79 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
81 * @pre This function requires opened connection to content service by media_content_connect().
82 * @post This function invokes media_playlist_cb().
84 * @see media_playlist_cb()
85 * @see media_content_connect()
86 * @see media_filter_create()
88 int media_playlist_foreach_playlist_from_db(filter_h filter, media_playlist_cb callback, void *user_data);
91 * @brief Gets the number of the media info for the given playlist present in the media database.
94 * @param[in] playlist_id The ID of the media playlist
95 * @param[in] filter The media filter handle
96 * @param[out] media_count The number of media items
98 * @return @c 0 on success,
99 * otherwise a negative error value
101 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
102 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
103 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
105 * @pre This function requires opened connection to content service by media_content_connect().
107 * @see media_content_connect()
109 int media_playlist_get_media_count_from_db(int playlist_id, filter_h filter, int *media_count);
112 * @brief Iterates through the media files with an optional @a filter in the given audio playlist from the media database.
113 * @details This function gets all media files associated with the given media playlist and
114 * meeting desired filter option and calls registered callback function for
115 * every retrieved media info. If @c NULL is passed to the @a filter, no filtering is applied.
119 * @param[in] playlist_id The ID of the media playlist
120 * @param[in] filter The audio filter handle
121 * @param[in] callback The callback function to be invoked
122 * @param[in] user_data The user data to be passed to the callback function
124 * @return @c 0 on success,
125 * otherwise a negative error value
127 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
128 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
129 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
130 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
132 * @pre This function requires opened connection to content service by media_content_connect().
133 * @post This function invokes media_info_cb().
135 * @see media_info_cb()
136 * @see media_content_connect()
137 * @see media_filter_create()
139 int media_playlist_foreach_media_from_db(int playlist_id, filter_h filter, playlist_member_cb callback, void *user_data);
142 * @brief Inserts a new playlist with the given name into the media database.
146 * @privilege %http://tizen.org/privilege/content.write
148 * @remarks You must release the created handle using media_playlist_destroy().
150 * @param[in] name The name of the inserted playlist
151 * @param[out] playlist A created handle to media playlist
153 * @return @c 0 on success,
154 * otherwise a negative error value
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_INVALID_OPERATION Invalid operation
160 * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB Operation failed
161 * @retval #MEDIA_CONTENT_ERROR_DB_BUSY DB Operation busy
162 * @retval #MEDIA_CONTENT_ERROR_NETWORK Network fail
163 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
165 * @pre This function requires opened connection to content service by media_content_connect().
167 * @see media_content_connect()
168 * @see media_playlist_delete_from_db()
170 int media_playlist_insert_to_db(const char *name, media_playlist_h *playlist);
173 * @brief Deletes the given playlist from the media database.
177 * @privilege %http://tizen.org/privilege/content.write
179 * @param[in] playlist_id The ID of media playlist
181 * @return @c 0 on success,
182 * otherwise a negative error value
184 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
185 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
186 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
188 * @pre This function requires opened connection to content service by media_content_connect().
190 * @see media_content_connect()
191 * @see media_playlist_insert_to_db()
193 int media_playlist_delete_from_db(int playlist_id);
196 * @brief Gets the media playlist from the media database.
198 * @details This function creates a new media playlist handle from the media database by the given @a playlist_id.
199 * The media playlist will be created and will be filled with the playlist information.
203 * @remarks You must release @a playlist using media_playlist_destroy().
205 * @param[in] playlist_id The ID of the media playlist
206 * @param[out] playlist The media playlist handle associated with the playlist ID
208 * @return @c 0 on success,
209 * otherwise a negative error value
211 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
212 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
213 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
215 * @pre This function requires opened connection to content service by media_content_connect().
217 * @see media_content_connect()
218 * @see media_playlist_destroy()
220 int media_playlist_get_playlist_from_db(int playlist_id, media_playlist_h *playlist);
223 * @brief Destroys a playlist handle.
224 * @details This function frees all resources related to the playlist handle. This
225 * handle no longer can be used to perform any operation. A new handle has to
226 * be created before next usage.
230 * @param[in] playlist The media playlist handle
232 * @return @c 0 on success,
233 * otherwise a negative error value
235 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
236 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
237 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
239 * @pre Get a copy of playlist handle by calling media_playlist_clone() or media_playlist_insert_to_db().
241 * @see media_playlist_clone()
243 int media_playlist_destroy(media_playlist_h playlist);
246 * @brief Clones a playlist handle.
247 * @details This function copies the media playlist handle from a source to
248 * destination. There is no media_playlist_create() function. The media_playlist_h is created internally and available through
249 * media playlist foreach function such as media_playlist_foreach_playlist_from_db().
250 * To use this handle outside of these foreach functions, use this function.
254 * @remarks The destination handle must be released using media_playlist_destroy().
256 * @param[in] src The source handle of a media playlist
257 * @param[out] dst The destination handle to a media playlist
259 * @return @c 0 on success,
260 * otherwise a negative error value
262 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
263 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
264 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
265 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
267 * @see media_playlist_destroy()
268 * @see media_playlist_foreach_playlist_from_db()
270 int media_playlist_clone(media_playlist_h *dst, media_playlist_h src);
273 * @brief Gets the media playlist ID.
276 * @param[in] playlist The media playlist handle
277 * @param[out] playlist_id The ID of the media playlist
279 * @return @c 0 on success,
280 * otherwise a negative error value
282 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
283 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
284 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
286 int media_playlist_get_playlist_id(media_playlist_h playlist, int *playlist_id);
289 * @brief Gets a name of the playlist.
292 * @remarks You must release @a playlist_name using free().
294 * @param[in] playlist The media playlist handle
295 * @param[out] playlist_name The playlist name
297 * @return @c 0 on success,
298 * otherwise a negative error value
300 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
301 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
302 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
303 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
305 int media_playlist_get_name(media_playlist_h playlist, char **playlist_name);
308 * @brief Sets the name of the playlist.
311 * @param[in] playlist The media playlist handle
312 * @param[in] playlist_name The name of the media playlist
314 * @return @c 0 on success,
315 * otherwise a negative error value
317 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
318 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
319 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
320 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
322 * @post media_playlist_update_to_db()
325 int media_playlist_set_name(media_playlist_h playlist, const char *playlist_name);
328 * @brief Gets a thumbnail path of the playlist.
331 * @remarks You must release @a path using free().
333 * @param[in] playlist The media playlist handle
334 * @param[out] path The path of the thumbnail
336 * @return @c 0 on success,
337 * otherwise a negative error value
339 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
340 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
341 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
342 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
344 int media_playlist_get_thumbnail_path(media_playlist_h playlist, char **path);
347 * @brief Sets the thumbnail path of the playlist.
350 * @param[in] playlist The media playlist handle
351 * @param[in] path The path of the thumbnail
353 * @return @c 0 on success,
354 * otherwise a negative error value
356 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
357 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
358 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
359 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
361 * @post media_playlist_update_to_db()
363 int media_playlist_set_thumbnail_path(media_playlist_h playlist, const char *path);
367 * @brief Sets the playing order in the playlist.
370 * @param[in] playlist The media playlist handle
371 * @param[in] playlist_member_id The playlist member ID
372 * @param[in] play_order The playing order
374 * @return @c 0 on success,
375 * otherwise a negative error value
377 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
378 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
379 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
380 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
382 * @post media_playlist_update_to_db()
384 int media_playlist_set_play_order(media_playlist_h playlist, int playlist_member_id, int play_order);
387 * @brief Adds a new media info to the playlist.
390 * @param[in] playlist The media playlist handle
391 * @param[in] media_id The ID to the media info which is added
393 * @return @c 0 on success,
394 * otherwise a negative error value
396 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
397 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
398 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
399 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
401 * @pre This function requires opened connection to content service by media_content_connect().
402 * @post media_playlist_update_to_db()
404 * @see media_content_connect()
405 * @see media_playlist_remove_media()
407 int media_playlist_add_media(media_playlist_h playlist, const char *media_id);
410 * @brief Removes the playlist members related with the media from the given playlist.
413 * @param[in] playlist The media playlist handle
414 * @param[in] playlist_member_id The playlist member ID
416 * @return @c 0 on success,
417 * otherwise a negative error value
419 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
420 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
421 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
422 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
424 * @pre This function requires opened connection to content service by media_content_connect().
425 * @post media_playlist_update_to_db()
427 * @see media_content_connect()
428 * @see media_playlist_add_media()
430 int media_playlist_remove_media(media_playlist_h playlist, int playlist_member_id);
433 * @brief Gets the played order of the playlist.
436 * @param[in] playlist The media playlist handle
437 * @param[in] playlist_member_id The playlist member ID
438 * @param[out] play_order The played order
440 * @return @c 0 on success,
441 * otherwise a negative error value
443 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
444 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
445 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
447 int media_playlist_get_play_order(media_playlist_h playlist, int playlist_member_id, int *play_order);
450 * @brief Updates the media playlist to the media database.
452 * @details The function updates the given media playlist in the media database.
453 * The function should be called after any change in the playlist, to be updated to the media database.
454 * For example, after using media_playlist_set_name() for setting the name of the playlist, the
455 * media_playlist_update_to_db() function should be called so as to update
456 * the given playlist attributes in the media database.
461 * @privilege %http://tizen.org/privilege/content.write
463 * @param[in] playlist The media playlist handle
465 * @return @c 0 on success,
466 * otherwise a negative error value
468 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
469 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
470 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
472 * @pre This function requires opened connection to content service by media_content_connect().
474 * @see media_content_connect()
475 * @see media_playlist_destroy()
476 * @see media_playlist_add_media()
477 * @see media_playlist_remove_media()
478 * @see media_playlist_set_name()
479 * @see media_playlist_set_play_order()
481 int media_playlist_update_to_db(media_playlist_h playlist);
489 #endif /* __cplusplus */
490 #endif /*__TIZEN_MEDIA_PLAYLIST_H__*/