remove Func suffix from DialTimeout and ListenPacket options

This commit is contained in:
aler9
2020-07-28 16:29:12 +02:00
parent 179f58c59a
commit 51805a4883
2 changed files with 10 additions and 8 deletions

View File

@@ -19,8 +19,8 @@ func newConnClientUdpListener(c *ConnClient, port int, trackId int, streamType S
var pc net.PacketConn
var err error
if c.conf.ListenPacketFunc != nil {
pc, err = c.conf.ListenPacketFunc("udp", ":"+strconv.FormatInt(int64(port), 10))
if c.conf.ListenPacket != nil {
pc, err = c.conf.ListenPacket("udp", ":"+strconv.FormatInt(int64(port), 10))
if err != nil {
return nil, err
}

View File

@@ -49,11 +49,13 @@ type ConnClientConf struct {
// It defaults to 5 seconds
WriteTimeout time.Duration
// (optional) allow for custom dialer
DialTimeoutFunc func(network, address string, timeout time.Duration) (net.Conn, error)
// (optional) function used to initialize the TCP client.
// It defaults to net.DialTimeout
DialTimeout func(network, address string, timeout time.Duration) (net.Conn, error)
// (optional) allow for custom udp listener
ListenPacketFunc func(network, address string) (net.PacketConn, error)
// (optional) function used to initialize UDP listeners.
// It defaults to net.ListenPacket
ListenPacket func(network, address string) (net.PacketConn, error)
}
// ConnClient is a client-side RTSP connection.
@@ -86,8 +88,8 @@ func NewConnClient(conf ConnClientConf) (*ConnClient, error) {
var nconn net.Conn
var err error
if conf.DialTimeoutFunc != nil {
nconn, err = conf.DialTimeoutFunc("tcp", conf.Host, conf.ReadTimeout)
if conf.DialTimeout != nil {
nconn, err = conf.DialTimeout("tcp", conf.Host, conf.ReadTimeout)
if err != nil {
return nil, err
}