diff mbox

[FFmpeg-devel,1/2] avformat/avio: add av_urlcontext_get_class_by_name

Message ID 20191126112652.31350-1-lq@chinaffmpeg.org
State New
Headers show

Commit Message

Liu Steven Nov. 26, 2019, 11:26 a.m. UTC
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
 doc/APIchanges          |  3 +++
 libavformat/avio.h      |  8 ++++++++
 libavformat/protocols.c | 10 ++++++++++
 libavformat/version.h   |  2 +-
 4 files changed, 22 insertions(+), 1 deletion(-)

Comments

Andriy Gelman Nov. 26, 2019, 12:23 p.m. UTC | #1
On Tue, 26. Nov 19:26, Steven Liu wrote:
> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
> ---
>  doc/APIchanges          |  3 +++
>  libavformat/avio.h      |  8 ++++++++
>  libavformat/protocols.c | 10 ++++++++++
>  libavformat/version.h   |  2 +-
>  4 files changed, 22 insertions(+), 1 deletion(-)
> 
> diff --git a/doc/APIchanges b/doc/APIchanges
> index 401c65a753..39896146d3 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -15,6 +15,9 @@ libavutil:     2017-10-21
>  
>  API changes, most recent first:
>  
> +2019-11-26 - xxxxxxxxxx - lavf 58.26.100 - avio.h
> +  Add av_urlcontext_get_class_by_name().
> +
>  2019-11-17 - 1c23abc88f - lavu 56.36.100 - eval API
>    Add av_expr_count_vars().
>  
> diff --git a/libavformat/avio.h b/libavformat/avio.h
> index 9141642e75..bf8cf120f2 100644
> --- a/libavformat/avio.h
> +++ b/libavformat/avio.h
> @@ -807,6 +807,14 @@ int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer);
>   */
>  const char *avio_enum_protocols(void **opaque, int output);
>  
> +/**
> + * Get AVClass by names of available protocols.
> + *

> + * @param name protocol name

extra name   ^
Nicolas George Nov. 26, 2019, 12:35 p.m. UTC | #2
Andriy Gelman (12019-11-26):
> > + * @param name protocol name
> extra name   ^

No, it is the normal pattern, to mean "the variable 'name' is the name
of the protocol".

But it is indeed a completely useless precision, much like the infamous
"to print, use the print menu".

Regards,
Liu Steven Nov. 26, 2019, 2:23 p.m. UTC | #3
> 在 2019年11月26日,下午8:35,Nicolas George <george@nsup.org> 写道:
> 
> Andriy Gelman (12019-11-26):
>>> + * @param name protocol name
>> extra name   ^
> 
> No, it is the normal pattern, to mean "the variable 'name' is the name
> of the protocol".
> 
> But it is indeed a completely useless precision, much like the infamous
> "to print, use the print menu”.
Hi Nicolas,
	What should i do next step? remove the comment of the parameter? or just looks good?
> 
> Regards,
> 
> -- 
>  Nicolas George

Thanks
Steven
Nicolas George Nov. 26, 2019, 2:32 p.m. UTC | #4
Liu Steven (12019-11-26):
> 	What should i do next step? remove the comment of the parameter? or just looks good?

My opinion is to remove the comment because it brings nothing.

Regards,
Hendrik Leppkes Nov. 26, 2019, 2:51 p.m. UTC | #5
On Tue, Nov 26, 2019 at 12:27 PM Steven Liu <lq@chinaffmpeg.org> wrote:
>
> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
> ---
>  doc/APIchanges          |  3 +++
>  libavformat/avio.h      |  8 ++++++++
>  libavformat/protocols.c | 10 ++++++++++
>  libavformat/version.h   |  2 +-
>  4 files changed, 22 insertions(+), 1 deletion(-)
>
> diff --git a/doc/APIchanges b/doc/APIchanges
> index 401c65a753..39896146d3 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -15,6 +15,9 @@ libavutil:     2017-10-21
>
>  API changes, most recent first:
>
> +2019-11-26 - xxxxxxxxxx - lavf 58.26.100 - avio.h
> +  Add av_urlcontext_get_class_by_name().
> +
>  2019-11-17 - 1c23abc88f - lavu 56.36.100 - eval API
>    Add av_expr_count_vars().
>
> diff --git a/libavformat/avio.h b/libavformat/avio.h
> index 9141642e75..bf8cf120f2 100644
> --- a/libavformat/avio.h
> +++ b/libavformat/avio.h
> @@ -807,6 +807,14 @@ int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer);
>   */
>  const char *avio_enum_protocols(void **opaque, int output);
>
> +/**
> + * Get AVClass by names of available protocols.
> + *
> + * @param name protocol name
> + * @return A AVClass of input protocol name or NULL
> + */
> +const AVClass *av_urlcontext_get_class_by_name(const char *name);
> +

The function should probably follow naming similar to the other
functions in that file,  use avio_protocol as a prefix, not
urlcontext, so eg. avio_protocol_get_class_by_name (or perhaps even
drop the by_name part)

- Hendrik
diff mbox

Patch

diff --git a/doc/APIchanges b/doc/APIchanges
index 401c65a753..39896146d3 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,9 @@  libavutil:     2017-10-21
 
 API changes, most recent first:
 
+2019-11-26 - xxxxxxxxxx - lavf 58.26.100 - avio.h
+  Add av_urlcontext_get_class_by_name().
+
 2019-11-17 - 1c23abc88f - lavu 56.36.100 - eval API
   Add av_expr_count_vars().
 
diff --git a/libavformat/avio.h b/libavformat/avio.h
index 9141642e75..bf8cf120f2 100644
--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -807,6 +807,14 @@  int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer);
  */
 const char *avio_enum_protocols(void **opaque, int output);
 
+/**
+ * Get AVClass by names of available protocols.
+ *
+ * @param name protocol name
+ * @return A AVClass of input protocol name or NULL
+ */
+const AVClass *av_urlcontext_get_class_by_name(const char *name);
+
 /**
  * Pause and resume playing - only meaningful if using a network streaming
  * protocol (e.g. MMS).
diff --git a/libavformat/protocols.c b/libavformat/protocols.c
index face5b29b5..512cdd6d2e 100644
--- a/libavformat/protocols.c
+++ b/libavformat/protocols.c
@@ -107,6 +107,16 @@  const char *avio_enum_protocols(void **opaque, int output)
     return avio_enum_protocols(opaque, output);
 }
 
+const AVClass *av_urlcontext_get_class_by_name(const char *name)
+{
+    int i = 0;
+    for (i = 0; url_protocols[i]; i++) {
+        if (!strcmp(url_protocols[i]->name, name))
+            return url_protocols[i]->priv_data_class;
+    }
+    return NULL;
+}
+
 const URLProtocol **ffurl_get_protocols(const char *whitelist,
                                         const char *blacklist)
 {
diff --git a/libavformat/version.h b/libavformat/version.h
index bac54aed9d..f72fb9478a 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -32,7 +32,7 @@ 
 // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium)
 // Also please add any ticket numbers that you believe might be affected here
 #define LIBAVFORMAT_VERSION_MAJOR  58
-#define LIBAVFORMAT_VERSION_MINOR  35
+#define LIBAVFORMAT_VERSION_MINOR  36
 #define LIBAVFORMAT_VERSION_MICRO 100
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \