Introduces keyFrameCache — a bounded ring buffer that retains all RTP packets from the most recent H.264 IDR NAL unit until the packet just before the next one. New WHEP subscribers receive this burst immediately on Subscribe(), cutting first-frame latency from up to one IDR interval (typically ~2 s at GOP=60/30fps) to nearly zero. Design notes: - Detection covers single-NAL (type 5) and FU-A start (type 28, start bit set, inner type 5). STAP-A IDR leading is not handled — FFmpeg never uses STAP-A for IDR slices in practice. - Bounded at 512 packets / 2 MiB per source to cap memory per stream. - push() is called only from the single-goroutine readLoop; the lock it holds is tiny and brief. - snapshot() returns a shallow copy; *rtp.Packet values are immutable after being placed in the cache so sharing is safe. |
||
|---|---|---|
| .. | ||
| webrtc | ||