demux_playlist: port ini reference playlist parser

Port it from playlist_parser.c to demux_playlist.c. Also, change the m3u
parser to drop whitespace from the trailing part of the line (will make
it work properly with windows line endings).

(I hoped that this would make MMS URIs with http instead of mmsh
prefixes work, but it doesn't. Instead, it leads to a playlist loop. So
solving this issue would require a change in ffmpeg, probably.)
This commit is contained in:
wm4 2013-08-26 23:34:07 +02:00
parent 792844f873
commit 33c03c4d0a
2 changed files with 18 additions and 37 deletions

View File

@ -69,7 +69,7 @@ static int parse_m3u(struct pl_parser *p)
if (p->probing)
return 0;
while (!pl_eof(p)) {
line = bstr_lstrip(pl_get_line(p));
line = bstr_strip(pl_get_line(p));
if (line.len == 0 || bstr_startswith0(line, "#"))
continue;
pl_add(p, line);
@ -77,6 +77,22 @@ static int parse_m3u(struct pl_parser *p)
return 0;
}
static int parse_ref_init(struct pl_parser *p)
{
bstr line = bstr_strip(pl_get_line(p));
if (!bstr_equals0(line, "[Reference]"))
return -1;
while (!pl_eof(p)) {
line = bstr_strip(pl_get_line(p));
if (bstr_case_startswith(line, bstr0("Ref"))) {
bstr_split_tok(line, "=", &(bstr){0}, &line);
if (line.len)
pl_add(p, line);
}
}
return 0;
}
struct pl_format {
const char *name;
int (*parse)(struct pl_parser *p);
@ -84,6 +100,7 @@ struct pl_format {
static const struct pl_format formats[] = {
{"m3u", parse_m3u},
{"ini", parse_ref_init},
};
static const struct pl_format *probe_pl(struct pl_parser *p, bool force)

View File

@ -376,41 +376,6 @@ static bool parse_pls(play_tree_parser_t* p) {
return true;
}
/*
Reference Ini-Format: Each entry is assumed a reference
*/
static bool parse_ref_ini(play_tree_parser_t* p) {
char *line,*v;
mp_msg(MSGT_PLAYTREE,MSGL_V,"Trying reference-ini playlist...\n");
if (!(line = play_tree_parser_get_line(p)))
return NULL;
strstrip(line);
if(strcasecmp(line,"[Reference]"))
return NULL;
mp_msg(MSGT_PLAYTREE,MSGL_V,"Detected reference-ini playlist format\n");
play_tree_parser_stop_keeping(p);
line = play_tree_parser_get_line(p);
if(!line)
return NULL;
while(line) {
strstrip(line);
if(strncasecmp(line,"Ref",3) == 0) {
v = pls_entry_get_value(line+3);
if(!v)
mp_msg(MSGT_PLAYTREE,MSGL_ERR,"No value in entry %s\n",line);
else
{
mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"Adding entry %s\n",v);
playlist_add_file(p->pl, v);
}
}
line = play_tree_parser_get_line(p);
}
return true;
}
static bool parse_smil(play_tree_parser_t* p) {
int entrymode=0;
char* line,source[512],*pos,*s_start,*s_end,*src_line;
@ -693,7 +658,6 @@ typedef bool (*parser_fn)(play_tree_parser_t *);
static const parser_fn pl_parsers[] = {
parse_asx,
parse_pls,
parse_ref_ini,
parse_smil,
parse_nsc,
parse_textplain