Fix timeout for RTSP with only Recv track

This commit is contained in:
Alexey Khit
2023-02-17 09:41:53 +03:00
parent bb5df24ecf
commit 338da2a747
+17 -1
View File
@@ -559,9 +559,16 @@ func (c *Conn) Handle() (err error) {
switch c.mode {
case ModeClientProducer:
// polling frames from remote RTSP Server (ex Camera)
timeout = time.Second * 5
go c.keepalive()
if c.HasSendTracks() {
// if we receiving video/audio from camera
timeout = time.Second * 5
} else {
// if we only send audio to camera
timeout = time.Second * 30
}
case ModeServerProducer:
// polling frames from remote RTSP Client (ex FFmpeg)
timeout = time.Second * 15
@@ -721,3 +728,12 @@ func (c *Conn) GetChannel(media *streamer.Media) int {
}
return -1
}
func (c *Conn) HasSendTracks() bool {
for _, track := range c.tracks {
if track.Direction == streamer.DirectionSendonly {
return true
}
}
return false
}