From 5824eb7107a612880f68cc8e4f42cfff1bbf88ba Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 27 Feb 2015 19:44:39 +0100 Subject: stream_rar: treat rar files as playlists Refactors an older hack, which for some reason used a more complicated way. This generates the playlist representing the contents of the rar file in demux_playlist.c. The pseudo-demuxer could easily be separate from the the playlist parsers (and in fact there's almost no shared code), but I don't think this obscure feature deserves a separate file. Sample files created with: rar a -v20000k -m0 files.rar file1.mkv file1.mkv --- demux/demux_playlist.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'demux/demux_playlist.c') diff --git a/demux/demux_playlist.c b/demux/demux_playlist.c index 381b50f269..c0e868d209 100644 --- a/demux/demux_playlist.c +++ b/demux/demux_playlist.c @@ -23,6 +23,7 @@ #include "common/playlist.h" #include "options/path.h" #include "stream/stream.h" +#include "stream/rar.h" #include "demux.h" #define PROBE_SIZE (8 * 1024) @@ -188,6 +189,29 @@ static int parse_pls(struct pl_parser *p) return 0; } +static int parse_rar(struct pl_parser *p) +{ + if (RarProbe(p->s)) + return -1; + if (p->probing) + return 0; + + int count; + rar_file_t **files; + if (RarParse(p->s, &count, &files)) + return -1; + + char *prefix = mp_url_escape(p, p->real_stream->url, "~|"); + for (int n = 0; n < count; n++) { + // stream_rar.c does the real work + playlist_add_file(p->pl, + talloc_asprintf(p, "rar://%s|%s", prefix, files[n]->name)); + RarFileDelete(files[n]); + } + talloc_free(files); + return 0; +} + static int parse_txt(struct pl_parser *p) { if (!p->force) @@ -220,6 +244,7 @@ static const struct pl_format formats[] = { {"mov", parse_mov_rtsptext}, {"pls", parse_pls, MIME_TYPES("audio/x-scpls")}, + {"rar", parse_rar}, {"txt", parse_txt}, }; -- cgit v1.2.3