OSDN Git Service

Merge commit 'e58c85b0686892960042232e51c77168b264838a'
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 12 Mar 2014 02:28:43 +0000 (03:28 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 12 Mar 2014 02:33:14 +0000 (03:33 +0100)
* commit 'e58c85b0686892960042232e51c77168b264838a':
  http: Export Content-Type information

Conflicts:
doc/protocols.texi
libavformat/http.c

See: 76d851b65619e5a0fe4cc5248a6858287fe890b4
See: 20899c54f03c413b225e8839a3c5318ab47abe55
See: 255ec768da6f6e821775888621da2156764598da
Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
doc/protocols.texi
libavformat/http.c

@@@ -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
@@@ -71,10 -69,6 +72,9 @@@ typedef struct 
      int multiple_requests;
      uint8_t *post_data;
      int post_datalen;
-     char *mime_type;
 +    int is_akamai;
 +    int is_mediagateway;
 +    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;
  #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)) {