[gst-devel] creating bins and ghostpads

Rohan rohan at perzonae.com
Thu Sep 24 11:15:57 CEST 2009

Hi all,

I am obviously doing something wrong here, but cannot figure out

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>
   File "stream_receiver.py", line 27, in __init__
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= port=5001 ! "
# pipe="$pipe speexdec ! queue ! alsasink sync=false "

import sys,os
import gobject
import pygst
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()


     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"))
         return bin

if __name__ == "__main__":
     loop = gobject.MainLoop()


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

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
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)

         # local video
         localvidbin = self.build_localvid()


     def build_localvid(self):
         """This bin takes a camera (video) stream and produces a live image
         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"))
         return bin

if __name__ == '__main__':
     loop = gobject.MainLoop()


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,


More information about the gstreamer-devel mailing list