summaryrefslogtreecommitdiffstats
path: root/demux/demux_playlist.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-11-04 23:55:41 +0100
committerwm4 <wm4@nowhere>2013-11-04 23:55:41 +0100
commited02cbf92f73a540f87a237ac3b487094d7b609f (patch)
treebd849b019c75245d801a6d995a92d31347b07481 /demux/demux_playlist.c
parentb74edd406989cbb7a74b8462cb608b560918aa7b (diff)
downloadmpv-ed02cbf92f73a540f87a237ac3b487094d7b609f.tar.bz2
mpv-ed02cbf92f73a540f87a237ac3b487094d7b609f.tar.xz
playlist: rewrite PLS parser
Somehow the new parser ends up much smaller. Much of it is because we don't parse some additional information. We just skip it, instead of parsing it and then throwing it away. More importantly, we use the physical order of entries, instead of trying to sort them by entry number. Each "File" entry is followed by a number that is supposed to be the entry number, and "File1" is first. (Should it turn out that this is really needed, an additional field should be added to playlist_entry, and then qsort().)
Diffstat (limited to 'demux/demux_playlist.c')
-rw-r--r--demux/demux_playlist.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/demux/demux_playlist.c b/demux/demux_playlist.c
index 1dd063ed9d..dc42c2ea1f 100644
--- a/demux/demux_playlist.c
+++ b/demux/demux_playlist.c
@@ -110,6 +110,27 @@ static int parse_mov_rtsptext(struct pl_parser *p)
return -1;
}
+static int parse_pls(struct pl_parser *p)
+{
+ bstr line = {0};
+ while (!line.len && !pl_eof(p))
+ line = bstr_strip(pl_get_line(p));
+ if (bstrcasecmp0(line, "[playlist]") != 0)
+ return -1;
+ if (p->probing)
+ return 0;
+ while (!pl_eof(p)) {
+ line = bstr_strip(pl_get_line(p));
+ bstr key, value;
+ if (bstr_split_tok(line, "=", &key, &value) &&
+ bstr_case_startswith(key, bstr0("File")))
+ {
+ pl_add(p, value);
+ }
+ }
+ return 0;
+}
+
struct pl_format {
const char *name;
int (*parse)(struct pl_parser *p);
@@ -119,6 +140,7 @@ static const struct pl_format formats[] = {
{"m3u", parse_m3u},
{"ini", parse_ref_init},
{"mov", parse_mov_rtsptext},
+ {"pls", parse_pls},
};
static const struct pl_format *probe_pl(struct pl_parser *p, bool force)