mirror of
https://github.com/aler9/gortsplib
synced 2025-10-27 17:21:22 +08:00
increase udp kernel read buffer size to minimize packet losses (https://github.com/aler9/rtsp-simple-server/issues/125)
This commit is contained in:
@@ -33,7 +33,6 @@ const (
|
|||||||
clientUDPCheckStreamPeriod = 5 * time.Second
|
clientUDPCheckStreamPeriod = 5 * time.Second
|
||||||
clientUDPKeepalivePeriod = 30 * time.Second
|
clientUDPKeepalivePeriod = 30 * time.Second
|
||||||
clientTCPFrameReadBufferSize = 128 * 1024
|
clientTCPFrameReadBufferSize = 128 * 1024
|
||||||
clientUDPFrameReadBufferSize = 2048
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type connClientState int
|
type connClientState int
|
||||||
|
|||||||
@@ -9,6 +9,13 @@ import (
|
|||||||
"github.com/aler9/gortsplib/pkg/multibuffer"
|
"github.com/aler9/gortsplib/pkg/multibuffer"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// use the same buffer size as gstreamer's rtspsrc
|
||||||
|
connClientUDPKernelReadBufferSize = 0x80000
|
||||||
|
|
||||||
|
connClientUDPReadBufferSize = 2048
|
||||||
|
)
|
||||||
|
|
||||||
type connClientUDPListener struct {
|
type connClientUDPListener struct {
|
||||||
c *ConnClient
|
c *ConnClient
|
||||||
pc net.PacketConn
|
pc net.PacketConn
|
||||||
@@ -29,10 +36,15 @@ func newConnClientUDPListener(c *ConnClient, port int) (*connClientUDPListener,
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = pc.(*net.UDPConn).SetReadBuffer(connClientUDPKernelReadBufferSize)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
return &connClientUDPListener{
|
return &connClientUDPListener{
|
||||||
c: c,
|
c: c,
|
||||||
pc: pc,
|
pc: pc,
|
||||||
udpFrameBuffer: multibuffer.New(c.d.ReadBufferCount, 2048),
|
udpFrameBuffer: multibuffer.New(c.d.ReadBufferCount, connClientUDPReadBufferSize),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user