Commit 75235a25 authored by Stephan Holljes's avatar Stephan Holljes

lavf/tcp: increase range for listen and call the underlying socket operations accordingly

Signed-off-by: 's avatarStephan Holljes <klaxa1337@googlemail.com>
parent 21198155
...@@ -45,7 +45,7 @@ typedef struct TCPContext { ...@@ -45,7 +45,7 @@ typedef struct TCPContext {
#define D AV_OPT_FLAG_DECODING_PARAM #define D AV_OPT_FLAG_DECODING_PARAM
#define E AV_OPT_FLAG_ENCODING_PARAM #define E AV_OPT_FLAG_ENCODING_PARAM
static const AVOption options[] = { static const AVOption options[] = {
{ "listen", "Listen for incoming connections", OFFSET(listen), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, .flags = D|E }, { "listen", "Listen for incoming connections", OFFSET(listen), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 2, .flags = D|E },
{ "timeout", "set timeout (in microseconds) of socket I/O operations", OFFSET(rw_timeout), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E }, { "timeout", "set timeout (in microseconds) of socket I/O operations", OFFSET(rw_timeout), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E },
{ "listen_timeout", "Connection awaiting timeout (in milliseconds)", OFFSET(listen_timeout), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E }, { "listen_timeout", "Connection awaiting timeout (in milliseconds)", OFFSET(listen_timeout), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E },
{ NULL } { NULL }
...@@ -126,12 +126,17 @@ static int tcp_open(URLContext *h, const char *uri, int flags) ...@@ -126,12 +126,17 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
goto fail; goto fail;
} }
if (s->listen) { if (s->listen == 2) {
if ((ret = ff_listen_bind(fd, cur_ai->ai_addr, cur_ai->ai_addrlen, // multi-client
if ((ret = ff_listen(fd, cur_ai->ai_addr, cur_ai->ai_addrlen)) < 0)
goto fail1;
} else if (s->listen == 1) {
// single client
if ((fd = ff_listen_bind(fd, cur_ai->ai_addr, cur_ai->ai_addrlen,
s->listen_timeout, h)) < 0) { s->listen_timeout, h)) < 0) {
ret = fd;
goto fail1; goto fail1;
} }
fd = ret;
} else { } else {
if ((ret = ff_listen_connect(fd, cur_ai->ai_addr, cur_ai->ai_addrlen, if ((ret = ff_listen_connect(fd, cur_ai->ai_addr, cur_ai->ai_addrlen,
s->open_timeout / 1000, h, !!cur_ai->ai_next)) < 0) { s->open_timeout / 1000, h, !!cur_ai->ai_next)) < 0) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment