diff options
author | wm4 <wm4@nowhere> | 2014-04-13 15:39:48 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-04-13 15:40:05 +0200 |
commit | 47972a0077892636fb922a3600d66779636b7ee7 (patch) | |
tree | 8cee937efe6d36c99f8a0faacb986c1a3236dce3 /common/playlist.c | |
parent | 586b02e7bd3499c8ef300fee7b723fbed19526dd (diff) | |
download | mpv-47972a0077892636fb922a3600d66779636b7ee7.tar.bz2 mpv-47972a0077892636fb922a3600d66779636b7ee7.tar.xz |
player: remove ASX, SMIL and NSC playlist parsers
These playlist parsers are all what's left from the old mplayer playlist
parsing code. All of it is old code that does little error checking; the
type of C string parsing code that gives you nightmare.
Some playlist parsers have been rewritten and are located in
demux_playlist.c. The removed formats were not reimplemented. ASX and
SMIL use XML, and since we don't want to depend on a full blown XML
parser, this is not so easy. Possibly these formats could be supported
by writing a very primitive XML-like lexer, which would lead to success
with most real world files, but I haven't attempted that. As for NSC, I
couldn't find any URL that worked with MPlayer, and in general this
formats seems to be more than dead.
Move playlist_parse_file() to playlist.c. It's pretty small now, and
basically just opens a stream and a demuxer. No use keeping
playlist_parser.c just for this.
Diffstat (limited to 'common/playlist.c')
-rw-r--r-- | common/playlist.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/common/playlist.c b/common/playlist.c index 297cb4d379..9080a27ae9 100644 --- a/common/playlist.c +++ b/common/playlist.c @@ -19,9 +19,14 @@ #include "config.h" #include "playlist.h" #include "common/common.h" +#include "common/global.h" +#include "common/msg.h" #include "talloc.h" #include "options/path.h" +#include "demux/demux.h" +#include "stream/stream.h" + struct playlist_entry *playlist_entry_new(const char *filename) { struct playlist_entry *e = talloc_zero(NULL, struct playlist_entry); @@ -239,3 +244,39 @@ struct playlist_entry *playlist_entry_from_index(struct playlist *pl, int index) } } +struct playlist *playlist_parse_file(const char *file, struct mpv_global *global) +{ + struct mp_log *log = mp_log_new(NULL, global->log, "!playlist_parser"); + mp_verbose(log, "Parsing playlist file %s...\n", file); + + struct playlist *ret = NULL; + stream_t *stream = stream_open(file, global); + if(!stream) { + mp_err(log, "Error while opening playlist file %s\n", file); + talloc_free(log); + return NULL; + } + + struct demuxer *pl_demux = demux_open(stream, "playlist", NULL, global); + if (pl_demux && pl_demux->playlist) { + ret = talloc_zero(NULL, struct playlist); + playlist_transfer_entries(ret, pl_demux->playlist); + } + free_demuxer(pl_demux); + free_stream(stream); + + if (ret) { + mp_verbose(log, "Playlist successfully parsed\n"); + } else { + mp_err(log, "Error while parsing playlist\n"); + } + + if (ret && !ret->first) + mp_warn(log, "Warning: empty playlist\n"); + + if (ret) + playlist_add_base_path(ret, mp_dirname(file)); + + talloc_free(log); + return ret; +} |