On 22/07/14 20:44, Diego Biurrun wrote:
> Also comment some #endifs and sort headers into canonical order.
> ---
> libavformat/http.c | 220
> +++++++++++++++++++++++++++--------------------------
> 1 file changed, 113 insertions(+), 107 deletions(-)
>
> diff --git a/libavformat/http.c b/libavformat/http.c
> index 6c390e8..9507f0d 100644
> --- a/libavformat/http.c
> +++ b/libavformat/http.c
> @@ -19,28 +19,30 @@
> * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
> USA
> */
>
> +#include "config.h"
> +
> +#if CONFIG_ZLIB
> +#include <zlib.h>
> +#endif /* CONFIG_ZLIB */
> +
> #include "libavutil/avstring.h"
> +#include "libavutil/opt.h"
> +
> #include "avformat.h"
> +#include "http.h"
> +#include "httpauth.h"
> #include "internal.h"
> #include "network.h"
> -#include "http.h"
> #include "os_support.h"
> -#include "httpauth.h"
> #include "url.h"
> -#include "libavutil/opt.h"
> -
> -#if CONFIG_ZLIB
> -#include <zlib.h>
> -#endif
>
> /* XXX: POST protocol is not completely implemented because avconv uses
> - only a subset of it. */
> + * only a subset of it. */
>
> /* The IO buffer size is unrelated to the max URL size in itself, but needs
> * to be large enough to fit the full request headers (including long
> - * path names).
> - */
> -#define BUFFER_SIZE MAX_URL_SIZE
> + * path names). */
> +#define BUFFER_SIZE MAX_URL_SIZE
> #define MAX_REDIRECTS 8
>
> typedef struct {
> @@ -82,37 +84,38 @@ typedef struct {
> int compressed;
> z_stream inflate_stream;
> uint8_t *inflate_buffer;
> -#endif
> +#endif /* CONFIG_ZLIB */
> AVDictionary *chained_options;
> int send_expect_100;
> char *method;
> } HTTPContext;
>
> -#define OFFSET(x) offsetof(HTTPContext, x)
> -#define D AV_OPT_FLAG_DECODING_PARAM
> -#define E AV_OPT_FLAG_ENCODING_PARAM
> +#define OFFSET(x) offsetof(HTTPContext, x)
> +#define D AV_OPT_FLAG_DECODING_PARAM
> +#define E AV_OPT_FLAG_ENCODING_PARAM
> #define DEFAULT_USER_AGENT "Lavf/" AV_STRINGIFY(LIBAVFORMAT_VERSION)
This hunk looks wrong this way, drop it.
> static const AVOption options[] = {
> -{"chunked_post", "use chunked transfer-encoding for posts",
> OFFSET(chunked_post), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, E },
> -{"headers", "set custom HTTP headers, can override built in default
> headers", OFFSET(headers), AV_OPT_TYPE_STRING, { 0 }, 0, 0, D|E },
> -{"content_type", "set a specific content type for the POST messages",
> OFFSET(content_type), AV_OPT_TYPE_STRING, { 0 }, 0, 0, D|E },
> -{"user_agent", "override User-Agent header", OFFSET(user_agent),
> AV_OPT_TYPE_STRING, {.str = DEFAULT_USER_AGENT}, 0, 0, D },
> -{"user-agent", "override User-Agent header, for compatibility with ffmpeg",
> OFFSET(user_agent), AV_OPT_TYPE_STRING, {.str = DEFAULT_USER_AGENT}, 0, 0, D
> },
> -{"multiple_requests", "use persistent connections",
> OFFSET(multiple_requests), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, D|E },
> -{"post_data", "set custom HTTP post data", OFFSET(post_data),
> AV_OPT_TYPE_BINARY, .flags = D|E },
> -{"mime_type", "export the MIME type", OFFSET(mime_type), AV_OPT_TYPE_STRING,
> {0}, 0, 0, AV_OPT_FLAG_EXPORT | AV_OPT_FLAG_READONLY },
> -{"icy", "request ICY metadata", OFFSET(icy), AV_OPT_TYPE_INT, {.i64 = 0}, 0,
> 1, D },
> -{"icy_metadata_headers", "return ICY metadata headers",
> OFFSET(icy_metadata_headers), AV_OPT_TYPE_STRING, {0}, 0, 0,
> AV_OPT_FLAG_EXPORT },
> -{"icy_metadata_packet", "return current ICY metadata packet",
> OFFSET(icy_metadata_packet), AV_OPT_TYPE_STRING, {0}, 0, 0,
> AV_OPT_FLAG_EXPORT },
> -{"auth_type", "HTTP authentication type", OFFSET(auth_state.auth_type),
> AV_OPT_TYPE_INT, {.i64 = HTTP_AUTH_NONE}, HTTP_AUTH_NONE, HTTP_AUTH_BASIC,
> D|E, "auth_type" },
> -{"none", "No auth method set, autodetect", 0, AV_OPT_TYPE_CONST, {.i64 =
> HTTP_AUTH_NONE}, 0, 0, D|E, "auth_type" },
> -{"basic", "HTTP basic authentication", 0, AV_OPT_TYPE_CONST, {.i64 =
> HTTP_AUTH_BASIC}, 0, 0, D|E, "auth_type" },
> -{"send_expect_100", "Force sending an Expect: 100-continue header for POST",
> OFFSET(send_expect_100), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, E },
> -{"location", "The actual location of the data received", OFFSET(location),
> AV_OPT_TYPE_STRING, { 0 }, 0, 0, D|E },
> -{"offset", "initial byte offset", OFFSET(off), AV_OPT_TYPE_INT64, {.i64 =
> 0}, 0, INT64_MAX, D },
> -{"end_offset", "try to limit the request to bytes preceding this offset",
> OFFSET(end_off), AV_OPT_TYPE_INT64, {.i64 = 0}, 0, INT64_MAX, D },
> -{"method", "Override the HTTP method", OFFSET(method), AV_OPT_TYPE_STRING, {
> .str = NULL }, 0, 0, E, },
> -{NULL}
> + { "chunked_post", "use chunked transfer-encoding for posts",
> OFFSET(chunked_post), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, E },
> + { "headers", "set custom HTTP headers, can override built in default
> headers", OFFSET(headers), AV_OPT_TYPE_STRING, { 0 }, 0, 0, D | E },
> + { "content_type", "set a specific content type for the POST messages",
> OFFSET(content_type), AV_OPT_TYPE_STRING, { 0 }, 0, 0, D | E },
> + { "user_agent", "override User-Agent header", OFFSET(user_agent),
> AV_OPT_TYPE_STRING, { .str = DEFAULT_USER_AGENT }, 0, 0, D },
> + { "user-agent", "override User-Agent header, for compatibility with
> ffmpeg", OFFSET(user_agent), AV_OPT_TYPE_STRING, { .str = DEFAULT_USER_AGENT
> }, 0, 0, D },
> + { "multiple_requests", "use persistent connections",
> OFFSET(multiple_requests), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, D | E },
> + { "post_data", "set custom HTTP post data", OFFSET(post_data),
> AV_OPT_TYPE_BINARY, .flags = D | E },
> + { "mime_type", "export the MIME type", OFFSET(mime_type),
> AV_OPT_TYPE_STRING, { 0 }, 0, 0, AV_OPT_FLAG_EXPORT | AV_OPT_FLAG_READONLY },
> + { "icy", "request ICY metadata", OFFSET(icy), AV_OPT_TYPE_INT, { .i64 =
> 0 }, 0, 1, D },
> + { "icy_metadata_headers", "return ICY metadata headers",
> OFFSET(icy_metadata_headers), AV_OPT_TYPE_STRING, { 0 }, 0, 0,
> AV_OPT_FLAG_EXPORT },
> + { "icy_metadata_packet", "return current ICY metadata packet",
> OFFSET(icy_metadata_packet), AV_OPT_TYPE_STRING, { 0 }, 0, 0,
> AV_OPT_FLAG_EXPORT },
> + { "auth_type", "HTTP authentication type", OFFSET(auth_state.auth_type),
> AV_OPT_TYPE_INT, { .i64 = HTTP_AUTH_NONE }, HTTP_AUTH_NONE, HTTP_AUTH_BASIC,
> D | E, "auth_type"},
> + { "none", "No auth method set, autodetect", 0, AV_OPT_TYPE_CONST, { .i64
> = HTTP_AUTH_NONE }, 0, 0, D | E, "auth_type"},
> + { "basic", "HTTP basic authentication", 0, AV_OPT_TYPE_CONST, { .i64 =
> HTTP_AUTH_BASIC }, 0, 0, D | E, "auth_type"},
> + { "send_expect_100", "Force sending an Expect: 100-continue header for
> POST", OFFSET(send_expect_100), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, E },
> + { "location", "The actual location of the data received",
> OFFSET(location), AV_OPT_TYPE_STRING, { 0 }, 0, 0, D | E },
> + { "offset", "initial byte offset", OFFSET(off), AV_OPT_TYPE_INT64, {
> .i64 = 0 }, 0, INT64_MAX, D },
> + { "end_offset", "try to limit the request to bytes preceding this
> offset", OFFSET(end_off), AV_OPT_TYPE_INT64, { .i64 = 0 }, 0, INT64_MAX, D },
> + { "method", "Override the HTTP method", OFFSET(method),
> AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, E },
> + { NULL }
> };
>
> static int http_connect(URLContext *h, const char *path, const char
> *local_path,
> @@ -121,10 +124,11 @@ static int http_connect(URLContext *h, const char
> *path, const char *local_path,
>
> void ff_http_init_auth_state(URLContext *dest, const URLContext *src)
> {
> - memcpy(&((HTTPContext*)dest->priv_data)->auth_state,
> - &((HTTPContext*)src->priv_data)->auth_state,
> sizeof(HTTPAuthState));
> - memcpy(&((HTTPContext*)dest->priv_data)->proxy_auth_state,
> - &((HTTPContext*)src->priv_data)->proxy_auth_state,
> + memcpy(&((HTTPContext *) dest->priv_data)->auth_state,
> + &((HTTPContext *) src->priv_data)->auth_state,
> + sizeof(HTTPAuthState));
> + memcpy(&((HTTPContext *) dest->priv_data)->proxy_auth_state,
> + &((HTTPContext *) src->priv_data)->proxy_auth_state,
> sizeof(HTTPAuthState));
Drop the space between the cast, it is against the coding style.
The rest looks fine to me.
lu
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel