Fix a possible crash on 64 bit systems when the lumSrcPtr or chrSrcPtr
[mplayer/glamo.git] / playtree.h
blob9876bb64a00053f9f77c623749141a345c55d50f
2 /// \file
3 /// \ingroup Playtree
5 #ifndef __PLAYTREE_H
6 #define __PLAYTREE_H
8 struct stream_st;
9 struct m_config;
11 /// \defgroup PlaytreeIterReturn Playtree iterator return code
12 /// \ingroup PlaytreeIter
13 ///@{
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
18 ///@}
20 /// \defgroup PlaytreeEntryTypes Playtree entry types
21 /// \ingroup Playtree
22 ///@{
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
28 ///@}
31 /// \defgroup PlaytreeEntryFlags Playtree flags
32 /// \ingroup Playtree
33 ///@{
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)
38 ///@}
40 /// \defgroup PlaytreeIterMode Playtree iterator mode
41 /// \ingroup PlaytreeIter
42 ///@{
43 #define PLAY_TREE_ITER_NORMAL 0
44 #define PLAY_TREE_ITER_RND 1
45 ///@}
47 /// \defgroup Playtree
48 ///@{
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;
56 #if 0
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 {
60 char* title;
61 char* author;
62 char* copyright;
63 char* abstract;
64 // Some more ??
66 #endif
68 struct play_tree_param {
69 char* name;
70 char* value;
74 /// Playtree item
75 struct play_tree {
76 play_tree_t* parent;
77 play_tree_t* child;
78 play_tree_t* next;
79 play_tree_t* prev;
81 //play_tree_info_t info;
82 play_tree_param_t* params;
83 int loop;
84 char** files;
85 int entry_type;
86 int flags;
90 /// \defgroup PlaytreeIter Playtree iterator
91 /// \ingroup Playtree
92 ///@{
94 /// Playtree iterator
95 struct play_tree_iter {
96 /// Root of the iterated tree.
97 play_tree_t* root;
98 /// Current position in the tree.
99 play_tree_t* tree;
100 /// \ref Config used.
101 struct m_config* config;
102 /// Looping status
103 int loop;
104 /// Selected file in the current item.
105 int file;
106 /// Number of files in the current item.
107 int num_files;
108 int entry_pushed;
109 int mode;
111 /// loop/valid stack to save/revert status when we go up/down.
112 int* status_stack;
113 /// status stack size
114 int stack_size;
116 ///@}
118 /// Create a new empty playtree item.
119 play_tree_t*
120 play_tree_new(void);
122 /// Free a playtree item.
123 /** \param pt Item to free.
124 * \param childs If non-zero the item's childs are recursively freed.
126 void
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.
134 void
135 play_tree_free_list(play_tree_t* pt, int childs);
138 /// Set the childs of a playtree item.
139 void
140 play_tree_set_child(play_tree_t* pt, play_tree_t* child);
142 /// Set the parent of a playtree item.
143 void
144 play_tree_set_parent(play_tree_t* pt, play_tree_t* parent);
147 /// Append an item after its siblings.
148 void
149 play_tree_append_entry(play_tree_t* pt, play_tree_t* entry);
151 /// Prepend an item before its siblings.
152 void
153 play_tree_prepend_entry(play_tree_t* pt, play_tree_t* entry);
155 /// Insert an item right after a siblings.
156 void
157 play_tree_insert_entry(play_tree_t* pt, play_tree_t* entry);
159 /// Detach an item from the tree.
160 void
161 play_tree_remove(play_tree_t* pt, int free_it,int with_childs);
163 /// Add a file to an item.
164 void
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.
173 void
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.
181 void
182 play_tree_set_params_from(play_tree_t* dest,play_tree_t* src);
184 /// \addtogroup PlaytreeIter
185 ///@{
187 /// Create a new iterator.
188 play_tree_iter_t*
189 play_tree_iter_new(play_tree_t* pt, struct m_config* config);
191 /// Duplicate an iterator.
192 play_tree_iter_t*
193 play_tree_iter_new_copy(play_tree_iter_t* old);
195 /// Free an iterator.
196 void
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.
205 int
206 play_tree_iter_step(play_tree_iter_t* iter, int d,int with_nodes);
208 /// Step up, useful 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 useful 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.
222 char*
223 play_tree_iter_get_file(play_tree_iter_t* iter, int d);
225 ///@}
226 // PlaytreeIter group
228 /// Create a playtree from a playlist file.
229 /** \ingroup PlaytreeParser
231 play_tree_t*
232 parse_playtree(struct stream_st *stream, int forced);
234 /// Clean a tree by destroying all empty elements.
235 play_tree_t*
236 play_tree_cleanup(play_tree_t* pt);
238 /// Create a playtree from a playlist file.
239 /** \ingroup PlaytreeParser
241 play_tree_t*
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).
248 ///@{
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);
253 /// Frees the iter.
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);
283 ///@}
285 #endif
287 ///@}