1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-11-22 08:35:57 +01:00

Fix loss statistics on NACK.

Since we don't use a separate RTX SSID, we must explicitly account for
NACKed packets in our loss statistics.
This commit is contained in:
Juliusz Chroboczek 2021-04-27 12:18:43 +02:00
parent 8da55c6e6c
commit f0cf9ae141

View file

@ -260,14 +260,15 @@ func (cache *Cache) Store(seqno uint16, timestamp uint32, keyframe bool, marker
cache.lastValid = true cache.lastValid = true
cache.expected++ cache.expected++
} else { } else {
if compare(cache.last, seqno) <= 0 { cmp := compare(cache.last, seqno)
if cmp < 0 {
cache.expected += uint32(seqno - cache.last) cache.expected += uint32(seqno - cache.last)
cache.lost += uint32(seqno - cache.last - 1) cache.lost += uint32(seqno - cache.last - 1)
if seqno < cache.last { if seqno < cache.last {
cache.cycle++ cache.cycle++
} }
cache.last = seqno cache.last = seqno
} else { } else if cmp > 0 {
if cache.lost > 0 { if cache.lost > 0 {
cache.lost-- cache.lost--
} }
@ -346,7 +347,7 @@ func completeKeyframe(cache *Cache) {
} }
} }
// Expect records that we expect n packets. It is used for loss statistics. // Expect records that we expect n additional packets.
func (cache *Cache) Expect(n int) { func (cache *Cache) Expect(n int) {
if n <= 0 { if n <= 0 {
return return
@ -354,6 +355,7 @@ func (cache *Cache) Expect(n int) {
cache.mu.Lock() cache.mu.Lock()
defer cache.mu.Unlock() defer cache.mu.Unlock()
cache.expected += uint32(n) cache.expected += uint32(n)
cache.lost++
} }
// get retrieves a packet from a slice of entries. // get retrieves a packet from a slice of entries.