Fix timeout for RTSP with only Recv track
This commit is contained in:
+17
-1
@@ -559,9 +559,16 @@ func (c *Conn) Handle() (err error) {
|
|||||||
switch c.mode {
|
switch c.mode {
|
||||||
case ModeClientProducer:
|
case ModeClientProducer:
|
||||||
// polling frames from remote RTSP Server (ex Camera)
|
// polling frames from remote RTSP Server (ex Camera)
|
||||||
timeout = time.Second * 5
|
|
||||||
go c.keepalive()
|
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:
|
case ModeServerProducer:
|
||||||
// polling frames from remote RTSP Client (ex FFmpeg)
|
// polling frames from remote RTSP Client (ex FFmpeg)
|
||||||
timeout = time.Second * 15
|
timeout = time.Second * 15
|
||||||
@@ -721,3 +728,12 @@ func (c *Conn) GetChannel(media *streamer.Media) int {
|
|||||||
}
|
}
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Conn) HasSendTracks() bool {
|
||||||
|
for _, track := range c.tracks {
|
||||||
|
if track.Direction == streamer.DirectionSendonly {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user