Adding a second output to a custom element
jackBuffington
jbuffington at redzone.com
Tue Feb 4 18:22:30 UTC 2020
I am working on a custom Gstreamer element based on GstBaseTransform. I am
trying to output video on two pads where the video isn't identical (so I
can't use a tee). Additionally, for each buffer that I receive, I want to
send it to only one of the output pads.
I have code that is partially running that creates the extra output pad but
if I try to connect anything to it, it hangs after the first frame. I don't
get any errors but I only get one frame. This code runs if I only connect
to one of the pads. I was expecting that it would run but that the second
output would be blank since I am not specifically sending buffers to it.
I'll try to give relevant info below.
I am using gst-launch-1.0 and am not specifying pads by name when connecting
things up. Everything after the source pads is identical.
*It seems that I need to create a second template for my pad or else I just
end up with a single output pad:*
static GstStaticPadTemplate laserSrcTemplate = GST_STATIC_PAD_TEMPLATE
("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS("video/x-raw,format=UYVY")
);
*In my class_init, I have to add one of my output pads. I believe that I
tested adding it later but I was getting a compilation warning. *
gst_element_class_add_static_pad_template (element_class, &srcTemplate);
*In my element_init I can add the second pad:*
lfselement->laserSrcPad = gst_pad_new_from_static_template
(&laserSrcTemplate, "laser");
gst_element_add_pad (GST_ELEMENT (lfselement), lfselement->laserSrcPad);
*I am using the transform function which is defined as:*
static GstFlowReturn gst_lfselement_transform (GstBaseTransform *trans,
GstBuffer *inbuf, GstBuffer *outbuf)
*I am mapping my in buffer and out buffers (error checking not shown)*
gst_buffer_map (inbuf, &inMap, GST_MAP_READ);
gst_buffer_map (outbuf, &outMap, GST_MAP_WRITE);
* I get pointers to the actual video data:*
guint8 *dest;
guint8 *src;
dest = outMap.data;
src = inMap.data;
* I draw onto the buffer without changing its size and then unmap the
buffers*
// Drawing code not shown
gst_buffer_unmap (outbuf, &outMap);
gst_buffer_unmap (inbuf, &inMap);
I then just return GST_FLOW_OK. *
I'm not specifying where the data goes so I'm guessing that it defaults to
the first pad created or possibly to a pad named 'src'
My questions are:
* How do I make it so that things don't hang?
* Do I need to add some function to deal with the second pad?
* How do I specify which pad to send the data to? I'm guessing that I need
to use gst_pad_push() somehow but haven't made it that far to check.
Any help would be greatly appreciated.
--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
More information about the gstreamer-devel
mailing list