Skip to content

Commit

Permalink
player: remove ASX, SMIL and NSC playlist parsers
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
wm4 committed Apr 13, 2014
1 parent 586b02e commit 47972a0
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 1,186 deletions.
571 changes: 0 additions & 571 deletions common/asxparser.c

This file was deleted.

28 changes: 0 additions & 28 deletions common/asxparser.h

This file was deleted.

41 changes: 41 additions & 0 deletions common/playlist.c
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
3 changes: 3 additions & 0 deletions common/playlist.h
Expand Up @@ -79,4 +79,7 @@ int playlist_entry_to_index(struct playlist *pl, struct playlist_entry *e);
int playlist_entry_count(struct playlist *pl);
struct playlist_entry *playlist_entry_from_index(struct playlist *pl, int index);

struct mpv_global;
struct playlist *playlist_parse_file(const char *file, struct mpv_global *global);

#endif

0 comments on commit 47972a0

Please sign in to comment.