Skip to content

Commit

Permalink
fix: serialize all rtp, rtcp_fb and fmtp entrys
Browse files Browse the repository at this point in the history
  • Loading branch information
hoodie committed Jan 17, 2022
1 parent c0ffeeb commit c0ffeea
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 5 deletions.
8 changes: 8 additions & 0 deletions src/attributes/rtpmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,14 @@ fn test_rtpmap_line() {
assert_line_print!(rtpmap_line, "a=rtpmap:127 red/90000");
assert_line_print!(rtpmap_line, "a=rtpmap:123 rtx/90000");
assert_line_print!(rtpmap_line, "a=rtpmap:125 ulpfec/90000");
assert_line!(rtpmap_line, "a=rtpmap:122 red/90000",
RtpMap {
payload: 122,
encoding_name: "red".into(),
clock_rate: Some(90_000),
encoding: None,
}
,print);
assert_line!(
rtpmap_line,
"a=rtpmap:113 telephone-event/16000",
Expand Down
3 changes: 2 additions & 1 deletion src/lines/media.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use crate::parsers::*;
#[cfg(test)]
use crate::{assert_line, assert_line_print};

/// [RFC4566#5.14](https://datatracker.ietf.org/doc/html/rfc4566#section-5.14)
#[derive(Clone, IntoOwned, PartialEq)]
#[cfg_attr(feature = "debug", derive(Debug))]
#[cfg_attr(
Expand All @@ -31,7 +32,7 @@ pub fn media_line(input: &str) -> IResult<&str, Media> {
wsf(cowify(read_string)), // type
wsf(read_number), // port
wsf(slash_separated_cow_strings), // protocol
wsf(read_as_cow_strings), //payloads
wsf(read_as_cow_strings), // payloads
)),
|(r#type, port, protocol, payloads)| Media {
r#type,
Expand Down
37 changes: 33 additions & 4 deletions src/udisplay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,43 @@ impl ufmt::uDisplay for MediaSection<'_> {
uwriteln!(f, "{}", rtcp_option)?;
}

for payload in self.payloads.iter().filter_map(|p| p.parse::<u32>().ok()) {
for rtp in self.rtp_map.iter().filter(|r| r.payload == payload) {
let known_payloads = self
.payloads
.iter()
.filter_map(|p| p.parse::<u32>().ok())
.collect::<Vec<_>>();

for payload in &known_payloads {
for rtp in self.rtp_map.iter().filter(|r| r.payload == *payload) {
uwriteln!(f, "{}", rtp)?;
}
for rtcp_fb in self.rtcp_fb.iter().filter(|r| r.payload == payload) {
for rtcp_fb in self.rtcp_fb.iter().filter(|r| r.payload == *payload) {
uwriteln!(f, "{}", rtcp_fb)?;
}
for fmtp in self.fmtp.iter().filter(|r| r.payload == payload) {
for fmtp in self.fmtp.iter().filter(|r| r.payload == *payload) {
uwriteln!(f, "{}", fmtp)?;
}
} // one more round for those not listed in the fmt field
{
for rtp in self
.rtp_map
.iter()
.filter(|r| !known_payloads.contains(&r.payload))
{
uwriteln!(f, "{}", rtp)?;
}
for rtcp_fb in self
.rtcp_fb
.iter()
.filter(|r| !known_payloads.contains(&r.payload))
{
uwriteln!(f, "{}", rtcp_fb)?;
}
for fmtp in self
.fmtp
.iter()
.filter(|r| !known_payloads.contains(&r.payload))
{
uwriteln!(f, "{}", fmtp)?;
}
}
Expand Down

0 comments on commit c0ffeea

Please sign in to comment.