Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,8 @@ components:
session:
type: string
nullable: true
tunnel:
type: string

RTSPConnList:
type: object
Expand Down Expand Up @@ -780,6 +782,9 @@ components:
transport:
type: string
nullable: true
profile:
type: string
nullable: true
bytesReceived:
type: integer
format: int64
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/asticode/go-astits v1.13.0
github.com/bluenviron/gohlslib/v2 v2.2.3
github.com/bluenviron/gortmplib v0.0.0-20250916095243-72b6eaffb6a4
github.com/bluenviron/gortsplib/v5 v5.0.0-20250916102828-1616c8c63415
github.com/bluenviron/gortsplib/v5 v5.0.0-20250917174653-288b637b2301
github.com/bluenviron/mediacommon/v2 v2.4.2
github.com/datarhei/gosrt v0.9.0
github.com/fsnotify/fsnotify v1.9.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ github.com/bluenviron/gohlslib/v2 v2.2.3 h1:1R/Jnh1kNR9UB09KAX6xjS2GcdKFRLuPd9wM
github.com/bluenviron/gohlslib/v2 v2.2.3/go.mod h1:z4Viks+Mdgcl7OcOVJ1fgSmuUwCCJBxYJPLN49n7Vnw=
github.com/bluenviron/gortmplib v0.0.0-20250916095243-72b6eaffb6a4 h1:ZDsCiFpmOoEy2eWcJBEhV8jb0sA9MxO/BzYmyrmm4hE=
github.com/bluenviron/gortmplib v0.0.0-20250916095243-72b6eaffb6a4/go.mod h1:73VbUEJLkaixSRPRI/imEkVRkBccvR1GKrd6SUOdkrQ=
github.com/bluenviron/gortsplib/v5 v5.0.0-20250916102828-1616c8c63415 h1:FErClZLSuXkZEPfIsAtD4DH6CKmQ6z7gtod1eHi4Efg=
github.com/bluenviron/gortsplib/v5 v5.0.0-20250916102828-1616c8c63415/go.mod h1:un/XrjuE+yaglJw4Fd75OUXowPxioaHHqNOUC28byFA=
github.com/bluenviron/gortsplib/v5 v5.0.0-20250917174653-288b637b2301 h1:dLEqNi4/uTN6lUM3djwWXhO0uqs9/TbRSg4AfDOJjH8=
github.com/bluenviron/gortsplib/v5 v5.0.0-20250917174653-288b637b2301/go.mod h1:zp5tDI2tkjVMgyWiy+B2tRQowqYq/GwHjdAdYFQAxrU=
github.com/bluenviron/mediacommon/v2 v2.4.2 h1:rggs61nTaqPcR1+RhlIE8/nDqfF5PO57QxpxBzSFfrw=
github.com/bluenviron/mediacommon/v2 v2.4.2/go.mod h1:zy1fODPuS/kBd93ftgJS1Jhvjq7LFWfAo32KP7By9AE=
github.com/bytedance/sonic v1.13.2 h1:8/H1FempDZqC4VqjptGo14QQlJx8VdZJegxs6wwfqpQ=
Expand Down
9 changes: 6 additions & 3 deletions internal/core/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,7 @@ func TestAPIProtocolListGet(t *testing.T) {

switch ca {
case "rtsps conns", "rtsps sessions":
conf += "rtspTransports: [tcp]\n" +
"rtspEncryption: strict\n" +
conf += "rtspEncryption: strict\n" +
"rtspServerCert: " + serverCertFpath + "\n" +
"rtspServerKey: " + serverKeyFpath + "\n"

Expand Down Expand Up @@ -621,6 +620,7 @@ func TestAPIProtocolListGet(t *testing.T) {
"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"],
"tunnel": "none",
},
},
}, out1)
Expand All @@ -640,6 +640,7 @@ func TestAPIProtocolListGet(t *testing.T) {
"remoteAddr": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["remoteAddr"],
"state": "publish",
"transport": "UDP",
"profile": "AVP",
"rtpPacketsReceived": float64(0),
"rtpPacketsSent": float64(0),
"rtpPacketsLost": float64(0),
Expand All @@ -664,6 +665,7 @@ func TestAPIProtocolListGet(t *testing.T) {
"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"],
"tunnel": "none",
},
},
}, out1)
Expand All @@ -682,7 +684,8 @@ func TestAPIProtocolListGet(t *testing.T) {
"query": "key=val",
"remoteAddr": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["remoteAddr"],
"state": "publish",
"transport": "TCP",
"transport": "UDP",
"profile": "SAVP",
"rtpPacketsReceived": float64(0),
"rtpPacketsSent": float64(0),
"rtpPacketsLost": float64(0),
Expand Down
2 changes: 2 additions & 0 deletions internal/defs/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ type APIRTSPConn struct {
BytesReceived uint64 `json:"bytesReceived"`
BytesSent uint64 `json:"bytesSent"`
Session *uuid.UUID `json:"session"`
Tunnel string `json:"tunnel"`
}

// APIRTSPConnsList is a list of RTSP connections.
Expand Down Expand Up @@ -168,6 +169,7 @@ type APIRTSPSession struct {
Path string `json:"path"`
Query string `json:"query"`
Transport *string `json:"transport"`
Profile *string `json:"profile"`
BytesReceived uint64 `json:"bytesReceived"`
BytesSent uint64 `json:"bytesSent"`
RTPPacketsReceived uint64 `json:"rtpPacketsReceived"`
Expand Down
13 changes: 13 additions & 0 deletions internal/servers/rtsp/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ func credentialsProvided(req *base.Request) bool {
return err == nil && auth.Username != ""
}

func tunnelLabel(t gortsplib.Tunnel) string {
switch t {
case gortsplib.TunnelHTTP:
return "http"
case gortsplib.TunnelWebSocket:
return "websocket"
case gortsplib.TunnelNone:
return "none"
}
return "unknown"
}

type connParent interface {
logger.Writer
findSessionByRSessionUnsafe(rsession *gortsplib.ServerSession) *session
Expand Down Expand Up @@ -229,5 +241,6 @@ func (c *conn) apiItem() *defs.APIRTSPConn {
}
return nil
}(),
Tunnel: tunnelLabel(c.rconn.Transport().Tunnel),
}
}
19 changes: 19 additions & 0 deletions internal/servers/rtsp/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/bluenviron/gortsplib/v5"
rtspauth "github.com/bluenviron/gortsplib/v5/pkg/auth"
"github.com/bluenviron/gortsplib/v5/pkg/base"
"github.com/bluenviron/gortsplib/v5/pkg/headers"
"github.com/google/uuid"

