diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-08-13 22:47:35 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-08-13 22:52:53 +0200 |
commit | 69a5cd9feac5382c378ff1613f586b37f34d8961 (patch) | |
tree | cd150a2eee6fac15bcd4871c16f7c6def1e9d4ec | |
parent | 2ba45778095cdd6e1438644e4797b76e9de6c672 (diff) | |
parent | 7601f9412a2d3387617a45966b65b452a632c27a (diff) | |
download | ffmpeg-69a5cd9feac5382c378ff1613f586b37f34d8961.tar.gz |
Merge commit '7601f9412a2d3387617a45966b65b452a632c27a'
* commit '7601f9412a2d3387617a45966b65b452a632c27a':
http: export icecast metadata as an option with name "metadata".
Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavformat/http.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/libavformat/http.c b/libavformat/http.c index a9f1700f2d..10c7c91f53 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -84,6 +84,7 @@ typedef struct { int icy_metaint; char *icy_metadata_headers; char *icy_metadata_packet; + AVDictionary *metadata; #if CONFIG_ZLIB int compressed; z_stream inflate_stream; @@ -113,6 +114,7 @@ static const AVOption options[] = { { "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 }, + { "metadata", "metadata read from the bitstream", OFFSET(metadata), AV_OPT_TYPE_DICT, {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"}, @@ -426,6 +428,8 @@ static int parse_icy(HTTPContext *s, const char *tag, const char *p) int is_first = !s->icy_metadata_headers; int ret; + av_dict_set(&s->metadata, tag, p, 0); + if (s->icy_metadata_headers) len += strlen(s->icy_metadata_headers); @@ -941,6 +945,32 @@ static int http_read_stream_all(URLContext *h, uint8_t *buf, int size) return pos; } +static void update_metadata(HTTPContext *s, char *data) +{ + char *key; + char *val; + char *end; + char *next = data; + + while (*next) { + key = next; + val = strstr(key, "='"); + if (!val) + break; + end = strstr(val, "';"); + if (!end) + break; + + *val = '\0'; + *end = '\0'; + val += 2; + + av_dict_set(&s->metadata, key, val, 0); + + next = end + 2; + } +} + static int store_icy(URLContext *h, int size) { HTTPContext *s = h->priv_data; @@ -969,6 +999,7 @@ static int store_icy(URLContext *h, int size) data[len + 1] = 0; if ((ret = av_opt_set(s, "icy_metadata_packet", data, 0)) < 0) return ret; + update_metadata(s, data); } s->icy_data_read = 0; remaining = s->icy_metaint; |