GNOME Bugzilla – Bug 346666
A test filter element in gst-python
Last modified: 2012-12-17 11:32:17 UTC
I'm attempting to create a regular filter type element with gst-python. Here is my fist attempt at writing a plain passthru filter. I was not quite sure how the GstElementDetails part translated into the python binding. Am I on the right track? ___________________________________________________________________________ import pygst #pygst.require('0.10') import gst import gobject class TestFilter(gst.Element): _srcpadtemplate = gst.PadTemplate ("srcpadtemplate", gst.PAD_SRC, gst.PAD_ALWAYS, gst.caps_new_any()) _sinkpadtemplate = gst.PadTemplate ("sinkpadtemplate", gst.PAD_SINK, gst.PAD_ALWAYS, gst.caps_new_any()) def __init__(self): gst.Element.__init__(self) self.srcpad = gst.Pad(self._srcpadtemplate, "src") self.inkpad = gst.Pad(self._sinkpadtemplate, "sink") self.add_pad(self.srcpad) self.add_pad(self.sinkpad) self.sinkpad.set_chain_function(self.chainfunc) self.sinkpad.set_event_function(self.eventfunc) def chainfunc(self, pad, buffer): return self.sinkpad.push(buffer) def eventfunc(self, pad, event): return self.sinkpad.push(buffer) gobject.type_register(TestFilter) ------------------------------------------------------------------------------
Had a few typos. Fixed them, and attempted to stream a v4l src through it. I get the following error after the 2nd data event. (helloworld.py:1176): GStreamer-CRITICAL **: gst_pad_push: assertion `GST_PAD_DIRECTION (pad) == GST_PAD_SRC' failed here's the revised code ------------------------------------------------------------------------------- import pygst #pygst.require('0.10') import gst import gobject class TestFilter(gst.Element): _srcpadtemplate = gst.PadTemplate ("srcpadtemplate", gst.PAD_SRC, gst.PAD_ALWAYS, gst.caps_new_any()) _sinkpadtemplate = gst.PadTemplate ("sinkpadtemplate", gst.PAD_SINK, gst.PAD_ALWAYS, gst.caps_new_any()) def __init__(self, name): gst.Element.__init__(self) self.set_name(name) self.srcpad = gst.Pad(self._srcpadtemplate, "src") self.sinkpad = gst.Pad(self._sinkpadtemplate, "sink") self.add_pad(self.srcpad) self.add_pad(self.sinkpad) self.sinkpad.set_chain_function(self.chainfunc) self.sinkpad.set_event_function(self.eventfunc) def chainfunc(self, pad, buffer): return self.sinkpad.push(buffer) def eventfunc(self, pad, event): return self.sinkpad.push(buffer) gobject.type_register(TestFilter) -------------------------------------------------------------------------------
Alright, so despite one setback of minor idiocy, here is the truly working code. HOWEVER, I believe that it should probably contain some more general information, as in setting the element details, etc ... Also need to add in an example of setting caps, etc ... How's it look? ------------------------------------------------------------------------------- import pygst #pygst.require('0.10') import gst import gobject class TestFilter(gst.Element): _srcpadtemplate = gst.PadTemplate ("srcpadtemplate", gst.PAD_SRC, gst.PAD_ALWAYS, gst.caps_new_any()) _sinkpadtemplate = gst.PadTemplate ("sinkpadtemplate", gst.PAD_SINK, gst.PAD_ALWAYS, gst.caps_new_any()) def __init__(self, name): gst.Element.__init__(self) self.set_name(name) self.srcpad = gst.Pad(self._srcpadtemplate, "src") self.sinkpad = gst.Pad(self._sinkpadtemplate, "sink") self.add_pad(self.srcpad) self.add_pad(self.sinkpad) self.sinkpad.set_chain_function(self.chainfunc) self.sinkpad.set_event_function(self.eventfunc) def chainfunc(self, pad, buffer): return self.srcpad.push(buffer) def eventfunc(self, pad, event): return self.srcpad.push_event(event) gobject.type_register(TestFilter) ------------------------------------------------------------------------------
This is a good skeleton, but it's missing some *functionnality* :) If it's a filter, you might want to use gst.BaseTransform , which makes the code smaller. In order to show it's working, you could put some debugging in the code, so that when you run it with GST_DEBUG=python:5 you can see what it's doing. That would make the example even more interesting for people trying to understand how it works.
Any progress on this? Is this still needed/wanted?
Who is going to take a final call here so that bug can be moved to right status (close the bug or keep it open) ? IMHO, it won't be a good move to close enhancement bug without any fair reason.
Reopening so that the maintainers can see and decide on it.
Closing this bug now, gst-python is only an extension module to pygi now and this bug doesn't make much sense anymore in this context.