PR #21696 opened by Jack Lau (JackLau)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21696
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21696.patch


>From df9ab587cefe41752a5d056f7ea555a662fd659b Mon Sep 17 00:00:00 2001
From: Jack Lau <[email protected]>
Date: Mon, 9 Feb 2026 16:57:27 +0800
Subject: [PATCH 1/2] avformat/tls_gnutls: limit the wirtten size to data mtu

Signed-off-by: Jack Lau <[email protected]>
---
 libavformat/tls_gnutls.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libavformat/tls_gnutls.c b/libavformat/tls_gnutls.c
index d0358c162c..957831081e 100644
--- a/libavformat/tls_gnutls.c
+++ b/libavformat/tls_gnutls.c
@@ -709,6 +709,12 @@ static int tls_write(URLContext *h, const uint8_t *buf, 
int size)
     // Set or clear the AVIO_FLAG_NONBLOCK on c->tls_shared.tcp
     uc->flags &= ~AVIO_FLAG_NONBLOCK;
     uc->flags |= h->flags & AVIO_FLAG_NONBLOCK;
+
+    if (s->is_dtls) {
+        const size_t mtu_size = gnutls_dtls_get_data_mtu(c->session);
+        size = FFMIN(size, mtu_size);
+    }
+
     ret = gnutls_record_send(c->session, buf, size);
     if (ret > 0)
         return ret;
-- 
2.52.0


>From f43cbb95d8fe12084a4d7a7ed1efd0708563a4ca Mon Sep 17 00:00:00 2001
From: Jack Lau <[email protected]>
Date: Mon, 9 Feb 2026 17:01:20 +0800
Subject: [PATCH 2/2] avformat/tls_gnutls: update the comment since the
 underlying socket can be tcp or udp

Signed-off-by: Jack Lau <[email protected]>
---
 libavformat/tls_gnutls.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/tls_gnutls.c b/libavformat/tls_gnutls.c
index 957831081e..778ca9cf40 100644
--- a/libavformat/tls_gnutls.c
+++ b/libavformat/tls_gnutls.c
@@ -689,7 +689,7 @@ static int tls_read(URLContext *h, uint8_t *buf, int size)
     TLSShared *s = &c->tls_shared;
     URLContext *uc = s->is_dtls ? s->udp : s->tcp;
     int ret;
-    // Set or clear the AVIO_FLAG_NONBLOCK on c->tls_shared.tcp
+    // Set or clear the AVIO_FLAG_NONBLOCK on the underlying socket
     uc->flags &= ~AVIO_FLAG_NONBLOCK;
     uc->flags |= h->flags & AVIO_FLAG_NONBLOCK;
     ret = gnutls_record_recv(c->session, buf, size);
@@ -706,7 +706,7 @@ static int tls_write(URLContext *h, const uint8_t *buf, int 
size)
     TLSShared *s = &c->tls_shared;
     URLContext *uc = s->is_dtls ? s->udp : s->tcp;
     int ret;
-    // Set or clear the AVIO_FLAG_NONBLOCK on c->tls_shared.tcp
+    // Set or clear the AVIO_FLAG_NONBLOCK on the underlying socket
     uc->flags &= ~AVIO_FLAG_NONBLOCK;
     uc->flags |= h->flags & AVIO_FLAG_NONBLOCK;
 
-- 
2.52.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to