[FFmpeg-devel] [PATCH] Private options for url protocols

Stefano Sabatini stefasab at gmail.com
Tue Nov 15 01:42:46 CET 2011


On date Thursday 2011-11-10 17:56:11 +0100, Michael Niedermayer encoded:
> Hi
> 
> Attached patchset implemets subj
> Comments welcome, ill probably push it tomorrow if there are no
> objections
> 
> An example of how useage would look is:
> ffplay http,user-agent=JustTesting://samples.multimedia.cx/MPEG2/test422.m2v
> 
> the syntax would also work for nested protocols ...
> 
> -- 
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> 
> No human being will ever know the Truth, for even if they happen to say it
> by chance, they would not even known they had done so. -- Xenophanes

> From d300a9c6a787827dbe2d86a1b330b8aba830bcc7 Mon Sep 17 00:00:00 2001
> From: Michael Niedermayer <michaelni at gmx.at>
> Date: Thu, 10 Nov 2011 17:02:02 +0100
> Subject: [PATCH 1/2] avio: allow any chars in protocols
> 
> Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> ---
>  libavformat/avio.c |    6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/libavformat/avio.c b/libavformat/avio.c
> index 47b2d51..f08cbab 100644
> --- a/libavformat/avio.c
> +++ b/libavformat/avio.c
> @@ -221,17 +221,17 @@ int ffurl_alloc(URLContext **puc, const char *filename, int flags)
>  {
>      URLProtocol *up;
>      char proto_str[128], proto_nested[128], *ptr;
> -    size_t proto_len = strspn(filename, URL_SCHEME_CHARS);
> +    const char *proto_end = strchr(filename, ':');

uhmm... what if you have ":" in the options? e.g.:
ffplay http,user-agent=::the_bloody_user_agent::://samples.multimedia.cx/MPEG2/test422.m2v

I still find the lack of defined namespaces for the options a big
issue, but I can't say what would be a good way of setting this,
maybe:
-proto_opts=user_agent=... http://...

yes that would be inconsistent...

>      if (!first_protocol) {
>          av_log(NULL, AV_LOG_WARNING, "No URL Protocols are registered. "
>                                       "Missing call to av_register_all()?\n");
>      }
>  
> -    if (filename[proto_len] != ':' || is_dos_path(filename))
> +    if (!proto_end || is_dos_path(filename))
>          strcpy(proto_str, "file");
>      else
> -        av_strlcpy(proto_str, filename, FFMIN(proto_len+1, sizeof(proto_str)));
> +        av_strlcpy(proto_str, filename, FFMIN(proto_end-filename+1, sizeof(proto_str)));
>  
>      av_strlcpy(proto_nested, proto_str, sizeof(proto_nested));
>      if ((ptr = strchr(proto_nested, '+')))
> -- 
> 1.7.4.1
> 

> From fbee6fa7eb68c87f5df51849e046904c9113a23d Mon Sep 17 00:00:00 2001
> From: Michael Niedermayer <michaelni at gmx.at>
> Date: Thu, 10 Nov 2011 04:34:35 +0100
> Subject: [PATCH 2/2] avio: Support private options in URLProtocols
> 
> Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> ---
>  libavformat/avio.c |   10 ++++++++++
>  1 files changed, 10 insertions(+), 0 deletions(-)
> 
> diff --git a/libavformat/avio.c b/libavformat/avio.c
> index f08cbab..bb7660a 100644
> --- a/libavformat/avio.c
> +++ b/libavformat/avio.c
> @@ -108,8 +108,16 @@ static int url_alloc_for_protocol (URLContext **puc, struct URLProtocol *up,
>      if (up->priv_data_size) {
>          uc->priv_data = av_mallocz(up->priv_data_size);
>          if (up->priv_data_class) {
> +            char *p, *p2;
>              *(const AVClass**)uc->priv_data = up->priv_data_class;
>              av_opt_set_defaults(uc->priv_data);
> +            if((p2=uc->filename+strcspn(uc->filename, ":+")) && *p2 && (p=strchr(uc->filename, ',')) && p<p2){
> +                int term= *p2;
> +                *p2++= 0;
> +                av_set_options_string(uc->priv_data, p+1, "=", ",");

maybe you should check&abort for errors here
[...]
-- 
FFmpeg = Fierce Fast Merciless Purposeless Embarassing Gangster


More information about the ffmpeg-devel mailing list