some typos in the english parts
[mplayer/greg.git] / playtree.h
blob3fb2d9abc1ac5995b284375a0c3558bcf21401f5
2 #ifndef __PLAYTREE_H
3 #define __PLAYTREE_H
5 struct stream_st;
6 struct m_config;
8 #define PLAY_TREE_ITER_ERROR 0
9 #define PLAY_TREE_ITER_ENTRY 1
10 #define PLAY_TREE_ITER_NODE 2
11 #define PLAY_TREE_ITER_END 3
13 #define PLAY_TREE_ENTRY_NODE -1
14 #define PLAY_TREE_ENTRY_DVD 0
15 #define PLAY_TREE_ENTRY_VCD 1
16 #define PLAY_TREE_ENTRY_TV 2
17 #define PLAY_TREE_ENTRY_FILE 3
19 // Playtree flags
20 #define PLAY_TREE_RND (1<<0)
21 // Playtree flags used by the iter
22 #define PLAY_TREE_RND_PLAYED (1<<8)
24 // Iter mode
25 #define PLAY_TREE_ITER_NORMAL 0
26 #define PLAY_TREE_ITER_RND 1
28 typedef struct play_tree play_tree_t;
29 typedef struct play_tree_iter play_tree_iter_t;
30 typedef struct play_tree_param play_tree_param_t;
33 #if 0
34 typedef struct play_tree_info play_tree_info_t;
35 // TODO : a attrib,val pair system and not something hardcoded
36 struct play_tree_info {
37 char* title;
38 char* author;
39 char* copyright;
40 char* abstract;
41 // Some more ??
43 #endif
45 struct play_tree_param {
46 char* name;
47 char* value;
51 struct play_tree {
52 play_tree_t* parent;
53 play_tree_t* child;
54 play_tree_t* next;
55 play_tree_t* prev;
57 //play_tree_info_t info;
58 play_tree_param_t* params;
59 int loop;
60 char** files;
61 int entry_type;
62 int flags;
65 struct play_tree_iter {
66 play_tree_t* root; // Iter root tree
67 play_tree_t* tree; // Current tree
68 struct m_config* config;
69 int loop; // Looping status
70 int file;
71 int num_files;
72 int entry_pushed;
73 int mode;
75 int* status_stack; // loop/valid stack to save/revert status when we go up/down
76 int stack_size; // status stack size
79 play_tree_t*
80 play_tree_new(void);
82 // If childs is true free also the childs
83 void
84 play_tree_free(play_tree_t* pt, int childs);
87 void
88 play_tree_free_list(play_tree_t* pt, int childs);
91 // Childs
92 void
93 play_tree_set_child(play_tree_t* pt, play_tree_t* child);
94 // Or parent
95 void
96 play_tree_set_parent(play_tree_t* pt, play_tree_t* parent);
99 // Add at end
100 void
101 play_tree_append_entry(play_tree_t* pt, play_tree_t* entry);
103 // And on begining
104 void
105 play_tree_prepend_entry(play_tree_t* pt, play_tree_t* entry);
107 // Insert after
108 void
109 play_tree_insert_entry(play_tree_t* pt, play_tree_t* entry);
111 // Detach from the tree
112 void
113 play_tree_remove(play_tree_t* pt, int free_it,int with_childs);
116 void
117 play_tree_add_file(play_tree_t* pt,char* file);
120 play_tree_remove_file(play_tree_t* pt,char* file);
123 // Val can be NULL
124 void
125 play_tree_set_param(play_tree_t* pt, char* name, char* val);
128 play_tree_unset_param(play_tree_t* pt, char* name);
130 // Set all paramter of source in dest
131 void
132 play_tree_set_params_from(play_tree_t* dest,play_tree_t* src);
134 /// Iterator
136 play_tree_iter_t*
137 play_tree_iter_new(play_tree_t* pt, struct m_config* config);
139 play_tree_iter_t*
140 play_tree_iter_new_copy(play_tree_iter_t* old);
142 void
143 play_tree_iter_free(play_tree_iter_t* iter);
145 // d is the direction : d > 0 == next , d < 0 == prev
146 // with_node : TRUE == stop on nodes with childs, FALSE == go directly to the next child
148 int
149 play_tree_iter_step(play_tree_iter_t* iter, int d,int with_nodes);
151 int // Break a loop, etc
152 play_tree_iter_up_step(play_tree_iter_t* iter, int d,int with_nodes);
154 int // Enter a node child list
155 play_tree_iter_down_step(play_tree_iter_t* iter, int d,int with_nodes);
157 char*
158 play_tree_iter_get_file(play_tree_iter_t* iter, int d);
160 play_tree_t*
161 parse_playtree(struct stream_st *stream, int forced);
163 play_tree_t*
164 play_tree_cleanup(play_tree_t* pt);
166 play_tree_t*
167 parse_playlist_file(char* file);
169 // Highlevel API with pt-suffix to different from low-level API
170 // by Fabian Franz (mplayer@fabian-franz.de)
172 // Cleanups pt and creates a new iter
173 play_tree_iter_t* pt_iter_create(play_tree_t** pt, struct m_config* config);
175 // Frees the iter
176 void pt_iter_destroy(play_tree_iter_t** iter);
178 // Gets the next available file in the direction (d=-1 || d=+1)
179 char* pt_iter_get_file(play_tree_iter_t* iter, int d);
181 // Two Macros that implement forward and backward direction
182 #define pt_iter_get_next_file(iter) pt_iter_get_file(iter, 1)
183 #define pt_iter_get_prev_file(iter) pt_iter_get_file(iter, -1)
185 // Inserts entry into the playtree
186 void pt_iter_insert_entry(play_tree_iter_t* iter, play_tree_t* entry);
188 //Replaces current entry in playtree with entry
189 //by doing insert and remove
190 void pt_iter_replace_entry(play_tree_iter_t* iter, play_tree_t* entry);
192 // Adds a new file to the playtree,
193 // if it is not valid it is created
194 void pt_add_file(play_tree_t** ppt, char* filename);
196 // Performs a convert to playtree-syntax, by concat path/file
197 // and performs pt_add_file
198 void pt_add_gui_file(play_tree_t** ppt, char* path, char* file);
200 //Two macros to use only the iter and not the other things
201 #define pt_iter_add_file(iter, filename) pt_add_file(&iter->tree, filename)
202 #define pt_iter_add_gui_file(iter, path, name) pt_add_gui_file(&iter->tree, path, name)
204 // Resets the iter and goes back to head
205 void pt_iter_goto_head(play_tree_iter_t* iter);
207 #endif