fix(rtcp): re-latch RxStats on a mid-call SSRC change - #165
Merged
Conversation
RxStats latched the first remote SSRC and never updated it, so a mid-call SSRC change (re-INVITE, hold/resume, a device swap) kept folding the new stream into the previous source's RFC 3550 A.1/A.3/A.8 accounting — silently corrupting loss/jitter/MOS/RTT for the rest of the call. Detect an SSRC change and reset the per-source accounting so the new SSRC is treated as a fresh stream. A two-sighting guard (the new SSRC must repeat on consecutive packets before the switch commits) keeps a single stray, reordered, or spoofed packet from wiping the accounting; the first sighting is not counted. Tests: a lone stray-SSRC packet is ignored and the source stays latched; a repeated new SSRC relatches and discards the old source's loss/SR state. Co-Authored-By: Claude Opus 4.8 (1M context) <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.
Re-latch RTCP receiver accounting when the peer's SSRC changes mid-call
RxStatslatched the first remote SSRC and never updated it. If the peer's synchronization source changed during a call, every subsequent packet was folded into the previous source's RFC 3550 A.1/A.3/A.8 accounting — silently corrupting loss / jitter / MOS / RTT for the rest of the call.This bites hardest on PSTN, where the media SSRC changes with no signalling as the call routes across endpoints — e.g. early media, then onto voicemail — sometimes with no re-INVITE at all.
Change
Scope
bad_seqpath.Tests
single_stray_ssrc_packet_does_not_relatch— a lone different-SSRC packet is ignored and the source stays latched.repeated_new_ssrc_relatches_and_resets_accounting— a repeated new SSRC relatches and discards the old source's loss/SR state.cargo test --lib117 passing; clippy--all-targets+ rustfmt clean.🤖 Generated with Claude Code