mirror of
https://github.com/aler9/gortsplib
synced 2025-10-27 17:21:22 +08:00
add ConnClient.LoopUDP()
This commit is contained in:
@@ -20,8 +20,9 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
clientReadBufferSize = 4096
|
||||
clientWriteBufferSize = 4096
|
||||
clientReadBufferSize = 4096
|
||||
clientWriteBufferSize = 4096
|
||||
clientTcpKeepalivePeriod = 30 * time.Second
|
||||
)
|
||||
|
||||
// Track is a track available in a certain URL.
|
||||
@@ -403,3 +404,19 @@ func (c *ConnClient) Play(u *url.URL) (*Response, error) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// LoopUDP is called after setupping UDP tracks and calling Play(); it keeps
|
||||
// the TCP connection open through keepalives, and returns when the TCP
|
||||
// connection closes.
|
||||
func (c *ConnClient) LoopUDP(u *url.URL) (error) {
|
||||
keepaliveTicker := time.NewTicker(clientTcpKeepalivePeriod)
|
||||
defer keepaliveTicker.Stop()
|
||||
|
||||
for {
|
||||
<- keepaliveTicker.C
|
||||
_, err := c.Options(u)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user