Hi,
Below is my pipeline : v4l2src -> h264parse -> avdec_h264 -> identity ->glupload -> glcolorconvert -> gltransformation -> glimagesink. Based on the user input(keyboard input), I set the property "drop-probability" to 1 or 0. Basically, just toggling it based on the count of input. Now I want to modify the above pipeline, and insert/delete a new element 'imagefreeze' based on the user input. So the new pipeline looks like this : v4l2src -> h264parse -> avdec_h264 -> identity -> imagefreeze -> glupload -> glcolorconvert -> gltransformation -> glimagesink. For this I did the following : 1. I installed a IDLE probe on source pad of identity. 2. And then in the callback, I unlink identity ->glupload, 3. add new element identity and link source pad of identity to sink pad of imagefreeze, 4. also link srcpad of imagefreeze to sink pad of glimagesink. However, I get the following error : idsrcpad.link(ifreeze_sinkpad) File "/usr/lib/python3/dist-packages/gi/overrides/Gst.py", line 162, in link raise LinkError(ret) gi.overrides.Gst.LinkError: <enum GST_PAD_LINK_WRONG_HIERARCHY of type Gst.PadLinkReturn> idsrcpad - the source pad of identity ifreeze_sinkpad - the sinkpad of imagefreeze Here is a snippet from the code: class Thread def __init__(self): thread2 = threading.Thread(target=self.get) thread2.start() def get(self): # apply gltransformation # if user input, && set = True, make "drop-probability = 1" identity.set_property("drop-probability",1) idsrcpad = identity.get_static_pad("src") idsrcpad.add_probe (Gst.PadProbeType.IDLE, self.modify_pipeline) #if user input && set = False, make "drop-probability = 0" ## add code to remove the imagefreeze element, and go back to old pipeline.(pending) def modify_pipeline(pad,info,self): #1.get sink pad of glupload and unlink identity & glupload upload_sinkpad = upload.get_static_pad("sink") idsrcpad.unlink(upload_sinkpad) #2.get new src and sink pad of imagefreeze ifreeze_sinkpad = ifreeze.get_static_pad("sink") ifreeze_srcpad = ifreeze.get_static_pad("src") #3. link identity src pad to imagefreeze sinkpad idsrcpad = identity.get_static_pad("src") idsrcpad.link(ifreeze_sinkpad) #4. link imagefreeze src pad to upload sink pad ifreeze_srcpad.link(upload_sinkpad) return Gst.PadProbeReturn.OK 1. I have tried different ways to solve this issue, but I am unable to find a solution. Does anyone know where I am going wrong. 2. The callback function for add_probe, accepts 2 arguments as per the documentation here <https://valadoc.org/gstreamer-1.0/Gst.PadProbeCallback.html> . However, if I define my callback with only 2 arguments (def modify_pipeline(pad,info))- I get an error saying the callback accepts only 2 arguments, but 3 were provided. The C API of add_probe <https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/GstPad.html#gst-pad-add-probe> defines 3 arguments anyhow. 3. I am also unable to use class members using 'self' inside the callback function. Does anyone have some suggestions? Regards. -- Sent from: http://gstreamer-devel.966125.n4.nabble.com/ _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Hey,
Generally you get "WRONG_HIERARCHY" when you try to link an element that doesn't belong to the pipeline you are tying to link to. I don't see you adding it to the pipeline in that snippet. That needs to be done before you attempt to link it. I'm not sure about the python API, but with the C Api, you need to pass either user_data or a context when you attach the probe, which is probably why self is not working in your method. I would also probably use a static function for the sake of simplicity. Best of luck! On 8/17/2018 4:08 AM, vk_gst wrote: > Hi, > > Below is my pipeline : > v4l2src -> h264parse -> avdec_h264 -> identity ->glupload -> glcolorconvert > -> gltransformation -> glimagesink. > > Based on the user input(keyboard input), I set the property > "drop-probability" to 1 or 0. Basically, just toggling it based on the count > of input. > Now I want to modify the above pipeline, and insert/delete a new element > 'imagefreeze' based on the user input. So the new pipeline looks like this : > v4l2src -> h264parse -> avdec_h264 -> identity -> imagefreeze -> glupload -> > glcolorconvert -> gltransformation -> glimagesink. > > > For this I did the following : > 1. I installed a IDLE probe on source pad of identity. > 2. And then in the callback, I unlink identity ->glupload, > 3. add new element identity and link source pad of identity to sink pad of > imagefreeze, > 4. also link srcpad of imagefreeze to sink pad of glimagesink. > > > However, I get the following error : > > idsrcpad.link(ifreeze_sinkpad) > File "/usr/lib/python3/dist-packages/gi/overrides/Gst.py", line 162, in > link > raise LinkError(ret) > gi.overrides.Gst.LinkError: <enum GST_PAD_LINK_WRONG_HIERARCHY of type > Gst.PadLinkReturn> > > idsrcpad - the source pad of identity > ifreeze_sinkpad - the sinkpad of imagefreeze > > Here is a snippet from the code: > > class Thread > > def __init__(self): > thread2 = threading.Thread(target=self.get) > thread2.start() > > def get(self): > # apply gltransformation > # if user input, && set = True, make "drop-probability = 1" > identity.set_property("drop-probability",1) > idsrcpad = identity.get_static_pad("src") > idsrcpad.add_probe (Gst.PadProbeType.IDLE, self.modify_pipeline) > > #if user input && set = False, make "drop-probability = 0" > ## add code to remove the imagefreeze element, and go back to old > pipeline.(pending) > > def modify_pipeline(pad,info,self): > #1.get sink pad of glupload and unlink identity & glupload > upload_sinkpad = upload.get_static_pad("sink") > idsrcpad.unlink(upload_sinkpad) > #2.get new src and sink pad of imagefreeze > ifreeze_sinkpad = ifreeze.get_static_pad("sink") > ifreeze_srcpad = ifreeze.get_static_pad("src") > #3. link identity src pad to imagefreeze sinkpad > idsrcpad = identity.get_static_pad("src") > idsrcpad.link(ifreeze_sinkpad) > #4. link imagefreeze src pad to upload sink pad > ifreeze_srcpad.link(upload_sinkpad) > > return Gst.PadProbeReturn.OK > > > 1. I have tried different ways to solve this issue, but I am unable to find > a solution. Does anyone know where I am going wrong. > > 2. The callback function for add_probe, accepts 2 arguments as per the > documentation here > <https://valadoc.org/gstreamer-1.0/Gst.PadProbeCallback.html> . However, > if I define my callback with only 2 arguments (def > modify_pipeline(pad,info))- I get an error saying the callback accepts only > 2 arguments, but 3 were provided. The C API of add_probe > <https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/GstPad.html#gst-pad-add-probe> > defines 3 arguments anyhow. > > 3. I am also unable to use class members using 'self' inside the callback > function. Does anyone have some suggestions? > > > Regards. > > > > -- > Sent from: http://gstreamer-devel.966125.n4.nabble.com/ > _______________________________________________ > 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 |
Hi Michael,
My main pipeline consists of the following elements and are linked in the same order: v4l2src -> h264parse -> avdec_h264 -> identity ->glupload -> glcolorconvert -> gltransformation -> glimagesink So when you mean, that element 'imagefreeze' should be a part of the pipeline- do you mean that I add it to the main pipeline and keep it unlinked, and based on the event I break the link between identity and glupload and insert imagefreeze? Well I always thought that all the elements added to the pipeline must be linked before, we set the pipeline to playing. P.S. I have created all the elements before hand, and use them accordingly. -- Sent from: http://gstreamer-devel.966125.n4.nabble.com/ _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Free forum by Nabble | Edit this page |