- Add cache *keyFrameCache field to Source (nil by default). - Add EnableKeyFrameCache() — call before Start() on video sources to activate IDR burst caching. - readLoop: call cache.push(pkt) after each successful unmarshal, before the subscriber fanout. No lock held at push time — push acquires its own mutex internally. - Subscribe: snapshot the cache outside s.mu to avoid any cross-lock complexity, then pre-fill the new channel with the burst before registering it in the subscriber set. Uses a labeled break to stop pre-filling if the channel is full (bufDepth too small for the burst; the subscriber will wait for the next live keyframe instead). |
||
|---|---|---|
| .. | ||
| webrtc | ||