diff options
Diffstat (limited to 'stream')
-rw-r--r-- | stream/stream.c | 79 | ||||
-rw-r--r-- | stream/stream.h | 13 |
2 files changed, 0 insertions, 92 deletions
diff --git a/stream/stream.c b/stream/stream.c index ed7697e9c6..d5cf747b1e 100644 --- a/stream/stream.c +++ b/stream/stream.c @@ -183,65 +183,6 @@ char *mp_url_escape(void *talloc_ctx, const char *s, const char *ok) return buf; } -static const char *find_url_opt(struct stream *s, const char *opt) -{ - for (int n = 0; s->info->url_options && s->info->url_options[n]; n++) { - const char *entry = s->info->url_options[n]; - const char *t = strchr(entry, '='); - assert(t); - if (strncmp(opt, entry, t - entry) == 0) - return t + 1; - } - return NULL; -} - -static bstr split_next(bstr *s, char end, const char *delim) -{ - int idx = bstrcspn(*s, delim); - if (end && (idx >= s->len || s->start[idx] != end)) - return (bstr){0}; - bstr r = bstr_splice(*s, 0, idx); - *s = bstr_cut(*s, idx + (end ? 1 : 0)); - return r; -} - -// Parse the stream URL, syntax: -// proto:// [<username>@]<hostname>[:<port>][/<filename>] -// (the proto:// part is assumed to be already removed from s) -// This code originates from times when http code used this, but now it's -// just relict from other stream implementations reusing this code. -void mp_parse_legacy_url(bstr s, bstr c[4]) -{ - c[0] = split_next(&s, '@', "@:/"); - c[1] = split_next(&s, 0, ":/"); - c[2] = bstr_eatstart0(&s, ":") ? split_next(&s, 0, "/") : (bstr){0}; - c[3] = bstr_eatstart0(&s, "/") ? s : (bstr){0}; -} - -static bool parse_url(struct stream *st, struct m_config *config) -{ - bstr f[4]; - mp_parse_legacy_url(bstr0(st->path), f); - const char *f_names[4] = {"username", "hostname", "port", "filename"}; - for (int n = 0; n < 4; n++) { - if (f[n].len) { - const char *opt = find_url_opt(st, f_names[n]); - if (!opt) { - MP_ERR(st, "Stream type '%s' accepts no '%s' field in URLs.\n", - st->info->name, f_names[n]); - return false; - } - int r = m_config_set_option(config, bstr0(opt), f[n]); - if (r < 0) { - MP_ERR(st, "Error setting stream option: %s\n", - m_option_strerror(r)); - return false; - } - } - } - return true; -} - static stream_t *new_stream(void) { return talloc_zero_size(NULL, sizeof(stream_t) + TOTAL_BUFFER_SIZE); @@ -284,7 +225,6 @@ static int open_internal(const stream_info_t *sinfo, const char *url, int flags, stream_t *s = new_stream(); s->log = mp_log_new(s, global->log, sinfo->name); s->info = sinfo; - s->opts = global->opts; s->cancel = c; s->global = global; s->url = talloc_strdup(s, url); @@ -301,24 +241,6 @@ static int open_internal(const stream_info_t *sinfo, const char *url, int flags, return STREAM_NO_MATCH; } - // Parse options - if (sinfo->priv_size) { - struct m_obj_desc desc = { - .priv_size = sinfo->priv_size, - .priv_defaults = sinfo->priv_defaults, - .options = sinfo->options, - }; - if (sinfo->get_defaults) - desc.priv_defaults = sinfo->get_defaults(s); - struct m_config *config = m_config_from_obj_desc(s, s->log, &desc); - s->priv = config->optstruct; - if (s->info->url_options && !parse_url(s, config)) { - MP_ERR(s, "URL parsing failed on url %s\n", url); - talloc_free(s); - return STREAM_ERROR; - } - } - int r = (sinfo->open)(s); if (r != STREAM_OK) { talloc_free(s); @@ -757,7 +679,6 @@ static stream_t *open_cache(stream_t *orig, const char *name) cache->lavf_type = talloc_strdup(cache, orig->lavf_type); cache->streaming = orig->streaming, cache->is_network = orig->is_network; - cache->opts = orig->opts; cache->cancel = orig->cancel; cache->global = orig->global; diff --git a/stream/stream.h b/stream/stream.h index 90545da087..4444da8ed3 100644 --- a/stream/stream.h +++ b/stream/stream.h @@ -157,11 +157,6 @@ typedef struct stream_info_st { // opts is set from ->opts int (*open)(struct stream *st); const char *const *protocols; - int priv_size; - const void *priv_defaults; - void *(*get_defaults)(struct stream *st); - const struct m_option *options; - const char *const *url_options; bool can_write; // correctly checks for READ/WRITE modes bool is_safe; // opening is no security issue, even with remote provided URLs bool is_network; // used to restrict remote playlist entries to remote URLs @@ -203,7 +198,6 @@ typedef struct stream { bool is_network : 1; // original stream_info_t.is_network flag bool allow_caching : 1; // stream cache makes sense struct mp_log *log; - struct MPOpts *opts; struct mpv_global *global; struct mp_cancel *cancel; // cancellation notification @@ -296,13 +290,6 @@ void mp_setup_av_network_options(struct AVDictionary **dict, struct mpv_global *global, struct mp_log *log); -// sort-of legacy handling of options-in-stream-URL -#define URL_USERNAME 0 -#define URL_HOSTNAME 1 -#define URL_PORT 2 -#define URL_FILENAME 3 -void mp_parse_legacy_url(bstr url, bstr components[4]); - void stream_print_proto_list(struct mp_log *log); char **stream_get_proto_list(void); bool stream_has_proto(const char *proto); |