feat(interceptor): add JitterBuffer receiver-side interceptor#84
Open
nightness wants to merge 1 commit intowebrtc-rs:masterfrom
Open
feat(interceptor): add JitterBuffer receiver-side interceptor#84nightness wants to merge 1 commit intowebrtc-rs:masterfrom
nightness wants to merge 1 commit intowebrtc-rs:masterfrom
Conversation
Adds a new `JitterBufferInterceptor` that buffers incoming RTP packets per SSRC and releases them in sequence order after an adaptive playout delay computed from the RFC 3550 §A.8 jitter formula. - `JitterBufferStream` (stream.rs): per-SSRC packet buffer with adaptive target delay; force-release after max_delay to prevent starvation; playout-delay RTP extension (ietf WebRTC draft) for sender-side hints - `JitterBufferInterceptor<P>` (mod.rs): wraps inner chain; buffers RTP for tracked SSRCs, passes RTCP and untracked-SSRC packets immediately; drains ready packets into inner chain in handle_timeout + poll_read - `JitterBufferBuilder`: configurable min/max/initial delay with sensible defaults (20 ms / 500 ms / 50 ms) - Jitter update skips out-of-order RTP timestamps to prevent spurious delay spikes from reordered packets - 15 unit tests across stream.rs and mod.rs; all 129 interceptor tests pass Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
JitterBufferInterceptor— a receiver-side interceptor that buffers incoming RTP packets and releases them in sequence-number order after a playout delayjitter += (d - jitter) / 16.0)wrapping_sub(seq) < 0x8000comparisonsmax_delayto prevent starvationJitterBufferBuilderwith configurablemin_delay(20ms),initial_delay(50ms),max_delay(500ms)Design
In
poll_read: callsstream.pop_ready(now)for all streams, injects ready packets viainner.handle_read(), then returnsinner.poll_read(). This ensures all downstream interceptors see every packet.Test plan
cargo test -p rtc-interceptor jitter_buffercargo test -p rtc-interceptor(all 130+ tests pass)🤖 Generated with Claude Code