1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-11-09 02:05:59 +01:00

Discard old keyframes.

Avoids seqno wraparound.  Unlikely, but I'm supersticious.
This commit is contained in:
Juliusz Chroboczek 2020-10-06 05:02:58 +02:00
parent 0eb1593bb8
commit 86f7594626

View file

@ -137,6 +137,10 @@ func (frame *frame) store(seqno uint16, timestamp uint32, first bool, data []byt
}
} else if len(frame.entries) > 0 {
if frame.timestamp != timestamp {
delta := seqno - frame.entries[0].seqno
if (delta & 0x8000) == 0 && delta > 0x4000 {
frame.entries = frame.entries[:0]
}
return
}
} else {
@ -271,6 +275,10 @@ func (cache *Cache) Keyframe() (uint32, []uint16) {
cache.mu.Lock()
defer cache.mu.Unlock()
if len(cache.keyframe.entries) == 0 {
return 0, nil
}
seqnos := make([]uint16, len(cache.keyframe.entries))
for i := range cache.keyframe.entries {
seqnos[i] = cache.keyframe.entries[i].seqno