audio: add af_lavrresample, remove old resampling filters
[mplayer.git] / DOCS / tech / playtree
blob2aaf5a175e36401d2272eec0eba5724ae8c23042
2 How work the playtree ?
4 Good question, I try to explain but note that it's the first doc
5 I write :)
7 First there is two things. The playtree itself and the iterator.
8 The playtree represent the data and the iterator is used by
9 mplayer to go from entry to entry.
11 First the play_tree struct :
14 struct play_tree {
15   play_tree_t* parent;
16   play_tree_t* child;
17   play_tree_t* next;
18   play_tree_t* prev;
20   play_tree_param_t* params;
21   int loop;
22   char** files;
23   int entry_type;
26 The play_tree_t* hold the links in the 4 directions, the params hold
27 all parameters of this entry, loop is obvious (loop < 0 mean infint loop),
28 files hold all the files of this entry and entry_type obviously tell the
29 type of this entry (Node, file, dvd, vcd ot tv).
31 An entry can hold more than one file, why ?
33 Because an entry can be a network stream and usually you have more than
34 one server. But all send the same thing, so it's only on entry with sevral
35 sources.
37 Then how do I use this stuff ?
39 First you create an entry using the play_tree_new func. This create the struct
40 and fill it with defaults values.
41 Then this can become a node or a leaf. It will become a node as soon as you link it
42 to another one using either play_tree_set_child or play_tree_set_parent.
43 Or it will become a leaf as soon as you use play_tree_add_file on it.
44 If an entry contain at least one file it can't become an node (an assert will be
45 raised) and if en entry has a child you can't add file to (here also an assert will
46 be raised).
47 Then to create a list of entry you should use play_tree_append_entry,
48 play_tree_prepend_entry or play_tree_insert_entry.
49 In all this function you can use any entry of the the list as first argument,
50 no need that it's the first one. The same apply when you set the child of a node,
51 the child argument can be any entry in a list.
52 To remove an entry from the tree use play_tree_remove. If the second arg (free_it)
53 is true it will also free it, if the entry should be freed and the third
54 arg is true it will also free the children.
56 When your tree is ready you can then use play_tree_cleanup to remove all unuseful
57 entries.
59 If you want to load a playlist you can use parse_playtree which take a stream_t
60 as argument or parse_playlist_file which take a filename as argument.
61 Both function will return NULL in case of failure or a new (cleaned) tree that
62 you can add somewhere in your tree.
64 How do I add DVD, VCD or TV entry to the tree ?
66 You should use some virtual URL as filename like :
67      dvd://x where x is the title number.
68      vcd://x where x is the track number
69      tv://x where x is the channel
72 My playtree is ready now, what with this play_tree_iter ?
74 This is an iterator used to go trough the tree. It handle itself
75 loop of list and setting mplayer config according to the params
76 of each entry.
77 It's created with play_tree_iter_new which take as argument a play_tree_t
78 and an m_config_t which is then used to set/unset the params of each entry.
79 After creation the iter point to nothing, you should init with a first step.
80 To go to another entry in the list you should use play_tree_iter_step. The
81 second argument is the direction of the step : positive value go frontward,
82 negative go backward and 0 don't move. The third tell if must care of
83 node or not. If it's true, the iterator will stop on nodes, otherwise it go
84 to the next valid entry.
85 This function return different values :
86 PLAY_TREE_ITER_ERROR  : obvious
87 PLAY_TREE_ITER_ENTRY : we are now on an entry
88 PLAY_TREE_ITER_NODE  : we are now on a node
89 PLAY_TREE_ITER_END : we are now at end
90 (( Note : I must add a PLAY_TREE_ITER_BEGINNING for the beginning. Don't know
91 what it will return in a such case.  PLAY_TREE_ITER_ERROR ? ))
93 There is also play_tree_iter_up_step which can be used to break a loop or skip
94 the current list. The argument are the same than play_tree_iter_step. The
95 difference is that it go back to parent of the current list, and then step according
96 to the arguments.
98 Then when your iter returned PLAY_TREE_ITER_ENTRY you can use
99 play_tree_iter_get_file to get the file. If you call it more than one time
100 it will return the next file for this entry or loop trough the list if no more
101 file are available. You can now how many files are available using
102 iter->num_files and which one it returned using iter->file.
103 In case the entry is a DVD, VCD or TV channel the returned string is not a filename
104 but "DVD title x", "VCD track x" or "TV channel x".
105 To distinc those case from a normal file you can check iter->tree->entry_type.
106 It will contain one of PLAY_TREE_ENTRY_DVD, PLAY_TREE_ENTRY_VCD,
107 PLAY_TREE_ENTRY_TV or PLAY_TREE_ENTRY_FILE.
109 If you need to make some check with the iter, such as will next entry be valid, etc
110 You must create a clone with play_tree_iter_new_copy. This iter will not affect
111 the config, so you can do all you want with it.
113 Then when you have finish with the iter free it with play_tree_iter_free.
116 Ok, that's all for now. To have some exemples look into mplayer.c ;)
117 First just after config parsing, the iterator is created there. Also
118 after stream opening, in case the stream is a playlist it replace the
119 entry which contained the playlist by the result of the parsing.
120 In the event handling it check if a step can be done, etc. And finnaly
121 at the end it go the next entry.
123 Suggestion, flames, etc about this doc must go to albeu@free.fr