diff --git a/apidocs/openapi.yaml b/apidocs/openapi.yaml index d15fc097..ce96d11b 100644 --- a/apidocs/openapi.yaml +++ b/apidocs/openapi.yaml @@ -487,6 +487,8 @@ components: enum: [idle, read, publish] path: type: string + query: + type: string bytesReceived: type: integer format: int64 @@ -544,6 +546,8 @@ components: enum: [idle, read, publish] path: type: string + query: + type: string transport: type: string nullable: true @@ -578,6 +582,8 @@ components: enum: [idle, read, publish] path: type: string + query: + type: string bytesReceived: type: integer format: int64 @@ -615,6 +621,8 @@ components: enum: [read, publish] path: type: string + query: + type: string bytesReceived: type: integer format: int64 diff --git a/internal/core/api_test.go b/internal/core/api_test.go index 635f10ab..0ab8499f 100644 --- a/internal/core/api_test.go +++ b/internal/core/api_test.go @@ -688,7 +688,7 @@ func TestAPIProtocolList(t *testing.T) { case "rtsp conns", "rtsp sessions": source := gortsplib.Client{} - err := source.StartRecording("rtsp://localhost:8554/mypath", + err := source.StartRecording("rtsp://localhost:8554/mypath?key=val", &description.Session{Medias: []*description.Media{medi}}) require.NoError(t, err) defer source.Close() @@ -698,7 +698,7 @@ func TestAPIProtocolList(t *testing.T) { TLSConfig: &tls.Config{InsecureSkipVerify: true}, } - err := source.StartRecording("rtsps://localhost:8322/mypath", + err := source.StartRecording("rtsps://localhost:8322/mypath?key=val", &description.Session{Medias: []*description.Media{medi}}) require.NoError(t, err) defer source.Close() @@ -711,7 +711,7 @@ func TestAPIProtocolList(t *testing.T) { port = "1936" } - u, err := url.Parse("rtmp://127.0.0.1:" + port + "/mypath") + u, err := url.Parse("rtmp://127.0.0.1:" + port + "/mypath?key=val") require.NoError(t, err) nconn, err := func() (net.Conn, error) { @@ -795,7 +795,7 @@ func TestAPIProtocolList(t *testing.T) { require.NoError(t, err) defer source.Close() - u, err := url.Parse("http://localhost:8889/mypath/whep") + u, err := url.Parse("http://localhost:8889/mypath/whep?key=val") require.NoError(t, err) go func() { @@ -826,7 +826,7 @@ func TestAPIProtocolList(t *testing.T) { case "srt": conf := srt.DefaultConfig() - conf.StreamId = "publish:mypath" + conf.StreamId = "publish:mypath:::key=val" conn, err := srt.Dial("srt", "localhost:8890", conf) require.NoError(t, err) @@ -878,6 +878,7 @@ func TestAPIProtocolList(t *testing.T) { type item struct { State string `json:"state"` Path string `json:"path"` + Query string `json:"query"` } var out struct { @@ -890,6 +891,7 @@ func TestAPIProtocolList(t *testing.T) { require.Equal(t, item{ State: "publish", Path: "mypath", + Query: "key=val", }, out.Items[0]) } @@ -914,6 +916,7 @@ func TestAPIProtocolList(t *testing.T) { PeerConnectionEstablished bool `json:"peerConnectionEstablished"` State string `json:"state"` Path string `json:"path"` + Query string `json:"query"` } var out struct { @@ -926,6 +929,7 @@ func TestAPIProtocolList(t *testing.T) { PeerConnectionEstablished: true, State: "read", Path: "mypath", + Query: "key=val", }, out.Items[0]) } }) diff --git a/internal/defs/api.go b/internal/defs/api.go index f0f9150b..feaea0e6 100644 --- a/internal/defs/api.go +++ b/internal/defs/api.go @@ -61,22 +61,6 @@ type APIHLSMuxerList struct { Items []*APIHLSMuxer `json:"items"` } -// APIRTSPConn is a RTSP connection. -type APIRTSPConn struct { - ID uuid.UUID `json:"id"` - Created time.Time `json:"created"` - RemoteAddr string `json:"remoteAddr"` - BytesReceived uint64 `json:"bytesReceived"` - BytesSent uint64 `json:"bytesSent"` -} - -// APIRTSPConnsList is a list of RTSP connections. -type APIRTSPConnsList struct { - ItemCount int `json:"itemCount"` - PageCount int `json:"pageCount"` - Items []*APIRTSPConn `json:"items"` -} - // APIRTMPConnState is the state of a RTMP connection. type APIRTMPConnState string @@ -94,6 +78,7 @@ type APIRTMPConn struct { RemoteAddr string `json:"remoteAddr"` State APIRTMPConnState `json:"state"` Path string `json:"path"` + Query string `json:"query"` BytesReceived uint64 `json:"bytesReceived"` BytesSent uint64 `json:"bytesSent"` } @@ -105,6 +90,22 @@ type APIRTMPConnList struct { Items []*APIRTMPConn `json:"items"` } +// APIRTSPConn is a RTSP connection. +type APIRTSPConn struct { + ID uuid.UUID `json:"id"` + Created time.Time `json:"created"` + RemoteAddr string `json:"remoteAddr"` + BytesReceived uint64 `json:"bytesReceived"` + BytesSent uint64 `json:"bytesSent"` +} + +// APIRTSPConnsList is a list of RTSP connections. +type APIRTSPConnsList struct { + ItemCount int `json:"itemCount"` + PageCount int `json:"pageCount"` + Items []*APIRTSPConn `json:"items"` +} + // APIRTSPSessionState is the state of a RTSP session. type APIRTSPSessionState string @@ -122,6 +123,7 @@ type APIRTSPSession struct { RemoteAddr string `json:"remoteAddr"` State APIRTSPSessionState `json:"state"` Path string `json:"path"` + Query string `json:"query"` Transport *string `json:"transport"` BytesReceived uint64 `json:"bytesReceived"` BytesSent uint64 `json:"bytesSent"` @@ -151,6 +153,7 @@ type APISRTConn struct { RemoteAddr string `json:"remoteAddr"` State APISRTConnState `json:"state"` Path string `json:"path"` + Query string `json:"query"` BytesReceived uint64 `json:"bytesReceived"` BytesSent uint64 `json:"bytesSent"` } @@ -181,6 +184,7 @@ type APIWebRTCSession struct { RemoteCandidate string `json:"remoteCandidate"` State APIWebRTCSessionState `json:"state"` Path string `json:"path"` + Query string `json:"query"` BytesReceived uint64 `json:"bytesReceived"` BytesSent uint64 `json:"bytesSent"` } diff --git a/internal/servers/rtmp/conn.go b/internal/servers/rtmp/conn.go index 7907ef01..26a52f0e 100644 --- a/internal/servers/rtmp/conn.go +++ b/internal/servers/rtmp/conn.go @@ -71,6 +71,7 @@ type conn struct { rconn *rtmp.Conn state connState pathName string + query string } func (c *conn) initialize() { @@ -191,6 +192,7 @@ func (c *conn) runRead(conn *rtmp.Conn, u *url.URL) error { c.mutex.Lock() c.state = connStateRead c.pathName = pathName + c.query = rawQuery c.mutex.Unlock() writer := asyncwriter.New(c.writeQueueSize, c) @@ -421,6 +423,7 @@ func (c *conn) runPublish(conn *rtmp.Conn, u *url.URL) error { c.mutex.Lock() c.state = connStatePublish c.pathName = pathName + c.query = rawQuery c.mutex.Unlock() r, err := rtmp.NewReader(conn) @@ -594,6 +597,7 @@ func (c *conn) apiItem() *defs.APIRTMPConn { } }(), Path: c.pathName, + Query: c.query, BytesReceived: bytesReceived, BytesSent: bytesSent, } diff --git a/internal/servers/rtsp/session.go b/internal/servers/rtsp/session.go index 2150ec8e..9acf167b 100644 --- a/internal/servers/rtsp/session.go +++ b/internal/servers/rtsp/session.go @@ -40,6 +40,7 @@ type session struct { state gortsplib.ServerSessionState transport *gortsplib.Transport pathName string + query string decodeErrLogger logger.Writer writeErrLogger logger.Writer } @@ -140,6 +141,7 @@ func (s *session) onAnnounce(c *conn, ctx *gortsplib.ServerHandlerOnAnnounceCtx) s.mutex.Lock() s.state = gortsplib.ServerSessionStatePreRecord s.pathName = ctx.Path + s.query = ctx.Query s.mutex.Unlock() return &base.Response{ @@ -232,6 +234,7 @@ func (s *session) onSetup(c *conn, ctx *gortsplib.ServerHandlerOnSetupCtx, s.mutex.Lock() s.state = gortsplib.ServerSessionStatePrePlay s.pathName = ctx.Path + s.query = ctx.Query s.mutex.Unlock() var stream *gortsplib.ServerStream @@ -400,7 +403,8 @@ func (s *session) apiItem() *defs.APIRTSPSession { } return defs.APIRTSPSessionStateIdle }(), - Path: s.pathName, + Path: s.pathName, + Query: s.query, Transport: func() *string { if s.transport == nil { return nil diff --git a/internal/servers/srt/conn.go b/internal/servers/srt/conn.go index f9af9647..38238996 100644 --- a/internal/servers/srt/conn.go +++ b/internal/servers/srt/conn.go @@ -72,6 +72,7 @@ type conn struct { mutex sync.RWMutex state connState pathName string + query string sconn srt.Conn chNew chan srtNewConnReq @@ -218,6 +219,7 @@ func (c *conn) runPublish(req srtNewConnReq, pathName string, user string, pass c.mutex.Lock() c.state = connStatePublish c.pathName = pathName + c.query = query c.sconn = sconn c.mutex.Unlock() @@ -317,6 +319,7 @@ func (c *conn) runRead(req srtNewConnReq, pathName string, user string, pass str c.mutex.Lock() c.state = connStateRead c.pathName = pathName + c.query = query c.sconn = sconn c.mutex.Unlock() @@ -434,6 +437,7 @@ func (c *conn) apiItem() *defs.APISRTConn { } }(), Path: c.pathName, + Query: c.query, BytesReceived: bytesReceived, BytesSent: bytesSent, } diff --git a/internal/servers/webrtc/session.go b/internal/servers/webrtc/session.go index 4499ea70..142021b0 100644 --- a/internal/servers/webrtc/session.go +++ b/internal/servers/webrtc/session.go @@ -708,6 +708,7 @@ func (s *session) apiItem() *defs.APIWebRTCSession { return defs.APIWebRTCSessionStateRead }(), Path: s.req.pathName, + Query: s.req.query, BytesReceived: bytesReceived, BytesSent: bytesSent, }