Add support custom timeout for RTSP source

This commit is contained in:
Alexey Khit
2023-08-23 14:08:15 +03:00
parent b1c0a28366
commit 9f9dc7e844
6 changed files with 24 additions and 13 deletions
+5 -1
View File
@@ -31,7 +31,11 @@ func (c *Conn) Dial() (err error) {
var conn net.Conn
if c.Transport == "" {
conn, err = tcp.Dial(c.URL, "554")
timeout := core.ConnDialTimeout
if c.Timeout != 0 {
timeout = time.Second * time.Duration(c.Timeout)
}
conn, err = tcp.Dial(c.URL, "554", timeout)
} else {
conn, err = websocket.Dial(c.Transport)
}
+11 -6
View File
@@ -26,6 +26,7 @@ type Conn struct {
Media string
PacketSize uint16
SessionName string
Timeout int
Transport string // custom transport support, ex. RTSP over WebSocket
Medias []*core.Media
@@ -108,13 +109,17 @@ func (c *Conn) Handle() (err error) {
}
keepaliveTS = time.Now().Add(keepaliveDT)
// polling frames from remote RTSP Server (ex Camera)
if len(c.receivers) > 0 {
// if we receiving video/audio from camera
timeout = time.Second * 5
if c.Timeout == 0 {
// polling frames from remote RTSP Server (ex Camera)
if len(c.receivers) > 0 {
// if we receiving video/audio from camera
timeout = time.Second * 5
} else {
// if we only send audio to camera
timeout = time.Second * 30
}
} else {
// if we only send audio to camera
timeout = time.Second * 30
timeout = time.Second * time.Duration(c.Timeout)
}
case core.ModePassiveProducer: