Skip to content

Commit

Permalink
sdp: Assign repair stream regardless of attribute order
Browse files Browse the repository at this point in the history
  • Loading branch information
anders-avos committed Aug 26, 2024
1 parent d75c624 commit dc609d6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
17 changes: 7 additions & 10 deletions webrtc/src/peer_connection/sdp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,29 +178,19 @@ 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),
kind: codec_type,
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);
Expand All @@ -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.
Expand Down
9 changes: 5 additions & 4 deletions webrtc/src/peer_connection/sdp/sdp_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand All @@ -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()
},
Expand Down Expand Up @@ -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");
}
Expand Down

0 comments on commit dc609d6

Please sign in to comment.