protocol/rtsp: general naming clean up

This commit is contained in:
Saxon 2019-04-29 12:39:58 +09:30
parent d91995a1cf
commit 6605ee7295
2 changed files with 13 additions and 12 deletions

View File

@ -43,7 +43,7 @@ type Client struct {
sessionID string sessionID string
} }
// NewClient returns a pointer to a new Client. The URL u will be parsed and // NewClient returns a pointer to a new Client. The address addr will be parsed and
// a connection to the RTSP server will be made. // a connection to the RTSP server will be made.
func NewClient(addr string) (*Client, error) { func NewClient(addr string) (*Client, error) {
c := &Client{addr: addr} c := &Client{addr: addr}
@ -111,7 +111,7 @@ func (c *Client) Play() (*Response, error) {
return c.Do(req) return c.Do(req)
} }
// Do sends the given RTSP request r and reads any responses, return the response // Do sends the given RTSP request req, reads any responses and returns the response
// and any errors. // and any errors.
func (c *Client) Do(req *Request) (*Response, error) { func (c *Client) Do(req *Request) (*Response, error) {
err := req.Write(c.conn) err := req.Write(c.conn)
@ -119,14 +119,15 @@ func (c *Client) Do(req *Request) (*Response, error) {
return nil, err return nil, err
} }
res, err := ReadResponse(bufio.NewReader(c.conn)) resp, err := ReadResponse(bufio.NewReader(c.conn))
if err != nil { if err != nil {
return nil, err return nil, err
} }
return res, nil return resp, nil
} }
// nextCSeq provides the next CSeq number for the next RTSP request.
func (c *Client) nextCSeq() string { func (c *Client) nextCSeq() string {
c.cSeq++ c.cSeq++
return strconv.Itoa(c.cSeq) return strconv.Itoa(c.cSeq)

View File

@ -46,31 +46,31 @@ func main() {
panic(fmt.Sprintf("creating RTSP session failed with error: %v", err)) panic(fmt.Sprintf("creating RTSP session failed with error: %v", err))
} }
res, err := sess.Options() resp, err := sess.Options()
if err != nil { if err != nil {
log.Fatalln(err) log.Fatalln(err)
} }
fmt.Println("Options:") fmt.Println("Options:")
fmt.Println(res) fmt.Println(resp)
res, err = sess.Describe() resp, err = sess.Describe()
if err != nil { if err != nil {
log.Fatalln(err) log.Fatalln(err)
} }
fmt.Println("Describe:") fmt.Println("Describe:")
fmt.Println(res) fmt.Println(resp)
res, err = sess.Setup(*trackPtr, fmt.Sprintf("RTP/AVP;unicast;client_port=%d-%d", *clientPortPtr, *clientPortPtr+1)) resp, err = sess.Setup(*trackPtr, fmt.Sprintf("RTP/AVP;unicast;client_port=%d-%d", *clientPortPtr, *clientPortPtr+1))
if err != nil { if err != nil {
log.Fatalln(err) log.Fatalln(err)
} }
log.Println(res) log.Println(resp)
res, err = sess.Play() resp, err = sess.Play()
if err != nil { if err != nil {
log.Fatalln(err) log.Fatalln(err)
} }
log.Println(res) log.Println(resp)
// TODO(saxon): use RTCP client here to maintain stream. // TODO(saxon): use RTCP client here to maintain stream.
for { for {