summaryrefslogtreecommitdiffstats
path: root/demux/demux.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-02-20 21:56:55 +0100
committerwm4 <wm4@nowhere>2015-02-20 21:56:55 +0100
commit1cac7d1a659faffd1514a3269edf9fcae4d357c1 (patch)
treefeaa280fa28a416691f2fe2e0cd56f588746dcd1 /demux/demux.c
parent6aa6778ac46672dd237acc86856353d133917f06 (diff)
downloadmpv-1cac7d1a659faffd1514a3269edf9fcae4d357c1.tar.bz2
mpv-1cac7d1a659faffd1514a3269edf9fcae4d357c1.tar.xz
demux: add a demux_open_url() function
Often stream and a demuxer are opened at the same time. Provide a function for this and replace most of its uses.
Diffstat (limited to 'demux/demux.c')
-rw-r--r--demux/demux.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/demux/demux.c b/demux/demux.c
index a08f633289..21898e3156 100644
--- a/demux/demux.c
+++ b/demux/demux.c
@@ -1039,6 +1039,26 @@ done:
return demuxer;
}
+// Convenience function: open the stream, enable the cache (according to params
+// and global opts.), open the demuxer.
+// (use free_demuxer_and_stream() to free the underlying stream too)
+struct demuxer *demux_open_url(const char *url,
+ struct demuxer_params *params,
+ struct mp_cancel *cancel,
+ struct mpv_global *global)
+{
+ struct MPOpts *opts = global->opts;
+ struct stream *s = stream_create(url, STREAM_READ, cancel, global);
+ if (!s)
+ return NULL;
+ if (!(params && params->disable_cache))
+ stream_enable_cache(&s, &opts->stream_cache);
+ struct demuxer *d = demux_open(s, params, global);
+ if (!d)
+ free_stream(s);
+ return d;
+}
+
static void flush_locked(demuxer_t *demuxer)
{
for (int n = 0; n < demuxer->num_streams; n++)