"github.com/bluenviron/mediamtx/internal/auth"
Expand All @@ -24,6 +25,16 @@ import (
"github.com/bluenviron/mediamtx/internal/stream"
)

func profileLabel(p headers.TransportProfile) string {
switch p {
case headers.TransportProfileSAVP:
return "SAVP"
case headers.TransportProfileAVP:
return "AVP"
}
return "unknown"
}

type session struct {
isTLS bool
transports conf.RTSPTransports
Expand Down Expand Up @@ -408,6 +419,14 @@ func (s *session) apiItem() *defs.APIRTSPSession {
v := transport.Protocol.String()
return &v
}(),
Profile: func() *string {
transport := s.rsession.Transport()
if transport == nil {
return nil
}
v := profileLabel(transport.Profile)
return &v
}(),
BytesReceived: stats.BytesReceived,
BytesSent: stats.BytesSent,
RTPPacketsReceived: stats.RTPPacketsReceived,
Expand Down
6 changes: 6 additions & 0 deletions internal/testapidocs/apidocs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,12 @@ func TestAPIDocs(t *testing.T) {
case sf.Type == reflect.TypeOf(""):
content2.Properties[js] = openAPIProperty{Type: "string"}

case sf.Type == reflect.PointerTo(reflect.TypeOf("")):
content2.Properties[js] = openAPIProperty{
Type: "string",
Nullable: true,
}

case sf.Type == reflect.TypeOf(int(0)):
content2.Properties[js] = openAPIProperty{Type: "integer", Format: "int64"}

Expand Down