update docs

This commit is contained in:
aler9
2022-06-23 10:39:13 +02:00
parent fa36721df4
commit 2c1edabaed
2 changed files with 40 additions and 40 deletions

View File

@@ -178,19 +178,7 @@ type ClientOnPacketRTCPCtx struct {
// Client is a RTSP client. // Client is a RTSP client.
type Client struct { type Client struct {
// //
// callbacks // RTSP parameters (all optional)
//
// called before every request.
OnRequest func(*base.Request)
// called after every response.
OnResponse func(*base.Response)
// called when a RTP packet arrives.
OnPacketRTP func(*ClientOnPacketRTPCtx)
// called when a RTCP packet arrives.
OnPacketRTCP func(*ClientOnPacketRTCPCtx)
//
// RTSP parameters
// //
// timeout of read operations. // timeout of read operations.
// It defaults to 10 seconds. // It defaults to 10 seconds.
@@ -231,7 +219,7 @@ type Client struct {
UserAgent string UserAgent string
// //
// system functions // system functions (all optional)
// //
// function used to initialize the TCP client. // function used to initialize the TCP client.
// It defaults to (&net.Dialer{}).DialContext. // It defaults to (&net.Dialer{}).DialContext.
@@ -240,6 +228,18 @@ type Client struct {
// It defaults to net.ListenPacket. // It defaults to net.ListenPacket.
ListenPacket func(network, address string) (net.PacketConn, error) ListenPacket func(network, address string) (net.PacketConn, error)
//
// callbacks (all optional)
//
// called before every request.
OnRequest func(*base.Request)
// called after every response.
OnResponse func(*base.Response)
// called when a RTP packet arrives.
OnPacketRTP func(*ClientOnPacketRTPCtx)
// called when a RTCP packet arrives.
OnPacketRTCP func(*ClientOnPacketRTCPCtx)
// //
// private // private
// //
@@ -302,16 +302,6 @@ type Client struct {
// Start initializes the connection to a server. // Start initializes the connection to a server.
func (c *Client) Start(scheme string, host string) error { func (c *Client) Start(scheme string, host string) error {
// callbacks
if c.OnPacketRTP == nil {
c.OnPacketRTP = func(ctx *ClientOnPacketRTPCtx) {
}
}
if c.OnPacketRTCP == nil {
c.OnPacketRTCP = func(ctx *ClientOnPacketRTCPCtx) {
}
}
// RTSP parameters // RTSP parameters
if c.ReadTimeout == 0 { if c.ReadTimeout == 0 {
c.ReadTimeout = 10 * time.Second c.ReadTimeout = 10 * time.Second
@@ -340,6 +330,16 @@ func (c *Client) Start(scheme string, host string) error {
c.ListenPacket = net.ListenPacket c.ListenPacket = net.ListenPacket
} }
// callbacks
if c.OnPacketRTP == nil {
c.OnPacketRTP = func(ctx *ClientOnPacketRTPCtx) {
}
}
if c.OnPacketRTCP == nil {
c.OnPacketRTCP = func(ctx *ClientOnPacketRTCPCtx) {
}
}
// private // private
if c.udpSenderReportPeriod == 0 { if c.udpSenderReportPeriod == 0 {
c.udpSenderReportPeriod = 10 * time.Second c.udpSenderReportPeriod = 10 * time.Second

View File

@@ -66,25 +66,11 @@ type streamMulticastIPReq struct {
// Server is a RTSP server. // Server is a RTSP server.
type Server struct { type Server struct {
// //
// handler // RTSP parameters (all optional except RTSPAddress)
// //
// an handler to handle server events.
Handler ServerHandler
//
// RTSP parameters
//
// timeout of read operations.
// It defaults to 10 seconds
ReadTimeout time.Duration
// timeout of write operations.
// It defaults to 10 seconds
WriteTimeout time.Duration
// the RTSP address of the server, to accept connections and send and receive // the RTSP address of the server, to accept connections and send and receive
// packets with the TCP transport. // packets with the TCP transport.
RTSPAddress string RTSPAddress string
// a TLS configuration to accept TLS (RTSPS) connections.
TLSConfig *tls.Config
// a port to send and receive RTP packets with the UDP transport. // a port to send and receive RTP packets with the UDP transport.
// If UDPRTPAddress and UDPRTCPAddress are filled, the server can support the UDP transport. // If UDPRTPAddress and UDPRTCPAddress are filled, the server can support the UDP transport.
UDPRTPAddress string UDPRTPAddress string
@@ -103,6 +89,14 @@ type Server struct {
// If MulticastIPRange, MulticastRTPPort, MulticastRTCPPort are filled, the server // If MulticastIPRange, MulticastRTPPort, MulticastRTCPPort are filled, the server
// can support the UDP-multicast transport. // can support the UDP-multicast transport.
MulticastRTCPPort int MulticastRTCPPort int
// timeout of read operations.
// It defaults to 10 seconds
ReadTimeout time.Duration
// timeout of write operations.
// It defaults to 10 seconds
WriteTimeout time.Duration
// a TLS configuration to accept TLS (RTSPS) connections.
TLSConfig *tls.Config
// read buffer count. // read buffer count.
// If greater than 1, allows to pass buffers to routines different than the one // If greater than 1, allows to pass buffers to routines different than the one
// that is reading frames. // that is reading frames.
@@ -116,7 +110,13 @@ type Server struct {
WriteBufferCount int WriteBufferCount int
// //
// system functions // handler (optional)
//
// an handler to handle server events.
Handler ServerHandler
//
// system functions (all optional)
// //
// function used to initialize the TCP listener. // function used to initialize the TCP listener.
// It defaults to net.Listen. // It defaults to net.Listen.