Skip to content

Commit

Permalink
Fix ssrc-group implementation needed for video calls
Browse files Browse the repository at this point in the history
  • Loading branch information
tmolitor-stud-tu committed Jan 12, 2024
1 parent e5e572e commit 570bb12
Showing 1 changed file with 41 additions and 9 deletions.
50 changes: 41 additions & 9 deletions rust/sdp-to-jingle/src/xep_0339.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub struct JingleSsrcGroup {
#[serde(rename = "@semantics")]
semantics: SsrcGroupSemantics,
#[serde(rename = "source", skip_serializing_if = "Vec::is_empty")]
sources: Vec<u32>,
sources: Vec<JingleSsrcGroupSourceEnum>,
}

impl JingleSsrcGroup {
Expand All @@ -72,9 +72,9 @@ impl JingleSsrcGroup {
SdpSsrcGroupSemantic::ForwardErrorCorrectionFr => SsrcGroupSemantics::FecFr,
SdpSsrcGroupSemantic::Sim => SsrcGroupSemantics::Sim,
};
let mut sources_vec: Vec<u32> = Vec::new();
let mut sources_vec: Vec<JingleSsrcGroupSourceEnum> = Vec::new();
for ssrc in sources {
sources_vec.push(ssrc.id);
sources_vec.push(JingleSsrcGroupSourceEnum::Source(JingleSsrcGroupSource::new_from_sdp(ssrc)));
}
Self {
xmlns: "urn:xmpp:jingle:apps:rtp:ssma:0".to_string(),
Expand All @@ -92,12 +92,11 @@ impl JingleSsrcGroup {
SsrcGroupSemantics::Sim => SdpSsrcGroupSemantic::Sim,
};
let mut sources_vec: Vec<SdpAttributeSsrc> = Vec::new();
for id in &self.sources {
sources_vec.push(SdpAttributeSsrc {
id: *id,
attribute: None,
value: None,
});
for ssrc in &self.sources {
match ssrc {
JingleSsrcGroupSourceEnum::Source(src) => { sources_vec.push(src.to_sdp()); }
JingleSsrcGroupSourceEnum::Invalid => {}
};
}
(semantics, sources_vec)
}
Expand All @@ -114,3 +113,36 @@ pub enum SsrcGroupSemantics {
FecFr,
Sim, //not defined in the IANA registry?? see https://www.iana.org/assignments/sdp-parameters/sdp-parameters.xhtml#sdp-parameters-17
}

// *** xep-0339
#[derive(Serialize, Deserialize, Clone)]
#[serde(rename_all = "lowercase")]
pub enum JingleSsrcGroupSourceEnum {
Source(JingleSsrcGroupSource),
#[serde(other)]
Invalid,
}

// *** xep-0339
#[derive(Serialize, Deserialize, Clone)]
pub struct JingleSsrcGroupSource {
#[serde(rename = "@ssrc")]
id: u32,
}

impl JingleSsrcGroupSource {
pub fn new_from_sdp(ssrc: &SdpAttributeSsrc) -> Self {
Self {
id: ssrc.id,
}
}

pub fn to_sdp(&self) -> SdpAttributeSsrc {
SdpAttributeSsrc {
id: self.id,
attribute: None,
value: None,
}
}
}

0 comments on commit 570bb12

Please sign in to comment.