Browse Source

initialize udp listeners only if udp is enabled

pull/80/head
aler9 5 years ago
parent
commit
3c95dd0cdb
  1. 23
      main.go
  2. 7
      rtsp-simple-server.yml

23
main.go

@ -252,14 +252,16 @@ func newProgram(args []string, stdin io.Reader) (*program, error) {
return nil, err return nil, err
} }
p.serverRtcp, err = newServerUdp(p, conf.RtcpPort, gortsplib.StreamTypeRtcp) if _, ok := conf.protocolsParsed[gortsplib.StreamProtocolUdp]; ok {
if err != nil { p.serverRtcp, err = newServerUdp(p, conf.RtcpPort, gortsplib.StreamTypeRtcp)
return nil, err if err != nil {
} return nil, err
}
p.serverRtsp, err = newServerTcp(p) p.serverRtsp, err = newServerTcp(p)
if err != nil { if err != nil {
return nil, err return nil, err
}
} }
for name, confp := range conf.Paths { for name, confp := range conf.Paths {
@ -545,8 +547,11 @@ outer:
} }
p.serverRtsp.close() 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 { for c := range p.clients {
c.conn.NetConn().Close() c.conn.NetConn().Close()

7
rtsp-simple-server.yml

@ -3,9 +3,9 @@
protocols: [udp, tcp] protocols: [udp, tcp]
# port of the TCP RTSP listener # port of the TCP RTSP listener
rtspPort: 8554 rtspPort: 8554
# port of the UDP RTP listener # port of the UDP RTP listener (used only if udp is in protocols)
rtpPort: 8000 rtpPort: 8000
# port of the UDP RTCP listener # port of the UDP RTCP listener (used only if udp is in protocols)
rtcpPort: 8001 rtcpPort: 8001
# timeout of read operations # timeout of read operations
@ -13,8 +13,7 @@ readTimeout: 10s
# timeout of write operations # timeout of write operations
writeTimeout: 5s writeTimeout: 5s
# supported authentication methods # supported authentication methods (both are insecure, use RTSP inside a VPN to enforce security)
# WARNING: both methods are insecure, use RTSP inside a VPN to enforce security.
authMethods: [basic, digest] authMethods: [basic, digest]
# command to run when a client connects. # command to run when a client connects.

Loading…
Cancel
Save