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