From: Michael Niedermayer Date: Wed, 12 Mar 2014 02:28:43 +0000 (+0100) Subject: Merge commit 'e58c85b0686892960042232e51c77168b264838a' X-Git-Tag: android-x86-6.0-r1~6751 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=c03af3ac1c4c865fdde5f57df6c2ccc646680f77;p=android-x86%2Fexternal-ffmpeg.git Merge commit 'e58c85b0686892960042232e51c77168b264838a' * commit 'e58c85b0686892960042232e51c77168b264838a': http: Export Content-Type information Conflicts: doc/protocols.texi libavformat/http.c See: 76d851b65619e5a0fe4cc5248a6858287fe890b4 See: 20899c54f03c413b225e8839a3c5318ab47abe55 See: 255ec768da6f6e821775888621da2156764598da Merged-by: Michael Niedermayer --- c03af3ac1c4c865fdde5f57df6c2ccc646680f77 diff --cc doc/protocols.texi index 5f6b118dc6,b16234b8fa..ee9e01193c --- a/doc/protocols.texi +++ b/doc/protocols.texi @@@ -216,39 -92,8 +216,39 @@@ HTTP (Hyper Text Transfer Protocol) This protocol accepts the following options: @table @option +@item seekable +Control seekability of connection. If set to 1 the resource is +supposed to be seekable, if set to 0 it is assumed not to be seekable, +if set to -1 it will try to autodetect if it is seekable. Default +value is -1. + +@item chunked_post +If set to 1 use chunked transfer-encoding for posts, default is 1. + +@item headers +Set custom HTTP headers, can override built in default headers. The +value must be a string encoding the headers. + +@item content_type +Force a content type. + +@item user-agent +Override User-Agent header. If not specified the protocol will use a +string describing the libavformat build. + +@item multiple_requests +Use persistent connections if set to 1. By default it is 0. + +@item post_data +Set custom HTTP post data. + +@item timeout +Set timeout of socket I/O operations used by the underlying low level +operation. By default it is set to -1, which means that the timeout is +not specified. + @item mime_type - Set MIME type. + Export the MIME type. @item icy If set to 1 request ICY (SHOUTcast) metadata from the server. If the server diff --cc libavformat/http.c index 95a64e4c9a,2edca73029..7c2b2bb5ee --- a/libavformat/http.c +++ b/libavformat/http.c @@@ -71,10 -69,6 +72,9 @@@ typedef struct int multiple_requests; uint8_t *post_data; int post_datalen; + int is_akamai; + int is_mediagateway; - char *mime_type; + char *cookies; ///< holds newline (\n) delimited Set-Cookie header field values (without the "Set-Cookie: " field name) int icy; /* how much data was read since the last ICY metadata packet */ int icy_data_read; @@@ -94,17 -88,12 +94,17 @@@ #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) static const AVOption options[] = { +{"seekable", "control seekability of connection", OFFSET(seekable), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, D }, {"chunked_post", "use chunked transfer-encoding for posts", OFFSET(chunked_post), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, E }, -{"headers", "custom HTTP headers, can override built in default headers", OFFSET(headers), AV_OPT_TYPE_STRING, { 0 }, 0, 0, D|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", "force a content type", 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 }, {"multiple_requests", "use persistent connections", OFFSET(multiple_requests), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, D|E }, -{"post_data", "custom HTTP post data", OFFSET(post_data), AV_OPT_TYPE_BINARY, .flags = D|E }, +{"post_data", "set custom HTTP post data", OFFSET(post_data), AV_OPT_TYPE_BINARY, .flags = D|E }, - {"mime_type", "set MIME type", OFFSET(mime_type), AV_OPT_TYPE_STRING, {0}, 0, 0, 0 }, + {"mime_type", "export the MIME type", OFFSET(mime_type), AV_OPT_TYPE_STRING, {0}, 0, 0, AV_OPT_FLAG_EXPORT | AV_OPT_FLAG_READONLY }, +{"cookies", "set cookies to be sent in applicable future requests, use newline delimited Set-Cookie HTTP field value syntax", OFFSET(cookies), AV_OPT_TYPE_STRING, {0}, 0, 0, D }, {"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 }, @@@ -483,28 -470,9 +483,29 @@@ static int process_line(URLContext *h, } else if (!av_strcasecmp(tag, "Connection")) { if (!strcmp(p, "close")) s->willclose = 1; + } else if (!av_strcasecmp (tag, "Server")) { + if (!av_strcasecmp (p, "AkamaiGHost")) { + s->is_akamai = 1; + } else if (!av_strncasecmp (p, "MediaGateway", 12)) { + s->is_mediagateway = 1; + } } else if (!av_strcasecmp (tag, "Content-Type")) { - av_free(s->mime_type); s->mime_type = av_strdup(p); + av_free(s->mime_type); + s->mime_type = av_strdup(p); + } else if (!av_strcasecmp (tag, "Set-Cookie")) { + if (!s->cookies) { + if (!(s->cookies = av_strdup(p))) + return AVERROR(ENOMEM); + } else { + char *tmp = s->cookies; + size_t str_size = strlen(tmp) + strlen(p) + 2; + if (!(s->cookies = av_malloc(str_size))) { + s->cookies = tmp; + return AVERROR(ENOMEM); + } + snprintf(s->cookies, str_size, "%s\n%s", tmp, p); + av_free(tmp); + } } else if (!av_strcasecmp (tag, "Icy-MetaInt")) { s->icy_metaint = strtoll(p, NULL, 10); } else if (!av_strncasecmp(tag, "Icy-", 4)) {