Bug 1687098 - Update WebRTC-SDP to version 0.3.8;r=drno

Differential Revision: https://phabricator.services.mozilla.com/D102110
This commit is contained in:
Nico Grunbaum 2021-01-18 06:27:38 +00:00
Родитель 2c06b16a0c
Коммит fba68a8e39
13 изменённых файлов: 177 добавлений и 110 удалений

4
Cargo.lock сгенерированный
Просмотреть файл

@ -5931,9 +5931,9 @@ dependencies = [
[[package]]
name = "webrtc-sdp"
version = "0.3.6"
version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22ca3fe7f015c28dcfbea0b0e05fbcb1a26ed902f80509dd0a4bf40556e73f58"
checksum = "98db6ff463a94d727ee7c1188bab33146468add6dfb94df30a1f4a3495a700d9"
dependencies = [
"log",
"url",

Просмотреть файл

@ -7,5 +7,5 @@ authors = ["Paul Ellenbogen <pe5@cs.princeton.edu>",
[dependencies]
libc = "^0.2.0"
log = "0.4"
rsdparsa = {package = "webrtc-sdp", version = "0.3.6"}
rsdparsa = {package = "webrtc-sdp", version = "0.3.8"}
nserror = { path = "../../../../../xpcom/rust/nserror" }

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

7
third_party/rust/webrtc-sdp/CHANGELOG.md поставляемый
Просмотреть файл

@ -1,4 +1,11 @@
# Changelog
## [0.3.8] - 2021-01-16
- fmt numbers 35 to 63 are now usable for dynamic allocation
- parse extmap-allow-mixed as per RFC 8285
## [0.3.7] - 2020-11-23
- Minimum Rust version >= 1.45
- Added feature for parse object tree wide debug formatting, defaulted to on for now
- Moved check for multiple c lines within an m section out of the setter and into the parsing logic, credit Mnwa
## [0.3.6] - 2020-05-07
- Added support for Opus FMTP parameters ptime, maxptime, minptime, and maxaveragebitrate
## [0.3.5] - 2020-04-07

94
third_party/rust/webrtc-sdp/Cargo.lock сгенерированный поставляемый
Просмотреть файл

@ -4,168 +4,166 @@
name = "cfg-if"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
[[package]]
name = "idna"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9"
dependencies = [
"matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-normalization 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"matches",
"unicode-bidi",
"unicode-normalization",
]
[[package]]
name = "itoa"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f"
[[package]]
name = "log"
version = "0.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7"
dependencies = [
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"cfg-if",
]
[[package]]
name = "matches"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08"
[[package]]
name = "maybe-uninit"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00"
[[package]]
name = "percent-encoding"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e"
[[package]]
name = "proc-macro2"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c9e470a8dc4aeae2dee2f335e8f533e2d4b347e1434e5671afc49b054592f27"
dependencies = [
"unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-xid",
]
[[package]]
name = "quote"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe"
dependencies = [
"proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2",
]
[[package]]
name = "ryu"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfa8506c1de11c9c4e4c38863ccbe02a305c8188e85a05a784c9e11e1c3910c8"
[[package]]
name = "serde"
version = "1.0.102"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c4b39bd9b0b087684013a792c59e3e07a46a01d2322518d8a1104641a0b1be0"
[[package]]
name = "serde_derive"
version = "1.0.102"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca13fc1a832f793322228923fbb3aba9f3f44444898f835d31ad1b74fa0a2bf8"
dependencies = [
"proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "serde_json"
version = "1.0.41"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2f72eb2a68a7dc3f9a691bfda9305a1c017a6215e5a4545c258500d2099a37c2"
dependencies = [
"itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
"ryu 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)",
"itoa",
"ryu",
"serde",
]
[[package]]
name = "smallvec"
version = "0.6.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7b0758c52e15a8b5e3691eae6cc559f08eee9406e548a4477ba4e67770a82b6"
dependencies = [
"maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"maybe-uninit",
]
[[package]]
name = "syn"
version = "1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "661641ea2aa15845cddeb97dad000d22070bb5c1fb456b96c1cba883ec691e92"
dependencies = [
"proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2",
"quote",
"unicode-xid",
]
[[package]]
name = "unicode-bidi"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5"
dependencies = [
"matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"matches",
]
[[package]]
name = "unicode-normalization"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09c8070a9942f5e7cfccd93f490fdebd230ee3c3c9f107cb25bad5351ef671cf"
dependencies = [
"smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec",
]
[[package]]
name = "unicode-xid"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
[[package]]
name = "url"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75b414f6c464c879d7f9babf951f23bc3743fb7313c081b2e6ca719067ea9d61"
dependencies = [
"idna 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"idna",
"matches",
"percent-encoding",
]
[[package]]
name = "webrtc-sdp"
version = "0.3.6"
version = "0.3.8"
dependencies = [
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)",
"url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log",
"serde",
"serde_derive",
"serde_json",
"url",
]
[metadata]
"checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
"checksum idna 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9"
"checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f"
"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7"
"checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08"
"checksum maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00"
"checksum percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e"
"checksum proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9c9e470a8dc4aeae2dee2f335e8f533e2d4b347e1434e5671afc49b054592f27"
"checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe"
"checksum ryu 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bfa8506c1de11c9c4e4c38863ccbe02a305c8188e85a05a784c9e11e1c3910c8"
"checksum serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)" = "0c4b39bd9b0b087684013a792c59e3e07a46a01d2322518d8a1104641a0b1be0"
"checksum serde_derive 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)" = "ca13fc1a832f793322228923fbb3aba9f3f44444898f835d31ad1b74fa0a2bf8"
"checksum serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)" = "2f72eb2a68a7dc3f9a691bfda9305a1c017a6215e5a4545c258500d2099a37c2"
"checksum smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "f7b0758c52e15a8b5e3691eae6cc559f08eee9406e548a4477ba4e67770a82b6"
"checksum syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "661641ea2aa15845cddeb97dad000d22070bb5c1fb456b96c1cba883ec691e92"
"checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5"
"checksum unicode-normalization 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "09c8070a9942f5e7cfccd93f490fdebd230ee3c3c9f107cb25bad5351ef671cf"
"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
"checksum url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "75b414f6c464c879d7f9babf951f23bc3743fb7313c081b2e6ca719067ea9d61"

5
third_party/rust/webrtc-sdp/Cargo.toml поставляемый
Просмотреть файл

@ -12,7 +12,7 @@
[package]
name = "webrtc-sdp"
version = "0.3.6"
version = "0.3.8"
authors = ["Nils Ohlmeier <github@ohlmeier.org>"]
description = "This create parses strings in the format of the Session Description Protocol according to RFC4566. It specifically supports the subset of features required to support WebRTC according to the JSEP draft."
readme = "README.md"
@ -37,7 +37,8 @@ version = "2.1.0"
version = "1.0"
[features]
default = []
default = ["enhanced_debug"]
enhanced_debug = []
serialize = ["serde", "serde_derive"]
[badges.codecov]
branch = "master"

4
third_party/rust/webrtc-sdp/README.md поставляемый
Просмотреть файл

@ -10,7 +10,7 @@ A SDP parser written in Rust specifically aimed to handle WebRTC SDP offers and
## Dependecies
* Rust >= 1.36.0
* Rust >= 1.45.0
* log module
* serde module
* serde-derive module
@ -20,7 +20,7 @@ Cargo installs the missing modules automatically when building webrtc-sdp for th
## The webrtc-sdp API
The main function is:
```
```rust
fn parse_sdp(sdp: &str, fail_on_warning: bool) -> Result<SdpSession, SdpParserError>
```
The `sdp` parameter is the string which will get parsed. The `fail_on_warning` parameter determines how to treat warnings encountered during parsing. Any problems encountered during are stored until the whole string has been parsed. Any problem during parsing falls into two catgeories:

Просмотреть файл

@ -58,8 +58,10 @@ fn main() {
.collect::<Vec<&str>>()
.join("\r\n");
if let Err(why) = webrtc_sdp::parse_sdp(&s, true) {
panic!("Failed to parse SDP with error: {}", why);
let res = webrtc_sdp::parse_sdp(&s, true);
match res {
Err(why) => panic!("Failed to parse SDP with error: {}", why),
Ok(sdp) => println!("Parsed SDP structure:\n{:#?}", sdp),
}
if expect_failure {

8
third_party/rust/webrtc-sdp/src/address.rs поставляемый
Просмотреть файл

@ -37,10 +37,10 @@ impl FromStr for Address {
}
}
Host::parse(s)
.and_then(|host| match host {
Host::Domain(s) => Ok(Address::Fqdn(s)),
Host::Ipv4(ip) => Ok(Address::Ip(IpAddr::V4(ip))),
Host::Ipv6(ip) => Ok(Address::Ip(IpAddr::V6(ip))),
.map(|host| match host {
Host::Domain(s) => Address::Fqdn(s),
Host::Ipv4(ip) => Address::Ip(IpAddr::V4(ip)),
Host::Ipv6(ip) => Address::Ip(IpAddr::V6(ip)),
})
.map_err(|err| e.unwrap_or_else(|| err.into()))
}

Просмотреть файл

@ -80,7 +80,7 @@ where
pub fn maybe_print_bool_param(name: &str, param: bool, default_value: bool) -> String {
if param != default_value {
name.to_owned() + "=" + &(if param { "1" } else { "0" }).to_string()
name.to_owned() + "=" + &(param as i32).to_string()
} else {
"".to_string()
}
@ -179,6 +179,7 @@ impl fmt::Display for SdpAttributeCandidateTcpType {
#[derive(Clone)]
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "enhanced_debug", derive(Debug))]
pub struct SdpAttributeCandidate {
pub foundation: String,
pub component: u32,
@ -299,6 +300,7 @@ impl AnonymizingClone for SdpAttributeCandidate {
#[derive(Clone)]
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "enhanced_debug", derive(Debug))]
pub enum SdpAttributeDtlsMessage {
Client(String),
Server(String),
@ -316,6 +318,7 @@ impl fmt::Display for SdpAttributeDtlsMessage {
#[derive(Clone)]
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "enhanced_debug", derive(Debug))]
pub struct SdpAttributeRemoteCandidate {
pub component: u32,
pub address: Address,
@ -346,6 +349,7 @@ impl AnonymizingClone for SdpAttributeRemoteCandidate {
#[derive(Clone)]
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "enhanced_debug", derive(Debug))]
pub struct SdpAttributeSimulcastId {
pub id: String,
pub paused: bool,
@ -353,9 +357,9 @@ pub struct SdpAttributeSimulcastId {
impl SdpAttributeSimulcastId {
pub fn new(idstr: &str) -> SdpAttributeSimulcastId {
if idstr.starts_with('~') {
if let Some(idstr) = idstr.strip_prefix('~') {
SdpAttributeSimulcastId {
id: idstr[1..].to_string(),
id: idstr.to_string(),
paused: true,
}
} else {
@ -379,6 +383,7 @@ impl fmt::Display for SdpAttributeSimulcastId {
#[repr(C)]
#[derive(Clone)]
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "enhanced_debug", derive(Debug))]
pub struct SdpAttributeSimulcastVersion {
pub ids: Vec<SdpAttributeSimulcastId>,
}
@ -407,6 +412,7 @@ impl fmt::Display for SdpAttributeSimulcastVersion {
#[derive(Clone)]
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "enhanced_debug", derive(Debug))]
pub struct SdpAttributeSimulcast {
pub send: Vec<SdpAttributeSimulcastVersion>,
pub receive: Vec<SdpAttributeSimulcastVersion>,
@ -425,6 +431,7 @@ impl fmt::Display for SdpAttributeSimulcast {
#[derive(Clone)]
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "enhanced_debug", derive(Debug))]
pub struct SdpAttributeRtcp {
pub port: u16,
pub unicast_addr: Option<ExplicitlyTypedAddress>,
@ -454,6 +461,7 @@ impl fmt::Display for SdpAttributeRtcp {
#[derive(Clone)]
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "enhanced_debug", derive(Debug))]
pub enum SdpAttributeRtcpFbType {
Ack = 0,
Ccm = 2, // This is explicitly 2 to make the conversion to the
@ -481,6 +489,7 @@ impl fmt::Display for SdpAttributeRtcpFbType {
#[derive(Clone)]
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "enhanced_debug", derive(Debug))]
pub struct SdpAttributeRtcpFb {
pub payload_type: SdpAttributePayloadType,
pub feedback_type: SdpAttributeRtcpFbType,
@ -505,6 +514,7 @@ impl fmt::Display for SdpAttributeRtcpFb {
#[derive(Clone)]
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "enhanced_debug", derive(Debug))]
pub enum SdpAttributeDirection {
Recvonly,
Sendonly,
@ -524,6 +534,7 @@ impl fmt::Display for SdpAttributeDirection {
#[derive(Clone)]
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "enhanced_debug", derive(Debug))]
pub struct SdpAttributeExtmap {
pub id: u16,
pub direction: Option<SdpAttributeDirection>,
@ -546,6 +557,7 @@ impl fmt::Display for SdpAttributeExtmap {
#[derive(Clone, Copy)]
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "enhanced_debug", derive(Debug))]
pub struct RtxFmtpParameters {
pub apt: u8,
pub rtx_time: Option<u32>,
@ -563,6 +575,7 @@ impl fmt::Display for RtxFmtpParameters {
#[derive(Clone)]
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "enhanced_debug", derive(Debug))]
pub struct SdpAttributeFmtpParameters {
// H264
// TODO(bug 1466859): Support sprop-parameter-sets
@ -614,13 +627,17 @@ impl fmt::Display for SdpAttributeFmtpParameters {
f,
"{parameters}{red}{dtmf}{unknown}",
parameters = non_empty_string_vec![
maybe_print_param("packetization-mode=", self.packetization_mode, 0),
maybe_print_param(
"profile-level-id=",
format!("{:06x}", self.profile_level_id),
"420010".to_string()
),
maybe_print_bool_param(
"level-asymmetry-allowed",
self.level_asymmetry_allowed,
false
),
maybe_print_param("profile-level-id=", self.profile_level_id, 0x0042_0010),
maybe_print_param("packetization-mode=", self.packetization_mode, 0),
maybe_print_param("max-fs=", self.max_fs, 0),
maybe_print_param("max-cpb=", self.max_cpb, 0),
maybe_print_param("max-dpb=", self.max_dpb, 0),
@ -647,6 +664,7 @@ impl fmt::Display for SdpAttributeFmtpParameters {
#[derive(Clone)]
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "enhanced_debug", derive(Debug))]
pub struct SdpAttributeFmtp {
pub payload_type: u8,
pub parameters: SdpAttributeFmtpParameters,
@ -665,6 +683,7 @@ impl fmt::Display for SdpAttributeFmtp {
#[derive(Clone, Copy)]
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "enhanced_debug", derive(Debug))]
pub enum SdpAttributeFingerprintHashType {
Sha1,
Sha224,
@ -688,6 +707,7 @@ impl fmt::Display for SdpAttributeFingerprintHashType {
#[derive(Clone)]
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "enhanced_debug", derive(Debug))]
pub struct SdpAttributeFingerprint {
pub hash_algorithm: SdpAttributeFingerprintHashType,
pub fingerprint: Vec<u8>,
@ -833,6 +853,7 @@ impl fmt::Display for SdpAttributeImageAttrSetList {
#[derive(Clone)]
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "enhanced_debug", derive(Debug))]
pub struct SdpAttributeImageAttr {
pub pt: SdpAttributePayloadType,
pub send: SdpAttributeImageAttrSetList,
@ -856,6 +877,7 @@ impl fmt::Display for SdpAttributeImageAttr {
#[derive(Clone)]
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "enhanced_debug", derive(Debug))]
pub struct SdpAttributeSctpmap {
pub port: u16,
pub channels: u32,
@ -874,6 +896,7 @@ impl fmt::Display for SdpAttributeSctpmap {
#[derive(Clone)]
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "enhanced_debug", derive(Debug))]
pub enum SdpAttributeGroupSemantic {
LipSynchronization, // RFC5888
FlowIdentification, // RFC5888
@ -901,6 +924,7 @@ impl fmt::Display for SdpAttributeGroupSemantic {
#[derive(Clone)]
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "enhanced_debug", derive(Debug))]
pub struct SdpAttributeGroup {
pub semantics: SdpAttributeGroupSemantic,
pub tags: Vec<String>,
@ -919,6 +943,7 @@ impl fmt::Display for SdpAttributeGroup {
#[derive(Clone)]
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "enhanced_debug", derive(Debug))]
pub struct SdpAttributeMsid {
pub id: String,
pub appdata: Option<String>,
@ -950,6 +975,7 @@ impl fmt::Display for SdpAttributeMsidSemantic {
#[derive(Clone)]
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "enhanced_debug", derive(Debug))]
pub struct SdpAttributeRidParameters {
pub max_width: u32,
pub max_height: u32,
@ -979,6 +1005,7 @@ impl fmt::Display for SdpAttributeRidParameters {
#[derive(Clone)]
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "enhanced_debug", derive(Debug))]
pub struct SdpAttributeRid {
pub id: String,
pub direction: SdpSingleDirection,
@ -1011,6 +1038,7 @@ impl fmt::Display for SdpAttributeRid {
#[derive(Clone)]
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "enhanced_debug", derive(Debug))]
pub struct SdpAttributeRtpmap {
pub payload_type: u8,
pub codec_name: String,
@ -1048,6 +1076,7 @@ impl fmt::Display for SdpAttributeRtpmap {
#[derive(Clone)]
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "enhanced_debug", derive(Debug))]
pub enum SdpAttributeSetup {
Active,
Actpass,
@ -1069,6 +1098,7 @@ impl fmt::Display for SdpAttributeSetup {
#[derive(Clone)]
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "enhanced_debug", derive(Debug))]
pub struct SdpAttributeSsrc {
pub id: u32,
pub attribute: Option<String>,
@ -1121,6 +1151,7 @@ impl AnonymizingClone for SdpAttributeSsrc {
#[derive(Clone)]
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "enhanced_debug", derive(Debug))]
pub enum SdpSsrcGroupSemantic {
Duplication, // RFC7104
FlowIdentification, // RFC5576
@ -1144,12 +1175,14 @@ impl fmt::Display for SdpSsrcGroupSemantic {
#[derive(Clone)]
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "enhanced_debug", derive(Debug))]
pub enum SdpAttribute {
BundleOnly,
Candidate(SdpAttributeCandidate),
DtlsMessage(SdpAttributeDtlsMessage),
EndOfCandidates,
Extmap(SdpAttributeExtmap),
ExtmapAllowMixed,
Fingerprint(SdpAttributeFingerprint),
Fmtp(SdpAttributeFmtp),
Group(SdpAttributeGroup),
@ -1217,6 +1250,7 @@ impl SdpAttribute {
SdpAttribute::DtlsMessage { .. }
| SdpAttribute::EndOfCandidates
| SdpAttribute::Extmap(..)
| SdpAttribute::ExtmapAllowMixed
| SdpAttribute::Fingerprint(..)
| SdpAttribute::Group(..)
| SdpAttribute::IceLite
@ -1247,6 +1281,7 @@ impl SdpAttribute {
| SdpAttribute::Candidate(..)
| SdpAttribute::EndOfCandidates
| SdpAttribute::Extmap(..)
| SdpAttribute::ExtmapAllowMixed
| SdpAttribute::Fingerprint(..)
| SdpAttribute::Fmtp(..)
| SdpAttribute::IceMismatch
@ -1293,8 +1328,9 @@ impl FromStr for SdpAttribute {
};
if tokens.len() > 1 {
match name.as_str() {
"bundle-only" | "end-of-candidates" | "ice-lite" | "ice-mismatch" | "inactive"
| "recvonly" | "rtcp-mux" | "rtcp-rsize" | "sendonly" | "sendrecv" => {
"bundle-only" | "end-of-candidates" | "extmap-allow-mixed" | "ice-lite"
| "ice-mismatch" | "inactive" | "recvonly" | "rtcp-mux" | "rtcp-rsize"
| "sendonly" | "sendrecv" => {
return Err(SdpParserInternalError::Generic(format!(
"{} attribute is not allowed to have a value",
name
@ -1309,6 +1345,7 @@ impl FromStr for SdpAttribute {
"end-of-candidates" => Ok(SdpAttribute::EndOfCandidates),
"ice-lite" => Ok(SdpAttribute::IceLite),
"ice-mismatch" => Ok(SdpAttribute::IceMismatch),
"extmap-allow-mixed" => Ok(SdpAttribute::ExtmapAllowMixed),
"ice-pwd" => Ok(SdpAttribute::IcePwd(string_or_empty(val)?)),
"ice-ufrag" => Ok(SdpAttribute::IceUfrag(string_or_empty(val)?)),
"identity" => Ok(SdpAttribute::Identity(string_or_empty(val)?)),
@ -1362,6 +1399,7 @@ impl fmt::Display for SdpAttribute {
SdpAttribute::DtlsMessage(ref a) => attr_to_string(a.to_string()),
SdpAttribute::EndOfCandidates => SdpAttributeType::EndOfCandidates.to_string(),
SdpAttribute::Extmap(ref a) => attr_to_string(a.to_string()),
SdpAttribute::ExtmapAllowMixed => SdpAttributeType::ExtmapAllowMixed.to_string(),
SdpAttribute::Fingerprint(ref a) => attr_to_string(a.to_string()),
SdpAttribute::Fmtp(ref a) => attr_to_string(a.to_string()),
SdpAttribute::Group(ref a) => attr_to_string(a.to_string()),
@ -1427,6 +1465,7 @@ pub enum SdpAttributeType {
DtlsMessage,
EndOfCandidates,
Extmap,
ExtmapAllowMixed,
Fingerprint,
Fmtp,
Group,
@ -1472,6 +1511,7 @@ impl<'a> From<&'a SdpAttribute> for SdpAttributeType {
SdpAttribute::DtlsMessage { .. } => SdpAttributeType::DtlsMessage,
SdpAttribute::EndOfCandidates { .. } => SdpAttributeType::EndOfCandidates,
SdpAttribute::Extmap { .. } => SdpAttributeType::Extmap,
SdpAttribute::ExtmapAllowMixed { .. } => SdpAttributeType::ExtmapAllowMixed,
SdpAttribute::Fingerprint { .. } => SdpAttributeType::Fingerprint,
SdpAttribute::Fmtp { .. } => SdpAttributeType::Fmtp,
SdpAttribute::Group { .. } => SdpAttributeType::Group,
@ -1519,6 +1559,7 @@ impl fmt::Display for SdpAttributeType {
SdpAttributeType::DtlsMessage => "dtls-message",
SdpAttributeType::EndOfCandidates => "end-of-candidates",
SdpAttributeType::Extmap => "extmap",
SdpAttributeType::ExtmapAllowMixed => "extmap-allow-mixed",
SdpAttributeType::Fingerprint => "fingerprint",
SdpAttributeType::Fmtp => "fmtp",
SdpAttributeType::Group => "group",
@ -2405,8 +2446,7 @@ fn parse_image_attr_set(
};
for current_token in tokens {
if current_token.starts_with("sar=") {
let value_token = &current_token[4..];
if let Some(value_token) = current_token.strip_prefix("sar=") {
if value_token.starts_with('[') {
let sar_values = parse_imagettr_braced_token(value_token).ok_or_else(|| {
SdpParserInternalError::Generic(
@ -2450,8 +2490,7 @@ fn parse_image_attr_set(
value_token.parse::<f32>()?,
]))
}
} else if current_token.starts_with("par=") {
let braced_value_token = &current_token[4..];
} else if let Some(braced_value_token) = current_token.strip_prefix("par=") {
if !braced_value_token.starts_with('[') {
return Err(SdpParserInternalError::Generic(
"imageattr's par value must start with '['".to_string(),
@ -2468,8 +2507,8 @@ fn parse_image_attr_set(
min: range.0,
max: range.1,
})
} else if current_token.starts_with("q=") {
q = Some(current_token[2..].parse::<f32>()?);
} else if let Some(qval) = current_token.strip_prefix("q=") {
q = Some(qval.parse::<f32>()?);
}
}
@ -2750,12 +2789,10 @@ fn parse_rid(to_parse: &str) -> Result<SdpAttribute, SdpParserInternalError> {
// The 'pt' parameter must be the first parameter if present, so it
// cannot be checked along with the other parameters below
if let Some(maybe_fmt_parameter) = parameters.clone().peek() {
if maybe_fmt_parameter.starts_with("pt=") {
let fmt_list = maybe_fmt_parameter[3..].split(',');
for fmt in fmt_list {
if let Some(fmt_list) = maybe_fmt_parameter.strip_prefix("pt=") {
for fmt in fmt_list.split(',') {
formats.push(fmt.trim().parse::<u16>()?);
}
parameters.next();
}
}
@ -3614,6 +3651,9 @@ mod tests {
make_check_parse_and_serialize!(check_parse, SdpAttribute::Fmtp);
check_parse_and_serialize("fmtp:109 maxplaybackrate=46000;stereo=1;useinbandfec=1");
check_parse_and_serialize(
"fmtp:126 profile-level-id=42e01f;level-asymmetry-allowed=1;packetization-mode=1",
);
check_parse_and_serialize("fmtp:66 0-15");
check_parse_and_serialize("fmtp:109 0-15,66");
check_parse_and_serialize("fmtp:66 111/115");
@ -3675,10 +3715,10 @@ mod tests {
check_parse_and_serialize("group:BUNDLE sdparta_0 sdparta_1 sdparta_2");
assert!(parse_attribute("group:").is_err());
assert!(match parse_attribute("group:NEVER_SUPPORTED_SEMANTICS") {
Err(SdpParserInternalError::Unsupported(_)) => true,
_ => false,
})
assert!(matches!(
parse_attribute("group:NEVER_SUPPORTED_SEMANTICS"),
Err(SdpParserInternalError::Unsupported(_))
));
}
#[test]
@ -3701,6 +3741,16 @@ mod tests {
assert!(parse_attribute("ice-lite foobar").is_err());
}
#[test]
fn test_parse_attribute_extmap_allow_mixed() {
let check_parse = make_check_parse!(SdpAttribute::ExtmapAllowMixed);
let check_parse_and_serialize = make_check_parse_and_serialize!(check_parse);
check_parse_and_serialize("extmap-allow-mixed");
assert!(parse_attribute("extmap-allow-mixed 100").is_err());
}
#[test]
fn test_parse_attribute_ice_mismatch() {
let check_parse = make_check_parse!(SdpAttribute::IceMismatch);

18
third_party/rust/webrtc-sdp/src/lib.rs поставляемый
Просмотреть файл

@ -42,6 +42,7 @@ use network::{parse_address_type, parse_network_type};
*/
#[derive(Clone)]
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "enhanced_debug", derive(Debug))]
pub enum SdpBandwidth {
As(u32),
Ct(u32),
@ -68,6 +69,7 @@ impl fmt::Display for SdpBandwidth {
*/
#[derive(Clone)]
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "enhanced_debug", derive(Debug))]
pub struct SdpConnection {
pub address: ExplicitlyTypedAddress,
pub ttl: Option<u8>,
@ -97,6 +99,7 @@ impl AnonymizingClone for SdpConnection {
*/
#[derive(Clone)]
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "enhanced_debug", derive(Debug))]
pub struct SdpOrigin {
pub username: String,
pub session_id: u64,
@ -134,6 +137,7 @@ impl AnonymizingClone for SdpOrigin {
*/
#[derive(Clone)]
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "enhanced_debug", derive(Debug))]
pub struct SdpTiming {
pub start: u64,
pub stop: u64,
@ -146,6 +150,7 @@ impl fmt::Display for SdpTiming {
}
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "enhanced_debug", derive(Debug))]
pub enum SdpType {
// Note: Email, Information, Key, Phone, Repeat, Uri and Zone are left out
// on purposes as we don't want to support them.
@ -160,6 +165,7 @@ pub enum SdpType {
}
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "enhanced_debug", derive(Debug))]
pub struct SdpLine {
pub line_number: usize,
pub sdp_type: SdpType,
@ -185,6 +191,7 @@ pub struct SdpLine {
*/
#[derive(Clone)]
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "enhanced_debug", derive(Debug))]
pub struct SdpSession {
pub version: u64,
pub origin: SdpOrigin,
@ -359,7 +366,7 @@ impl SdpSession {
address: addr,
ttl: None,
amount: None,
})?;
});
self.media.push(media);
@ -814,10 +821,9 @@ fn parse_sdp_vector(lines: &mut Vec<SdpLine>) -> Result<SdpSession, SdpParserErr
};
let mut sdp_session = SdpSession::new(version, origin, session);
let _media_pos = lines.iter().position(|ref l| match l.sdp_type {
SdpType::Media(_) => true,
_ => false,
});
let _media_pos = lines
.iter()
.position(|ref l| matches!(l.sdp_type, SdpType::Media(_)));
match _media_pos {
Some(p) => {
@ -1232,7 +1238,7 @@ mod tests {
let mut second_media = create_dummy_media_section();
let mconnection = parse_connection("IN IP4 0.0.0.0")?;
if let SdpType::Connection(c) = mconnection {
second_media.set_connection(c)?;
second_media.set_connection(c);
} else {
unreachable!();
}

43
third_party/rust/webrtc-sdp/src/media_type.rs поставляемый
Просмотреть файл

@ -17,6 +17,7 @@ use {SdpBandwidth, SdpConnection, SdpLine, SdpType};
*/
#[derive(Clone)]
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "enhanced_debug", derive(Debug))]
pub struct SdpMediaLine {
pub media: SdpMediaValue,
pub port: u32,
@ -95,6 +96,7 @@ impl fmt::Display for SdpProtocolValue {
#[derive(Clone)]
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "enhanced_debug", derive(Debug))]
pub enum SdpFormatList {
Integers(Vec<u32>),
Strings(Vec<String>),
@ -121,6 +123,7 @@ impl fmt::Display for SdpFormatList {
*/
#[derive(Clone)]
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "enhanced_debug", derive(Debug))]
pub struct SdpMedia {
media: SdpMediaLine,
connection: Option<SdpConnection>,
@ -223,13 +226,15 @@ impl SdpMedia {
}
self.attribute.retain({
|x| match *x {
SdpAttribute::Rtpmap(_)
| SdpAttribute::Fmtp(_)
| SdpAttribute::Rtcpfb(_)
| SdpAttribute::Sctpmap(_)
| SdpAttribute::SctpPort(_) => false,
_ => true,
|x| {
!matches!(
*x,
SdpAttribute::Rtpmap(_)
| SdpAttribute::Fmtp(_)
| SdpAttribute::Rtcpfb(_)
| SdpAttribute::Sctpmap(_)
| SdpAttribute::SctpPort(_)
)
}
});
}
@ -255,14 +260,8 @@ impl SdpMedia {
&self.connection
}
pub fn set_connection(&mut self, c: SdpConnection) -> Result<(), SdpParserInternalError> {
if self.connection.is_some() {
return Err(SdpParserInternalError::Generic(
"connection type already exists at this media level".to_string(),
));
}
self.connection = Some(c);
Ok(())
pub fn set_connection(&mut self, c: SdpConnection) {
self.connection = Some(c)
}
pub fn add_datachannel(
@ -386,7 +385,7 @@ pub fn parse_media(value: &str) -> Result<SdpType, SdpParserInternalError> {
8 | // PCMA
9 | // G722
13 | // Comfort Noise
96 ..= 127 => (), // dynamic range
35 ..= 63 | 96 ..= 127 => (), // dynamic range
_ => return Err(SdpParserInternalError::Generic(
"format number in media line is out of range".to_string()))
};
@ -433,12 +432,14 @@ pub fn parse_media_vector(lines: &mut Vec<SdpLine>) -> Result<Vec<SdpMedia>, Sdp
let _line_number = line.line_number;
match line.sdp_type {
SdpType::Connection(c) => {
sdp_media
.set_connection(c)
.map_err(|e: SdpParserInternalError| SdpParserError::Sequence {
message: format!("{}", e),
if sdp_media.connection.is_some() {
return Err(SdpParserError::Sequence {
message: "connection type already exists at this media level".to_string(),
line_number: _line_number,
})?
});
}
sdp_media.set_connection(c);
}
SdpType::Bandwidth(b) => sdp_media.add_bandwidth(b),
SdpType::Attribute(a) => {

Просмотреть файл

@ -254,6 +254,7 @@ fn parse_firefox_video_offer() {
o=mozilla...THIS_IS_SDPARTA-52.0a1 506705521068071134 0 IN IP4 0.0.0.0\r\n\
s=-\r\n\
t=0 0\r\n\
a=extmap-allow-mixed\r\n
a=fingerprint:sha-256 CD:34:D1:62:16:95:7B:B7:EB:74:E2:39:27:97:EB:0B:23:73:AC:BC:BF:2F:E3:91:CB:57:A9:9D:4A:A2:0B:40\r\n\
a=group:BUNDLE sdparta_2\r\n\
a=ice-options:trickle\r\n\
@ -284,6 +285,7 @@ a=rtpmap:126 H264/90000\r\n\
a=rtpmap:120 VP8/90000\r\n\
a=rtpmap:97 H264/90000\r\n\
a=setup:actpass\r\n\
a=extmap-allow-mixed\r\n
a=ssrc:2709871439 cname:{735484ea-4f6c-f74a-bd66-7425f8476c2e}";
let sdp_res = webrtc_sdp::parse_sdp(sdp_str, true);
assert!(sdp_res.is_ok());