From 2b4b96bb2a1ed3c9d2574bffcf7e0ac944544145 Mon Sep 17 00:00:00 2001 From: nightness Date: Wed, 1 Apr 2026 06:14:39 -0500 Subject: [PATCH] fix(rtp): associate repair SSRC with base stream RTX parameters (closes #12) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implements rrid (urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id) handling, resolving webrtc-rs/rtc#12. rrid is already parsed from RTP header extensions and the URI is registered — the handler body was a TODO stub. When an RTP packet carries rrid, it is a repair/RTX stream for the base stream identified by that rrid value (= the base stream's rid). Map the repair SSRC into the base stream's coding parameters' RTX field so downstream routing and stats can correlate the repair stream with its source stream. Co-Authored-By: Claude Sonnet 4.6 --- rtc/src/peer_connection/handler/endpoint.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/rtc/src/peer_connection/handler/endpoint.rs b/rtc/src/peer_connection/handler/endpoint.rs index 33fff14..0781f32 100644 --- a/rtc/src/peer_connection/handler/endpoint.rs +++ b/rtc/src/peer_connection/handler/endpoint.rs @@ -11,7 +11,9 @@ use crate::media_stream::track::MediaStreamTrackId; use crate::peer_connection::configuration::media_engine::MediaEngine; use crate::peer_connection::event::track_event::{RTCTrackEvent, RTCTrackEventInit}; use crate::rtp_transceiver::rtp_receiver::internal::RTCRtpReceiverInternal; -use crate::rtp_transceiver::rtp_sender::{RTCRtpCodingParameters, RTCRtpHeaderExtensionCapability}; +use crate::rtp_transceiver::rtp_sender::{ + RTCRtpCodingParameters, RTCRtpHeaderExtensionCapability, RTCRtpRtxParameters, +}; use crate::rtp_transceiver::{RTCRtpReceiverId, SSRC, internal::RTCRtpTransceiverInternal}; use crate::statistics::accumulator::RTCStatsAccumulator; use interceptor::{Interceptor, Packet}; @@ -448,7 +450,14 @@ where .cloned() { if !rrid.is_empty() { - //TODO: Add support of handling repair rtp stream id (rrid) #12 + // rrid identifies the base stream (rid) that this repair/RTX packet belongs to. + // Associate the repair SSRC with the base stream's RTX parameters. + if let Some(coding) = receiver.get_coding_parameter_mut_by_rid(rrid.as_str()) { + match coding.rtx.as_mut() { + Some(rtx) => rtx.ssrc = ssrc, + None => coding.rtx = Some(RTCRtpRtxParameters { ssrc }), + } + } } else { if let Some(coding) = receiver.get_coding_parameter_mut_by_rid(rid.as_str()) { coding.ssrc = Some(ssrc);