3 # vi:si:et:sw=4:sts=4:ts=4
6 # (c) 2005 Edward Hervey <edward@fluendo.com>
9 # Small test application to show how to write a sink element
10 # in 20 lines in python
12 # Run this script with GST_DEBUG=python:5 to see the debug
19 gobject.threads_init ()
22 # Simple Sink element created entirely in python
25 class MySink(gst.Element):
27 _sinkpadtemplate = gst.PadTemplate ("sinkpadtemplate",
33 gst.Element.__init__(self)
34 gst.info('creating sinkpad')
35 self.sinkpad = gst.Pad(self._sinkpadtemplate, "sink")
36 gst.info('adding sinkpad to self')
37 self.add_pad(self.sinkpad)
39 gst.info('setting chain/event functions')
40 self.sinkpad.set_chain_function(self.chainfunc)
41 self.sinkpad.set_event_function(self.eventfunc)
43 def chainfunc(self, pad, buffer):
44 self.info("%s timestamp(buffer):%d" % (pad, buffer.timestamp))
47 def eventfunc(self, pad, event):
48 self.info("%s event:%r" % (pad, event.type))
51 gobject.type_register(MySink)
54 # Code to test the MySink class
57 src = gst.element_factory_make('fakesrc')
58 gst.info('About to create MySink')
61 pipeline = gst.Pipeline()
62 pipeline.add(src, sink)
66 pipeline.set_state(gst.STATE_PLAYING)
68 gobject.MainLoop().run()