Files
2026-09-01 23:45:10 +03:00

38 lines
840 B
Go

package main
import "mxl-player/internal/playback"
// videoDropTracker counts gaps only within one playback generation. Frame
// indices belong to their source and cannot be compared across feed changes.
type videoDropTracker struct {
generation uint64
source playback.FeedConfig
lastIndex uint64
hasIndex bool
}
func (t *videoDropTracker) Observe(
generation uint64,
source playback.FeedConfig,
index uint64,
) uint64 {
if !t.hasIndex ||
generation != t.generation ||
!sameVideoSource(source, t.source) ||
index <= t.lastIndex {
t.generation = generation
t.source = source
t.lastIndex = index
t.hasIndex = true
return 0
}
dropped := index - t.lastIndex - 1
t.lastIndex = index
return dropped
}
func sameVideoSource(a, b playback.FeedConfig) bool {
return a.Domain == b.Domain && a.UUID == b.UUID
}