Mercurial > mplayer.hg
annotate playtreeparser.c @ 29190:cb11a0c11f5e
typo in XFORM asm check, noticed by Emanuele Giaquinta
author | diego |
---|---|
date | Sat, 25 Apr 2009 16:37:08 +0000 |
parents | 3e4486488465 |
children | 0f1b5b68af32 |
rev | line source |
---|---|
18265 | 1 |
2 /// \file | |
3 /// \ingroup PlaytreeParser | |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
4 |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4043
diff
changeset
|
5 #include "config.h" |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
6 #include <stdlib.h> |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
7 #include <stdio.h> |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
8 #include <string.h> |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
9 #include <assert.h> |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
10 #include <errno.h> |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
11 #include <sys/types.h> |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
12 #include <sys/stat.h> |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
13 #include <fcntl.h> |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
14 #include <unistd.h> |
12300
95ea9f5f6f14
Fix embedded smil playlist detection if there are parameters on the url
rtognimp
parents:
12223
diff
changeset
|
15 #include <ctype.h> |
9749 | 16 #include "m_config.h" |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
17 #include "playtree.h" |
4308
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
18 #include "playtreeparser.h" |
19271
64d82a45a05d
introduce new 'stream' directory for all stream layer related components and split them from libmpdemux
ben
parents:
18928
diff
changeset
|
19 #include "stream/stream.h" |
12223 | 20 #include "libmpdemux/demuxer.h" |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
21 #include "mp_msg.h" |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
22 |
6662
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
23 |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
24 extern play_tree_t* |
4308
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
25 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
|
26 |
4782 | 27 #define BUF_STEP 1024 |
28 | |
29 #define WHITES " \n\r\t" | |
30 | |
31 static void | |
32 strstrip(char* str) { | |
33 char* i; | |
34 | |
8907 | 35 if (str==NULL) |
36 return; | |
4782 | 37 for(i = str ; i[0] != '\0' && strchr(WHITES,i[0]) != NULL; i++) |
38 /* NOTHING */; | |
39 if(i[0] != '\0') { | |
8907 | 40 memmove(str,i,strlen(i) + 1); |
41 for(i = str + strlen(str) - 1 ; strchr(WHITES,i[0]) != NULL; i--) | |
4782 | 42 /* NOTHING */; |
43 i[1] = '\0'; | |
44 } else | |
45 str[0] = '\0'; | |
46 } | |
47 | |
48 static char* | |
49 play_tree_parser_get_line(play_tree_parser_t* p) { | |
50 char *end,*line_end; | |
51 int r,resize = 0; | |
52 | |
53 if(p->buffer == NULL) { | |
18869 | 54 p->buffer = malloc(BUF_STEP); |
4782 | 55 p->buffer_size = BUF_STEP; |
28183 | 56 p->buffer[0] = 0; |
4782 | 57 p->iter = p->buffer; |
58 } | |
59 | |
5802 | 60 if(p->stream->eof && (p->buffer_end == 0 || p->iter[0] == '\0')) |
4782 | 61 return NULL; |
62 | |
28182
26ab2d01157f
Add asserts to detect when assumptions for play_tree_parser_get_line
reimar
parents:
25141
diff
changeset
|
63 assert(p->buffer_end < p->buffer_size); |
26ab2d01157f
Add asserts to detect when assumptions for play_tree_parser_get_line
reimar
parents:
25141
diff
changeset
|
64 assert(!p->buffer[p->buffer_end]); |
4782 | 65 while(1) { |
66 | |
67 if(resize) { | |
68 r = p->iter - p->buffer; | |
69 p->buffer = (char*)realloc(p->buffer,p->buffer_size+BUF_STEP); | |
70 p->iter = p->buffer + r; | |
71 p->buffer_size += BUF_STEP; | |
72 resize = 0; | |
73 } | |
74 | |
75 if(p->buffer_size - p->buffer_end > 1 && ! p->stream->eof) { | |
76 r = stream_read(p->stream,p->buffer + p->buffer_end,p->buffer_size - p->buffer_end - 1); | |
77 if(r > 0) { | |
78 p->buffer_end += r; | |
28182
26ab2d01157f
Add asserts to detect when assumptions for play_tree_parser_get_line
reimar
parents:
25141
diff
changeset
|
79 assert(p->buffer_end < p->buffer_size); |
4782 | 80 p->buffer[p->buffer_end] = '\0'; |
22242
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
81 while(strlen(p->buffer + p->buffer_end - r) != r) |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
82 p->buffer[p->buffer_end - r + strlen(p->buffer + p->buffer_end - r)] = '\n'; |
4782 | 83 } |
28182
26ab2d01157f
Add asserts to detect when assumptions for play_tree_parser_get_line
reimar
parents:
25141
diff
changeset
|
84 assert(!p->buffer[p->buffer_end]); |
4782 | 85 } |
86 | |
87 end = strchr(p->iter,'\n'); | |
88 if(!end) { | |
89 if(p->stream->eof) { | |
4857 | 90 end = p->buffer + p->buffer_end; |
4782 | 91 break; |
92 } | |
93 resize = 1; | |
94 continue; | |
95 } | |
96 break; | |
97 } | |
98 | |
25141
fba022abe464
100l in play_tree_parser_get_line, check that there actually is
reimar
parents:
24962
diff
changeset
|
99 line_end = (end > p->iter && *(end-1) == '\r') ? end-1 : end; |
5802 | 100 if(line_end - p->iter >= 0) |
101 p->line = (char*)realloc(p->line,line_end - p->iter+1); | |
102 else | |
4782 | 103 return NULL; |
5802 | 104 if(line_end - p->iter > 0) |
105 strncpy(p->line,p->iter,line_end - p->iter); | |
4782 | 106 p->line[line_end - p->iter] = '\0'; |
5802 | 107 if(end[0] != '\0') |
4857 | 108 end++; |
4782 | 109 |
110 if(!p->keep) { | |
4857 | 111 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
|
112 p->buffer_end -= end-p->iter; |
4782 | 113 memmove(p->buffer,end,p->buffer_end); |
114 } else | |
115 p->buffer_end = 0; | |
28183 | 116 p->buffer[p->buffer_end] = '\0'; |
4782 | 117 p->iter = p->buffer; |
118 } else | |
119 p->iter = end; | |
120 | |
121 return p->line; | |
122 } | |
123 | |
124 static void | |
125 play_tree_parser_reset(play_tree_parser_t* p) { | |
126 p->iter = p->buffer; | |
127 } | |
128 | |
129 static void | |
130 play_tree_parser_stop_keeping(play_tree_parser_t* p) { | |
131 p->keep = 0; | |
132 if(p->iter && p->iter != p->buffer) { | |
133 p->buffer_end -= p->iter -p->buffer; | |
134 if(p->buffer_end) | |
135 memmove(p->buffer,p->iter,p->buffer_end); | |
28184
0fb5551413f7
1000l, play_tree_parser_stop_keeping broke 0-termination of buffer
reimar
parents:
28183
diff
changeset
|
136 p->buffer[p->buffer_end] = 0; |
4782 | 137 p->iter = p->buffer; |
138 } | |
139 } | |
140 | |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
141 |
18916
a95ed361d16b
several function from playtreeparser.c maked static,
reynaldo
parents:
18879
diff
changeset
|
142 static play_tree_t* |
4308
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
143 parse_asx(play_tree_parser_t* p) { |
4782 | 144 int comments = 0,get_line = 1; |
145 char* line = NULL; | |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
146 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
147 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
|
148 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
149 while(1) { |
4782 | 150 if(get_line) { |
151 line = play_tree_parser_get_line(p); | |
152 if(!line) | |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
153 return NULL; |
4782 | 154 strstrip(line); |
155 if(line[0] == '\0') | |
156 continue; | |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
157 } |
4782 | 158 if(!comments) { |
159 if(line[0] != '<') { | |
160 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
|
161 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
|
162 return NULL; |
4782 | 163 } else if(strncmp(line,"<!--",4) == 0) { // Comments |
164 comments = 1; | |
165 line += 4; | |
166 if(line[0] != '\0' && strlen(line) > 0) | |
167 get_line = 0; | |
168 } else if(strncasecmp(line,"<ASX",4) == 0) // We got an asx element | |
169 break; | |
170 else // We don't get an asx | |
171 return NULL; | |
172 } else { // Comments | |
173 char* c; | |
174 c = strchr(line,'-'); | |
175 if(c) { | |
176 if (strncmp(c,"--!>",4) == 0) { // End of comments | |
177 comments = 0; | |
178 line = c+4; | |
179 if(line[0] != '\0') // There is some more data on this line : keep it | |
180 get_line = 0; | |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
181 |
4782 | 182 } else { |
183 line = c+1; // Jump the - | |
184 if(line[0] != '\0') // Some more data | |
185 get_line = 0; | |
186 else // End of line | |
187 get_line = 1; | |
188 } | |
189 } else // No - on this line (or rest of line) : get next one | |
190 get_line = 1; | |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
191 } |
4782 | 192 } |
193 | |
194 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
|
195 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
196 // 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
|
197 |
4782 | 198 while((line = play_tree_parser_get_line(p)) != NULL) |
199 /* NOTHING */; | |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
200 |
10487 | 201 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
|
202 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
|
203 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
204 |
4782 | 205 static char* |
206 pls_entry_get_value(char* line) { | |
207 char* i; | |
208 | |
209 i = strchr(line,'='); | |
210 if(!i || i[1] == '\0') | |
211 return NULL; | |
212 else | |
213 return i+1; | |
214 } | |
215 | |
216 typedef struct pls_entry { | |
217 char* file; | |
218 char* title; | |
219 char* length; | |
220 } pls_entry_t; | |
221 | |
222 static int | |
223 pls_read_entry(char* line,pls_entry_t** _e,int* _max_entry,char** val) { | |
224 int num,max_entry = (*_max_entry); | |
225 pls_entry_t* e = (*_e); | |
226 char* v; | |
227 | |
228 v = pls_entry_get_value(line); | |
229 if(!v) { | |
230 mp_msg(MSGT_PLAYTREE,MSGL_ERR,"No value in entry %s\n",line); | |
231 return 0; | |
232 } | |
233 | |
234 num = atoi(line); | |
235 if(num < 0) { | |
236 num = max_entry+1; | |
237 mp_msg(MSGT_PLAYTREE,MSGL_WARN,"No entry index in entry %s\nAssuming %d\n",line,num); | |
238 } | |
239 if(num > max_entry) { | |
240 e = (pls_entry_t*)realloc(e,num*sizeof(pls_entry_t)); | |
241 memset(&e[max_entry],0,(num-max_entry)*sizeof(pls_entry_t)); | |
242 max_entry = num; | |
243 } | |
244 (*_e) = e; | |
245 (*_max_entry) = max_entry; | |
246 (*val) = v; | |
247 | |
248 return num; | |
249 } | |
250 | |
251 | |
18916
a95ed361d16b
several function from playtreeparser.c maked static,
reynaldo
parents:
18879
diff
changeset
|
252 static play_tree_t* |
4782 | 253 parse_pls(play_tree_parser_t* p) { |
254 char *line,*v; | |
255 pls_entry_t* entries = NULL; | |
256 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
|
257 play_tree_t *list = NULL, *entry = NULL, *last_entry = NULL; |
4782 | 258 |
10487 | 259 mp_msg(MSGT_PLAYTREE,MSGL_V,"Trying Winamp playlist...\n"); |
20834 | 260 while((line = play_tree_parser_get_line(p))) { |
261 strstrip(line); | |
262 if(strlen(line)) | |
263 break; | |
264 } | |
265 if (!line) | |
8925
5c15777f1c07
this patch adds an fallback to playlist (any but the plaintext-list format)
arpi
parents:
8907
diff
changeset
|
266 return NULL; |
4782 | 267 if(strcasecmp(line,"[playlist]")) |
268 return NULL; | |
10487 | 269 mp_msg(MSGT_PLAYTREE,MSGL_V,"Detected Winamp playlist format\n"); |
4782 | 270 play_tree_parser_stop_keeping(p); |
271 line = play_tree_parser_get_line(p); | |
272 if(!line) | |
273 return NULL; | |
274 strstrip(line); | |
275 if(strncasecmp(line,"NumberOfEntries",15) == 0) { | |
276 v = pls_entry_get_value(line); | |
277 n_entries = atoi(v); | |
278 if(n_entries < 0) | |
10487 | 279 mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"Invalid number of entries: very funny!!!\n"); |
4782 | 280 else |
10487 | 281 mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"Playlist claims to have %d entries. Let's see.\n",n_entries); |
4782 | 282 line = play_tree_parser_get_line(p); |
283 } | |
284 | |
285 while(line) { | |
286 strstrip(line); | |
287 if(line[0] == '\0') { | |
288 line = play_tree_parser_get_line(p); | |
289 continue; | |
290 } | |
291 if(strncasecmp(line,"File",4) == 0) { | |
292 num = pls_read_entry(line+4,&entries,&max_entry,&v); | |
293 if(num < 0) | |
294 mp_msg(MSGT_PLAYTREE,MSGL_ERR,"No value in entry %s\n",line); | |
295 else | |
296 entries[num-1].file = strdup(v); | |
297 } else if(strncasecmp(line,"Title",5) == 0) { | |
298 num = pls_read_entry(line+5,&entries,&max_entry,&v); | |
299 if(num < 0) | |
300 mp_msg(MSGT_PLAYTREE,MSGL_ERR,"No value in entry %s\n",line); | |
301 else | |
302 entries[num-1].title = strdup(v); | |
303 } else if(strncasecmp(line,"Length",6) == 0) { | |
304 num = pls_read_entry(line+6,&entries,&max_entry,&v); | |
305 if(num < 0) | |
306 mp_msg(MSGT_PLAYTREE,MSGL_ERR,"No value in entry %s\n",line); | |
307 else | |
308 entries[num-1].length = strdup(v); | |
309 } else | |
10397 | 310 mp_msg(MSGT_PLAYTREE,MSGL_WARN,"Unknown entry type %s\n",line); |
4782 | 311 line = play_tree_parser_get_line(p); |
312 } | |
313 | |
314 for(num = 0; num < max_entry ; num++) { | |
315 if(entries[num].file == NULL) | |
316 mp_msg(MSGT_PLAYTREE,MSGL_ERR,"Entry %d don't have a file !!!!\n",num+1); | |
317 else { | |
5866 | 318 mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"Adding entry %s\n",entries[num].file); |
4782 | 319 entry = play_tree_new(); |
320 play_tree_add_file(entry,entries[num].file); | |
321 free(entries[num].file); | |
322 if(list) | |
9789
45173e0d34cc
Fix the incredible slowness with very long list. Now a 10^6 entries
albeu
parents:
9749
diff
changeset
|
323 play_tree_append_entry(last_entry,entry); |
4782 | 324 else |
325 list = entry; | |
9789
45173e0d34cc
Fix the incredible slowness with very long list. Now a 10^6 entries
albeu
parents:
9749
diff
changeset
|
326 last_entry = entry; |
4782 | 327 } |
328 if(entries[num].title) { | |
329 // When we have info in playtree we add this info | |
330 free(entries[num].title); | |
331 } | |
332 if(entries[num].length) { | |
333 // When we have info in playtree we add this info | |
334 free(entries[num].length); | |
335 } | |
336 } | |
337 | |
338 free(entries); | |
5866 | 339 |
340 entry = play_tree_new(); | |
341 play_tree_set_child(entry,list); | |
342 return entry; | |
4782 | 343 } |
344 | |
8897
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
345 /* |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
346 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
|
347 */ |
18916
a95ed361d16b
several function from playtreeparser.c maked static,
reynaldo
parents:
18879
diff
changeset
|
348 static play_tree_t* |
8897
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
349 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
|
350 char *line,*v; |
9789
45173e0d34cc
Fix the incredible slowness with very long list. Now a 10^6 entries
albeu
parents:
9749
diff
changeset
|
351 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
|
352 |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
353 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
|
354 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
|
355 return NULL; |
8897
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
356 strstrip(line); |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
357 if(strcasecmp(line,"[Reference]")) |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
358 return NULL; |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
359 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
|
360 play_tree_parser_stop_keeping(p); |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
361 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
|
362 if(!line) |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
363 return NULL; |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
364 while(line) { |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
365 strstrip(line); |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
366 if(strncasecmp(line,"Ref",3) == 0) { |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
367 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
|
368 if(!v) |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
369 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
|
370 else |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
371 { |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
372 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
|
373 entry = play_tree_new(); |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
374 play_tree_add_file(entry,v); |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
375 if(list) |
9789
45173e0d34cc
Fix the incredible slowness with very long list. Now a 10^6 entries
albeu
parents:
9749
diff
changeset
|
376 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
|
377 else |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
378 list = entry; |
9789
45173e0d34cc
Fix the incredible slowness with very long list. Now a 10^6 entries
albeu
parents:
9749
diff
changeset
|
379 last_entry = entry; |
8897
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
380 } |
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 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
|
383 } |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
384 |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
385 if(!list) return NULL; |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
386 entry = play_tree_new(); |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
387 play_tree_set_child(entry,list); |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
388 return entry; |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
389 } |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
390 |
18916
a95ed361d16b
several function from playtreeparser.c maked static,
reynaldo
parents:
18879
diff
changeset
|
391 static play_tree_t* |
6661
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
392 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
|
393 char* line; |
9789
45173e0d34cc
Fix the incredible slowness with very long list. Now a 10^6 entries
albeu
parents:
9749
diff
changeset
|
394 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
|
395 |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
396 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
|
397 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
|
398 return NULL; |
6661
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
399 strstrip(line); |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
400 if(strcasecmp(line,"#EXTM3U")) |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
401 return NULL; |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
402 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
|
403 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
|
404 |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
405 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
|
406 strstrip(line); |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
407 if(line[0] == '\0') |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
408 continue; |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
409 /* EXTM3U files contain such lines: |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
410 * #EXTINF:<seconds>, <title> |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
411 * 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
|
412 * 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
|
413 * 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
|
414 */ |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
415 if(line[0] == '#') { |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
416 #if 0 /* code functional */ |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
417 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
|
418 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
|
419 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
|
420 } |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
421 #endif |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
422 continue; |
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 entry = play_tree_new(); |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
425 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
|
426 if(!list) |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
427 list = entry; |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
428 else |
9789
45173e0d34cc
Fix the incredible slowness with very long list. Now a 10^6 entries
albeu
parents:
9749
diff
changeset
|
429 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
|
430 last_entry = entry; |
6661
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
431 } |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
432 |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
433 if(!list) return NULL; |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
434 entry = play_tree_new(); |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
435 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
|
436 return entry; |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
437 } |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
438 |
18916
a95ed361d16b
several function from playtreeparser.c maked static,
reynaldo
parents:
18879
diff
changeset
|
439 static play_tree_t* |
12097
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
440 parse_smil(play_tree_parser_t* p) { |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
441 int entrymode=0; |
22242
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
442 char* line,source[512],*pos,*s_start,*s_end,*src_line; |
12097
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
443 play_tree_t *list = NULL, *entry = NULL, *last_entry = NULL; |
22242
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
444 int is_rmsmil = 0; |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
445 unsigned int npkt, ttlpkt; |
12097
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
446 |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
447 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
|
448 |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
449 // Check if smil |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
450 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
|
451 strstrip(line); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
452 if(line[0] == '\0') // Ignore empties |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
453 continue; |
22518
29a3bb75db47
Support smil embedded into xml, fixes bugzilla #768
rtogni
parents:
22477
diff
changeset
|
454 if (strncasecmp(line,"<?xml",5)==0) // smil in xml |
29a3bb75db47
Support smil embedded into xml, fixes bugzilla #768
rtogni
parents:
22477
diff
changeset
|
455 continue; |
28314 | 456 if (strncasecmp(line,"<!DOCTYPE smil",13)==0) // smil in xml |
457 continue; | |
22242
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
458 if (strncasecmp(line,"<smil",5)==0 || strncasecmp(line,"<?wpl",5)==0 || |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
459 strncasecmp(line,"(smil-document",14)==0) |
12097
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
460 break; // smil header found |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
461 else |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
462 return NULL; //line not smil exit |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
463 } |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
464 |
24962
fb50e37df836
Fix possible null-pointer-dereference in parse_smil().
cehoyos
parents:
24424
diff
changeset
|
465 if (!line) return NULL; |
12097
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
466 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
|
467 play_tree_parser_stop_keeping(p); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
468 |
22242
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
469 if (strncasecmp(line,"(smil-document",14)==0) { |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
470 mp_msg(MSGT_PLAYTREE,MSGL_V,"Special smil-over-realrtsp playlist header\n"); |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
471 is_rmsmil = 1; |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
472 if (sscanf(line, "(smil-document (ver 1.0)(npkt %u)(ttlpkt %u", &npkt, &ttlpkt) != 2) { |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
473 mp_msg(MSGT_PLAYTREE,MSGL_WARN,"smil-over-realrtsp: header parsing failure, assuming single packet.\n"); |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
474 npkt = ttlpkt = 1; |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
475 } |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
476 if (ttlpkt == 0 || npkt > ttlpkt) { |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
477 mp_msg(MSGT_PLAYTREE,MSGL_WARN,"smil-over-realrtsp: bad packet counters (npkk = %u, ttlpkt = %u), assuming single packet.\n", |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
478 npkt, ttlpkt); |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
479 npkt = ttlpkt = 1; |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
480 } |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
481 } |
12097
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
482 |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
483 //Get entries from smil |
22712
c7eee1ecbe8c
Support multiple tags in a single line and tags on the same line as the
rtogni
parents:
22520
diff
changeset
|
484 src_line = line; |
22242
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
485 line = NULL; |
22712
c7eee1ecbe8c
Support multiple tags in a single line and tags on the same line as the
rtogni
parents:
22520
diff
changeset
|
486 do { |
22242
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
487 strstrip(src_line); |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
488 if (line) { |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
489 free(line); |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
490 line = NULL; |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
491 } |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
492 /* If we're parsing smil over realrtsp and this is not the last packet and |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
493 * this is the last line in the packet (terminating with ") ) we must get |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
494 * the next line, strip the header, and concatenate it to the current line. |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
495 */ |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
496 if (is_rmsmil && npkt != ttlpkt && strstr(src_line,"\")")) { |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
497 char *payload; |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
498 |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
499 line = strdup(src_line); |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
500 if(!(src_line = play_tree_parser_get_line(p))) { |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
501 mp_msg(MSGT_PLAYTREE,MSGL_WARN,"smil-over-realrtsp: can't get line from packet %u/%u.\n", npkt, ttlpkt); |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
502 break; |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
503 } |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
504 strstrip(src_line); |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
505 // Skip header, packet starts after " |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
506 if(!(payload = strchr(src_line,'\"'))) { |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
507 mp_msg(MSGT_PLAYTREE,MSGL_WARN,"smil-over-realrtsp: can't find start of packet, using complete line.\n"); |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
508 payload = src_line; |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
509 } else |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
510 payload++; |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
511 // Skip ") at the end of the last line from the current packet |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
512 line[strlen(line)-2] = 0; |
22477 | 513 line = realloc(line, strlen(line)+strlen(payload)+1); |
22242
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
514 strcat (line, payload); |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
515 npkt++; |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
516 } else |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
517 line = strdup(src_line); |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
518 /* Unescape \" to " for smil-over-rtsp */ |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
519 if (is_rmsmil && line[0] != '\0') { |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
520 int i, j; |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
521 |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
522 for (i = 0; i < strlen(line); i++) |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
523 if (line[i] == '\\' && line[i+1] == '"') |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
524 for (j = i; line[j]; j++) |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
525 line[j] = line[j+1]; |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
526 } |
22712
c7eee1ecbe8c
Support multiple tags in a single line and tags on the same line as the
rtogni
parents:
22520
diff
changeset
|
527 pos = line; |
c7eee1ecbe8c
Support multiple tags in a single line and tags on the same line as the
rtogni
parents:
22520
diff
changeset
|
528 while (pos) { |
12097
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
529 if (!entrymode) { // all entries filled so far |
24424 | 530 while ((pos=strchr(pos, '<'))) { |
22712
c7eee1ecbe8c
Support multiple tags in a single line and tags on the same line as the
rtogni
parents:
22520
diff
changeset
|
531 if (strncasecmp(pos,"<video",6)==0 || strncasecmp(pos,"<audio",6)==0 || strncasecmp(pos,"<media",6)==0) { |
12097
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
532 entrymode=1; |
22712
c7eee1ecbe8c
Support multiple tags in a single line and tags on the same line as the
rtogni
parents:
22520
diff
changeset
|
533 break; // Got a valid tag, exit '<' search loop |
12097
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
534 } |
22712
c7eee1ecbe8c
Support multiple tags in a single line and tags on the same line as the
rtogni
parents:
22520
diff
changeset
|
535 pos++; |
c7eee1ecbe8c
Support multiple tags in a single line and tags on the same line as the
rtogni
parents:
22520
diff
changeset
|
536 } |
22520 | 537 } |
538 if (entrymode) { //Entry found but not yet filled | |
22712
c7eee1ecbe8c
Support multiple tags in a single line and tags on the same line as the
rtogni
parents:
22520
diff
changeset
|
539 pos = strstr(pos,"src="); // Is source present on this line |
12097
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
540 if (pos != NULL) { |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
541 entrymode=0; |
23774
16a67232e916
realrtsp smil files can also use ' as field delimiter instead of "
rtogni
parents:
22712
diff
changeset
|
542 if (pos[4] != '"' && pos[4] != '\'') { |
16a67232e916
realrtsp smil files can also use ' as field delimiter instead of "
rtogni
parents:
22712
diff
changeset
|
543 mp_msg(MSGT_PLAYTREE,MSGL_V,"Unknown delimiter %c in source line %s\n", pos[4], line); |
16a67232e916
realrtsp smil files can also use ' as field delimiter instead of "
rtogni
parents:
22712
diff
changeset
|
544 break; |
16a67232e916
realrtsp smil files can also use ' as field delimiter instead of "
rtogni
parents:
22712
diff
changeset
|
545 } |
12097
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
546 s_start=pos+5; |
23774
16a67232e916
realrtsp smil files can also use ' as field delimiter instead of "
rtogni
parents:
22712
diff
changeset
|
547 s_end=strchr(s_start,pos[4]); |
12097
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
548 if (s_end == NULL) { |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
549 mp_msg(MSGT_PLAYTREE,MSGL_V,"Error parsing this source line %s\n",line); |
22712
c7eee1ecbe8c
Support multiple tags in a single line and tags on the same line as the
rtogni
parents:
22520
diff
changeset
|
550 break; |
12097
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
551 } |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
552 if (s_end-s_start> 511) { |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
553 mp_msg(MSGT_PLAYTREE,MSGL_V,"Cannot store such a large source %s\n",line); |
22712
c7eee1ecbe8c
Support multiple tags in a single line and tags on the same line as the
rtogni
parents:
22520
diff
changeset
|
554 break; |
12097
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
555 } |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
556 strncpy(source,s_start,s_end-s_start); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
557 source[(s_end-s_start)]='\0'; // Null terminate |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
558 entry = play_tree_new(); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
559 play_tree_add_file(entry,source); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
560 if(!list) //Insert new entry |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
561 list = entry; |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
562 else |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
563 play_tree_append_entry(last_entry,entry); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
564 last_entry = entry; |
22712
c7eee1ecbe8c
Support multiple tags in a single line and tags on the same line as the
rtogni
parents:
22520
diff
changeset
|
565 pos = s_end; |
12097
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 } |
22712
c7eee1ecbe8c
Support multiple tags in a single line and tags on the same line as the
rtogni
parents:
22520
diff
changeset
|
568 } |
c7eee1ecbe8c
Support multiple tags in a single line and tags on the same line as the
rtogni
parents:
22520
diff
changeset
|
569 } while((src_line = play_tree_parser_get_line(p)) != NULL); |
12097
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
570 |
22242
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
571 if (line) |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
572 free(line); |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
573 |
12097
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
574 if(!list) return NULL; // Nothing found |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
575 |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
576 entry = play_tree_new(); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
577 play_tree_set_child(entry,list); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
578 return entry; |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
579 } |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
580 |
18916
a95ed361d16b
several function from playtreeparser.c maked static,
reynaldo
parents:
18879
diff
changeset
|
581 static play_tree_t* |
12097
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
582 embedded_playlist_parse(char *line) { |
12223 | 583 int f=DEMUXER_TYPE_PLAYLIST; |
12097
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
584 stream_t* stream; |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
585 play_tree_parser_t* ptp; |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
586 play_tree_t* entry; |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
587 |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
588 // Get stream opened to link |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
589 stream=open_stream(line,0,&f); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
590 if(!stream) { |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
591 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
|
592 return NULL; |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
593 } |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
594 |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
595 //add new playtree |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
596 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
|
597 |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
598 ptp = play_tree_parser_new(stream,1); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
599 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
|
600 play_tree_parser_free(ptp); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
601 free_stream(stream); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
602 |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
603 return entry; |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
604 } |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
605 |
18916
a95ed361d16b
several function from playtreeparser.c maked static,
reynaldo
parents:
18879
diff
changeset
|
606 static play_tree_t* |
4308
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
607 parse_textplain(play_tree_parser_t* p) { |
4782 | 608 char* line; |
12300
95ea9f5f6f14
Fix embedded smil playlist detection if there are parameters on the url
rtognimp
parents:
12223
diff
changeset
|
609 char *c; |
95ea9f5f6f14
Fix embedded smil playlist detection if there are parameters on the url
rtognimp
parents:
12223
diff
changeset
|
610 int embedded; |
9789
45173e0d34cc
Fix the incredible slowness with very long list. Now a 10^6 entries
albeu
parents:
9749
diff
changeset
|
611 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
|
612 |
6661
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
613 mp_msg(MSGT_PLAYTREE,MSGL_V,"Trying plaintext playlist...\n"); |
4782 | 614 play_tree_parser_stop_keeping(p); |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
615 |
4782 | 616 while((line = play_tree_parser_get_line(p)) != NULL) { |
617 strstrip(line); | |
12689
050c90536ddd
Support for comments in plaintext playlist by adland
alex
parents:
12538
diff
changeset
|
618 if(line[0] == '\0' || line[0] == '#' || (line[0] == '/' && line[1] == '/')) |
4782 | 619 continue; |
12097
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
620 |
12538
2beafad68f68
Enhance detection of embedded smil playlist, add embedded ram playlist
rtognimp
parents:
12300
diff
changeset
|
621 //Special check for embedded smil or ram reference in file |
12300
95ea9f5f6f14
Fix embedded smil playlist detection if there are parameters on the url
rtognimp
parents:
12223
diff
changeset
|
622 embedded = 0; |
95ea9f5f6f14
Fix embedded smil playlist detection if there are parameters on the url
rtognimp
parents:
12223
diff
changeset
|
623 if (strlen(line) > 5) |
95ea9f5f6f14
Fix embedded smil playlist detection if there are parameters on the url
rtognimp
parents:
12223
diff
changeset
|
624 for(c = line; c[0]; c++ ) |
12538
2beafad68f68
Enhance detection of embedded smil playlist, add embedded ram playlist
rtognimp
parents:
12300
diff
changeset
|
625 if ( ((c[0] == '.') && //start with . and next have smil with optional ? or & |
2beafad68f68
Enhance detection of embedded smil playlist, add embedded ram playlist
rtognimp
parents:
12300
diff
changeset
|
626 (tolower(c[1]) == 's') && (tolower(c[2])== 'm') && |
12300
95ea9f5f6f14
Fix embedded smil playlist detection if there are parameters on the url
rtognimp
parents:
12223
diff
changeset
|
627 (tolower(c[3]) == 'i') && (tolower(c[4]) == 'l') && |
12538
2beafad68f68
Enhance detection of embedded smil playlist, add embedded ram playlist
rtognimp
parents:
12300
diff
changeset
|
628 (!c[5] || c[5] == '?' || c[5] == '&')) || // or |
2beafad68f68
Enhance detection of embedded smil playlist, add embedded ram playlist
rtognimp
parents:
12300
diff
changeset
|
629 ((c[0] == '.') && // start with . and next have smi or ram with optional ? or & |
2beafad68f68
Enhance detection of embedded smil playlist, add embedded ram playlist
rtognimp
parents:
12300
diff
changeset
|
630 ( ((tolower(c[1]) == 's') && (tolower(c[2])== 'm') && (tolower(c[3]) == 'i')) || |
2beafad68f68
Enhance detection of embedded smil playlist, add embedded ram playlist
rtognimp
parents:
12300
diff
changeset
|
631 ((tolower(c[1]) == 'r') && (tolower(c[2])== 'a') && (tolower(c[3]) == 'm')) ) |
2beafad68f68
Enhance detection of embedded smil playlist, add embedded ram playlist
rtognimp
parents:
12300
diff
changeset
|
632 && (!c[4] || c[4] == '?' || c[4] == '&')) ){ |
12300
95ea9f5f6f14
Fix embedded smil playlist detection if there are parameters on the url
rtognimp
parents:
12223
diff
changeset
|
633 entry=embedded_playlist_parse(line); |
95ea9f5f6f14
Fix embedded smil playlist detection if there are parameters on the url
rtognimp
parents:
12223
diff
changeset
|
634 embedded = 1; |
95ea9f5f6f14
Fix embedded smil playlist detection if there are parameters on the url
rtognimp
parents:
12223
diff
changeset
|
635 break; |
95ea9f5f6f14
Fix embedded smil playlist detection if there are parameters on the url
rtognimp
parents:
12223
diff
changeset
|
636 } |
95ea9f5f6f14
Fix embedded smil playlist detection if there are parameters on the url
rtognimp
parents:
12223
diff
changeset
|
637 |
95ea9f5f6f14
Fix embedded smil playlist detection if there are parameters on the url
rtognimp
parents:
12223
diff
changeset
|
638 if (!embedded) { //regular file link |
12097
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
639 entry = play_tree_new(); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
640 play_tree_add_file(entry,line); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
641 } |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
642 |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
643 if (entry != NULL) { |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
644 if(!list) |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
645 list = entry; |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
646 else |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
647 play_tree_append_entry(last_entry,entry); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
648 last_entry = entry; |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
649 } |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
650 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
651 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
652 if(!list) return NULL; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
653 entry = play_tree_new(); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
654 play_tree_set_child(entry,list); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
655 return entry; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
656 } |
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 play_tree_t* |
8925
5c15777f1c07
this patch adds an fallback to playlist (any but the plaintext-list format)
arpi
parents:
8907
diff
changeset
|
659 parse_playtree(stream_t *stream, int forced) { |
4308
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
660 play_tree_parser_t* p; |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
661 play_tree_t* ret; |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
662 |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4043
diff
changeset
|
663 #ifdef MP_DEBUG |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
664 assert(stream != NULL); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
665 #endif |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
666 |
4308
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
667 p = play_tree_parser_new(stream,0); |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
668 if(!p) |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
669 return NULL; |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
670 |
8925
5c15777f1c07
this patch adds an fallback to playlist (any but the plaintext-list format)
arpi
parents:
8907
diff
changeset
|
671 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
|
672 play_tree_parser_free(p); |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
673 |
4308
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
674 return ret; |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
675 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
676 |
6662
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
677 static void |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
678 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
|
679 int i,bl = strlen(bp),fl; |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
680 |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
681 if(pt->child) { |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
682 play_tree_t* i; |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
683 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
|
684 play_tree_add_basepath(i,bp); |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
685 return; |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
686 } |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
687 |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
688 if(!pt->files) |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
689 return; |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
690 |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
691 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
|
692 fl = strlen(pt->files[i]); |
13305
90ffe76b5b25
Don't prepend basepath to a full unix path. ( 10l to Joey. )
al
parents:
13010
diff
changeset
|
693 // if we find a full unix path, url:// or X:\ at the beginning, |
90ffe76b5b25
Don't prepend basepath to a full unix path. ( 10l to Joey. )
al
parents:
13010
diff
changeset
|
694 // don't mangle it. |
90ffe76b5b25
Don't prepend basepath to a full unix path. ( 10l to Joey. )
al
parents:
13010
diff
changeset
|
695 if(fl <= 0 || strstr(pt->files[i],"://") || (strstr(pt->files[i],":\\") == pt->files[i] + 1) || (pt->files[i][0] == '/') ) |
6662
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
696 continue; |
13010 | 697 // if the path begins with \ then prepend drive letter to it. |
698 if (pt->files[i][0] == '\\') { | |
18928
586777f09b1b
relative-to-absolute path fixes: Do not prepend drive letter to \\ paths.
reimar
parents:
18916
diff
changeset
|
699 if (pt->files[i][1] == '\\') |
586777f09b1b
relative-to-absolute path fixes: Do not prepend drive letter to \\ paths.
reimar
parents:
18916
diff
changeset
|
700 continue; |
13010 | 701 pt->files[i] = (char*)realloc(pt->files[i],2+fl+1); |
702 memmove(pt->files[i] + 2,pt->files[i],fl+1); | |
703 memcpy(pt->files[i],bp,2); | |
18928
586777f09b1b
relative-to-absolute path fixes: Do not prepend drive letter to \\ paths.
reimar
parents:
18916
diff
changeset
|
704 continue; |
13010 | 705 } |
6662
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
706 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
|
707 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
|
708 memcpy(pt->files[i],bp,bl); |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
709 } |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
710 } |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
711 |
9301
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
712 // 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
|
713 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
|
714 { |
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
715 char *ls, *file; |
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
716 |
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
717 if (pt && filename) |
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
718 { |
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
719 file = strdup(filename); |
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
720 if (file) |
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
721 { |
13010 | 722 ls = strrchr(file,'/'); |
723 if(!ls) ls = strrchr(file,'\\'); | |
9301
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
724 if(ls) { |
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
725 ls[1] = '\0'; |
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
726 play_tree_add_basepath(pt,file); |
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
727 } |
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
728 free(file); |
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
729 } |
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
730 } |
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
731 } |
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
732 |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
733 play_tree_t* |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
734 parse_playlist_file(char* file) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
735 stream_t *stream; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
736 play_tree_t* ret; |
12223 | 737 int f=DEMUXER_TYPE_PLAYLIST; |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
738 |
9749 | 739 stream = open_stream(file,0,&f); |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
740 |
9749 | 741 if(!stream) { |
10487 | 742 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
|
743 return NULL; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
744 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
745 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
746 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
|
747 |
8925
5c15777f1c07
this patch adds an fallback to playlist (any but the plaintext-list format)
arpi
parents:
8907
diff
changeset
|
748 ret = parse_playtree(stream,1); |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
749 free_stream(stream); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
750 |
9301
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
751 play_tree_add_bpf(ret, file); |
6662
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
752 |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
753 return ret; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
754 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
755 } |
4308
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
756 |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
757 |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
758 play_tree_parser_t* |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
759 play_tree_parser_new(stream_t* stream,int deep) { |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
760 play_tree_parser_t* p; |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
761 |
18879 | 762 p = calloc(1,sizeof(play_tree_parser_t)); |
4308
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
763 if(!p) |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
764 return NULL; |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
765 p->stream = stream; |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
766 p->deep = deep; |
4782 | 767 p->keep = 1; |
4308
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
768 |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
769 return p; |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
770 |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
771 } |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
772 |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
773 void |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
774 play_tree_parser_free(play_tree_parser_t* p) { |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
775 |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
776 #ifdef MP_DEBUG |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
777 assert(p != NULL); |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
778 #endif |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
779 |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
780 if(p->buffer) free(p->buffer); |
4782 | 781 if(p->line) free(p->line); |
782 free(p); | |
4308
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
783 } |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
784 |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
785 play_tree_t* |
8925
5c15777f1c07
this patch adds an fallback to playlist (any but the plaintext-list format)
arpi
parents:
8907
diff
changeset
|
786 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
|
787 play_tree_t* tree = NULL; |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
788 |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
789 #ifdef MP_DEBUG |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
790 assert(p != NULL); |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
791 #endif |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
792 |
4782 | 793 |
794 while(play_tree_parser_get_line(p) != NULL) { | |
795 play_tree_parser_reset(p); | |
796 | |
4308
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
797 tree = parse_asx(p); |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
798 if(tree) break; |
4782 | 799 play_tree_parser_reset(p); |
800 | |
801 tree = parse_pls(p); | |
802 if(tree) break; | |
803 play_tree_parser_reset(p); | |
804 | |
6661
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
805 tree = parse_m3u(p); |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
806 if(tree) break; |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
807 play_tree_parser_reset(p); |
8897
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
808 |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
809 tree = parse_ref_ini(p); |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
810 if(tree) break; |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
811 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
|
812 |
12097
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
813 tree = parse_smil(p); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
814 if(tree) break; |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
815 play_tree_parser_reset(p); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
816 |
4308
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
817 // 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
|
818 if (forced) |
5c15777f1c07
this patch adds an fallback to playlist (any but the plaintext-list format)
arpi
parents:
8907
diff
changeset
|
819 { |
5c15777f1c07
this patch adds an fallback to playlist (any but the plaintext-list format)
arpi
parents:
8907
diff
changeset
|
820 tree = parse_textplain(p); |
5c15777f1c07
this patch adds an fallback to playlist (any but the plaintext-list format)
arpi
parents:
8907
diff
changeset
|
821 if(tree) break; |
5c15777f1c07
this patch adds an fallback to playlist (any but the plaintext-list format)
arpi
parents:
8907
diff
changeset
|
822 } |
4308
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
823 break; |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
824 } |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
825 |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
826 if(tree) |
10487 | 827 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
|
828 else |
5c15777f1c07
this patch adds an fallback to playlist (any but the plaintext-list format)
arpi
parents:
8907
diff
changeset
|
829 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
|
830 |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
831 if(tree) |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
832 tree = play_tree_cleanup(tree); |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
833 |
10487 | 834 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
|
835 |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
836 return tree; |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
837 } |