[FFmpeg-devel] [PATCH 1/2] avformat/url.h add av_find_protocol_by_name for find URLProtocol by name

Andreas Rheinhardt andreas.rheinhardt at gmail.com
Fri Nov 22 11:05:00 EET 2019


Steven Liu:
> Signed-off-by: Steven Liu <lq at chinaffmpeg.org>
> ---
>  doc/APIchanges          |  3 +++
>  libavformat/protocols.c | 16 ++++++++++++++++
>  libavformat/url.h       |  9 +++++++++
>  libavformat/version.h   |  2 +-
>  4 files changed, 29 insertions(+), 1 deletion(-)
> 
> diff --git a/doc/APIchanges b/doc/APIchanges
> index 401c65a753..804a57de41 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -15,6 +15,9 @@ libavutil:     2017-10-21
>  
>  API changes, most recent first:
>  
> +2019-11-22 - xxxxxxxxxx - lavf 58.35.101 - url.h
> +  Add av_find_protocol_by_name().
> +
>  2019-11-17 - 1c23abc88f - lavu 56.36.100 - eval API
>    Add av_expr_count_vars().
>  
> diff --git a/libavformat/protocols.c b/libavformat/protocols.c
> index face5b29b5..d4dee23a8e 100644
> --- a/libavformat/protocols.c
> +++ b/libavformat/protocols.c
> @@ -107,6 +107,22 @@ const char *avio_enum_protocols(void **opaque, int output)
>      return avio_enum_protocols(opaque, output);
>  }
>  
> +const URLProtocol *av_find_protocol_by_name(const char *name)
> +{
> +    int i = 0;
> +    const URLProtocol **protocols;
> +    protocols = ffurl_get_protocols(NULL, NULL);

You should not call ffurl_get_protocols as you don't use its
functionality (namely filtering out unwanted protocols). Instead you
should simply directly search the list yourself. This way you won't
have to free anything.

- Andreas


More information about the ffmpeg-devel mailing list