diff --git a/webrtc/src/peer_connection/sdp/mod.rs b/webrtc/src/peer_connection/sdp/mod.rs index b3c6012a1..1ee813415 100644 --- a/webrtc/src/peer_connection/sdp/mod.rs +++ b/webrtc/src/peer_connection/sdp/mod.rs @@ -178,21 +178,12 @@ pub(crate) fn track_details_from_sdp( } } - let mut repair_ssrc = 0; - for (repair, base) in &rtx_repair_flows { - if *base == ssrc { - repair_ssrc = *repair; - //TODO: no break? - } - } - if track_idx < tracks_in_media_section.len() { tracks_in_media_section[track_idx].mid = SmolStr::from(mid_value); tracks_in_media_section[track_idx].kind = codec_type; stream_id.clone_into(&mut tracks_in_media_section[track_idx].stream_id); track_id.clone_into(&mut tracks_in_media_section[track_idx].id); tracks_in_media_section[track_idx].ssrcs = vec![ssrc]; - tracks_in_media_section[track_idx].repair_ssrc = repair_ssrc; } else { let track_details = TrackDetails { mid: SmolStr::from(mid_value), @@ -200,7 +191,6 @@ pub(crate) fn track_details_from_sdp( stream_id: stream_id.to_owned(), id: track_id.to_owned(), ssrcs: vec![ssrc], - repair_ssrc, ..Default::default() }; tracks_in_media_section.push(track_details); @@ -210,6 +200,13 @@ pub(crate) fn track_details_from_sdp( _ => {} }; } + for (repair, base) in &rtx_repair_flows { + for track in &mut tracks_in_media_section { + if track.ssrcs.contains(base) { + track.repair_ssrc = *repair; + } + } + } // If media line is using RTP Stream Identifier Source Description per RFC8851 // we will need to override tracks, and remove ssrcs. diff --git a/webrtc/src/peer_connection/sdp/sdp_test.rs b/webrtc/src/peer_connection/sdp/sdp_test.rs index 4b86d30e5..abe88319d 100644 --- a/webrtc/src/peer_connection/sdp/sdp_test.rs +++ b/webrtc/src/peer_connection/sdp/sdp_test.rs @@ -364,10 +364,6 @@ fn test_track_details_from_sdp() -> Result<()> { key: "sendrecv".to_owned(), value: None, }, - Attribute { - key: "ssrc-group".to_owned(), - value: Some("FID 3000 4000".to_owned()), - }, Attribute { key: "ssrc".to_owned(), value: Some("3000 msid:video_trk_label video_trk_guid".to_owned()), @@ -376,6 +372,10 @@ fn test_track_details_from_sdp() -> Result<()> { key: "ssrc".to_owned(), value: Some("4000 msid:rtx_trk_label rtx_trck_guid".to_owned()), }, + Attribute { + key: "ssrc-group".to_owned(), + value: Some("FID 3000 4000".to_owned()), + }, ], ..Default::default() }, @@ -441,6 +441,7 @@ fn test_track_details_from_sdp() -> Result<()> { assert_eq!(track.kind, RTPCodecType::Video); assert_eq!(track.ssrcs[0], 3000); assert_eq!(track.stream_id, "video_trk_label"); + assert_eq!(track.repair_ssrc, 4000); } else { panic!("missing video track with ssrc:3000"); }