2023-10-31 13:19:04 +00:00
|
|
|
package defs
|
2023-05-18 13:07:47 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/google/uuid"
|
|
|
|
|
|
|
|
"github.com/bluenviron/mediamtx/internal/conf"
|
|
|
|
)
|
|
|
|
|
2023-10-31 13:19:04 +00:00
|
|
|
// APIError is a generic error.
|
|
|
|
type APIError struct {
|
2023-10-27 18:43:34 +00:00
|
|
|
Error string `json:"error"`
|
|
|
|
}
|
|
|
|
|
2023-10-31 13:19:04 +00:00
|
|
|
// APIPathConfList is a list of path configurations.
|
|
|
|
type APIPathConfList struct {
|
2023-10-28 12:53:23 +00:00
|
|
|
ItemCount int `json:"itemCount"`
|
|
|
|
PageCount int `json:"pageCount"`
|
|
|
|
Items []*conf.Path `json:"items"`
|
2023-10-07 21:32:15 +00:00
|
|
|
}
|
|
|
|
|
2023-10-31 13:19:04 +00:00
|
|
|
// APIPathSourceOrReader is a source or a reader.
|
|
|
|
type APIPathSourceOrReader struct {
|
2023-09-16 19:41:49 +00:00
|
|
|
Type string `json:"type"`
|
|
|
|
ID string `json:"id"`
|
|
|
|
}
|
|
|
|
|
2023-10-31 13:19:04 +00:00
|
|
|
// APIPath is a path.
|
|
|
|
type APIPath struct {
|
2023-09-16 19:41:49 +00:00
|
|
|
Name string `json:"name"`
|
|
|
|
ConfName string `json:"confName"`
|
2023-10-31 13:19:04 +00:00
|
|
|
Source *APIPathSourceOrReader `json:"source"`
|
2023-09-16 19:41:49 +00:00
|
|
|
Ready bool `json:"ready"`
|
|
|
|
ReadyTime *time.Time `json:"readyTime"`
|
|
|
|
Tracks []string `json:"tracks"`
|
|
|
|
BytesReceived uint64 `json:"bytesReceived"`
|
2023-11-08 10:20:16 +00:00
|
|
|
BytesSent uint64 `json:"bytesSent"`
|
2023-10-31 13:19:04 +00:00
|
|
|
Readers []APIPathSourceOrReader `json:"readers"`
|
2023-05-18 13:07:47 +00:00
|
|
|
}
|
|
|
|
|
2023-10-31 13:19:04 +00:00
|
|
|
// APIPathList is a list of paths.
|
|
|
|
type APIPathList struct {
|
2023-05-18 18:05:59 +00:00
|
|
|
ItemCount int `json:"itemCount"`
|
2023-05-18 13:07:47 +00:00
|
|
|
PageCount int `json:"pageCount"`
|
2023-10-31 13:19:04 +00:00
|
|
|
Items []*APIPath `json:"items"`
|
2023-05-18 13:07:47 +00:00
|
|
|
}
|
|
|
|
|
2023-10-31 13:19:04 +00:00
|
|
|
// APIHLSMuxer is an HLS muxer.
|
|
|
|
type APIHLSMuxer struct {
|
2023-05-18 13:07:47 +00:00
|
|
|
Path string `json:"path"`
|
|
|
|
Created time.Time `json:"created"`
|
|
|
|
LastRequest time.Time `json:"lastRequest"`
|
|
|
|
BytesSent uint64 `json:"bytesSent"`
|
|
|
|
}
|
|
|
|
|
2023-10-31 13:19:04 +00:00
|
|
|
// APIHLSMuxerList is a list of HLS muxers.
|
|
|
|
type APIHLSMuxerList struct {
|
2023-05-18 18:05:59 +00:00
|
|
|
ItemCount int `json:"itemCount"`
|
2023-05-18 13:07:47 +00:00
|
|
|
PageCount int `json:"pageCount"`
|
2023-10-31 13:19:04 +00:00
|
|
|
Items []*APIHLSMuxer `json:"items"`
|
2023-05-18 13:07:47 +00:00
|
|
|
}
|
|
|
|
|
2023-10-31 13:19:04 +00:00
|
|
|
// APIRTMPConnState is the state of a RTMP connection.
|
|
|
|
type APIRTMPConnState string
|
2023-08-05 15:10:48 +00:00
|
|
|
|
2023-10-31 13:19:04 +00:00
|
|
|
// states.
|
2023-08-05 15:10:48 +00:00
|
|
|
const (
|
2023-10-31 13:19:04 +00:00
|
|
|
APIRTMPConnStateIdle APIRTMPConnState = "idle"
|
|
|
|
APIRTMPConnStateRead APIRTMPConnState = "read"
|
|
|
|
APIRTMPConnStatePublish APIRTMPConnState = "publish"
|
2023-08-05 15:10:48 +00:00
|
|
|
)
|
|
|
|
|
2023-10-31 13:19:04 +00:00
|
|
|
// APIRTMPConn is a RTMP connection.
|
|
|
|
type APIRTMPConn struct {
|
2023-08-05 15:10:48 +00:00
|
|
|
ID uuid.UUID `json:"id"`
|
|
|
|
Created time.Time `json:"created"`
|
|
|
|
RemoteAddr string `json:"remoteAddr"`
|
2023-10-31 13:19:04 +00:00
|
|
|
State APIRTMPConnState `json:"state"`
|
2023-08-05 15:10:48 +00:00
|
|
|
Path string `json:"path"`
|
2023-12-26 12:59:53 +00:00
|
|
|
Query string `json:"query"`
|
2023-08-05 15:10:48 +00:00
|
|
|
BytesReceived uint64 `json:"bytesReceived"`
|
|
|
|
BytesSent uint64 `json:"bytesSent"`
|
2023-05-18 13:07:47 +00:00
|
|
|
}
|
|
|
|
|
2023-10-31 13:19:04 +00:00
|
|
|
// APIRTMPConnList is a list of RTMP connections.
|
|
|
|
type APIRTMPConnList struct {
|
2023-05-18 18:05:59 +00:00
|
|
|
ItemCount int `json:"itemCount"`
|
2023-05-18 13:07:47 +00:00
|
|
|
PageCount int `json:"pageCount"`
|
2023-10-31 13:19:04 +00:00
|
|
|
Items []*APIRTMPConn `json:"items"`
|
2023-05-18 13:07:47 +00:00
|
|
|
}
|
|
|
|
|
2023-12-26 12:59:53 +00:00
|
|
|
// 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"`
|
|
|
|
}
|
|
|
|
|
2023-10-31 13:19:04 +00:00
|
|
|
// APIRTSPSessionState is the state of a RTSP session.
|
|
|
|
type APIRTSPSessionState string
|
2023-08-05 15:10:48 +00:00
|
|
|
|
2023-10-31 13:19:04 +00:00
|
|
|
// states.
|
2023-08-05 15:10:48 +00:00
|
|
|
const (
|
2023-10-31 13:19:04 +00:00
|
|
|
APIRTSPSessionStateIdle APIRTSPSessionState = "idle"
|
|
|
|
APIRTSPSessionStateRead APIRTSPSessionState = "read"
|
|
|
|
APIRTSPSessionStatePublish APIRTSPSessionState = "publish"
|
2023-08-05 15:10:48 +00:00
|
|
|
)
|
|
|
|
|
2023-10-31 13:19:04 +00:00
|
|
|
// APIRTSPSession is a RTSP session.
|
|
|
|
type APIRTSPSession struct {
|
2023-08-05 15:10:48 +00:00
|
|
|
ID uuid.UUID `json:"id"`
|
|
|
|
Created time.Time `json:"created"`
|
|
|
|
RemoteAddr string `json:"remoteAddr"`
|
2023-10-31 13:19:04 +00:00
|
|
|
State APIRTSPSessionState `json:"state"`
|
2023-08-05 15:10:48 +00:00
|
|
|
Path string `json:"path"`
|
2023-12-26 12:59:53 +00:00
|
|
|
Query string `json:"query"`
|
2023-08-05 15:10:48 +00:00
|
|
|
Transport *string `json:"transport"`
|
|
|
|
BytesReceived uint64 `json:"bytesReceived"`
|
|
|
|
BytesSent uint64 `json:"bytesSent"`
|
2023-05-18 13:07:47 +00:00
|
|
|
}
|
|
|
|
|
2023-10-31 13:19:04 +00:00
|
|
|
// APIRTSPSessionList is a list of RTSP sessions.
|
|
|
|
type APIRTSPSessionList struct {
|
2023-05-18 18:05:59 +00:00
|
|
|
ItemCount int `json:"itemCount"`
|
2023-05-18 13:07:47 +00:00
|
|
|
PageCount int `json:"pageCount"`
|
2023-10-31 13:19:04 +00:00
|
|
|
Items []*APIRTSPSession `json:"items"`
|
2023-05-18 13:07:47 +00:00
|
|
|
}
|
|
|
|
|
2023-10-31 13:19:04 +00:00
|
|
|
// APISRTConnState is the state of a SRT connection.
|
|
|
|
type APISRTConnState string
|
2023-05-18 13:07:47 +00:00
|
|
|
|
2023-10-31 13:19:04 +00:00
|
|
|
// states.
|
2023-08-05 15:10:48 +00:00
|
|
|
const (
|
2023-10-31 13:19:04 +00:00
|
|
|
APISRTConnStateIdle APISRTConnState = "idle"
|
|
|
|
APISRTConnStateRead APISRTConnState = "read"
|
|
|
|
APISRTConnStatePublish APISRTConnState = "publish"
|
2023-08-05 15:10:48 +00:00
|
|
|
)
|
2023-07-31 19:20:09 +00:00
|
|
|
|
2023-10-31 13:19:04 +00:00
|
|
|
// APISRTConn is a SRT connection.
|
|
|
|
type APISRTConn struct {
|
2023-08-05 15:10:48 +00:00
|
|
|
ID uuid.UUID `json:"id"`
|
|
|
|
Created time.Time `json:"created"`
|
|
|
|
RemoteAddr string `json:"remoteAddr"`
|
2023-10-31 13:19:04 +00:00
|
|
|
State APISRTConnState `json:"state"`
|
2023-08-05 15:10:48 +00:00
|
|
|
Path string `json:"path"`
|
2023-12-26 12:59:53 +00:00
|
|
|
Query string `json:"query"`
|
2023-08-05 15:10:48 +00:00
|
|
|
BytesReceived uint64 `json:"bytesReceived"`
|
|
|
|
BytesSent uint64 `json:"bytesSent"`
|
2023-07-31 19:20:09 +00:00
|
|
|
}
|
|
|
|
|
2023-10-31 13:19:04 +00:00
|
|
|
// APISRTConnList is a list of SRT connections.
|
|
|
|
type APISRTConnList struct {
|
2023-07-31 19:20:09 +00:00
|
|
|
ItemCount int `json:"itemCount"`
|
|
|
|
PageCount int `json:"pageCount"`
|
2023-10-31 13:19:04 +00:00
|
|
|
Items []*APISRTConn `json:"items"`
|
2023-07-31 19:20:09 +00:00
|
|
|
}
|
2023-08-05 15:10:48 +00:00
|
|
|
|
2023-10-31 13:19:04 +00:00
|
|
|
// APIWebRTCSessionState is the state of a WebRTC connection.
|
|
|
|
type APIWebRTCSessionState string
|
2023-08-05 15:10:48 +00:00
|
|
|
|
2023-10-31 13:19:04 +00:00
|
|
|
// states.
|
2023-08-05 15:10:48 +00:00
|
|
|
const (
|
2023-10-31 13:19:04 +00:00
|
|
|
APIWebRTCSessionStateRead APIWebRTCSessionState = "read"
|
|
|
|
APIWebRTCSessionStatePublish APIWebRTCSessionState = "publish"
|
2023-08-05 15:10:48 +00:00
|
|
|
)
|
|
|
|
|
2023-10-31 13:19:04 +00:00
|
|
|
// APIWebRTCSession is a WebRTC session.
|
|
|
|
type APIWebRTCSession struct {
|
2023-08-05 15:10:48 +00:00
|
|
|
ID uuid.UUID `json:"id"`
|
|
|
|
Created time.Time `json:"created"`
|
|
|
|
RemoteAddr string `json:"remoteAddr"`
|
|
|
|
PeerConnectionEstablished bool `json:"peerConnectionEstablished"`
|
|
|
|
LocalCandidate string `json:"localCandidate"`
|
|
|
|
RemoteCandidate string `json:"remoteCandidate"`
|
2023-10-31 13:19:04 +00:00
|
|
|
State APIWebRTCSessionState `json:"state"`
|
2023-08-05 15:10:48 +00:00
|
|
|
Path string `json:"path"`
|
2023-12-26 12:59:53 +00:00
|
|
|
Query string `json:"query"`
|
2023-08-05 15:10:48 +00:00
|
|
|
BytesReceived uint64 `json:"bytesReceived"`
|
|
|
|
BytesSent uint64 `json:"bytesSent"`
|
|
|
|
}
|
|
|
|
|
2023-10-31 13:19:04 +00:00
|
|
|
// APIWebRTCSessionList is a list of WebRTC sessions.
|
|
|
|
type APIWebRTCSessionList struct {
|
2023-08-05 15:10:48 +00:00
|
|
|
ItemCount int `json:"itemCount"`
|
|
|
|
PageCount int `json:"pageCount"`
|
2023-10-31 13:19:04 +00:00
|
|
|
Items []*APIWebRTCSession `json:"items"`
|
2023-08-05 15:10:48 +00:00
|
|
|
}
|
2024-02-04 22:51:51 +00:00
|
|
|
|
|
|
|
// APIRecordingSegment is a recording segment.
|
|
|
|
type APIRecordingSegment struct {
|
|
|
|
Start time.Time `json:"start"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// APIRecording is a recording.
|
|
|
|
type APIRecording struct {
|
|
|
|
Name string `json:"name"`
|
|
|
|
Segments []*APIRecordingSegment `json:"segments"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// APIRecordingList is a list of recordings.
|
|
|
|
type APIRecordingList struct {
|
|
|
|
ItemCount int `json:"itemCount"`
|
|
|
|
PageCount int `json:"pageCount"`
|
|
|
|
Items []*APIRecording `json:"items"`
|
|
|
|
}
|