Reuse the code for the general do_dr1 case to set get_buffer/release_buffer for XvMC.
[mplayer/glamo.git] / playtree.h
blob7e454ad1fa9af06cf4341e0229cc92b79feff447
1 #ifndef MPLAYER_PLAYTREE_H
2 #define MPLAYER_PLAYTREE_H
4 /// \file
5 /// \ingroup Playtree
7 struct stream_st;
8 struct m_config;
10 /// \defgroup PlaytreeIterReturn Playtree iterator return code
11 /// \ingroup PlaytreeIter
12 ///@{
13 #define PLAY_TREE_ITER_ERROR 0
14 #define PLAY_TREE_ITER_ENTRY 1
15 #define PLAY_TREE_ITER_NODE 2
16 #define PLAY_TREE_ITER_END 3
17 ///@}
19 /// \defgroup PlaytreeEntryTypes Playtree entry types
20 /// \ingroup Playtree
21 ///@{
22 #define PLAY_TREE_ENTRY_NODE -1
23 #define PLAY_TREE_ENTRY_DVD 0
24 #define PLAY_TREE_ENTRY_VCD 1
25 #define PLAY_TREE_ENTRY_TV 2
26 #define PLAY_TREE_ENTRY_FILE 3
27 ///@}
30 /// \defgroup PlaytreeEntryFlags Playtree flags
31 /// \ingroup Playtree
32 ///@{
33 /// Play the item children in random order.
34 #define PLAY_TREE_RND (1<<0)
35 /// Playtree flags used by the iterator to mark items already "randomly" played.
36 #define PLAY_TREE_RND_PLAYED (1<<8)
37 ///@}
39 /// \defgroup PlaytreeIterMode Playtree iterator mode
40 /// \ingroup PlaytreeIter
41 ///@{
42 #define PLAY_TREE_ITER_NORMAL 0
43 #define PLAY_TREE_ITER_RND 1
44 ///@}
46 /// \defgroup Playtree
47 ///@{
49 typedef struct play_tree play_tree_t;
50 /// \ingroup PlaytreeIter
51 typedef struct play_tree_iter play_tree_iter_t;
52 typedef struct play_tree_param play_tree_param_t;
55 #if 0
56 typedef struct play_tree_info play_tree_info_t;
57 // TODO : a attrib,val pair system and not something hardcoded
58 struct play_tree_info {
59 char* title;
60 char* author;
61 char* copyright;
62 char* abstract;
63 // Some more ??
65 #endif
67 struct play_tree_param {
68 char* name;
69 char* value;
73 /// Playtree item
74 struct play_tree {
75 play_tree_t* parent;
76 play_tree_t* child;
77 play_tree_t* next;
78 play_tree_t* prev;
80 //play_tree_info_t info;
81 play_tree_param_t* params;
82 int loop;
83 char** files;
84 int entry_type;
85 int flags;
89 /// \defgroup PlaytreeIter Playtree iterator
90 /// \ingroup Playtree
91 ///@{
93 /// Playtree iterator
94 struct play_tree_iter {
95 /// Root of the iterated tree.
96 play_tree_t* root;
97 /// Current position in the tree.
98 play_tree_t* tree;
99 /// \ref Config used.
100 struct m_config* config;
101 /// Looping status
102 int loop;
103 /// Selected file in the current item.
104 int file;
105 /// Number of files in the current item.
106 int num_files;
107 int entry_pushed;
108 int mode;
110 /// loop/valid stack to save/revert status when we go up/down.
111 int* status_stack;
112 /// status stack size
113 int stack_size;
115 ///@}
117 /// Create a new empty playtree item.
118 play_tree_t*
119 play_tree_new(void);
121 /// Free a playtree item.
122 /** \param pt Item to free.
123 * \param children If non-zero the item's children are recursively freed.
125 void
126 play_tree_free(play_tree_t* pt, int children);
129 /// Free an item and its siblings.
130 /** \param pt Item to free.
131 * \param children If non-zero the items' children are recursively freed.
133 void
134 play_tree_free_list(play_tree_t* pt, int children);
137 /// Set the children of a playtree item.
138 void
139 play_tree_set_child(play_tree_t* pt, play_tree_t* child);
141 /// Set the parent of a playtree item.
142 void
143 play_tree_set_parent(play_tree_t* pt, play_tree_t* parent);
146 /// Append an item after its siblings.
147 void
148 play_tree_append_entry(play_tree_t* pt, play_tree_t* entry);
150 /// Prepend an item before its siblings.
151 void
152 play_tree_prepend_entry(play_tree_t* pt, play_tree_t* entry);
154 /// Insert an item right after a siblings.
155 void
156 play_tree_insert_entry(play_tree_t* pt, play_tree_t* entry);
158 /// Detach an item from the tree.
159 void
160 play_tree_remove(play_tree_t* pt, int free_it,int with_children);
162 /// Add a file to an item.
163 void
164 play_tree_add_file(play_tree_t* pt,char* file);
166 /// Remove a file from an item.
168 play_tree_remove_file(play_tree_t* pt,char* file);
171 /// Add a config paramter to an item.
172 void
173 play_tree_set_param(play_tree_t* pt, char* name, char* val);
175 /// Remove a config parameter from an item.
177 play_tree_unset_param(play_tree_t* pt, char* name);
179 /// Copy the config parameters from one item to another.
180 void
181 play_tree_set_params_from(play_tree_t* dest,play_tree_t* src);
183 /// \addtogroup PlaytreeIter
184 ///@{
186 /// Create a new iterator.
187 play_tree_iter_t*
188 play_tree_iter_new(play_tree_t* pt, struct m_config* config);
190 /// Duplicate an iterator.
191 play_tree_iter_t*
192 play_tree_iter_new_copy(play_tree_iter_t* old);
194 /// Free an iterator.
195 void
196 play_tree_iter_free(play_tree_iter_t* iter);
198 /// Step an iterator.
199 /** \param iter The iterator.
200 * \param d The direction: d > 0 == next , d < 0 == prev
201 * \param with_node TRUE == stop on nodes with children, FALSE == go directly to the next child
202 * \return See \ref PlaytreeIterReturn.
204 int
205 play_tree_iter_step(play_tree_iter_t* iter, int d,int with_nodes);
207 /// Step up, useful to break a loop, etc.
208 /** \param iter The iterator.
209 * \param d The direction: d > 0 == next , d < 0 == prev
210 * \param with_node TRUE == stop on nodes with children, FALSE == go directly to the next child
211 * \return See \ref PlaytreeIterReturn.
214 play_tree_iter_up_step(play_tree_iter_t* iter, int d,int with_nodes);
216 /// Enter a node child list, only useful when stopping on nodes.
218 play_tree_iter_down_step(play_tree_iter_t* iter, int d,int with_nodes);
220 /// Get a file from the current item.
221 char*
222 play_tree_iter_get_file(play_tree_iter_t* iter, int d);
224 ///@}
225 // PlaytreeIter group
227 /// Create a playtree from a playlist file.
228 /** \ingroup PlaytreeParser
230 play_tree_t*
231 parse_playtree(struct stream_st *stream, int forced);
233 /// Clean a tree by destroying all empty elements.
234 play_tree_t*
235 play_tree_cleanup(play_tree_t* pt);
237 /// Create a playtree from a playlist file.
238 /** \ingroup PlaytreeParser
240 play_tree_t*
241 parse_playlist_file(char* file);
243 /// \defgroup PtAPI Playtree highlevel API
244 /// \ingroup Playtree
245 /// Highlevel API with pt-suffix to different from low-level API
246 /// by Fabian Franz (mplayer@fabian-franz.de).
247 ///@{
249 // Cleans up pt and creates a new iter.
250 play_tree_iter_t* pt_iter_create(play_tree_t** pt, struct m_config* config);
252 /// Frees the iter.
253 void pt_iter_destroy(play_tree_iter_t** iter);
255 /// Gets the next available file in the direction (d=-1 || d=+1).
256 char* pt_iter_get_file(play_tree_iter_t* iter, int d);
258 // Two Macros that implement forward and backward direction.
259 #define pt_iter_get_next_file(iter) pt_iter_get_file(iter, 1)
260 #define pt_iter_get_prev_file(iter) pt_iter_get_file(iter, -1)
262 /// Inserts entry into the playtree.
263 void pt_iter_insert_entry(play_tree_iter_t* iter, play_tree_t* entry);
265 /// Replaces current entry in playtree with entry by doing insert and remove.
266 void pt_iter_replace_entry(play_tree_iter_t* iter, play_tree_t* entry);
268 /// Adds a new file to the playtree, if it is not valid it is created.
269 void pt_add_file(play_tree_t** ppt, char* filename);
271 /// \brief Performs a convert to playtree-syntax, by concat path/file
272 /// and performs pt_add_file
273 void pt_add_gui_file(play_tree_t** ppt, char* path, char* file);
275 // Two macros to use only the iter and not the other things.
276 #define pt_iter_add_file(iter, filename) pt_add_file(&iter->tree, filename)
277 #define pt_iter_add_gui_file(iter, path, name) pt_add_gui_file(&iter->tree, path, name)
279 /// Resets the iter and goes back to head.
280 void pt_iter_goto_head(play_tree_iter_t* iter);
282 ///@}
284 ///@}
286 #endif /* MPLAYER_PLAYTREE_H */