feat(webrtc): enable keyframe cache on video sources (issue #17)
Some checks failed
ci / vet + build (push) Failing after 5m1s
ci / race tests (push) Has been skipped
ci / WebRTC smoke (5-viewer fanout) (push) Has been skipped
ci / WebRTC latency p95 gate (push) Has been skipped

Call videoSrc.EnableKeyFrameCache() immediately after binding the video
UDP Source in allocAdjacentPair(). Audio sources are intentionally left
uncached — IDR detection on Opus packets would accumulate the entire
audio stream without ever resetting the burst.
This commit is contained in:
Zac Gaetano 2026-05-09 19:05:11 -04:00
parent 020a1800ce
commit 7490edd770

View file

@ -141,6 +141,11 @@ func (s *Subsystem) allocAdjacentPair(id string) (int, *corewebrtc.Source, *core
lastErr = err lastErr = err
continue continue
} }
// Activate IDR keyframe caching on the video source so that
// late-joining WHEP peers receive a reference frame immediately
// instead of waiting up to one full keyframe interval.
videoSrc.EnableKeyFrameCache()
audioSrc, err := corewebrtc.NewSourceOn(id+":audio", "127.0.0.1", port+1) audioSrc, err := corewebrtc.NewSourceOn(id+":audio", "127.0.0.1", port+1)
if err != nil { if err != nil {
_ = videoSrc.Close() _ = videoSrc.Close()