mirror of
https://github.com/bluenviron/mediamtx.git
synced 2026-01-26 21:39:16 -08:00
parent
18d0eec76c
commit
8a808ac0f6
8 changed files with 35 additions and 10 deletions
|
|
@ -657,6 +657,9 @@ components:
|
|||
bytesSent:
|
||||
type: integer
|
||||
format: int64
|
||||
session:
|
||||
type: string
|
||||
nullable: true
|
||||
|
||||
RTSPConnList:
|
||||
type: object
|
||||
|
|
|
|||
2
go.mod
2
go.mod
|
|
@ -10,7 +10,7 @@ require (
|
|||
github.com/alecthomas/kong v1.6.0
|
||||
github.com/asticode/go-astits v1.13.0
|
||||
github.com/bluenviron/gohlslib/v2 v2.1.0
|
||||
github.com/bluenviron/gortsplib/v4 v4.12.1-0.20241225143216-4d3d6bc108f3
|
||||
github.com/bluenviron/gortsplib/v4 v4.12.1-0.20241225145501-66410517c85f
|
||||
github.com/bluenviron/mediacommon v1.13.2
|
||||
github.com/datarhei/gosrt v0.8.0
|
||||
github.com/fsnotify/fsnotify v1.8.0
|
||||
|
|
|
|||
4
go.sum
4
go.sum
|
|
@ -33,8 +33,8 @@ github.com/benburkert/openpgp v0.0.0-20160410205803-c2471f86866c h1:8XZeJrs4+ZYh
|
|||
github.com/benburkert/openpgp v0.0.0-20160410205803-c2471f86866c/go.mod h1:x1vxHcL/9AVzuk5HOloOEPrtJY0MaalYr78afXZ+pWI=
|
||||
github.com/bluenviron/gohlslib/v2 v2.1.0 h1:I0KXXPjnt7QxsR39z97fKe/x1yj22e1NhSqZ5P6FbWE=
|
||||
github.com/bluenviron/gohlslib/v2 v2.1.0/go.mod h1:irD+TAdUsb400Gp8v80LKPPC4YumiAieUSO6ICykeWo=
|
||||
github.com/bluenviron/gortsplib/v4 v4.12.1-0.20241225143216-4d3d6bc108f3 h1:9JqYzxhzIQhPqe5MIq2leJNARrs7VPNgL2o3qwmlgqA=
|
||||
github.com/bluenviron/gortsplib/v4 v4.12.1-0.20241225143216-4d3d6bc108f3/go.mod h1:MwFrCmflxvLTMjgtnPJ2H4SQSB/r9wX8nsR5YPtUs7M=
|
||||
github.com/bluenviron/gortsplib/v4 v4.12.1-0.20241225145501-66410517c85f h1:x+W67M2KMNCumzQ8XpIFXbVE+quKD/xP5PiaJhKwqTY=
|
||||
github.com/bluenviron/gortsplib/v4 v4.12.1-0.20241225145501-66410517c85f/go.mod h1:MwFrCmflxvLTMjgtnPJ2H4SQSB/r9wX8nsR5YPtUs7M=
|
||||
github.com/bluenviron/mediacommon v1.13.2 h1:Ssq+59ZtPm5f9iAVVugWNOyl89Vp0G758RMv033lkik=
|
||||
github.com/bluenviron/mediacommon v1.13.2/go.mod h1:tffg+sPMErUIe7WMq7ZlYry/rPE6TyENWCrYT5JWcgs=
|
||||
github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0=
|
||||
|
|
|
|||
|
|
@ -602,6 +602,7 @@ func TestAPIProtocolListGet(t *testing.T) {
|
|||
"created": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["created"],
|
||||
"id": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["id"],
|
||||
"remoteAddr": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["remoteAddr"],
|
||||
"session": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["session"],
|
||||
},
|
||||
},
|
||||
}, out1)
|
||||
|
|
@ -644,6 +645,7 @@ func TestAPIProtocolListGet(t *testing.T) {
|
|||
"created": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["created"],
|
||||
"id": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["id"],
|
||||
"remoteAddr": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["remoteAddr"],
|
||||
"session": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["session"],
|
||||
},
|
||||
},
|
||||
}, out1)
|
||||
|
|
|
|||
|
|
@ -92,11 +92,12 @@ type APIRTMPConnList struct {
|
|||
|
||||
// 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"`
|
||||
ID uuid.UUID `json:"id"`
|
||||
Created time.Time `json:"created"`
|
||||
RemoteAddr string `json:"remoteAddr"`
|
||||
BytesReceived uint64 `json:"bytesReceived"`
|
||||
BytesSent uint64 `json:"bytesSent"`
|
||||
Session *uuid.UUID `json:"session"`
|
||||
}
|
||||
|
||||
// APIRTSPConnsList is a list of RTSP connections.
|
||||
|
|
|
|||
|
|
@ -23,6 +23,11 @@ const (
|
|||
rtspAuthRealm = "IPCAM"
|
||||
)
|
||||
|
||||
type connParent interface {
|
||||
logger.Writer
|
||||
findSessionByRSession(rsession *gortsplib.ServerSession) *session
|
||||
}
|
||||
|
||||
type conn struct {
|
||||
isTLS bool
|
||||
rtspAddress string
|
||||
|
|
@ -35,7 +40,7 @@ type conn struct {
|
|||
pathManager serverPathManager
|
||||
rconn *gortsplib.ServerConn
|
||||
rserver *gortsplib.Server
|
||||
parent *Server
|
||||
parent connParent
|
||||
|
||||
uuid uuid.UUID
|
||||
created time.Time
|
||||
|
|
@ -216,5 +221,12 @@ func (c *conn) apiItem() *defs.APIRTSPConn {
|
|||
RemoteAddr: c.remoteAddr().String(),
|
||||
BytesReceived: stats.BytesReceived,
|
||||
BytesSent: stats.BytesSent,
|
||||
Session: func() *uuid.UUID {
|
||||
sx := c.parent.findSessionByRSession(c.rconn.Session())
|
||||
if sx != nil {
|
||||
return &sx.uuid
|
||||
}
|
||||
return nil
|
||||
}(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -337,6 +337,13 @@ func (s *Server) findSessionByUUID(uuid uuid.UUID) (*gortsplib.ServerSession, *s
|
|||
return nil, nil
|
||||
}
|
||||
|
||||
func (s *Server) findSessionByRSession(rsession *gortsplib.ServerSession) *session {
|
||||
s.mutex.RLock()
|
||||
defer s.mutex.RUnlock()
|
||||
|
||||
return s.sessions[rsession]
|
||||
}
|
||||
|
||||
// APIConnsList is called by api and metrics.
|
||||
func (s *Server) APIConnsList() (*defs.APIRTSPConnsList, error) {
|
||||
select {
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ type session struct {
|
|||
rserver *gortsplib.Server
|
||||
externalCmdPool *externalcmd.Pool
|
||||
pathManager serverPathManager
|
||||
parent *Server
|
||||
parent logger.Writer
|
||||
|
||||
uuid uuid.UUID
|
||||
created time.Time
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue