[1/3] http: Add encoding/decoding flags to the AVOptions

Message ID 1320916777-57324-1-git-send-email-martin@martin.st
State Committed
Headers show

Commit Message

Martin Storsjö Nov. 10, 2011, 9:19 a.m.
From: Anton Khirnov <anton@khirnov.net>

---
 libavformat/http.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

Comments

Anton Khirnov Nov. 10, 2011, 10:43 a.m. | #1
On Thu, 10 Nov 2011 11:19:35 +0200, Martin Storsjö <martin@martin.st> wrote:
> From: Anton Khirnov <anton@khirnov.net>
> 
> ---
>  libavformat/http.c |    6 ++++--
>  1 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/libavformat/http.c b/libavformat/http.c
> index 783ac6a..6458c5b 100644
> --- a/libavformat/http.c
> +++ b/libavformat/http.c
> @@ -52,9 +52,11 @@ typedef struct {
>  } HTTPContext;
>  
>  #define OFFSET(x) offsetof(HTTPContext, x)
> +#define D AV_OPT_FLAG_DECODING_PARAM
> +#define E AV_OPT_FLAG_ENCODING_PARAM
>  static const AVOption options[] = {
> -{"chunksize", "use chunked transfer-encoding for posts, -1 disables it, 0 enables it", OFFSET(chunksize), AV_OPT_TYPE_INT64, {.dbl = 0}, -1, 0 }, /* Default to 0, for chunked POSTs */
> -{"headers", "custom HTTP headers, can override built in default headers", OFFSET(headers), AV_OPT_TYPE_STRING },
> +{"chunksize", "use chunked transfer-encoding for posts, -1 disables it, 0 enables it", OFFSET(chunksize), AV_OPT_TYPE_INT64, {.dbl = 0}, -1, 0, E }, /* Default to 0, for chunked POSTs */
> +{"headers", "custom HTTP headers, can override built in default headers", OFFSET(headers), AV_OPT_TYPE_STRING, { 0 }, 0, 0, D|E },

Ok.

Using .flags = D|E instead of those dummy 0s would be shorter, but
whatever you prefer.

Patch

diff --git a/libavformat/http.c b/libavformat/http.c
index 783ac6a..6458c5b 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -52,9 +52,11 @@  typedef struct {
 } HTTPContext;
 
 #define OFFSET(x) offsetof(HTTPContext, x)
+#define D AV_OPT_FLAG_DECODING_PARAM
+#define E AV_OPT_FLAG_ENCODING_PARAM
 static const AVOption options[] = {
-{"chunksize", "use chunked transfer-encoding for posts, -1 disables it, 0 enables it", OFFSET(chunksize), AV_OPT_TYPE_INT64, {.dbl = 0}, -1, 0 }, /* Default to 0, for chunked POSTs */
-{"headers", "custom HTTP headers, can override built in default headers", OFFSET(headers), AV_OPT_TYPE_STRING },
+{"chunksize", "use chunked transfer-encoding for posts, -1 disables it, 0 enables it", OFFSET(chunksize), AV_OPT_TYPE_INT64, {.dbl = 0}, -1, 0, E }, /* Default to 0, for chunked POSTs */
+{"headers", "custom HTTP headers, can override built in default headers", OFFSET(headers), AV_OPT_TYPE_STRING, { 0 }, 0, 0, D|E },
 {NULL}
 };
 static const AVClass httpcontext_class = {