diff --git a/README.md b/README.md index ecf4f59b..72a24c4f 100644 --- a/README.md +++ b/README.md @@ -87,4 +87,5 @@ Related projects * https://github.com/flaviostutz/rtsp-relay IETF Standard -* https://tools.ietf.org/html/rfc7826 +* (1.0) https://tools.ietf.org/html/rfc2326 +* (2.0) https://tools.ietf.org/html/rfc7826 diff --git a/go.mod b/go.mod index 4fbcf2de..62247302 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.13 require ( github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d // indirect - github.com/aler9/gortsplib v0.0.0-20200503131544-a171a9e328ec + github.com/aler9/gortsplib v0.0.0-20200503140554-28603af339e6 gopkg.in/alecthomas/kingpin.v2 v2.2.6 gortc.io/sdp v0.17.0 ) diff --git a/go.sum b/go.sum index ceadf6da..be79ba42 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,8 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafo github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d h1:UQZhZ2O0vMHr2cI+DC1Mbh0TJxzA3RcLoMsFw+aXw7E= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= -github.com/aler9/gortsplib v0.0.0-20200503131544-a171a9e328ec h1:8giuucZXMi/qEGru9Ic8Zxz6k6Jd2rASkFrVaslwr+s= -github.com/aler9/gortsplib v0.0.0-20200503131544-a171a9e328ec/go.mod h1:YiIgmmv0ELkWUy11Jj2h5AgfqLCpy8sIX/l9MmS8+uw= +github.com/aler9/gortsplib v0.0.0-20200503140554-28603af339e6 h1:41jZy+JIekzJXtYdkCsW9ts7D4jubfEVyjMCl7QY2wY= +github.com/aler9/gortsplib v0.0.0-20200503140554-28603af339e6/go.mod h1:YiIgmmv0ELkWUy11Jj2h5AgfqLCpy8sIX/l9MmS8+uw= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw= diff --git a/server-client.go b/server-client.go index 99feb81d..61e8015e 100644 --- a/server-client.go +++ b/server-client.go @@ -227,7 +227,7 @@ func (c *serverClient) writeResError(req *gortsplib.Request, code gortsplib.Stat } func (c *serverClient) handleRequest(req *gortsplib.Request) bool { - c.log(req.Method) + c.log(string(req.Method)) cseq, ok := req.Header["CSeq"] if !ok || len(cseq) != 1 { @@ -258,7 +258,7 @@ func (c *serverClient) handleRequest(req *gortsplib.Request) bool { }() switch req.Method { - case "OPTIONS": + case gortsplib.OPTIONS: // do not check state, since OPTIONS can be requested // in any state @@ -267,19 +267,19 @@ func (c *serverClient) handleRequest(req *gortsplib.Request) bool { Header: gortsplib.Header{ "CSeq": []string{cseq[0]}, "Public": []string{strings.Join([]string{ - "DESCRIBE", - "ANNOUNCE", - "SETUP", - "PLAY", - "PAUSE", - "RECORD", - "TEARDOWN", + string(gortsplib.DESCRIBE), + string(gortsplib.ANNOUNCE), + string(gortsplib.SETUP), + string(gortsplib.PLAY), + string(gortsplib.PAUSE), + string(gortsplib.RECORD), + string(gortsplib.TEARDOWN), }, ", ")}, }, }) return true - case "DESCRIBE": + case gortsplib.DESCRIBE: if c.state != _CLIENT_STATE_STARTING { c.writeResError(req, gortsplib.StatusBadRequest, fmt.Errorf("client is in state '%d'", c.state)) return false @@ -312,7 +312,7 @@ func (c *serverClient) handleRequest(req *gortsplib.Request) bool { }) return true - case "ANNOUNCE": + case gortsplib.ANNOUNCE: if c.state != _CLIENT_STATE_STARTING { c.writeResError(req, gortsplib.StatusBadRequest, fmt.Errorf("client is in state '%d'", c.state)) return false @@ -325,7 +325,7 @@ func (c *serverClient) handleRequest(req *gortsplib.Request) bool { c.as = gortsplib.NewAuthServer(c.p.publishUser, c.p.publishPass) } - err := c.as.ValidateHeader(req.Header["Authorization"], "ANNOUNCE", req.Url) + err := c.as.ValidateHeader(req.Header["Authorization"], gortsplib.ANNOUNCE, req.Url) if err != nil { if !initialRequest { c.log("ERR: Unauthorized: %s", err) @@ -395,7 +395,7 @@ func (c *serverClient) handleRequest(req *gortsplib.Request) bool { }) return true - case "SETUP": + case gortsplib.SETUP: tsRaw, ok := req.Header["Transport"] if !ok || len(tsRaw) != 1 { c.writeResError(req, gortsplib.StatusBadRequest, fmt.Errorf("transport header missing")) @@ -696,7 +696,7 @@ func (c *serverClient) handleRequest(req *gortsplib.Request) bool { return false } - case "PLAY": + case gortsplib.PLAY: if c.state != _CLIENT_STATE_PRE_PLAY { c.writeResError(req, gortsplib.StatusBadRequest, fmt.Errorf("client is in state '%d'", c.state)) return false @@ -773,7 +773,7 @@ func (c *serverClient) handleRequest(req *gortsplib.Request) bool { return true - case "PAUSE": + case gortsplib.PAUSE: if c.state != _CLIENT_STATE_PLAY { c.writeResError(req, gortsplib.StatusBadRequest, fmt.Errorf("client is in state '%d'", c.state)) return false @@ -799,7 +799,7 @@ func (c *serverClient) handleRequest(req *gortsplib.Request) bool { }) return true - case "RECORD": + case gortsplib.RECORD: if c.state != _CLIENT_STATE_PRE_RECORD { c.writeResError(req, gortsplib.StatusBadRequest, fmt.Errorf("client is in state '%d'", c.state)) return false @@ -869,7 +869,7 @@ func (c *serverClient) handleRequest(req *gortsplib.Request) bool { return true - case "TEARDOWN": + case gortsplib.TEARDOWN: // close connection silently return false