/src/vlc/include/vlc_playlist.h
Line | Count | Source (jump to first uncovered line) |
1 | | /***************************************************************************** |
2 | | * vlc_playlist.h |
3 | | ***************************************************************************** |
4 | | * Copyright (C) 2018 VLC authors and VideoLAN |
5 | | * |
6 | | * This program is free software; you can redistribute it and/or modify it |
7 | | * under the terms of the GNU Lesser General Public License as published by |
8 | | * the Free Software Foundation; either version 2.1 of the License, or |
9 | | * (at your option) any later version. |
10 | | * |
11 | | * This program is distributed in the hope that it will be useful, |
12 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | | * GNU Lesser General Public License for more details. |
15 | | * |
16 | | * You should have received a copy of the GNU Lesser General Public License |
17 | | * along with this program; if not, write to the Free Software Foundation, |
18 | | * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. |
19 | | *****************************************************************************/ |
20 | | |
21 | | #ifndef VLC_PLAYLIST_NEW_H |
22 | | #define VLC_PLAYLIST_NEW_H |
23 | | |
24 | | #include <vlc_common.h> |
25 | | #include <vlc_preparser.h> |
26 | | |
27 | | # ifdef __cplusplus |
28 | | extern "C" { |
29 | | # endif |
30 | | |
31 | | /** |
32 | | * \defgroup playlist VLC playlist |
33 | | * \ingroup interface |
34 | | * |
35 | | * A VLC playlist contains a list of "playlist items". |
36 | | * |
37 | | * Each playlist item contains exactly one media (input item). In the future, |
38 | | * it might contain associated data. |
39 | | * |
40 | | * The API is intended to be simple, UI-friendly and allow for an |
41 | | * implementation both correct (no race conditions) and performant for common |
42 | | * use cases. |
43 | | * |
44 | | * UI frameworks typically use "list models" to provide a list of items to a |
45 | | * list view component. A list model requires to implement functions to: |
46 | | * - return the total number of items, |
47 | | * - return the item at a given index. |
48 | | * |
49 | | * In addition, it must notify the view when changes occur when: |
50 | | * - items are inserted (providing index and count), |
51 | | * - items are removed (providing index and count), |
52 | | * - items are moved (providing index, count, and target index), |
53 | | * - items are updated (providing index and count), |
54 | | * - the model is reset (the whole content should be considered changed). |
55 | | * |
56 | | * The API directly exposes what list models require. |
57 | | * |
58 | | * The core playlist may be modified from any thread, so it may not be used as |
59 | | * a direct data source for a list model. In other words, the functions of a |
60 | | * list model must not delegate the calls to the playlist. This would require |
61 | | * locking the playlist individually for each call to get the count and |
62 | | * retrieve each item (which is, in itself, not a good idea for UI |
63 | | * responsiveness), and would not be sufficient to guarantee correctness: the |
64 | | * playlist content could change between view calls so that a request to |
65 | | * retrieve an item at a specific index could be invalid (which would break the |
66 | | * list model expected behavior). |
67 | | * |
68 | | * As a consequence, the UI playlist should be considered as a remote |
69 | | * out-of-sync view of the core playlist. This implies that the UI needs to |
70 | | * keep a copy of the playlist content. |
71 | | * |
72 | | * Note that the copy must not be limited to the list of playlist items |
73 | | * (pointers) themselves, but also to the item's content which is displayed and |
74 | | * susceptible to change asynchronously (e.g. media metadata, like title or |
75 | | * duration). The UI should never lock a media (input item) for rendering a |
76 | | * playlist item; otherwise, the content could be changed (and exposed) before |
77 | | * the list model notified the view of this change (which, again, would break |
78 | | * the list model expected behavior). |
79 | | * |
80 | | * It is very important that the copy held by the UI is only modified through |
81 | | * the core playlist callbacks, to guarantee that the indexes notified are |
82 | | * valid in the context of the list model. In other words, from the client, the |
83 | | * playlist copy is a read-only "desynchronized" view of the core playlist. |
84 | | * |
85 | | * Moreover, the events triggered by the playlist must be kept in order until |
86 | | * they are handled. The callbacks may be called from any thread, with lock |
87 | | * held (in practice, the thread from which a change is requested). A UI will |
88 | | * typically need to handle the events in the UI thread, so it will usually |
89 | | * post the events in an event loop, to handle them from the UI thread. In that |
90 | | * case, be careful to always post the events in the event loop, even if the |
91 | | * current thread is already the UI thread, not to break the order of events. |
92 | | * |
93 | | * The playlist also handles the playback order and the repeat mode. It also |
94 | | * manages a cursor to the "current" item, and exposes whether previous and |
95 | | * next items (which depend on the playback order and repeat mode) are |
96 | | * available. |
97 | | * |
98 | | * When a user requests to insert, move or remove items, or to set the current |
99 | | * item, before the core playlist lock is successfully acquired, another client |
100 | | * may have changed the list. Therefore, vlc_playlist_Request*() functions are |
101 | | * exposed to resolve potential conflicts and apply the changes. The actual |
102 | | * changes applied are notified through the callbacks. |
103 | | * |
104 | | * @{ |
105 | | */ |
106 | | |
107 | | /* forward declarations */ |
108 | | typedef struct input_item_t input_item_t; |
109 | | typedef struct vlc_player_t vlc_player_t; |
110 | | |
111 | | /* opaque types */ |
112 | | typedef struct vlc_playlist vlc_playlist_t; |
113 | | typedef struct vlc_playlist_item vlc_playlist_item_t; |
114 | | typedef struct vlc_playlist_listener_id vlc_playlist_listener_id; |
115 | | |
116 | | enum vlc_playlist_playback_repeat |
117 | | { |
118 | | VLC_PLAYLIST_PLAYBACK_REPEAT_NONE, |
119 | | VLC_PLAYLIST_PLAYBACK_REPEAT_CURRENT, |
120 | | VLC_PLAYLIST_PLAYBACK_REPEAT_ALL, |
121 | | }; |
122 | | |
123 | | enum vlc_playlist_playback_order |
124 | | { |
125 | | VLC_PLAYLIST_PLAYBACK_ORDER_NORMAL, |
126 | | VLC_PLAYLIST_PLAYBACK_ORDER_RANDOM, |
127 | | }; |
128 | | |
129 | | enum vlc_playlist_sort_key |
130 | | { |
131 | | VLC_PLAYLIST_SORT_KEY_TITLE, |
132 | | VLC_PLAYLIST_SORT_KEY_DURATION, |
133 | | VLC_PLAYLIST_SORT_KEY_ARTIST, |
134 | | VLC_PLAYLIST_SORT_KEY_ALBUM, |
135 | | VLC_PLAYLIST_SORT_KEY_ALBUM_ARTIST, |
136 | | VLC_PLAYLIST_SORT_KEY_GENRE, |
137 | | VLC_PLAYLIST_SORT_KEY_DATE, |
138 | | VLC_PLAYLIST_SORT_KEY_TRACK_NUMBER, |
139 | | VLC_PLAYLIST_SORT_KEY_DISC_NUMBER, |
140 | | VLC_PLAYLIST_SORT_KEY_URL, |
141 | | VLC_PLAYLIST_SORT_KEY_RATING, |
142 | | VLC_PLAYLIST_SORT_KEY_FILE_SIZE, |
143 | | VLC_PLAYLIST_SORT_KEY_FILE_MODIFIED |
144 | | }; |
145 | | |
146 | | enum vlc_playlist_sort_order |
147 | | { |
148 | | VLC_PLAYLIST_SORT_ORDER_ASCENDING, |
149 | | VLC_PLAYLIST_SORT_ORDER_DESCENDING, |
150 | | }; |
151 | | |
152 | | struct vlc_playlist_sort_criterion |
153 | | { |
154 | | enum vlc_playlist_sort_key key; |
155 | | enum vlc_playlist_sort_order order; |
156 | | }; |
157 | | |
158 | | /** Preparsing depth */ |
159 | | enum vlc_playlist_preparsing |
160 | | { |
161 | | /** Don't parse anything */ |
162 | | VLC_PLAYLIST_PREPARSING_DISABLED, |
163 | | /** Auto parse items but don't auto-parse sub items */ |
164 | | VLC_PLAYLIST_PREPARSING_ENABLED, |
165 | | /** Auto parse sub items of items (1 level depth) */ |
166 | | VLC_PLAYLIST_PREPARSING_COLLAPSE, |
167 | | /** Auto parse all sub items recursively */ |
168 | | VLC_PLAYLIST_PREPARSING_RECURSIVE, |
169 | | }; |
170 | | |
171 | | /** |
172 | | * Action when a media is stopped |
173 | | * |
174 | | * @see vlc_playlist_SetMediaStoppedAction() |
175 | | */ |
176 | | enum vlc_playlist_media_stopped_action { |
177 | | /** Continue (or stop if there is no next media), default behavior */ |
178 | | VLC_PLAYLIST_MEDIA_STOPPED_CONTINUE, |
179 | | /** Pause when reaching the end of file */ |
180 | | VLC_PLAYLIST_MEDIA_STOPPED_PAUSE, |
181 | | /** Stop, even if there is a next media to play */ |
182 | | VLC_PLAYLIST_MEDIA_STOPPED_STOP, |
183 | | /** Exit VLC */ |
184 | | VLC_PLAYLIST_MEDIA_STOPPED_EXIT, |
185 | | }; |
186 | | |
187 | | /** |
188 | | * Playlist callbacks. |
189 | | * |
190 | | * A client may register a listener using vlc_playlist_AddListener() to listen |
191 | | * playlist events. |
192 | | * |
193 | | * All callbacks are called with the playlist locked (see vlc_playlist_Lock()). |
194 | | */ |
195 | | struct vlc_playlist_callbacks |
196 | | { |
197 | | /** |
198 | | * Called when the whole content has changed (e.g. when the playlist has |
199 | | * been cleared, shuffled or sorted). |
200 | | * |
201 | | * \param playlist the playlist |
202 | | * \param items the whole new content of the playlist |
203 | | * \param count the number of items |
204 | | * \param userdata userdata provided to AddListener() |
205 | | */ |
206 | | void |
207 | | (*on_items_reset)(vlc_playlist_t *, vlc_playlist_item_t *const items[], |
208 | | size_t count, void *userdata); |
209 | | |
210 | | /** |
211 | | * Called when items have been added to the playlist. |
212 | | * |
213 | | * \param playlist the playlist |
214 | | * \param index the index of the insertion |
215 | | * \param items the array of added items |
216 | | * \param count the number of items added |
217 | | * \param userdata userdata provided to AddListener() |
218 | | */ |
219 | | void |
220 | | (*on_items_added)(vlc_playlist_t *playlist, size_t index, |
221 | | vlc_playlist_item_t *const items[], size_t count, |
222 | | void *userdata); |
223 | | |
224 | | /** |
225 | | * Called when a slice of items have been moved. |
226 | | * |
227 | | * \param playlist the playlist |
228 | | * \param index the index of the first moved item |
229 | | * \param count the number of items moved |
230 | | * \param target the new index of the moved slice |
231 | | * \param userdata userdata provided to AddListener() |
232 | | */ |
233 | | void |
234 | | (*on_items_moved)(vlc_playlist_t *playlist, size_t index, size_t count, |
235 | | size_t target, void *userdata); |
236 | | /** |
237 | | * Called when a slice of items have been removed from the playlist. |
238 | | * |
239 | | * \param playlist the playlist |
240 | | * \param index the index of the first removed item |
241 | | * \param count the number of items removed |
242 | | * \param userdata userdata provided to AddListener() |
243 | | */ |
244 | | void |
245 | | (*on_items_removed)(vlc_playlist_t *playlist, size_t index, size_t count, |
246 | | void *userdata); |
247 | | |
248 | | /** |
249 | | * Called when an item has been updated via (pre-)parsing. |
250 | | * |
251 | | * \param playlist the playlist |
252 | | * \param index the index of the first updated item |
253 | | * \param items the array of updated items |
254 | | * \param count the number of items updated |
255 | | * \param userdata userdata provided to AddListener() |
256 | | */ |
257 | | void |
258 | | (*on_items_updated)(vlc_playlist_t *playlist, size_t index, |
259 | | vlc_playlist_item_t *const items[], size_t count, |
260 | | void *userdata); |
261 | | |
262 | | /** |
263 | | * Called when the playback repeat mode has been changed. |
264 | | * |
265 | | * \param playlist the playlist |
266 | | * \param repeat the new playback "repeat" mode |
267 | | * \param userdata userdata provided to AddListener() |
268 | | */ |
269 | | void |
270 | | (*on_playback_repeat_changed)(vlc_playlist_t *playlist, |
271 | | enum vlc_playlist_playback_repeat repeat, |
272 | | void *userdata); |
273 | | |
274 | | /** |
275 | | * Called when the playback order mode has been changed. |
276 | | * |
277 | | * \param playlist the playlist |
278 | | * \param rorder the new playback order |
279 | | * \param userdata userdata provided to AddListener() |
280 | | */ |
281 | | void |
282 | | (*on_playback_order_changed)(vlc_playlist_t *playlist, |
283 | | enum vlc_playlist_playback_order order, |
284 | | void *userdata); |
285 | | |
286 | | /** |
287 | | * Called when the current item index has changed. |
288 | | * |
289 | | * Note that the current item index may have changed while the current item |
290 | | * is still the same: it may have been moved. |
291 | | * |
292 | | * \param playlist the playlist |
293 | | * \param index the new current index (-1 if there is no current item) |
294 | | * \param userdata userdata provided to AddListener() |
295 | | */ |
296 | | void |
297 | | (*on_current_index_changed)(vlc_playlist_t *playlist, ssize_t index, |
298 | | void *userdata); |
299 | | |
300 | | /** |
301 | | * Called when the "has previous item" property has changed. |
302 | | * |
303 | | * This is typically useful to update any "previous" button in the UI. |
304 | | * |
305 | | * \param playlist the playlist |
306 | | * \param has_prev true if there is a previous item, false otherwise |
307 | | * \param userdata userdata provided to AddListener() |
308 | | */ |
309 | | void |
310 | | (*on_has_prev_changed)(vlc_playlist_t *playlist, bool has_prev, |
311 | | void *userdata); |
312 | | |
313 | | /** |
314 | | * Called when the "has next item" property has changed. |
315 | | * |
316 | | * This is typically useful to update any "next" button in the UI. |
317 | | * |
318 | | * \param playlist the playlist |
319 | | * \param has_next true if there is a next item, false otherwise |
320 | | * \param userdata userdata provided to AddListener() |
321 | | */ |
322 | | void |
323 | | (*on_has_next_changed)(vlc_playlist_t *playlist, |
324 | | bool has_next, void *userdata); |
325 | | |
326 | | /** |
327 | | * Called when the stopped action has changed |
328 | | * |
329 | | * @see vlc_playlist_SetMediaStoppedAction() |
330 | | * |
331 | | * \param playlist the playlist |
332 | | * @param new_action action to execute when a media is stopped |
333 | | * \param userdata userdata provided to AddListener() |
334 | | */ |
335 | | void (*on_media_stopped_action_changed)(vlc_playlist_t *playlist, |
336 | | enum vlc_playlist_media_stopped_action new_action, |
337 | | void *userdata); |
338 | | }; |
339 | | |
340 | | /* Playlist items */ |
341 | | |
342 | | /** |
343 | | * Hold a playlist item. |
344 | | * |
345 | | * Increment the refcount of the playlist item. |
346 | | */ |
347 | | VLC_API void |
348 | | vlc_playlist_item_Hold(vlc_playlist_item_t *); |
349 | | |
350 | | /** |
351 | | * Release a playlist item. |
352 | | * |
353 | | * Decrement the refcount of the playlist item, and destroy it if necessary. |
354 | | */ |
355 | | VLC_API void |
356 | | vlc_playlist_item_Release(vlc_playlist_item_t *); |
357 | | |
358 | | /** |
359 | | * Return the media associated to the playlist item. |
360 | | */ |
361 | | VLC_API input_item_t * |
362 | | vlc_playlist_item_GetMedia(vlc_playlist_item_t *); |
363 | | |
364 | | /** |
365 | | * Return a unique id for the playlist item instance. |
366 | | */ |
367 | | VLC_API uint64_t |
368 | | vlc_playlist_item_GetId(vlc_playlist_item_t *); |
369 | | |
370 | | /* Playlist */ |
371 | | |
372 | | /** |
373 | | * Create a new playlist. |
374 | | * |
375 | | * \param parent a VLC object |
376 | | * \param rec preparsing depth |
377 | | * \param preparse_max_threads the maximum number of threads used to parse, must be >= 1 |
378 | | * \param preparse_timeout default timeout of the preparser, 0 for no limits. |
379 | | * \return a pointer to a valid playlist instance, or NULL if an error occurred |
380 | | */ |
381 | | VLC_API VLC_USED vlc_playlist_t * |
382 | | vlc_playlist_New(vlc_object_t *parent, enum vlc_playlist_preparsing rec, |
383 | | unsigned preparse_max_threads, vlc_tick_t preparse_timeout); |
384 | | |
385 | | /** |
386 | | * Delete a playlist. |
387 | | * |
388 | | * All playlist items are released, and listeners are removed and destroyed. |
389 | | */ |
390 | | VLC_API void |
391 | | vlc_playlist_Delete(vlc_playlist_t *); |
392 | | |
393 | | /** |
394 | | * Lock the playlist/player. |
395 | | * |
396 | | * The playlist and its player share the same lock, to avoid lock-order |
397 | | * inversion issues. |
398 | | * |
399 | | * \warning Do not forget that the playlist and player lock are the same (or |
400 | | * you could lock twice the same and deadlock). |
401 | | * |
402 | | * Almost all playlist functions must be called with lock held (check their |
403 | | * description). |
404 | | * |
405 | | * The lock is not recursive. |
406 | | */ |
407 | | VLC_API void |
408 | | vlc_playlist_Lock(vlc_playlist_t *); |
409 | | |
410 | | /** |
411 | | * Unlock the playlist/player. |
412 | | */ |
413 | | VLC_API void |
414 | | vlc_playlist_Unlock(vlc_playlist_t *); |
415 | | |
416 | | /** |
417 | | * Add a playlist listener. |
418 | | * |
419 | | * Return an opaque listener identifier, to be passed to |
420 | | * vlc_player_RemoveListener(). |
421 | | * |
422 | | * If notify_current_state is true, the callbacks are called once with the |
423 | | * current state of the playlist. This is useful because when a client |
424 | | * registers to the playlist, it may already contain items. Calling callbacks |
425 | | * is a convenient way to initialize the client automatically. |
426 | | * |
427 | | * \param playlist the playlist, locked |
428 | | * \param cbs the callbacks (must be valid until the listener |
429 | | * is removed) |
430 | | * \param userdata userdata provided as a parameter in callbacks |
431 | | * \param notify_current_state true to notify the current state immediately via |
432 | | * callbacks |
433 | | * \return a listener identifier, or NULL if an error occurred |
434 | | */ |
435 | | VLC_API VLC_USED vlc_playlist_listener_id * |
436 | | vlc_playlist_AddListener(vlc_playlist_t *playlist, |
437 | | const struct vlc_playlist_callbacks *cbs, |
438 | | void *userdata, bool notify_current_state); |
439 | | |
440 | | /** |
441 | | * Remove a player listener. |
442 | | * |
443 | | * \param playlist the playlist, locked |
444 | | * \param id the listener identifier returned by |
445 | | * vlc_playlist_AddListener() |
446 | | */ |
447 | | VLC_API void |
448 | | vlc_playlist_RemoveListener(vlc_playlist_t *playlist, |
449 | | vlc_playlist_listener_id *id); |
450 | | |
451 | | /** |
452 | | * Setup an action when a media is stopped |
453 | | * |
454 | | * @param playlist the playlist, locked |
455 | | * @param action action to do when a media is stopped |
456 | | */ |
457 | | VLC_API void |
458 | | vlc_playlist_SetMediaStoppedAction(vlc_playlist_t *playlist, |
459 | | enum vlc_playlist_media_stopped_action action); |
460 | | |
461 | | /** |
462 | | * Return the number of items. |
463 | | * |
464 | | * \param playlist the playlist, locked |
465 | | */ |
466 | | VLC_API size_t |
467 | | vlc_playlist_Count(vlc_playlist_t *playlist); |
468 | | |
469 | | /** |
470 | | * Return the item at a given index. |
471 | | * |
472 | | * The index must be in range (less than vlc_playlist_Count()). |
473 | | * |
474 | | * \param playlist the playlist, locked |
475 | | * \param index the index |
476 | | * \return the playlist item |
477 | | */ |
478 | | VLC_API vlc_playlist_item_t * |
479 | | vlc_playlist_Get(vlc_playlist_t *playlist, size_t index); |
480 | | |
481 | | /** |
482 | | * Clear the playlist. |
483 | | * |
484 | | * \param playlist the playlist, locked |
485 | | */ |
486 | | VLC_API void |
487 | | vlc_playlist_Clear(vlc_playlist_t *playlist); |
488 | | |
489 | | /** |
490 | | * Insert a list of media at a given index. |
491 | | * |
492 | | * The index must be in range (less than or equal to vlc_playlist_Count()). |
493 | | * |
494 | | * \param playlist the playlist, locked |
495 | | * \param index the index where the media are to be inserted |
496 | | * \param media the array of media to insert |
497 | | * \param count the number of media to insert |
498 | | * \return VLC_SUCCESS on success, another value on error |
499 | | */ |
500 | | VLC_API int |
501 | | vlc_playlist_Insert(vlc_playlist_t *playlist, size_t index, |
502 | | input_item_t *const media[], size_t count); |
503 | | |
504 | | /** |
505 | | * Insert a media at a given index. |
506 | | * |
507 | | * The index must be in range (less than or equal to vlc_playlist_Count()). |
508 | | * |
509 | | * \param playlist the playlist, locked |
510 | | * \param index the index where the media is to be inserted |
511 | | * \param media the media to insert |
512 | | * \return VLC_SUCCESS on success, another value on error |
513 | | */ |
514 | | static inline int |
515 | | vlc_playlist_InsertOne(vlc_playlist_t *playlist, size_t index, |
516 | | input_item_t *media) |
517 | 0 | { |
518 | 0 | return vlc_playlist_Insert(playlist, index, &media, 1); |
519 | 0 | } Unexecuted instantiation: libvlc.c:vlc_playlist_InsertOne Unexecuted instantiation: media_source.c:vlc_playlist_InsertOne Unexecuted instantiation: interface.c:vlc_playlist_InsertOne Unexecuted instantiation: content.c:vlc_playlist_InsertOne Unexecuted instantiation: control.c:vlc_playlist_InsertOne Unexecuted instantiation: item.c:vlc_playlist_InsertOne Unexecuted instantiation: notify.c:vlc_playlist_InsertOne Unexecuted instantiation: player.c:vlc_playlist_InsertOne Unexecuted instantiation: playlist.c:vlc_playlist_InsertOne Unexecuted instantiation: preparse.c:vlc_playlist_InsertOne |
520 | | |
521 | | /** |
522 | | * Add a list of media at the end of the playlist. |
523 | | * |
524 | | * \param playlist the playlist, locked |
525 | | * \param media the array of media to append |
526 | | * \param count the number of media to append |
527 | | * \return VLC_SUCCESS on success, another value on error |
528 | | */ |
529 | | static inline int |
530 | | vlc_playlist_Append(vlc_playlist_t *playlist, input_item_t *const media[], |
531 | | size_t count) |
532 | 0 | { |
533 | 0 | size_t size = vlc_playlist_Count(playlist); |
534 | 0 | return vlc_playlist_Insert(playlist, size, media, count); |
535 | 0 | } Unexecuted instantiation: libvlc.c:vlc_playlist_Append Unexecuted instantiation: media_source.c:vlc_playlist_Append Unexecuted instantiation: interface.c:vlc_playlist_Append Unexecuted instantiation: content.c:vlc_playlist_Append Unexecuted instantiation: control.c:vlc_playlist_Append Unexecuted instantiation: item.c:vlc_playlist_Append Unexecuted instantiation: notify.c:vlc_playlist_Append Unexecuted instantiation: player.c:vlc_playlist_Append Unexecuted instantiation: playlist.c:vlc_playlist_Append Unexecuted instantiation: preparse.c:vlc_playlist_Append |
536 | | |
537 | | /** |
538 | | * Add a media at the end of the playlist. |
539 | | * |
540 | | * \param playlist the playlist, locked |
541 | | * \param media the media to append |
542 | | * \return VLC_SUCCESS on success, another value on error |
543 | | */ |
544 | | static inline int |
545 | | vlc_playlist_AppendOne(vlc_playlist_t *playlist, input_item_t *media) |
546 | 0 | { |
547 | 0 | return vlc_playlist_Append(playlist, &media, 1); |
548 | 0 | } Unexecuted instantiation: libvlc.c:vlc_playlist_AppendOne Unexecuted instantiation: media_source.c:vlc_playlist_AppendOne Unexecuted instantiation: interface.c:vlc_playlist_AppendOne Unexecuted instantiation: content.c:vlc_playlist_AppendOne Unexecuted instantiation: control.c:vlc_playlist_AppendOne Unexecuted instantiation: item.c:vlc_playlist_AppendOne Unexecuted instantiation: notify.c:vlc_playlist_AppendOne Unexecuted instantiation: player.c:vlc_playlist_AppendOne Unexecuted instantiation: playlist.c:vlc_playlist_AppendOne Unexecuted instantiation: preparse.c:vlc_playlist_AppendOne |
549 | | |
550 | | /** |
551 | | * Move a slice of items to a given target index. |
552 | | * |
553 | | * The slice and the target must be in range (both index+count and target+count |
554 | | * less than or equal to vlc_playlist_Count()). |
555 | | * |
556 | | * \param playlist the playlist, locked |
557 | | * \param index the index of the first item to move |
558 | | * \param count the number of items to move |
559 | | * \param target the new index of the moved slice |
560 | | */ |
561 | | VLC_API void |
562 | | vlc_playlist_Move(vlc_playlist_t *playlist, size_t index, size_t count, |
563 | | size_t target); |
564 | | |
565 | | /** |
566 | | * Move an item to a given target index. |
567 | | * |
568 | | * The index and the target must be in range (index less than, and target less |
569 | | * than or equal to, vlc_playlist_Count()). |
570 | | * |
571 | | * \param playlist the playlist, locked |
572 | | * \param index the index of the item to move |
573 | | * \param target the new index of the moved item |
574 | | */ |
575 | | static inline void |
576 | | vlc_playlist_MoveOne(vlc_playlist_t *playlist, size_t index, size_t target) |
577 | 0 | { |
578 | 0 | vlc_playlist_Move(playlist, index, 1, target); |
579 | 0 | } Unexecuted instantiation: libvlc.c:vlc_playlist_MoveOne Unexecuted instantiation: media_source.c:vlc_playlist_MoveOne Unexecuted instantiation: interface.c:vlc_playlist_MoveOne Unexecuted instantiation: content.c:vlc_playlist_MoveOne Unexecuted instantiation: control.c:vlc_playlist_MoveOne Unexecuted instantiation: item.c:vlc_playlist_MoveOne Unexecuted instantiation: notify.c:vlc_playlist_MoveOne Unexecuted instantiation: player.c:vlc_playlist_MoveOne Unexecuted instantiation: playlist.c:vlc_playlist_MoveOne Unexecuted instantiation: preparse.c:vlc_playlist_MoveOne |
580 | | |
581 | | /** |
582 | | * Remove a slice of items at a given index. |
583 | | * |
584 | | * The slice must be in range (index+count less than or equal to |
585 | | * vlc_playlist_Count()). |
586 | | * |
587 | | * \param playlist the playlist, locked |
588 | | * \param index the index of the first item to remove |
589 | | * \param count the number of items to remove |
590 | | */ |
591 | | VLC_API void |
592 | | vlc_playlist_Remove(vlc_playlist_t *playlist, size_t index, size_t count); |
593 | | |
594 | | /** |
595 | | * Remove an item at a given index. |
596 | | * |
597 | | * The index must be in range (less than vlc_playlist_Count()). |
598 | | * |
599 | | * \param playlist the playlist, locked |
600 | | * \param index the index of the item to remove |
601 | | */ |
602 | | static inline void |
603 | | vlc_playlist_RemoveOne(vlc_playlist_t *playlist, size_t index) |
604 | 0 | { |
605 | 0 | vlc_playlist_Remove(playlist, index, 1); |
606 | 0 | } Unexecuted instantiation: libvlc.c:vlc_playlist_RemoveOne Unexecuted instantiation: media_source.c:vlc_playlist_RemoveOne Unexecuted instantiation: interface.c:vlc_playlist_RemoveOne Unexecuted instantiation: content.c:vlc_playlist_RemoveOne Unexecuted instantiation: control.c:vlc_playlist_RemoveOne Unexecuted instantiation: item.c:vlc_playlist_RemoveOne Unexecuted instantiation: notify.c:vlc_playlist_RemoveOne Unexecuted instantiation: player.c:vlc_playlist_RemoveOne Unexecuted instantiation: playlist.c:vlc_playlist_RemoveOne Unexecuted instantiation: preparse.c:vlc_playlist_RemoveOne |
607 | | |
608 | | /** |
609 | | * Insert a list of media at a given index (if in range), or append. |
610 | | * |
611 | | * Contrary to vlc_playlist_Insert(), the index need not be in range: if it is |
612 | | * out of bounds, items will be appended. |
613 | | * |
614 | | * This is an helper to apply a desynchronized insert request, i.e. the |
615 | | * playlist content may have changed since the request had been submitted. |
616 | | * This is typically the case for user requests (e.g. from UI), because the |
617 | | * playlist lock has to be acquired *after* the user requested the |
618 | | * change. |
619 | | * |
620 | | * \param playlist the playlist, locked |
621 | | * \param index the index where the media are to be inserted |
622 | | * \param media the array of media to insert |
623 | | * \param count the number of media to insert |
624 | | * \return VLC_SUCCESS on success, another value on error |
625 | | */ |
626 | | VLC_API int |
627 | | vlc_playlist_RequestInsert(vlc_playlist_t *playlist, size_t index, |
628 | | input_item_t *const media[], size_t count); |
629 | | |
630 | | /** |
631 | | * Move a slice of items by value. |
632 | | * |
633 | | * If the indices are known, use vlc_playlist_Move() instead. |
634 | | * |
635 | | * This is an helper to apply a desynchronized move request, i.e. the playlist |
636 | | * content may have changed since the request had been submitted. This is |
637 | | * typically the case for user requests (e.g. from UI), because the playlist |
638 | | * lock has to be acquired *after* the user requested the change. |
639 | | * |
640 | | * For optimization purpose, it is possible to pass an `index_hint`, which is |
641 | | * the expected index of the first item of the slice (as known by the client). |
642 | | * Hopefully, the index should often match, since conflicts are expected to be |
643 | | * rare. Pass -1 not to pass any hint. |
644 | | * |
645 | | * \param playlist the playlist, locked |
646 | | * \param items the array of items to move |
647 | | * \param count the number of items to move |
648 | | * \param target the new index of the moved slice |
649 | | * \param index_hint the expected index of the first item (-1 for none) |
650 | | * \return VLC_SUCCESS on success, another value on error |
651 | | */ |
652 | | VLC_API int |
653 | | vlc_playlist_RequestMove(vlc_playlist_t *playlist, |
654 | | vlc_playlist_item_t *const items[], size_t count, |
655 | | size_t target, ssize_t index_hint); |
656 | | |
657 | | /** |
658 | | * Remove a slice of items by value. |
659 | | * |
660 | | * If the indices are known, use vlc_playlist_Remove() instead. |
661 | | * |
662 | | * This is an helper to apply a desynchronized remove request, i.e. the |
663 | | * playlist content may have changed since the request had been submitted. |
664 | | * This is typically the case for user requests (e.g. from UI), because the |
665 | | * playlist lock has to be acquired *after* the user requested the change. |
666 | | * |
667 | | * For optimization purpose, it is possible to pass an `index_hint`, which is |
668 | | * the expected index of the first item of the slice (as known by the client). |
669 | | * Hopefully, the index should often match, since conflicts are expected to be |
670 | | * rare. Pass -1 not to pass any hint. |
671 | | * |
672 | | * \param playlist the playlist, locked |
673 | | * \param items the array of items to remove |
674 | | * \param count the number of items to remove |
675 | | * \param index_hint the expected index of the first item (-1 for none) |
676 | | * \return VLC_SUCCESS on success, another value on error |
677 | | */ |
678 | | VLC_API int |
679 | | vlc_playlist_RequestRemove(vlc_playlist_t *playlist, |
680 | | vlc_playlist_item_t *const items[], size_t count, |
681 | | ssize_t index_hint); |
682 | | |
683 | | /** |
684 | | * Shuffle the playlist. |
685 | | * |
686 | | * \param playlist the playlist, locked |
687 | | */ |
688 | | VLC_API void |
689 | | vlc_playlist_Shuffle(vlc_playlist_t *playlist); |
690 | | |
691 | | /** |
692 | | * Sort the playlist by a list of criteria. |
693 | | * |
694 | | * \param playlist the playlist, locked |
695 | | * \param criteria the sort criteria (in order) |
696 | | * \param count the number of criteria |
697 | | * \return VLC_SUCCESS on success, another value on error |
698 | | */ |
699 | | VLC_API int |
700 | | vlc_playlist_Sort(vlc_playlist_t *playlist, |
701 | | const struct vlc_playlist_sort_criterion criteria[], |
702 | | size_t count); |
703 | | |
704 | | /** |
705 | | * Return the index of a given item. |
706 | | * |
707 | | * \param playlist the playlist, locked |
708 | | * \param item the item to locate |
709 | | * \return the index of the item (-1 if not found) |
710 | | */ |
711 | | VLC_API ssize_t |
712 | | vlc_playlist_IndexOf(vlc_playlist_t *playlist, const vlc_playlist_item_t *item); |
713 | | |
714 | | /** |
715 | | * Return the index of a given media. |
716 | | * |
717 | | * \param playlist the playlist, locked |
718 | | * \param media the media to locate |
719 | | * \return the index of the playlist item containing the media (-1 if not found) |
720 | | */ |
721 | | VLC_API ssize_t |
722 | | vlc_playlist_IndexOfMedia(vlc_playlist_t *playlist, const input_item_t *media); |
723 | | |
724 | | /** |
725 | | * Return the index of a given item id. |
726 | | * |
727 | | * \param playlist the playlist, locked |
728 | | * \param id the id to locate |
729 | | * \return the index of the playlist item having the id (-1 if not found) |
730 | | */ |
731 | | VLC_API ssize_t |
732 | | vlc_playlist_IndexOfId(vlc_playlist_t *playlist, uint64_t id); |
733 | | |
734 | | /** |
735 | | * Return the playback "repeat" mode. |
736 | | * |
737 | | * \param playlist the playlist, locked |
738 | | * \return the playback "repeat" mode |
739 | | */ |
740 | | VLC_API enum vlc_playlist_playback_repeat |
741 | | vlc_playlist_GetPlaybackRepeat(vlc_playlist_t *playlist); |
742 | | |
743 | | /** |
744 | | * Return the playback order. |
745 | | * |
746 | | * \param playlist the playlist, locked |
747 | | * \return the playback order |
748 | | */ |
749 | | VLC_API enum vlc_playlist_playback_order |
750 | | vlc_playlist_GetPlaybackOrder(vlc_playlist_t *playlist); |
751 | | |
752 | | /** |
753 | | * Change the playback "repeat" mode. |
754 | | * |
755 | | * \param playlist the playlist, locked |
756 | | * \param repeat the new playback "repeat" mode |
757 | | */ |
758 | | VLC_API void |
759 | | vlc_playlist_SetPlaybackRepeat(vlc_playlist_t *playlist, |
760 | | enum vlc_playlist_playback_repeat repeat); |
761 | | |
762 | | /** |
763 | | * Change the playback order |
764 | | * |
765 | | * \param playlist the playlist, locked |
766 | | * \param order the new playback order |
767 | | */ |
768 | | VLC_API void |
769 | | vlc_playlist_SetPlaybackOrder(vlc_playlist_t *playlist, |
770 | | enum vlc_playlist_playback_order order); |
771 | | |
772 | | /** |
773 | | * Return the index of the current item. |
774 | | * |
775 | | * \param playlist the playlist, locked |
776 | | * \return the index of the current item, -1 if none. |
777 | | */ |
778 | | VLC_API ssize_t |
779 | | vlc_playlist_GetCurrentIndex(vlc_playlist_t *playlist); |
780 | | |
781 | | /** |
782 | | * Indicate whether a previous item is available. |
783 | | * |
784 | | * \param playlist the playlist, locked |
785 | | * \retval true if a previous item is available |
786 | | * \retval false if no previous item is available |
787 | | */ |
788 | | VLC_API bool |
789 | | vlc_playlist_HasPrev(vlc_playlist_t *playlist); |
790 | | |
791 | | /** |
792 | | * Indicate whether a next item is available. |
793 | | * |
794 | | * \param playlist the playlist, locked |
795 | | * \retval true if a next item is available |
796 | | * \retval false if no next item is available |
797 | | */ |
798 | | VLC_API bool |
799 | | vlc_playlist_HasNext(vlc_playlist_t *playlist); |
800 | | |
801 | | /** |
802 | | * Go to the previous item. |
803 | | * |
804 | | * Return VLC_EGENERIC if vlc_playlist_HasPrev() returns false. |
805 | | * |
806 | | * \param playlist the playlist, locked |
807 | | * \return VLC_SUCCESS on success, another value on error |
808 | | */ |
809 | | VLC_API int |
810 | | vlc_playlist_Prev(vlc_playlist_t *playlist); |
811 | | |
812 | | /** |
813 | | * Go to the next item. |
814 | | * |
815 | | * Return VLC_EGENERIC if vlc_playlist_HasNext() returns false. |
816 | | * |
817 | | * \param playlist the playlist, locked |
818 | | * \return VLC_SUCCESS on success, another value on error |
819 | | */ |
820 | | VLC_API int |
821 | | vlc_playlist_Next(vlc_playlist_t *playlist); |
822 | | |
823 | | /** |
824 | | * Go to a given index. |
825 | | * |
826 | | * the index must be -1 or in range (less than vlc_playlist_Count()). |
827 | | * |
828 | | * \param playlist the playlist, locked |
829 | | * \param index the index to go to (-1 to none) |
830 | | * \return VLC_SUCCESS on success, another value on error |
831 | | */ |
832 | | VLC_API int |
833 | | vlc_playlist_GoTo(vlc_playlist_t *playlist, ssize_t index); |
834 | | |
835 | | /** |
836 | | * Go to a given item. |
837 | | * |
838 | | * If the index is known, use vlc_playlist_GoTo() instead. |
839 | | * |
840 | | * This is a helper to apply a desynchronized "go to" request, i.e. the |
841 | | * playlist content may have changed since the request had been submitted. |
842 | | * This is typically the case for user requests (e.g. from UI), because the |
843 | | * playlist lock has to be acquired *after* the user requested the change. |
844 | | * |
845 | | * For optimization purpose, it is possible to pass an `index_hint`, which is |
846 | | * the expected index of the first item of the slice (as known by the client). |
847 | | * Hopefully, the index should often match, since conflicts are expected to be |
848 | | * rare. Pass -1 not to pass any hint. |
849 | | * |
850 | | * \param playlist the playlist, locked |
851 | | * \param item the item to go to (NULL for none) |
852 | | * \param index_hint the expected index of the item (-1 for none) |
853 | | * \return VLC_SUCCESS on success, another value on error |
854 | | */ |
855 | | VLC_API int |
856 | | vlc_playlist_RequestGoTo(vlc_playlist_t *playlist, vlc_playlist_item_t *item, |
857 | | ssize_t index_hint); |
858 | | |
859 | | /** |
860 | | * Return the player owned by the playlist. |
861 | | * |
862 | | * \param playlist the playlist (not necessarily locked) |
863 | | * \return the player |
864 | | */ |
865 | | VLC_API vlc_player_t * |
866 | | vlc_playlist_GetPlayer(vlc_playlist_t *playlist); |
867 | | |
868 | | /** |
869 | | * Start the player. |
870 | | * |
871 | | * \param playlist the playlist, locked |
872 | | * \return VLC_SUCCESS on success, another value on error |
873 | | */ |
874 | | VLC_API int |
875 | | vlc_playlist_Start(vlc_playlist_t *playlist); |
876 | | |
877 | | /** |
878 | | * Stop the player. |
879 | | * |
880 | | * \param playlist the playlist, locked |
881 | | */ |
882 | | VLC_API void |
883 | | vlc_playlist_Stop(vlc_playlist_t *playlist); |
884 | | |
885 | | /** |
886 | | * Pause the player. |
887 | | * |
888 | | * \param playlist the playlist, locked |
889 | | */ |
890 | | VLC_API void |
891 | | vlc_playlist_Pause(vlc_playlist_t *playlist); |
892 | | |
893 | | /** |
894 | | * Resume the player. |
895 | | * |
896 | | * \param playlist the playlist, locked |
897 | | */ |
898 | | VLC_API void |
899 | | vlc_playlist_Resume(vlc_playlist_t *playlist); |
900 | | |
901 | | /** |
902 | | * Go to the given index and plays the corresponding item. |
903 | | * |
904 | | * \param playlist the playlist, locked |
905 | | * \param index the index to play at |
906 | | * \return VLC_SUCCESS on success, another value on error |
907 | | */ |
908 | | static inline int |
909 | | vlc_playlist_PlayAt(vlc_playlist_t *playlist, size_t index) |
910 | 0 | { |
911 | 0 | int ret = vlc_playlist_GoTo(playlist, index); |
912 | 0 | if (ret != VLC_SUCCESS) |
913 | 0 | return ret; |
914 | 0 | return vlc_playlist_Start(playlist); |
915 | 0 | } Unexecuted instantiation: libvlc.c:vlc_playlist_PlayAt Unexecuted instantiation: media_source.c:vlc_playlist_PlayAt Unexecuted instantiation: interface.c:vlc_playlist_PlayAt Unexecuted instantiation: content.c:vlc_playlist_PlayAt Unexecuted instantiation: control.c:vlc_playlist_PlayAt Unexecuted instantiation: item.c:vlc_playlist_PlayAt Unexecuted instantiation: notify.c:vlc_playlist_PlayAt Unexecuted instantiation: player.c:vlc_playlist_PlayAt Unexecuted instantiation: playlist.c:vlc_playlist_PlayAt Unexecuted instantiation: preparse.c:vlc_playlist_PlayAt |
916 | | |
917 | | /** |
918 | | * Export the playlist to a file. |
919 | | * |
920 | | * \param playlist a playlist instance |
921 | | * \param filename the location where the exported file will be saved |
922 | | * \param type the type of the playlist file to create (m3u, m3u8, xspf, ...) |
923 | | * \return VLC_SUCCESS on success, another value on error |
924 | | */ |
925 | | // XXX use vlc_memstream instead of filename? |
926 | | VLC_API int |
927 | | vlc_playlist_Export(vlc_playlist_t *playlist, const char *filename, |
928 | | const char *type); |
929 | | |
930 | | /** @} */ |
931 | | # ifdef __cplusplus |
932 | | } |
933 | | # endif |
934 | | |
935 | | #endif |