diff options
author | wm4 <wm4@nowhere> | 2019-09-29 00:45:41 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2019-09-29 00:46:54 +0200 |
commit | 2bb5ab07b7ee09fb7ae0e90a74c1e8e5adcc3d59 (patch) | |
tree | ce765b9b553e40890faba658243191542b8f5068 /stream/stream.h | |
parent | a7158ceec00f14e680a885722cfe23761b4662d3 (diff) | |
download | mpv-2bb5ab07b7ee09fb7ae0e90a74c1e8e5adcc3d59.tar.bz2 mpv-2bb5ab07b7ee09fb7ae0e90a74c1e8e5adcc3d59.tar.xz |
stream: rearrange open functions
Add yet another variant of the stream open function. This time, make it
so that it's possible to add new open parameters in an extendable way,
which should put an end to having to change this every other year.
Effectively get rid of the overly special stream_create_instance()
function and use the new one instead, which requires changes in
stream_concat.c and stream_memory.c. The function is still in private in
stream.c, but I preferred to make the mentioned users go through the new
function for orthogonality. The error handling (mostly logging) was
adjusted accordingly.
This should not have any functional changes. (To preempt any excuses, I
didn't actually test stream_concat and stream_memory.)
Diffstat (limited to 'stream/stream.h')
-rw-r--r-- | stream/stream.h | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/stream/stream.h b/stream/stream.h index 62712503ed..87862f1acc 100644 --- a/stream/stream.h +++ b/stream/stream.h @@ -66,12 +66,13 @@ struct stream_avseek { }; struct stream; +struct stream_open_args; typedef struct stream_info_st { const char *name; // opts is set from ->opts int (*open)(struct stream *st); // Alternative to open(). Only either open() or open2() can be set. - int (*open2)(struct stream *st, void *arg); + int (*open2)(struct stream *st, struct stream_open_args *args); const char *const *protocols; bool can_write; // correctly checks for READ/WRITE modes bool is_safe; // opening is no security issue, even with remote provided URLs @@ -165,9 +166,17 @@ struct bstr stream_read_file(const char *filename, void *talloc_ctx, struct mpv_global *global, int max_size); int stream_control(stream_t *s, int cmd, void *arg); void free_stream(stream_t *s); -int stream_create_instance(const stream_info_t *sinfo, const char *url, int flags, - struct mp_cancel *c, struct mpv_global *global, - void *arg, struct stream **ret); + +struct stream_open_args { + struct mpv_global *global; + struct mp_cancel *cancel; // aborting stream access (used directly) + const char *url; + int flags; // STREAM_READ etc. + const stream_info_t *sinfo; // NULL = autoprobe, otherwise force stream impl. + void *special_arg; // specific to impl., use only with sinfo +}; + +int stream_create_with_args(struct stream_open_args *args, struct stream **ret); struct stream *stream_create(const char *url, int flags, struct mp_cancel *c, struct mpv_global *global); struct stream *stream_open(const char *filename, struct mpv_global *global); |