[gst-devel] creating bins and ghostpads

Rohan rohan at perzonae.com
Fri Sep 25 10:36:54 CEST 2009


Aurelien Grimaud wrote:
> Add vidsource in pipeline ?
> 

Oh lord, how embarrassing.

Thanks, that is exactly what the problem was.

Thanks again,

Rohan

> Rohan a écrit :
>> Hi all,
>>
>> I am obviously doing something wrong here, but cannot figure out
>> what.
>>
>> Essentially the pipeline is the same as the receiver but I have broken
>> it into bins.  I seem to be having problems with the ghostpad, because
>> I get this error:
>>
>> (stream_receiver.py:1914): GStreamer-WARNING **: Trying to connect elements that
>> don't share a common ancestor: vidsource and vidbin
>>
>> Traceback (most recent call last):
>>    File "stream_receiver.py", line 118, in <module>
>>      server()
>>    File "stream_receiver.py", line 27, in __init__
>>      vidsource.link(vidbin)
>> gst.LinkError: failed to link vidsource with vidbin
>>
>> Here is the code:
>>
>> ----------------------------------------------------------------------
>> #!/bin/env python
>>
>> # The gst pipeline
>> # pipe="udpsrc port=5000 ! smokedec ! autovideosink"
>> # # audio
>> # pipe="$pipe tcpclientsrc host=127.0.0.1 port=5001 ! "
>> # pipe="$pipe speexdec ! queue ! alsasink sync=false "
>>
>> import sys,os
>> import gobject
>> import pygst
>> pygst.require("0.10")
>> import gst
>>
>> class server (object):
>>      def __init__(self):
>>          # start with video
>>
>>          self.pipe = gst.Pipeline("player")
>>
>>          # video source
>>          vidsource = gst.element_factory_make("udpsrc", "vidsource")
>>          vidsource.set_property("port", 5000)
>>
>>          vidbin = self.buildvid()
>>          self.pipe.add(vidbin)
>>          vidsource.link(vidbin)
>>
>>
>>          self.pipe.set_state(gst.STATE_PLAYING)
>>
>>      def buildvid(self):
>>          bin = gst.Bin("vidbin")
>>          queue = gst.element_factory_make("queue")
>>          smokedec = gst.element_factory_make("smokedec")
>>          vidsink = gst.element_factory_make("autovideosink")
>>          bin.add(queue, smokedec, vidsink)
>>          gst.element_link_many(queue, smokedec, vidsink)
>>
>>          # ghostpad
>>          binsink = gst.GhostPad("binsink", queue.get_pad("sink"))
>>          bin.add_pad(binsink)
>>          return bin
>>
>> if __name__ == "__main__":
>>      server()
>>      loop = gobject.MainLoop()
>>      loop.run()
>>
>> ----------------------------------------------------------------------------
>>
>> What is driving me slightly nuts is that if I put all the buildvid code
>> into init and have a long series of object instatiations with add to
>> pipeline and link it works, but as soon as I started messing with
>> ghostpads and bin (which makes the code much more manageable when
>> adding functionality for windows and macs) this messed up.  Below is
>> more code that works, and I cannot figure out why this and why not
>> that.
>>
>> And the other thing is this does work in a commandline pipeline such
>> as the one sitting at the top of the script in comments.
>>
>> I am using the same system for the sender, but I'll only include the
>> local display.  This sends an image happily, using the build_localvid
>> bin, and linking it to the camera.
>>
>> -----------------------------------------------------------------------------
>> #!/bin/env python
>>
>> import sys, os
>> import gobject
>> import pygst
>> pygst.require("0.10")
>> import gst
>>
>> class client(object):
>>
>>      def __init__(self):
>>          self.pipe = gst.Pipeline("sender")
>>
>>          # Initial video input
>>          camera = gst.element_factory_make("v4l2src", "camera")
>>          vidtee = gst.element_factory_make("tee", "vidtee")
>>          self.pipe.add(camera, vidtee)
>>          camera.link(vidtee)
>>
>>          # local video
>>          localvidbin = self.build_localvid()
>>          self.pipe.add(localvidbin)
>>          vidtee.link(localvidbin)
>>
>>          self.pipe.set_state(gst.STATE_PLAYING)
>>
>>      def build_localvid(self):
>>          """This bin takes a camera (video) stream and produces a live image
>> locally."""
>>          bin = gst.Bin("localvid")
>>          queue = gst.element_factory_make("queue")
>>          out = gst.element_factory_make("xvimagesink")
>>          bin.add(out, queue)
>>          queue.link_pads("src", out, "sink")
>>          binsink = gst.GhostPad("binsink", queue.get_pad("sink"))
>>          bin.add_pad(binsink)
>>          return bin
>>
>> if __name__ == '__main__':
>>      client()
>>      loop = gobject.MainLoop()
>>      loop.run()
>>
>> ---------------------------------------------------------------------------
>>
>> This does the correct thing, and I get a live image from the camera.
>>
>> I am completely stumped on this one, and have resorted to using
>> gst.parse_bin_from_description() with the gst-launch pipeline, but
>> this is far from ideal from a maintenance perspective. :)
>>
>> I am sure I am missing something pretty obvious, but so far flailing
>> around in my ignorance has not let me stumble on a solution.
>>
>> Thanks for any help,
>>
>> Rohan
>>
>>
>> ------------------------------------------------------------------------------
>> Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
>> is the only developer event you need to attend this year. Jumpstart your
>> developing skills, take BlackBerry mobile applications to market and stay 
>> ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
>> http://p.sf.net/sfu/devconf
>> _______________________________________________
>> gstreamer-devel mailing list
>> gstreamer-devel at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>>
>>
>>   
> 
> 
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay 
> ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
> http://p.sf.net/sfu/devconf
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel





More information about the gstreamer-devel mailing list