> tabs aren’t allowed in ffmpeg git (except makefiles) fixed > SO_RCVBUF occurs twice, is that intended ? Not intended, fixed, thanks.
> cleaning up the indention is welcome, but please in a seperate patch Removed from this patch. > also an update to the docs is needed Done. Updated patch follows: diff --git a/doc/protocols.texi b/doc/protocols.texi index 8b2e310..05c4bdb 100644 --- a/doc/protocols.texi +++ b/doc/protocols.texi @@ -1147,6 +1147,12 @@ than this time interval, raise error. @item listen_timeout=@var{milliseconds} Set listen timeout, expressed in milliseconds. + +@item recv_buffer_size=@var{bytes} +Set receive buffer size, expressed bytes. + +@item send_buffer_size=@var{bytes} +Set send buffer size, expressed bytes. @end table The following example shows how to setup a listening TCP connection diff --git a/libavformat/tcp.c b/libavformat/tcp.c index e02c64b..5738690 100644 --- a/libavformat/tcp.c +++ b/libavformat/tcp.c @@ -39,6 +39,8 @@ typedef struct TCPContext { int open_timeout; int rw_timeout; int listen_timeout; + int recv_buffer_size; + int send_buffer_size; } TCPContext; #define OFFSET(x) offsetof(TCPContext, x) @@ -48,6 +50,8 @@ static const AVOption options[] = { { "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 }, { "listen_timeout", "Connection awaiting timeout (in milliseconds)", OFFSET(listen_timeout), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E }, + { "send_buffer_size", "Socket send buffer size (in bytes)", OFFSET(send_buffer_size), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E }, + { "recv_buffer_size", "Socket receive buffer size (in bytes)", OFFSET(recv_buffer_size), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E }, { NULL } }; @@ -150,6 +154,15 @@ static int tcp_open(URLContext *h, const char *uri, int flags) h->is_streamed = 1; s->fd = fd; + /* Set the socket's send or receive buffer sizes, if specified. + If unspecified or setting fails, system default is used. */ + if (s->recv_buffer_size > 0) { + setsockopt (fd, SOL_SOCKET, SO_RCVBUF, &s->recv_buffer_size, sizeof (s->recv_buffer_size)); + } + if (s->send_buffer_size > 0) { + setsockopt (fd, SOL_SOCKET, SO_SNDBUF, &s->send_buffer_size, sizeof (s->send_buffer_size)); + } + freeaddrinfo(ai); return 0; _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel