Buffer splitting logic

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Buffer splitting logic

tlpl
Hello everyone,

I am fairly new to GStreamer. Nevertheless, I am currently working on
implementing custom plugin for my small application. I have hit a wall
that's why I decided to ask community for help.

What I would like to achieve in short: after reading some .mp4 file,
demuxing it and being left with "video" (frames) part of, I am trying to
split every single video frame into /n/ sub-frames. After splitting, which
will be done by my custom plugin, all sub-frames are pushed to next element,
which process them one by one and sends them to some sink. When all
sub-frames are processed next batch of sub-frames may be received for
processing. To my current understanding this involves splitting original
buffer in my custom plugin, in /chain/ function, into /n/ sub-frames.

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 hope I made my question clear enough, and haven't missed anything while
searching for an answer before. Any direction, guide or tips will help.
Thank You in advance!

Best,
Tom




--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Buffer splitting logic

Tim Müller
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

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel