mirror of
https://github.com/aler9/gortsplib
synced 2025-10-05 15:16:51 +08:00
ServerUDPListener: set writeTimeout once
This commit is contained in:
@@ -37,7 +37,10 @@ func newServer(conf ServerConf, address string) (*Server, error) {
|
||||
|
||||
if conf.UDPRTPListener != nil {
|
||||
conf.UDPRTPListener.streamType = StreamTypeRTP
|
||||
conf.UDPRTPListener.writeTimeout = conf.WriteTimeout
|
||||
|
||||
conf.UDPRTCPListener.streamType = StreamTypeRTCP
|
||||
conf.UDPRTCPListener.writeTimeout = conf.WriteTimeout
|
||||
}
|
||||
|
||||
listener, err := conf.Listen("tcp", address)
|
||||
|
@@ -809,14 +809,14 @@ func (sc *ServerConn) WriteFrame(trackID int, streamType StreamType, payload []b
|
||||
track := sc.tracks[trackID]
|
||||
|
||||
if streamType == StreamTypeRTP {
|
||||
return sc.conf.UDPRTPListener.write(sc.conf.WriteTimeout, payload, &net.UDPAddr{
|
||||
return sc.conf.UDPRTPListener.write(payload, &net.UDPAddr{
|
||||
IP: sc.ip(),
|
||||
Zone: sc.zone(),
|
||||
Port: track.rtpPort,
|
||||
})
|
||||
}
|
||||
|
||||
return sc.conf.UDPRTCPListener.write(sc.conf.WriteTimeout, payload, &net.UDPAddr{
|
||||
return sc.conf.UDPRTCPListener.write(payload, &net.UDPAddr{
|
||||
IP: sc.ip(),
|
||||
Zone: sc.zone(),
|
||||
Port: track.rtcpPort,
|
||||
|
@@ -39,7 +39,8 @@ func (p *publisherAddr) fill(ip net.IP, port int) {
|
||||
|
||||
// ServerUDPListener is a UDP server that can be used to send and receive RTP and RTCP packets.
|
||||
type ServerUDPListener struct {
|
||||
streamType StreamType
|
||||
streamType StreamType
|
||||
writeTimeout time.Duration
|
||||
|
||||
pc *net.UDPConn
|
||||
readBuf *multibuffer.MultiBuffer
|
||||
@@ -116,11 +117,11 @@ func (s *ServerUDPListener) port() int {
|
||||
return s.pc.LocalAddr().(*net.UDPAddr).Port
|
||||
}
|
||||
|
||||
func (s *ServerUDPListener) write(writeTimeout time.Duration, buf []byte, addr *net.UDPAddr) error {
|
||||
func (s *ServerUDPListener) write(buf []byte, addr *net.UDPAddr) error {
|
||||
s.writeMutex.Lock()
|
||||
defer s.writeMutex.Unlock()
|
||||
|
||||
s.pc.SetWriteDeadline(time.Now().Add(writeTimeout))
|
||||
s.pc.SetWriteDeadline(time.Now().Add(s.writeTimeout))
|
||||
_, err := s.pc.WriteTo(buf, addr)
|
||||
return err
|
||||
}
|
||||
|
Reference in New Issue
Block a user