From 2c1edabaed076313ed23ce6eb1b4de29f38f0f15 Mon Sep 17 00:00:00 2001 From: aler9 <46489434+aler9@users.noreply.github.com> Date: Thu, 23 Jun 2022 10:39:13 +0200 Subject: [PATCH] update docs --- client.go | 48 ++++++++++++++++++++++++------------------------ server.go | 32 ++++++++++++++++---------------- 2 files changed, 40 insertions(+), 40 deletions(-) diff --git a/client.go b/client.go index 30b78dd2..e63f76ce 100644 --- a/client.go +++ b/client.go @@ -178,19 +178,7 @@ type ClientOnPacketRTCPCtx struct { // Client is a RTSP client. type Client struct { // - // callbacks - // - // 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 + // RTSP parameters (all optional) // // timeout of read operations. // It defaults to 10 seconds. @@ -231,7 +219,7 @@ type Client struct { UserAgent string // - // system functions + // system functions (all optional) // // function used to initialize the TCP client. // It defaults to (&net.Dialer{}).DialContext. @@ -240,6 +228,18 @@ type Client struct { // It defaults to net.ListenPacket. 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 // @@ -302,16 +302,6 @@ type Client struct { // Start initializes the connection to a server. 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 if c.ReadTimeout == 0 { c.ReadTimeout = 10 * time.Second @@ -340,6 +330,16 @@ func (c *Client) Start(scheme string, host string) error { c.ListenPacket = net.ListenPacket } + // callbacks + if c.OnPacketRTP == nil { + c.OnPacketRTP = func(ctx *ClientOnPacketRTPCtx) { + } + } + if c.OnPacketRTCP == nil { + c.OnPacketRTCP = func(ctx *ClientOnPacketRTCPCtx) { + } + } + // private if c.udpSenderReportPeriod == 0 { c.udpSenderReportPeriod = 10 * time.Second diff --git a/server.go b/server.go index 6ff3edc5..34c000b6 100644 --- a/server.go +++ b/server.go @@ -66,25 +66,11 @@ type streamMulticastIPReq struct { // Server is a RTSP server. 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 // packets with the TCP transport. 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. // If UDPRTPAddress and UDPRTCPAddress are filled, the server can support the UDP transport. UDPRTPAddress string @@ -103,6 +89,14 @@ type Server struct { // If MulticastIPRange, MulticastRTPPort, MulticastRTCPPort are filled, the server // can support the UDP-multicast transport. 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. // If greater than 1, allows to pass buffers to routines different than the one // that is reading frames. @@ -116,7 +110,13 @@ type Server struct { 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. // It defaults to net.Listen.