mirror of
https://github.com/aler9/gortsplib
synced 2025-10-20 13:55:30 +08:00
add docs
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// ConnClient is a client-side RTSP connection.
|
||||
type ConnClient struct {
|
||||
nconn net.Conn
|
||||
br *bufio.Reader
|
||||
@@ -16,6 +17,7 @@ type ConnClient struct {
|
||||
authProv *authClientProvider
|
||||
}
|
||||
|
||||
// NewConnClient allocates a ConnClient.
|
||||
func NewConnClient(nconn net.Conn) *ConnClient {
|
||||
return &ConnClient{
|
||||
nconn: nconn,
|
||||
@@ -24,22 +26,29 @@ func NewConnClient(nconn net.Conn) *ConnClient {
|
||||
}
|
||||
}
|
||||
|
||||
// NetConn returns the underlying new.Conn.
|
||||
func (c *ConnClient) NetConn() net.Conn {
|
||||
return c.nconn
|
||||
}
|
||||
|
||||
// SetSession sets a Session header that is automatically inserted into every outgoing request.
|
||||
func (c *ConnClient) SetSession(v string) {
|
||||
c.session = v
|
||||
}
|
||||
|
||||
// EnableCseq allows to automatically insert the CSeq header into every outgoing request.
|
||||
// CSeq is incremented after every request.
|
||||
func (c *ConnClient) EnableCseq() {
|
||||
c.cseqEnabled = true
|
||||
}
|
||||
|
||||
// SetCredentials allows to automatically insert Authenticate header into every outgoing request.
|
||||
// The content of the header is computed with the given user, password, realm and nonce.
|
||||
func (c *ConnClient) SetCredentials(user string, pass string, realm string, nonce string) {
|
||||
c.authProv = newAuthClientProvider(user, pass, realm, nonce)
|
||||
}
|
||||
|
||||
// WriteRequest writes a Request.
|
||||
func (c *ConnClient) WriteRequest(req *Request) error {
|
||||
if c.session != "" {
|
||||
if req.Header == nil {
|
||||
@@ -63,14 +72,17 @@ func (c *ConnClient) WriteRequest(req *Request) error {
|
||||
return req.write(c.bw)
|
||||
}
|
||||
|
||||
// ReadResponse reads a response.
|
||||
func (c *ConnClient) ReadResponse() (*Response, error) {
|
||||
return readResponse(c.br)
|
||||
}
|
||||
|
||||
// ReadInterleavedFrame reads an InterleavedFrame.
|
||||
func (c *ConnClient) ReadInterleavedFrame() (*InterleavedFrame, error) {
|
||||
return readInterleavedFrame(c.br)
|
||||
}
|
||||
|
||||
// WriteInterleavedFrame writes an InterleavedFrame.
|
||||
func (c *ConnClient) WriteInterleavedFrame(frame *InterleavedFrame) error {
|
||||
return frame.write(c.bw)
|
||||
}
|
||||
|
Reference in New Issue
Block a user