Commit 57151829 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Fix TotalLost value in receiver reports.

parent 100f72e7
...@@ -395,7 +395,7 @@ func sendRR(c *client, conn *upConnection) error { ...@@ -395,7 +395,7 @@ func sendRR(c *client, conn *upConnection) error {
reports := make([]rtcp.ReceptionReport, 0, len(conn.tracks)) reports := make([]rtcp.ReceptionReport, 0, len(conn.tracks))
for _, t := range 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 { if expected == 0 {
expected = 1 expected = 1
} }
...@@ -406,7 +406,7 @@ func sendRR(c *client, conn *upConnection) error { ...@@ -406,7 +406,7 @@ func sendRR(c *client, conn *upConnection) error {
SSRC: t.track.SSRC(), SSRC: t.track.SSRC(),
LastSenderReport: atomic.LoadUint32(&t.lastSenderReport), LastSenderReport: atomic.LoadUint32(&t.lastSenderReport),
FractionLost: uint8((lost * 256) / expected), FractionLost: uint8((lost * 256) / expected),
TotalLost: lost, TotalLost: totalLost,
LastSequenceNumber: eseqno, LastSequenceNumber: eseqno,
}) })
} }
......
...@@ -698,7 +698,7 @@ func getClientStats(c *client) clientStats { ...@@ -698,7 +698,7 @@ func getClientStats(c *client) clientStats {
for _, up := range c.up { for _, up := range c.up {
conns := connStats{id: up.id} conns := connStats{id: up.id}
for _, t := range up.tracks { for _, t := range up.tracks {
expected, lost, _ := t.cache.GetStats(false) expected, lost, _, _ := t.cache.GetStats(false)
if expected == 0 { if expected == 0 {
expected = 1 expected = 1
} }
......
...@@ -20,6 +20,7 @@ type Cache struct { ...@@ -20,6 +20,7 @@ type Cache struct {
lastValid bool lastValid bool
expected uint32 expected uint32
lost uint32 lost uint32
totalLost uint32
// bitmap // bitmap
first uint16 first uint16
bitmap uint32 bitmap uint32
...@@ -151,17 +152,19 @@ func (cache *Cache) BitmapGet() (uint16, uint16) { ...@@ -151,17 +152,19 @@ func (cache *Cache) BitmapGet() (uint16, uint16) {
return first, bitmap 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() cache.mu.Lock()
defer cache.mu.Unlock() defer cache.mu.Unlock()
expected := cache.expected expected := cache.expected
lost := cache.lost lost := cache.lost
totalLost := cache.totalLost + cache.lost
eseqno := uint32(cache.cycle)<<16 | uint32(cache.last) eseqno := uint32(cache.cycle)<<16 | uint32(cache.last)
if reset { if reset {
cache.expected = 0 cache.expected = 0
cache.totalLost += cache.lost
cache.lost = 0 cache.lost = 0
} }
return expected, lost, eseqno return expected, lost, totalLost, eseqno
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment