Mercurial > mplayer.hg
annotate playtreeparser.c @ 36272:aa0011dfbfdc
Use again special value -1 to set original aspect ratio.
With -1, the switch_ratio command does exactly the calculation
being performed here.
This reverts changes in setting the value for the aspect ratio
made in r36358 and r36360.
author | ib |
---|---|
date | Sat, 27 Jul 2013 22:25:57 +0000 |
parents | 389d43c448b3 |
children | 20cf5874f85a |
rev | line source |
---|---|
30429
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
29263
diff
changeset
|
1 /* |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
29263
diff
changeset
|
2 * This file is part of MPlayer. |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
29263
diff
changeset
|
3 * |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
29263
diff
changeset
|
4 * MPlayer is free software; you can redistribute it and/or modify |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
29263
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
29263
diff
changeset
|
6 * the Free Software Foundation; either version 2 of the License, or |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
29263
diff
changeset
|
7 * (at your option) any later version. |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
29263
diff
changeset
|
8 * |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
29263
diff
changeset
|
9 * MPlayer is distributed in the hope that it will be useful, |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
29263
diff
changeset
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
29263
diff
changeset
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
29263
diff
changeset
|
12 * GNU General Public License for more details. |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
29263
diff
changeset
|
13 * |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
29263
diff
changeset
|
14 * You should have received a copy of the GNU General Public License along |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
29263
diff
changeset
|
15 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
29263
diff
changeset
|
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
29263
diff
changeset
|
17 */ |
18265 | 18 |
19 /// \file | |
20 /// \ingroup PlaytreeParser | |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
21 |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4043
diff
changeset
|
22 #include "config.h" |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
23 #include <stdlib.h> |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
24 #include <stdio.h> |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
25 #include <string.h> |
35903 | 26 #include <strings.h> |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
27 #include <assert.h> |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
28 #include <errno.h> |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
29 #include <sys/types.h> |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
30 #include <sys/stat.h> |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
31 #include <fcntl.h> |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
32 #include <unistd.h> |
12300
95ea9f5f6f14
Fix embedded smil playlist detection if there are parameters on the url
rtognimp
parents:
12223
diff
changeset
|
33 #include <ctype.h> |
30749
88cd611f49dd
Improve integer overflow and realloc error handling in playlist parser.
reimar
parents:
30702
diff
changeset
|
34 #include <limits.h> |
30632
dad8e0eb182a
Add asx_parser_build_tree() to asxparser.h instead of forward declaring it.
diego
parents:
30429
diff
changeset
|
35 #include "asxparser.h" |
9749 | 36 #include "m_config.h" |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
37 #include "playtree.h" |
4308
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
38 #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
|
39 #include "stream/stream.h" |
12223 | 40 #include "libmpdemux/demuxer.h" |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
41 #include "mp_msg.h" |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
42 |
6662
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
43 |
4782 | 44 #define BUF_STEP 1024 |
45 | |
46 #define WHITES " \n\r\t" | |
47 | |
48 static void | |
49 strstrip(char* str) { | |
50 char* i; | |
51 | |
8907 | 52 if (str==NULL) |
53 return; | |
4782 | 54 for(i = str ; i[0] != '\0' && strchr(WHITES,i[0]) != NULL; i++) |
55 /* NOTHING */; | |
56 if(i[0] != '\0') { | |
8907 | 57 memmove(str,i,strlen(i) + 1); |
58 for(i = str + strlen(str) - 1 ; strchr(WHITES,i[0]) != NULL; i--) | |
4782 | 59 /* NOTHING */; |
60 i[1] = '\0'; | |
61 } else | |
62 str[0] = '\0'; | |
63 } | |
64 | |
65 static char* | |
66 play_tree_parser_get_line(play_tree_parser_t* p) { | |
67 char *end,*line_end; | |
68 int r,resize = 0; | |
69 | |
70 if(p->buffer == NULL) { | |
18869 | 71 p->buffer = malloc(BUF_STEP); |
4782 | 72 p->buffer_size = BUF_STEP; |
28183 | 73 p->buffer[0] = 0; |
4782 | 74 p->iter = p->buffer; |
75 } | |
76 | |
5802 | 77 if(p->stream->eof && (p->buffer_end == 0 || p->iter[0] == '\0')) |
4782 | 78 return NULL; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28314
diff
changeset
|
79 |
28182
26ab2d01157f
Add asserts to detect when assumptions for play_tree_parser_get_line
reimar
parents:
25141
diff
changeset
|
80 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
|
81 assert(!p->buffer[p->buffer_end]); |
4782 | 82 while(1) { |
83 | |
84 if(resize) { | |
30749
88cd611f49dd
Improve integer overflow and realloc error handling in playlist parser.
reimar
parents:
30702
diff
changeset
|
85 char *tmp; |
4782 | 86 r = p->iter - p->buffer; |
30749
88cd611f49dd
Improve integer overflow and realloc error handling in playlist parser.
reimar
parents:
30702
diff
changeset
|
87 end = p->buffer + p->buffer_end; |
88cd611f49dd
Improve integer overflow and realloc error handling in playlist parser.
reimar
parents:
30702
diff
changeset
|
88 if (p->buffer_size > INT_MAX - BUF_STEP) |
88cd611f49dd
Improve integer overflow and realloc error handling in playlist parser.
reimar
parents:
30702
diff
changeset
|
89 break; |
88cd611f49dd
Improve integer overflow and realloc error handling in playlist parser.
reimar
parents:
30702
diff
changeset
|
90 tmp = realloc(p->buffer, p->buffer_size + BUF_STEP); |
88cd611f49dd
Improve integer overflow and realloc error handling in playlist parser.
reimar
parents:
30702
diff
changeset
|
91 if (!tmp) |
88cd611f49dd
Improve integer overflow and realloc error handling in playlist parser.
reimar
parents:
30702
diff
changeset
|
92 break; |
88cd611f49dd
Improve integer overflow and realloc error handling in playlist parser.
reimar
parents:
30702
diff
changeset
|
93 p->buffer = tmp; |
4782 | 94 p->iter = p->buffer + r; |
95 p->buffer_size += BUF_STEP; | |
96 resize = 0; | |
97 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28314
diff
changeset
|
98 |
4782 | 99 if(p->buffer_size - p->buffer_end > 1 && ! p->stream->eof) { |
100 r = stream_read(p->stream,p->buffer + p->buffer_end,p->buffer_size - p->buffer_end - 1); | |
101 if(r > 0) { | |
102 p->buffer_end += r; | |
28182
26ab2d01157f
Add asserts to detect when assumptions for play_tree_parser_get_line
reimar
parents:
25141
diff
changeset
|
103 assert(p->buffer_end < p->buffer_size); |
4782 | 104 p->buffer[p->buffer_end] = '\0'; |
22242
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
105 while(strlen(p->buffer + p->buffer_end - r) != r) |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
106 p->buffer[p->buffer_end - r + strlen(p->buffer + p->buffer_end - r)] = '\n'; |
4782 | 107 } |
28182
26ab2d01157f
Add asserts to detect when assumptions for play_tree_parser_get_line
reimar
parents:
25141
diff
changeset
|
108 assert(!p->buffer[p->buffer_end]); |
4782 | 109 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28314
diff
changeset
|
110 |
4782 | 111 end = strchr(p->iter,'\n'); |
112 if(!end) { | |
113 if(p->stream->eof) { | |
4857 | 114 end = p->buffer + p->buffer_end; |
4782 | 115 break; |
116 } | |
117 resize = 1; | |
118 continue; | |
119 } | |
120 break; | |
121 } | |
122 | |
25141
fba022abe464
100l in play_tree_parser_get_line, check that there actually is
reimar
parents:
24962
diff
changeset
|
123 line_end = (end > p->iter && *(end-1) == '\r') ? end-1 : end; |
5802 | 124 if(line_end - p->iter >= 0) |
30702 | 125 p->line = realloc(p->line, line_end - p->iter + 1); |
5802 | 126 else |
4782 | 127 return NULL; |
5802 | 128 if(line_end - p->iter > 0) |
129 strncpy(p->line,p->iter,line_end - p->iter); | |
4782 | 130 p->line[line_end - p->iter] = '\0'; |
5802 | 131 if(end[0] != '\0') |
4857 | 132 end++; |
4782 | 133 |
134 if(!p->keep) { | |
4857 | 135 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
|
136 p->buffer_end -= end-p->iter; |
4782 | 137 memmove(p->buffer,end,p->buffer_end); |
138 } else | |
139 p->buffer_end = 0; | |
28183 | 140 p->buffer[p->buffer_end] = '\0'; |
4782 | 141 p->iter = p->buffer; |
142 } else | |
143 p->iter = end; | |
144 | |
145 return p->line; | |
146 } | |
147 | |
148 static void | |
149 play_tree_parser_reset(play_tree_parser_t* p) { | |
150 p->iter = p->buffer; | |
151 } | |
152 | |
153 static void | |
154 play_tree_parser_stop_keeping(play_tree_parser_t* p) { | |
155 p->keep = 0; | |
156 if(p->iter && p->iter != p->buffer) { | |
157 p->buffer_end -= p->iter -p->buffer; | |
158 if(p->buffer_end) | |
159 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
|
160 p->buffer[p->buffer_end] = 0; |
4782 | 161 p->iter = p->buffer; |
162 } | |
163 } | |
164 | |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
165 |
18916
a95ed361d16b
several function from playtreeparser.c maked static,
reynaldo
parents:
18879
diff
changeset
|
166 static play_tree_t* |
4308
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
167 parse_asx(play_tree_parser_t* p) { |
4782 | 168 int comments = 0,get_line = 1; |
169 char* line = NULL; | |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
170 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
171 mp_msg(MSGT_PLAYTREE,MSGL_V,"Trying asx...\n"); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28314
diff
changeset
|
172 |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
173 while(1) { |
4782 | 174 if(get_line) { |
175 line = play_tree_parser_get_line(p); | |
176 if(!line) | |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
177 return NULL; |
4782 | 178 strstrip(line); |
179 if(line[0] == '\0') | |
180 continue; | |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
181 } |
4782 | 182 if(!comments) { |
183 if(line[0] != '<') { | |
184 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
|
185 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
|
186 return NULL; |
4782 | 187 } else if(strncmp(line,"<!--",4) == 0) { // Comments |
188 comments = 1; | |
189 line += 4; | |
190 if(line[0] != '\0' && strlen(line) > 0) | |
191 get_line = 0; | |
192 } else if(strncasecmp(line,"<ASX",4) == 0) // We got an asx element | |
193 break; | |
194 else // We don't get an asx | |
195 return NULL; | |
196 } else { // Comments | |
197 char* c; | |
198 c = strchr(line,'-'); | |
199 if(c) { | |
200 if (strncmp(c,"--!>",4) == 0) { // End of comments | |
201 comments = 0; | |
202 line = c+4; | |
203 if(line[0] != '\0') // There is some more data on this line : keep it | |
204 get_line = 0; | |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
205 |
4782 | 206 } else { |
207 line = c+1; // Jump the - | |
208 if(line[0] != '\0') // Some more data | |
209 get_line = 0; | |
210 else // End of line | |
211 get_line = 1; | |
212 } | |
213 } else // No - on this line (or rest of line) : get next one | |
214 get_line = 1; | |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
215 } |
4782 | 216 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28314
diff
changeset
|
217 |
4782 | 218 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
|
219 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
220 // 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
|
221 |
4782 | 222 while((line = play_tree_parser_get_line(p)) != NULL) |
223 /* NOTHING */; | |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
224 |
10487 | 225 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
|
226 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
|
227 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
228 |
4782 | 229 static char* |
230 pls_entry_get_value(char* line) { | |
231 char* i; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28314
diff
changeset
|
232 |
4782 | 233 i = strchr(line,'='); |
234 if(!i || i[1] == '\0') | |
235 return NULL; | |
236 else | |
237 return i+1; | |
238 } | |
239 | |
240 typedef struct pls_entry { | |
241 char* file; | |
242 char* title; | |
243 char* length; | |
244 } pls_entry_t; | |
245 | |
246 static int | |
247 pls_read_entry(char* line,pls_entry_t** _e,int* _max_entry,char** val) { | |
248 int num,max_entry = (*_max_entry); | |
249 pls_entry_t* e = (*_e); | |
30749
88cd611f49dd
Improve integer overflow and realloc error handling in playlist parser.
reimar
parents:
30702
diff
changeset
|
250 int limit = INT_MAX / sizeof(*e); |
4782 | 251 char* v; |
252 | |
253 v = pls_entry_get_value(line); | |
254 if(!v) { | |
255 mp_msg(MSGT_PLAYTREE,MSGL_ERR,"No value in entry %s\n",line); | |
30751
a375d947381b
Use negative return values for errors in pls_read_entry to make it match
reimar
parents:
30750
diff
changeset
|
256 return -1; |
4782 | 257 } |
258 | |
259 num = atoi(line); | |
30750
b9ec8956164f
A playlist entry number of 0 is invalid for pls playlists.
reimar
parents:
30749
diff
changeset
|
260 if(num <= 0 || num > limit) { |
30749
88cd611f49dd
Improve integer overflow and realloc error handling in playlist parser.
reimar
parents:
30702
diff
changeset
|
261 if (max_entry >= limit) { |
88cd611f49dd
Improve integer overflow and realloc error handling in playlist parser.
reimar
parents:
30702
diff
changeset
|
262 mp_msg(MSGT_PLAYTREE, MSGL_WARN, "Too many index entries\n"); |
30751
a375d947381b
Use negative return values for errors in pls_read_entry to make it match
reimar
parents:
30750
diff
changeset
|
263 return -1; |
30749
88cd611f49dd
Improve integer overflow and realloc error handling in playlist parser.
reimar
parents:
30702
diff
changeset
|
264 } |
4782 | 265 num = max_entry+1; |
30749
88cd611f49dd
Improve integer overflow and realloc error handling in playlist parser.
reimar
parents:
30702
diff
changeset
|
266 mp_msg(MSGT_PLAYTREE,MSGL_WARN,"No or invalid entry index in entry %s\nAssuming %d\n",line,num); |
4782 | 267 } |
268 if(num > max_entry) { | |
30702 | 269 e = realloc(e, num * sizeof(pls_entry_t)); |
30749
88cd611f49dd
Improve integer overflow and realloc error handling in playlist parser.
reimar
parents:
30702
diff
changeset
|
270 if (!e) |
30751
a375d947381b
Use negative return values for errors in pls_read_entry to make it match
reimar
parents:
30750
diff
changeset
|
271 return -1; |
4782 | 272 memset(&e[max_entry],0,(num-max_entry)*sizeof(pls_entry_t)); |
273 max_entry = num; | |
274 } | |
275 (*_e) = e; | |
276 (*_max_entry) = max_entry; | |
277 (*val) = v; | |
278 | |
279 return num; | |
280 } | |
281 | |
282 | |
18916
a95ed361d16b
several function from playtreeparser.c maked static,
reynaldo
parents:
18879
diff
changeset
|
283 static play_tree_t* |
4782 | 284 parse_pls(play_tree_parser_t* p) { |
285 char *line,*v; | |
286 pls_entry_t* entries = NULL; | |
287 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
|
288 play_tree_t *list = NULL, *entry = NULL, *last_entry = NULL; |
4782 | 289 |
10487 | 290 mp_msg(MSGT_PLAYTREE,MSGL_V,"Trying Winamp playlist...\n"); |
20834 | 291 while((line = play_tree_parser_get_line(p))) { |
292 strstrip(line); | |
293 if(strlen(line)) | |
294 break; | |
295 } | |
296 if (!line) | |
8925
5c15777f1c07
this patch adds an fallback to playlist (any but the plaintext-list format)
arpi
parents:
8907
diff
changeset
|
297 return NULL; |
4782 | 298 if(strcasecmp(line,"[playlist]")) |
299 return NULL; | |
10487 | 300 mp_msg(MSGT_PLAYTREE,MSGL_V,"Detected Winamp playlist format\n"); |
4782 | 301 play_tree_parser_stop_keeping(p); |
302 line = play_tree_parser_get_line(p); | |
303 if(!line) | |
304 return NULL; | |
305 strstrip(line); | |
306 if(strncasecmp(line,"NumberOfEntries",15) == 0) { | |
307 v = pls_entry_get_value(line); | |
308 n_entries = atoi(v); | |
309 if(n_entries < 0) | |
10487 | 310 mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"Invalid number of entries: very funny!!!\n"); |
4782 | 311 else |
10487 | 312 mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"Playlist claims to have %d entries. Let's see.\n",n_entries); |
4782 | 313 line = play_tree_parser_get_line(p); |
314 } | |
315 | |
316 while(line) { | |
317 strstrip(line); | |
318 if(line[0] == '\0') { | |
319 line = play_tree_parser_get_line(p); | |
320 continue; | |
321 } | |
322 if(strncasecmp(line,"File",4) == 0) { | |
323 num = pls_read_entry(line+4,&entries,&max_entry,&v); | |
324 if(num < 0) | |
325 mp_msg(MSGT_PLAYTREE,MSGL_ERR,"No value in entry %s\n",line); | |
326 else | |
327 entries[num-1].file = strdup(v); | |
328 } else if(strncasecmp(line,"Title",5) == 0) { | |
329 num = pls_read_entry(line+5,&entries,&max_entry,&v); | |
330 if(num < 0) | |
331 mp_msg(MSGT_PLAYTREE,MSGL_ERR,"No value in entry %s\n",line); | |
332 else | |
333 entries[num-1].title = strdup(v); | |
334 } else if(strncasecmp(line,"Length",6) == 0) { | |
335 num = pls_read_entry(line+6,&entries,&max_entry,&v); | |
336 if(num < 0) | |
337 mp_msg(MSGT_PLAYTREE,MSGL_ERR,"No value in entry %s\n",line); | |
33532 | 338 else { |
339 char *end; | |
340 long val = strtol(v, &end, 10); | |
341 if (*end || (val <= 0 && val != -1)) | |
342 mp_msg(MSGT_PLAYTREE,MSGL_ERR,"Invalid length value in entry %s\n",line); | |
343 else if (val > 0) | |
344 entries[num-1].length = strdup(v); | |
345 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28314
diff
changeset
|
346 } else |
10397 | 347 mp_msg(MSGT_PLAYTREE,MSGL_WARN,"Unknown entry type %s\n",line); |
4782 | 348 line = play_tree_parser_get_line(p); |
349 } | |
350 | |
351 for(num = 0; num < max_entry ; num++) { | |
352 if(entries[num].file == NULL) | |
353 mp_msg(MSGT_PLAYTREE,MSGL_ERR,"Entry %d don't have a file !!!!\n",num+1); | |
354 else { | |
5866 | 355 mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"Adding entry %s\n",entries[num].file); |
4782 | 356 entry = play_tree_new(); |
357 play_tree_add_file(entry,entries[num].file); | |
33532 | 358 if (entries[num].length) |
359 play_tree_set_param(entry, "endpos", entries[num].length); | |
4782 | 360 free(entries[num].file); |
361 if(list) | |
9789
45173e0d34cc
Fix the incredible slowness with very long list. Now a 10^6 entries
albeu
parents:
9749
diff
changeset
|
362 play_tree_append_entry(last_entry,entry); |
4782 | 363 else |
364 list = entry; | |
9789
45173e0d34cc
Fix the incredible slowness with very long list. Now a 10^6 entries
albeu
parents:
9749
diff
changeset
|
365 last_entry = entry; |
4782 | 366 } |
32511
b39155e98ac3
Remove some useless NULL pointer checks before invoking free() on the pointer.
diego
parents:
31880
diff
changeset
|
367 // When we have info in playtree we add these info |
b39155e98ac3
Remove some useless NULL pointer checks before invoking free() on the pointer.
diego
parents:
31880
diff
changeset
|
368 free(entries[num].title); |
b39155e98ac3
Remove some useless NULL pointer checks before invoking free() on the pointer.
diego
parents:
31880
diff
changeset
|
369 free(entries[num].length); |
4782 | 370 } |
371 | |
372 free(entries); | |
5866 | 373 |
31880
4f837c9acc58
Avoid trying to parse playlists without any recognized entries.
siretart
parents:
30751
diff
changeset
|
374 if (!list) |
4f837c9acc58
Avoid trying to parse playlists without any recognized entries.
siretart
parents:
30751
diff
changeset
|
375 return NULL; |
4f837c9acc58
Avoid trying to parse playlists without any recognized entries.
siretart
parents:
30751
diff
changeset
|
376 |
5866 | 377 entry = play_tree_new(); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28314
diff
changeset
|
378 play_tree_set_child(entry,list); |
5866 | 379 return entry; |
4782 | 380 } |
381 | |
8897
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
382 /* |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
383 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
|
384 */ |
18916
a95ed361d16b
several function from playtreeparser.c maked static,
reynaldo
parents:
18879
diff
changeset
|
385 static play_tree_t* |
8897
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
386 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
|
387 char *line,*v; |
9789
45173e0d34cc
Fix the incredible slowness with very long list. Now a 10^6 entries
albeu
parents:
9749
diff
changeset
|
388 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
|
389 |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
390 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
|
391 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
|
392 return NULL; |
8897
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
393 strstrip(line); |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
394 if(strcasecmp(line,"[Reference]")) |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
395 return NULL; |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
396 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
|
397 play_tree_parser_stop_keeping(p); |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
398 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
|
399 if(!line) |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
400 return NULL; |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
401 while(line) { |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
402 strstrip(line); |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
403 if(strncasecmp(line,"Ref",3) == 0) { |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
404 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
|
405 if(!v) |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
406 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
|
407 else |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
408 { |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
409 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
|
410 entry = play_tree_new(); |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
411 play_tree_add_file(entry,v); |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
412 if(list) |
9789
45173e0d34cc
Fix the incredible slowness with very long list. Now a 10^6 entries
albeu
parents:
9749
diff
changeset
|
413 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
|
414 else |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
415 list = entry; |
9789
45173e0d34cc
Fix the incredible slowness with very long list. Now a 10^6 entries
albeu
parents:
9749
diff
changeset
|
416 last_entry = entry; |
8897
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
417 } |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
418 } |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
419 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
|
420 } |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
421 |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
422 if(!list) return NULL; |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
423 entry = play_tree_new(); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28314
diff
changeset
|
424 play_tree_set_child(entry,list); |
8897
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
425 return entry; |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
426 } |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
427 |
18916
a95ed361d16b
several function from playtreeparser.c maked static,
reynaldo
parents:
18879
diff
changeset
|
428 static play_tree_t* |
6661
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
429 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
|
430 char* line; |
9789
45173e0d34cc
Fix the incredible slowness with very long list. Now a 10^6 entries
albeu
parents:
9749
diff
changeset
|
431 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
|
432 |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
433 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
|
434 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
|
435 return NULL; |
6661
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
436 strstrip(line); |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
437 if(strcasecmp(line,"#EXTM3U")) |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
438 return NULL; |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
439 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
|
440 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
|
441 |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
442 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
|
443 strstrip(line); |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
444 if(line[0] == '\0') |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
445 continue; |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
446 /* EXTM3U files contain such lines: |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
447 * #EXTINF:<seconds>, <title> |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
448 * 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
|
449 * 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
|
450 * 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
|
451 */ |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
452 if(line[0] == '#') { |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
453 #if 0 /* code functional */ |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
454 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
|
455 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
|
456 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
|
457 } |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
458 #endif |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
459 continue; |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
460 } |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
461 entry = play_tree_new(); |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
462 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
|
463 if(!list) |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
464 list = entry; |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
465 else |
9789
45173e0d34cc
Fix the incredible slowness with very long list. Now a 10^6 entries
albeu
parents:
9749
diff
changeset
|
466 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
|
467 last_entry = entry; |
6661
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
468 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28314
diff
changeset
|
469 |
6661
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
470 if(!list) return NULL; |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
471 entry = play_tree_new(); |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
472 play_tree_set_child(entry,list); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28314
diff
changeset
|
473 return entry; |
6661
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
474 } |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
475 |
18916
a95ed361d16b
several function from playtreeparser.c maked static,
reynaldo
parents:
18879
diff
changeset
|
476 static play_tree_t* |
12097
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
477 parse_smil(play_tree_parser_t* p) { |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
478 int entrymode=0; |
22242
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
479 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
|
480 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
|
481 int is_rmsmil = 0; |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
482 unsigned int npkt, ttlpkt; |
12097
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
483 |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
484 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
|
485 |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
486 // Check if smil |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
487 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
|
488 strstrip(line); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
489 if(line[0] == '\0') // Ignore empties |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
490 continue; |
22518
29a3bb75db47
Support smil embedded into xml, fixes bugzilla #768
rtogni
parents:
22477
diff
changeset
|
491 if (strncasecmp(line,"<?xml",5)==0) // smil in xml |
29a3bb75db47
Support smil embedded into xml, fixes bugzilla #768
rtogni
parents:
22477
diff
changeset
|
492 continue; |
28314 | 493 if (strncasecmp(line,"<!DOCTYPE smil",13)==0) // smil in xml |
494 continue; | |
22242
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
495 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
|
496 strncasecmp(line,"(smil-document",14)==0) |
12097
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
497 break; // smil header found |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
498 else |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
499 return NULL; //line not smil exit |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
500 } |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
501 |
24962
fb50e37df836
Fix possible null-pointer-dereference in parse_smil().
cehoyos
parents:
24424
diff
changeset
|
502 if (!line) return NULL; |
12097
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
503 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
|
504 play_tree_parser_stop_keeping(p); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
505 |
22242
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
506 if (strncasecmp(line,"(smil-document",14)==0) { |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
507 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
|
508 is_rmsmil = 1; |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
509 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
|
510 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
|
511 npkt = ttlpkt = 1; |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
512 } |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
513 if (ttlpkt == 0 || npkt > ttlpkt) { |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
514 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
|
515 npkt, ttlpkt); |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
516 npkt = ttlpkt = 1; |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
517 } |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
518 } |
12097
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
519 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28314
diff
changeset
|
520 //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
|
521 src_line = line; |
22242
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
522 line = NULL; |
22712
c7eee1ecbe8c
Support multiple tags in a single line and tags on the same line as the
rtogni
parents:
22520
diff
changeset
|
523 do { |
22242
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
524 strstrip(src_line); |
32511
b39155e98ac3
Remove some useless NULL pointer checks before invoking free() on the pointer.
diego
parents:
31880
diff
changeset
|
525 free(line); |
b39155e98ac3
Remove some useless NULL pointer checks before invoking free() on the pointer.
diego
parents:
31880
diff
changeset
|
526 line = NULL; |
22242
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
527 /* 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
|
528 * 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
|
529 * 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
|
530 */ |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
531 if (is_rmsmil && npkt != ttlpkt && strstr(src_line,"\")")) { |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
532 char *payload; |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
533 |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
534 line = strdup(src_line); |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
535 if(!(src_line = play_tree_parser_get_line(p))) { |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
536 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
|
537 break; |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
538 } |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
539 strstrip(src_line); |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
540 // Skip header, packet starts after " |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
541 if(!(payload = strchr(src_line,'\"'))) { |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
542 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
|
543 payload = src_line; |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
544 } else |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
545 payload++; |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
546 // 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
|
547 line[strlen(line)-2] = 0; |
22477 | 548 line = realloc(line, strlen(line)+strlen(payload)+1); |
22242
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
549 strcat (line, payload); |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
550 npkt++; |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
551 } else |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
552 line = strdup(src_line); |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
553 /* Unescape \" to " for smil-over-rtsp */ |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
554 if (is_rmsmil && line[0] != '\0') { |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
555 int i, j; |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
556 |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
557 for (i = 0; i < strlen(line); i++) |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
558 if (line[i] == '\\' && line[i+1] == '"') |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
559 for (j = i; line[j]; j++) |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
560 line[j] = line[j+1]; |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
561 } |
22712
c7eee1ecbe8c
Support multiple tags in a single line and tags on the same line as the
rtogni
parents:
22520
diff
changeset
|
562 pos = line; |
c7eee1ecbe8c
Support multiple tags in a single line and tags on the same line as the
rtogni
parents:
22520
diff
changeset
|
563 while (pos) { |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28314
diff
changeset
|
564 if (!entrymode) { // all entries filled so far |
24424 | 565 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
|
566 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
|
567 entrymode=1; |
22712
c7eee1ecbe8c
Support multiple tags in a single line and tags on the same line as the
rtogni
parents:
22520
diff
changeset
|
568 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
|
569 } |
22712
c7eee1ecbe8c
Support multiple tags in a single line and tags on the same line as the
rtogni
parents:
22520
diff
changeset
|
570 pos++; |
c7eee1ecbe8c
Support multiple tags in a single line and tags on the same line as the
rtogni
parents:
22520
diff
changeset
|
571 } |
22520 | 572 } |
573 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
|
574 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
|
575 if (pos != NULL) { |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
576 entrymode=0; |
23774
16a67232e916
realrtsp smil files can also use ' as field delimiter instead of "
rtogni
parents:
22712
diff
changeset
|
577 if (pos[4] != '"' && pos[4] != '\'') { |
16a67232e916
realrtsp smil files can also use ' as field delimiter instead of "
rtogni
parents:
22712
diff
changeset
|
578 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
|
579 break; |
16a67232e916
realrtsp smil files can also use ' as field delimiter instead of "
rtogni
parents:
22712
diff
changeset
|
580 } |
12097
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
581 s_start=pos+5; |
23774
16a67232e916
realrtsp smil files can also use ' as field delimiter instead of "
rtogni
parents:
22712
diff
changeset
|
582 s_end=strchr(s_start,pos[4]); |
12097
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
583 if (s_end == NULL) { |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
584 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
|
585 break; |
12097
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
586 } |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
587 if (s_end-s_start> 511) { |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
588 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
|
589 break; |
12097
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
590 } |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
591 strncpy(source,s_start,s_end-s_start); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
592 source[(s_end-s_start)]='\0'; // Null terminate |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
593 entry = play_tree_new(); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
594 play_tree_add_file(entry,source); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
595 if(!list) //Insert new entry |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
596 list = entry; |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
597 else |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
598 play_tree_append_entry(last_entry,entry); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
599 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
|
600 pos = s_end; |
12097
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
601 } |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
602 } |
22712
c7eee1ecbe8c
Support multiple tags in a single line and tags on the same line as the
rtogni
parents:
22520
diff
changeset
|
603 } |
c7eee1ecbe8c
Support multiple tags in a single line and tags on the same line as the
rtogni
parents:
22520
diff
changeset
|
604 } 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
|
605 |
32511
b39155e98ac3
Remove some useless NULL pointer checks before invoking free() on the pointer.
diego
parents:
31880
diff
changeset
|
606 free(line); |
22242
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21910
diff
changeset
|
607 |
12097
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
608 if(!list) return NULL; // Nothing found |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
609 |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
610 entry = play_tree_new(); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
611 play_tree_set_child(entry,list); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
612 return entry; |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
613 } |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
614 |
18916
a95ed361d16b
several function from playtreeparser.c maked static,
reynaldo
parents:
18879
diff
changeset
|
615 static play_tree_t* |
12097
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
616 embedded_playlist_parse(char *line) { |
12223 | 617 int f=DEMUXER_TYPE_PLAYLIST; |
12097
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
618 stream_t* stream; |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
619 play_tree_parser_t* ptp; |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
620 play_tree_t* entry; |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
621 |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
622 // Get stream opened to link |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
623 stream=open_stream(line,0,&f); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
624 if(!stream) { |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
625 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
|
626 return NULL; |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
627 } |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
628 |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
629 //add new playtree |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
630 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
|
631 |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
632 ptp = play_tree_parser_new(stream,1); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
633 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
|
634 play_tree_parser_free(ptp); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
635 free_stream(stream); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
636 |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
637 return entry; |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
638 } |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
639 |
18916
a95ed361d16b
several function from playtreeparser.c maked static,
reynaldo
parents:
18879
diff
changeset
|
640 static play_tree_t* |
4308
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
641 parse_textplain(play_tree_parser_t* p) { |
4782 | 642 char* line; |
12300
95ea9f5f6f14
Fix embedded smil playlist detection if there are parameters on the url
rtognimp
parents:
12223
diff
changeset
|
643 char *c; |
95ea9f5f6f14
Fix embedded smil playlist detection if there are parameters on the url
rtognimp
parents:
12223
diff
changeset
|
644 int embedded; |
9789
45173e0d34cc
Fix the incredible slowness with very long list. Now a 10^6 entries
albeu
parents:
9749
diff
changeset
|
645 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
|
646 |
6661
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
647 mp_msg(MSGT_PLAYTREE,MSGL_V,"Trying plaintext playlist...\n"); |
4782 | 648 play_tree_parser_stop_keeping(p); |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
649 |
4782 | 650 while((line = play_tree_parser_get_line(p)) != NULL) { |
651 strstrip(line); | |
12689
050c90536ddd
Support for comments in plaintext playlist by adland
alex
parents:
12538
diff
changeset
|
652 if(line[0] == '\0' || line[0] == '#' || (line[0] == '/' && line[1] == '/')) |
4782 | 653 continue; |
12097
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
654 |
12538
2beafad68f68
Enhance detection of embedded smil playlist, add embedded ram playlist
rtognimp
parents:
12300
diff
changeset
|
655 //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
|
656 embedded = 0; |
95ea9f5f6f14
Fix embedded smil playlist detection if there are parameters on the url
rtognimp
parents:
12223
diff
changeset
|
657 if (strlen(line) > 5) |
95ea9f5f6f14
Fix embedded smil playlist detection if there are parameters on the url
rtognimp
parents:
12223
diff
changeset
|
658 for(c = line; c[0]; c++ ) |
12538
2beafad68f68
Enhance detection of embedded smil playlist, add embedded ram playlist
rtognimp
parents:
12300
diff
changeset
|
659 if ( ((c[0] == '.') && //start with . and next have smil with optional ? or & |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28314
diff
changeset
|
660 (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
|
661 (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
|
662 (!c[5] || c[5] == '?' || c[5] == '&')) || // or |
2beafad68f68
Enhance detection of embedded smil playlist, add embedded ram playlist
rtognimp
parents:
12300
diff
changeset
|
663 ((c[0] == '.') && // start with . and next have smi or ram with optional ? or & |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28314
diff
changeset
|
664 ( ((tolower(c[1]) == 's') && (tolower(c[2])== 'm') && (tolower(c[3]) == 'i')) || |
12538
2beafad68f68
Enhance detection of embedded smil playlist, add embedded ram playlist
rtognimp
parents:
12300
diff
changeset
|
665 ((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
|
666 && (!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
|
667 entry=embedded_playlist_parse(line); |
95ea9f5f6f14
Fix embedded smil playlist detection if there are parameters on the url
rtognimp
parents:
12223
diff
changeset
|
668 embedded = 1; |
95ea9f5f6f14
Fix embedded smil playlist detection if there are parameters on the url
rtognimp
parents:
12223
diff
changeset
|
669 break; |
95ea9f5f6f14
Fix embedded smil playlist detection if there are parameters on the url
rtognimp
parents:
12223
diff
changeset
|
670 } |
95ea9f5f6f14
Fix embedded smil playlist detection if there are parameters on the url
rtognimp
parents:
12223
diff
changeset
|
671 |
95ea9f5f6f14
Fix embedded smil playlist detection if there are parameters on the url
rtognimp
parents:
12223
diff
changeset
|
672 if (!embedded) { //regular file link |
12097
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
673 entry = play_tree_new(); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
674 play_tree_add_file(entry,line); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
675 } |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
676 |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
677 if (entry != NULL) { |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
678 if(!list) |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
679 list = entry; |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
680 else |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
681 play_tree_append_entry(last_entry,entry); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
682 last_entry = entry; |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
683 } |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
684 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28314
diff
changeset
|
685 |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
686 if(!list) return NULL; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
687 entry = play_tree_new(); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
688 play_tree_set_child(entry,list); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28314
diff
changeset
|
689 return entry; |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
690 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
691 |
32623 | 692 /** |
693 * \brief decode the base64 used in nsc files | |
694 * \param in input string, 0-terminated | |
695 * \param buf output buffer, must point to memory suitable for realloc, | |
696 * will be NULL on failure. | |
697 * \return decoded length in bytes | |
698 */ | |
699 static int decode_nsc_base64(char *in, char **buf) { | |
700 int i, j, n; | |
701 if (in[0] != '0' || in[1] != '2') | |
702 goto err_out; | |
703 in += 2; // skip prefix | |
704 if (strlen(in) < 16) // error out if nothing to decode | |
705 goto err_out; | |
706 in += 12; // skip encoded string length | |
707 n = strlen(in) / 4; | |
708 *buf = realloc(*buf, n * 3); | |
709 for (i = 0; i < n; i++) { | |
710 uint8_t c[4]; | |
711 for (j = 0; j < 4; j++) { | |
712 c[j] = in[4 * i + j]; | |
713 if (c[j] >= '0' && c[j] <= '9') c[j] += 0 - '0'; | |
714 else if (c[j] >= 'A' && c[j] <= 'Z') c[j] += 10 - 'A'; | |
715 else if (c[j] >= 'a' && c[j] <= 'z') c[j] += 36 - 'a'; | |
716 else if (c[j] == '{') c[j] = 62; | |
717 else if (c[j] == '}') c[j] = 63; | |
718 else { | |
719 mp_msg(MSGT_PLAYTREE, MSGL_ERR, "Invalid character %c (0x%02"PRIx8")\n", c[j], c[j]); | |
720 goto err_out; | |
721 } | |
722 } | |
723 (*buf)[3 * i] = (c[0] << 2) | (c[1] >> 4); | |
724 (*buf)[3 * i + 1] = (c[1] << 4) | (c[2] >> 2); | |
725 (*buf)[3 * i + 2] = (c[2] << 6) | c[3]; | |
726 } | |
727 return 3 * n; | |
728 err_out: | |
32628 | 729 free(*buf); |
32623 | 730 *buf = NULL; |
731 return 0; | |
732 } | |
733 | |
734 /** | |
735 * \brief "converts" utf16 to ascii by just discarding every second byte | |
736 * \param buf buffer to convert | |
737 * \param len lenght of buffer, must be > 0 | |
738 */ | |
739 static void utf16_to_ascii(char *buf, int len) { | |
740 int i; | |
741 if (len <= 0) return; | |
742 for (i = 0; i < len / 2; i++) | |
743 buf[i] = buf[i * 2]; | |
744 buf[i] = 0; // just in case | |
745 } | |
746 | |
747 static play_tree_t *parse_nsc(play_tree_parser_t* p) { | |
748 char *line, *addr = NULL, *url, *unicast_url = NULL; | |
749 int port = 0; | |
750 play_tree_t *entry = NULL; | |
751 | |
752 mp_msg(MSGT_PLAYTREE,MSGL_V,"Trying nsc playlist...\n"); | |
753 while((line = play_tree_parser_get_line(p)) != NULL) { | |
754 strstrip(line); | |
755 if(!line[0]) // Ignore empties | |
756 continue; | |
757 if (strncasecmp(line,"[Address]", 9) == 0) | |
758 break; // nsc header found | |
759 else | |
760 return NULL; | |
761 } | |
762 mp_msg(MSGT_PLAYTREE,MSGL_V,"Detected nsc playlist format\n"); | |
763 play_tree_parser_stop_keeping(p); | |
764 while ((line = play_tree_parser_get_line(p)) != NULL) { | |
765 strstrip(line); | |
766 if (!line[0]) | |
767 continue; | |
768 if (strncasecmp(line, "Unicast URL=", 12) == 0) { | |
769 int len = decode_nsc_base64(&line[12], &unicast_url); | |
770 if (len <= 0) | |
771 mp_msg(MSGT_PLAYTREE, MSGL_WARN, "[nsc] Unsupported Unicast URL encoding\n"); | |
772 else | |
773 utf16_to_ascii(unicast_url, len); | |
774 } else if (strncasecmp(line, "IP Address=", 11) == 0) { | |
775 int len = decode_nsc_base64(&line[11], &addr); | |
776 if (len <= 0) | |
777 mp_msg(MSGT_PLAYTREE, MSGL_WARN, "[nsc] Unsupported IP Address encoding\n"); | |
778 else | |
779 utf16_to_ascii(addr, len); | |
780 } else if (strncasecmp(line, "IP Port=", 8) == 0) { | |
781 port = strtol(&line[8], NULL, 0); | |
782 } | |
783 } | |
784 | |
785 if (unicast_url) | |
786 url = strdup(unicast_url); | |
787 else if (addr && port) { | |
788 url = malloc(strlen(addr) + 7 + 20 + 1); | |
789 sprintf(url, "http://%s:%i", addr, port); | |
790 } else | |
791 goto out; | |
792 | |
793 entry = play_tree_new(); | |
794 play_tree_add_file(entry, url); | |
795 free(url); | |
796 out: | |
32628 | 797 free(addr); |
798 free(unicast_url); | |
32623 | 799 return entry; |
800 } | |
801 | |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
802 play_tree_t* |
8925
5c15777f1c07
this patch adds an fallback to playlist (any but the plaintext-list format)
arpi
parents:
8907
diff
changeset
|
803 parse_playtree(stream_t *stream, int forced) { |
4308
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
804 play_tree_parser_t* p; |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
805 play_tree_t* ret; |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
806 |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4043
diff
changeset
|
807 #ifdef MP_DEBUG |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
808 assert(stream != NULL); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
809 #endif |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
810 |
4308
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
811 p = play_tree_parser_new(stream,0); |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
812 if(!p) |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
813 return NULL; |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
814 |
8925
5c15777f1c07
this patch adds an fallback to playlist (any but the plaintext-list format)
arpi
parents:
8907
diff
changeset
|
815 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
|
816 play_tree_parser_free(p); |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
817 |
4308
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
818 return ret; |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
819 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
820 |
6662
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
821 static void |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
822 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
|
823 int i,bl = strlen(bp),fl; |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
824 |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
825 if(pt->child) { |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
826 play_tree_t* i; |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
827 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
|
828 play_tree_add_basepath(i,bp); |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
829 return; |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
830 } |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
831 |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
832 if(!pt->files) |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
833 return; |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
834 |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
835 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
|
836 fl = strlen(pt->files[i]); |
13305
90ffe76b5b25
Don't prepend basepath to a full unix path. ( 10l to Joey. )
al
parents:
13010
diff
changeset
|
837 // 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
|
838 // don't mangle it. |
34128 | 839 if(fl <= 0 || strstr(pt->files[i],"://") || (pt->files[i][0] == '/') |
840 #if HAVE_DOS_PATHS | |
841 || (strstr(pt->files[i],":\\") == pt->files[i] + 1) | |
34129 | 842 // the X:/ format is allowed as well |
843 || (strstr(pt->files[i],":/") == pt->files[i] + 1) | |
34128 | 844 #endif |
845 ) | |
6662
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
846 continue; |
13010 | 847 // if the path begins with \ then prepend drive letter to it. |
848 if (pt->files[i][0] == '\\') { | |
18928
586777f09b1b
relative-to-absolute path fixes: Do not prepend drive letter to \\ paths.
reimar
parents:
18916
diff
changeset
|
849 if (pt->files[i][1] == '\\') |
586777f09b1b
relative-to-absolute path fixes: Do not prepend drive letter to \\ paths.
reimar
parents:
18916
diff
changeset
|
850 continue; |
30702 | 851 pt->files[i] = realloc(pt->files[i], 2 + fl + 1); |
13010 | 852 memmove(pt->files[i] + 2,pt->files[i],fl+1); |
853 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
|
854 continue; |
13010 | 855 } |
30702 | 856 pt->files[i] = realloc(pt->files[i], bl + fl + 1); |
6662
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
857 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
|
858 memcpy(pt->files[i],bp,bl); |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
859 } |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
860 } |
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
861 |
9301
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
862 // 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
|
863 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
|
864 { |
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
865 char *ls, *file; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28314
diff
changeset
|
866 |
9301
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
867 if (pt && filename) |
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
868 { |
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
869 file = strdup(filename); |
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
870 if (file) |
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
871 { |
13010 | 872 ls = strrchr(file,'/'); |
873 if(!ls) ls = strrchr(file,'\\'); | |
9301
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
874 if(ls) { |
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
875 ls[1] = '\0'; |
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
876 play_tree_add_basepath(pt,file); |
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
877 } |
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
878 free(file); |
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
879 } |
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
880 } |
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
881 } |
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
882 |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
883 play_tree_t* |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
884 parse_playlist_file(char* file) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
885 stream_t *stream; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
886 play_tree_t* ret; |
12223 | 887 int f=DEMUXER_TYPE_PLAYLIST; |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
888 |
9749 | 889 stream = open_stream(file,0,&f); |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
890 |
9749 | 891 if(!stream) { |
10487 | 892 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
|
893 return NULL; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
894 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
895 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
896 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
|
897 |
8925
5c15777f1c07
this patch adds an fallback to playlist (any but the plaintext-list format)
arpi
parents:
8907
diff
changeset
|
898 ret = parse_playtree(stream,1); |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
899 free_stream(stream); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
900 |
9301
7841308ad250
this patch fixes latest bug, discovered by .so ... (relative filenames &
arpi
parents:
9089
diff
changeset
|
901 play_tree_add_bpf(ret, file); |
6662
f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
albeu
parents:
6661
diff
changeset
|
902 |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
903 return ret; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
904 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
905 } |
4308
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
906 |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
907 |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
908 play_tree_parser_t* |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
909 play_tree_parser_new(stream_t* stream,int deep) { |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
910 play_tree_parser_t* p; |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
911 |
18879 | 912 p = calloc(1,sizeof(play_tree_parser_t)); |
4308
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
913 if(!p) |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
914 return NULL; |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
915 p->stream = stream; |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
916 p->deep = deep; |
4782 | 917 p->keep = 1; |
4308
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
918 |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
919 return p; |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
920 |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
921 } |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
922 |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
923 void |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
924 play_tree_parser_free(play_tree_parser_t* p) { |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
925 |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
926 #ifdef MP_DEBUG |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
927 assert(p != NULL); |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
928 #endif |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
929 |
32511
b39155e98ac3
Remove some useless NULL pointer checks before invoking free() on the pointer.
diego
parents:
31880
diff
changeset
|
930 free(p->buffer); |
b39155e98ac3
Remove some useless NULL pointer checks before invoking free() on the pointer.
diego
parents:
31880
diff
changeset
|
931 free(p->line); |
4782 | 932 free(p); |
4308
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
933 } |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
934 |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
935 play_tree_t* |
8925
5c15777f1c07
this patch adds an fallback to playlist (any but the plaintext-list format)
arpi
parents:
8907
diff
changeset
|
936 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
|
937 play_tree_t* tree = NULL; |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
938 |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
939 #ifdef MP_DEBUG |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
940 assert(p != NULL); |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
941 #endif |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
942 |
4782 | 943 |
944 while(play_tree_parser_get_line(p) != NULL) { | |
945 play_tree_parser_reset(p); | |
946 | |
4308
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
947 tree = parse_asx(p); |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
948 if(tree) break; |
4782 | 949 play_tree_parser_reset(p); |
950 | |
951 tree = parse_pls(p); | |
952 if(tree) break; | |
953 play_tree_parser_reset(p); | |
954 | |
6661
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
955 tree = parse_m3u(p); |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
956 if(tree) break; |
dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
atmos4
parents:
5866
diff
changeset
|
957 play_tree_parser_reset(p); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28314
diff
changeset
|
958 |
8897
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
959 tree = parse_ref_ini(p); |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
960 if(tree) break; |
ef01554542fb
This patch adds support for some silly ini-style-playlist-file-format ...
arpi
parents:
8164
diff
changeset
|
961 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
|
962 |
12097
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
963 tree = parse_smil(p); |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
964 if(tree) break; |
cb0cdaa0bddf
Support for smil playlist, both standalone and embedded into other
rtognimp
parents:
10694
diff
changeset
|
965 play_tree_parser_reset(p); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28314
diff
changeset
|
966 |
32623 | 967 tree = parse_nsc(p); |
968 if(tree) break; | |
969 play_tree_parser_reset(p); | |
970 | |
4308
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
971 // 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
|
972 if (forced) |
5c15777f1c07
this patch adds an fallback to playlist (any but the plaintext-list format)
arpi
parents:
8907
diff
changeset
|
973 { |
5c15777f1c07
this patch adds an fallback to playlist (any but the plaintext-list format)
arpi
parents:
8907
diff
changeset
|
974 tree = parse_textplain(p); |
5c15777f1c07
this patch adds an fallback to playlist (any but the plaintext-list format)
arpi
parents:
8907
diff
changeset
|
975 if(tree) break; |
5c15777f1c07
this patch adds an fallback to playlist (any but the plaintext-list format)
arpi
parents:
8907
diff
changeset
|
976 } |
4308
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
977 break; |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
978 } |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
979 |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
980 if(tree) |
10487 | 981 mp_msg(MSGT_PLAYTREE,MSGL_V,"Playlist successfully parsed\n"); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28314
diff
changeset
|
982 else |
8925
5c15777f1c07
this patch adds an fallback to playlist (any but the plaintext-list format)
arpi
parents:
8907
diff
changeset
|
983 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
|
984 |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
985 if(tree) |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
986 tree = play_tree_cleanup(tree); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28314
diff
changeset
|
987 |
10487 | 988 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
|
989 |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
990 return tree; |
d752f99fd535
Objectization of the play_tree_parser for more flexiblity
albeu
parents:
4156
diff
changeset
|
991 } |