mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
add ReceiverReport.
This commit is contained in:
parent
fb707f05a6
commit
d5c934f2af
@ -404,6 +404,13 @@ func (manager *WebRTCManagerCtx) CreatePeer(session types.Session, videoID strin
|
|||||||
switch rtcpPacket := p.(type) {
|
switch rtcpPacket := p.(type) {
|
||||||
case *rtcp.ReceiverEstimatedMaximumBitrate: // TODO: Deprecated.
|
case *rtcp.ReceiverEstimatedMaximumBitrate: // TODO: Deprecated.
|
||||||
manager.metrics.SetReceiverEstimatedMaximumBitrate(session, rtcpPacket.Bitrate)
|
manager.metrics.SetReceiverEstimatedMaximumBitrate(session, rtcpPacket.Bitrate)
|
||||||
|
|
||||||
|
case *rtcp.ReceiverReport:
|
||||||
|
l := len(rtcpPacket.Reports)
|
||||||
|
if l > 0 {
|
||||||
|
// use only last report
|
||||||
|
manager.metrics.SetReceiverReport(session, rtcpPacket.Reports[l-1])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package webrtc
|
|||||||
import (
|
import (
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"github.com/pion/rtcp"
|
||||||
"github.com/pion/webrtc/v3"
|
"github.com/pion/webrtc/v3"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||||
@ -23,6 +24,10 @@ type metrics struct {
|
|||||||
|
|
||||||
receiverEstimatedMaximumBitrate prometheus.Gauge
|
receiverEstimatedMaximumBitrate prometheus.Gauge
|
||||||
|
|
||||||
|
receiverReportDelay prometheus.Gauge
|
||||||
|
receiverReportJitter prometheus.Gauge
|
||||||
|
receiverReportTotalLost prometheus.Gauge
|
||||||
|
|
||||||
iceBytesSent prometheus.Gauge
|
iceBytesSent prometheus.Gauge
|
||||||
iceBytesReceived prometheus.Gauge
|
iceBytesReceived prometheus.Gauge
|
||||||
sctpBytesSent prometheus.Gauge
|
sctpBytesSent prometheus.Gauge
|
||||||
@ -104,6 +109,34 @@ func (m *metricsCtx) getBySession(session types.Session) metrics {
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
receiverReportDelay: promauto.NewGauge(prometheus.GaugeOpts{
|
||||||
|
Name: "receiver_report_delay",
|
||||||
|
Namespace: "neko",
|
||||||
|
Subsystem: "webrtc",
|
||||||
|
Help: "Receiver Report Delay from SCTP, expressed in units of 1/65536 seconds.",
|
||||||
|
ConstLabels: map[string]string{
|
||||||
|
"session_id": session.ID(),
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
receiverReportJitter: promauto.NewGauge(prometheus.GaugeOpts{
|
||||||
|
Name: "receiver_report_jitter",
|
||||||
|
Namespace: "neko",
|
||||||
|
Subsystem: "webrtc",
|
||||||
|
Help: "Receiver Report Jitter from SCTP.",
|
||||||
|
ConstLabels: map[string]string{
|
||||||
|
"session_id": session.ID(),
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
receiverReportTotalLost: promauto.NewGauge(prometheus.GaugeOpts{
|
||||||
|
Name: "receiver_report_total_lost",
|
||||||
|
Namespace: "neko",
|
||||||
|
Subsystem: "webrtc",
|
||||||
|
Help: "Receiver Report Total Lost from SCTP.",
|
||||||
|
ConstLabels: map[string]string{
|
||||||
|
"session_id": session.ID(),
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
|
||||||
iceBytesSent: promauto.NewGauge(prometheus.GaugeOpts{
|
iceBytesSent: promauto.NewGauge(prometheus.GaugeOpts{
|
||||||
Name: "bytes_sent",
|
Name: "bytes_sent",
|
||||||
Namespace: "neko",
|
Namespace: "neko",
|
||||||
@ -227,6 +260,14 @@ func (m *metricsCtx) SetReceiverEstimatedMaximumBitrate(session types.Session, b
|
|||||||
met.receiverEstimatedMaximumBitrate.Set(float64(bitrate))
|
met.receiverEstimatedMaximumBitrate.Set(float64(bitrate))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *metricsCtx) SetReceiverReport(session types.Session, report rtcp.ReceptionReport) {
|
||||||
|
met := m.getBySession(session)
|
||||||
|
|
||||||
|
met.receiverReportDelay.Set(float64(report.Delay))
|
||||||
|
met.receiverReportJitter.Set(float64(report.Jitter))
|
||||||
|
met.receiverReportTotalLost.Set(float64(report.TotalLost))
|
||||||
|
}
|
||||||
|
|
||||||
func (m *metricsCtx) SetIceTransportStats(session types.Session, data webrtc.TransportStats) {
|
func (m *metricsCtx) SetIceTransportStats(session types.Session, data webrtc.TransportStats) {
|
||||||
met := m.getBySession(session)
|
met := m.getBySession(session)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user