cocoa: gl3: make window creation fail on OSX < 10.7
[mplayer.git] / playtree.h
blob7af1518fd0714b6b27130067aa24e4eb02d3d48f
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;
30 /// \defgroup PlaytreeIterReturn Playtree iterator return code
31 /// \ingroup PlaytreeIter
32 ///@{
33 #define PLAY_TREE_ITER_ERROR 0
34 #define PLAY_TREE_ITER_ENTRY 1
35 #define PLAY_TREE_ITER_NODE 2
36 #define PLAY_TREE_ITER_END 3
37 ///@}
39 /// \defgroup PlaytreeEntryTypes Playtree entry types
40 /// \ingroup Playtree
41 ///@{
42 #define PLAY_TREE_ENTRY_NODE -1
43 #define PLAY_TREE_ENTRY_DVD 0
44 #define PLAY_TREE_ENTRY_VCD 1
45 #define PLAY_TREE_ENTRY_TV 2
46 #define PLAY_TREE_ENTRY_FILE 3
47 ///@}
50 /// \defgroup PlaytreeEntryFlags Playtree flags
51 /// \ingroup Playtree
52 ///@{
53 /// Play the item children in random order.
54 #define PLAY_TREE_RND (1<<0)
55 /// Playtree flags used by the iterator to mark items already "randomly" played.
56 #define PLAY_TREE_RND_PLAYED (1<<8)
57 ///@}
59 /// \defgroup PlaytreeIterMode Playtree iterator mode
60 /// \ingroup PlaytreeIter
61 ///@{
62 #define PLAY_TREE_ITER_NORMAL 0
63 #define PLAY_TREE_ITER_RND 1
64 ///@}
66 /// \defgroup Playtree
67 ///@{
69 typedef struct play_tree play_tree_t;
70 /// \ingroup PlaytreeIter
71 typedef struct play_tree_iter play_tree_iter_t;
72 typedef struct play_tree_param play_tree_param_t;
75 #if 0
76 typedef struct play_tree_info play_tree_info_t;
77 // TODO : a attrib,val pair system and not something hardcoded
78 struct play_tree_info {
79 char* title;
80 char* author;
81 char* copyright;
82 char* abstract;
83 // Some more ??
85 #endif
87 struct play_tree_param {
88 char* name;
89 char* value;
93 /// Playtree item
94 struct play_tree {
95 play_tree_t* parent;
96 play_tree_t* child;
97 play_tree_t* next;
98 play_tree_t* prev;
100 //play_tree_info_t info;
101 play_tree_param_t* params;
102 int loop;
103 char** files;
104 int entry_type;
105 int flags;
109 /// \defgroup PlaytreeIter Playtree iterator
110 /// \ingroup Playtree
111 ///@{
113 /// Playtree iterator
114 struct play_tree_iter {
115 /// Root of the iterated tree.
116 play_tree_t* root;
117 /// Current position in the tree.
118 play_tree_t* tree;
119 /// \ref Config used.
120 struct m_config* config;
121 /// Looping status
122 int loop;
123 /// Selected file in the current item.
124 int file;
125 /// Number of files in the current item.
126 int num_files;
127 int entry_pushed;
128 int mode;
130 /// loop/valid stack to save/revert status when we go up/down.
131 int* status_stack;
132 /// status stack size
133 int stack_size;
135 ///@}
137 /// Create a new empty playtree item.
138 play_tree_t*
139 play_tree_new(void);
141 /// Free a playtree item.
142 /** \param pt Item to free.
143 * \param children If non-zero the item's children are recursively freed.
145 void
146 play_tree_free(play_tree_t* pt, int children);
149 /// Free an item and its siblings.
150 /** \param pt Item to free.
151 * \param children If non-zero the items' children are recursively freed.
153 void
154 play_tree_free_list(play_tree_t* pt, int children);
157 /// Set the children of a playtree item.
158 void
159 play_tree_set_child(play_tree_t* pt, play_tree_t* child);
161 /// Set the parent of a playtree item.
162 void
163 play_tree_set_parent(play_tree_t* pt, play_tree_t* parent);
166 /// Append an item after its siblings.
167 void
168 play_tree_append_entry(play_tree_t* pt, play_tree_t* entry);
170 /// Prepend an item before its siblings.
171 void
172 play_tree_prepend_entry(play_tree_t* pt, play_tree_t* entry);
174 /// Insert an item right after a siblings.
175 void
176 play_tree_insert_entry(play_tree_t* pt, play_tree_t* entry);
178 /// Detach an item from the tree.
179 void
180 play_tree_remove(play_tree_t* pt, int free_it,int with_children);
182 /// Add a file to an item.
183 void
184 play_tree_add_file(play_tree_t* pt,const char* file);
186 /// Remove a file from an item.
188 play_tree_remove_file(play_tree_t* pt,const char* file);
191 /// Add a config paramter to an item.
192 void
193 play_tree_set_param(play_tree_t* pt, struct bstr name, struct bstr val);
195 /// Remove a config parameter from an item.
197 play_tree_unset_param(play_tree_t* pt, const char* name);
199 /// Copy the config parameters from one item to another.
200 void
201 play_tree_set_params_from(play_tree_t* dest,play_tree_t* src);
203 /// \addtogroup PlaytreeIter
204 ///@{
206 /// Create a new iterator.
207 play_tree_iter_t*
208 play_tree_iter_new(play_tree_t* pt, struct m_config* config);
210 /// Duplicate an iterator.
211 play_tree_iter_t*
212 play_tree_iter_new_copy(play_tree_iter_t* old);
214 /// Free an iterator.
215 void
216 play_tree_iter_free(play_tree_iter_t* iter);
218 /// Step an iterator.
219 /** \param iter The iterator.
220 * \param d The direction: d > 0 == next , d < 0 == prev
221 * \param with_node TRUE == stop on nodes with children, FALSE == go directly to the next child
222 * \return See \ref PlaytreeIterReturn.
225 play_tree_iter_step(play_tree_iter_t* iter, int d,int with_nodes);
227 /// Step up, useful to break a loop, etc.
228 /** \param iter The iterator.
229 * \param d The direction: d > 0 == next , d < 0 == prev
230 * \param with_node TRUE == stop on nodes with children, FALSE == go directly to the next child
231 * \return See \ref PlaytreeIterReturn.
234 play_tree_iter_up_step(play_tree_iter_t* iter, int d,int with_nodes);
236 /// Enter a node child list, only useful when stopping on nodes.
238 play_tree_iter_down_step(play_tree_iter_t* iter, int d,int with_nodes);
240 /// Get a file from the current item.
241 char*
242 play_tree_iter_get_file(play_tree_iter_t* iter, int d);
244 ///@}
245 // PlaytreeIter group
247 /// Create a playtree from a playlist file.
248 /** \ingroup PlaytreeParser
250 struct m_config;
251 play_tree_t*
252 parse_playtree(struct stream *stream, struct m_config *mconfig, int forced);
254 /// Clean a tree by destroying all empty elements.
255 play_tree_t*
256 play_tree_cleanup(play_tree_t* pt);
258 /// Create a playtree from a playlist file.
259 /** \ingroup PlaytreeParser
261 play_tree_t*
262 parse_playlist_file(struct m_config *mconfig, struct bstr file);
264 /// \defgroup PtAPI Playtree highlevel API
265 /// \ingroup Playtree
266 /// Highlevel API with pt-suffix to different from low-level API
267 /// by Fabian Franz (mplayer@fabian-franz.de).
268 ///@{
270 // Cleans up pt and creates a new iter.
271 play_tree_iter_t* pt_iter_create(play_tree_t** pt, struct m_config* config);
273 /// Frees the iter.
274 void pt_iter_destroy(play_tree_iter_t** iter);
276 /// Gets the next available file in the direction (d=-1 || d=+1).
277 char* pt_iter_get_file(play_tree_iter_t* iter, int d);
279 // Two Macros that implement forward and backward direction.
280 #define pt_iter_get_next_file(iter) pt_iter_get_file(iter, 1)
281 #define pt_iter_get_prev_file(iter) pt_iter_get_file(iter, -1)
283 /// Inserts entry into the playtree.
284 void pt_iter_insert_entry(play_tree_iter_t* iter, play_tree_t* entry);
286 /// Replaces current entry in playtree with entry by doing insert and remove.
287 void pt_iter_replace_entry(play_tree_iter_t* iter, play_tree_t* entry);
289 /// Adds a new file to the playtree, if it is not valid it is created.
290 void pt_add_file(play_tree_t** ppt, const char* filename);
292 // A macro to use only the iter and not the other things.
293 #define pt_iter_add_file(iter, filename) pt_add_file(&iter->tree, filename)
295 /// Resets the iter and goes back to head.
296 void pt_iter_goto_head(play_tree_iter_t* iter);
298 ///@}
300 ///@}
302 #endif /* MPLAYER_PLAYTREE_H */