Hey,
I’m writing a plugin using the gstreamer rust bindings that is essentially a wrapper around queue
. I am using a gst::Bin
to accomplish this as my goal is to drop buffers based on some custom logic before they are passed on to the child queue element.
I thought about using a probe
, but decided the proxy_chain_function
seemed more appropriate. I may be wrong here, so would be interested to know when to use each?
For context, to hook up the chain function:
fn with_class(klass: &Self::Class) -> Self {
tracing::trace!("with_class");
let ghost_sink_pad =
gst::GhostPad::builder_from_template(&klass.pad_template("sink").unwrap())
.name("sink")
.proxy_pad_chain_function({
move |pad, parent, buffer| {
let parent = parent.and_then(|p| p.parent());
Self::catch_panic_pad_function(
parent.as_ref(),
|| Err(gst::FlowError::Error),
|imp| imp.sink_chain(buffer, pad),
)
.map_err(|flow_err| panic!("{flow_err:?}"))
}
})
.build();
let ghost_src_pad =
gst::GhostPad::builder_from_template(&klass.pad_template("src").unwrap())
.name("src")
.build();
let settings = Settings::default();
let queue = gst::ElementFactory::make("queue")
.property("max-size-buffers", settings.max_size_buffers)
.property_from_str("leaky", &settings.leaky.to_string())
.build()
.unwrap();
Self {
queue,
ghost_sink_pad,
ghost_src_pad,
buffer_state: Arc::new(Mutex::new(BufferState::new(settings.max_rate))),
settings: Arc::new(Mutex::new(settings)),
}
}
when running, I am receiving the error:
(...:195202): GStreamer-CRITICAL **: 01:57:16.607: gst_pad_set_chain_function_full: assertion 'GST_PAD_IS_SINK (pad)' failed
and no buffers are going through the proxy pad function. The pads look to be hooked up correctly, as buffers are definitely leaving the bin and being processed by the subsequent elements.
For context, my bin construction:
fn constructed(&self) {
tracing::trace!("constructed");
self.parent_constructed();
let obj = self.obj();
obj.add(&self.queue).unwrap();
self.ghost_sink_pad
.set_target(Some(&self.queue.static_pad("sink").unwrap()))
.unwrap();
self.ghost_src_pad
.set_target(Some(&self.queue.static_pad("src").unwrap()))
.unwrap();
obj.add_pad(&self.ghost_sink_pad).unwrap();
obj.add_pad(&self.ghost_src_pad).unwrap();
}
}