demux: mp4: remove unused chunk sample index
[vlc.git] / src / playlist / randomizer.h
blob8835ab7d3744aa85ad69947788a5f36ac775129c
1 /*****************************************************************************
2 * randomizer.h
3 *****************************************************************************
4 * Copyright (C) 2018 VLC authors and VideoLAN
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.
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.
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 *****************************************************************************/
21 #ifndef RANDOMIZER_H
22 #define RANDOMIZER_H
24 #include <vlc_common.h>
25 #include <vlc_vector.h>
27 typedef struct vlc_playlist_item vlc_playlist_item_t;
29 /**
30 * \defgroup playlist_randomizer Playlist randomizer helper
31 * \ingroup playlist
32 * @{ */
34 /**
35 * Playlist helper to manage random playback.
37 * See randomizer.c for implementation details.
39 struct randomizer {
40 struct VLC_VECTOR(vlc_playlist_item_t *) items;
41 unsigned short xsubi[3]; /* random state */
42 bool loop;
43 size_t head;
44 size_t next;
45 size_t history;
48 /**
49 * Initialize an empty randomizer.
51 void
52 randomizer_Init(struct randomizer *randomizer);
54 /**
55 * Destroy a randomizer.
57 void
58 randomizer_Destroy(struct randomizer *randomizer);
60 /**
61 * Enable or disable "loop" mode.
63 * This affects the behavior of prev/next.
65 void
66 randomizer_SetLoop(struct randomizer *randomizer, bool loop);
68 /**
69 * Return the number of items in the randomizer.
71 bool
72 randomizer_Count(struct randomizer *randomizer);
74 /**
75 * Start a new random cycle.
77 * The "history" is lost, and "next" can be called _n_ times if the randomizer
78 * contains _n_ items (when loop is disabled).
80 void
81 randomizer_Reshuffle(struct randomizer *randomizer);
83 /**
84 * Indicate whether there is a previous item.
86 bool
87 randomizer_HasPrev(struct randomizer *randomizer);
89 /**
90 * Indicate whether there is a next item.
92 bool
93 randomizer_HasNext(struct randomizer *randomizer);
95 /**
96 * Peek the previous item (without changing the current one).
98 vlc_playlist_item_t *
99 randomizer_PeekPrev(struct randomizer *randomizer);
102 * Peek the next item (without changing the current one).
104 vlc_playlist_item_t *
105 randomizer_PeekNext(struct randomizer *randomizer);
108 * Go back to the previous item.
110 vlc_playlist_item_t *
111 randomizer_Prev(struct randomizer *randomizer);
114 * Go back to the next item.
116 vlc_playlist_item_t *
117 randomizer_Next(struct randomizer *randomizer);
120 * Force the selection of a specific item.
122 * This function should be called when the user requested to play a specific
123 * item in the playlist.
125 void
126 randomizer_Select(struct randomizer *randomizer,
127 const vlc_playlist_item_t *item);
130 * Add items to the randomizer.
132 * This function should be called when items are added to the playlist.
134 bool
135 randomizer_Add(struct randomizer *randomizer, vlc_playlist_item_t *items[],
136 size_t count);
139 * Remove items from the randomizer.
141 * This function should be called when items are removed from the playlist.
143 void
144 randomizer_Remove(struct randomizer *randomizer,
145 vlc_playlist_item_t *const items[], size_t count);
148 * Clear the randomizer.
150 void
151 randomizer_Clear(struct randomizer *randomizer);
153 /** @} */
155 #endif