Mercurial > mplayer.hg
annotate playtreeparser.c @ 12264:070cc45bef28
Clear subs in broken OGM files (those without empty subtitle packets) a bit later in order to avoid flickering if there are more subs following immediately. Patch by Michael Reinsch <mr at uue adot org>
author | mosu |
---|---|
date | Fri, 23 Apr 2004 16:36:33 +0000 |
parents | e7c8200ffdc5 |
children | 95ea9f5f6f14 |
rev | line source |
---|---|
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
1 |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4043
diff
changeset
|
2 #include "config.h" |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
3 #include <stdlib.h> |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
4 #include <stdio.h> |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
5 #include <string.h> |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4043
diff
changeset
|
6 #ifdef MP_DEBUG |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
7 #include <assert.h> |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4043
diff
changeset
|
8 #endif |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
9 #include <errno.h> |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
10 #include <sys/types.h> |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
11 #include <sys/stat.h> |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
12 #include <fcntl.h> |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
13 #include <unistd.h> |
9749 | 14 #include "m_config.h" |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
15 #include "playtree.h" |
4308
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
16 #include "playtreeparser.h" |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
17 #include "libmpdemux/stream.h" |
12223 | 18 #include "libmpdemux/demuxer.h" |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
19 #include "mp_msg.h" |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
20 |
6662
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
21 |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
22 #if defined(__CYGWIN__) || defined(__OS2__) |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
23 #define PATH_SEP '\\' |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
24 #else |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
25 #define PATH_SEP '/' |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
26 #endif |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
27 |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
28 extern play_tree_t* |
4308
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
29 asx_parser_build_tree(char* buffer, int ref); |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
30 |
4782 | 31 #define BUF_STEP 1024 |
32 | |
33 #define WHITES " \n\r\t" | |
34 | |
35 static void | |
36 strstrip(char* str) { | |
37 char* i; | |
38 | |
8907 | 39 if (str==NULL) |
40 return; | |
4782 | 41 for(i = str ; i[0] != '\0' && strchr(WHITES,i[0]) != NULL; i++) |
42 /* NOTHING */; | |
43 if(i[0] != '\0') { | |
8907 | 44 memmove(str,i,strlen(i) + 1); |
45 for(i = str + strlen(str) - 1 ; strchr(WHITES,i[0]) != NULL; i--) | |
4782 | 46 /* NOTHING */; |
47 i[1] = '\0'; | |
48 } else | |
49 str[0] = '\0'; | |
50 } | |
51 | |
52 static char* | |
53 play_tree_parser_get_line(play_tree_parser_t* p) { | |
54 char *end,*line_end; | |
55 int r,resize = 0; | |
56 | |
57 if(p->buffer == NULL) { | |
58 p->buffer = (char*)malloc(BUF_STEP); | |
59 p->buffer_size = BUF_STEP; | |
60 p->iter = p->buffer; | |
61 } | |
62 | |
5802 | 63 if(p->stream->eof && (p->buffer_end == 0 || p->iter[0] == '\0')) |
4782 | 64 return NULL; |
65 | |
66 while(1) { | |
67 | |
68 if(resize) { | |
69 r = p->iter - p->buffer; | |
70 p->buffer = (char*)realloc(p->buffer,p->buffer_size+BUF_STEP); | |
71 p->iter = p->buffer + r; | |
72 p->buffer_size += BUF_STEP; | |
73 resize = 0; | |
74 } | |
75 | |
76 if(p->buffer_size - p->buffer_end > 1 && ! p->stream->eof) { | |
77 r = stream_read(p->stream,p->buffer + p->buffer_end,p->buffer_size - p->buffer_end - 1); | |
78 if(r > 0) { | |
79 p->buffer_end += r; | |
80 p->buffer[p->buffer_end] = '\0'; | |
81 } | |
82 } | |
83 | |
84 end = strchr(p->iter,'\n'); | |
85 if(!end) { | |
86 if(p->stream->eof) { | |
4857 | 87 end = p->buffer + p->buffer_end; |
4782 | 88 break; |
89 } | |
90 resize = 1; | |
91 continue; | |
92 } | |
93 break; | |
94 } | |
95 | |
96 line_end = ((*(end-1)) == '\r') ? end-1 : end; | |
5802 | 97 if(line_end - p->iter >= 0) |
98 p->line = (char*)realloc(p->line,line_end - p->iter+1); | |
99 else | |
4782 | 100 return NULL; |
5802 | 101 if(line_end - p->iter > 0) |
102 strncpy(p->line,p->iter,line_end - p->iter); | |
4782 | 103 p->line[line_end - p->iter] = '\0'; |
5802 | 104 if(end[0] != '\0') |
4857 | 105 end++; |
4782 | 106 |
107 if(!p->keep) { | |
4857 | 108 if(end[0] != '\0') { |
5788
8bd1c1e319fb
Fix a bug produced when line are terminated with \r\n and not a single
albeu
parents:
4857
diff
changeset
|
109 p->buffer_end -= end-p->iter; |
4782 | 110 memmove(p->buffer,end,p->buffer_end); |
10694 | 111 p->buffer[p->buffer_end] = '\0'; |
4782 | 112 } else |
113 p->buffer_end = 0; | |
114 p->iter = p->buffer; | |
115 } else | |
116 p->iter = end; | |
117 | |
118 return p->line; | |
119 } | |
120 | |
121 static void | |
122 play_tree_parser_reset(play_tree_parser_t* p) { | |
123 p->iter = p->buffer; | |
124 } | |
125 | |
126 static void | |
127 play_tree_parser_stop_keeping(play_tree_parser_t* p) { | |
128 p->keep = 0; | |
129 if(p->iter && p->iter != p->buffer) { | |
130 p->buffer_end -= p->iter -p->buffer; | |
131 if(p->buffer_end) | |
132 memmove(p->buffer,p->iter,p->buffer_end); | |
133 p->iter = p->buffer; | |
134 } | |
135 } | |
136 | |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
137 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
138 play_tree_t* |
4308
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
139 parse_asx(play_tree_parser_t* p) { |
4782 | 140 int comments = 0,get_line = 1; |
141 char* line = NULL; | |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
142 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
143 mp_msg(MSGT_PLAYTREE,MSGL_V,"Trying asx...\n"); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
144 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
145 while(1) { |
4782 | 146 if(get_line) { |
147 line = play_tree_parser_get_line(p); | |
148 if(!line) | |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
149 return NULL; |
4782 | 150 strstrip(line); |
151 if(line[0] == '\0') | |
152 continue; | |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
153 } |
4782 | 154 if(!comments) { |
155 if(line[0] != '<') { | |
156 mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"First char isn't '<' but '%c'\n",line[0]); | |
4308
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
157 mp_msg(MSGT_PLAYTREE,MSGL_DBG3,"Buffer = [%s]\n",p->buffer); |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
158 return NULL; |
4782 | 159 } else if(strncmp(line,"<!--",4) == 0) { // Comments |
160 comments = 1; | |
161 line += 4; | |
162 if(line[0] != '\0' && strlen(line) > 0) | |
163 get_line = 0; | |
164 } else if(strncasecmp(line,"<ASX",4) == 0) // We got an asx element | |
165 break; | |
166 else // We don't get an asx | |
167 return NULL; | |
168 } else { // Comments | |
169 char* c; | |
170 c = strchr(line,'-'); | |
171 if(c) { | |
172 if (strncmp(c,"--!>",4) == 0) { // End of comments | |
173 comments = 0; | |
174 line = c+4; | |
175 if(line[0] != '\0') // There is some more data on this line : keep it | |
176 get_line = 0; | |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
177 |
4782 | 178 } else { |
179 line = c+1; // Jump the - | |
180 if(line[0] != '\0') // Some more data | |
181 get_line = 0; | |
182 else // End of line | |
183 get_line = 1; | |
184 } | |
185 } else // No - on this line (or rest of line) : get next one | |
186 get_line = 1; | |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
187 } |
4782 | 188 } |
189 | |
190 mp_msg(MSGT_PLAYTREE,MSGL_V,"Detected asx format\n"); | |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
191 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
192 // We have an asx : load it in memory and parse |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
193 |
4782 | 194 while((line = play_tree_parser_get_line(p)) != NULL) |
195 /* NOTHING */; | |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
196 |
10487 | 197 mp_msg(MSGT_PLAYTREE,MSGL_DBG3,"Parsing asx file: [%s]\n",p->buffer); |
4308
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
198 return asx_parser_build_tree(p->buffer,p->deep); |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
199 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
200 |
4782 | 201 static char* |
202 pls_entry_get_value(char* line) { | |
203 char* i; | |
204 | |
205 i = strchr(line,'='); | |
206 if(!i || i[1] == '\0') | |
207 return NULL; | |
208 else | |
209 return i+1; | |
210 } | |
211 | |
212 typedef struct pls_entry { | |
213 char* file; | |
214 char* title; | |
215 char* length; | |
216 } pls_entry_t; | |
217 | |
218 static int | |
219 pls_read_entry(char* line,pls_entry_t** _e,int* _max_entry,char** val) { | |
220 int num,max_entry = (*_max_entry); | |
221 pls_entry_t* e = (*_e); | |
222 char* v; | |
223 | |
224 v = pls_entry_get_value(line); | |
225 if(!v) { | |
226 mp_msg(MSGT_PLAYTREE,MSGL_ERR,"No value in entry %s\n",line); | |
227 return 0; | |
228 } | |
229 | |
230 num = atoi(line); | |
231 if(num < 0) { | |
232 num = max_entry+1; | |
233 mp_msg(MSGT_PLAYTREE,MSGL_WARN,"No entry index in entry %s\nAssuming %d\n",line,num); | |
234 } | |
235 if(num > max_entry) { | |
236 e = (pls_entry_t*)realloc(e,num*sizeof(pls_entry_t)); | |
237 memset(&e[max_entry],0,(num-max_entry)*sizeof(pls_entry_t)); | |
238 max_entry = num; | |
239 } | |
240 (*_e) = e; | |
241 (*_max_entry) = max_entry; | |
242 (*val) = v; | |
243 | |
244 return num; | |
245 } | |
246 | |
247 | |
248 play_tree_t* | |
249 parse_pls(play_tree_parser_t* p) { | |
250 char *line,*v; | |
251 pls_entry_t* entries = NULL; | |
252 int n_entries = 0,max_entry=0,num; | |
9789
45173e0d34cc
Fix the incredible slowness with very long list. Now a 10^6 entries
albeu
parents:
9749
diff
changeset
|
253 play_tree_t *list = NULL, *entry = NULL, *last_entry = NULL; |
4782 | 254 |
10487 | 255 mp_msg(MSGT_PLAYTREE,MSGL_V,"Trying Winamp playlist...\n"); |
8925
5c15777f1c07
this patch adds an fallback to playlist (any but the plaintext-list format)
arpi
parents:
8907
diff
changeset
|
256 if (!(line = play_tree_parser_get_line(p))) |
5c15777f1c07
this patch adds an fallback to playlist (any but the plaintext-list format)
arpi
parents:
8907
diff
changeset
|
257 return NULL; |
4782 | 258 strstrip(line); |
259 if(strcasecmp(line,"[playlist]")) | |
260 return NULL; | |
10487 | 261 mp_msg(MSGT_PLAYTREE,MSGL_V,"Detected Winamp playlist format\n"); |
4782 | 262 play_tree_parser_stop_keeping(p); |
263 line = play_tree_parser_get_line(p); | |
264 if(!line) | |
265 return NULL; | |
266 strstrip(line); | |
267 if(strncasecmp(line,"NumberOfEntries",15) == 0) { | |
268 v = pls_entry_get_value(line); | |
269 n_entries = atoi(v); | |
270 if(n_entries < 0) | |
10487 | 271 mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"Invalid number of entries: very funny!!!\n"); |
4782 | 272 else |
10487 | 273 mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"Playlist claims to have %d entries. Let's see.\n",n_entries); |
4782 | 274 line = play_tree_parser_get_line(p); |
275 } | |
276 | |
277 while(line) { | |
278 strstrip(line); | |
279 if(line[0] == '\0') { | |
280 line = play_tree_parser_get_line(p); | |
281 continue; | |
282 } | |
283 if(strncasecmp(line,"File",4) == 0) { | |
284 num = pls_read_entry(line+4,&entries,&max_entry,&v); | |
285 if(num < 0) | |
286 mp_msg(MSGT_PLAYTREE,MSGL_ERR,"No value in entry %s\n",line); | |
287 else | |
288 entries[num-1].file = strdup(v); | |
289 } else if(strncasecmp(line,"Title",5) == 0) { | |
290 num = pls_read_entry(line+5,&entries,&max_entry,&v); | |
291 if(num < 0) | |
292 mp_msg(MSGT_PLAYTREE,MSGL_ERR,"No value in entry %s\n",line); | |
293 else | |
294 entries[num-1].title = strdup(v); | |
295 } else if(strncasecmp(line,"Length",6) == 0) { | |
296 num = pls_read_entry(line+6,&entries,&max_entry,&v); | |
297 if(num < 0) | |
298 mp_msg(MSGT_PLAYTREE,MSGL_ERR,"No value in entry %s\n",line); | |
299 else | |
300 entries[num-1].length = strdup(v); | |
301 } else | |
10397 | 302 mp_msg(MSGT_PLAYTREE,MSGL_WARN,"Unknown entry type %s\n",line); |
4782 | 303 line = play_tree_parser_get_line(p); |
304 } | |
305 | |
306 for(num = 0; num < max_entry ; num++) { | |
307 if(entries[num].file == NULL) | |
308 mp_msg(MSGT_PLAYTREE,MSGL_ERR,"Entry %d don't have a file !!!!\n",num+1); | |
309 else { | |
5866 | 310 mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"Adding entry %s\n",entries[num].file); |
4782 | 311 entry = play_tree_new(); |
312 play_tree_add_file(entry,entries[num].file); | |
313 free(entries[num].file); | |
314 if(list) | |
9789
45173e0d34cc
Fix the incredible slowness with very long list. Now a 10^6 entries
albeu
parents:
9749
diff
changeset
|
315 play_tree_append_entry(last_entry,entry); |
4782 | 316 else |
317 list = entry; | |
9789
45173e0d34cc
Fix the incredible slowness with very long list. Now a 10^6 entries
albeu
parents:
9749
diff
changeset
|
318 last_entry = entry; |
4782 | 319 } |
320 if(entries[num].title) { | |
321 // When we have info in playtree we add this info | |
322 free(entries[num].title); | |
323 } | |
324 if(entries[num].length) { | |
325 // When we have info in playtree we add this info | |
326 free(entries[num].length); | |
327 } | |
328 } | |
329 | |
330 free(entries); | |
5866 | 331 |
332 entry = play_tree_new(); | |
333 play_tree_set_child(entry,list); | |
334 return entry; | |
4782 | 335 } |
336 | |
8897
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
337 /* |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
338 Reference Ini-Format: Each entry is assumed a reference |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
339 */ |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
340 play_tree_t* |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
341 parse_ref_ini(play_tree_parser_t* p) { |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
342 char *line,*v; |
9789
45173e0d34cc
Fix the incredible slowness with very long list. Now a 10^6 entries
albeu
parents:
9749
diff
changeset
|
343 play_tree_t *list = NULL, *entry = NULL, *last_entry = NULL; |
8897
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
344 |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
345 mp_msg(MSGT_PLAYTREE,MSGL_V,"Trying reference-ini playlist...\n"); |
8925
5c15777f1c07
this patch adds an fallback to playlist (any but the plaintext-list format)
arpi
parents:
8907
diff
changeset
|
346 if (!(line = play_tree_parser_get_line(p))) |
5c15777f1c07
this patch adds an fallback to playlist (any but the plaintext-list format)
arpi
parents:
8907
diff
changeset
|
347 return NULL; |
8897
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
348 strstrip(line); |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
349 if(strcasecmp(line,"[Reference]")) |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
350 return NULL; |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
351 mp_msg(MSGT_PLAYTREE,MSGL_V,"Detected reference-ini playlist format\n"); |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
352 play_tree_parser_stop_keeping(p); |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
353 line = play_tree_parser_get_line(p); |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
354 if(!line) |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
355 return NULL; |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
356 while(line) { |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
357 strstrip(line); |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
358 if(strncasecmp(line,"Ref",3) == 0) { |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
359 v = pls_entry_get_value(line+3); |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
360 if(!v) |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
361 mp_msg(MSGT_PLAYTREE,MSGL_ERR,"No value in entry %s\n",line); |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
362 else |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
363 { |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
364 mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"Adding entry %s\n",v); |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
365 entry = play_tree_new(); |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
366 play_tree_add_file(entry,v); |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
367 if(list) |
9789
45173e0d34cc
Fix the incredible slowness with very long list. Now a 10^6 entries
albeu
parents:
9749
diff
changeset
|
368 play_tree_append_entry(last_entry,entry); |
8897
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
369 else |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
370 list = entry; |
9789
45173e0d34cc
Fix the incredible slowness with very long list. Now a 10^6 entries
albeu
parents:
9749
diff
changeset
|
371 last_entry = entry; |
8897
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
372 } |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
373 } |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
374 line = play_tree_parser_get_line(p); |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
375 } |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
376 |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
377 if(!list) return NULL; |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
378 entry = play_tree_new(); |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
379 play_tree_set_child(entry,list); |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
380 return entry; |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
381 } |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
382 |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
383 play_tree_t* |
6661
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
384 parse_m3u(play_tree_parser_t* p) { |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
385 char* line; |
9789
45173e0d34cc
Fix the incredible slowness with very long list. Now a 10^6 entries
albeu
parents:
9749
diff
changeset
|
386 play_tree_t *list = NULL, *entry = NULL, *last_entry = NULL; |
6661
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
387 |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
388 mp_msg(MSGT_PLAYTREE,MSGL_V,"Trying extended m3u playlist...\n"); |
8925
5c15777f1c07
this patch adds an fallback to playlist (any but the plaintext-list format)
arpi
parents:
8907
diff
changeset
|
389 if (!(line = play_tree_parser_get_line(p))) |
5c15777f1c07
this patch adds an fallback to playlist (any but the plaintext-list format)
arpi
parents:
8907
diff
changeset
|
390 return NULL; |
6661
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
391 strstrip(line); |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
392 if(strcasecmp(line,"#EXTM3U")) |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
393 return NULL; |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
394 mp_msg(MSGT_PLAYTREE,MSGL_V,"Detected extended m3u playlist format\n"); |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
395 play_tree_parser_stop_keeping(p); |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
396 |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
397 while((line = play_tree_parser_get_line(p)) != NULL) { |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
398 strstrip(line); |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
399 if(line[0] == '\0') |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
400 continue; |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
401 /* EXTM3U files contain such lines: |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
402 * #EXTINF:<seconds>, <title> |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
403 * followed by a line with the filename |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
404 * for now we have no place to put that |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
405 * so we just skip that extra-info ::atmos |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
406 */ |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
407 if(line[0] == '#') { |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
408 #if 0 /* code functional */ |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
409 if(strncasecmp(line,"#EXTINF:",8) == 0) { |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
410 mp_msg(MSGT_PLAYTREE,MSGL_INFO,"[M3U] Duration: %dsec Title: %s\n", |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
411 strtol(line+8,&line,10), line+2); |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
412 } |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
413 #endif |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
414 continue; |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
415 } |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
416 entry = play_tree_new(); |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
417 play_tree_add_file(entry,line); |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
418 if(!list) |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
419 list = entry; |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
420 else |
9789
45173e0d34cc
Fix the incredible slowness with very long list. Now a 10^6 entries
albeu
parents:
9749
diff
changeset
|
421 play_tree_append_entry(last_entry,entry); |
45173e0d34cc
Fix the incredible slowness with very long list. Now a 10^6 entries
albeu
parents:
9749
diff
changeset
|
422 last_entry = entry; |
6661
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
423 } |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
424 |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
425 if(!list) return NULL; |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
426 entry = play_tree_new(); |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
427 play_tree_set_child(entry,list); |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
428 return entry; |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
429 } |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
430 |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
431 play_tree_t* |
12097
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
432 parse_smil(play_tree_parser_t* p) { |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
433 int entrymode=0; |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
434 char* line,source[512],*pos,*s_start,*s_end; |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
435 play_tree_t *list = NULL, *entry = NULL, *last_entry = NULL; |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
436 |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
437 mp_msg(MSGT_PLAYTREE,MSGL_V,"Trying smil playlist...\n"); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
438 |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
439 // Check if smil |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
440 while((line = play_tree_parser_get_line(p)) != NULL) { |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
441 strstrip(line); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
442 if(line[0] == '\0') // Ignore empties |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
443 continue; |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
444 if (strncasecmp(line,"<smil",5)==0) |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
445 break; // smil header found |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
446 else |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
447 return NULL; //line not smil exit |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
448 } |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
449 |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
450 mp_msg(MSGT_PLAYTREE,MSGL_V,"Detected smil playlist format\n"); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
451 play_tree_parser_stop_keeping(p); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
452 |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
453 |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
454 //Get entries from smil |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
455 while((line = play_tree_parser_get_line(p)) != NULL) { |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
456 strstrip(line); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
457 if (line[0]=='\0') |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
458 continue; |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
459 if (!entrymode) { // all entries filled so far |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
460 if (strncasecmp(line,"<video",6)==0 || strncasecmp(line,"<audio",6)==0) { |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
461 pos=strstr(line,"src="); // Is source present on this line |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
462 if (pos !=NULL) { |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
463 s_start=pos+5; |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
464 s_end=strchr(s_start,'"'); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
465 if (s_end == NULL) { |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
466 mp_msg(MSGT_PLAYTREE,MSGL_V,"Error parsing this source line %s\n",line); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
467 continue; |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
468 } |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
469 if (s_end-s_start> 511) { |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
470 mp_msg(MSGT_PLAYTREE,MSGL_V,"Cannot store such a large source %s\n",line); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
471 continue; |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
472 } |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
473 strncpy(source,s_start,s_end-s_start); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
474 source[(s_end-s_start)]='\0'; // Null terminate |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
475 entry = play_tree_new(); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
476 play_tree_add_file(entry,source); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
477 if(!list) //Insert new entry |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
478 list = entry; |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
479 else |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
480 play_tree_append_entry(last_entry,entry); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
481 last_entry = entry; |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
482 } else { |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
483 entrymode=1; |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
484 } |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
485 } |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
486 } else { //Entry found but not yet filled |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
487 pos = strstr(line,"src="); // Is source present on this line |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
488 if (pos != NULL) { |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
489 entrymode=0; |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
490 s_start=pos+5; |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
491 s_end=strchr(s_start,'"'); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
492 if (s_end == NULL) { |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
493 mp_msg(MSGT_PLAYTREE,MSGL_V,"Error parsing this source line %s\n",line); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
494 continue; |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
495 } |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
496 if (s_end-s_start> 511) { |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
497 mp_msg(MSGT_PLAYTREE,MSGL_V,"Cannot store such a large source %s\n",line); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
498 continue; |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
499 } |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
500 strncpy(source,s_start,s_end-s_start); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
501 source[(s_end-s_start)]='\0'; // Null terminate |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
502 entry = play_tree_new(); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
503 play_tree_add_file(entry,source); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
504 if(!list) //Insert new entry |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
505 list = entry; |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
506 else |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
507 play_tree_append_entry(last_entry,entry); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
508 last_entry = entry; |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
509 } |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
510 } |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
511 } |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
512 |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
513 if(!list) return NULL; // Nothing found |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
514 |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
515 entry = play_tree_new(); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
516 play_tree_set_child(entry,list); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
517 return entry; |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
518 } |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
519 |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
520 play_tree_t* |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
521 embedded_playlist_parse(char *line) { |
12223 | 522 int f=DEMUXER_TYPE_PLAYLIST; |
12097
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
523 stream_t* stream; |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
524 play_tree_parser_t* ptp; |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
525 play_tree_t* entry; |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
526 |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
527 // Get stream opened to link |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
528 stream=open_stream(line,0,&f); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
529 if(!stream) { |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
530 mp_msg(MSGT_PLAYTREE,MSGL_WARN,"Can't open playlist %s\n",line); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
531 return NULL; |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
532 } |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
533 |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
534 //add new playtree |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
535 mp_msg(MSGT_PLAYTREE,MSGL_V,"Adding playlist %s to element entryref\n",line); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
536 |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
537 ptp = play_tree_parser_new(stream,1); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
538 entry = play_tree_parser_get_play_tree(ptp, 1); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
539 play_tree_parser_free(ptp); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
540 free_stream(stream); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
541 |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
542 return entry; |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
543 } |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
544 |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
545 play_tree_t* |
4308
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
546 parse_textplain(play_tree_parser_t* p) { |
4782 | 547 char* line; |
12097
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
548 int reflen; |
9789
45173e0d34cc
Fix the incredible slowness with very long list. Now a 10^6 entries
albeu
parents:
9749
diff
changeset
|
549 play_tree_t *list = NULL, *entry = NULL, *last_entry = NULL; |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
550 |
6661
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
551 mp_msg(MSGT_PLAYTREE,MSGL_V,"Trying plaintext playlist...\n"); |
4782 | 552 play_tree_parser_stop_keeping(p); |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
553 |
4782 | 554 while((line = play_tree_parser_get_line(p)) != NULL) { |
555 strstrip(line); | |
556 if(line[0] == '\0') | |
557 continue; | |
12097
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
558 |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
559 //Special check for smil refernce in file |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
560 reflen=strlen(line); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
561 if ( (reflen>5) && (strncasecmp(line+(reflen-5),".smil",5)==0) ) { //embedded playlist link |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
562 entry=embedded_playlist_parse(line); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
563 } else { //regular file link |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
564 entry = play_tree_new(); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
565 play_tree_add_file(entry,line); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
566 } |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
567 |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
568 if (entry != NULL) { |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
569 if(!list) |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
570 list = entry; |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
571 else |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
572 play_tree_append_entry(last_entry,entry); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
573 last_entry = entry; |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
574 } |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
575 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
576 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
577 if(!list) return NULL; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
578 entry = play_tree_new(); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
579 play_tree_set_child(entry,list); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
580 return entry; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
581 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
582 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
583 play_tree_t* |
8925
5c15777f1c07
this patch adds an fallback to playlist (any but the plaintext-list format)
arpi
parents:
8907
diff
changeset
|
584 parse_playtree(stream_t *stream, int forced) { |
4308
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
585 play_tree_parser_t* p; |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
586 play_tree_t* ret; |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
587 |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4043
diff
changeset
|
588 #ifdef MP_DEBUG |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
589 assert(stream != NULL); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
590 #endif |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
591 |
4308
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
592 p = play_tree_parser_new(stream,0); |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
593 if(!p) |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
594 return NULL; |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
595 |
8925
5c15777f1c07
this patch adds an fallback to playlist (any but the plaintext-list format)
arpi
parents:
8907
diff
changeset
|
596 ret = play_tree_parser_get_play_tree(p, forced); |
4308
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
597 play_tree_parser_free(p); |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
598 |
4308
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
599 return ret; |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
600 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
601 |
6662
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
602 static void |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
603 play_tree_add_basepath(play_tree_t* pt, char* bp) { |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
604 int i,bl = strlen(bp),fl; |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
605 |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
606 if(pt->child) { |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
607 play_tree_t* i; |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
608 for(i = pt->child ; i != NULL ; i = i->next) |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
609 play_tree_add_basepath(i,bp); |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
610 return; |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
611 } |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
612 |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
613 if(!pt->files) |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
614 return; |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
615 |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
616 for(i = 0 ; pt->files[i] != NULL ; i++) { |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
617 fl = strlen(pt->files[i]); |
6663 | 618 if(fl <= 0 || pt->files[i][0] == PATH_SEP || strstr(pt->files[i],"://")) |
6662
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
619 continue; |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
620 pt->files[i] = (char*)realloc(pt->files[i],bl+fl+1); |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
621 memmove(pt->files[i] + bl,pt->files[i],fl+1); |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
622 memcpy(pt->files[i],bp,bl); |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
623 } |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
624 } |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
625 |
9301
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
626 // Wrapper for play_tree_add_basepath (add base path from file) |
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
627 void play_tree_add_bpf(play_tree_t* pt, char* filename) |
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
628 { |
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
629 char *ls, *file; |
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
630 |
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
631 if (pt && filename) |
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
632 { |
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
633 file = strdup(filename); |
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
634 if (file) |
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
635 { |
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
636 ls = strrchr(file,PATH_SEP); |
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
637 if(ls) { |
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
638 ls[1] = '\0'; |
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
639 play_tree_add_basepath(pt,file); |
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
640 } |
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
641 free(file); |
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
642 } |
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
643 } |
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
644 } |
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
645 |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
646 play_tree_t* |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
647 parse_playlist_file(char* file) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
648 stream_t *stream; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
649 play_tree_t* ret; |
12223 | 650 int f=DEMUXER_TYPE_PLAYLIST; |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
651 |
9749 | 652 stream = open_stream(file,0,&f); |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
653 |
9749 | 654 if(!stream) { |
10487 | 655 mp_msg(MSGT_PLAYTREE,MSGL_ERR,"Error while opening playlist file %s: %s\n",file,strerror(errno)); |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
656 return NULL; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
657 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
658 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
659 mp_msg(MSGT_PLAYTREE,MSGL_V,"Parsing playlist file %s...\n",file); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
660 |
8925
5c15777f1c07
this patch adds an fallback to playlist (any but the plaintext-list format)
arpi
parents:
8907
diff
changeset
|
661 ret = parse_playtree(stream,1); |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
662 free_stream(stream); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
663 |
9301
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
664 play_tree_add_bpf(ret, file); |
6662
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
665 |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
666 return ret; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
667 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
668 } |
4308
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
669 |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
670 |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
671 play_tree_parser_t* |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
672 play_tree_parser_new(stream_t* stream,int deep) { |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
673 play_tree_parser_t* p; |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
674 |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
675 p = (play_tree_parser_t*)calloc(1,sizeof(play_tree_parser_t)); |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
676 if(!p) |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
677 return NULL; |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
678 p->stream = stream; |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
679 p->deep = deep; |
4782 | 680 p->keep = 1; |
4308
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
681 |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
682 return p; |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
683 |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
684 } |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
685 |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
686 void |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
687 play_tree_parser_free(play_tree_parser_t* p) { |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
688 |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
689 #ifdef MP_DEBUG |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
690 assert(p != NULL); |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
691 #endif |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
692 |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
693 if(p->buffer) free(p->buffer); |
4782 | 694 if(p->line) free(p->line); |
695 free(p); | |
4308
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
696 } |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
697 |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
698 play_tree_t* |
8925
5c15777f1c07
this patch adds an fallback to playlist (any but the plaintext-list format)
arpi
parents:
8907
diff
changeset
|
699 play_tree_parser_get_play_tree(play_tree_parser_t* p, int forced) { |
4308
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
700 play_tree_t* tree = NULL; |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
701 |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
702 #ifdef MP_DEBUG |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
703 assert(p != NULL); |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
704 #endif |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
705 |
4782 | 706 |
707 while(play_tree_parser_get_line(p) != NULL) { | |
708 play_tree_parser_reset(p); | |
709 | |
4308
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
710 tree = parse_asx(p); |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
711 if(tree) break; |
4782 | 712 play_tree_parser_reset(p); |
713 | |
714 tree = parse_pls(p); | |
715 if(tree) break; | |
716 play_tree_parser_reset(p); | |
717 | |
6661
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
718 tree = parse_m3u(p); |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
719 if(tree) break; |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
720 play_tree_parser_reset(p); |
8897
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
721 |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
722 tree = parse_ref_ini(p); |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
723 if(tree) break; |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
724 play_tree_parser_reset(p); |
6661
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
725 |
12097
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
726 tree = parse_smil(p); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
727 if(tree) break; |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
728 play_tree_parser_reset(p); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
729 |
4308
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
730 // Here come the others formats ( textplain must stay the last one ) |
8925
5c15777f1c07
this patch adds an fallback to playlist (any but the plaintext-list format)
arpi
parents:
8907
diff
changeset
|
731 if (forced) |
5c15777f1c07
this patch adds an fallback to playlist (any but the plaintext-list format)
arpi
parents:
8907
diff
changeset
|
732 { |
5c15777f1c07
this patch adds an fallback to playlist (any but the plaintext-list format)
arpi
parents:
8907
diff
changeset
|
733 tree = parse_textplain(p); |
5c15777f1c07
this patch adds an fallback to playlist (any but the plaintext-list format)
arpi
parents:
8907
diff
changeset
|
734 if(tree) break; |
5c15777f1c07
this patch adds an fallback to playlist (any but the plaintext-list format)
arpi
parents:
8907
diff
changeset
|
735 } |
4308
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
736 break; |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
737 } |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
738 |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
739 if(tree) |
10487 | 740 mp_msg(MSGT_PLAYTREE,MSGL_V,"Playlist successfully parsed\n"); |
8925
5c15777f1c07
this patch adds an fallback to playlist (any but the plaintext-list format)
arpi
parents:
8907
diff
changeset
|
741 else |
5c15777f1c07
this patch adds an fallback to playlist (any but the plaintext-list format)
arpi
parents:
8907
diff
changeset
|
742 mp_msg(MSGT_PLAYTREE,((forced==1)?MSGL_ERR:MSGL_V),"Error while parsing playlist\n"); |
4308
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
743 |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
744 if(tree) |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
745 tree = play_tree_cleanup(tree); |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
746 |
10487 | 747 if(!tree) mp_msg(MSGT_PLAYTREE,((forced==1)?MSGL_WARN:MSGL_V),"Warning: empty playlist\n"); |
4308
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
748 |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
749 return tree; |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
750 } |