mirror of
https://github.com/aler9/gortsplib
synced 2025-10-05 15:16:51 +08:00
client: force TCP if encryption is active
This commit is contained in:
@@ -103,6 +103,11 @@ func (c ClientConf) Dial(scheme string, host string) (*ClientConn, error) {
|
|||||||
return nil, fmt.Errorf("unsupported scheme '%s'", scheme)
|
return nil, fmt.Errorf("unsupported scheme '%s'", scheme)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
v := StreamProtocolUDP
|
||||||
|
if scheme == "rtsps" && c.StreamProtocol == &v {
|
||||||
|
return nil, fmt.Errorf("RTSPS can't be used with UDP")
|
||||||
|
}
|
||||||
|
|
||||||
if !strings.Contains(host, ":") {
|
if !strings.Contains(host, ":") {
|
||||||
host += ":554"
|
host += ":554"
|
||||||
}
|
}
|
||||||
@@ -122,6 +127,7 @@ func (c ClientConf) Dial(scheme string, host string) (*ClientConn, error) {
|
|||||||
return &ClientConn{
|
return &ClientConn{
|
||||||
conf: c,
|
conf: c,
|
||||||
nconn: nconn,
|
nconn: nconn,
|
||||||
|
isTLS: (scheme == "rtsps"),
|
||||||
br: bufio.NewReaderSize(conn, clientReadBufferSize),
|
br: bufio.NewReaderSize(conn, clientReadBufferSize),
|
||||||
bw: bufio.NewWriterSize(conn, clientWriteBufferSize),
|
bw: bufio.NewWriterSize(conn, clientWriteBufferSize),
|
||||||
udpRtpListeners: make(map[int]*clientConnUDPListener),
|
udpRtpListeners: make(map[int]*clientConnUDPListener),
|
||||||
|
@@ -65,6 +65,7 @@ func (s clientConnState) String() string {
|
|||||||
type ClientConn struct {
|
type ClientConn struct {
|
||||||
conf ClientConf
|
conf ClientConf
|
||||||
nconn net.Conn
|
nconn net.Conn
|
||||||
|
isTLS bool
|
||||||
br *bufio.Reader
|
br *bufio.Reader
|
||||||
bw *bufio.Writer
|
bw *bufio.Writer
|
||||||
session string
|
session string
|
||||||
@@ -386,6 +387,12 @@ func (c *ClientConn) Setup(mode headers.TransportMode, track *Track,
|
|||||||
var rtpListener *clientConnUDPListener
|
var rtpListener *clientConnUDPListener
|
||||||
var rtcpListener *clientConnUDPListener
|
var rtcpListener *clientConnUDPListener
|
||||||
|
|
||||||
|
// always use TCP if encrypted
|
||||||
|
if c.isTLS {
|
||||||
|
v := StreamProtocolTCP
|
||||||
|
c.streamProtocol = &v
|
||||||
|
}
|
||||||
|
|
||||||
proto := func() StreamProtocol {
|
proto := func() StreamProtocol {
|
||||||
// protocol set by previous Setup()
|
// protocol set by previous Setup()
|
||||||
if c.streamProtocol != nil {
|
if c.streamProtocol != nil {
|
||||||
@@ -397,7 +404,7 @@ func (c *ClientConn) Setup(mode headers.TransportMode, track *Track,
|
|||||||
return *c.conf.StreamProtocol
|
return *c.conf.StreamProtocol
|
||||||
}
|
}
|
||||||
|
|
||||||
// try udp
|
// try UDP
|
||||||
return StreamProtocolUDP
|
return StreamProtocolUDP
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user