protocol/rtsp: using string literals for request methods

This commit is contained in:
Saxon 2019-04-28 00:53:47 +09:30
parent 2f752d5b7f
commit 07e7235dc4
3 changed files with 8 additions and 16 deletions

View File

@ -61,7 +61,7 @@ func NewClient(addr string) (*Client, error) {
// Describe forms and sends an RTSP request of method DESCRIBE to the RTSP server. // Describe forms and sends an RTSP request of method DESCRIBE to the RTSP server.
func (c *Client) Describe() (*Response, error) { func (c *Client) Describe() (*Response, error) {
req, err := NewRequest(describe, c.nextCSeq(), c.url, nil) req, err := NewRequest("DESCRIBE", c.nextCSeq(), c.url, nil)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -71,7 +71,7 @@ func (c *Client) Describe() (*Response, error) {
// Options forms and sends an RTSP request of method OPTIONS to the RTSP server. // Options forms and sends an RTSP request of method OPTIONS to the RTSP server.
func (c *Client) Options() (*Response, error) { func (c *Client) Options() (*Response, error) {
req, err := NewRequest(options, c.nextCSeq(), c.url, nil) req, err := NewRequest("OPTIONS", c.nextCSeq(), c.url, nil)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -85,7 +85,7 @@ func (c *Client) Setup(track, transport string) (*Response, error) {
return nil, err return nil, err
} }
req, err := NewRequest(setup, c.nextCSeq(), url, nil) req, err := NewRequest("SETUP", c.nextCSeq(), url, nil)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -102,7 +102,7 @@ func (c *Client) Setup(track, transport string) (*Response, error) {
// Play forms and sends an RTSP request of method PLAY to the RTSP server // Play forms and sends an RTSP request of method PLAY to the RTSP server
func (c *Client) Play() (*Response, error) { func (c *Client) Play() (*Response, error) {
req, err := NewRequest(play, c.nextCSeq(), c.url, nil) req, err := NewRequest("PLAY", c.nextCSeq(), c.url, nil)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -69,14 +69,6 @@ import (
"strings" "strings"
) )
// RTSP methods.
const (
describe = "DESCRIBE"
options = "OPTIONS"
play = "PLAY"
setup = "SETUP"
)
// Minimum response size to be considered valid. // Minimum response size to be considered valid.
const minResponse = 2 const minResponse = 2

View File

@ -58,7 +58,7 @@ func TestMethods(t *testing.T) {
}{ }{
{ {
method: func(c *Client) (*Response, error) { method: func(c *Client) (*Response, error) {
req, err := NewRequest(describe, c.nextCSeq(), url, nil) req, err := NewRequest("DESCRIBE", c.nextCSeq(), url, nil)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -79,7 +79,7 @@ func TestMethods(t *testing.T) {
}, },
{ {
method: func(c *Client) (*Response, error) { method: func(c *Client) (*Response, error) {
req, err := NewRequest(options, c.nextCSeq(), url, nil) req, err := NewRequest("OPTIONS", c.nextCSeq(), url, nil)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -102,7 +102,7 @@ func TestMethods(t *testing.T) {
return nil, err return nil, err
} }
req, err := NewRequest(setup, c.nextCSeq(), u, nil) req, err := NewRequest("SETUP", c.nextCSeq(), u, nil)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -126,7 +126,7 @@ func TestMethods(t *testing.T) {
}, },
{ {
method: func(c *Client) (*Response, error) { method: func(c *Client) (*Response, error) {
req, err := NewRequest(play, c.nextCSeq(), url, nil) req, err := NewRequest("PLAY", c.nextCSeq(), url, nil)
if err != nil { if err != nil {
return nil, err return nil, err
} }