diff mbox

[FFmpeg-devel,2/3] lavf/tcp: add option to setting Maximum Segment Size

Message ID 1525619534-27976-2-git-send-email-mypopydev@gmail.com
State Superseded
Headers show

Commit Message

Jun Zhao May 6, 2018, 3:12 p.m. UTC
This can change the the MSS value announced to the other end in
the initial TCP packet, it's can be used when failed Path MTU
discovery.

Signed-off-by: Jun Zhao <mypopydev@gmail.com>
---
 libavformat/tcp.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Michael Niedermayer May 6, 2018, 9:17 p.m. UTC | #1
On Sun, May 06, 2018 at 11:12:13PM +0800, Jun Zhao wrote:
> This can change the the MSS value announced to the other end in
> the initial TCP packet, it's can be used when failed Path MTU
> discovery.
> 
> Signed-off-by: Jun Zhao <mypopydev@gmail.com>
> ---
>  libavformat/tcp.c | 5 +++++
>  1 file changed, 5 insertions(+)

breaks build on mingw64

CC	libavformat/tcp.o
src/libavformat/tcp.c: In function ‘tcp_open’:
src/libavformat/tcp.c:159:27: error: ‘TCP_MAXSEG’ undeclared (first use in this function)
         setsockopt (fd, IPPROTO_TCP, TCP_MAXSEG, &s->tcp_mss, sizeof (s->tcp_mss));
                           ^
src/libavformat/tcp.c:159:27: note: each undeclared identifier is reported only once for each function it appears in
make: *** [libavformat/tcp.o] Error 1
make: Target `all' not remade because of errors.

[...]
mypopy@gmail.com May 7, 2018, 12:36 a.m. UTC | #2
2018-05-07 5:17 GMT+08:00 Michael Niedermayer <michael@niedermayer.cc>:
> On Sun, May 06, 2018 at 11:12:13PM +0800, Jun Zhao wrote:
>> This can change the the MSS value announced to the other end in
>> the initial TCP packet, it's can be used when failed Path MTU
>> discovery.
>>
>> Signed-off-by: Jun Zhao <mypopydev@gmail.com>
>> ---
>>  libavformat/tcp.c | 5 +++++
>>  1 file changed, 5 insertions(+)
>
> breaks build on mingw64
>
> CC      libavformat/tcp.o
> src/libavformat/tcp.c: In function ‘tcp_open’:
> src/libavformat/tcp.c:159:27: error: ‘TCP_MAXSEG’ undeclared (first use in this function)
>          setsockopt (fd, IPPROTO_TCP, TCP_MAXSEG, &s->tcp_mss, sizeof (s->tcp_mss));
>                            ^
> src/libavformat/tcp.c:159:27: note: each undeclared identifier is reported only once for each function it appears in
> make: *** [libavformat/tcp.o] Error 1
> make: Target `all' not remade because of errors.
Will fix the mingw64 build fail, tks
>
> [...]
> --
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> No great genius has ever existed without some touch of madness. -- Aristotle
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
diff mbox

Patch

diff --git a/libavformat/tcp.c b/libavformat/tcp.c
index b0289f8..1d51710 100644
--- a/libavformat/tcp.c
+++ b/libavformat/tcp.c
@@ -42,6 +42,7 @@  typedef struct TCPContext {
     int recv_buffer_size;
     int send_buffer_size;
     int tcp_nodelay;
+    int tcp_mss;
 } TCPContext;
 
 #define OFFSET(x) offsetof(TCPContext, x)
@@ -54,6 +55,7 @@  static const AVOption options[] = {
     { "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 },
     { "tcp_nodelay", "Use TCP_NODELAY to disable nagle's algorithm",           OFFSET(tcp_nodelay), AV_OPT_TYPE_BOOL, { .i64 = 0 },             0, 1, .flags = D|E },
+    { "tcp_mss",     "Maximum segment size for outgoing TCP packets",          OFFSET(tcp_mss),     AV_OPT_TYPE_INT, { .i64 = -1 },         -1, INT_MAX, .flags = D|E },
     { NULL }
 };
 
@@ -153,6 +155,9 @@  static int tcp_open(URLContext *h, const char *uri, int flags)
     if (s->tcp_nodelay > 0) {
         setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, &s->tcp_nodelay, sizeof (s->tcp_nodelay));
     }
+    if (s->tcp_mss > 0) {
+        setsockopt (fd, IPPROTO_TCP, TCP_MAXSEG, &s->tcp_mss, sizeof (s->tcp_mss));
+    }
 
     if (s->listen == 2) {
         // multi-client