Do not reset caps when they do not change

Otherwise a useless renegotiation will be triggered by capsfilter
This commit is contained in:
Thibault Saunier 2022-02-11 19:50:13 +00:00 committed by Mathieu Duponchelle
parent 55d30db53b
commit 9285798210

View file

@ -538,12 +538,8 @@ impl VideoEncoder {
_ => unreachable!(), _ => unreachable!(),
} }
let mut s = self let current_caps = self.filter.property::<gst::Caps>("caps");
.filter let mut s = current_caps.structure(0).unwrap().to_owned();
.property::<gst::Caps>("caps")
.structure(0)
.unwrap()
.to_owned();
// Hardcoded thresholds, may be tuned further in the future, and // Hardcoded thresholds, may be tuned further in the future, and
// adapted according to the codec in use // adapted according to the codec in use
@ -587,17 +583,19 @@ impl VideoEncoder {
.structure(s) .structure(s)
.build(); .build();
gst_log!( if !caps.is_strictly_equal(&current_caps) {
CAT, gst_log!(
obj: element, CAT,
"consumer {}: setting bitrate {} and caps {} on encoder {:?}", obj: element,
self.peer_id, "consumer {}: setting bitrate {} and caps {} on encoder {:?}",
bitrate, self.peer_id,
caps, bitrate,
self.element caps,
); self.element
);
self.filter.set_property("caps", caps); self.filter.set_property("caps", caps);
}
} }
fn gather_stats(&self) -> gst::Structure { fn gather_stats(&self) -> gst::Structure {