Rtsp: add DialWithConn
This commit is contained in:
parent
7a563b07e3
commit
7d6ed926f2
@ -106,6 +106,21 @@ type RTSPClientOptions struct {
|
||||
}
|
||||
|
||||
func Dial(options RTSPClientOptions) (*RTSPClient, error) {
|
||||
u, err := url.Parse(options.URL)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if u.Port() == "" {
|
||||
u.Host = fmt.Sprintf("%s:%s", u.Host, "554")
|
||||
}
|
||||
conn, err := net.DialTimeout("tcp", u.Host, options.DialTimeout)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return DialWithConn(options, conn)
|
||||
}
|
||||
|
||||
func DialWithConn(options RTSPClientOptions, conn net.Conn) (*RTSPClient, error) {
|
||||
client := &RTSPClient{
|
||||
headers: make(map[string]string),
|
||||
Signals: make(chan int, 100),
|
||||
@ -124,10 +139,6 @@ func Dial(options RTSPClientOptions) (*RTSPClient, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
conn, err := net.DialTimeout("tcp", client.pURL.Host, client.options.DialTimeout)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = conn.SetDeadline(time.Now().Add(client.options.ReadWriteTimeout))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
Loading…
Reference in New Issue
Block a user