|
|
|
@ -105,7 +105,7 @@ const (
@@ -105,7 +105,7 @@ const (
|
|
|
|
|
_CLIENT_STATE_RECORD |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
type client struct { |
|
|
|
|
type serverClient struct { |
|
|
|
|
p *program |
|
|
|
|
conn *gortsplib.ConnServer |
|
|
|
|
state clientState |
|
|
|
@ -119,8 +119,8 @@ type client struct {
@@ -119,8 +119,8 @@ type client struct {
|
|
|
|
|
chanWrite chan *gortsplib.InterleavedFrame |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func newClient(p *program, nconn net.Conn) *client { |
|
|
|
|
c := &client{ |
|
|
|
|
func newServerClient(p *program, nconn net.Conn) *serverClient { |
|
|
|
|
c := &serverClient{ |
|
|
|
|
p: p, |
|
|
|
|
conn: gortsplib.NewConnServer(nconn), |
|
|
|
|
state: _CLIENT_STATE_STARTING, |
|
|
|
@ -134,7 +134,7 @@ func newClient(p *program, nconn net.Conn) *client {
@@ -134,7 +134,7 @@ func newClient(p *program, nconn net.Conn) *client {
|
|
|
|
|
return c |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (c *client) close() error { |
|
|
|
|
func (c *serverClient) close() error { |
|
|
|
|
// already deleted
|
|
|
|
|
if _, ok := c.p.clients[c]; !ok { |
|
|
|
|
return nil |
|
|
|
@ -160,12 +160,12 @@ func (c *client) close() error {
@@ -160,12 +160,12 @@ func (c *client) close() error {
|
|
|
|
|
return nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (c *client) log(format string, args ...interface{}) { |
|
|
|
|
func (c *serverClient) log(format string, args ...interface{}) { |
|
|
|
|
format = "[RTSP client " + c.conn.NetConn().RemoteAddr().String() + "] " + format |
|
|
|
|
log.Printf(format, args...) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (c *client) run() { |
|
|
|
|
func (c *serverClient) run() { |
|
|
|
|
defer func() { |
|
|
|
|
if c.p.postScript != "" { |
|
|
|
|
postScript := exec.Command(c.p.postScript) |
|
|
|
@ -213,12 +213,12 @@ func (c *client) run() {
@@ -213,12 +213,12 @@ func (c *client) run() {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (c *client) writeResDeadline(res *gortsplib.Response) { |
|
|
|
|
func (c *serverClient) writeResDeadline(res *gortsplib.Response) { |
|
|
|
|
c.conn.NetConn().SetWriteDeadline(time.Now().Add(_WRITE_TIMEOUT)) |
|
|
|
|
c.conn.WriteResponse(res) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (c *client) writeResError(req *gortsplib.Request, err error) { |
|
|
|
|
func (c *serverClient) writeResError(req *gortsplib.Request, err error) { |
|
|
|
|
c.log("ERR: %s", err) |
|
|
|
|
|
|
|
|
|
if cseq, ok := req.Header["CSeq"]; ok && len(cseq) == 1 { |
|
|
|
@ -237,7 +237,7 @@ func (c *client) writeResError(req *gortsplib.Request, err error) {
@@ -237,7 +237,7 @@ func (c *client) writeResError(req *gortsplib.Request, err error) {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (c *client) handleRequest(req *gortsplib.Request) bool { |
|
|
|
|
func (c *serverClient) handleRequest(req *gortsplib.Request) bool { |
|
|
|
|
c.log(req.Method) |
|
|
|
|
|
|
|
|
|
cseq, ok := req.Header["CSeq"] |
|
|
|
|