Bug 1875184 - vendor webrtc-sdp 0.3.11;r=mjf,supply-chain-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D198894
This commit is contained in:
Nico Grunbaum 2024-01-23 18:38:23 +00:00
parent f444c4b1b3
commit d2e23c69f4
15 changed files with 175 additions and 236 deletions

4
Cargo.lock generated
View file

@ -6386,9 +6386,9 @@ dependencies = [
[[package]] [[package]]
name = "webrtc-sdp" name = "webrtc-sdp"
version = "0.3.10" version = "0.3.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b27cfe685c697666a76932399d55026bf2a5a205d91d277fd16346f0c65a7c06" checksum = "c7351fba122c7f6566779efdef49d2213e842f69fa1c654eef1fd9301f425064"
dependencies = [ dependencies = [
"log", "log",
"url", "url",

View file

@ -4286,6 +4286,11 @@ who = "Byron Campen <docfaraday@gmail.com>"
criteria = "safe-to-deploy" criteria = "safe-to-deploy"
delta = "0.3.9 -> 0.3.10" delta = "0.3.9 -> 0.3.10"
[[audits.webrtc-sdp]]
who = "Nicolas Grunbaum <ngrunbaum@mozilla.com>"
criteria = "safe-to-deploy"
delta = "0.3.10 -> 0.3.11"
[[audits.weedle2]] [[audits.weedle2]]
who = "Travis Long <tlong@mozilla.com>" who = "Travis Long <tlong@mozilla.com>"
criteria = "safe-to-deploy" criteria = "safe-to-deploy"

File diff suppressed because one or more lines are too long

View file

@ -1,4 +1,6 @@
# Changelog # Changelog
## [0.3.11] - 2024-01-17
- Permit a wider set of payload type numbers
## [0.3.10] - 2023-01-05 ## [0.3.10] - 2023-01-05
- Permit inconsistent simulcast directions - Permit inconsistent simulcast directions
## [0.3.9] - 2022-01-12 ## [0.3.9] - 2022-01-12

View file

@ -2,95 +2,78 @@
# It is not intended for manual editing. # It is not intended for manual editing.
version = 3 version = 3
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]] [[package]]
name = "form_urlencoded" name = "form_urlencoded"
version = "1.0.1" version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652"
dependencies = [ dependencies = [
"matches",
"percent-encoding", "percent-encoding",
] ]
[[package]] [[package]]
name = "idna" name = "idna"
version = "0.2.3" version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c"
dependencies = [ dependencies = [
"matches",
"unicode-bidi", "unicode-bidi",
"unicode-normalization", "unicode-normalization",
] ]
[[package]] [[package]]
name = "itoa" name = "itoa"
version = "1.0.1" version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38"
[[package]] [[package]]
name = "log" name = "log"
version = "0.4.14" version = "0.4.19"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4"
dependencies = [
"cfg-if",
]
[[package]]
name = "matches"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f"
[[package]] [[package]]
name = "percent-encoding" name = "percent-encoding"
version = "2.1.0" version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94"
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.36" version = "1.0.66"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029" checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9"
dependencies = [ dependencies = [
"unicode-xid", "unicode-ident",
] ]
[[package]] [[package]]
name = "quote" name = "quote"
version = "1.0.14" version = "1.0.31"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "47aa80447ce4daf1717500037052af176af5d38cc3e571d9ec1c7353fc10c87d" checksum = "5fe8a65d69dd0808184ebb5f836ab526bb259db23c657efa38711b1072ee47f0"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
] ]
[[package]] [[package]]
name = "ryu" name = "ryu"
version = "1.0.9" version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741"
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.133" version = "1.0.173"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97565067517b60e2d1ea8b268e59ce036de907ac523ad83a0475da04e818989a" checksum = "e91f70896d6720bc714a4a57d22fc91f1db634680e65c8efe13323f1fa38d53f"
[[package]] [[package]]
name = "serde_derive" name = "serde_derive"
version = "1.0.133" version = "1.0.173"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed201699328568d8d08208fdd080e3ff594e6c422e438b6705905da01005d537" checksum = "a6250dde8342e0232232be9ca3db7aa40aceb5a3e5dd9bddbc00d99a007cde49"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -99,9 +82,9 @@ dependencies = [
[[package]] [[package]]
name = "serde_json" name = "serde_json"
version = "1.0.74" version = "1.0.103"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee2bb9cd061c5865d345bb02ca49fcef1391741b672b54a0bf7b679badec3142" checksum = "d03b412469450d4404fe8499a268edd7f8b79fecb074b0d812ad64ca21f4031b"
dependencies = [ dependencies = [
"itoa", "itoa",
"ryu", "ryu",
@ -110,66 +93,65 @@ dependencies = [
[[package]] [[package]]
name = "syn" name = "syn"
version = "1.0.85" version = "2.0.26"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a684ac3dcd8913827e18cd09a68384ee66c1de24157e3c556c9ab16d85695fb7" checksum = "45c3457aacde3c65315de5031ec191ce46604304d2446e803d71ade03308d970"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"unicode-xid", "unicode-ident",
] ]
[[package]] [[package]]
name = "tinyvec" name = "tinyvec"
version = "1.5.1" version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c1c1d5a42b6245520c249549ec267180beaffcc0615401ac8e31853d4b6d8d2" checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50"
dependencies = [ dependencies = [
"tinyvec_macros", "tinyvec_macros",
] ]
[[package]] [[package]]
name = "tinyvec_macros" name = "tinyvec_macros"
version = "0.1.0" version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]] [[package]]
name = "unicode-bidi" name = "unicode-bidi"
version = "0.3.7" version = "0.3.13"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a01404663e3db436ed2746d9fefef640d868edae3cceb81c3b8d5732fda678f" checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460"
[[package]]
name = "unicode-ident"
version = "1.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c"
[[package]] [[package]]
name = "unicode-normalization" name = "unicode-normalization"
version = "0.1.19" version = "0.1.22"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d54590932941a9e9266f0832deed84ebe1bf2e4c9e4a3554d393d18f5e854bf9" checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921"
dependencies = [ dependencies = [
"tinyvec", "tinyvec",
] ]
[[package]]
name = "unicode-xid"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
[[package]] [[package]]
name = "url" name = "url"
version = "2.2.2" version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c" checksum = "50bff7831e19200a85b17131d085c25d7811bc4e186efdaf54bbd132994a88cb"
dependencies = [ dependencies = [
"form_urlencoded", "form_urlencoded",
"idna", "idna",
"matches",
"percent-encoding", "percent-encoding",
] ]
[[package]] [[package]]
name = "webrtc-sdp" name = "webrtc-sdp"
version = "0.3.10" version = "0.3.11"
dependencies = [ dependencies = [
"log", "log",
"serde", "serde",

View file

@ -11,7 +11,7 @@
[package] [package]
name = "webrtc-sdp" name = "webrtc-sdp"
version = "0.3.10" version = "0.3.11"
authors = [ authors = [
"Nicolas Grunbaum <na-g+github@nostrum.com>", "Nicolas Grunbaum <na-g+github@nostrum.com>",
"Nils Ohlmeier <github@ohlmeier.org>", "Nils Ohlmeier <github@ohlmeier.org>",

View file

@ -10,7 +10,7 @@ A SDP parser written in Rust specifically aimed to handle WebRTC SDP offers and
## Dependecies ## Dependecies
* Rust >= 1.45.0 * Rust >= 1.60.0
* log module * log module
* serde module * serde module
* serde-derive module * serde-derive module

View file

@ -25,7 +25,7 @@ fn main() {
let path = Path::new(filename.as_str()); let path = Path::new(filename.as_str());
let display = path.display(); let display = path.display();
let mut file = match File::open(&path) { let mut file = match File::open(path) {
Err(why) => panic!("Failed to open {}: {}", display, why), Err(why) => panic!("Failed to open {}: {}", display, why),
Ok(file) => file, Ok(file) => file,
}; };
@ -61,7 +61,7 @@ fn main() {
let res = webrtc_sdp::parse_sdp(&s, true); let res = webrtc_sdp::parse_sdp(&s, true);
match res { match res {
Err(why) => panic!("Failed to parse SDP with error: {}", why), Err(why) => panic!("Failed to parse SDP with error: {}", why),
Ok(sdp) => println!("Parsed SDP structure:\n{:#?}", sdp), Ok(sdp) => println!("Parsed SDP structure:\n{sdp:#?}"),
} }
if expect_failure { if expect_failure {

View file

@ -221,7 +221,7 @@ impl fmt::Display for SdpAttributeCandidate {
unknown = self unknown = self
.unknown_extensions .unknown_extensions
.iter() .iter()
.map(|&(ref name, ref value)| format!(" {} {}", name, value)) .map(|(name, value)| format!(" {name} {value}"))
.collect::<String>() .collect::<String>()
) )
} }
@ -308,9 +308,9 @@ pub enum SdpAttributeDtlsMessage {
impl fmt::Display for SdpAttributeDtlsMessage { impl fmt::Display for SdpAttributeDtlsMessage {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self { match self {
SdpAttributeDtlsMessage::Client(ref msg) => format!("client {}", msg), SdpAttributeDtlsMessage::Client(msg) => format!("client {msg}"),
SdpAttributeDtlsMessage::Server(ref msg) => format!("server {}", msg), SdpAttributeDtlsMessage::Server(msg) => format!("server {msg}"),
} }
.fmt(f) .fmt(f)
} }
@ -622,7 +622,7 @@ impl fmt::Display for SdpAttributeFmtpParameters {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
if let Some(ref rtx) = self.rtx { if let Some(ref rtx) = self.rtx {
// rtx // rtx
return write!(f, "{}", rtx); return write!(f, "{rtx}");
} }
if !self.dtmf_tones.is_empty() { if !self.dtmf_tones.is_empty() {
// telephone-event // telephone-event
@ -713,8 +713,7 @@ impl SdpAttributeFingerprintHashType {
"sha-384" => Ok(Self::Sha384), "sha-384" => Ok(Self::Sha384),
"sha-512" => Ok(Self::Sha512), "sha-512" => Ok(Self::Sha512),
unknown => Err(SdpParserInternalError::Unsupported(format!( unknown => Err(SdpParserInternalError::Unsupported(format!(
"fingerprint contains an unsupported hash algorithm '{}'", "fingerprint contains an unsupported hash algorithm '{unknown}'"
unknown
))), ))),
} }
} }
@ -786,8 +785,7 @@ impl TryFrom<(SdpAttributeFingerprintHashType, Vec<u8>)> for SdpAttributeFingerp
fingerprint, fingerprint,
}), }),
(a, b) => Err(SdpParserInternalError::Generic(format!( (a, b) => Err(SdpParserInternalError::Generic(format!(
"Hash algoritm expects {} fingerprint bytes not {}", "Hash algoritm expects {a} fingerprint bytes not {b}",
a, b
))), ))),
} }
} }
@ -802,7 +800,7 @@ impl fmt::Display for SdpAttributeFingerprint {
fp = self fp = self
.fingerprint .fingerprint
.iter() .iter()
.map(|byte| format!("{:02X}", byte)) .map(|byte| format!("{byte:02X}"))
.collect::<Vec<String>>() .collect::<Vec<String>>()
.join(":") .join(":")
) )
@ -846,11 +844,11 @@ impl fmt::Display for SdpAttributeImageAttrXyRange {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self { match *self {
SdpAttributeImageAttrXyRange::Range(ref min, ref max, ref step_opt) => { SdpAttributeImageAttrXyRange::Range(ref min, ref max, ref step_opt) => {
write!(f, "[{}:", min)?; write!(f, "[{min}:")?;
if step_opt.is_some() { if step_opt.is_some() {
write!(f, "{}:", step_opt.unwrap())?; write!(f, "{}:", step_opt.unwrap())?;
} }
write!(f, "{}]", max) write!(f, "{max}]")
} }
SdpAttributeImageAttrXyRange::DiscreteValues(ref values) => { SdpAttributeImageAttrXyRange::DiscreteValues(ref values) => {
write!(f, "{}", imageattr_discrete_value_list_to_string(values)) write!(f, "{}", imageattr_discrete_value_list_to_string(values))
@ -868,9 +866,9 @@ pub enum SdpAttributeImageAttrSRange {
impl fmt::Display for SdpAttributeImageAttrSRange { impl fmt::Display for SdpAttributeImageAttrSRange {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self { match self {
SdpAttributeImageAttrSRange::Range(ref min, ref max) => write!(f, "[{}-{}]", min, max), SdpAttributeImageAttrSRange::Range(min, max) => write!(f, "[{min}-{max}]"),
SdpAttributeImageAttrSRange::DiscreteValues(ref values) => { SdpAttributeImageAttrSRange::DiscreteValues(values) => {
write!(f, "{}", imageattr_discrete_value_list_to_string(values)) write!(f, "{}", imageattr_discrete_value_list_to_string(values))
} }
} }
@ -1110,7 +1108,7 @@ impl fmt::Display for SdpAttributeRid {
.as_str() .as_str()
{ {
"" => "".to_string(), "" => "".to_string(),
x => format!(" {}", x), x => format!(" {x}"),
} }
) )
} }
@ -1195,7 +1193,7 @@ impl SdpAttributeSsrc {
} }
fn set_attribute(&mut self, a: &str) { fn set_attribute(&mut self, a: &str) {
if a.find(':') == None { if a.find(':').is_none() {
self.attribute = Some(a.to_string()); self.attribute = Some(a.to_string());
} else { } else {
let v: Vec<&str> = a.splitn(2, ':').collect(); let v: Vec<&str> = a.splitn(2, ':').collect();
@ -1415,8 +1413,7 @@ impl FromStr for SdpAttribute {
| "ice-mismatch" | "inactive" | "recvonly" | "rtcp-mux" | "rtcp-mux-only" | "ice-mismatch" | "inactive" | "recvonly" | "rtcp-mux" | "rtcp-mux-only"
| "rtcp-rsize" | "sendonly" | "sendrecv" => { | "rtcp-rsize" | "sendonly" | "sendrecv" => {
return Err(SdpParserInternalError::Generic(format!( return Err(SdpParserInternalError::Generic(format!(
"{} attribute is not allowed to have a value", "{name} attribute is not allowed to have a value",
name
))); )));
} }
_ => (), _ => (),
@ -1466,8 +1463,7 @@ impl FromStr for SdpAttribute {
"simulcast" => parse_simulcast(val), "simulcast" => parse_simulcast(val),
"ssrc" => parse_ssrc(val), "ssrc" => parse_ssrc(val),
_ => Err(SdpParserInternalError::Unsupported(format!( _ => Err(SdpParserInternalError::Unsupported(format!(
"Unknown attribute type {}", "Unknown attribute type {name}",
name
))), ))),
} }
} }
@ -1710,8 +1706,7 @@ fn parse_single_direction(to_parse: &str) -> Result<SdpSingleDirection, SdpParse
"send" => Ok(SdpSingleDirection::Send), "send" => Ok(SdpSingleDirection::Send),
"recv" => Ok(SdpSingleDirection::Recv), "recv" => Ok(SdpSingleDirection::Recv),
x => Err(SdpParserInternalError::Generic(format!( x => Err(SdpParserInternalError::Generic(format!(
"Unknown direction description found: '{:}'", "Unknown direction description found: '{x:}'"
x
))), ))),
} }
} }
@ -1736,8 +1731,7 @@ fn parse_ssrc_group(to_parse: &str) -> Result<SdpAttribute, SdpParserInternalErr
"SIM" => SdpSsrcGroupSemantic::Sim, "SIM" => SdpSsrcGroupSemantic::Sim,
unknown => { unknown => {
return Err(SdpParserInternalError::Unsupported(format!( return Err(SdpParserInternalError::Unsupported(format!(
"Unknown ssrc semantic '{:?}' found", "Unknown ssrc semantic '{unknown:?}' found"
unknown
))); )));
} }
}, },
@ -1773,8 +1767,7 @@ fn parse_sctp_port(to_parse: &str) -> Result<SdpAttribute, SdpParserInternalErro
let port = to_parse.parse()?; let port = to_parse.parse()?;
if port > 65535 { if port > 65535 {
return Err(SdpParserInternalError::Generic(format!( return Err(SdpParserInternalError::Generic(format!(
"Sctpport port {} can only be a bit 16bit number", "Sctpport port {port} can only be a bit 16bit number"
port
))); )));
} }
Ok(SdpAttribute::SctpPort(port)) Ok(SdpAttribute::SctpPort(port))
@ -1948,8 +1941,7 @@ fn parse_dtls_message(to_parse: &str) -> Result<SdpAttribute, SdpParserInternalE
"server" => SdpAttributeDtlsMessage::Server(tokens[1].to_string()), "server" => SdpAttributeDtlsMessage::Server(tokens[1].to_string()),
e => { e => {
return Err(SdpParserInternalError::Generic(format!( return Err(SdpParserInternalError::Generic(format!(
"dtls-message has unknown role token '{}'", "dtls-message has unknown role token '{e}'"
e
))); )));
} }
})) }))
@ -1991,7 +1983,7 @@ fn parse_extmap(to_parse: &str) -> Result<SdpAttribute, SdpParserInternalError>
} }
let id: u16; let id: u16;
let mut direction: Option<SdpAttributeDirection> = None; let mut direction: Option<SdpAttributeDirection> = None;
if tokens[0].find('/') == None { if tokens[0].find('/').is_none() {
id = tokens[0].parse::<u16>()?; id = tokens[0].parse::<u16>()?;
} else { } else {
let id_dir: Vec<&str> = tokens[0].splitn(2, '/').collect(); let id_dir: Vec<&str> = tokens[0].splitn(2, '/').collect();
@ -2121,8 +2113,7 @@ fn parse_fmtp(to_parse: &str) -> Result<SdpAttribute, SdpParserInternalError> {
0 => Ok(false), 0 => Ok(false),
1 => Ok(true), 1 => Ok(true),
_ => Err(SdpParserInternalError::Generic(format!( _ => Err(SdpParserInternalError::Generic(format!(
"The fmtp parameter '{:}' must be 0 or 1", "The fmtp parameter '{param_name:}' must be 0 or 1"
param_name
))), ))),
} }
}; };
@ -2300,8 +2291,7 @@ fn parse_group(to_parse: &str) -> Result<SdpAttribute, SdpParserInternalError> {
"BUNDLE" => SdpAttributeGroupSemantic::Bundle, "BUNDLE" => SdpAttributeGroupSemantic::Bundle,
unknown => { unknown => {
return Err(SdpParserInternalError::Unsupported(format!( return Err(SdpParserInternalError::Unsupported(format!(
"Unknown group semantic '{:?}' found", "Unknown group semantic '{unknown:?}' found",
unknown
))); )));
} }
}, },
@ -3052,8 +3042,7 @@ fn parse_rtcp_fb(to_parse: &str) -> Result<SdpAttribute, SdpParserInternalError>
"transport-cc" => SdpAttributeRtcpFbType::TransCc, "transport-cc" => SdpAttributeRtcpFbType::TransCc,
_ => { _ => {
return Err(SdpParserInternalError::Unsupported(format!( return Err(SdpParserInternalError::Unsupported(format!(
"Unknown rtcpfb feedback type: {:?}", "Unknown rtcpfb feedback type: {x:?}"
x
))); )));
} }
}, },
@ -3071,8 +3060,7 @@ fn parse_rtcp_fb(to_parse: &str) -> Result<SdpAttribute, SdpParserInternalError>
"rpsi" | "app" => (*x).to_string(), "rpsi" | "app" => (*x).to_string(),
_ => { _ => {
return Err(SdpParserInternalError::Unsupported(format!( return Err(SdpParserInternalError::Unsupported(format!(
"Unknown rtcpfb ack parameter: {:?}", "Unknown rtcpfb ack parameter: {x:?}"
x
))); )));
} }
}, },
@ -3087,8 +3075,7 @@ fn parse_rtcp_fb(to_parse: &str) -> Result<SdpAttribute, SdpParserInternalError>
"fir" | "tmmbr" | "tstr" | "vbcm" => (*x).to_string(), "fir" | "tmmbr" | "tstr" | "vbcm" => (*x).to_string(),
_ => { _ => {
return Err(SdpParserInternalError::Unsupported(format!( return Err(SdpParserInternalError::Unsupported(format!(
"Unknown rtcpfb ccm parameter: {:?}", "Unknown rtcpfb ccm parameter: {x:?}"
x
))); )));
} }
}, },
@ -3099,8 +3086,7 @@ fn parse_rtcp_fb(to_parse: &str) -> Result<SdpAttribute, SdpParserInternalError>
"sli" | "pli" | "rpsi" | "app" => (*x).to_string(), "sli" | "pli" | "rpsi" | "app" => (*x).to_string(),
_ => { _ => {
return Err(SdpParserInternalError::Unsupported(format!( return Err(SdpParserInternalError::Unsupported(format!(
"Unknown rtcpfb nack parameter: {:?}", "Unknown rtcpfb nack parameter: {x:?}"
x
))); )));
} }
}, },
@ -3111,8 +3097,7 @@ fn parse_rtcp_fb(to_parse: &str) -> Result<SdpAttribute, SdpParserInternalError>
_ if x.parse::<u32>().is_ok() => (*x).to_string(), _ if x.parse::<u32>().is_ok() => (*x).to_string(),
_ => { _ => {
return Err(SdpParserInternalError::Generic(format!( return Err(SdpParserInternalError::Generic(format!(
"Unknown rtcpfb trr-int parameter: {:?}", "Unknown rtcpfb trr-int parameter: {x:?}"
x
))); )));
} }
}, },
@ -3125,8 +3110,7 @@ fn parse_rtcp_fb(to_parse: &str) -> Result<SdpAttribute, SdpParserInternalError>
SdpAttributeRtcpFbType::Remb | SdpAttributeRtcpFbType::TransCc => match tokens.get(2) { SdpAttributeRtcpFbType::Remb | SdpAttributeRtcpFbType::TransCc => match tokens.get(2) {
Some(x) => { Some(x) => {
return Err(SdpParserInternalError::Unsupported(format!( return Err(SdpParserInternalError::Unsupported(format!(
"Unknown rtcpfb {} parameter: {:?}", "Unknown rtcpfb {feedback_type} parameter: {x:?}"
feedback_type, x
))); )));
} }
None => "".to_string(), None => "".to_string(),
@ -3213,8 +3197,7 @@ fn parse_simulcast_version_list(
descriptor_versionlist_pair.next().unwrap(), descriptor_versionlist_pair.next().unwrap(),
)), )),
descriptor => Err(SdpParserInternalError::Generic(format!( descriptor => Err(SdpParserInternalError::Generic(format!(
"Simulcast attribute has unknown list descriptor '{:?}'", "Simulcast attribute has unknown list descriptor '{descriptor:?}'"
descriptor
))), ))),
} }
} else { } else {
@ -3249,7 +3232,7 @@ fn parse_simulcast_version_list(
// ; rid-id defined in [I-D.ietf-mmusic-rid] // ; rid-id defined in [I-D.ietf-mmusic-rid]
fn parse_simulcast(to_parse: &str) -> Result<SdpAttribute, SdpParserInternalError> { fn parse_simulcast(to_parse: &str) -> Result<SdpAttribute, SdpParserInternalError> {
// TODO: Bug 1225877: Stop accepting all kinds of whitespace here, and only accept SP // TODO: Bug 1225877: Stop accepting all kinds of whitespace here, and only accept SP
let mut tokens = to_parse.trim().split_whitespace(); let mut tokens = to_parse.split_whitespace();
let first_direction = match tokens.next() { let first_direction = match tokens.next() {
Some(x) => parse_single_direction(x)?, Some(x) => parse_single_direction(x)?,
None => { None => {

View file

@ -36,27 +36,25 @@ impl fmt::Display for SdpParserInternalError {
match *self { match *self {
SdpParserInternalError::UnknownAddressType(ref unknown) => write!( SdpParserInternalError::UnknownAddressType(ref unknown) => write!(
f, f,
"{}: {}", "{INTERNAL_ERROR_MESSAGE_UNKNOWN_ADDRESS_TYPE}: {unknown}"
INTERNAL_ERROR_MESSAGE_UNKNOWN_ADDRESS_TYPE, unknown
), ),
SdpParserInternalError::AddressTypeMismatch { found, expected } => write!( SdpParserInternalError::AddressTypeMismatch { found, expected } => write!(
f, f,
"{}: {}, {}", "{INTERNAL_ERROR_MESSAGE_ADDRESS_TYPE_MISMATCH}: {found}, {expected}"
INTERNAL_ERROR_MESSAGE_ADDRESS_TYPE_MISMATCH, found, expected
), ),
SdpParserInternalError::Generic(ref message) => write!(f, "Parsing error: {}", message), SdpParserInternalError::Generic(ref message) => write!(f, "Parsing error: {message}"),
SdpParserInternalError::Unsupported(ref message) => { SdpParserInternalError::Unsupported(ref message) => {
write!(f, "Unsupported parsing error: {}", message) write!(f, "Unsupported parsing error: {message}")
} }
SdpParserInternalError::Integer(ref error) => { SdpParserInternalError::Integer(ref error) => {
write!(f, "Integer parsing error: {}", error) write!(f, "Integer parsing error: {error}")
} }
SdpParserInternalError::Float(ref error) => write!(f, "Float parsing error: {}", error), SdpParserInternalError::Float(ref error) => write!(f, "Float parsing error: {error}"),
SdpParserInternalError::Domain(ref error) => { SdpParserInternalError::Domain(ref error) => {
write!(f, "Domain name parsing error: {}", error) write!(f, "Domain name parsing error: {error}")
} }
SdpParserInternalError::IpAddress(ref error) => { SdpParserInternalError::IpAddress(ref error) => {
write!(f, "IP address parsing error: {}", error) write!(f, "IP address parsing error: {error}")
} }
} }
} }
@ -101,33 +99,25 @@ impl Serialize for SdpParserError {
{ {
let mut state = serializer.serialize_struct( let mut state = serializer.serialize_struct(
"error", "error",
match *self { match self {
SdpParserError::Sequence { .. } => 3, SdpParserError::Sequence { .. } => 3,
_ => 4, _ => 4,
}, },
)?; )?;
match *self { match self {
SdpParserError::Line { SdpParserError::Line { error, line, .. } => {
ref error,
ref line,
..
} => {
state.serialize_field("type", "Line")?; state.serialize_field("type", "Line")?;
state.serialize_field("message", &format!("{}", error))?; state.serialize_field("message", &format!("{error}"))?;
state.serialize_field("line", &line)? state.serialize_field("line", line)?
} }
SdpParserError::Unsupported { SdpParserError::Unsupported { error, line, .. } => {
ref error,
ref line,
..
} => {
state.serialize_field("type", "Unsupported")?; state.serialize_field("type", "Unsupported")?;
state.serialize_field("message", &format!("{}", error))?; state.serialize_field("message", &format!("{error}"))?;
state.serialize_field("line", &line)? state.serialize_field("line", line)?
} }
SdpParserError::Sequence { ref message, .. } => { SdpParserError::Sequence { message, .. } => {
state.serialize_field("type", "Sequence")?; state.serialize_field("type", "Sequence")?;
state.serialize_field("message", &message)?; state.serialize_field("message", message)?;
} }
}; };
state.serialize_field( state.serialize_field(
@ -144,38 +134,31 @@ impl Serialize for SdpParserError {
impl fmt::Display for SdpParserError { impl fmt::Display for SdpParserError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self { match self {
SdpParserError::Line { SdpParserError::Line {
ref error, error,
ref line, line,
ref line_number, line_number,
} => write!( } => write!(f, "Line error: {error} in line({line_number}): {line}"),
f,
"Line error: {} in line({}): {}",
error, line_number, line
),
SdpParserError::Unsupported { SdpParserError::Unsupported {
ref error, error,
ref line, line,
ref line_number, line_number,
} => write!( } => write!(f, "Unsupported: {error} in line({line_number}): {line}",),
f,
"Unsupported: {} in line({}): {}",
error, line_number, line
),
SdpParserError::Sequence { SdpParserError::Sequence {
ref message, message,
ref line_number, line_number,
} => write!(f, "Sequence error in line({}): {}", line_number, message), } => write!(f, "Sequence error in line({line_number}): {message}"),
} }
} }
} }
impl Error for SdpParserError { impl Error for SdpParserError {
fn source(&self) -> Option<&(dyn error::Error + 'static)> { fn source(&self) -> Option<&(dyn error::Error + 'static)> {
match *self { match self {
SdpParserError::Line { ref error, .. } SdpParserError::Line { error, .. } | SdpParserError::Unsupported { error, .. } => {
| SdpParserError::Unsupported { ref error, .. } => Some(error), Some(error)
}
// Can't tell much more about our internal errors // Can't tell much more about our internal errors
_ => None, _ => None,
} }

View file

@ -9,7 +9,7 @@ use std::str::FromStr;
fn test_sdp_parser_internal_error_unknown_address_type() { fn test_sdp_parser_internal_error_unknown_address_type() {
let error = SdpParserInternalError::UnknownAddressType("foo".to_string()); let error = SdpParserInternalError::UnknownAddressType("foo".to_string());
assert_eq!( assert_eq!(
format!("{}", error), format!("{error}"),
format!("{}: {}", INTERNAL_ERROR_MESSAGE_UNKNOWN_ADDRESS_TYPE, "foo") format!("{}: {}", INTERNAL_ERROR_MESSAGE_UNKNOWN_ADDRESS_TYPE, "foo")
); );
assert!(error.source().is_none()); assert!(error.source().is_none());
@ -21,7 +21,7 @@ fn test_sdp_parser_internal_error_address_type_mismatch() {
expected: AddressType::IpV6, expected: AddressType::IpV6,
}; };
assert_eq!( assert_eq!(
format!("{}", error), format!("{error}"),
format!( format!(
"{}: {}, {}", "{}: {}, {}",
INTERNAL_ERROR_MESSAGE_ADDRESS_TYPE_MISMATCH, INTERNAL_ERROR_MESSAGE_ADDRESS_TYPE_MISMATCH,
@ -35,7 +35,7 @@ fn test_sdp_parser_internal_error_address_type_mismatch() {
#[test] #[test]
fn test_sdp_parser_internal_error_generic() { fn test_sdp_parser_internal_error_generic() {
let generic = SdpParserInternalError::Generic("generic message".to_string()); let generic = SdpParserInternalError::Generic("generic message".to_string());
assert_eq!(format!("{}", generic), "Parsing error: generic message"); assert_eq!(format!("{generic}"), "Parsing error: generic message");
assert!(generic.source().is_none()); assert!(generic.source().is_none());
} }
@ -44,7 +44,7 @@ fn test_sdp_parser_internal_error_unsupported() {
let unsupported = let unsupported =
SdpParserInternalError::Unsupported("unsupported internal message".to_string()); SdpParserInternalError::Unsupported("unsupported internal message".to_string());
assert_eq!( assert_eq!(
format!("{}", unsupported), format!("{unsupported}"),
"Unsupported parsing error: unsupported internal message" "Unsupported parsing error: unsupported internal message"
); );
assert!(unsupported.source().is_none()); assert!(unsupported.source().is_none());
@ -57,10 +57,10 @@ fn test_sdp_parser_internal_error_integer() {
assert!(integer.is_err()); assert!(integer.is_err());
let int_err = SdpParserInternalError::Integer(integer.err().unwrap()); let int_err = SdpParserInternalError::Integer(integer.err().unwrap());
assert_eq!( assert_eq!(
format!("{}", int_err), format!("{int_err}"),
"Integer parsing error: invalid digit found in string" "Integer parsing error: invalid digit found in string"
); );
assert!(!int_err.source().is_none()); assert!(int_err.source().is_some());
} }
#[test] #[test]
@ -70,10 +70,10 @@ fn test_sdp_parser_internal_error_float() {
assert!(float.is_err()); assert!(float.is_err());
let int_err = SdpParserInternalError::Float(float.err().unwrap()); let int_err = SdpParserInternalError::Float(float.err().unwrap());
assert_eq!( assert_eq!(
format!("{}", int_err), format!("{int_err}"),
"Float parsing error: invalid float literal" "Float parsing error: invalid float literal"
); );
assert!(!int_err.source().is_none()); assert!(int_err.source().is_some());
} }
#[test] #[test]
@ -81,10 +81,10 @@ fn test_sdp_parser_internal_error_address() {
let v = "127.0.0.500"; let v = "127.0.0.500";
let addr_err = Address::from_str(v).err().unwrap(); let addr_err = Address::from_str(v).err().unwrap();
assert_eq!( assert_eq!(
format!("{}", addr_err), format!("{addr_err}"),
"Domain name parsing error: invalid IPv4 address" "Domain name parsing error: invalid IPv4 address"
); );
assert!(!addr_err.source().is_none()); assert!(addr_err.source().is_some());
} }
#[test] #[test]
@ -95,7 +95,7 @@ fn test_sdp_parser_error_line() {
line_number: 13, line_number: 13,
}; };
assert_eq!( assert_eq!(
format!("{}", line1), format!("{line1}"),
"Line error: Parsing error: test message in line(13): test line" "Line error: Parsing error: test message in line(13): test line"
); );
assert!(line1.source().is_some()); assert!(line1.source().is_some());
@ -109,7 +109,7 @@ fn test_sdp_parser_error_unsupported() {
line_number: 21, line_number: 21,
}; };
assert_eq!( assert_eq!(
format!("{}", unsupported1), format!("{unsupported1}"),
"Unsupported: Parsing error: unsupported value in line(21): unsupported line" "Unsupported: Parsing error: unsupported value in line(21): unsupported line"
); );
assert!(unsupported1.source().is_some()); assert!(unsupported1.source().is_some());
@ -122,7 +122,7 @@ fn test_sdp_parser_error_sequence() {
line_number: 42, line_number: 42,
}; };
assert_eq!( assert_eq!(
format!("{}", sequence1), format!("{sequence1}"),
"Sequence error in line(42): sequence message" "Sequence error in line(42): sequence message"
); );
assert!(sequence1.source().is_none()); assert!(sequence1.source().is_none());

View file

@ -58,7 +58,7 @@ impl fmt::Display for SdpBandwidth {
SdpBandwidth::Tias(ref x) => ("TIAS", x), SdpBandwidth::Tias(ref x) => ("TIAS", x),
SdpBandwidth::Unknown(ref tp, ref x) => (&tp[..], x), SdpBandwidth::Unknown(ref tp, ref x) => (&tp[..], x),
}; };
write!(f, "{tp}:{val}", tp = tp_string, val = value) write!(f, "{tp_string}:{value}")
} }
} }
@ -292,8 +292,7 @@ impl SdpSession {
pub fn add_attribute(&mut self, a: SdpAttribute) -> Result<(), SdpParserInternalError> { pub fn add_attribute(&mut self, a: SdpAttribute) -> Result<(), SdpParserInternalError> {
if !a.allowed_at_session_level() { if !a.allowed_at_session_level() {
return Err(SdpParserInternalError::Generic(format!( return Err(SdpParserInternalError::Generic(format!(
"{} not allowed at session level", "{a} not allowed at session level"
a
))); )));
}; };
self.attribute.push(a); self.attribute.push(a);
@ -312,7 +311,7 @@ impl SdpSession {
let _line_number = line.line_number; let _line_number = line.line_number;
self.add_attribute(a).map_err(|e: SdpParserInternalError| { self.add_attribute(a).map_err(|e: SdpParserInternalError| {
SdpParserError::Sequence { SdpParserError::Sequence {
message: format!("{}", e), message: format!("{e}"),
line_number: _line_number, line_number: _line_number,
} }
})? })?
@ -408,8 +407,7 @@ fn parse_version(value: &str) -> Result<SdpType, SdpParserInternalError> {
let ver = value.parse::<u64>()?; let ver = value.parse::<u64>()?;
if ver != 0 { if ver != 0 {
return Err(SdpParserInternalError::Generic(format!( return Err(SdpParserInternalError::Generic(format!(
"version type contains unsupported value {}", "version type contains unsupported value {ver}"
ver
))); )));
}; };
trace!("version: {}", ver); trace!("version: {}", ver);
@ -493,7 +491,7 @@ fn parse_connection(value: &str) -> Result<SdpType, SdpParserInternalError> {
let mut ttl = None; let mut ttl = None;
let mut amount = None; let mut amount = None;
let mut addr_token = cv[2]; let mut addr_token = cv[2];
if addr_token.find('/') != None { if addr_token.find('/').is_some() {
let addr_tokens: Vec<&str> = addr_token.split('/').collect(); let addr_tokens: Vec<&str> = addr_token.split('/').collect();
if addr_tokens.len() >= 3 { if addr_tokens.len() >= 3 {
amount = Some(addr_tokens[2].parse::<u32>()?); amount = Some(addr_tokens[2].parse::<u32>()?);
@ -544,7 +542,7 @@ fn parse_timing(value: &str) -> Result<SdpType, SdpParserInternalError> {
} }
pub fn parse_sdp_line(line: &str, line_number: usize) -> Result<SdpLine, SdpParserError> { pub fn parse_sdp_line(line: &str, line_number: usize) -> Result<SdpLine, SdpParserError> {
if line.find('=') == None { if line.find('=').is_none() {
return Err(SdpParserError::Line { return Err(SdpParserError::Line {
error: SdpParserInternalError::Generic("missing = character in line".to_string()), error: SdpParserInternalError::Generic("missing = character in line".to_string()),
line: line.to_string(), line: line.to_string(),
@ -605,37 +603,30 @@ pub fn parse_sdp_line(line: &str, line_number: usize) -> Result<SdpLine, SdpPars
"b" => parse_bandwidth(line_value), "b" => parse_bandwidth(line_value),
"c" => parse_connection(line_value), "c" => parse_connection(line_value),
"e" => Err(SdpParserInternalError::Generic(format!( "e" => Err(SdpParserInternalError::Generic(format!(
"unsupported type email: {}", "unsupported type email: {line_value}"
line_value
))), ))),
"i" => Err(SdpParserInternalError::Generic(format!( "i" => Err(SdpParserInternalError::Generic(format!(
"unsupported type information: {}", "unsupported type information: {line_value}"
line_value
))), ))),
"k" => Err(SdpParserInternalError::Generic(format!( "k" => Err(SdpParserInternalError::Generic(format!(
"unsupported insecure key exchange: {}", "unsupported insecure key exchange: {line_value}"
line_value
))), ))),
"m" => parse_media(line_value), "m" => parse_media(line_value),
"o" => parse_origin(line_value), "o" => parse_origin(line_value),
"p" => Err(SdpParserInternalError::Generic(format!( "p" => Err(SdpParserInternalError::Generic(format!(
"unsupported type phone: {}", "unsupported type phone: {line_value}"
line_value
))), ))),
"r" => Err(SdpParserInternalError::Generic(format!( "r" => Err(SdpParserInternalError::Generic(format!(
"unsupported type repeat: {}", "unsupported type repeat: {line_value}"
line_value
))), ))),
"s" => parse_session(untrimmed_line_value), "s" => parse_session(untrimmed_line_value),
"t" => parse_timing(line_value), "t" => parse_timing(line_value),
"u" => Err(SdpParserInternalError::Generic(format!( "u" => Err(SdpParserInternalError::Generic(format!(
"unsupported type uri: {}", "unsupported type uri: {line_value}"
line_value
))), ))),
"v" => parse_version(line_value), "v" => parse_version(line_value),
"z" => Err(SdpParserInternalError::Generic(format!( "z" => Err(SdpParserInternalError::Generic(format!(
"unsupported type zone: {}", "unsupported type zone: {line_value}"
line_value
))), ))),
_ => Err(SdpParserInternalError::Generic( _ => Err(SdpParserInternalError::Generic(
"unknown sdp type".to_string(), "unknown sdp type".to_string(),
@ -749,7 +740,7 @@ fn sanity_check_sdp_session(session: &SdpSession) -> Result<(), SdpParserError>
} }
} }
if let Some(&SdpAttribute::Simulcast(ref simulcast)) = if let Some(SdpAttribute::Simulcast(simulcast)) =
msection.get_attribute(SdpAttributeType::Simulcast) msection.get_attribute(SdpAttributeType::Simulcast)
{ {
let check_defined_rids = let check_defined_rids =

View file

@ -196,8 +196,7 @@ impl SdpMedia {
pub fn add_attribute(&mut self, attr: SdpAttribute) -> Result<(), SdpParserInternalError> { pub fn add_attribute(&mut self, attr: SdpAttribute) -> Result<(), SdpParserInternalError> {
if !attr.allowed_at_media_level() { if !attr.allowed_at_media_level() {
return Err(SdpParserInternalError::Generic(format!( return Err(SdpParserInternalError::Generic(format!(
"{} not allowed at media level", "{attr} not allowed at media level"
attr
))); )));
} }
self.attribute.push(attr); self.attribute.push(attr);
@ -318,8 +317,7 @@ fn parse_media_token(value: &str) -> Result<SdpMediaValue, SdpParserInternalErro
"application" => SdpMediaValue::Application, "application" => SdpMediaValue::Application,
_ => { _ => {
return Err(SdpParserInternalError::Unsupported(format!( return Err(SdpParserInternalError::Unsupported(format!(
"unsupported media value: {}", "unsupported media value: {value}"
value
))); )));
} }
}) })
@ -340,8 +338,7 @@ fn parse_protocol_token(value: &str) -> Result<SdpProtocolValue, SdpParserIntern
"TCP/DTLS/SCTP" => SdpProtocolValue::TcpDtlsSctp, "TCP/DTLS/SCTP" => SdpProtocolValue::TcpDtlsSctp,
_ => { _ => {
return Err(SdpParserInternalError::Unsupported(format!( return Err(SdpParserInternalError::Unsupported(format!(
"unsupported protocol value: {}", "unsupported protocol value: {value}"
value
))); )));
} }
}) })
@ -380,15 +377,11 @@ pub fn parse_media(value: &str) -> Result<SdpType, SdpParserInternalError> {
let mut fmt_vec: Vec<u32> = vec![]; let mut fmt_vec: Vec<u32> = vec![];
for num in fmt_slice { for num in fmt_slice {
let fmt_num = num.parse::<u32>()?; let fmt_num = num.parse::<u32>()?;
match fmt_num { if matches!(fmt_num, 1 | 2 | 19 | 64..=95 | 128 .. ) {
0 | // PCMU return Err(SdpParserInternalError::Generic(
8 | // PCMA "format number in media line is out of range".to_string(),
9 | // G722 ));
13 | // Comfort Noise }
35 ..= 63 | 96 ..= 127 => (), // dynamic range
_ => return Err(SdpParserInternalError::Generic(
"format number in media line is out of range".to_string()))
};
fmt_vec.push(fmt_num); fmt_vec.push(fmt_num);
} }
SdpFormatList::Integers(fmt_vec) SdpFormatList::Integers(fmt_vec)
@ -459,7 +452,7 @@ pub fn parse_media_vector(lines: &mut Vec<SdpLine>) -> Result<Vec<SdpMedia>, Sdp
_ => sdp_media.add_attribute(a), _ => sdp_media.add_attribute(a),
} }
.map_err(|e: SdpParserInternalError| SdpParserError::Sequence { .map_err(|e: SdpParserInternalError| SdpParserError::Sequence {
message: format!("{}", e), message: format!("{e}"),
line_number: _line_number, line_number: _line_number,
})? })?
} }

View file

@ -9,8 +9,8 @@ use std::str::FromStr;
pub fn ip_address_to_string(addr: IpAddr) -> String { pub fn ip_address_to_string(addr: IpAddr) -> String {
match addr { match addr {
IpAddr::V4(ipv4) => format!("IN IP4 {}", ipv4), IpAddr::V4(ipv4) => format!("IN IP4 {ipv4}"),
IpAddr::V6(ipv6) => format!("IN IP6 {}", ipv6), IpAddr::V6(ipv6) => format!("IN IP6 {ipv6}"),
} }
} }

View file

@ -311,9 +311,9 @@ a=ssrc:2709871439 cname:{735484ea-4f6c-f74a-bd66-7425f8476c2e}";
assert!(msection assert!(msection
.get_attribute(webrtc_sdp::attribute_type::SdpAttributeType::Recvonly) .get_attribute(webrtc_sdp::attribute_type::SdpAttributeType::Recvonly)
.is_some()); .is_some());
assert!(!msection assert!(msection
.get_attribute(webrtc_sdp::attribute_type::SdpAttributeType::Extmap) .get_attribute(webrtc_sdp::attribute_type::SdpAttributeType::Extmap)
.is_some()); .is_none());
assert_eq!( assert_eq!(
msection msection
.get_attributes_of_type(webrtc_sdp::attribute_type::SdpAttributeType::Fmtp) .get_attributes_of_type(webrtc_sdp::attribute_type::SdpAttributeType::Fmtp)
@ -332,9 +332,9 @@ a=ssrc:2709871439 cname:{735484ea-4f6c-f74a-bd66-7425f8476c2e}";
assert!(msection assert!(msection
.get_attribute(webrtc_sdp::attribute_type::SdpAttributeType::Mid) .get_attribute(webrtc_sdp::attribute_type::SdpAttributeType::Mid)
.is_some()); .is_some());
assert!(!msection assert!(msection
.get_attribute(webrtc_sdp::attribute_type::SdpAttributeType::Msid) .get_attribute(webrtc_sdp::attribute_type::SdpAttributeType::Msid)
.is_some()); .is_none());
assert_eq!( assert_eq!(
msection msection
.get_attributes_of_type(webrtc_sdp::attribute_type::SdpAttributeType::Rtcpfb) .get_attributes_of_type(webrtc_sdp::attribute_type::SdpAttributeType::Rtcpfb)
@ -402,9 +402,9 @@ fn parse_firefox_datachannel_offer() {
assert!(msection assert!(msection
.get_attribute(webrtc_sdp::attribute_type::SdpAttributeType::Sendrecv) .get_attribute(webrtc_sdp::attribute_type::SdpAttributeType::Sendrecv)
.is_some()); .is_some());
assert!(!msection assert!(msection
.get_attribute(webrtc_sdp::attribute_type::SdpAttributeType::Extmap) .get_attribute(webrtc_sdp::attribute_type::SdpAttributeType::Extmap)
.is_some()); .is_none());
assert!(msection assert!(msection
.get_attribute(webrtc_sdp::attribute_type::SdpAttributeType::IcePwd) .get_attribute(webrtc_sdp::attribute_type::SdpAttributeType::IcePwd)
.is_some()); .is_some());
@ -417,18 +417,18 @@ fn parse_firefox_datachannel_offer() {
assert!(msection assert!(msection
.get_attribute(webrtc_sdp::attribute_type::SdpAttributeType::Mid) .get_attribute(webrtc_sdp::attribute_type::SdpAttributeType::Mid)
.is_some()); .is_some());
assert!(!msection assert!(msection
.get_attribute(webrtc_sdp::attribute_type::SdpAttributeType::Msid) .get_attribute(webrtc_sdp::attribute_type::SdpAttributeType::Msid)
.is_some()); .is_none());
assert!(!msection assert!(msection
.get_attribute(webrtc_sdp::attribute_type::SdpAttributeType::Rtcpfb) .get_attribute(webrtc_sdp::attribute_type::SdpAttributeType::Rtcpfb)
.is_some()); .is_none());
assert!(!msection assert!(msection
.get_attribute(webrtc_sdp::attribute_type::SdpAttributeType::RtcpMux) .get_attribute(webrtc_sdp::attribute_type::SdpAttributeType::RtcpMux)
.is_some()); .is_none());
assert!(!msection assert!(msection
.get_attribute(webrtc_sdp::attribute_type::SdpAttributeType::Rtpmap) .get_attribute(webrtc_sdp::attribute_type::SdpAttributeType::Rtpmap)
.is_some()); .is_none());
assert!(msection assert!(msection
.get_attribute(webrtc_sdp::attribute_type::SdpAttributeType::Sctpmap) .get_attribute(webrtc_sdp::attribute_type::SdpAttributeType::Sctpmap)
.is_some()); .is_some());