Buffer splitting logic

Tim Müller tim at centricular.com
Mon Feb 17 10:03:20 UTC 2020


On Sun, 2020-02-16 at 09:15 -0600, tlpl wrote:

Hi Tom,

> My question here is more about logic of data flow than the
> implementation itself. After splitting the original buffer into sub-
> buffers how am I suppose to push / handle multiple resulting buffers
> into next GstElement in the pipeline? I don't mind queuing buffers
> before next element - anything will work. The only problem here is
> producing and pushing multiple buffers from a single element to the
> next.

I'm not entirely sure if I understand the point where you're stuck at
correctly.

There's no problem in principle to do e.g.

GstFlowReturn
your_chain_func (GstPad *pad, GstObject * el, GstBuffer *input_buf)
{
  GstBuffer *out_buf;
  gsize in_size = gst_buffer_get_size (input_buf);

  out_buf = gst_buffer_copy_region (input_buf, ..., 0, in_size / 2);
  flow_ret = gst_pad_push (srcpad, out_buf);
  if (flow_ret != GST_FLOW_OK)
    goto out;

  out_buf = gst_buffer_copy_region (input_buf, ..., in_size / 2, -1);
  flow_ret = gst_pad_push (srcpad, out_buf);

  out:
    gst_buffer_unref (input_buf);
    return flow_ret;
}

(Not saying this is the best or even a good way to do it, just
illustrating conceptually what you can do. You might want to use
GstAdapter instead for example).

Cheers
 Tim

-- 
Tim Müller, Centricular Ltd - http://www.centricular.com



More information about the gstreamer-devel mailing list