Merge pull request #41 from allenporter/rtsp-tls
Add support for rtsps streams
This commit is contained in:
commit
022deeb641
@ -4,6 +4,7 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
|
"crypto/tls"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"errors"
|
"errors"
|
||||||
@ -125,6 +126,14 @@ func Dial(options RTSPClientOptions) (*RTSPClient, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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.conn = conn
|
||||||
client.connRW = bufio.NewReadWriter(bufio.NewReader(conn), bufio.NewWriter(conn))
|
client.connRW = bufio.NewReadWriter(bufio.NewReader(conn), bufio.NewWriter(conn))
|
||||||
err = client.request(OPTIONS, nil, client.pURL.String(), false, false)
|
err = client.request(OPTIONS, nil, client.pURL.String(), false, false)
|
||||||
@ -485,7 +494,7 @@ func (client *RTSPClient) parseURL(rawURL string) error {
|
|||||||
if l.Port() == "" {
|
if l.Port() == "" {
|
||||||
l.Host = fmt.Sprintf("%s:%s", l.Host, "554")
|
l.Host = fmt.Sprintf("%s:%s", l.Host, "554")
|
||||||
}
|
}
|
||||||
if l.Scheme != "rtsp" {
|
if l.Scheme != "rtsp" && l.Scheme != "rtsps" {
|
||||||
l.Scheme = "rtsp"
|
l.Scheme = "rtsp"
|
||||||
}
|
}
|
||||||
client.pURL = l
|
client.pURL = l
|
||||||
|
Loading…
Reference in New Issue
Block a user