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.
42 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
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
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.
68 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
70 * @param[in] filter The handle to the media 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.
95 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
97 * @param[in] playlist_id The ID of the media playlist
98 * @param[in] filter The handle to the media filter
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 @a callback for
120 * every retrieved media info. If @c NULL is passed to the @a filter, no filtering is applied.
122 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
124 * @param[in] playlist_id The ID of the media playlist
125 * @param[in] filter The handle to the media filter
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.
150 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
153 * @privilege %http://tizen.org/privilege/content.write
155 * @remarks The @a playlist should be released using media_playlist_destroy().
157 * @param[in] name The name of the inserted playlist
158 * @param[out] playlist The handle to the 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.
181 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
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.
212 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
214 * @remarksThe @a playlist should be released using media_playlist_destroy().
216 * @param[in] playlist_id The ID of the media playlist
217 * @param[out] playlist The handle to the media playlist
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.
242 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
244 * @param[in] playlist The handle to the media playlist
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
252 * @pre Get a copy of playlist handle by calling media_playlist_clone() or media_playlist_insert_to_db().
254 * @see media_playlist_clone()
256 int media_playlist_destroy(media_playlist_h playlist);
259 * @brief Clones a playlist handle.
260 * @details This function copies the media playlist handle from a source to
261 * destination. There is no media_playlist_create() function. The media_playlist_h is created internally and available through
262 * media playlist foreach function such as media_playlist_foreach_playlist_from_db().
263 * To use this handle outside of these foreach functions, use this function.
265 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
267 * @remarks The @ a dst should be released using media_playlist_destroy().
269 * @param[out] dst The destination handle to the media playlist
270 * @param[in] src The source handle to the media playlist
272 * @return @c 0 on success,
273 * otherwise a negative error value
275 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
276 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
277 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
279 * @see media_playlist_destroy()
280 * @see media_playlist_foreach_playlist_from_db()
282 int media_playlist_clone(media_playlist_h *dst, media_playlist_h src);
285 * @brief Gets the media playlist ID.
286 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
288 * @param[in] playlist The handle to the media playlist
289 * @param[out] playlist_id The ID of the media playlist
291 * @return @c 0 on success,
292 * otherwise a negative error value
294 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
295 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
297 int media_playlist_get_playlist_id(media_playlist_h playlist, int *playlist_id);
300 * @brief Gets a name of the playlist.
301 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
303 * @remarks The @a playlist_name should be released using free().
305 * @param[in] playlist The handle to the media playlist
306 * @param[out] playlist_name The playlist name
308 * @return @c 0 on success,
309 * otherwise a negative error value
311 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
312 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
313 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
315 int media_playlist_get_name(media_playlist_h playlist, char **playlist_name);
318 * @brief Sets the name of the playlist.
319 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
321 * @param[in] playlist The handle to the media playlist
322 * @param[in] playlist_name The name of the media playlist
324 * @return @c 0 on success,
325 * otherwise a negative error value
327 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
328 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
329 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
331 * @post media_playlist_update_to_db()
334 int media_playlist_set_name(media_playlist_h playlist, const char *playlist_name);
337 * @brief Gets a thumbnail path of the playlist.
338 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
340 * @remarks The @a path should be released using free().
342 * @param[in] playlist The handle to the media playlist
343 * @param[out] path The path of the thumbnail
345 * @return @c 0 on success,
346 * otherwise a negative error value
348 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
349 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
350 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
352 int media_playlist_get_thumbnail_path(media_playlist_h playlist, char **path);
355 * @brief Sets the thumbnail path of the playlist.
356 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
358 * @param[in] playlist The handle to the media playlist
359 * @param[in] path The path of the thumbnail
361 * @return @c 0 on success,
362 * otherwise a negative error value
364 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
365 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
366 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
368 * @post media_playlist_update_to_db()
370 int media_playlist_set_thumbnail_path(media_playlist_h playlist, const char *path);
374 * @brief Sets the playing order in the playlist.
375 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
377 * @param[in] playlist The handle to the media playlist
378 * @param[in] playlist_member_id The ID of the playlist member
379 * @param[in] play_order The playing order
381 * @return @c 0 on success,
382 * otherwise a negative error value
384 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
385 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
386 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
388 * @post media_playlist_update_to_db()
390 int media_playlist_set_play_order(media_playlist_h playlist, int playlist_member_id, int play_order);
393 * @brief Adds a new media info to the playlist.
394 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
396 * @param[in] playlist The handle to the media playlist
397 * @param[in] media_id The media ID
399 * @return @c 0 on success,
400 * otherwise a negative error value
402 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
403 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
404 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
406 * @pre This function requires opened connection to content service by media_content_connect().
407 * @post media_playlist_update_to_db()
409 * @see media_content_connect()
410 * @see media_playlist_remove_media()
412 int media_playlist_add_media(media_playlist_h playlist, const char *media_id);
415 * @brief Removes the playlist members related with the media from the given playlist.
416 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
418 * @param[in] playlist The handle to the media playlist
419 * @param[in] playlist_member_id The ID of the playlist member
421 * @return @c 0 on success,
422 * otherwise a negative error value
424 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
425 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
426 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
428 * @pre This function requires opened connection to content service by media_content_connect().
429 * @post media_playlist_update_to_db()
431 * @see media_content_connect()
432 * @see media_playlist_add_media()
434 int media_playlist_remove_media(media_playlist_h playlist, int playlist_member_id);
437 * @brief Gets the played order of the playlist.
438 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
440 * @param[in] playlist The handle to the media playlist
441 * @param[in] playlist_member_id The ID of the playlist member
442 * @param[out] play_order The played order
444 * @return @c 0 on success,
445 * otherwise a negative error value
447 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
448 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
450 int media_playlist_get_play_order(media_playlist_h playlist, int playlist_member_id, int *play_order);
453 * @brief Updates the media playlist to the media database.
455 * @details The function updates the given media playlist in the media database.
456 * The function should be called after any change in the playlist, to be updated to the media database.
457 * For example, after using media_playlist_set_name() for setting the name of the playlist, the
458 * media_playlist_update_to_db() function should be called so as to update
459 * the given playlist attributes in the media database.
461 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
464 * @privilege %http://tizen.org/privilege/content.write
466 * @param[in] playlist The handle to the media playlist
468 * @return @c 0 on success,
469 * otherwise a negative error value
471 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
472 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
473 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
474 * @retval #MEDIA_CONTENT_ERROR_INVALID_OPERATION Invalid operation
475 * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB Operation failed
476 * @retval #MEDIA_CONTENT_ERROR_DB_BUSY DB Operation busy
477 * @retval #MEDIA_CONTENT_ERROR_NETWORK Network fail
478 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
480 * @pre This function requires opened connection to content service by media_content_connect().
482 * @see media_content_connect()
483 * @see media_playlist_destroy()
484 * @see media_playlist_add_media()
485 * @see media_playlist_remove_media()
486 * @see media_playlist_set_name()
487 * @see media_playlist_set_play_order()
489 int media_playlist_update_to_db(media_playlist_h playlist);
492 * @brief Imports the playlist from m3u playlist file.
493 * @details This function reads a playlist from the m3u playlist file and insert into the db.
494 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
497 * @privilege %http://tizen.org/privilege/content.write
499 * @remarks The @ a playlist should be released using media_playlist_destroy().
500 * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage. \n
501 * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n
502 * This function does not support the file of extended m3u playlist.
504 * @param[in] playlist_name The name of the media playlist to save
505 * @param[in] path The path to import the playlist file
506 * @param[out] playlist The handle to the media playlist
508 * @return @c 0 on success,
509 * otherwise a negative error value
511 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
512 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
513 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
514 * @retval #MEDIA_CONTENT_ERROR_INVALID_OPERATION Invalid operation
515 * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB Operation failed
516 * @retval #MEDIA_CONTENT_ERROR_DB_BUSY DB Operation busy
517 * @retval #MEDIA_CONTENT_ERROR_NETWORK Network fail
518 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
520 int media_playlist_import_from_file(const char *playlist_name, const char *path, media_playlist_h *playlist);
523 * @brief Exports the playlist to m3u playlist file.
524 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
526 * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage. \n
527 * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n
529 * @param[in] playlist The handle to the media playlist
530 * @param[in] path path The path to export the playlist
532 * @return @c 0 on success,
533 * otherwise a negative error value
535 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
536 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
537 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
538 * @retval #MEDIA_CONTENT_ERROR_INVALID_OPERATION Invalid operation
539 * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB Operation failed
540 * @retval #MEDIA_CONTENT_ERROR_DB_BUSY DB Operation busy
541 * @retval #MEDIA_CONTENT_ERROR_NETWORK Network fail
542 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
544 int media_playlist_export_to_file(media_playlist_h playlist, const char* path);
552 #endif /* __cplusplus */
553 #endif /*__TIZEN_CONTENT_MEDIA_PLAYLIST_H__*/