summaryrefslogtreecommitdiffstats
path: root/demux
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-02-27 19:44:39 +0100
committerwm4 <wm4@nowhere>2015-02-27 19:44:39 +0100
commit5824eb7107a612880f68cc8e4f42cfff1bbf88ba (patch)
treecf07ffbcf460d14cefbf55ef6c2aba1b7afa6c0e /demux
parent64456488b3b6bbbcbc4d3c96aab1b45cbd215439 (diff)
downloadmpv-5824eb7107a612880f68cc8e4f42cfff1bbf88ba.tar.bz2
mpv-5824eb7107a612880f68cc8e4f42cfff1bbf88ba.tar.xz
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
Diffstat (limited to 'demux')
-rw-r--r--demux/demux_playlist.c25
1 files changed, 25 insertions, 0 deletions
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},
};