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_DB_BUSY DB Operation busy
54 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
56 * @pre This function requires opened connection to content service by media_content_connect().
58 * @see media_content_connect()
60 int media_playlist_get_playlist_count_from_db(filter_h filter, int *playlist_count);
63 * @brief Iterates through the media playlists with an optional @a filter from the media database.
64 * @details This function gets all media playlists meeting the given filter.
65 * The callback function will be invoked for every retrieved media playlist.
66 * If @c NULL is passed to the filter, no filtering is applied.
70 * @param[in] filter The handle to the audio filter
71 * @param[in] callback The callback function to be invoked
72 * @param[in] user_data The user data to be passed to the callback function
74 * @return @c 0 on success,
75 * otherwise a negative error value
77 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
78 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
79 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
80 * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB Operation failed
81 * @retval #MEDIA_CONTENT_ERROR_DB_BUSY DB Operation busy
82 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
84 * @pre This function requires opened connection to content service by media_content_connect().
85 * @post This function invokes media_playlist_cb().
87 * @see media_playlist_cb()
88 * @see media_content_connect()
89 * @see media_filter_create()
91 int media_playlist_foreach_playlist_from_db(filter_h filter, media_playlist_cb callback, void *user_data);
94 * @brief Gets the number of the media info for the given playlist present in the media database.
97 * @param[in] playlist_id The ID of the media playlist
98 * @param[in] filter The media filter handle
99 * @param[out] media_count The number of media items
101 * @return @c 0 on success,
102 * otherwise a negative error value
104 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
105 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
106 * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB Operation failed
107 * @retval #MEDIA_CONTENT_ERROR_DB_BUSY DB Operation busy
108 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
110 * @pre This function requires opened connection to content service by media_content_connect().
112 * @see media_content_connect()
114 int media_playlist_get_media_count_from_db(int playlist_id, filter_h filter, int *media_count);
117 * @brief Iterates through the media files with an optional @a filter in the given audio playlist from the media database.
118 * @details This function gets all media files associated with the given media playlist and
119 * meeting desired filter option and calls registered callback function for
120 * every retrieved media info. If @c NULL is passed to the @a filter, no filtering is applied.
124 * @param[in] playlist_id The ID of the media playlist
125 * @param[in] filter The audio filter handle
126 * @param[in] callback The callback function to be invoked
127 * @param[in] user_data The user data to be passed to the callback function
129 * @return @c 0 on success,
130 * otherwise a negative error value
132 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
133 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
134 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
135 * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB Operation failed
136 * @retval #MEDIA_CONTENT_ERROR_DB_BUSY DB Operation busy
137 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
139 * @pre This function requires opened connection to content service by media_content_connect().
140 * @post This function invokes media_info_cb().
142 * @see media_info_cb()
143 * @see media_content_connect()
144 * @see media_filter_create()
146 int media_playlist_foreach_media_from_db(int playlist_id, filter_h filter, playlist_member_cb callback, void *user_data);
149 * @brief Inserts a new playlist with the given name into the media database.
153 * @privilege %http://tizen.org/privilege/content.write
155 * @remarks You must release the created handle using media_playlist_destroy().
157 * @param[in] name The name of the inserted playlist
158 * @param[out] playlist A created handle to media playlist
160 * @return @c 0 on success,
161 * otherwise a negative error value
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_INVALID_OPERATION Invalid operation
167 * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB Operation failed
168 * @retval #MEDIA_CONTENT_ERROR_DB_BUSY DB Operation busy
169 * @retval #MEDIA_CONTENT_ERROR_NETWORK Network fail
170 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
172 * @pre This function requires opened connection to content service by media_content_connect().
174 * @see media_content_connect()
175 * @see media_playlist_delete_from_db()
177 int media_playlist_insert_to_db(const char *name, media_playlist_h *playlist);
180 * @brief Deletes the given playlist from the media database.
184 * @privilege %http://tizen.org/privilege/content.write
186 * @param[in] playlist_id The ID of media playlist
188 * @return @c 0 on success,
189 * otherwise a negative error value
191 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
192 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
193 * @retval #MEDIA_CONTENT_ERROR_INVALID_OPERATION Invalid operation
194 * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB Operation failed
195 * @retval #MEDIA_CONTENT_ERROR_DB_BUSY DB Operation busy
196 * @retval #MEDIA_CONTENT_ERROR_NETWORK Network fail
197 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
199 * @pre This function requires opened connection to content service by media_content_connect().
201 * @see media_content_connect()
202 * @see media_playlist_insert_to_db()
204 int media_playlist_delete_from_db(int playlist_id);
207 * @brief Gets the media playlist from the media database.
209 * @details This function creates a new media playlist handle from the media database by the given @a playlist_id.
210 * The media playlist will be created and will be filled with the playlist information.
214 * @remarks You must release @a playlist using media_playlist_destroy().
216 * @param[in] playlist_id The ID of the media playlist
217 * @param[out] playlist The media playlist handle associated with the playlist ID
219 * @return @c 0 on success,
220 * otherwise a negative error value
222 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
223 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
224 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
225 * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB Operation failed
226 * @retval #MEDIA_CONTENT_ERROR_DB_BUSY DB Operation busy
227 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
229 * @pre This function requires opened connection to content service by media_content_connect().
231 * @see media_content_connect()
232 * @see media_playlist_destroy()
234 int media_playlist_get_playlist_from_db(int playlist_id, media_playlist_h *playlist);
237 * @brief Destroys a playlist handle.
238 * @details This function frees all resources related to the playlist handle. This
239 * handle no longer can be used to perform any operation. A new handle has to
240 * be created before next usage.
244 * @param[in] playlist The media playlist handle
246 * @return @c 0 on success,
247 * otherwise a negative error value
249 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
250 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
251 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
253 * @pre Get a copy of playlist handle by calling media_playlist_clone() or media_playlist_insert_to_db().
255 * @see media_playlist_clone()
257 int media_playlist_destroy(media_playlist_h playlist);
260 * @brief Clones a playlist handle.
261 * @details This function copies the media playlist handle from a source to
262 * destination. There is no media_playlist_create() function. The media_playlist_h is created internally and available through
263 * media playlist foreach function such as media_playlist_foreach_playlist_from_db().
264 * To use this handle outside of these foreach functions, use this function.
268 * @remarks The destination handle must be released using media_playlist_destroy().
270 * @param[in] src The source handle of a media playlist
271 * @param[out] dst The destination handle to a media playlist
273 * @return @c 0 on success,
274 * otherwise a negative error value
276 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
277 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
278 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
279 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
281 * @see media_playlist_destroy()
282 * @see media_playlist_foreach_playlist_from_db()
284 int media_playlist_clone(media_playlist_h *dst, media_playlist_h src);
287 * @brief Gets the media playlist ID.
290 * @param[in] playlist The media playlist handle
291 * @param[out] playlist_id The ID of the media playlist
293 * @return @c 0 on success,
294 * otherwise a negative error value
296 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
297 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
298 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
300 int media_playlist_get_playlist_id(media_playlist_h playlist, int *playlist_id);
303 * @brief Gets a name of the playlist.
306 * @remarks You must release @a playlist_name using free().
308 * @param[in] playlist The media playlist handle
309 * @param[out] playlist_name The playlist name
311 * @return @c 0 on success,
312 * otherwise a negative error value
314 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
315 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
316 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
317 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
319 int media_playlist_get_name(media_playlist_h playlist, char **playlist_name);
322 * @brief Sets the name of the playlist.
325 * @param[in] playlist The media playlist handle
326 * @param[in] playlist_name The name of the media playlist
328 * @return @c 0 on success,
329 * otherwise a negative error value
331 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
332 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
333 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
334 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
336 * @post media_playlist_update_to_db()
339 int media_playlist_set_name(media_playlist_h playlist, const char *playlist_name);
342 * @brief Gets a thumbnail path of the playlist.
345 * @remarks You must release @a path using free().
347 * @param[in] playlist The media playlist handle
348 * @param[out] path The path of the thumbnail
350 * @return @c 0 on success,
351 * otherwise a negative error value
353 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
354 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
355 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
356 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
358 int media_playlist_get_thumbnail_path(media_playlist_h playlist, char **path);
361 * @brief Sets the thumbnail path of the playlist.
364 * @param[in] playlist The media playlist handle
365 * @param[in] path The path of the thumbnail
367 * @return @c 0 on success,
368 * otherwise a negative error value
370 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
371 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
372 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
373 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
375 * @post media_playlist_update_to_db()
377 int media_playlist_set_thumbnail_path(media_playlist_h playlist, const char *path);
381 * @brief Sets the playing order in the playlist.
384 * @param[in] playlist The media playlist handle
385 * @param[in] playlist_member_id The playlist member ID
386 * @param[in] play_order The playing order
388 * @return @c 0 on success,
389 * otherwise a negative error value
391 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
392 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
393 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
394 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
396 * @post media_playlist_update_to_db()
398 int media_playlist_set_play_order(media_playlist_h playlist, int playlist_member_id, int play_order);
401 * @brief Adds a new media info to the playlist.
404 * @param[in] playlist The media playlist handle
405 * @param[in] media_id The ID to the media info which is added
407 * @return @c 0 on success,
408 * otherwise a negative error value
410 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
411 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
412 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
413 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
415 * @pre This function requires opened connection to content service by media_content_connect().
416 * @post media_playlist_update_to_db()
418 * @see media_content_connect()
419 * @see media_playlist_remove_media()
421 int media_playlist_add_media(media_playlist_h playlist, const char *media_id);
424 * @brief Removes the playlist members related with the media from the given playlist.
427 * @param[in] playlist The media playlist handle
428 * @param[in] playlist_member_id The playlist member ID
430 * @return @c 0 on success,
431 * otherwise a negative error value
433 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
434 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
435 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
436 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
438 * @pre This function requires opened connection to content service by media_content_connect().
439 * @post media_playlist_update_to_db()
441 * @see media_content_connect()
442 * @see media_playlist_add_media()
444 int media_playlist_remove_media(media_playlist_h playlist, int playlist_member_id);
447 * @brief Gets the played order of the playlist.
450 * @param[in] playlist The media playlist handle
451 * @param[in] playlist_member_id The playlist member ID
452 * @param[out] play_order The played order
454 * @return @c 0 on success,
455 * otherwise a negative error value
457 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
458 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
459 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
461 int media_playlist_get_play_order(media_playlist_h playlist, int playlist_member_id, int *play_order);
464 * @brief Updates the media playlist to the media database.
466 * @details The function updates the given media playlist in the media database.
467 * The function should be called after any change in the playlist, to be updated to the media database.
468 * For example, after using media_playlist_set_name() for setting the name of the playlist, the
469 * media_playlist_update_to_db() function should be called so as to update
470 * the given playlist attributes in the media database.
475 * @privilege %http://tizen.org/privilege/content.write
477 * @param[in] playlist The media playlist handle
479 * @return @c 0 on success,
480 * otherwise a negative error value
482 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
483 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
484 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
485 * @retval #MEDIA_CONTENT_ERROR_INVALID_OPERATION Invalid operation
486 * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB Operation failed
487 * @retval #MEDIA_CONTENT_ERROR_DB_BUSY DB Operation busy
488 * @retval #MEDIA_CONTENT_ERROR_NETWORK Network fail
489 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
491 * @pre This function requires opened connection to content service by media_content_connect().
493 * @see media_content_connect()
494 * @see media_playlist_destroy()
495 * @see media_playlist_add_media()
496 * @see media_playlist_remove_media()
497 * @see media_playlist_set_name()
498 * @see media_playlist_set_play_order()
500 int media_playlist_update_to_db(media_playlist_h playlist);
508 #endif /* __cplusplus */
509 #endif /*__TIZEN_MEDIA_PLAYLIST_H__*/