[FFmpeg-cvslog] tcp: Use rw_timeout for setting the connect/listen timeouts

Martin Storsjö git at videolan.org
Thu Apr 21 17:02:05 CEST 2016


ffmpeg | branch: master | Martin Storsjö <martin at martin.st> | Sat Feb 28 01:43:39 2015 +0200| [136c3438bbdb56a5d2f1f0f486f180641dc6dda0] | committer: Martin Storsjö

tcp: Use rw_timeout for setting the connect/listen timeouts

Apply the default value for timeout in code instead of via the
avoption, to allow distinguishing the default value from the user
not setting anything at all.

Signed-off-by: Martin Storsjö <martin at martin.st>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=136c3438bbdb56a5d2f1f0f486f180641dc6dda0
---

 libavformat/tcp.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libavformat/tcp.c b/libavformat/tcp.c
index f211142..1498c26 100644
--- a/libavformat/tcp.c
+++ b/libavformat/tcp.c
@@ -43,7 +43,7 @@ typedef struct TCPContext {
 #define E AV_OPT_FLAG_ENCODING_PARAM
 static const AVOption options[] = {
     { "listen",          "Listen for incoming connections",  OFFSET(listen),         AV_OPT_TYPE_INT, { .i64 = 0 },     0,       1,       .flags = D|E },
-    { "timeout",         "Connection timeout (in milliseconds)", OFFSET(timeout),    AV_OPT_TYPE_INT, { .i64 = 10000 }, INT_MIN, INT_MAX, .flags = D|E },
+    { "timeout",         "Connection timeout (in milliseconds)", OFFSET(timeout),    AV_OPT_TYPE_INT, { .i64 = 0 }, INT_MIN, INT_MAX, .flags = D|E },
     { "listen_timeout",  "Bind timeout (in milliseconds)",   OFFSET(listen_timeout), AV_OPT_TYPE_INT, { .i64 = -1 },    INT_MIN, INT_MAX, .flags = D|E },
     { NULL }
 };
@@ -86,6 +86,10 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
             s->listen_timeout = strtol(buf, NULL, 10);
         }
     }
+    if (!s->timeout)
+        s->timeout = h->rw_timeout ? h->rw_timeout / 1000 : 10000;
+    if (h->rw_timeout && s->listen_timeout < 0)
+        s->listen_timeout = h->rw_timeout / 1000;
     hints.ai_family = AF_UNSPEC;
     hints.ai_socktype = SOCK_STREAM;
     snprintf(portstr, sizeof(portstr), "%d", port);



More information about the ffmpeg-cvslog mailing list