11 /// \defgroup PlaytreeIterReturn Playtree iterator return code
12 /// \ingroup PlaytreeIter
14 #define PLAY_TREE_ITER_ERROR 0
15 #define PLAY_TREE_ITER_ENTRY 1
16 #define PLAY_TREE_ITER_NODE 2
17 #define PLAY_TREE_ITER_END 3
20 /// \defgroup PlaytreeEntryTypes Playtree entry types
23 #define PLAY_TREE_ENTRY_NODE -1
24 #define PLAY_TREE_ENTRY_DVD 0
25 #define PLAY_TREE_ENTRY_VCD 1
26 #define PLAY_TREE_ENTRY_TV 2
27 #define PLAY_TREE_ENTRY_FILE 3
31 /// \defgroup PlaytreeEntryFlags Playtree flags
34 /// Play the item childs in random order.
35 #define PLAY_TREE_RND (1<<0)
36 /// Playtree flags used by the iterator to mark items already "randomly" played.
37 #define PLAY_TREE_RND_PLAYED (1<<8)
40 /// \defgroup PlaytreeIterMode Playtree iterator mode
41 /// \ingroup PlaytreeIter
43 #define PLAY_TREE_ITER_NORMAL 0
44 #define PLAY_TREE_ITER_RND 1
47 /// \defgroup Playtree
50 typedef struct play_tree play_tree_t
;
51 /// \ingroup PlaytreeIter
52 typedef struct play_tree_iter play_tree_iter_t
;
53 typedef struct play_tree_param play_tree_param_t
;
57 typedef struct play_tree_info play_tree_info_t
;
58 // TODO : a attrib,val pair system and not something hardcoded
59 struct play_tree_info
{
68 struct play_tree_param
{
81 //play_tree_info_t info;
82 play_tree_param_t
* params
;
90 /// \defgroup PlaytreeIter Playtree iterator
95 struct play_tree_iter
{
96 /// Root of the iterated tree.
98 /// Current position in the tree.
100 /// \ref Config used.
101 struct m_config
* config
;
104 /// Selected file in the current item.
106 /// Number of files in the current item.
111 /// loop/valid stack to save/revert status when we go up/down.
113 /// status stack size
118 /// Create a new empty playtree item.
122 /// Free a playtree item.
123 /** \param pt Item to free.
124 * \param childs If non-zero the item's childs are recursively freed.
127 play_tree_free(play_tree_t
* pt
, int childs
);
130 /// Free an item and its siblings.
131 /** \param pt Item to free.
132 * \param childs If non-zero the items' childs are recursively freed.
135 play_tree_free_list(play_tree_t
* pt
, int childs
);
138 /// Set the childs of a playtree item.
140 play_tree_set_child(play_tree_t
* pt
, play_tree_t
* child
);
142 /// Set the parent of a playtree item.
144 play_tree_set_parent(play_tree_t
* pt
, play_tree_t
* parent
);
147 /// Append an item after its siblings.
149 play_tree_append_entry(play_tree_t
* pt
, play_tree_t
* entry
);
151 /// Prepend an item before its siblings.
153 play_tree_prepend_entry(play_tree_t
* pt
, play_tree_t
* entry
);
155 /// Insert an item right after a siblings.
157 play_tree_insert_entry(play_tree_t
* pt
, play_tree_t
* entry
);
159 /// Detach an item from the tree.
161 play_tree_remove(play_tree_t
* pt
, int free_it
,int with_childs
);
163 /// Add a file to an item.
165 play_tree_add_file(play_tree_t
* pt
,char* file
);
167 /// Remove a file from an item.
169 play_tree_remove_file(play_tree_t
* pt
,char* file
);
172 /// Add a config paramter to an item.
174 play_tree_set_param(play_tree_t
* pt
, char* name
, char* val
);
176 /// Remove a config parameter from an item.
178 play_tree_unset_param(play_tree_t
* pt
, char* name
);
180 /// Copy the config parameters from one item to another.
182 play_tree_set_params_from(play_tree_t
* dest
,play_tree_t
* src
);
184 /// \addtogroup PlaytreeIter
187 /// Create a new iterator.
189 play_tree_iter_new(play_tree_t
* pt
, struct m_config
* config
);
191 /// Duplicate an iterator.
193 play_tree_iter_new_copy(play_tree_iter_t
* old
);
195 /// Free an iterator.
197 play_tree_iter_free(play_tree_iter_t
* iter
);
199 /// Step an iterator.
200 /** \param iter The iterator.
201 * \param d The direction: d > 0 == next , d < 0 == prev
202 * \param with_node TRUE == stop on nodes with childs, FALSE == go directly to the next child
203 * \return See \ref PlaytreeIterReturn.
206 play_tree_iter_step(play_tree_iter_t
* iter
, int d
,int with_nodes
);
208 /// Step up, usefull to break a loop, etc.
209 /** \param iter The iterator.
210 * \param d The direction: d > 0 == next , d < 0 == prev
211 * \param with_node TRUE == stop on nodes with childs, FALSE == go directly to the next child
212 * \return See \ref PlaytreeIterReturn.
215 play_tree_iter_up_step(play_tree_iter_t
* iter
, int d
,int with_nodes
);
217 /// Enter a node child list, only usefull when stopping on nodes.
219 play_tree_iter_down_step(play_tree_iter_t
* iter
, int d
,int with_nodes
);
221 /// Get a file from the current item.
223 play_tree_iter_get_file(play_tree_iter_t
* iter
, int d
);
226 // PlaytreeIter group
228 /// Create a playtree from a playlist file.
229 /** \ingroup PlaytreeParser
232 parse_playtree(struct stream_st
*stream
, int forced
);
234 /// Clean a tree by destroying all empty elements.
236 play_tree_cleanup(play_tree_t
* pt
);
238 /// Create a playtree from a playlist file.
239 /** \ingroup PlaytreeParser
242 parse_playlist_file(char* file
);
244 /// \defgroup PtAPI Playtree highlevel API
245 /// \ingroup Playtree
246 /// Highlevel API with pt-suffix to different from low-level API
247 /// by Fabian Franz (mplayer@fabian-franz.de).
250 // Cleans up pt and creates a new iter.
251 play_tree_iter_t
* pt_iter_create(play_tree_t
** pt
, struct m_config
* config
);
254 void pt_iter_destroy(play_tree_iter_t
** iter
);
256 /// Gets the next available file in the direction (d=-1 || d=+1).
257 char* pt_iter_get_file(play_tree_iter_t
* iter
, int d
);
259 // Two Macros that implement forward and backward direction.
260 #define pt_iter_get_next_file(iter) pt_iter_get_file(iter, 1)
261 #define pt_iter_get_prev_file(iter) pt_iter_get_file(iter, -1)
263 /// Inserts entry into the playtree.
264 void pt_iter_insert_entry(play_tree_iter_t
* iter
, play_tree_t
* entry
);
266 /// Replaces current entry in playtree with entry by doing insert and remove.
267 void pt_iter_replace_entry(play_tree_iter_t
* iter
, play_tree_t
* entry
);
269 /// Adds a new file to the playtree, if it is not valid it is created.
270 void pt_add_file(play_tree_t
** ppt
, char* filename
);
272 /// \brief Performs a convert to playtree-syntax, by concat path/file
273 /// and performs pt_add_file
274 void pt_add_gui_file(play_tree_t
** ppt
, char* path
, char* file
);
276 // Two macros to use only the iter and not the other things.
277 #define pt_iter_add_file(iter, filename) pt_add_file(&iter->tree, filename)
278 #define pt_iter_add_gui_file(iter, path, name) pt_add_gui_file(&iter->tree, path, name)
280 /// Resets the iter and goes back to head.
281 void pt_iter_goto_head(play_tree_iter_t
* iter
);