From 3c95dd0cdbfef8c898c6df4c4bf6d78091e0fe0c Mon Sep 17 00:00:00 2001 From: aler9 <46489434+aler9@users.noreply.github.com> Date: Mon, 17 Aug 2020 18:22:14 +0200 Subject: [PATCH] initialize udp listeners only if udp is enabled --- main.go | 23 ++++++++++++++--------- rtsp-simple-server.yml | 7 +++---- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/main.go b/main.go index e0a8d86c..ac76d898 100644 --- a/main.go +++ b/main.go @@ -252,14 +252,16 @@ func newProgram(args []string, stdin io.Reader) (*program, error) { return nil, err } - p.serverRtcp, err = newServerUdp(p, conf.RtcpPort, gortsplib.StreamTypeRtcp) - if err != nil { - return nil, err - } + if _, ok := conf.protocolsParsed[gortsplib.StreamProtocolUdp]; ok { + p.serverRtcp, err = newServerUdp(p, conf.RtcpPort, gortsplib.StreamTypeRtcp) + if err != nil { + return nil, err + } - p.serverRtsp, err = newServerTcp(p) - if err != nil { - return nil, err + p.serverRtsp, err = newServerTcp(p) + if err != nil { + return nil, err + } } for name, confp := range conf.Paths { @@ -545,8 +547,11 @@ outer: } p.serverRtsp.close() - p.serverRtcp.close() - p.serverRtp.close() + + if _, ok := p.conf.protocolsParsed[gortsplib.StreamProtocolUdp]; ok { + p.serverRtcp.close() + p.serverRtp.close() + } for c := range p.clients { c.conn.NetConn().Close() diff --git a/rtsp-simple-server.yml b/rtsp-simple-server.yml index 818f5f39..a0105b0b 100644 --- a/rtsp-simple-server.yml +++ b/rtsp-simple-server.yml @@ -3,9 +3,9 @@ protocols: [udp, tcp] # port of the TCP RTSP listener rtspPort: 8554 -# port of the UDP RTP listener +# port of the UDP RTP listener (used only if udp is in protocols) rtpPort: 8000 -# port of the UDP RTCP listener +# port of the UDP RTCP listener (used only if udp is in protocols) rtcpPort: 8001 # timeout of read operations @@ -13,8 +13,7 @@ readTimeout: 10s # timeout of write operations writeTimeout: 5s -# supported authentication methods -# WARNING: both methods are insecure, use RTSP inside a VPN to enforce security. +# supported authentication methods (both are insecure, use RTSP inside a VPN to enforce security) authMethods: [basic, digest] # command to run when a client connects.