mirror of
https://github.com/bluenviron/mediamtx.git
synced 2026-01-09 11:52:02 -08:00
more detailed error messages
This commit is contained in:
parent
f60e91baba
commit
ed715723f2
1 changed files with 34 additions and 6 deletions
|
|
@ -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 {
|
|||
|
||||
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 {
|
|||
|
||||
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 {
|
|||
}
|
||||
|
||||
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 {
|
|||
|
||||
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 {
|
|||
|
||||
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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue