[FFmpeg-devel] lavf/http.c: Add listen_timeout option.

Submitted by Stephan Holljes on Oct. 18, 2016, 12:09 a.m.

Details

Message ID 1476749383-28855-1-git-send-email-klaxa1337@googlemail.com
State New
Headers show

Commit Message

Stephan Holljes Oct. 18, 2016, 12:09 a.m.
---
 libavformat/http.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Stephan Holljes Oct. 18, 2016, 2:31 a.m.
On Tue, Oct 18, 2016 at 2:09 AM, Stephan Holljes
<klaxa1337@googlemail.com> wrote:
> ---
>  libavformat/http.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/libavformat/http.c b/libavformat/http.c
> index d48958d..3b0d6ab 100644
> --- a/libavformat/http.c
> +++ b/libavformat/http.c
> @@ -115,6 +115,7 @@ typedef struct HTTPContext {
>      int reconnect_delay;
>      int reconnect_delay_max;
>      int listen;
> +    int listen_timeout;
>      char *resource;
>      int reply_code;
>      int is_multi_client;
> @@ -158,6 +159,7 @@ static const AVOption options[] = {
>      { "reconnect_streamed", "auto reconnect streamed / non seekable streams", OFFSET(reconnect_streamed), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, D },
>      { "reconnect_delay_max", "max reconnect delay in seconds after which to give up", OFFSET(reconnect_delay_max), AV_OPT_TYPE_INT, { .i64 = 120 }, 0, UINT_MAX/1000/1000, D },
>      { "listen", "listen on HTTP", OFFSET(listen), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 2, D | E },
> +    { "listen_timeout",  "Connection awaiting timeout (in milliseconds)",      OFFSET(listen_timeout), AV_OPT_TYPE_INT, { .i64 = -1 },         -1, INT_MAX, .flags = D|E },
>      { "resource", "The resource requested by a client", OFFSET(resource), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, E },
>      { "reply_code", "The http status code to return to a client", OFFSET(reply_code), AV_OPT_TYPE_INT, { .i64 = 200}, INT_MIN, 599, E},
>      { NULL }
> @@ -463,6 +465,9 @@ static int http_listen(URLContext *h, const char *uri, int flags,
>                  NULL);
>      if ((ret = av_dict_set_int(options, "listen", s->listen, 0)) < 0)
>          goto fail;
> +    if ((ret = av_dict_set_int(options, "listen_timeout", s->listen_timeout, 0)) < 0)
> +        goto fail;
> +
>      if ((ret = ffurl_open_whitelist(&s->hd, lower_url, AVIO_FLAG_READ_WRITE,
>                                      &h->interrupt_callback, options,
>                                      h->protocol_whitelist, h->protocol_blacklist, h
> --
> 2.5.5
>

Disregard this patch. I was producing buggy application code and
thought this was necessary. (Options are passed down to lower
protocols and threads make things weird...).

Patch hide | download patch | download mbox

diff --git a/libavformat/http.c b/libavformat/http.c
index d48958d..3b0d6ab 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -115,6 +115,7 @@  typedef struct HTTPContext {
     int reconnect_delay;
     int reconnect_delay_max;
     int listen;
+    int listen_timeout;
     char *resource;
     int reply_code;
     int is_multi_client;
@@ -158,6 +159,7 @@  static const AVOption options[] = {
     { "reconnect_streamed", "auto reconnect streamed / non seekable streams", OFFSET(reconnect_streamed), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, D },
     { "reconnect_delay_max", "max reconnect delay in seconds after which to give up", OFFSET(reconnect_delay_max), AV_OPT_TYPE_INT, { .i64 = 120 }, 0, UINT_MAX/1000/1000, D },
     { "listen", "listen on HTTP", OFFSET(listen), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 2, D | E },
+    { "listen_timeout",  "Connection awaiting timeout (in milliseconds)",      OFFSET(listen_timeout), AV_OPT_TYPE_INT, { .i64 = -1 },         -1, INT_MAX, .flags = D|E },
     { "resource", "The resource requested by a client", OFFSET(resource), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, E },
     { "reply_code", "The http status code to return to a client", OFFSET(reply_code), AV_OPT_TYPE_INT, { .i64 = 200}, INT_MIN, 599, E},
     { NULL }
@@ -463,6 +465,9 @@  static int http_listen(URLContext *h, const char *uri, int flags,
                 NULL);
     if ((ret = av_dict_set_int(options, "listen", s->listen, 0)) < 0)
         goto fail;
+    if ((ret = av_dict_set_int(options, "listen_timeout", s->listen_timeout, 0)) < 0)
+        goto fail;
+
     if ((ret = ffurl_open_whitelist(&s->hd, lower_url, AVIO_FLAG_READ_WRITE,
                                     &h->interrupt_callback, options,
                                     h->protocol_whitelist, h->protocol_blacklist, h