|
|
|
@ -144,6 +144,7 @@ type client struct { |
|
|
|
streamProtocol gortsplib.StreamProtocol |
|
|
|
streamProtocol gortsplib.StreamProtocol |
|
|
|
streamTracks map[int]*clientTrack |
|
|
|
streamTracks map[int]*clientTrack |
|
|
|
rtcpReceivers []*gortsplib.RtcpReceiver |
|
|
|
rtcpReceivers []*gortsplib.RtcpReceiver |
|
|
|
|
|
|
|
udpLastFrameTimes []*int64 |
|
|
|
describeCSeq gortsplib.HeaderValue |
|
|
|
describeCSeq gortsplib.HeaderValue |
|
|
|
describeUrl string |
|
|
|
describeUrl string |
|
|
|
|
|
|
|
|
|
|
|
@ -1069,6 +1070,14 @@ func (c *client) runRecord() bool { |
|
|
|
c.rtcpReceivers[trackId] = gortsplib.NewRtcpReceiver() |
|
|
|
c.rtcpReceivers[trackId] = gortsplib.NewRtcpReceiver() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if c.streamProtocol == gortsplib.StreamProtocolUDP { |
|
|
|
|
|
|
|
c.udpLastFrameTimes = make([]*int64, len(c.streamTracks)) |
|
|
|
|
|
|
|
for trackId := range c.streamTracks { |
|
|
|
|
|
|
|
v := time.Now().Unix() |
|
|
|
|
|
|
|
c.udpLastFrameTimes[trackId] = &v |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
c.p.clientRecord <- c |
|
|
|
c.p.clientRecord <- c |
|
|
|
|
|
|
|
|
|
|
|
c.log("is publishing on path '%s', %d %s via %s", c.path.name, len(c.streamTracks), func() string { |
|
|
|
c.log("is publishing on path '%s', %d %s via %s", c.path.name, len(c.streamTracks), func() string { |
|
|
|
@ -1098,10 +1107,6 @@ func (c *client) runRecord() bool { |
|
|
|
onPublishCmd.Wait() |
|
|
|
onPublishCmd.Wait() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for trackId := range c.streamTracks { |
|
|
|
|
|
|
|
c.rtcpReceivers[trackId].Close() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return false |
|
|
|
return false |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -1160,9 +1165,13 @@ func (c *client) runRecordUDP() { |
|
|
|
return |
|
|
|
return |
|
|
|
|
|
|
|
|
|
|
|
case <-checkStreamTicker.C: |
|
|
|
case <-checkStreamTicker.C: |
|
|
|
for trackId := range c.streamTracks { |
|
|
|
now := time.Now() |
|
|
|
if time.Since(c.rtcpReceivers[trackId].LastFrameTime()) >= c.p.conf.ReadTimeout { |
|
|
|
|
|
|
|
c.log("ERR: no packets received recently (maybe there's a firewall/NAT)") |
|
|
|
for _, lastUnix := range c.udpLastFrameTimes { |
|
|
|
|
|
|
|
last := time.Unix(atomic.LoadInt64(lastUnix), 0) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if now.Sub(last) >= c.p.conf.ReadTimeout { |
|
|
|
|
|
|
|
c.log("ERR: no packets received recently (maybe there's a firewall/NAT in between)") |
|
|
|
c.conn.Close() |
|
|
|
c.conn.Close() |
|
|
|
<-readDone |
|
|
|
<-readDone |
|
|
|
c.p.clientClose <- c |
|
|
|
c.p.clientClose <- c |
|
|
|
|