mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-11-26 13:31:00 +00:00
rtp: basedepay: Clean up header extension negotiation
If configuring an existing extension from the new caps fails, remove it and try to request a new extension for it. Also remove all extensions from the list that are not provided in the caps, instead of passing RTP packets to all of them anyway. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1577>
This commit is contained in:
parent
16608d2541
commit
0d33077df6
1 changed files with 37 additions and 27 deletions
|
@ -1448,21 +1448,28 @@ impl RtpBaseDepay2 {
|
||||||
|
|
||||||
let mut extensions = self.extensions.lock().unwrap();
|
let mut extensions = self.extensions.lock().unwrap();
|
||||||
let mut extensions_changed = false;
|
let mut extensions_changed = false;
|
||||||
for (ext_id, uri) in caps_extensions {
|
for (ext_id, uri) in &caps_extensions {
|
||||||
if let Some(extension) = extensions.get(&ext_id) {
|
if let Some(extension) = extensions.get(ext_id) {
|
||||||
if extension.uri().as_deref() == Some(&uri) {
|
if extension.uri().as_deref() == Some(uri) {
|
||||||
// Same extension, nothing to do here, we will update it with the new caps
|
// Same extension, update it with the new caps in case the attributes changed
|
||||||
// later
|
if extension.set_attributes_from_caps(sink_caps) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try to get a new one for this extension ID instead
|
||||||
|
gst::warning!(CAT, imp: self, "Failed to configure extension {ext_id} from caps {sink_caps}");
|
||||||
|
extensions_changed |= true;
|
||||||
|
extensions.remove(ext_id);
|
||||||
|
} else {
|
||||||
|
gst::debug!(
|
||||||
|
CAT,
|
||||||
|
imp: self,
|
||||||
|
"Extension ID {ext_id} changed from {:?} to {uri}",
|
||||||
|
extension.uri(),
|
||||||
|
);
|
||||||
|
extensions_changed |= true;
|
||||||
|
extensions.remove(ext_id);
|
||||||
}
|
}
|
||||||
gst::debug!(
|
|
||||||
CAT,
|
|
||||||
imp: self,
|
|
||||||
"Extension ID {ext_id} changed from {:?} to {uri}",
|
|
||||||
extension.uri(),
|
|
||||||
);
|
|
||||||
extensions_changed |= true;
|
|
||||||
extensions.remove(&ext_id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gst::debug!(CAT, imp: self, "Requesting extension {uri} for ID {ext_id}");
|
gst::debug!(CAT, imp: self, "Requesting extension {uri} for ID {ext_id}");
|
||||||
|
@ -1470,7 +1477,7 @@ impl RtpBaseDepay2 {
|
||||||
.obj()
|
.obj()
|
||||||
.emit_by_name::<Option<gst_rtp::RTPHeaderExtension>>(
|
.emit_by_name::<Option<gst_rtp::RTPHeaderExtension>>(
|
||||||
"request-extension",
|
"request-extension",
|
||||||
&[&(ext_id as u32), &uri],
|
&[&(*ext_id as u32), &uri],
|
||||||
);
|
);
|
||||||
|
|
||||||
let Some(ext) = ext else {
|
let Some(ext) = ext else {
|
||||||
|
@ -1478,26 +1485,29 @@ impl RtpBaseDepay2 {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
if ext.id() != ext_id as u32 {
|
if ext.id() != *ext_id as u32 {
|
||||||
gst::warning!(CAT, imp: self, "Created extension has wrong ID");
|
gst::warning!(CAT, imp: self, "Created extension has wrong ID");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
extensions.insert(ext_id, ext);
|
if !ext.set_attributes_from_caps(sink_caps) {
|
||||||
|
gst::warning!(CAT, imp: self, "Failed to configure extension {ext_id} from caps {sink_caps}");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
extensions.insert(*ext_id, ext);
|
||||||
extensions_changed |= true;
|
extensions_changed |= true;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut to_remove = vec![];
|
// Remove all extensions that are not in the caps
|
||||||
for (ext_id, ext) in extensions.iter() {
|
extensions.retain(|ext_id, _| {
|
||||||
if !ext.set_attributes_from_caps(sink_caps) {
|
if !caps_extensions.contains_key(ext_id) {
|
||||||
gst::warning!(CAT, imp: self, "Failed to configure extension {ext_id} from caps {sink_caps}");
|
extensions_changed = true;
|
||||||
to_remove.push(*ext_id);
|
false
|
||||||
|
} else {
|
||||||
|
true
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
for ext_id in to_remove {
|
|
||||||
extensions.remove(&ext_id);
|
|
||||||
extensions_changed |= true;
|
|
||||||
}
|
|
||||||
drop(extensions);
|
drop(extensions);
|
||||||
|
|
||||||
if extensions_changed {
|
if extensions_changed {
|
||||||
|
|
Loading…
Reference in a new issue