forked from External/mediamtx
This commit is contained in:
parent
1341421412
commit
598fadc9fb
7 changed files with 51 additions and 22 deletions
|
|
@ -487,6 +487,8 @@ components:
|
||||||
enum: [idle, read, publish]
|
enum: [idle, read, publish]
|
||||||
path:
|
path:
|
||||||
type: string
|
type: string
|
||||||
|
query:
|
||||||
|
type: string
|
||||||
bytesReceived:
|
bytesReceived:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
|
|
@ -544,6 +546,8 @@ components:
|
||||||
enum: [idle, read, publish]
|
enum: [idle, read, publish]
|
||||||
path:
|
path:
|
||||||
type: string
|
type: string
|
||||||
|
query:
|
||||||
|
type: string
|
||||||
transport:
|
transport:
|
||||||
type: string
|
type: string
|
||||||
nullable: true
|
nullable: true
|
||||||
|
|
@ -578,6 +582,8 @@ components:
|
||||||
enum: [idle, read, publish]
|
enum: [idle, read, publish]
|
||||||
path:
|
path:
|
||||||
type: string
|
type: string
|
||||||
|
query:
|
||||||
|
type: string
|
||||||
bytesReceived:
|
bytesReceived:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
|
|
@ -615,6 +621,8 @@ components:
|
||||||
enum: [read, publish]
|
enum: [read, publish]
|
||||||
path:
|
path:
|
||||||
type: string
|
type: string
|
||||||
|
query:
|
||||||
|
type: string
|
||||||
bytesReceived:
|
bytesReceived:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
|
|
|
||||||
|
|
@ -688,7 +688,7 @@ func TestAPIProtocolList(t *testing.T) {
|
||||||
case "rtsp conns", "rtsp sessions":
|
case "rtsp conns", "rtsp sessions":
|
||||||
source := gortsplib.Client{}
|
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}})
|
&description.Session{Medias: []*description.Media{medi}})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer source.Close()
|
defer source.Close()
|
||||||
|
|
@ -698,7 +698,7 @@ func TestAPIProtocolList(t *testing.T) {
|
||||||
TLSConfig: &tls.Config{InsecureSkipVerify: true},
|
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}})
|
&description.Session{Medias: []*description.Media{medi}})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer source.Close()
|
defer source.Close()
|
||||||
|
|
@ -711,7 +711,7 @@ func TestAPIProtocolList(t *testing.T) {
|
||||||
port = "1936"
|
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)
|
require.NoError(t, err)
|
||||||
|
|
||||||
nconn, err := func() (net.Conn, error) {
|
nconn, err := func() (net.Conn, error) {
|
||||||
|
|
@ -795,7 +795,7 @@ func TestAPIProtocolList(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer source.Close()
|
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)
|
require.NoError(t, err)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
|
@ -826,7 +826,7 @@ func TestAPIProtocolList(t *testing.T) {
|
||||||
|
|
||||||
case "srt":
|
case "srt":
|
||||||
conf := srt.DefaultConfig()
|
conf := srt.DefaultConfig()
|
||||||
conf.StreamId = "publish:mypath"
|
conf.StreamId = "publish:mypath:::key=val"
|
||||||
|
|
||||||
conn, err := srt.Dial("srt", "localhost:8890", conf)
|
conn, err := srt.Dial("srt", "localhost:8890", conf)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
@ -878,6 +878,7 @@ func TestAPIProtocolList(t *testing.T) {
|
||||||
type item struct {
|
type item struct {
|
||||||
State string `json:"state"`
|
State string `json:"state"`
|
||||||
Path string `json:"path"`
|
Path string `json:"path"`
|
||||||
|
Query string `json:"query"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var out struct {
|
var out struct {
|
||||||
|
|
@ -890,6 +891,7 @@ func TestAPIProtocolList(t *testing.T) {
|
||||||
require.Equal(t, item{
|
require.Equal(t, item{
|
||||||
State: "publish",
|
State: "publish",
|
||||||
Path: "mypath",
|
Path: "mypath",
|
||||||
|
Query: "key=val",
|
||||||
}, out.Items[0])
|
}, out.Items[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -914,6 +916,7 @@ func TestAPIProtocolList(t *testing.T) {
|
||||||
PeerConnectionEstablished bool `json:"peerConnectionEstablished"`
|
PeerConnectionEstablished bool `json:"peerConnectionEstablished"`
|
||||||
State string `json:"state"`
|
State string `json:"state"`
|
||||||
Path string `json:"path"`
|
Path string `json:"path"`
|
||||||
|
Query string `json:"query"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var out struct {
|
var out struct {
|
||||||
|
|
@ -926,6 +929,7 @@ func TestAPIProtocolList(t *testing.T) {
|
||||||
PeerConnectionEstablished: true,
|
PeerConnectionEstablished: true,
|
||||||
State: "read",
|
State: "read",
|
||||||
Path: "mypath",
|
Path: "mypath",
|
||||||
|
Query: "key=val",
|
||||||
}, out.Items[0])
|
}, out.Items[0])
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -61,22 +61,6 @@ type APIHLSMuxerList struct {
|
||||||
Items []*APIHLSMuxer `json:"items"`
|
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.
|
// APIRTMPConnState is the state of a RTMP connection.
|
||||||
type APIRTMPConnState string
|
type APIRTMPConnState string
|
||||||
|
|
||||||
|
|
@ -94,6 +78,7 @@ type APIRTMPConn struct {
|
||||||
RemoteAddr string `json:"remoteAddr"`
|
RemoteAddr string `json:"remoteAddr"`
|
||||||
State APIRTMPConnState `json:"state"`
|
State APIRTMPConnState `json:"state"`
|
||||||
Path string `json:"path"`
|
Path string `json:"path"`
|
||||||
|
Query string `json:"query"`
|
||||||
BytesReceived uint64 `json:"bytesReceived"`
|
BytesReceived uint64 `json:"bytesReceived"`
|
||||||
BytesSent uint64 `json:"bytesSent"`
|
BytesSent uint64 `json:"bytesSent"`
|
||||||
}
|
}
|
||||||
|
|
@ -105,6 +90,22 @@ type APIRTMPConnList struct {
|
||||||
Items []*APIRTMPConn `json:"items"`
|
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.
|
// APIRTSPSessionState is the state of a RTSP session.
|
||||||
type APIRTSPSessionState string
|
type APIRTSPSessionState string
|
||||||
|
|
||||||
|
|
@ -122,6 +123,7 @@ type APIRTSPSession struct {
|
||||||
RemoteAddr string `json:"remoteAddr"`
|
RemoteAddr string `json:"remoteAddr"`
|
||||||
State APIRTSPSessionState `json:"state"`
|
State APIRTSPSessionState `json:"state"`
|
||||||
Path string `json:"path"`
|
Path string `json:"path"`
|
||||||
|
Query string `json:"query"`
|
||||||
Transport *string `json:"transport"`
|
Transport *string `json:"transport"`
|
||||||
BytesReceived uint64 `json:"bytesReceived"`
|
BytesReceived uint64 `json:"bytesReceived"`
|
||||||
BytesSent uint64 `json:"bytesSent"`
|
BytesSent uint64 `json:"bytesSent"`
|
||||||
|
|
@ -151,6 +153,7 @@ type APISRTConn struct {
|
||||||
RemoteAddr string `json:"remoteAddr"`
|
RemoteAddr string `json:"remoteAddr"`
|
||||||
State APISRTConnState `json:"state"`
|
State APISRTConnState `json:"state"`
|
||||||
Path string `json:"path"`
|
Path string `json:"path"`
|
||||||
|
Query string `json:"query"`
|
||||||
BytesReceived uint64 `json:"bytesReceived"`
|
BytesReceived uint64 `json:"bytesReceived"`
|
||||||
BytesSent uint64 `json:"bytesSent"`
|
BytesSent uint64 `json:"bytesSent"`
|
||||||
}
|
}
|
||||||
|
|
@ -181,6 +184,7 @@ type APIWebRTCSession struct {
|
||||||
RemoteCandidate string `json:"remoteCandidate"`
|
RemoteCandidate string `json:"remoteCandidate"`
|
||||||
State APIWebRTCSessionState `json:"state"`
|
State APIWebRTCSessionState `json:"state"`
|
||||||
Path string `json:"path"`
|
Path string `json:"path"`
|
||||||
|
Query string `json:"query"`
|
||||||
BytesReceived uint64 `json:"bytesReceived"`
|
BytesReceived uint64 `json:"bytesReceived"`
|
||||||
BytesSent uint64 `json:"bytesSent"`
|
BytesSent uint64 `json:"bytesSent"`
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,7 @@ type conn struct {
|
||||||
rconn *rtmp.Conn
|
rconn *rtmp.Conn
|
||||||
state connState
|
state connState
|
||||||
pathName string
|
pathName string
|
||||||
|
query string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *conn) initialize() {
|
func (c *conn) initialize() {
|
||||||
|
|
@ -191,6 +192,7 @@ func (c *conn) runRead(conn *rtmp.Conn, u *url.URL) error {
|
||||||
c.mutex.Lock()
|
c.mutex.Lock()
|
||||||
c.state = connStateRead
|
c.state = connStateRead
|
||||||
c.pathName = pathName
|
c.pathName = pathName
|
||||||
|
c.query = rawQuery
|
||||||
c.mutex.Unlock()
|
c.mutex.Unlock()
|
||||||
|
|
||||||
writer := asyncwriter.New(c.writeQueueSize, c)
|
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.mutex.Lock()
|
||||||
c.state = connStatePublish
|
c.state = connStatePublish
|
||||||
c.pathName = pathName
|
c.pathName = pathName
|
||||||
|
c.query = rawQuery
|
||||||
c.mutex.Unlock()
|
c.mutex.Unlock()
|
||||||
|
|
||||||
r, err := rtmp.NewReader(conn)
|
r, err := rtmp.NewReader(conn)
|
||||||
|
|
@ -594,6 +597,7 @@ func (c *conn) apiItem() *defs.APIRTMPConn {
|
||||||
}
|
}
|
||||||
}(),
|
}(),
|
||||||
Path: c.pathName,
|
Path: c.pathName,
|
||||||
|
Query: c.query,
|
||||||
BytesReceived: bytesReceived,
|
BytesReceived: bytesReceived,
|
||||||
BytesSent: bytesSent,
|
BytesSent: bytesSent,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ type session struct {
|
||||||
state gortsplib.ServerSessionState
|
state gortsplib.ServerSessionState
|
||||||
transport *gortsplib.Transport
|
transport *gortsplib.Transport
|
||||||
pathName string
|
pathName string
|
||||||
|
query string
|
||||||
decodeErrLogger logger.Writer
|
decodeErrLogger logger.Writer
|
||||||
writeErrLogger logger.Writer
|
writeErrLogger logger.Writer
|
||||||
}
|
}
|
||||||
|
|
@ -140,6 +141,7 @@ func (s *session) onAnnounce(c *conn, ctx *gortsplib.ServerHandlerOnAnnounceCtx)
|
||||||
s.mutex.Lock()
|
s.mutex.Lock()
|
||||||
s.state = gortsplib.ServerSessionStatePreRecord
|
s.state = gortsplib.ServerSessionStatePreRecord
|
||||||
s.pathName = ctx.Path
|
s.pathName = ctx.Path
|
||||||
|
s.query = ctx.Query
|
||||||
s.mutex.Unlock()
|
s.mutex.Unlock()
|
||||||
|
|
||||||
return &base.Response{
|
return &base.Response{
|
||||||
|
|
@ -232,6 +234,7 @@ func (s *session) onSetup(c *conn, ctx *gortsplib.ServerHandlerOnSetupCtx,
|
||||||
s.mutex.Lock()
|
s.mutex.Lock()
|
||||||
s.state = gortsplib.ServerSessionStatePrePlay
|
s.state = gortsplib.ServerSessionStatePrePlay
|
||||||
s.pathName = ctx.Path
|
s.pathName = ctx.Path
|
||||||
|
s.query = ctx.Query
|
||||||
s.mutex.Unlock()
|
s.mutex.Unlock()
|
||||||
|
|
||||||
var stream *gortsplib.ServerStream
|
var stream *gortsplib.ServerStream
|
||||||
|
|
@ -400,7 +403,8 @@ func (s *session) apiItem() *defs.APIRTSPSession {
|
||||||
}
|
}
|
||||||
return defs.APIRTSPSessionStateIdle
|
return defs.APIRTSPSessionStateIdle
|
||||||
}(),
|
}(),
|
||||||
Path: s.pathName,
|
Path: s.pathName,
|
||||||
|
Query: s.query,
|
||||||
Transport: func() *string {
|
Transport: func() *string {
|
||||||
if s.transport == nil {
|
if s.transport == nil {
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,7 @@ type conn struct {
|
||||||
mutex sync.RWMutex
|
mutex sync.RWMutex
|
||||||
state connState
|
state connState
|
||||||
pathName string
|
pathName string
|
||||||
|
query string
|
||||||
sconn srt.Conn
|
sconn srt.Conn
|
||||||
|
|
||||||
chNew chan srtNewConnReq
|
chNew chan srtNewConnReq
|
||||||
|
|
@ -218,6 +219,7 @@ func (c *conn) runPublish(req srtNewConnReq, pathName string, user string, pass
|
||||||
c.mutex.Lock()
|
c.mutex.Lock()
|
||||||
c.state = connStatePublish
|
c.state = connStatePublish
|
||||||
c.pathName = pathName
|
c.pathName = pathName
|
||||||
|
c.query = query
|
||||||
c.sconn = sconn
|
c.sconn = sconn
|
||||||
c.mutex.Unlock()
|
c.mutex.Unlock()
|
||||||
|
|
||||||
|
|
@ -317,6 +319,7 @@ func (c *conn) runRead(req srtNewConnReq, pathName string, user string, pass str
|
||||||
c.mutex.Lock()
|
c.mutex.Lock()
|
||||||
c.state = connStateRead
|
c.state = connStateRead
|
||||||
c.pathName = pathName
|
c.pathName = pathName
|
||||||
|
c.query = query
|
||||||
c.sconn = sconn
|
c.sconn = sconn
|
||||||
c.mutex.Unlock()
|
c.mutex.Unlock()
|
||||||
|
|
||||||
|
|
@ -434,6 +437,7 @@ func (c *conn) apiItem() *defs.APISRTConn {
|
||||||
}
|
}
|
||||||
}(),
|
}(),
|
||||||
Path: c.pathName,
|
Path: c.pathName,
|
||||||
|
Query: c.query,
|
||||||
BytesReceived: bytesReceived,
|
BytesReceived: bytesReceived,
|
||||||
BytesSent: bytesSent,
|
BytesSent: bytesSent,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -708,6 +708,7 @@ func (s *session) apiItem() *defs.APIWebRTCSession {
|
||||||
return defs.APIWebRTCSessionStateRead
|
return defs.APIWebRTCSessionStateRead
|
||||||
}(),
|
}(),
|
||||||
Path: s.req.pathName,
|
Path: s.req.pathName,
|
||||||
|
Query: s.req.query,
|
||||||
BytesReceived: bytesReceived,
|
BytesReceived: bytesReceived,
|
||||||
BytesSent: bytesSent,
|
BytesSent: bytesSent,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue