@@ -22,6 +22,7 @@ import (
2222 "github.com/pion/logging"
2323 pwebrtc "github.com/pion/webrtc/v4"
2424
25+ "github.com/bluenviron/gortsplib/v5/pkg/readbuffer"
2526 "github.com/bluenviron/mediamtx/internal/conf"
2627 "github.com/bluenviron/mediamtx/internal/defs"
2728 "github.com/bluenviron/mediamtx/internal/externalcmd"
@@ -193,6 +194,7 @@ type Server struct {
193194 TrustedProxies conf.IPNetworks
194195 ReadTimeout conf.Duration
195196 WriteTimeout conf.Duration
197+ UDPReadBufferSize uint
196198 LocalUDPAddress string
197199 LocalTCPAddress string
198200 IPsFromInterfaces bool
@@ -272,6 +274,17 @@ func (s *Server) Initialize() error {
272274 ctxCancel ()
273275 return err
274276 }
277+
278+ if s .UDPReadBufferSize != 0 {
279+ err = readbuffer .SetReadBuffer (s .udpMuxLn .(* net.UDPConn ), int (s .UDPReadBufferSize ))
280+ if err != nil {
281+ s .udpMuxLn .Close ()
282+ s .httpServer .close ()
283+ ctxCancel ()
284+ return err
285+ }
286+ }
287+
275288 s .iceUDPMux = pwebrtc .NewICEUDPMux (webrtcNilLogger , s .udpMuxLn )
276289 }
277290
@@ -285,6 +298,7 @@ func (s *Server) Initialize() error {
285298 ctxCancel ()
286299 return err
287300 }
301+
288302 s .iceTCPMux = & webrtc.TCPMuxWrapper {
289303 Mux : pwebrtc .NewICETCPMux (webrtcNilLogger , s .tcpMuxLn , 8 ),
290304 Ln : s .tcpMuxLn ,
@@ -336,6 +350,7 @@ outer:
336350 select {
337351 case req := <- s .chNewSession :
338352 sx := & session {
353+ udpReadBufferSize : s .UDPReadBufferSize ,
339354 parentCtx : s .ctx ,
340355 ipsFromInterfaces : s .IPsFromInterfaces ,
341356 ipsFromInterfacesList : s .IPsFromInterfacesList ,
0 commit comments