Mercurial > mplayer.hg
annotate DOCS/tech/playtree @ 14186:5053490906c3
Initialize cutoff, too. Fixes crash when AF_CONTROL_COMMAND_LINE is not set.
author | reimar |
---|---|
date | Sun, 19 Dec 2004 16:28:34 +0000 |
parents | 252fb0cf331a |
children | f3d7a1b58a82 |
rev | line source |
---|---|
4860 | 1 |
2 How work the playtree ? | |
3 | |
4 Good question, I try to explain but note that it's the first doc | |
5 I write :) | |
6 | |
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. | |
10 | |
11 First the play_tree struct : | |
12 | |
13 | |
14 struct play_tree { | |
15 play_tree_t* parent; | |
16 play_tree_t* child; | |
17 play_tree_t* next; | |
18 play_tree_t* prev; | |
19 | |
20 play_tree_param_t* params; | |
21 int loop; | |
22 char** files; | |
23 int entry_type; | |
24 }; | |
25 | |
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). | |
30 | |
31 An entry can hold more than one file, why ? | |
32 | |
11047 | 33 Because an entry can be a network stream and usually you have more than |
4860 | 34 one server. But all send the same thing, so it's only on entry with sevral |
35 sources. | |
36 | |
37 Then how do I use this stuff ? | |
38 | |
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 childs. | |
55 | |
56 When your tree is ready you can then use play_tree_cleanup to remove all unuseful | |
57 entries. | |
58 | |
11271
252fb0cf331a
spelling fixes, mostly by <ismail.donmez@boun.edu.tr>
diego
parents:
11047
diff
changeset
|
59 If you want to load a playlist you can use parse_playtree which take a stream_t |
252fb0cf331a
spelling fixes, mostly by <ismail.donmez@boun.edu.tr>
diego
parents:
11047
diff
changeset
|
60 as argument or parse_playlist_file which take a filename as argument. |
4860 | 61 Both function will return NULL in case of failure or a new (cleaned) tree that |
62 you can add somewhere in your tree. | |
63 | |
64 How do I add DVD, VCD or TV entry to the tree ? | |
65 | |
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 | |
70 | |
71 | |
72 My playtree is ready now, what with this play_tree_iter ? | |
73 | |
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. | |
11271
252fb0cf331a
spelling fixes, mostly by <ismail.donmez@boun.edu.tr>
diego
parents:
11047
diff
changeset
|
77 It's created with play_tree_iter_new which take as argument a play_tree_t |
252fb0cf331a
spelling fixes, mostly by <ismail.donmez@boun.edu.tr>
diego
parents:
11047
diff
changeset
|
78 and an m_config_t which is then used to set/unset the params of each entry. |
4860 | 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_BEGINING for the begining. Don't know | |
91 what it will return in a such case. PLAY_TREE_ITER_ERROR ? )) | |
92 | |
11271
252fb0cf331a
spelling fixes, mostly by <ismail.donmez@boun.edu.tr>
diego
parents:
11047
diff
changeset
|
93 There is also play_tree_iter_up_step which can be used to break a loop or skip |
4860 | 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. | |
97 | |
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 | |
11047 | 101 file are available. You can now how many files are available using |
11271
252fb0cf331a
spelling fixes, mostly by <ismail.donmez@boun.edu.tr>
diego
parents:
11047
diff
changeset
|
102 iter->num_files and which one it returned using iter->file. |
4860 | 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. | |
108 | |
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. | |
112 | |
113 Then when you have finish with the iter free it with play_tree_iter_free. | |
114 | |
115 | |
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 | |
11271
252fb0cf331a
spelling fixes, mostly by <ismail.donmez@boun.edu.tr>
diego
parents:
11047
diff
changeset
|
119 entry which contained the playlist by the result of the parsing. |
4860 | 120 In the event handeling it check if a step can be done, etc. And finnaly |
121 at the end it go the next entry. | |
122 | |
123 Suggestion, flames, etc about this doc must go to albeu@free.fr |