webrtcsink: fix pipeline when input caps contain max-framerate

GstVideoInfo uses max-framerate to compute its fps, but this leads
to issues in videorate when framerate is actually 0/1.

Fix this by stripping away max-framerate from input caps

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1276>
This commit is contained in:
Mathieu Duponchelle 2023-07-13 22:18:08 +02:00
parent 0331522128
commit 9707bb89e6

View file

@ -3035,7 +3035,18 @@ impl BaseWebRTCSink {
.iter_mut()
.for_each(|(_, stream)| {
if stream.sink_pad.upcast_ref::<gst::Pad>() == pad {
stream.in_caps = Some(e.caps().to_owned());
// We do not want VideoInfo to consider max-framerate
// when computing fps, so we strip it away here
let mut caps = e.caps().to_owned();
{
let mut_caps = caps.get_mut().unwrap();
if let Some(s) = mut_caps.structure_mut(0) {
if s.has_name("video/x-raw") {
s.remove_field("max-framerate");
}
}
}
stream.in_caps = Some(caps.to_owned());
}
});
}