From 089fb906cdb72355b65bd3c1c4a4c9eeabd9a2f9 Mon Sep 17 00:00:00 2001 From: cloudwebrtc Date: Mon, 29 Jun 2026 10:58:06 +0800 Subject: [PATCH] set limit for maxVideoFrameCacheDuration to 2s. --- pkg/sfu/receiver.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pkg/sfu/receiver.go b/pkg/sfu/receiver.go index a3aa2722d..47427ea69 100644 --- a/pkg/sfu/receiver.go +++ b/pkg/sfu/receiver.go @@ -93,8 +93,22 @@ func WithForwardStats(forwardStats *ForwardStats) ReceiverOpts { } } +// maxVideoFrameCacheDuration caps the video frame cache window: a longer cached interval would size +// the retransmit bucket too aggressively and delay subscriber bootstrap, so requests above it are +// clamped down. +const maxVideoFrameCacheDuration = 2 * time.Second + func WithVideoFrameCache(maxDuration time.Duration) ReceiverOpts { return func(w *WebRTCReceiver) *WebRTCReceiver { + if maxDuration > maxVideoFrameCacheDuration { + w.ReceiverBase.Logger().Infow( + "clamping video frame cache duration", + "requested", maxDuration, + "max", maxVideoFrameCacheDuration, + ) + maxDuration = maxVideoFrameCacheDuration + } + w.ReceiverBase.EnableVideoFrameCache(maxDuration) return w }