webrtcsrc: add twcc extension to codec-preferences when present

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1245>
This commit is contained in:
Mathieu Duponchelle 2023-06-15 17:28:45 +02:00 committed by GStreamer Marge Bot
parent 02c77d2e44
commit f00a169081

View file

@ -26,6 +26,9 @@ static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| {
) )
}); });
const RTP_TWCC_URI: &str =
"http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01";
struct Settings { struct Settings {
stun_server: Option<String>, stun_server: Option<String>,
signaller: Signallable, signaller: Signallable,
@ -656,7 +659,7 @@ impl WebRTCSrc {
.formats() .formats()
.filter_map(|format| { .filter_map(|format| {
format.parse::<i32>().ok().and_then(|pt| { format.parse::<i32>().ok().and_then(|pt| {
let mediacaps = media.caps_from_media(pt)?; let mut mediacaps = media.caps_from_media(pt)?;
let s = mediacaps.structure(0).unwrap(); let s = mediacaps.structure(0).unwrap();
if !codec_names.contains(s.get::<&str>("encoding-name").ok()?) { if !codec_names.contains(s.get::<&str>("encoding-name").ok()?) {
return None; return None;
@ -671,6 +674,32 @@ impl WebRTCSrc {
} }
})); }));
if media
.attributes_to_caps(mediacaps.get_mut().unwrap())
.is_err()
{
gst::warning!(
CAT,
imp: self,
"Failed to retrieve attributes from media!"
);
return None;
}
let s = mediacaps.structure(0).unwrap();
filtered_s.extend(s.iter().filter_map(|(key, value)| {
if key.starts_with("extmap-") {
if let Ok(s) = value.get::<String>() {
if s == RTP_TWCC_URI {
return Some((key, value.to_owned()));
}
}
}
None
}));
Some(filtered_s) Some(filtered_s)
}) })
}) })