Skip to content

fix(endpoint): route RTX/FEC repair packets to primary stream receiver#75

Open
nightness wants to merge 1 commit intowebrtc-rs:masterfrom
Brainwires:fix/rtx-fec-routing
Open

fix(endpoint): route RTX/FEC repair packets to primary stream receiver#75
nightness wants to merge 1 commit intowebrtc-rs:masterfrom
Brainwires:fix/rtx-fec-routing

Conversation

@nightness
Copy link
Copy Markdown

Summary

Three bugs caused all RTX/FEC repair packets to be silently dropped:

Bug 1 — find_track_id_by_ssrc: outer SSRC search misses repair SSRCs
RTX/FEC SSRCs live in coding.rtx.ssrc / coding.fec.ssrc, not coding.ssrc. The outer transceiver search only checked coding.ssrc, so any packet with an RTX or FEC SSRC fell through to None and was dropped. Fix: extend the .any() predicate to also check rtx/fec SSRCs. When a match is found via repair SSRC, the packet is routed to the primary stream's receiver immediately without firing OnOpen events.

Bug 2 — find_track_id_by_rid (rrid branch): always returned None
The rrid header extension identifies a repair packet for a base stream identified by rid. The code correctly updated coding.rtx.ssrc = ssrc, but then fell through to None instead of returning the primary stream's track_id. Every RTX packet carrying rrid was dropped. Fix: add return Some(receiver.track().track_id().clone()) after the SSRC update.

Bug 3 — handle_undeclared_ssrc: RTX codec matched as primary
RTX codec entries are included in get_codec_preferences() (added during SDP negotiation). If an RTX packet arrived first in the single-section non-rid path, the codec lookup would find the RTX codec and incorrectly set it up as the primary track's codec. Fix: exclude RTX mime-type codecs from the lookup so only primary codecs are accepted.

Test plan

  • cargo test -p rtc — all 246 tests pass
  • Integration: send a VP8 stream with RTX enabled; verify retransmitted packets are received by the media pipeline rather than dropped
  • Verify OnOpen is not fired for RTX SSRC sub-streams

🤖 Generated with Claude Code

Three bugs caused all RTX/FEC repair packets to be silently dropped:

1. find_track_id_by_ssrc: outer SSRC search only matched primary SSRCs
   (coding.ssrc). RTX/FEC SSRCs live in coding.rtx.ssrc / coding.fec.ssrc
   and were never found. Fix: extend the .any() predicate to also check
   rtx/fec SSRCs; when matched via repair SSRC, return the primary
   stream's track_id immediately without triggering OnOpen events.

2. find_track_id_by_rid (rrid branch): after correctly associating the
   repair SSRC with the base stream's RTX parameters, the function fell
   through to None instead of returning Some(track_id). RTX packets with
   the rrid header extension were always dropped on every packet.

3. handle_undeclared_ssrc: codec lookup could match the RTX codec entry
   (which IS in codec_preferences) and incorrectly set up a repair stream
   as a primary track. Fix: explicitly exclude RTX codecs so only primary
   codecs are accepted here.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@nightness nightness force-pushed the fix/rtx-fec-routing branch from 9b00c53 to 71e8f84 Compare April 1, 2026 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant