[FFmpeg-devel] [PATCH] avformat/http: Documented http_proxy option
--- doc/protocols.texi | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/protocols.texi b/doc/protocols.texi index 7c6b9d4..8b2e310 100644 --- a/doc/protocols.texi +++ b/doc/protocols.texi @@ -240,6 +240,9 @@ If set to 1 use chunked Transfer-Encoding for posts, default is 1. @item content_type Set a specific content type for the POST messages. +@item http_proxy +set HTTP proxy to tunnel through e.g. http://example.com:1234 + @item headers Set custom HTTP headers, can override built in default headers. The value must be a string encoding the headers. -- 1.9.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 2/3] avformat/hls: Remember to free HLSContext::headers
--- libavformat/hls.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/hls.c b/libavformat/hls.c index 2d4ee13..82d5410 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -256,6 +256,7 @@ static void free_playlist_list(HLSContext *c) av_freep(&c->playlists); av_freep(&c->cookies); av_freep(&c->user_agent); +av_freep(&c->headers); c->n_playlists = 0; } -- 1.9.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH v2] Added support for http_proxy
Previously, avformat/http only supported http proxy servers via the http_proxy environment variable. This patch series add support for an "http_proxy" option in avformat/http, which enables per-stream tunnelling through an HTTP proxy server. This has applications within Kodi, where per-stream proxying is an often needed feature. Additionally, this patch set adds http_proxy support to avformat/hls, and fixes a minor memory leak. v2: Fixed http_proxy option label. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 1/3] avformat/http: Added http_proxy option
--- libavformat/http.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavformat/http.c b/libavformat/http.c index 2230442..a1f1807 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -67,6 +67,7 @@ typedef struct HTTPContext { char *location; HTTPAuthState auth_state; HTTPAuthState proxy_auth_state; +char *http_proxy; char *headers; char *mime_type; char *user_agent; @@ -126,6 +127,7 @@ typedef struct HTTPContext { static const AVOption options[] = { { "seekable", "control seekability of connection", OFFSET(seekable), AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1, D }, { "chunked_post", "use chunked transfer-encoding for posts", OFFSET(chunked_post), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, E }, +{ "http_proxy", "set HTTP proxy to tunnel through", OFFSET(http_proxy), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, D | E }, { "headers", "set custom HTTP headers, can override built in default headers", OFFSET(headers), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, D | E }, { "content_type", "set a specific content type for the POST messages", OFFSET(content_type), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, D | E }, { "user_agent", "override User-Agent header", OFFSET(user_agent), AV_OPT_TYPE_STRING, { .str = DEFAULT_USER_AGENT }, 0, 0, D }, @@ -186,7 +188,7 @@ static int http_open_cnx_internal(URLContext *h, AVDictionary **options) path1, sizeof(path1), s->location); ff_url_join(hoststr, sizeof(hoststr), NULL, NULL, hostname, port, NULL); -proxy_path = getenv("http_proxy"); +proxy_path = s->http_proxy ? s->http_proxy : getenv("http_proxy"); use_proxy = !ff_http_match_no_proxy(getenv("no_proxy"), hostname) && proxy_path && av_strstart(proxy_path, "http://";, NULL); -- 1.9.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 3/3] avformat/hls: Added http_proxy support
--- libavformat/hls.c | 11 ++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libavformat/hls.c b/libavformat/hls.c index 82d5410..9ced13b 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -196,6 +196,7 @@ typedef struct HLSContext { char *user_agent;///< holds HTTP user agent set as an AVOption to the HTTP protocol context char *cookies; ///< holds HTTP cookie values set in either the initial response or as an AVOption to the HTTP protocol context char *headers; ///< holds HTTP headers set as an AVOption to the HTTP protocol context +char *http_proxy;///< holds the address of the HTTP proxy server AVDictionary *avio_opts; int strict_std_compliance; } HLSContext; @@ -257,6 +258,7 @@ static void free_playlist_list(HLSContext *c) av_freep(&c->cookies); av_freep(&c->user_agent); av_freep(&c->headers); +av_freep(&c->http_proxy); c->n_playlists = 0; } @@ -655,6 +657,7 @@ static int parse_playlist(HLSContext *c, const char *url, av_dict_set(&opts, "user-agent", c->user_agent, 0); av_dict_set(&opts, "cookies", c->cookies, 0); av_dict_set(&opts, "headers", c->headers, 0); +av_dict_set(&opts, "http_proxy", c->http_proxy, 0); ret = avio_open2(&in, url, AVIO_FLAG_READ, c->interrupt_callback, &opts); @@ -1068,6 +1071,7 @@ static int open_input(HLSContext *c, struct playlist *pls, struct segment *seg) av_dict_set(&opts, "user-agent", c->user_agent, 0); av_dict_set(&opts, "cookies", c->cookies, 0); av_dict_set(&opts, "headers", c->headers, 0); +av_dict_set(&opts, "http_proxy", c->http_proxy, 0); av_dict_set(&opts, "seekable", "0", 0); if (seg->size >= 0) { @@ -1468,7 +1472,9 @@ static int select_cur_seq_no(HLSContext *c, struct playlist *pls) static int save_avio_options(AVFormatContext *s) { HLSContext *c = s->priv_data; -const char *opts[] = { "headers", "user_agent", "user-agent", "cookies", NULL }, **opt = opts; +const char *opts[] = { + "headers", "http_proxy", "user_agent", "user-agent", "cookies", NULL }; +const char **opt = opts; uint8_t *buf; int ret = 0; @@ -1508,6 +1514,9 @@ static int hls_read_header(AVFormatContext *s) // get the previous headers & set back to null if string size is zero update_options(&c->headers, "headers", u->priv_data); + +// get the previous http proxt & set back to null if string size is zero +update_options(&c->http_proxy, "http_proxy", u->priv_data); } if ((ret = parse_playlist(c, s->filename, NULL, s->pb)) < 0) -- 1.9.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 3/3] avformat/hls: Added http_proxy support
--- libavformat/hls.c | 11 ++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libavformat/hls.c b/libavformat/hls.c index 82d5410..9ced13b 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -196,6 +196,7 @@ typedef struct HLSContext { char *user_agent;///< holds HTTP user agent set as an AVOption to the HTTP protocol context char *cookies; ///< holds HTTP cookie values set in either the initial response or as an AVOption to the HTTP protocol context char *headers; ///< holds HTTP headers set as an AVOption to the HTTP protocol context +char *http_proxy;///< holds the address of the HTTP proxy server AVDictionary *avio_opts; int strict_std_compliance; } HLSContext; @@ -257,6 +258,7 @@ static void free_playlist_list(HLSContext *c) av_freep(&c->cookies); av_freep(&c->user_agent); av_freep(&c->headers); +av_freep(&c->http_proxy); c->n_playlists = 0; } @@ -655,6 +657,7 @@ static int parse_playlist(HLSContext *c, const char *url, av_dict_set(&opts, "user-agent", c->user_agent, 0); av_dict_set(&opts, "cookies", c->cookies, 0); av_dict_set(&opts, "headers", c->headers, 0); +av_dict_set(&opts, "http_proxy", c->http_proxy, 0); ret = avio_open2(&in, url, AVIO_FLAG_READ, c->interrupt_callback, &opts); @@ -1068,6 +1071,7 @@ static int open_input(HLSContext *c, struct playlist *pls, struct segment *seg) av_dict_set(&opts, "user-agent", c->user_agent, 0); av_dict_set(&opts, "cookies", c->cookies, 0); av_dict_set(&opts, "headers", c->headers, 0); +av_dict_set(&opts, "http_proxy", c->http_proxy, 0); av_dict_set(&opts, "seekable", "0", 0); if (seg->size >= 0) { @@ -1468,7 +1472,9 @@ static int select_cur_seq_no(HLSContext *c, struct playlist *pls) static int save_avio_options(AVFormatContext *s) { HLSContext *c = s->priv_data; -const char *opts[] = { "headers", "user_agent", "user-agent", "cookies", NULL }, **opt = opts; +const char *opts[] = { + "headers", "http_proxy", "user_agent", "user-agent", "cookies", NULL }; +const char **opt = opts; uint8_t *buf; int ret = 0; @@ -1508,6 +1514,9 @@ static int hls_read_header(AVFormatContext *s) // get the previous headers & set back to null if string size is zero update_options(&c->headers, "headers", u->priv_data); + +// get the previous http proxt & set back to null if string size is zero +update_options(&c->http_proxy, "http_proxy", u->priv_data); } if ((ret = parse_playlist(c, s->filename, NULL, s->pb)) < 0) -- 1.9.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 2/3] avformat/hls: Remember to free HLSContext::headers
--- libavformat/hls.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/hls.c b/libavformat/hls.c index 2d4ee13..82d5410 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -256,6 +256,7 @@ static void free_playlist_list(HLSContext *c) av_freep(&c->playlists); av_freep(&c->cookies); av_freep(&c->user_agent); +av_freep(&c->headers); c->n_playlists = 0; } -- 1.9.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] Added support for http_proxy
Previously, avformat/http only supported http proxy servers via the http_proxy environment variable. This patch series add support for an "http_proxy" option in avformat/http, which enables per-stream tunnelling through an HTTP proxy server. This has applications within Kodi, where per-stream proxying is an often needed feature. Additionally, this patch set adds http_proxy support to avformat/hls, and fixes a minor memory leak. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 1/3] avformat/http: Added http_proxy option
--- libavformat/http.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavformat/http.c b/libavformat/http.c index 2230442..ad8358e 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -67,6 +67,7 @@ typedef struct HTTPContext { char *location; HTTPAuthState auth_state; HTTPAuthState proxy_auth_state; +char *http_proxy; char *headers; char *mime_type; char *user_agent; @@ -126,6 +127,7 @@ typedef struct HTTPContext { static const AVOption options[] = { { "seekable", "control seekability of connection", OFFSET(seekable), AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1, D }, { "chunked_post", "use chunked transfer-encoding for posts", OFFSET(chunked_post), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, E }, +{ "http_proxy", "The HTTP proxy to communicate via", OFFSET(http_proxy), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, D | E }, { "headers", "set custom HTTP headers, can override built in default headers", OFFSET(headers), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, D | E }, { "content_type", "set a specific content type for the POST messages", OFFSET(content_type), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, D | E }, { "user_agent", "override User-Agent header", OFFSET(user_agent), AV_OPT_TYPE_STRING, { .str = DEFAULT_USER_AGENT }, 0, 0, D }, @@ -186,7 +188,7 @@ static int http_open_cnx_internal(URLContext *h, AVDictionary **options) path1, sizeof(path1), s->location); ff_url_join(hoststr, sizeof(hoststr), NULL, NULL, hostname, port, NULL); -proxy_path = getenv("http_proxy"); +proxy_path = s->http_proxy ? s->http_proxy : getenv("http_proxy"); use_proxy = !ff_http_match_no_proxy(getenv("no_proxy"), hostname) && proxy_path && av_strstart(proxy_path, "http://";, NULL); -- 1.9.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel