I need to randomly access image data in a running pipeline. Something like gst_base_sink_get_last_sample()
but not for a sink element placed at the end of the pipeline. I need to inspect passing data in the middle of the pipeline while running, for example inspect the input buffer to the glupload. I also can not add tee
to the pipeline to make a fork and send that to fakesink as tee
has overheads of data copy for each frame. Is there any method I can use to extract current buffer/memory/sample of data in a PLAYING
element in gstreamer pipeline?
Thanks to @FlorianZwoch, I made it using pad probe. Every time I need to get access to data to probe it, I add a probe to any pad I want like this:
GstPad* pad = gst_element_get_static_pad(v4l2convert, "src");
gst_pad_add_probe(pad, GST_PAD_PROBE_TYPE_BUFFER, probe_callback, NULL, NULL);
gst_object_unref(pad);
and then in the callback function I can access data using these lines of code:
GstPadProbeReturn Gstreamer::probe_callback(
GstPad* pad, GstPadProbeInfo* info, gpointer user_data)
{
Q_UNUSED(user_data);
gst_println("callback called");
GstBuffer* buffer = gst_pad_probe_info_get_buffer(info); // No need to unref later [see docs]
GstCaps* caps = gst_pad_get_current_caps(pad);
if (!buffer || !caps)
{
g_printerr("Probe callback failed to fetch valid data.");
goto label_return;
}
// Consume data here
return GST_PAD_PROBE_REMOVE;
}