How to make custom element with multiple outputs?

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

How to make custom element with multiple outputs?

jackBuffington
I have a custom element that I have written that currently is using a 'transform' (as opposed to transform_ip' function to manipulate video and then output it.  The output video is the same size and in the same format as the input video.  That part is working great.  

I would now like to modify the element so that it has two outputs where it decides on a frame-by frame basis whether to push the buffer to output #1 or output #2.  Both of those outputs would be the same size and format as the input. I have working code that can determine which type of frame I am looking at so the only issue I am having is making my buffer go to one pad or the other.  I've tried a number of things and am not succeeding. 

Is there a good/bad/ugly element that I can reference to help with this?   I've looked through them but don't see anything that looks like it might help.  

Alternately, could someone here describe what is necessary to make this happen?  Example code would be great but even a high-level description would help.  

 

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

Re: How to make custom element with multiple outputs?

Roland Peffer-2
Hi,

did you check the sources of the GstOutputSelector plugin?

Regards
Roland

On 1. Apr 2020, at 15:56, Jack Buffington <[hidden email]> wrote:

I have a custom element that I have written that currently is using a 'transform' (as opposed to transform_ip' function to manipulate video and then output it.  The output video is the same size and in the same format as the input video.  That part is working great.  

I would now like to modify the element so that it has two outputs where it decides on a frame-by frame basis whether to push the buffer to output #1 or output #2.  Both of those outputs would be the same size and format as the input. I have working code that can determine which type of frame I am looking at so the only issue I am having is making my buffer go to one pad or the other.  I've tried a number of things and am not succeeding. 

Is there a good/bad/ugly element that I can reference to help with this?   I've looked through them but don't see anything that looks like it might help.  

Alternately, could someone here describe what is necessary to make this happen?  Example code would be great but even a high-level description would help.  

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


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

Re: How to make custom element with multiple outputs?

jackBuffington
That was helpful Roland.  Thanks.  

From that example, I figured out how to implement the chain function.  My
code is now running with it but I still have problems.   I have three
outputs at the moment: 'src', 'laser', and 'RGB'.  If I make my chain
function have this line:

GstFlowReturn res = gst_pad_push (filter->srcPad, buf);

and connect the next element in my graph to the 'src' pad (ignoring the
others for now) then my video comes out to the screen just fine.  

If I swap that line for the one below
GstFlowReturn res = gst_pad_push (filter->laserPad, buf);

and connect to the 'laser' pad,  then it still compiles fine but when I use
gst-launch-1.0 to test it, res is assigned -4, which corresponds to 'not
negotiated'.  

I didn't have a transform_caps function in my code as I do on other elements
that I have written so I added one that just returns the same caps that are
given to it.    This is the function that assists with caps negotiation.  I
figured that this would fix things but it didn't.  My transform_caps and
set_caps functions are pretty verbose.  I can see that caps ARE being
negotiated when I am connected to either pad and the negotiation is
identical.  With transform_caps, it still works if I connect to 'src' but
not if I connect to 'laser'.

Any ideas about why things aren't working?  Here is the output when I run
it:

<snip>
Setting pipeline to PLAYING ...
New clock: GstSystemClock
gst_lfselement_chain0  *These two lines just help me see where it is in the
code*
gst_lfselement_chain1
The result of pad_push for laserPad: -4 *Here it just tried to push to the
laser pin*
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal
data stream error.
Additional debug info:
gstbasesrc.c(3055): gst_base_src_loop ():
/GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
streaming stopped, reason not-negotiated (-4)




--
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: How to make custom element with multiple outputs?

jackBuffington
One thing that I should add is that I am creating src, laser, and RGB from
the same template.  The caps are identical on all three.



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel