Commit 86f75946 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Discard old keyframes.

Avoids seqno wraparound.  Unlikely, but I'm supersticious.
parent 0eb1593b
......@@ -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
......
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