diff --git a/format/rtspv2/client.go b/format/rtspv2/client.go index 9811c82..26512f4 100644 --- a/format/rtspv2/client.go +++ b/format/rtspv2/client.go @@ -4,6 +4,7 @@ import ( "bufio" "bytes" "crypto/md5" + "crypto/tls" "encoding/base64" "encoding/binary" "errors" @@ -125,6 +126,14 @@ func Dial(options RTSPClientOptions) (*RTSPClient, error) { if err != nil { return nil, err } + if client.pURL.Scheme == "rtsps" { + tlsConn := tls.Client(conn, &tls.Config{ServerName: client.pURL.Hostname()}) + err = tlsConn.Handshake() + if err != nil { + return nil, err + } + conn = tlsConn + } client.conn = conn client.connRW = bufio.NewReadWriter(bufio.NewReader(conn), bufio.NewWriter(conn)) err = client.request(OPTIONS, nil, client.pURL.String(), false, false) @@ -485,7 +494,7 @@ func (client *RTSPClient) parseURL(rawURL string) error { if l.Port() == "" { l.Host = fmt.Sprintf("%s:%s", l.Host, "554") } - if l.Scheme != "rtsp" { + if l.Scheme != "rtsp" && l.Scheme != "rtsps" { l.Scheme = "rtsp" } client.pURL = l