stats for pli and bitrate (#487)
* stats for pli and bitrate * solve comments * return 0 if no pli sent
This commit is contained in:
+15
-2
@@ -39,6 +39,7 @@ type TrackReceiver interface {
|
||||
GetBitrateTemporalCumulative() Bitrates
|
||||
|
||||
SendPLI(layer int32)
|
||||
LastPLI() int64
|
||||
|
||||
SetUpTrackPaused(paused bool)
|
||||
SetMaxExpectedSpatialLayer(layer int32)
|
||||
@@ -169,7 +170,7 @@ func NewWebRTCReceiver(
|
||||
w.connectionStats = connectionquality.NewConnectionStats(connectionquality.ConnectionStatsParams{
|
||||
CodecType: w.kind,
|
||||
ClockRate: w.codec.ClockRate,
|
||||
GetTrackStats: w.getTrackStats,
|
||||
GetTrackStats: w.GetTrackStats,
|
||||
GetIsReducedQuality: func() bool {
|
||||
return w.streamTrackerManager.IsReducedQuality()
|
||||
},
|
||||
@@ -402,6 +403,18 @@ func (w *WebRTCReceiver) SendPLI(layer int32) {
|
||||
buff.SendPLI()
|
||||
}
|
||||
|
||||
func (w *WebRTCReceiver) LastPLI() int64 {
|
||||
var lastPLI int64
|
||||
w.bufferMu.RLock()
|
||||
for _, b := range w.buffers {
|
||||
if b != nil && b.LastPLI() > lastPLI {
|
||||
lastPLI = b.LastPLI()
|
||||
}
|
||||
}
|
||||
w.bufferMu.RUnlock()
|
||||
return lastPLI
|
||||
}
|
||||
|
||||
func (w *WebRTCReceiver) SetRTCPCh(ch chan []rtcp.Packet) {
|
||||
w.rtcpCh = ch
|
||||
}
|
||||
@@ -422,7 +435,7 @@ func (w *WebRTCReceiver) ReadRTP(buf []byte, layer uint8, sn uint16) (int, error
|
||||
return buff.GetPacket(buf, sn)
|
||||
}
|
||||
|
||||
func (w *WebRTCReceiver) getTrackStats() map[uint32]*buffer.StreamStatsWithLayers {
|
||||
func (w *WebRTCReceiver) GetTrackStats() map[uint32]*buffer.StreamStatsWithLayers {
|
||||
w.bufferMu.RLock()
|
||||
defer w.bufferMu.RUnlock()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user