|
|
|
@ -38,6 +38,29 @@ const (
@@ -38,6 +38,29 @@ const (
|
|
|
|
|
_CLIENT_STATE_RECORD |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
func (cs clientState) String() string { |
|
|
|
|
switch cs { |
|
|
|
|
case _CLIENT_STATE_STARTING: |
|
|
|
|
return "STARTING" |
|
|
|
|
|
|
|
|
|
case _CLIENT_STATE_ANNOUNCE: |
|
|
|
|
return "ANNOUNCE" |
|
|
|
|
|
|
|
|
|
case _CLIENT_STATE_PRE_PLAY: |
|
|
|
|
return "PRE_PLAY" |
|
|
|
|
|
|
|
|
|
case _CLIENT_STATE_PLAY: |
|
|
|
|
return "PLAY" |
|
|
|
|
|
|
|
|
|
case _CLIENT_STATE_PRE_RECORD: |
|
|
|
|
return "PRE_RECORD" |
|
|
|
|
|
|
|
|
|
case _CLIENT_STATE_RECORD: |
|
|
|
|
return "RECORD" |
|
|
|
|
} |
|
|
|
|
return "UNKNOWN" |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
type serverClient struct { |
|
|
|
|
p *program |
|
|
|
|
conn *gortsplib.ConnServer |
|
|
|
@ -263,7 +286,8 @@ func (c *serverClient) handleRequest(req *gortsplib.Request) bool {
@@ -263,7 +286,8 @@ func (c *serverClient) handleRequest(req *gortsplib.Request) bool {
|
|
|
|
|
|
|
|
|
|
case gortsplib.DESCRIBE: |
|
|
|
|
if c.state != _CLIENT_STATE_STARTING { |
|
|
|
|
c.writeResError(req, gortsplib.StatusBadRequest, fmt.Errorf("client is in state '%d'", c.state)) |
|
|
|
|
c.writeResError(req, gortsplib.StatusBadRequest, |
|
|
|
|
fmt.Errorf("client is in state '%s' instead of '%s'", c.state, _CLIENT_STATE_STARTING)) |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -304,7 +328,8 @@ func (c *serverClient) handleRequest(req *gortsplib.Request) bool {
@@ -304,7 +328,8 @@ func (c *serverClient) handleRequest(req *gortsplib.Request) bool {
|
|
|
|
|
|
|
|
|
|
case gortsplib.ANNOUNCE: |
|
|
|
|
if c.state != _CLIENT_STATE_STARTING { |
|
|
|
|
c.writeResError(req, gortsplib.StatusBadRequest, fmt.Errorf("client is in state '%d'", c.state)) |
|
|
|
|
c.writeResError(req, gortsplib.StatusBadRequest, |
|
|
|
|
fmt.Errorf("client is in state '%s' instead of '%s'", c.state, _CLIENT_STATE_STARTING)) |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -669,13 +694,14 @@ func (c *serverClient) handleRequest(req *gortsplib.Request) bool {
@@ -669,13 +694,14 @@ func (c *serverClient) handleRequest(req *gortsplib.Request) bool {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
default: |
|
|
|
|
c.writeResError(req, gortsplib.StatusBadRequest, fmt.Errorf("client is in state '%d'", c.state)) |
|
|
|
|
c.writeResError(req, gortsplib.StatusBadRequest, fmt.Errorf("client is in state '%s'", c.state)) |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
case gortsplib.PLAY: |
|
|
|
|
if c.state != _CLIENT_STATE_PRE_PLAY { |
|
|
|
|
c.writeResError(req, gortsplib.StatusBadRequest, fmt.Errorf("client is in state '%d'", c.state)) |
|
|
|
|
c.writeResError(req, gortsplib.StatusBadRequest, |
|
|
|
|
fmt.Errorf("client is in state '%s' instead of '%s'", c.state, _CLIENT_STATE_PRE_PLAY)) |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -752,7 +778,8 @@ func (c *serverClient) handleRequest(req *gortsplib.Request) bool {
@@ -752,7 +778,8 @@ func (c *serverClient) handleRequest(req *gortsplib.Request) bool {
|
|
|
|
|
|
|
|
|
|
case gortsplib.PAUSE: |
|
|
|
|
if c.state != _CLIENT_STATE_PLAY { |
|
|
|
|
c.writeResError(req, gortsplib.StatusBadRequest, fmt.Errorf("client is in state '%d'", c.state)) |
|
|
|
|
c.writeResError(req, gortsplib.StatusBadRequest, |
|
|
|
|
fmt.Errorf("client is in state '%s' instead of '%s'", c.state, _CLIENT_STATE_PLAY)) |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -778,7 +805,8 @@ func (c *serverClient) handleRequest(req *gortsplib.Request) bool {
@@ -778,7 +805,8 @@ func (c *serverClient) handleRequest(req *gortsplib.Request) bool {
|
|
|
|
|
|
|
|
|
|
case gortsplib.RECORD: |
|
|
|
|
if c.state != _CLIENT_STATE_PRE_RECORD { |
|
|
|
|
c.writeResError(req, gortsplib.StatusBadRequest, fmt.Errorf("client is in state '%d'", c.state)) |
|
|
|
|
c.writeResError(req, gortsplib.StatusBadRequest, |
|
|
|
|
fmt.Errorf("client is in state '%s' instead of '%s'", c.state, _CLIENT_STATE_PRE_RECORD)) |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|