api: rename WebRTC stats to match RTSP ones (#5581)
This commit is contained in:
@@ -1565,30 +1565,62 @@ components:
|
|||||||
type: string
|
type: string
|
||||||
user:
|
user:
|
||||||
type: string
|
type: string
|
||||||
|
inboundBytes:
|
||||||
|
type: integer
|
||||||
|
format: uint64
|
||||||
|
inboundRTPPackets:
|
||||||
|
type: integer
|
||||||
|
format: uint64
|
||||||
|
inboundRTPPacketsLost:
|
||||||
|
type: integer
|
||||||
|
format: uint64
|
||||||
|
inboundRTPPacketsJitter:
|
||||||
|
type: number
|
||||||
|
format: double
|
||||||
|
inboundRTCPPackets:
|
||||||
|
type: integer
|
||||||
|
format: uint64
|
||||||
|
outboundBytes:
|
||||||
|
type: integer
|
||||||
|
format: uint64
|
||||||
|
outboundRTPPackets:
|
||||||
|
type: integer
|
||||||
|
format: uint64
|
||||||
|
outboundRTCPPackets:
|
||||||
|
type: integer
|
||||||
|
format: uint64
|
||||||
bytesReceived:
|
bytesReceived:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: uint64
|
||||||
|
deprecated: true
|
||||||
bytesSent:
|
bytesSent:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: uint64
|
||||||
|
deprecated: true
|
||||||
rtpPacketsReceived:
|
rtpPacketsReceived:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: uint64
|
||||||
|
deprecated: true
|
||||||
rtpPacketsSent:
|
rtpPacketsSent:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: uint64
|
||||||
|
deprecated: true
|
||||||
rtpPacketsLost:
|
rtpPacketsLost:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: uint64
|
||||||
|
deprecated: true
|
||||||
rtpPacketsJitter:
|
rtpPacketsJitter:
|
||||||
type: number
|
type: number
|
||||||
format: double
|
format: double
|
||||||
|
deprecated: true
|
||||||
rtcpPacketsReceived:
|
rtcpPacketsReceived:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: uint64
|
||||||
|
deprecated: true
|
||||||
rtcpPacketsSent:
|
rtcpPacketsSent:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: uint64
|
||||||
|
deprecated: true
|
||||||
|
|
||||||
WebRTCSessionList:
|
WebRTCSessionList:
|
||||||
type: object
|
type: object
|
||||||
|
|||||||
@@ -59,6 +59,14 @@ func TestWebRTCSessionsList(t *testing.T) {
|
|||||||
State: defs.APIWebRTCSessionStatePublish,
|
State: defs.APIWebRTCSessionStatePublish,
|
||||||
Path: "stream1",
|
Path: "stream1",
|
||||||
Query: "token=abc",
|
Query: "token=abc",
|
||||||
|
InboundBytes: 1000,
|
||||||
|
InboundRTPPackets: 100,
|
||||||
|
InboundRTPPacketsLost: 5,
|
||||||
|
InboundRTPPacketsJitter: 0.5,
|
||||||
|
InboundRTCPPackets: 10,
|
||||||
|
OutboundBytes: 2000,
|
||||||
|
OutboundRTPPackets: 200,
|
||||||
|
OutboundRTCPPackets: 15,
|
||||||
BytesReceived: 1000,
|
BytesReceived: 1000,
|
||||||
BytesSent: 2000,
|
BytesSent: 2000,
|
||||||
RTPPacketsReceived: 100,
|
RTPPacketsReceived: 100,
|
||||||
@@ -78,6 +86,14 @@ func TestWebRTCSessionsList(t *testing.T) {
|
|||||||
State: defs.APIWebRTCSessionStateRead,
|
State: defs.APIWebRTCSessionStateRead,
|
||||||
Path: "stream2",
|
Path: "stream2",
|
||||||
Query: "",
|
Query: "",
|
||||||
|
InboundBytes: 500,
|
||||||
|
InboundRTPPackets: 50,
|
||||||
|
InboundRTPPacketsLost: 0,
|
||||||
|
InboundRTPPacketsJitter: 0.1,
|
||||||
|
InboundRTCPPackets: 5,
|
||||||
|
OutboundBytes: 1500,
|
||||||
|
OutboundRTPPackets: 150,
|
||||||
|
OutboundRTCPPackets: 10,
|
||||||
BytesReceived: 500,
|
BytesReceived: 500,
|
||||||
BytesSent: 1500,
|
BytesSent: 1500,
|
||||||
RTPPacketsReceived: 50,
|
RTPPacketsReceived: 50,
|
||||||
@@ -130,6 +146,14 @@ func TestWebRTCSessionsGet(t *testing.T) {
|
|||||||
State: defs.APIWebRTCSessionStatePublish,
|
State: defs.APIWebRTCSessionStatePublish,
|
||||||
Path: "mystream",
|
Path: "mystream",
|
||||||
Query: "key=value",
|
Query: "key=value",
|
||||||
|
InboundBytes: 999999,
|
||||||
|
InboundRTPPackets: 10000,
|
||||||
|
InboundRTPPacketsLost: 50,
|
||||||
|
InboundRTPPacketsJitter: 1.5,
|
||||||
|
InboundRTCPPackets: 100,
|
||||||
|
OutboundBytes: 888888,
|
||||||
|
OutboundRTPPackets: 20000,
|
||||||
|
OutboundRTCPPackets: 200,
|
||||||
BytesReceived: 999999,
|
BytesReceived: 999999,
|
||||||
BytesSent: 888888,
|
BytesSent: 888888,
|
||||||
RTPPacketsReceived: 10000,
|
RTPPacketsReceived: 10000,
|
||||||
@@ -168,6 +192,10 @@ func TestWebRTCSessionsGet(t *testing.T) {
|
|||||||
require.True(t, out.PeerConnectionEstablished)
|
require.True(t, out.PeerConnectionEstablished)
|
||||||
require.Equal(t, "192.168.1.200:8000", out.LocalCandidate)
|
require.Equal(t, "192.168.1.200:8000", out.LocalCandidate)
|
||||||
require.Equal(t, "192.168.1.100:5000", out.RemoteCandidate)
|
require.Equal(t, "192.168.1.100:5000", out.RemoteCandidate)
|
||||||
|
require.Equal(t, uint64(999999), out.InboundBytes)
|
||||||
|
require.Equal(t, uint64(888888), out.OutboundBytes)
|
||||||
|
require.Equal(t, uint64(10000), out.InboundRTPPackets)
|
||||||
|
require.Equal(t, uint64(20000), out.OutboundRTPPackets)
|
||||||
require.Equal(t, uint64(999999), out.BytesReceived)
|
require.Equal(t, uint64(999999), out.BytesReceived)
|
||||||
require.Equal(t, uint64(888888), out.BytesSent)
|
require.Equal(t, uint64(888888), out.BytesSent)
|
||||||
require.Equal(t, uint64(10000), out.RTPPacketsReceived)
|
require.Equal(t, uint64(10000), out.RTPPacketsReceived)
|
||||||
@@ -192,6 +220,14 @@ func TestWebRTCSessionsKick(t *testing.T) {
|
|||||||
State: defs.APIWebRTCSessionStatePublish,
|
State: defs.APIWebRTCSessionStatePublish,
|
||||||
Path: "mystream",
|
Path: "mystream",
|
||||||
Query: "",
|
Query: "",
|
||||||
|
InboundBytes: 1000,
|
||||||
|
InboundRTPPackets: 100,
|
||||||
|
InboundRTPPacketsLost: 0,
|
||||||
|
InboundRTPPacketsJitter: 0.5,
|
||||||
|
InboundRTCPPackets: 10,
|
||||||
|
OutboundBytes: 2000,
|
||||||
|
OutboundRTPPackets: 200,
|
||||||
|
OutboundRTCPPackets: 15,
|
||||||
BytesReceived: 1000,
|
BytesReceived: 1000,
|
||||||
BytesSent: 2000,
|
BytesSent: 2000,
|
||||||
RTPPacketsReceived: 100,
|
RTPPacketsReceived: 100,
|
||||||
|
|||||||
@@ -653,7 +653,7 @@ func TestAPIProtocolListGet(t *testing.T) {
|
|||||||
"outboundRTPPackets": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["outboundRTPPackets"],
|
"outboundRTPPackets": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["outboundRTPPackets"],
|
||||||
"outboundRTPPacketsReportedLost": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["outboundRTPPacketsReportedLost"],
|
"outboundRTPPacketsReportedLost": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["outboundRTPPacketsReportedLost"],
|
||||||
"outboundRTCPPackets": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["outboundRTCPPackets"],
|
"outboundRTCPPackets": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["outboundRTCPPackets"],
|
||||||
"bytesReceived": float64(0),
|
"bytesReceived": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["bytesReceived"],
|
||||||
"bytesSent": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["bytesSent"],
|
"bytesSent": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["bytesSent"],
|
||||||
"created": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["created"],
|
"created": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["created"],
|
||||||
"id": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["id"],
|
"id": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["id"],
|
||||||
@@ -713,7 +713,7 @@ func TestAPIProtocolListGet(t *testing.T) {
|
|||||||
"outboundRTPPackets": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["outboundRTPPackets"],
|
"outboundRTPPackets": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["outboundRTPPackets"],
|
||||||
"outboundRTPPacketsReportedLost": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["outboundRTPPacketsReportedLost"],
|
"outboundRTPPacketsReportedLost": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["outboundRTPPacketsReportedLost"],
|
||||||
"outboundRTCPPackets": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["outboundRTCPPackets"],
|
"outboundRTCPPackets": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["outboundRTCPPackets"],
|
||||||
"bytesReceived": float64(0),
|
"bytesReceived": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["bytesReceived"],
|
||||||
"bytesSent": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["bytesSent"],
|
"bytesSent": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["bytesSent"],
|
||||||
"created": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["created"],
|
"created": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["created"],
|
||||||
"id": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["id"],
|
"id": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["id"],
|
||||||
@@ -795,6 +795,14 @@ func TestAPIProtocolListGet(t *testing.T) {
|
|||||||
"pageCount": float64(1),
|
"pageCount": float64(1),
|
||||||
"items": []any{
|
"items": []any{
|
||||||
map[string]any{
|
map[string]any{
|
||||||
|
"inboundBytes": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["inboundBytes"],
|
||||||
|
"inboundRTPPackets": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["inboundRTPPackets"],
|
||||||
|
"inboundRTPPacketsLost": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["inboundRTPPacketsLost"],
|
||||||
|
"inboundRTPPacketsJitter": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["inboundRTPPacketsJitter"],
|
||||||
|
"inboundRTCPPackets": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["inboundRTCPPackets"],
|
||||||
|
"outboundBytes": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["outboundBytes"],
|
||||||
|
"outboundRTPPackets": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["outboundRTPPackets"],
|
||||||
|
"outboundRTCPPackets": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["outboundRTCPPackets"],
|
||||||
"bytesReceived": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["bytesReceived"],
|
"bytesReceived": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["bytesReceived"],
|
||||||
"bytesSent": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["bytesSent"],
|
"bytesSent": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["bytesSent"],
|
||||||
"created": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["created"],
|
"created": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["created"],
|
||||||
@@ -900,6 +908,55 @@ func TestAPIProtocolListGet(t *testing.T) {
|
|||||||
nil, &out2)
|
nil, &out2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch ca {
|
||||||
|
case "rtsp conns", "rtsps conns":
|
||||||
|
out2.(map[string]any)["inboundBytes"] = out1.(map[string]any)["items"].([]any)[0].(map[string]any)["inboundBytes"]
|
||||||
|
out2.(map[string]any)["outboundBytes"] = out1.(map[string]any)["items"].([]any)[0].(map[string]any)["outboundBytes"]
|
||||||
|
out2.(map[string]any)["bytesReceived"] = out1.(map[string]any)["items"].([]any)[0].(map[string]any)["bytesReceived"]
|
||||||
|
out2.(map[string]any)["bytesSent"] = out1.(map[string]any)["items"].([]any)[0].(map[string]any)["bytesSent"]
|
||||||
|
|
||||||
|
case "rtsp sessions", "rtsps sessions":
|
||||||
|
out2.(map[string]any)["inboundBytes"] = out1.(map[string]any)["items"].([]any)[0].(map[string]any)["inboundBytes"]
|
||||||
|
out2.(map[string]any)["inboundRTPPackets"] = out1.(map[string]any)["items"].([]any)[0].(map[string]any)["inboundRTPPackets"]
|
||||||
|
out2.(map[string]any)["inboundRTPPacketsLost"] = out1.(map[string]any)["items"].([]any)[0].(map[string]any)["inboundRTPPacketsLost"]
|
||||||
|
out2.(map[string]any)["inboundRTPPacketsInError"] = out1.(map[string]any)["items"].([]any)[0].(map[string]any)["inboundRTPPacketsInError"]
|
||||||
|
out2.(map[string]any)["inboundRTPPacketsJitter"] = out1.(map[string]any)["items"].([]any)[0].(map[string]any)["inboundRTPPacketsJitter"]
|
||||||
|
out2.(map[string]any)["inboundRTCPPackets"] = out1.(map[string]any)["items"].([]any)[0].(map[string]any)["inboundRTCPPackets"]
|
||||||
|
out2.(map[string]any)["inboundRTCPPacketsInError"] = out1.(map[string]any)["items"].([]any)[0].(map[string]any)["inboundRTCPPacketsInError"]
|
||||||
|
out2.(map[string]any)["outboundBytes"] = out1.(map[string]any)["items"].([]any)[0].(map[string]any)["outboundBytes"]
|
||||||
|
out2.(map[string]any)["outboundRTPPackets"] = out1.(map[string]any)["items"].([]any)[0].(map[string]any)["outboundRTPPackets"]
|
||||||
|
out2.(map[string]any)["outboundRTPPacketsReportedLost"] = out1.(map[string]any)["items"].([]any)[0].(map[string]any)["outboundRTPPacketsReportedLost"]
|
||||||
|
out2.(map[string]any)["outboundRTCPPackets"] = out1.(map[string]any)["items"].([]any)[0].(map[string]any)["outboundRTCPPackets"]
|
||||||
|
out2.(map[string]any)["bytesReceived"] = out1.(map[string]any)["items"].([]any)[0].(map[string]any)["bytesReceived"]
|
||||||
|
out2.(map[string]any)["bytesSent"] = out1.(map[string]any)["items"].([]any)[0].(map[string]any)["bytesSent"]
|
||||||
|
out2.(map[string]any)["rtpPacketsReceived"] = out1.(map[string]any)["items"].([]any)[0].(map[string]any)["rtpPacketsReceived"]
|
||||||
|
out2.(map[string]any)["rtpPacketsSent"] = out1.(map[string]any)["items"].([]any)[0].(map[string]any)["rtpPacketsSent"]
|
||||||
|
out2.(map[string]any)["rtpPacketsLost"] = out1.(map[string]any)["items"].([]any)[0].(map[string]any)["rtpPacketsLost"]
|
||||||
|
out2.(map[string]any)["rtpPacketsInError"] = out1.(map[string]any)["items"].([]any)[0].(map[string]any)["rtpPacketsInError"]
|
||||||
|
out2.(map[string]any)["rtpPacketsJitter"] = out1.(map[string]any)["items"].([]any)[0].(map[string]any)["rtpPacketsJitter"]
|
||||||
|
out2.(map[string]any)["rtcpPacketsReceived"] = out1.(map[string]any)["items"].([]any)[0].(map[string]any)["rtcpPacketsReceived"]
|
||||||
|
out2.(map[string]any)["rtcpPacketsSent"] = out1.(map[string]any)["items"].([]any)[0].(map[string]any)["rtcpPacketsSent"]
|
||||||
|
out2.(map[string]any)["rtcpPacketsInError"] = out1.(map[string]any)["items"].([]any)[0].(map[string]any)["rtcpPacketsInError"]
|
||||||
|
|
||||||
|
case "webrtc":
|
||||||
|
out2.(map[string]any)["inboundBytes"] = out1.(map[string]any)["items"].([]any)[0].(map[string]any)["inboundBytes"]
|
||||||
|
out2.(map[string]any)["inboundRTPPackets"] = out1.(map[string]any)["items"].([]any)[0].(map[string]any)["inboundRTPPackets"]
|
||||||
|
out2.(map[string]any)["inboundRTPPacketsLost"] = out1.(map[string]any)["items"].([]any)[0].(map[string]any)["inboundRTPPacketsLost"]
|
||||||
|
out2.(map[string]any)["inboundRTPPacketsJitter"] = out1.(map[string]any)["items"].([]any)[0].(map[string]any)["inboundRTPPacketsJitter"]
|
||||||
|
out2.(map[string]any)["inboundRTCPPackets"] = out1.(map[string]any)["items"].([]any)[0].(map[string]any)["inboundRTCPPackets"]
|
||||||
|
out2.(map[string]any)["outboundBytes"] = out1.(map[string]any)["items"].([]any)[0].(map[string]any)["outboundBytes"]
|
||||||
|
out2.(map[string]any)["outboundRTPPackets"] = out1.(map[string]any)["items"].([]any)[0].(map[string]any)["outboundRTPPackets"]
|
||||||
|
out2.(map[string]any)["outboundRTCPPackets"] = out1.(map[string]any)["items"].([]any)[0].(map[string]any)["outboundRTCPPackets"]
|
||||||
|
out2.(map[string]any)["bytesReceived"] = out1.(map[string]any)["items"].([]any)[0].(map[string]any)["bytesReceived"]
|
||||||
|
out2.(map[string]any)["bytesSent"] = out1.(map[string]any)["items"].([]any)[0].(map[string]any)["bytesSent"]
|
||||||
|
out2.(map[string]any)["rtpPacketsReceived"] = out1.(map[string]any)["items"].([]any)[0].(map[string]any)["rtpPacketsReceived"]
|
||||||
|
out2.(map[string]any)["rtpPacketsSent"] = out1.(map[string]any)["items"].([]any)[0].(map[string]any)["rtpPacketsSent"]
|
||||||
|
out2.(map[string]any)["rtpPacketsLost"] = out1.(map[string]any)["items"].([]any)[0].(map[string]any)["rtpPacketsLost"]
|
||||||
|
out2.(map[string]any)["rtpPacketsJitter"] = out1.(map[string]any)["items"].([]any)[0].(map[string]any)["rtpPacketsJitter"]
|
||||||
|
out2.(map[string]any)["rtcpPacketsReceived"] = out1.(map[string]any)["items"].([]any)[0].(map[string]any)["rtcpPacketsReceived"]
|
||||||
|
out2.(map[string]any)["rtcpPacketsSent"] = out1.(map[string]any)["items"].([]any)[0].(map[string]any)["rtcpPacketsSent"]
|
||||||
|
}
|
||||||
|
|
||||||
require.Equal(t, out1.(map[string]any)["items"].([]any)[0], out2)
|
require.Equal(t, out1.(map[string]any)["items"].([]any)[0], out2)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -196,6 +196,14 @@ srt_conns_packets_received_avg_belated_time 0
|
|||||||
srt_conns_packets_send_loss_rate 0
|
srt_conns_packets_send_loss_rate 0
|
||||||
srt_conns_packets_received_loss_rate 0
|
srt_conns_packets_received_loss_rate 0
|
||||||
webrtc_sessions 0
|
webrtc_sessions 0
|
||||||
|
webrtc_sessions_inbound_bytes 0
|
||||||
|
webrtc_sessions_inbound_rtp_packets 0
|
||||||
|
webrtc_sessions_inbound_rtp_packets_lost 0
|
||||||
|
webrtc_sessions_inbound_rtp_packets_jitter 0
|
||||||
|
webrtc_sessions_inbound_rtcp_packets 0
|
||||||
|
webrtc_sessions_outbound_bytes 0
|
||||||
|
webrtc_sessions_outbound_rtp_packets 0
|
||||||
|
webrtc_sessions_outbound_rtcp_packets 0
|
||||||
webrtc_sessions_bytes_received 0
|
webrtc_sessions_bytes_received 0
|
||||||
webrtc_sessions_bytes_sent 0
|
webrtc_sessions_bytes_sent 0
|
||||||
webrtc_sessions_rtp_packets_received 0
|
webrtc_sessions_rtp_packets_received 0
|
||||||
@@ -539,6 +547,14 @@ webrtc_sessions_rtcp_packets_sent 0
|
|||||||
`srt_conns_packets_send_loss_rate\{id=".*?",path=".*?",remoteAddr=".*?",state="publish"\} [0-9]+`+"\n"+
|
`srt_conns_packets_send_loss_rate\{id=".*?",path=".*?",remoteAddr=".*?",state="publish"\} [0-9]+`+"\n"+
|
||||||
`srt_conns_packets_received_loss_rate\{id=".*?",path=".*?",remoteAddr=".*?",state="publish"\} [0-9]+`+"\n"+
|
`srt_conns_packets_received_loss_rate\{id=".*?",path=".*?",remoteAddr=".*?",state="publish"\} [0-9]+`+"\n"+
|
||||||
`webrtc_sessions\{id=".*?",path=".*?",remoteAddr=".*?",state="publish"\} 1`+"\n"+
|
`webrtc_sessions\{id=".*?",path=".*?",remoteAddr=".*?",state="publish"\} 1`+"\n"+
|
||||||
|
`webrtc_sessions_inbound_bytes\{id=".*?",path=".*?",remoteAddr=".*?",state="publish"\} [0-9]+`+"\n"+
|
||||||
|
`webrtc_sessions_inbound_rtp_packets\{id=".*?",path=".*?",remoteAddr=".*?",state="publish"\} [0-9]+`+"\n"+
|
||||||
|
`webrtc_sessions_inbound_rtp_packets_lost\{id=".*?",path=".*?",remoteAddr=".*?",state="publish"\} [0-9]+`+"\n"+
|
||||||
|
`webrtc_sessions_inbound_rtp_packets_jitter\{id=".*?",path=".*?",remoteAddr=".*?",state="publish"\} [0-9]+`+"\n"+
|
||||||
|
`webrtc_sessions_inbound_rtcp_packets\{id=".*?",path=".*?",remoteAddr=".*?",state="publish"\} [0-9]+`+"\n"+
|
||||||
|
`webrtc_sessions_outbound_bytes\{id=".*?",path=".*?",remoteAddr=".*?",state="publish"\} [0-9]+`+"\n"+
|
||||||
|
`webrtc_sessions_outbound_rtp_packets\{id=".*?",path=".*?",remoteAddr=".*?",state="publish"\} [0-9]+`+"\n"+
|
||||||
|
`webrtc_sessions_outbound_rtcp_packets\{id=".*?",path=".*?",remoteAddr=".*?",state="publish"\} [0-9]+`+"\n"+
|
||||||
`webrtc_sessions_bytes_received\{id=".*?",path=".*?",remoteAddr=".*?",state="publish"\} [0-9]+`+"\n"+
|
`webrtc_sessions_bytes_received\{id=".*?",path=".*?",remoteAddr=".*?",state="publish"\} [0-9]+`+"\n"+
|
||||||
`webrtc_sessions_bytes_sent\{id=".*?",path=".*?",remoteAddr=".*?",state="publish"\} [0-9]+`+"\n"+
|
`webrtc_sessions_bytes_sent\{id=".*?",path=".*?",remoteAddr=".*?",state="publish"\} [0-9]+`+"\n"+
|
||||||
`webrtc_sessions_rtp_packets_received\{id=".*?",path=".*?",remoteAddr=".*?",state="publish"\} [0-9]+`+"\n"+
|
`webrtc_sessions_rtp_packets_received\{id=".*?",path=".*?",remoteAddr=".*?",state="publish"\} [0-9]+`+"\n"+
|
||||||
|
|||||||
+11
-10
@@ -68,16 +68,17 @@ type APIRTSPSession struct {
|
|||||||
OutboundRTPPackets uint64 `json:"outboundRTPPackets"`
|
OutboundRTPPackets uint64 `json:"outboundRTPPackets"`
|
||||||
OutboundRTPPacketsReportedLost uint64 `json:"outboundRTPPacketsReportedLost"`
|
OutboundRTPPacketsReportedLost uint64 `json:"outboundRTPPacketsReportedLost"`
|
||||||
OutboundRTCPPackets uint64 `json:"outboundRTCPPackets"`
|
OutboundRTCPPackets uint64 `json:"outboundRTCPPackets"`
|
||||||
BytesReceived uint64 `json:"bytesReceived" deprecated:"true"`
|
// deprecated
|
||||||
BytesSent uint64 `json:"bytesSent" deprecated:"true"`
|
BytesReceived uint64 `json:"bytesReceived" deprecated:"true"`
|
||||||
RTPPacketsReceived uint64 `json:"rtpPacketsReceived" deprecated:"true"`
|
BytesSent uint64 `json:"bytesSent" deprecated:"true"`
|
||||||
RTPPacketsSent uint64 `json:"rtpPacketsSent" deprecated:"true"`
|
RTPPacketsReceived uint64 `json:"rtpPacketsReceived" deprecated:"true"`
|
||||||
RTPPacketsLost uint64 `json:"rtpPacketsLost" deprecated:"true"`
|
RTPPacketsSent uint64 `json:"rtpPacketsSent" deprecated:"true"`
|
||||||
RTPPacketsInError uint64 `json:"rtpPacketsInError" deprecated:"true"`
|
RTPPacketsLost uint64 `json:"rtpPacketsLost" deprecated:"true"`
|
||||||
RTPPacketsJitter float64 `json:"rtpPacketsJitter" deprecated:"true"`
|
RTPPacketsInError uint64 `json:"rtpPacketsInError" deprecated:"true"`
|
||||||
RTCPPacketsReceived uint64 `json:"rtcpPacketsReceived" deprecated:"true"`
|
RTPPacketsJitter float64 `json:"rtpPacketsJitter" deprecated:"true"`
|
||||||
RTCPPacketsSent uint64 `json:"rtcpPacketsSent" deprecated:"true"`
|
RTCPPacketsReceived uint64 `json:"rtcpPacketsReceived" deprecated:"true"`
|
||||||
RTCPPacketsInError uint64 `json:"rtcpPacketsInError" deprecated:"true"`
|
RTCPPacketsSent uint64 `json:"rtcpPacketsSent" deprecated:"true"`
|
||||||
|
RTCPPacketsInError uint64 `json:"rtcpPacketsInError" deprecated:"true"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// APIRTSPSessionList is a list of RTSP sessions.
|
// APIRTSPSessionList is a list of RTSP sessions.
|
||||||
|
|||||||
@@ -34,14 +34,23 @@ type APIWebRTCSession struct {
|
|||||||
Path string `json:"path"`
|
Path string `json:"path"`
|
||||||
Query string `json:"query"`
|
Query string `json:"query"`
|
||||||
User string `json:"user"`
|
User string `json:"user"`
|
||||||
BytesReceived uint64 `json:"bytesReceived"`
|
InboundBytes uint64 `json:"inboundBytes"`
|
||||||
BytesSent uint64 `json:"bytesSent"`
|
InboundRTPPackets uint64 `json:"inboundRTPPackets"`
|
||||||
RTPPacketsReceived uint64 `json:"rtpPacketsReceived"`
|
InboundRTPPacketsLost uint64 `json:"inboundRTPPacketsLost"`
|
||||||
RTPPacketsSent uint64 `json:"rtpPacketsSent"`
|
InboundRTPPacketsJitter float64 `json:"inboundRTPPacketsJitter"`
|
||||||
RTPPacketsLost uint64 `json:"rtpPacketsLost"`
|
InboundRTCPPackets uint64 `json:"inboundRTCPPackets"`
|
||||||
RTPPacketsJitter float64 `json:"rtpPacketsJitter"`
|
OutboundBytes uint64 `json:"outboundBytes"`
|
||||||
RTCPPacketsReceived uint64 `json:"rtcpPacketsReceived"`
|
OutboundRTPPackets uint64 `json:"outboundRTPPackets"`
|
||||||
RTCPPacketsSent uint64 `json:"rtcpPacketsSent"`
|
OutboundRTCPPackets uint64 `json:"outboundRTCPPackets"`
|
||||||
|
// deprecated
|
||||||
|
BytesReceived uint64 `json:"bytesReceived" deprecated:"true"`
|
||||||
|
BytesSent uint64 `json:"bytesSent" deprecated:"true"`
|
||||||
|
RTPPacketsReceived uint64 `json:"rtpPacketsReceived" deprecated:"true"`
|
||||||
|
RTPPacketsSent uint64 `json:"rtpPacketsSent" deprecated:"true"`
|
||||||
|
RTPPacketsLost uint64 `json:"rtpPacketsLost" deprecated:"true"`
|
||||||
|
RTPPacketsJitter float64 `json:"rtpPacketsJitter" deprecated:"true"`
|
||||||
|
RTCPPacketsReceived uint64 `json:"rtcpPacketsReceived" deprecated:"true"`
|
||||||
|
RTCPPacketsSent uint64 `json:"rtcpPacketsSent" deprecated:"true"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// APIWebRTCSessionList is a list of WebRTC sessions.
|
// APIWebRTCSessionList is a list of WebRTC sessions.
|
||||||
|
|||||||
@@ -638,6 +638,15 @@ func (m *Metrics) onMetrics(ctx *gin.Context) {
|
|||||||
"remoteAddr": i.RemoteAddr,
|
"remoteAddr": i.RemoteAddr,
|
||||||
})
|
})
|
||||||
out += metric("webrtc_sessions", ta, 1)
|
out += metric("webrtc_sessions", ta, 1)
|
||||||
|
out += metric("webrtc_sessions_inbound_bytes", ta, int64(i.InboundBytes))
|
||||||
|
out += metric("webrtc_sessions_inbound_rtp_packets", ta, int64(i.InboundRTPPackets))
|
||||||
|
out += metric("webrtc_sessions_inbound_rtp_packets_lost", ta, int64(i.InboundRTPPacketsLost))
|
||||||
|
out += metricFloat("webrtc_sessions_inbound_rtp_packets_jitter", ta, i.InboundRTPPacketsJitter)
|
||||||
|
out += metric("webrtc_sessions_inbound_rtcp_packets", ta, int64(i.InboundRTCPPackets))
|
||||||
|
out += metric("webrtc_sessions_outbound_bytes", ta, int64(i.OutboundBytes))
|
||||||
|
out += metric("webrtc_sessions_outbound_rtp_packets", ta, int64(i.OutboundRTPPackets))
|
||||||
|
out += metric("webrtc_sessions_outbound_rtcp_packets", ta, int64(i.OutboundRTCPPackets))
|
||||||
|
// deprecated
|
||||||
out += metric("webrtc_sessions_bytes_received", ta, int64(i.BytesReceived))
|
out += metric("webrtc_sessions_bytes_received", ta, int64(i.BytesReceived))
|
||||||
out += metric("webrtc_sessions_bytes_sent", ta, int64(i.BytesSent))
|
out += metric("webrtc_sessions_bytes_sent", ta, int64(i.BytesSent))
|
||||||
out += metric("webrtc_sessions_rtp_packets_received", ta, int64(i.RTPPacketsReceived))
|
out += metric("webrtc_sessions_rtp_packets_received", ta, int64(i.RTPPacketsReceived))
|
||||||
@@ -650,6 +659,15 @@ func (m *Metrics) onMetrics(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
} else if webrtcSessionFilter == "" {
|
} else if webrtcSessionFilter == "" {
|
||||||
out += metric("webrtc_sessions", "", 0)
|
out += metric("webrtc_sessions", "", 0)
|
||||||
|
out += metric("webrtc_sessions_inbound_bytes", "", 0)
|
||||||
|
out += metric("webrtc_sessions_inbound_rtp_packets", "", 0)
|
||||||
|
out += metric("webrtc_sessions_inbound_rtp_packets_lost", "", 0)
|
||||||
|
out += metricFloat("webrtc_sessions_inbound_rtp_packets_jitter", "", 0)
|
||||||
|
out += metric("webrtc_sessions_inbound_rtcp_packets", "", 0)
|
||||||
|
out += metric("webrtc_sessions_outbound_bytes", "", 0)
|
||||||
|
out += metric("webrtc_sessions_outbound_rtp_packets", "", 0)
|
||||||
|
out += metric("webrtc_sessions_outbound_rtcp_packets", "", 0)
|
||||||
|
// deprecated
|
||||||
out += metric("webrtc_sessions_bytes_received", "", 0)
|
out += metric("webrtc_sessions_bytes_received", "", 0)
|
||||||
out += metric("webrtc_sessions_bytes_sent", "", 0)
|
out += metric("webrtc_sessions_bytes_sent", "", 0)
|
||||||
out += metric("webrtc_sessions_rtp_packets_received", "", 0)
|
out += metric("webrtc_sessions_rtp_packets_received", "", 0)
|
||||||
|
|||||||
@@ -184,6 +184,14 @@ func (dummyWebRTCServer) APISessionsList() (*defs.APIWebRTCSessionList, error) {
|
|||||||
State: defs.APIWebRTCSessionStateRead,
|
State: defs.APIWebRTCSessionStateRead,
|
||||||
Path: "mypath",
|
Path: "mypath",
|
||||||
Query: "myquery",
|
Query: "myquery",
|
||||||
|
InboundBytes: 123,
|
||||||
|
InboundRTPPackets: 789,
|
||||||
|
InboundRTPPacketsLost: 456,
|
||||||
|
InboundRTPPacketsJitter: 789,
|
||||||
|
InboundRTCPPackets: 123,
|
||||||
|
OutboundBytes: 456,
|
||||||
|
OutboundRTPPackets: 123,
|
||||||
|
OutboundRTCPPackets: 456,
|
||||||
BytesReceived: 123,
|
BytesReceived: 123,
|
||||||
BytesSent: 456,
|
BytesSent: 456,
|
||||||
RTPPacketsReceived: 789,
|
RTPPacketsReceived: 789,
|
||||||
@@ -405,6 +413,22 @@ func TestMetrics(t *testing.T) {
|
|||||||
`path="mypath",remoteAddr="3.3.3.3:5678",state="read"} 456`+"\n"+
|
`path="mypath",remoteAddr="3.3.3.3:5678",state="read"} 456`+"\n"+
|
||||||
`webrtc_sessions{id="f47ac10b-58cc-4372-a567-0e02b2c3d479",`+
|
`webrtc_sessions{id="f47ac10b-58cc-4372-a567-0e02b2c3d479",`+
|
||||||
`path="mypath",remoteAddr="127.0.0.1:3455",state="read"} 1`+"\n"+
|
`path="mypath",remoteAddr="127.0.0.1:3455",state="read"} 1`+"\n"+
|
||||||
|
`webrtc_sessions_inbound_bytes{id="f47ac10b-58cc-4372-a567-0e02b2c3d479",`+
|
||||||
|
`path="mypath",remoteAddr="127.0.0.1:3455",state="read"} 123`+"\n"+
|
||||||
|
`webrtc_sessions_inbound_rtp_packets{id="f47ac10b-58cc-4372-a567-0e02b2c3d479",`+
|
||||||
|
`path="mypath",remoteAddr="127.0.0.1:3455",state="read"} 789`+"\n"+
|
||||||
|
`webrtc_sessions_inbound_rtp_packets_lost{id="f47ac10b-58cc-4372-a567-0e02b2c3d479",`+
|
||||||
|
`path="mypath",remoteAddr="127.0.0.1:3455",state="read"} 456`+"\n"+
|
||||||
|
`webrtc_sessions_inbound_rtp_packets_jitter{id="f47ac10b-58cc-4372-a567-0e02b2c3d479",`+
|
||||||
|
`path="mypath",remoteAddr="127.0.0.1:3455",state="read"} 789`+"\n"+
|
||||||
|
`webrtc_sessions_inbound_rtcp_packets{id="f47ac10b-58cc-4372-a567-0e02b2c3d479",`+
|
||||||
|
`path="mypath",remoteAddr="127.0.0.1:3455",state="read"} 123`+"\n"+
|
||||||
|
`webrtc_sessions_outbound_bytes{id="f47ac10b-58cc-4372-a567-0e02b2c3d479",`+
|
||||||
|
`path="mypath",remoteAddr="127.0.0.1:3455",state="read"} 456`+"\n"+
|
||||||
|
`webrtc_sessions_outbound_rtp_packets{id="f47ac10b-58cc-4372-a567-0e02b2c3d479",`+
|
||||||
|
`path="mypath",remoteAddr="127.0.0.1:3455",state="read"} 123`+"\n"+
|
||||||
|
`webrtc_sessions_outbound_rtcp_packets{id="f47ac10b-58cc-4372-a567-0e02b2c3d479",`+
|
||||||
|
`path="mypath",remoteAddr="127.0.0.1:3455",state="read"} 456`+"\n"+
|
||||||
`webrtc_sessions_bytes_received{id="f47ac10b-58cc-4372-a567-0e02b2c3d479",`+
|
`webrtc_sessions_bytes_received{id="f47ac10b-58cc-4372-a567-0e02b2c3d479",`+
|
||||||
`path="mypath",remoteAddr="127.0.0.1:3455",state="read"} 123`+"\n"+
|
`path="mypath",remoteAddr="127.0.0.1:3455",state="read"} 123`+"\n"+
|
||||||
`webrtc_sessions_bytes_sent{id="f47ac10b-58cc-4372-a567-0e02b2c3d479",`+
|
`webrtc_sessions_bytes_sent{id="f47ac10b-58cc-4372-a567-0e02b2c3d479",`+
|
||||||
|
|||||||
@@ -244,8 +244,8 @@ type IncomingTrack struct {
|
|||||||
writeRTCP func([]rtcp.Packet) error
|
writeRTCP func([]rtcp.Packet) error
|
||||||
log logger.Writer
|
log logger.Writer
|
||||||
|
|
||||||
packetsLost *counterdumper.Dumper
|
inboundRTPPacketsLost *counterdumper.Dumper
|
||||||
rtpReceiver *rtpreceiver.Receiver
|
rtpReceiver *rtpreceiver.Receiver
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *IncomingTrack) initialize() {
|
func (t *IncomingTrack) initialize() {
|
||||||
@@ -268,7 +268,7 @@ func (*IncomingTrack) PTSEqualsDTS(*rtp.Packet) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *IncomingTrack) start() {
|
func (t *IncomingTrack) start() {
|
||||||
t.packetsLost = &counterdumper.Dumper{
|
t.inboundRTPPacketsLost = &counterdumper.Dumper{
|
||||||
OnReport: func(val uint64) {
|
OnReport: func(val uint64) {
|
||||||
t.log.Log(logger.Warn, "%d RTP %s lost",
|
t.log.Log(logger.Warn, "%d RTP %s lost",
|
||||||
val,
|
val,
|
||||||
@@ -280,7 +280,7 @@ func (t *IncomingTrack) start() {
|
|||||||
}())
|
}())
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
t.packetsLost.Start()
|
t.inboundRTPPacketsLost.Start()
|
||||||
|
|
||||||
t.rtpReceiver = &rtpreceiver.Receiver{
|
t.rtpReceiver = &rtpreceiver.Receiver{
|
||||||
ClockRate: int(t.track.Codec().ClockRate),
|
ClockRate: int(t.track.Codec().ClockRate),
|
||||||
@@ -348,7 +348,7 @@ func (t *IncomingTrack) start() {
|
|||||||
packets, lost := t.rtpReceiver.ProcessPacket2(pkt, time.Now(), true)
|
packets, lost := t.rtpReceiver.ProcessPacket2(pkt, time.Now(), true)
|
||||||
|
|
||||||
if lost != 0 {
|
if lost != 0 {
|
||||||
t.packetsLost.Add(lost)
|
t.inboundRTPPacketsLost.Add(lost)
|
||||||
// do not return
|
// do not return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -370,8 +370,8 @@ func (t *IncomingTrack) PacketNTP(pkt *rtp.Packet) (time.Time, bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *IncomingTrack) close() {
|
func (t *IncomingTrack) close() {
|
||||||
if t.packetsLost != nil {
|
if t.inboundRTPPacketsLost != nil {
|
||||||
t.packetsLost.Stop()
|
t.inboundRTPPacketsLost.Stop()
|
||||||
}
|
}
|
||||||
if t.rtpReceiver != nil {
|
if t.rtpReceiver != nil {
|
||||||
t.rtpReceiver.Close()
|
t.rtpReceiver.Close()
|
||||||
|
|||||||
@@ -52,25 +52,25 @@ type session struct {
|
|||||||
pathManager serverPathManager
|
pathManager serverPathManager
|
||||||
parent sessionParent
|
parent sessionParent
|
||||||
|
|
||||||
uuid uuid.UUID
|
uuid uuid.UUID
|
||||||
created time.Time
|
created time.Time
|
||||||
pathConf *conf.Path // record only
|
pathConf *conf.Path // record only
|
||||||
path defs.Path
|
path defs.Path
|
||||||
stream *stream.Stream
|
stream *stream.Stream
|
||||||
subStream *stream.SubStream
|
subStream *stream.SubStream
|
||||||
onUnreadHook func()
|
onUnreadHook func()
|
||||||
packetsLost *counterdumper.Dumper
|
inboundRTPPacketsLost *counterdumper.Dumper
|
||||||
decodeErrors *errordumper.Dumper
|
inboundRTPPacketsInError *errordumper.Dumper
|
||||||
discardedFrames *counterdumper.Dumper
|
outboundRTPPacketsDiscarded *counterdumper.Dumper
|
||||||
mutex sync.RWMutex
|
mutex sync.RWMutex
|
||||||
user string
|
user string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *session) initialize() {
|
func (s *session) initialize() {
|
||||||
s.uuid = uuid.New()
|
s.uuid = uuid.New()
|
||||||
s.created = time.Now()
|
s.created = time.Now()
|
||||||
|
|
||||||
s.packetsLost = &counterdumper.Dumper{
|
s.inboundRTPPacketsLost = &counterdumper.Dumper{
|
||||||
OnReport: func(val uint64) {
|
OnReport: func(val uint64) {
|
||||||
s.Log(logger.Warn, "%d RTP %s lost",
|
s.Log(logger.Warn, "%d RTP %s lost",
|
||||||
val,
|
val,
|
||||||
@@ -82,9 +82,9 @@ func (s *session) initialize() {
|
|||||||
}())
|
}())
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
s.packetsLost.Start()
|
s.inboundRTPPacketsLost.Start()
|
||||||
|
|
||||||
s.decodeErrors = &errordumper.Dumper{
|
s.inboundRTPPacketsInError = &errordumper.Dumper{
|
||||||
OnReport: func(val uint64, last error) {
|
OnReport: func(val uint64, last error) {
|
||||||
if val == 1 {
|
if val == 1 {
|
||||||
s.Log(logger.Warn, "decode error: %v", last)
|
s.Log(logger.Warn, "decode error: %v", last)
|
||||||
@@ -93,9 +93,9 @@ func (s *session) initialize() {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
s.decodeErrors.Start()
|
s.inboundRTPPacketsInError.Start()
|
||||||
|
|
||||||
s.discardedFrames = &counterdumper.Dumper{
|
s.outboundRTPPacketsDiscarded = &counterdumper.Dumper{
|
||||||
OnReport: func(val uint64) {
|
OnReport: func(val uint64) {
|
||||||
s.Log(logger.Warn, "reader is too slow, discarding %d %s",
|
s.Log(logger.Warn, "reader is too slow, discarding %d %s",
|
||||||
val,
|
val,
|
||||||
@@ -107,7 +107,7 @@ func (s *session) initialize() {
|
|||||||
}())
|
}())
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
s.discardedFrames.Start()
|
s.outboundRTPPacketsDiscarded.Start()
|
||||||
|
|
||||||
s.Log(logger.Info, "created by %v", s.rconn.NetConn().RemoteAddr())
|
s.Log(logger.Info, "created by %v", s.rconn.NetConn().RemoteAddr())
|
||||||
}
|
}
|
||||||
@@ -147,9 +147,9 @@ func (s *session) onClose(err error) {
|
|||||||
s.stream = nil
|
s.stream = nil
|
||||||
s.subStream = nil
|
s.subStream = nil
|
||||||
|
|
||||||
s.discardedFrames.Stop()
|
s.outboundRTPPacketsDiscarded.Stop()
|
||||||
s.decodeErrors.Stop()
|
s.inboundRTPPacketsInError.Stop()
|
||||||
s.packetsLost.Stop()
|
s.inboundRTPPacketsLost.Stop()
|
||||||
|
|
||||||
s.Log(logger.Info, "destroyed: %v", err)
|
s.Log(logger.Info, "destroyed: %v", err)
|
||||||
}
|
}
|
||||||
@@ -405,18 +405,18 @@ func (s *session) APISourceDescribe() *defs.APIPathSource {
|
|||||||
|
|
||||||
// onPacketLost is called by rtspServer.
|
// onPacketLost is called by rtspServer.
|
||||||
func (s *session) onPacketsLost(ctx *gortsplib.ServerHandlerOnPacketsLostCtx) {
|
func (s *session) onPacketsLost(ctx *gortsplib.ServerHandlerOnPacketsLostCtx) {
|
||||||
s.packetsLost.Add(ctx.Lost)
|
s.inboundRTPPacketsLost.Add(ctx.Lost)
|
||||||
}
|
}
|
||||||
|
|
||||||
// onDecodeError is called by rtspServer.
|
// onDecodeError is called by rtspServer.
|
||||||
func (s *session) onDecodeError(ctx *gortsplib.ServerHandlerOnDecodeErrorCtx) {
|
func (s *session) onDecodeError(ctx *gortsplib.ServerHandlerOnDecodeErrorCtx) {
|
||||||
s.decodeErrors.Add(ctx.Error)
|
s.inboundRTPPacketsInError.Add(ctx.Error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// onStreamWriteError is called by rtspServer.
|
// onStreamWriteError is called by rtspServer.
|
||||||
func (s *session) onStreamWriteError(_ *gortsplib.ServerHandlerOnStreamWriteErrorCtx) {
|
func (s *session) onStreamWriteError(_ *gortsplib.ServerHandlerOnStreamWriteErrorCtx) {
|
||||||
// currently the only error returned by OnStreamWriteError is ErrServerWriteQueueFull
|
// currently the only error returned by OnStreamWriteError is ErrServerWriteQueueFull
|
||||||
s.discardedFrames.Increase()
|
s.outboundRTPPacketsDiscarded.Increase()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *session) apiItem() *defs.APIRTSPSession {
|
func (s *session) apiItem() *defs.APIRTSPSession {
|
||||||
|
|||||||
@@ -324,7 +324,7 @@ func TestServerPublish(t *testing.T) {
|
|||||||
|
|
||||||
list, err := s.APISessionsList()
|
list, err := s.APISessionsList()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, &defs.APIWebRTCSessionList{
|
require.Equal(t, &defs.APIWebRTCSessionList{ //nolint:dupl
|
||||||
Items: []defs.APIWebRTCSession{
|
Items: []defs.APIWebRTCSession{
|
||||||
{
|
{
|
||||||
ID: list.Items[0].ID,
|
ID: list.Items[0].ID,
|
||||||
@@ -334,6 +334,14 @@ func TestServerPublish(t *testing.T) {
|
|||||||
Path: "teststream",
|
Path: "teststream",
|
||||||
Query: "param=value",
|
Query: "param=value",
|
||||||
User: "myuser",
|
User: "myuser",
|
||||||
|
InboundBytes: list.Items[0].InboundBytes,
|
||||||
|
InboundRTPPackets: list.Items[0].InboundRTPPackets,
|
||||||
|
InboundRTPPacketsLost: list.Items[0].InboundRTPPacketsLost,
|
||||||
|
InboundRTPPacketsJitter: list.Items[0].InboundRTPPacketsJitter,
|
||||||
|
InboundRTCPPackets: list.Items[0].InboundRTCPPackets,
|
||||||
|
OutboundBytes: list.Items[0].OutboundBytes,
|
||||||
|
OutboundRTPPackets: list.Items[0].OutboundRTPPackets,
|
||||||
|
OutboundRTCPPackets: list.Items[0].OutboundRTCPPackets,
|
||||||
BytesReceived: list.Items[0].BytesReceived,
|
BytesReceived: list.Items[0].BytesReceived,
|
||||||
BytesSent: list.Items[0].BytesSent,
|
BytesSent: list.Items[0].BytesSent,
|
||||||
RTPPacketsReceived: list.Items[0].RTPPacketsReceived,
|
RTPPacketsReceived: list.Items[0].RTPPacketsReceived,
|
||||||
@@ -609,7 +617,7 @@ func TestServerRead(t *testing.T) {
|
|||||||
|
|
||||||
list, err := s.APISessionsList()
|
list, err := s.APISessionsList()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, &defs.APIWebRTCSessionList{
|
require.Equal(t, &defs.APIWebRTCSessionList{ //nolint:dupl
|
||||||
Items: []defs.APIWebRTCSession{
|
Items: []defs.APIWebRTCSession{
|
||||||
{
|
{
|
||||||
ID: list.Items[0].ID,
|
ID: list.Items[0].ID,
|
||||||
@@ -619,6 +627,14 @@ func TestServerRead(t *testing.T) {
|
|||||||
Path: "teststream",
|
Path: "teststream",
|
||||||
Query: "param=value",
|
Query: "param=value",
|
||||||
User: "myuser",
|
User: "myuser",
|
||||||
|
InboundBytes: list.Items[0].InboundBytes,
|
||||||
|
InboundRTPPackets: list.Items[0].InboundRTPPackets,
|
||||||
|
InboundRTPPacketsLost: list.Items[0].InboundRTPPacketsLost,
|
||||||
|
InboundRTPPacketsJitter: list.Items[0].InboundRTPPacketsJitter,
|
||||||
|
InboundRTCPPackets: list.Items[0].InboundRTCPPackets,
|
||||||
|
OutboundBytes: list.Items[0].OutboundBytes,
|
||||||
|
OutboundRTPPackets: list.Items[0].OutboundRTPPackets,
|
||||||
|
OutboundRTCPPackets: list.Items[0].OutboundRTCPPackets,
|
||||||
BytesReceived: list.Items[0].BytesReceived,
|
BytesReceived: list.Items[0].BytesReceived,
|
||||||
BytesSent: list.Items[0].BytesSent,
|
BytesSent: list.Items[0].BytesSent,
|
||||||
RTPPacketsReceived: list.Items[0].RTPPacketsReceived,
|
RTPPacketsReceived: list.Items[0].RTPPacketsReceived,
|
||||||
|
|||||||
@@ -508,16 +508,24 @@ func (s *session) apiItem() *defs.APIWebRTCSession {
|
|||||||
}
|
}
|
||||||
return defs.APIWebRTCSessionStateRead
|
return defs.APIWebRTCSessionStateRead
|
||||||
}(),
|
}(),
|
||||||
Path: s.req.pathName,
|
Path: s.req.pathName,
|
||||||
Query: s.req.httpRequest.URL.RawQuery,
|
Query: s.req.httpRequest.URL.RawQuery,
|
||||||
User: s.user,
|
User: s.user,
|
||||||
BytesReceived: bytesReceived,
|
InboundBytes: bytesReceived,
|
||||||
BytesSent: bytesSent,
|
InboundRTPPackets: rtpPacketsReceived,
|
||||||
RTPPacketsReceived: rtpPacketsReceived,
|
InboundRTPPacketsLost: rtpPacketsLost,
|
||||||
RTPPacketsSent: rtpPacketsSent,
|
InboundRTPPacketsJitter: rtpPacketsJitter,
|
||||||
RTPPacketsLost: rtpPacketsLost,
|
InboundRTCPPackets: rtcpPacketsReceived,
|
||||||
RTPPacketsJitter: rtpPacketsJitter,
|
OutboundBytes: bytesSent,
|
||||||
RTCPPacketsReceived: rtcpPacketsReceived,
|
OutboundRTPPackets: rtpPacketsSent,
|
||||||
RTCPPacketsSent: rtcpPacketsSent,
|
OutboundRTCPPackets: rtcpPacketsSent,
|
||||||
|
BytesReceived: bytesReceived,
|
||||||
|
BytesSent: bytesSent,
|
||||||
|
RTPPacketsReceived: rtpPacketsReceived,
|
||||||
|
RTPPacketsSent: rtpPacketsSent,
|
||||||
|
RTPPacketsLost: rtpPacketsLost,
|
||||||
|
RTPPacketsJitter: rtpPacketsJitter,
|
||||||
|
RTCPPacketsReceived: rtcpPacketsReceived,
|
||||||
|
RTCPPacketsSent: rtcpPacketsSent,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,10 +19,10 @@ type Reader struct {
|
|||||||
SkipBytesSent bool
|
SkipBytesSent bool
|
||||||
Parent logger.Writer
|
Parent logger.Writer
|
||||||
|
|
||||||
onDatas map[*description.Media]map[format.Format]OnDataFunc
|
onDatas map[*description.Media]map[format.Format]OnDataFunc
|
||||||
queueSize int
|
queueSize int
|
||||||
buffer *ringbuffer.RingBuffer
|
buffer *ringbuffer.RingBuffer
|
||||||
discardedFrames *counterdumper.Dumper
|
outboundFramesDiscarded *counterdumper.Dumper
|
||||||
|
|
||||||
// out
|
// out
|
||||||
err chan error
|
err chan error
|
||||||
@@ -76,7 +76,7 @@ func (r *Reader) start() {
|
|||||||
r.buffer = buffer
|
r.buffer = buffer
|
||||||
r.err = make(chan error)
|
r.err = make(chan error)
|
||||||
|
|
||||||
r.discardedFrames = &counterdumper.Dumper{
|
r.outboundFramesDiscarded = &counterdumper.Dumper{
|
||||||
OnReport: func(val uint64) {
|
OnReport: func(val uint64) {
|
||||||
r.Parent.Log(logger.Warn, "reader is too slow, discarding %d %s",
|
r.Parent.Log(logger.Warn, "reader is too slow, discarding %d %s",
|
||||||
val,
|
val,
|
||||||
@@ -88,14 +88,14 @@ func (r *Reader) start() {
|
|||||||
}())
|
}())
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
r.discardedFrames.Start()
|
r.outboundFramesDiscarded.Start()
|
||||||
|
|
||||||
go r.run()
|
go r.run()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Reader) stop() {
|
func (r *Reader) stop() {
|
||||||
r.buffer.Close()
|
r.buffer.Close()
|
||||||
r.discardedFrames.Stop()
|
r.outboundFramesDiscarded.Stop()
|
||||||
<-r.err
|
<-r.err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,6 +121,6 @@ func (r *Reader) runInner() error {
|
|||||||
func (r *Reader) push(cb func() error) {
|
func (r *Reader) push(cb func() error) {
|
||||||
ok := r.buffer.Push(cb)
|
ok := r.buffer.Push(cb)
|
||||||
if !ok {
|
if !ok {
|
||||||
r.discardedFrames.Increase()
|
r.outboundFramesDiscarded.Increase()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+26
-26
@@ -321,17 +321,17 @@ type Stream struct {
|
|||||||
ReplaceNTP bool
|
ReplaceNTP bool
|
||||||
Parent logger.Writer
|
Parent logger.Writer
|
||||||
|
|
||||||
offlineDesc *description.Session
|
offlineDesc *description.Session
|
||||||
mutex sync.RWMutex
|
mutex sync.RWMutex
|
||||||
subStream *SubStream
|
subStream *SubStream
|
||||||
offlineSubStream *offlineSubStream
|
offlineSubStream *offlineSubStream
|
||||||
inboundBytes *uint64
|
inboundBytes *uint64
|
||||||
outboundBytes *uint64
|
outboundBytes *uint64
|
||||||
medias map[*description.Media]*streamMedia
|
medias map[*description.Media]*streamMedia
|
||||||
rtspStream *gortsplib.ServerStream
|
rtspStream *gortsplib.ServerStream
|
||||||
rtspsStream *gortsplib.ServerStream
|
rtspsStream *gortsplib.ServerStream
|
||||||
readers map[*Reader]struct{}
|
readers map[*Reader]struct{}
|
||||||
processingErrors *errordumper.Dumper
|
inboundFramesInError *errordumper.Dumper
|
||||||
|
|
||||||
timeMutex sync.Mutex
|
timeMutex sync.Mutex
|
||||||
firstTimeReceived bool
|
firstTimeReceived bool
|
||||||
@@ -377,7 +377,7 @@ func (s *Stream) Initialize() error {
|
|||||||
s.readers = make(map[*Reader]struct{})
|
s.readers = make(map[*Reader]struct{})
|
||||||
s.hasReaders = make(chan struct{})
|
s.hasReaders = make(chan struct{})
|
||||||
|
|
||||||
s.processingErrors = &errordumper.Dumper{
|
s.inboundFramesInError = &errordumper.Dumper{
|
||||||
OnReport: func(val uint64, last error) {
|
OnReport: func(val uint64, last error) {
|
||||||
if val == 1 {
|
if val == 1 {
|
||||||
s.Parent.Log(logger.Warn, "processing error: %v", last)
|
s.Parent.Log(logger.Warn, "processing error: %v", last)
|
||||||
@@ -386,22 +386,22 @@ func (s *Stream) Initialize() error {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
s.processingErrors.Start()
|
s.inboundFramesInError.Start()
|
||||||
|
|
||||||
s.lastSystemTime = time.Now()
|
s.lastSystemTime = time.Now()
|
||||||
|
|
||||||
for _, media := range s.Desc.Medias {
|
for _, media := range s.Desc.Medias {
|
||||||
sm := &streamMedia{
|
sm := &streamMedia{
|
||||||
media: media,
|
media: media,
|
||||||
alwaysAvailable: s.AlwaysAvailable,
|
alwaysAvailable: s.AlwaysAvailable,
|
||||||
rtpMaxPayloadSize: s.RTPMaxPayloadSize,
|
rtpMaxPayloadSize: s.RTPMaxPayloadSize,
|
||||||
replaceNTP: s.ReplaceNTP,
|
replaceNTP: s.ReplaceNTP,
|
||||||
addBytesReceived: s.addBytesReceived,
|
addInboundBytes: s.addInboundBytes,
|
||||||
addBytesSent: s.addBytesSent,
|
addOutboundBytes: s.addOutboundBytes,
|
||||||
updateLastTime: s.updateLastTime,
|
updateLastTime: s.updateLastTime,
|
||||||
writeRTSP: s.writeRTSP,
|
writeRTSP: s.writeRTSP,
|
||||||
processingErrors: s.processingErrors,
|
inboundFramesInError: s.inboundFramesInError,
|
||||||
parent: s.Parent,
|
parent: s.Parent,
|
||||||
}
|
}
|
||||||
err := sm.initialize()
|
err := sm.initialize()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -426,7 +426,7 @@ func (s *Stream) Close() {
|
|||||||
s.offlineSubStream.close(false)
|
s.offlineSubStream.close(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
s.processingErrors.Stop()
|
s.inboundFramesInError.Stop()
|
||||||
|
|
||||||
if s.rtspStream != nil {
|
if s.rtspStream != nil {
|
||||||
s.rtspStream.Close()
|
s.rtspStream.Close()
|
||||||
@@ -571,11 +571,11 @@ func (s *Stream) WaitForReaders() {
|
|||||||
<-s.hasReaders
|
<-s.hasReaders
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Stream) addBytesReceived(v uint64) {
|
func (s *Stream) addInboundBytes(v uint64) {
|
||||||
atomic.AddUint64(s.inboundBytes, v)
|
atomic.AddUint64(s.inboundBytes, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Stream) addBytesSent(v uint64) {
|
func (s *Stream) addOutboundBytes(v uint64) {
|
||||||
atomic.AddUint64(s.outboundBytes, v)
|
atomic.AddUint64(s.outboundBytes, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,17 +38,17 @@ func randUint32() (uint32, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type streamFormat struct {
|
type streamFormat struct {
|
||||||
format format.Format
|
format format.Format
|
||||||
media *description.Media
|
media *description.Media
|
||||||
alwaysAvailable bool
|
alwaysAvailable bool
|
||||||
rtpMaxPayloadSize int
|
rtpMaxPayloadSize int
|
||||||
replaceNTP bool
|
replaceNTP bool
|
||||||
processingErrors *errordumper.Dumper
|
inboundFramesInError *errordumper.Dumper
|
||||||
addBytesReceived func(uint64)
|
addInboundBytes func(uint64)
|
||||||
addBytesSent func(uint64)
|
addOutboundBytes func(uint64)
|
||||||
updateLastTime func(time.Duration)
|
updateLastTime func(time.Duration)
|
||||||
writeRTSP func(*description.Media, []*rtp.Packet, time.Time)
|
writeRTSP func(*description.Media, []*rtp.Packet, time.Time)
|
||||||
parent logger.Writer
|
parent logger.Writer
|
||||||
|
|
||||||
ptsOffset int64
|
ptsOffset int64
|
||||||
formatUpdater formatUpdater
|
formatUpdater formatUpdater
|
||||||
|
|||||||
@@ -11,16 +11,16 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type streamMedia struct {
|
type streamMedia struct {
|
||||||
media *description.Media
|
media *description.Media
|
||||||
alwaysAvailable bool
|
alwaysAvailable bool
|
||||||
rtpMaxPayloadSize int
|
rtpMaxPayloadSize int
|
||||||
replaceNTP bool
|
replaceNTP bool
|
||||||
addBytesReceived func(uint64)
|
addInboundBytes func(uint64)
|
||||||
addBytesSent func(uint64)
|
addOutboundBytes func(uint64)
|
||||||
updateLastTime func(time.Duration)
|
updateLastTime func(time.Duration)
|
||||||
writeRTSP func(*description.Media, []*rtp.Packet, time.Time)
|
writeRTSP func(*description.Media, []*rtp.Packet, time.Time)
|
||||||
processingErrors *errordumper.Dumper
|
inboundFramesInError *errordumper.Dumper
|
||||||
parent logger.Writer
|
parent logger.Writer
|
||||||
|
|
||||||
formats map[format.Format]*streamFormat
|
formats map[format.Format]*streamFormat
|
||||||
}
|
}
|
||||||
@@ -30,17 +30,17 @@ func (sm *streamMedia) initialize() error {
|
|||||||
|
|
||||||
for _, forma := range sm.media.Formats {
|
for _, forma := range sm.media.Formats {
|
||||||
sf := &streamFormat{
|
sf := &streamFormat{
|
||||||
format: forma,
|
format: forma,
|
||||||
media: sm.media,
|
media: sm.media,
|
||||||
alwaysAvailable: sm.alwaysAvailable,
|
alwaysAvailable: sm.alwaysAvailable,
|
||||||
rtpMaxPayloadSize: sm.rtpMaxPayloadSize,
|
rtpMaxPayloadSize: sm.rtpMaxPayloadSize,
|
||||||
replaceNTP: sm.replaceNTP,
|
replaceNTP: sm.replaceNTP,
|
||||||
processingErrors: sm.processingErrors,
|
inboundFramesInError: sm.inboundFramesInError,
|
||||||
addBytesReceived: sm.addBytesReceived,
|
addInboundBytes: sm.addInboundBytes,
|
||||||
addBytesSent: sm.addBytesSent,
|
addOutboundBytes: sm.addOutboundBytes,
|
||||||
updateLastTime: sm.updateLastTime,
|
updateLastTime: sm.updateLastTime,
|
||||||
writeRTSP: sm.writeRTSP,
|
writeRTSP: sm.writeRTSP,
|
||||||
parent: sm.parent,
|
parent: sm.parent,
|
||||||
}
|
}
|
||||||
err := sf.initialize()
|
err := sf.initialize()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ func (ssf *subStreamFormat) initialize2(firstTimeReceived bool, lastPTS time.Dur
|
|||||||
func (ssf *subStreamFormat) writeUnit(u *unit.Unit) {
|
func (ssf *subStreamFormat) writeUnit(u *unit.Unit) {
|
||||||
err := ssf.writeUnitInner(u)
|
err := ssf.writeUnitInner(u)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ssf.streamFormat.processingErrors.Add(err)
|
ssf.streamFormat.inboundFramesInError.Add(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -170,7 +170,7 @@ func (ssf *subStreamFormat) writeUnitInner(u *unit.Unit) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
size := unitSize(u)
|
size := unitSize(u)
|
||||||
ssf.streamFormat.addBytesReceived(size)
|
ssf.streamFormat.addInboundBytes(size)
|
||||||
|
|
||||||
ssf.streamFormat.writeRTSP(ssf.streamFormat.media, u.RTPPackets, u.NTP)
|
ssf.streamFormat.writeRTSP(ssf.streamFormat.media, u.RTPPackets, u.NTP)
|
||||||
|
|
||||||
@@ -179,7 +179,7 @@ func (ssf *subStreamFormat) writeUnitInner(u *unit.Unit) error {
|
|||||||
cOnData := onData
|
cOnData := onData
|
||||||
sr.push(func() error {
|
sr.push(func() error {
|
||||||
if !csr.SkipBytesSent {
|
if !csr.SkipBytesSent {
|
||||||
ssf.streamFormat.addBytesSent(size)
|
ssf.streamFormat.addOutboundBytes(size)
|
||||||
}
|
}
|
||||||
return cOnData(u)
|
return cOnData(u)
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user