home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / gst-python / 0.10 / examples / sinkelement.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-04-20  |  1.9 KB  |  43 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import pygst
  5. pygst.require('0.10')
  6. import gst
  7. import gobject
  8. gobject.threads_init()
  9.  
  10. class MySink(gst.Element):
  11.     _sinkpadtemplate = gst.PadTemplate('sinkpadtemplate', gst.PAD_SINK, gst.PAD_ALWAYS, gst.caps_new_any())
  12.     
  13.     def __init__(self):
  14.         gst.Element.__init__(self)
  15.         gst.info('creating sinkpad')
  16.         self.sinkpad = gst.Pad(self._sinkpadtemplate, 'sink')
  17.         gst.info('adding sinkpad to self')
  18.         self.add_pad(self.sinkpad)
  19.         gst.info('setting chain/event functions')
  20.         self.sinkpad.set_chain_function(self.chainfunc)
  21.         self.sinkpad.set_event_function(self.eventfunc)
  22.  
  23.     
  24.     def chainfunc(self, pad, buffer):
  25.         self.info('%s timestamp(buffer):%d' % (pad, buffer.timestamp))
  26.         return gst.FLOW_OK
  27.  
  28.     
  29.     def eventfunc(self, pad, event):
  30.         self.info('%s event:%r' % (pad, event.type))
  31.         return True
  32.  
  33.  
  34. gobject.type_register(MySink)
  35. src = gst.element_factory_make('fakesrc')
  36. gst.info('About to create MySink')
  37. sink = MySink()
  38. pipeline = gst.Pipeline()
  39. pipeline.add(src, sink)
  40. src.link(sink)
  41. pipeline.set_state(gst.STATE_PLAYING)
  42. gobject.MainLoop().run()
  43.