diff --git a/client.go b/client.go index 44c6ba4..90eadea 100644 --- a/client.go +++ b/client.go @@ -395,7 +395,7 @@ func sendRR(c *client, conn *upConnection) error { reports := make([]rtcp.ReceptionReport, 0, len(conn.tracks)) for _, t := range conn.tracks { - expected, lost, eseqno := t.cache.GetStats(true) + expected, lost, totalLost, eseqno := t.cache.GetStats(true) if expected == 0 { expected = 1 } @@ -406,7 +406,7 @@ func sendRR(c *client, conn *upConnection) error { SSRC: t.track.SSRC(), LastSenderReport: atomic.LoadUint32(&t.lastSenderReport), FractionLost: uint8((lost * 256) / expected), - TotalLost: lost, + TotalLost: totalLost, LastSequenceNumber: eseqno, }) } diff --git a/group.go b/group.go index 3e19f3e..9b66cef 100644 --- a/group.go +++ b/group.go @@ -698,7 +698,7 @@ func getClientStats(c *client) clientStats { for _, up := range c.up { conns := connStats{id: up.id} for _, t := range up.tracks { - expected, lost, _ := t.cache.GetStats(false) + expected, lost, _, _ := t.cache.GetStats(false) if expected == 0 { expected = 1 } diff --git a/packetcache/packetcache.go b/packetcache/packetcache.go index b905c87..702c87d 100644 --- a/packetcache/packetcache.go +++ b/packetcache/packetcache.go @@ -20,6 +20,7 @@ type Cache struct { lastValid bool expected uint32 lost uint32 + totalLost uint32 // bitmap first uint16 bitmap uint32 @@ -151,17 +152,19 @@ func (cache *Cache) BitmapGet() (uint16, uint16) { return first, bitmap } -func (cache *Cache) GetStats(reset bool) (uint32, uint32, uint32) { +func (cache *Cache) GetStats(reset bool) (uint32, uint32, uint32, uint32) { cache.mu.Lock() defer cache.mu.Unlock() expected := cache.expected lost := cache.lost + totalLost := cache.totalLost + cache.lost eseqno := uint32(cache.cycle)<<16 | uint32(cache.last) if reset { cache.expected = 0 + cache.totalLost += cache.lost cache.lost = 0 } - return expected, lost, eseqno + return expected, lost, totalLost, eseqno }