Skip to content

Commit

Permalink
fixup! Add simulcast send support
Browse files Browse the repository at this point in the history
  • Loading branch information
kc5nra committed Jan 8, 2025
1 parent f7f3235 commit 8c83b27
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
23 changes: 17 additions & 6 deletions src/change/sdp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,22 @@ impl<'a> SdpApi<'a> {
};

let mut ssrcs = Vec::new();
if simulcast.is_none() {
let rtx = kind.is_video().then(|| self.rtc.session.streams.new_ssrc());
ssrcs.push((self.rtc.session.streams.new_ssrc(), rtx));

let ssrc_group_count = if let Some(simulcast) = &simulcast {
if simulcast.force_ssrc_groups && dir.is_sending() {
simulcast.send.len()
} else {
0usize
}
} else {
1usize
};

if ssrc_group_count > 0 {
for _ in 0..ssrc_group_count {
let rtx = kind.is_video().then(|| self.rtc.session.streams.new_ssrc());
ssrcs.push((self.rtc.session.streams.new_ssrc(), rtx));
}
}

// TODO: let user configure stream/track name.
Expand Down Expand Up @@ -1304,16 +1317,14 @@ impl AsSdpMediaLine for Media {

let count = ssrcs_tx.len();
#[allow(clippy::comparison_chain)]
if count == 1 {
for _ in 0..count {
let (ssrc, ssrc_rtx) = &ssrcs_tx[0];
if let Some(ssrc_rtx) = ssrc_rtx {
attrs.push(MediaAttribute::SsrcGroup {
semantics: "FID".to_string(),
ssrcs: vec![*ssrc, *ssrc_rtx],
});
}
} else {
// TODO: handle simulcast
}

MediaLine {
Expand Down
8 changes: 7 additions & 1 deletion src/media/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ impl From<SdpSimulcast> for Simulcast {
let send = s.send.iter().map(|r| r.0.as_ref()).map(Rid::from).collect();
let recv = s.recv.iter().map(|r| r.0.as_ref()).map(Rid::from).collect();

Simulcast { send, recv }
Simulcast {
send,
recv,
force_ssrc_groups: false,
}
}
}

Expand Down Expand Up @@ -65,6 +69,8 @@ pub struct Simulcast {
pub send: Vec<Rid>,
/// The RID used for receiving simulcast.
pub recv: Vec<Rid>,
/// Force ssrc-group creation (Firefox-style)
pub force_ssrc_groups: bool,
}

impl Simulcast {
Expand Down

0 comments on commit 8c83b27

Please sign in to comment.