From 7490edd770ca6798747bdefd686277a29028e85d Mon Sep 17 00:00:00 2001 From: ZGaetano Date: Sat, 9 May 2026 19:05:11 -0400 Subject: [PATCH] feat(webrtc): enable keyframe cache on video sources (issue #17) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- app/webrtc/lifecycle.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/webrtc/lifecycle.go b/app/webrtc/lifecycle.go index 2583d09..bf1c7d8 100644 --- a/app/webrtc/lifecycle.go +++ b/app/webrtc/lifecycle.go @@ -141,6 +141,11 @@ func (s *Subsystem) allocAdjacentPair(id string) (int, *corewebrtc.Source, *core lastErr = err 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) if err != nil { _ = videoSrc.Close()