subassconvert: do not escape likely ASS override tags
[mplayer.git] / playtree.h
blob5ad612c3c0a37ad2ea5866179324624d24d9a898
1 /*
2 * This file is part of MPlayer.
4 * MPlayer is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * MPlayer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #ifndef MPLAYER_PLAYTREE_H
20 #define MPLAYER_PLAYTREE_H
22 #include "bstr.h"
24 /// \file
25 /// \ingroup Playtree
27 struct stream;
28 struct m_config;
29 struct MPOpts;
31 /// \defgroup PlaytreeIterReturn Playtree iterator return code
32 /// \ingroup PlaytreeIter
33 ///@{
34 #define PLAY_TREE_ITER_ERROR 0
35 #define PLAY_TREE_ITER_ENTRY 1
36 #define PLAY_TREE_ITER_NODE 2
37 #define PLAY_TREE_ITER_END 3
38 ///@}
40 /// \defgroup PlaytreeEntryTypes Playtree entry types
41 /// \ingroup Playtree
42 ///@{
43 #define PLAY_TREE_ENTRY_NODE -1
44 #define PLAY_TREE_ENTRY_DVD 0
45 #define PLAY_TREE_ENTRY_VCD 1
46 #define PLAY_TREE_ENTRY_TV 2
47 #define PLAY_TREE_ENTRY_FILE 3
48 ///@}
51 /// \defgroup PlaytreeEntryFlags Playtree flags
52 /// \ingroup Playtree
53 ///@{
54 /// Play the item children in random order.
55 #define PLAY_TREE_RND (1<<0)
56 /// Playtree flags used by the iterator to mark items already "randomly" played.
57 #define PLAY_TREE_RND_PLAYED (1<<8)
58 ///@}
60 /// \defgroup PlaytreeIterMode Playtree iterator mode
61 /// \ingroup PlaytreeIter
62 ///@{
63 #define PLAY_TREE_ITER_NORMAL 0
64 #define PLAY_TREE_ITER_RND 1
65 ///@}
67 /// \defgroup Playtree
68 ///@{
70 typedef struct play_tree play_tree_t;
71 /// \ingroup PlaytreeIter
72 typedef struct play_tree_iter play_tree_iter_t;
73 typedef struct play_tree_param play_tree_param_t;
76 #if 0
77 typedef struct play_tree_info play_tree_info_t;
78 // TODO : a attrib,val pair system and not something hardcoded
79 struct play_tree_info {
80 char* title;
81 char* author;
82 char* copyright;
83 char* abstract;
84 // Some more ??
86 #endif
88 struct play_tree_param {
89 char* name;
90 char* value;
94 /// Playtree item
95 struct play_tree {
96 play_tree_t* parent;
97 play_tree_t* child;
98 play_tree_t* next;
99 play_tree_t* prev;
101 //play_tree_info_t info;
102 play_tree_param_t* params;
103 int loop;
104 char** files;
105 int entry_type;
106 int flags;
110 /// \defgroup PlaytreeIter Playtree iterator
111 /// \ingroup Playtree
112 ///@{
114 /// Playtree iterator
115 struct play_tree_iter {
116 /// Root of the iterated tree.
117 play_tree_t* root;
118 /// Current position in the tree.
119 play_tree_t* tree;
120 /// \ref Config used.
121 struct m_config* config;
122 /// Looping status
123 int loop;
124 /// Selected file in the current item.
125 int file;
126 /// Number of files in the current item.
127 int num_files;
128 int entry_pushed;
129 int mode;
131 /// loop/valid stack to save/revert status when we go up/down.
132 int* status_stack;
133 /// status stack size
134 int stack_size;
136 ///@}
138 /// Create a new empty playtree item.
139 play_tree_t*
140 play_tree_new(void);
142 /// Free a playtree item.
143 /** \param pt Item to free.
144 * \param children If non-zero the item's children are recursively freed.
146 void
147 play_tree_free(play_tree_t* pt, int children);
150 /// Free an item and its siblings.
151 /** \param pt Item to free.
152 * \param children If non-zero the items' children are recursively freed.
154 void
155 play_tree_free_list(play_tree_t* pt, int children);
158 /// Set the children of a playtree item.
159 void
160 play_tree_set_child(play_tree_t* pt, play_tree_t* child);
162 /// Set the parent of a playtree item.
163 void
164 play_tree_set_parent(play_tree_t* pt, play_tree_t* parent);
167 /// Append an item after its siblings.
168 void
169 play_tree_append_entry(play_tree_t* pt, play_tree_t* entry);
171 /// Prepend an item before its siblings.
172 void
173 play_tree_prepend_entry(play_tree_t* pt, play_tree_t* entry);
175 /// Insert an item right after a siblings.
176 void
177 play_tree_insert_entry(play_tree_t* pt, play_tree_t* entry);
179 /// Detach an item from the tree.
180 void
181 play_tree_remove(play_tree_t* pt, int free_it,int with_children);
183 /// Add a file to an item.
184 void
185 play_tree_add_file(play_tree_t* pt,const char* file);
187 /// Remove a file from an item.
189 play_tree_remove_file(play_tree_t* pt,const char* file);
192 /// Add a config paramter to an item.
193 void
194 play_tree_set_param(play_tree_t* pt, struct bstr name, struct bstr val);
196 /// Remove a config parameter from an item.
198 play_tree_unset_param(play_tree_t* pt, const char* name);
200 /// Copy the config parameters from one item to another.
201 void
202 play_tree_set_params_from(play_tree_t* dest,play_tree_t* src);
204 /// \addtogroup PlaytreeIter
205 ///@{
207 /// Create a new iterator.
208 play_tree_iter_t*
209 play_tree_iter_new(play_tree_t* pt, struct m_config* config);
211 /// Duplicate an iterator.
212 play_tree_iter_t*
213 play_tree_iter_new_copy(play_tree_iter_t* old);
215 /// Free an iterator.
216 void
217 play_tree_iter_free(play_tree_iter_t* iter);
219 /// Step an iterator.
220 /** \param iter The iterator.
221 * \param d The direction: d > 0 == next , d < 0 == prev
222 * \param with_node TRUE == stop on nodes with children, FALSE == go directly to the next child
223 * \return See \ref PlaytreeIterReturn.
226 play_tree_iter_step(play_tree_iter_t* iter, int d,int with_nodes);
228 /// Step up, useful to break a loop, etc.
229 /** \param iter The iterator.
230 * \param d The direction: d > 0 == next , d < 0 == prev
231 * \param with_node TRUE == stop on nodes with children, FALSE == go directly to the next child
232 * \return See \ref PlaytreeIterReturn.
235 play_tree_iter_up_step(play_tree_iter_t* iter, int d,int with_nodes);
237 /// Enter a node child list, only useful when stopping on nodes.
239 play_tree_iter_down_step(play_tree_iter_t* iter, int d,int with_nodes);
241 /// Get a file from the current item.
242 char*
243 play_tree_iter_get_file(play_tree_iter_t* iter, int d);
245 ///@}
246 // PlaytreeIter group
248 /// Create a playtree from a playlist file.
249 /** \ingroup PlaytreeParser
251 struct m_config;
252 play_tree_t*
253 parse_playtree(struct stream *stream, struct MPOpts *opts, int forced);
255 /// Clean a tree by destroying all empty elements.
256 play_tree_t*
257 play_tree_cleanup(play_tree_t* pt);
259 /// Create a playtree from a playlist file.
260 /** \ingroup PlaytreeParser
262 play_tree_t*
263 parse_playlist_file(struct MPOpts *opts, struct bstr file);
265 /// \defgroup PtAPI Playtree highlevel API
266 /// \ingroup Playtree
267 /// Highlevel API with pt-suffix to different from low-level API
268 /// by Fabian Franz (mplayer@fabian-franz.de).
269 ///@{
271 // Cleans up pt and creates a new iter.
272 play_tree_iter_t* pt_iter_create(play_tree_t** pt, struct m_config* config);
274 /// Frees the iter.
275 void pt_iter_destroy(play_tree_iter_t** iter);
277 /// Gets the next available file in the direction (d=-1 || d=+1).
278 char* pt_iter_get_file(play_tree_iter_t* iter, int d);
280 // Two Macros that implement forward and backward direction.
281 #define pt_iter_get_next_file(iter) pt_iter_get_file(iter, 1)
282 #define pt_iter_get_prev_file(iter) pt_iter_get_file(iter, -1)
284 /// Inserts entry into the playtree.
285 void pt_iter_insert_entry(play_tree_iter_t* iter, play_tree_t* entry);
287 /// Replaces current entry in playtree with entry by doing insert and remove.
288 void pt_iter_replace_entry(play_tree_iter_t* iter, play_tree_t* entry);
290 /// Adds a new file to the playtree, if it is not valid it is created.
291 void pt_add_file(play_tree_t** ppt, const char* filename);
293 // A macro to use only the iter and not the other things.
294 #define pt_iter_add_file(iter, filename) pt_add_file(&iter->tree, filename)
296 /// Resets the iter and goes back to head.
297 void pt_iter_goto_head(play_tree_iter_t* iter);
299 ///@}
301 ///@}
303 #endif /* MPLAYER_PLAYTREE_H */