X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Ftcp.c;h=3055e48015f7df09652339d7f64ab9b07569bc2c;hb=4507f29e4a6a4363e0179c02bdb78d55e4d9a12c;hp=5f00ba7588def93e93da549705e6eec63bf2b59b;hpb=b9292a9698375510c5668cde4ce80dea79d8ec02;p=ffmpeg diff --git a/libavformat/tcp.c b/libavformat/tcp.c index 5f00ba7588d..3055e48015f 100644 --- a/libavformat/tcp.c +++ b/libavformat/tcp.c @@ -266,6 +266,26 @@ static int tcp_get_file_handle(URLContext *h) return s->fd; } +static int tcp_get_window_size(URLContext *h) +{ + TCPContext *s = h->priv_data; + int avail; + int avail_len = sizeof(avail); + +#if HAVE_WINSOCK2_H + /* SO_RCVBUF with winsock only reports the actual TCP window size when + auto-tuning has been disabled via setting SO_RCVBUF */ + if (s->recv_buffer_size < 0) { + return AVERROR(ENOSYS); + } +#endif + + if (getsockopt(s->fd, SOL_SOCKET, SO_RCVBUF, &avail, &avail_len)) { + return ff_neterrno(); + } + return avail; +} + const URLProtocol ff_tcp_protocol = { .name = "tcp", .url_open = tcp_open, @@ -274,6 +294,7 @@ const URLProtocol ff_tcp_protocol = { .url_write = tcp_write, .url_close = tcp_close, .url_get_file_handle = tcp_get_file_handle, + .url_get_short_seek = tcp_get_window_size, .url_shutdown = tcp_shutdown, .priv_data_size = sizeof(TCPContext), .flags = URL_PROTOCOL_FLAG_NETWORK,