Fix handling of PacketLost (#296)

They come accumulated already.
This commit is contained in:
Artur Shellunts
2021-12-30 11:06:00 +01:00
committed by GitHub
parent 2d8106c3d7
commit 1b66fe1e23
3 changed files with 59 additions and 9 deletions
+10 -6
View File
@@ -25,11 +25,13 @@ type StatsWorker struct {
}
type Stats struct {
next *livekit.AnalyticsStat
totalPackets uint32
prevPackets uint32
totalBytes uint64
prevBytes uint64
next *livekit.AnalyticsStat
totalPackets uint32
prevPackets uint32
totalBytes uint64
prevBytes uint64
totalPacketsLost uint64
prevPacketsLost uint64
}
func newStatsWorker(ctx context.Context, t TelemetryReporter, roomID, roomName, participantID string) *StatsWorker {
@@ -89,6 +91,7 @@ func (s *StatsWorker) OnRTCP(trackID string, direction livekit.StreamType, stats
} else {
ds = s.getOrCreateIncomingStatsIfEmpty(trackID)
}
ds.totalPacketsLost = stats.PacketLost
if stats.Delay > ds.next.Delay {
ds.next.Delay = stats.Delay
@@ -96,7 +99,6 @@ func (s *StatsWorker) OnRTCP(trackID string, direction livekit.StreamType, stats
if stats.Jitter > ds.next.Jitter {
ds.next.Jitter = stats.Jitter
}
ds.next.PacketLost += stats.PacketLost
ds.next.NackCount += stats.NackCount
ds.next.PliCount += stats.PliCount
ds.next.FirCount += stats.FirCount
@@ -174,9 +176,11 @@ func (s *StatsWorker) update(stats *Stats, ts *timestamppb.Timestamp) *livekit.A
next.TimeStamp = ts
next.TotalPackets = uint64(stats.totalPackets - stats.prevPackets)
next.TotalBytes = stats.totalBytes - stats.prevBytes
next.PacketLost = stats.totalPacketsLost - stats.prevPacketsLost
stats.prevPackets = stats.totalPackets
stats.prevBytes = stats.totalBytes
stats.prevPacketsLost = stats.totalPacketsLost
return next
}