PR #21078 opened by caifan
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21078
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21078.patch

Add a "pkt_size" AVOption to the Unix domain socket protocol. This option
allows the user to specify the maximum packet size for packet-oriented
sockets (SOCK_DGRAM and SOCK_SEQPACKET).

Signed-off-by: caifan3 <[email protected]>


>From a8ff0abd0a4a2c392efa9cb7162e863ea04be191 Mon Sep 17 00:00:00 2001
From: caifan3 <[email protected]>
Date: Tue, 2 Dec 2025 21:37:13 +0800
Subject: [PATCH] avformat/unix: add pkt_size option

Add a "pkt_size" AVOption to the Unix domain socket protocol. This option
allows the user to specify the maximum packet size for packet-oriented
sockets (SOCK_DGRAM and SOCK_SEQPACKET).

Signed-off-by: caifan3 <[email protected]>
---
 libavformat/unix.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/libavformat/unix.c b/libavformat/unix.c
index fed215a691..921e9b85ba 100644
--- a/libavformat/unix.c
+++ b/libavformat/unix.c
@@ -39,6 +39,7 @@ typedef struct UnixContext {
     int listen;
     int type;
     int fd;
+    int pkt_size;
 } UnixContext;
 
 #define OFFSET(x) offsetof(UnixContext, x)
@@ -50,6 +51,7 @@ static const AVOption unix_options[] = {
     { "stream",    "Stream (reliable stream-oriented)",     0,               
AV_OPT_TYPE_CONST, { .i64 = SOCK_STREAM },    INT_MIN, INT_MAX, ED, .unit = 
"type" },
     { "datagram",  "Datagram (unreliable packet-oriented)", 0,               
AV_OPT_TYPE_CONST, { .i64 = SOCK_DGRAM },     INT_MIN, INT_MAX, ED, .unit = 
"type" },
     { "seqpacket", "Seqpacket (reliable packet-oriented",   0,               
AV_OPT_TYPE_CONST, { .i64 = SOCK_SEQPACKET }, INT_MIN, INT_MAX, ED, .unit = 
"type" },
+    { "pkt_size",  "Maximum packet size",                   OFFSET(pkt_size), 
AV_OPT_TYPE_INT,  { .i64 = 32768 },              1, INT_MAX, ED },
     { NULL }
 };
 
@@ -91,6 +93,9 @@ static int unix_open(URLContext *h, const char *filename, int 
flags)
     s->fd = fd;
     h->is_streamed = 1;
 
+    if (s->type == SOCK_DGRAM || s->type == SOCK_SEQPACKET)
+        h->min_packet_size = h->max_packet_size = s->pkt_size;
+
     return 0;
 
 fail:
-- 
2.49.1

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

Reply via email to