initialize udp listeners only if udp is enabled

This commit is contained in:
aler9 2020-08-17 18:22:14 +02:00
parent 7a440030ad
commit 3c95dd0cdb
2 changed files with 17 additions and 13 deletions

23
main.go
View File

@ -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()

View File

@ -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.