Skip to content

Commit

Permalink
The gstreamer plugin should resize when it's presented with frames to…
Browse files Browse the repository at this point in the history
… fill, not when caps are set
  • Loading branch information
Alan Jeffrey committed Nov 25, 2019
1 parent 49841b8 commit 2356f3e
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions ports/gstplugin/servosrc.rs
Expand Up @@ -485,11 +485,6 @@ impl BaseSrcImpl for ServoSrc {
fn set_caps(&self, _src: &BaseSrc, outcaps: &Caps) -> Result<(), LoggableError> {
let info = VideoInfo::from_caps(outcaps)
.ok_or_else(|| gst_loggable_error!(CATEGORY, "Failed to get video info"))?;
let size = Size2D::new(info.width(), info.height()).to_i32();
debug!("Setting servosrc buffer size to {}", size,);
self.sender
.send(ServoSrcMsg::Resize(size))
.map_err(|_| gst_loggable_error!(CATEGORY, "Failed to send video info"))?;
*self.info.lock().unwrap() = Some(info);
Ok(())
}
Expand Down Expand Up @@ -534,6 +529,7 @@ impl BaseSrcImpl for ServoSrc {
})?;
let height = frame.height() as i32;
let width = frame.width() as i32;
let size = Size2D::new(width, height);
let format = frame.format();
debug!(
"Filling servosrc buffer {}x{} {:?} {:?}",
Expand All @@ -545,6 +541,13 @@ impl BaseSrcImpl for ServoSrc {
let mut gfx = gfx.borrow_mut();
let gfx = &mut *gfx;
if let Some(surface) = self.swap_chain.take_surface() {
let surface_size = Size2D::from_untyped(gfx.device.surface_info(&surface).size);
if size != surface_size {
// If we're being asked to fill frames that are a different size than servo is providing,
// ask it to change size.
let _ = self.sender.send(ServoSrcMsg::Resize(size));
}

gfx.device.make_context_current(&gfx.context).unwrap();
debug_assert_eq!(
(
Expand Down

0 comments on commit 2356f3e

Please sign in to comment.