After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 346666 - A test filter element in gst-python
A test filter element in gst-python
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: gst-python
0.10.4
Other Linux
: Normal enhancement
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2006-07-05 16:14 UTC by Corey O.
Modified: 2012-12-17 11:32 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Corey O. 2006-07-05 16:14:31 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)

------------------------------------------------------------------------------
Comment 1 Corey O. 2006-07-05 16:34:41 UTC
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)

-------------------------------------------------------------------------------
Comment 2 Corey O. 2006-07-05 17:27:22 UTC
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)

------------------------------------------------------------------------------
Comment 3 Edward Hervey 2006-10-20 08:49:55 UTC
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.
Comment 4 Sebastian Dröge (slomo) 2011-05-18 12:15:39 UTC
Any progress on this? Is this still needed/wanted?
Comment 5 Akhil Laddha 2011-07-01 05:05:48 UTC
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.
Comment 6 Tobias Mueller 2011-10-04 13:34:49 UTC
Reopening so that the maintainers can see and decide on it.
Comment 7 Sebastian Dröge (slomo) 2012-12-17 11:32:17 UTC
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.