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_CONTENT_MEDIA_PLAYLIST_H__
18 #define __TIZEN_CONTENT_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 media 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
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 media 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_DB_FAILED DB Operation failed
80 * @retval #MEDIA_CONTENT_ERROR_DB_BUSY DB Operation busy
82 * @pre This function requires opened connection to content service by media_content_connect().
83 * @post This function invokes media_playlist_cb().
85 * @see media_playlist_cb()
86 * @see media_content_connect()
87 * @see media_filter_create()
89 int media_playlist_foreach_playlist_from_db(filter_h filter, media_playlist_cb callback, void *user_data);
92 * @brief Gets the number of the media info for the given playlist present in the media database.
95 * @param[in] playlist_id The ID of the media playlist
96 * @param[in] filter The handle to the media filter
97 * @param[out] media_count The number of media items
99 * @return @c 0 on success,
100 * otherwise a negative error value
102 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
103 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
104 * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB Operation failed
105 * @retval #MEDIA_CONTENT_ERROR_DB_BUSY DB Operation busy
107 * @pre This function requires opened connection to content service by media_content_connect().
109 * @see media_content_connect()
111 int media_playlist_get_media_count_from_db(int playlist_id, filter_h filter, int *media_count);
114 * @brief Iterates through the media files with an optional @a filter in the given audio playlist from the media database.
115 * @details This function gets all media files associated with the given media playlist and
116 * meeting desired filter option and calls @a callback for
117 * every retrieved media info. If @c NULL is passed to the @a filter, no filtering is applied.
121 * @param[in] playlist_id The ID of the media playlist
122 * @param[in] filter The handle to the media filter
123 * @param[in] callback The callback function to be invoked
124 * @param[in] user_data The user data to be passed to the callback function
126 * @return @c 0 on success,
127 * otherwise a negative error value
129 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
130 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
131 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
132 * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB Operation failed
133 * @retval #MEDIA_CONTENT_ERROR_DB_BUSY DB Operation busy
135 * @pre This function requires opened connection to content service by media_content_connect().
136 * @post This function invokes media_info_cb().
138 * @see media_info_cb()
139 * @see media_content_connect()
140 * @see media_filter_create()
142 int media_playlist_foreach_media_from_db(int playlist_id, filter_h filter, playlist_member_cb callback, void *user_data);
145 * @brief Inserts a new playlist with the given name into the media database.
149 * @privilege %http://tizen.org/privilege/content.write
151 * @remarks The @a playlist should be released using media_playlist_destroy().
153 * @param[in] name The name of the inserted playlist
154 * @param[out] playlist The handle to the media playlist
156 * @return @c 0 on success,
157 * otherwise a negative error value
159 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
160 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
161 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
162 * @retval #MEDIA_CONTENT_ERROR_INVALID_OPERATION Invalid operation
163 * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB Operation failed
164 * @retval #MEDIA_CONTENT_ERROR_DB_BUSY DB Operation busy
165 * @retval #MEDIA_CONTENT_ERROR_NETWORK Network fail
166 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
168 * @pre This function requires opened connection to content service by media_content_connect().
170 * @see media_content_connect()
171 * @see media_playlist_delete_from_db()
173 int media_playlist_insert_to_db(const char *name, media_playlist_h *playlist);
176 * @brief Deletes the given playlist from the media database.
180 * @privilege %http://tizen.org/privilege/content.write
182 * @param[in] playlist_id The ID of media playlist
184 * @return @c 0 on success,
185 * otherwise a negative error value
187 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
188 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
189 * @retval #MEDIA_CONTENT_ERROR_INVALID_OPERATION Invalid operation
190 * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB Operation failed
191 * @retval #MEDIA_CONTENT_ERROR_DB_BUSY DB Operation busy
192 * @retval #MEDIA_CONTENT_ERROR_NETWORK Network fail
193 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
195 * @pre This function requires opened connection to content service by media_content_connect().
197 * @see media_content_connect()
198 * @see media_playlist_insert_to_db()
200 int media_playlist_delete_from_db(int playlist_id);
203 * @brief Gets the media playlist from the media database.
205 * @details This function creates a new media playlist handle from the media database by the given @a playlist_id.
206 * The media playlist will be created and will be filled with the playlist information.
210 * @remarks The @a playlist should be released using media_playlist_destroy().
212 * @param[in] playlist_id The ID of the media playlist
213 * @param[out] playlist The handle to the media playlist
215 * @return @c 0 on success,
216 * otherwise a negative error value
218 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
219 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
220 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
221 * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB Operation failed
222 * @retval #MEDIA_CONTENT_ERROR_DB_BUSY DB Operation busy
224 * @pre This function requires opened connection to content service by media_content_connect().
226 * @see media_content_connect()
227 * @see media_playlist_destroy()
229 int media_playlist_get_playlist_from_db(int playlist_id, media_playlist_h *playlist);
232 * @brief Destroys a playlist handle.
233 * @details This function frees all resources related to the playlist handle. This
234 * handle no longer can be used to perform any operations. A new handle has to
235 * be created before next usage.
239 * @param[in] playlist The handle to the media playlist
241 * @return @c 0 on success,
242 * otherwise a negative error value
244 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
245 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
247 * @pre Get a copy of playlist handle by calling media_playlist_clone() or media_playlist_insert_to_db().
249 * @see media_playlist_clone()
251 int media_playlist_destroy(media_playlist_h playlist);
254 * @brief Clones a playlist handle.
255 * @details This function copies the media playlist handle from a source to
256 * destination. There is no media_playlist_create() function. The media_playlist_h is created internally and available through
257 * media playlist foreach function such as media_playlist_foreach_playlist_from_db().
258 * To use this handle outside of these foreach functions, use this function.
262 * @remarks The @a dst should be released using media_playlist_destroy().
264 * @param[out] dst The destination handle to the media playlist
265 * @param[in] src The source handle to the media playlist
267 * @return @c 0 on success,
268 * otherwise a negative error value
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
274 * @see media_playlist_destroy()
275 * @see media_playlist_foreach_playlist_from_db()
277 int media_playlist_clone(media_playlist_h *dst, media_playlist_h src);
280 * @brief Gets the media playlist ID.
283 * @param[in] playlist The handle to the media playlist
284 * @param[out] playlist_id The ID of the media playlist
286 * @return @c 0 on success,
287 * otherwise a negative error value
289 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
290 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
292 int media_playlist_get_playlist_id(media_playlist_h playlist, int *playlist_id);
295 * @brief Gets a name of the playlist.
298 * @remarks The @a playlist_name should be released using free().
300 * @param[in] playlist The handle to the media playlist
301 * @param[out] playlist_name The playlist name
303 * @return @c 0 on success,
304 * otherwise a negative error value
306 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
307 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
308 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
310 int media_playlist_get_name(media_playlist_h playlist, char **playlist_name);
313 * @brief Sets the name of the playlist.
316 * @param[in] playlist The handle to the media playlist
317 * @param[in] playlist_name The name of the media playlist
319 * @return @c 0 on success,
320 * otherwise a negative error value
322 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
323 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
324 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
326 * @post media_playlist_update_to_db()
329 int media_playlist_set_name(media_playlist_h playlist, const char *playlist_name);
332 * @brief Gets a thumbnail path of the playlist.
335 * @remarks The @a path should be released using free().
337 * @param[in] playlist The handle to the media playlist
338 * @param[out] path The path of the thumbnail
340 * @return @c 0 on success,
341 * otherwise a negative error value
343 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
344 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
345 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
347 int media_playlist_get_thumbnail_path(media_playlist_h playlist, char **path);
350 * @brief Sets the thumbnail path of the playlist.
353 * @param[in] playlist The handle to the media playlist
354 * @param[in] path The path of the thumbnail
356 * @return @c 0 on success,
357 * otherwise a negative error value
359 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
360 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
361 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
363 * @post media_playlist_update_to_db()
365 int media_playlist_set_thumbnail_path(media_playlist_h playlist, const char *path);
369 * @brief Sets the playing order in the playlist.
372 * @param[in] playlist The handle to the media playlist
373 * @param[in] playlist_member_id The ID of the playlist member
374 * @param[in] play_order The playing order
376 * @return @c 0 on success,
377 * otherwise a negative error value
379 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
380 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
381 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
383 * @post media_playlist_update_to_db()
385 int media_playlist_set_play_order(media_playlist_h playlist, int playlist_member_id, int play_order);
388 * @brief Adds a new media info to the playlist.
391 * @param[in] playlist The handle to the media playlist
392 * @param[in] media_id The media ID
394 * @return @c 0 on success,
395 * otherwise a negative error value
397 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
398 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
399 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
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 handle to the media playlist
414 * @param[in] playlist_member_id The ID of the playlist member
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
423 * @pre This function requires opened connection to content service by media_content_connect().
424 * @post media_playlist_update_to_db()
426 * @see media_content_connect()
427 * @see media_playlist_add_media()
429 int media_playlist_remove_media(media_playlist_h playlist, int playlist_member_id);
432 * @brief Gets the played order of the playlist.
435 * @param[in] playlist The handle to the media playlist
436 * @param[in] playlist_member_id The ID of the playlist member
437 * @param[out] play_order The played order
439 * @return @c 0 on success,
440 * otherwise a negative error value
442 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
443 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
445 int media_playlist_get_play_order(media_playlist_h playlist, int playlist_member_id, int *play_order);
448 * @brief Updates the media playlist to the media database.
450 * @details The function updates the given media playlist in the media database.
451 * The function should be called after any change in the playlist, to be updated to the media database.
452 * For example, after using media_playlist_set_name() for setting the name of the playlist, the
453 * media_playlist_update_to_db() function should be called so as to update
454 * the given playlist attributes in the media database.
459 * @privilege %http://tizen.org/privilege/content.write
461 * @param[in] playlist The handle to the media playlist
463 * @return @c 0 on success,
464 * otherwise a negative error value
466 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
467 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
468 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
469 * @retval #MEDIA_CONTENT_ERROR_INVALID_OPERATION Invalid operation
470 * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB Operation failed
471 * @retval #MEDIA_CONTENT_ERROR_DB_BUSY DB Operation busy
472 * @retval #MEDIA_CONTENT_ERROR_NETWORK Network fail
473 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
475 * @pre This function requires opened connection to content service by media_content_connect().
477 * @see media_content_connect()
478 * @see media_playlist_destroy()
479 * @see media_playlist_add_media()
480 * @see media_playlist_remove_media()
481 * @see media_playlist_set_name()
482 * @see media_playlist_set_play_order()
484 int media_playlist_update_to_db(media_playlist_h playlist);
487 * @brief Imports the playlist from m3u playlist file.
488 * @details This function reads a playlist from the m3u playlist file and insert into the db.
492 * @privilege %http://tizen.org/privilege/content.write
494 * @remarks The @a playlist should be released using media_playlist_destroy().
495 * @remarks %http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage. \n
496 * %http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n
497 * This function does not support the file of extended m3u playlist.
499 * @param[in] playlist_name The name of the media playlist to save
500 * @param[in] path The path to import the playlist file
501 * @param[out] playlist The handle to the media playlist
503 * @return @c 0 on success,
504 * otherwise a negative error value
506 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
507 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
508 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
509 * @retval #MEDIA_CONTENT_ERROR_INVALID_OPERATION Invalid operation
510 * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB Operation failed
511 * @retval #MEDIA_CONTENT_ERROR_DB_BUSY DB Operation busy
512 * @retval #MEDIA_CONTENT_ERROR_NETWORK Network fail
513 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
515 int media_playlist_import_from_file(const char *playlist_name, const char *path, media_playlist_h *playlist);
518 * @brief Exports the playlist to m3u playlist file.
521 * @remarks %http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage. \n
522 * %http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.
524 * @param[in] playlist The handle to the media playlist
525 * @param[in] path path The path to export the playlist
527 * @return @c 0 on success,
528 * otherwise a negative error value
530 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
531 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
532 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
533 * @retval #MEDIA_CONTENT_ERROR_INVALID_OPERATION Invalid operation
534 * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB Operation failed
535 * @retval #MEDIA_CONTENT_ERROR_DB_BUSY DB Operation busy
536 * @retval #MEDIA_CONTENT_ERROR_NETWORK Network fail
537 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
539 int media_playlist_export_to_file(media_playlist_h playlist, const char* path);
547 #endif /* __cplusplus */
548 #endif /*__TIZEN_CONTENT_MEDIA_PLAYLIST_H__*/