write a python source plugin?

Mathias Mathias.Franzius at honda-ri.de
Tue Jul 12 07:07:05 PDT 2011


First, thanks for the constructive comments.
I'm still busy writing my data source in python but the easiest way I have
come across is to extend the videotestsource. Problem was that I cannot
directly subclass it (not wrapped in python?) so I instantiated
videotestsrc via gst.element_factory_make, got its type and extended this:

xxx = gst.element_factory_make("videotestsrc", "video-source")
xclass = type(xxx)

Then, I can change the part where the data is actually created:

class yyy(xclass):
   def do_create(self, offset, length):
        try: self._cnt; # i have no custom constructor, so I have to test if
its here already
        except: self._cnt = 100; self.tic = time.time() # no, instantiate
this here
        origOutStat, origOutBuf = xclass.do_create(self, offset, length)    
#parent output (videotestsrc)
        dat = scipy.zeros(len(origOutBuf),'uint8')   # my dummy output for
testing
        dat[:] = self._cnt   # set to oscillating color, so we see something
changing
        buf = gst.Buffer(dat.ravel()) # overwrite buffer
        self._cnt+=1
        return gst.FLOW_OK, buf

and register it:

gobject.type_register(yyy)
gst.element_register(yyy, 'yyy', gst.RANK_MARGINAL)


This is rather ugly, but I think I can work my way on from here. 

Concerning the "why python" question: 
The comments in the posting above are all correct, additionally it depends
of course on my infrastructure. The data source that generates my images
happens to be in python, so it is the easiest way to stay within python.

Thanks again,
   Mathias

--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/write-a-python-source-plugin-tp3651443p3662390.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.


More information about the gstreamer-devel mailing list