|
|
|
@ -160,13 +160,12 @@ type program struct {
@@ -160,13 +160,12 @@ type program struct {
|
|
|
|
|
logFile *os.File |
|
|
|
|
metrics *metrics |
|
|
|
|
pprof *pprof |
|
|
|
|
serverRtsp *serverTcp |
|
|
|
|
paths map[string]*path |
|
|
|
|
serverRtp *serverUdp |
|
|
|
|
serverRtcp *serverUdp |
|
|
|
|
sources []*source |
|
|
|
|
serverRtsp *serverTcp |
|
|
|
|
clients map[*client]struct{} |
|
|
|
|
udpClientsByAddr map[udpClientAddr]*udpClient |
|
|
|
|
paths map[string]*path |
|
|
|
|
publisherCount int |
|
|
|
|
readerCount int |
|
|
|
|
|
|
|
|
@ -195,9 +194,9 @@ func newProgram(args []string, stdin io.Reader) (*program, error) {
@@ -195,9 +194,9 @@ func newProgram(args []string, stdin io.Reader) (*program, error) {
|
|
|
|
|
|
|
|
|
|
p := &program{ |
|
|
|
|
conf: conf, |
|
|
|
|
paths: make(map[string]*path), |
|
|
|
|
clients: make(map[*client]struct{}), |
|
|
|
|
udpClientsByAddr: make(map[udpClientAddr]*udpClient), |
|
|
|
|
paths: make(map[string]*path), |
|
|
|
|
events: make(chan programEvent), |
|
|
|
|
done: make(chan struct{}), |
|
|
|
|
} |
|
|
|
@ -211,20 +210,6 @@ func newProgram(args []string, stdin io.Reader) (*program, error) {
@@ -211,20 +210,6 @@ func newProgram(args []string, stdin io.Reader) (*program, error) {
|
|
|
|
|
|
|
|
|
|
p.log("rtsp-simple-server %s", Version) |
|
|
|
|
|
|
|
|
|
for name, confp := range conf.Paths { |
|
|
|
|
if name == "all" { |
|
|
|
|
continue |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
p.paths[name] = newPath(p, name, confp, true) |
|
|
|
|
|
|
|
|
|
if confp.Source != "record" { |
|
|
|
|
s := newSource(p, name, confp) |
|
|
|
|
p.sources = append(p.sources, s) |
|
|
|
|
p.paths[name].publisher = s |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if conf.Metrics { |
|
|
|
|
p.metrics, err = newMetrics(p) |
|
|
|
|
if err != nil { |
|
|
|
@ -239,6 +224,13 @@ func newProgram(args []string, stdin io.Reader) (*program, error) {
@@ -239,6 +224,13 @@ func newProgram(args []string, stdin io.Reader) (*program, error) {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for name, confp := range conf.Paths { |
|
|
|
|
if name == "all" { |
|
|
|
|
continue |
|
|
|
|
} |
|
|
|
|
p.paths[name] = newPath(p, name, confp, true) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if _, ok := conf.protocolsParsed[gortsplib.StreamProtocolUdp]; ok { |
|
|
|
|
p.serverRtp, err = newServerUdp(p, conf.RtpPort, gortsplib.StreamTypeRtp) |
|
|
|
|
if err != nil { |
|
|
|
@ -271,10 +263,6 @@ func newProgram(args []string, stdin io.Reader) (*program, error) {
@@ -271,10 +263,6 @@ func newProgram(args []string, stdin io.Reader) (*program, error) {
|
|
|
|
|
|
|
|
|
|
go p.serverRtsp.run() |
|
|
|
|
|
|
|
|
|
for _, s := range p.sources { |
|
|
|
|
go s.run() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for _, p := range p.paths { |
|
|
|
|
p.onInit() |
|
|
|
|
} |
|
|
|
@ -532,11 +520,6 @@ outer:
@@ -532,11 +520,6 @@ outer:
|
|
|
|
|
|
|
|
|
|
p.serverRtsp.close() |
|
|
|
|
|
|
|
|
|
for _, s := range p.sources { |
|
|
|
|
s.events <- sourceEventTerminate{} |
|
|
|
|
<-s.done |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if _, ok := p.conf.protocolsParsed[gortsplib.StreamProtocolUdp]; ok { |
|
|
|
|
p.serverRtcp.close() |
|
|
|
|
p.serverRtp.close() |
|
|
|
|