2002-10-03 22:11:37 +00:00
|
|
|
#!/usr/bin/env python
|
2002-03-27 11:09:40 +00:00
|
|
|
#
|
|
|
|
# gst-python
|
|
|
|
# Copyright (C) 2002 David I. Lehn
|
|
|
|
#
|
|
|
|
# This library is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU Library General Public
|
|
|
|
# License as published by the Free Software Foundation; either
|
|
|
|
# version 2 of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This library is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# Library General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Library General Public
|
|
|
|
# License along with this library; if not, write to the
|
|
|
|
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
# Boston, MA 02111-1307, USA.
|
|
|
|
#
|
2002-12-17 17:40:42 +00:00
|
|
|
# Author: David I. Lehn <dlehn@users.sourceforge.net>
|
2002-03-27 11:09:40 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
import sys
|
|
|
|
from gstreamer import *
|
|
|
|
import gobject
|
|
|
|
from cp import filter
|
|
|
|
|
|
|
|
class Identity(Element):
|
|
|
|
def __init__(self):
|
|
|
|
self.__gobject_init__()
|
2002-10-03 22:11:37 +00:00
|
|
|
self.sinkpad = Pad('sink', PAD_SINK)
|
2002-03-27 11:09:40 +00:00
|
|
|
self.add_pad(self.sinkpad)
|
|
|
|
self.sinkpad.set_chain_function(self.chain)
|
2003-01-10 00:18:33 +00:00
|
|
|
self.sinkpad.set_link_function(self.pad_link)
|
2002-03-27 11:09:40 +00:00
|
|
|
|
2002-10-03 22:11:37 +00:00
|
|
|
self.srcpad = Pad('src', PAD_SRC)
|
2002-03-27 11:09:40 +00:00
|
|
|
self.add_pad(self.srcpad)
|
2003-01-10 00:18:33 +00:00
|
|
|
self.srcpad.set_link_function(self.pad_link)
|
2002-03-27 11:09:40 +00:00
|
|
|
|
|
|
|
def get_bufferpool(self, pad):
|
|
|
|
print 'get_bufferpool:', self, pad
|
|
|
|
return self.srcpad.get_bufferpool()
|
|
|
|
|
2003-01-10 00:18:33 +00:00
|
|
|
def pad_link(self, pad, caps):
|
|
|
|
print 'pad_link:', self, pad, caps
|
|
|
|
return PAD_LINK_OK
|
2002-03-27 11:09:40 +00:00
|
|
|
|
|
|
|
def chain(self, pad, buf):
|
|
|
|
self.srcpad.push(buf)
|
|
|
|
|
|
|
|
gobject.type_register(Identity)
|
|
|
|
|
|
|
|
def main():
|
|
|
|
"A GStreamer Python subclassing example of an identity filter"
|
2002-10-03 22:11:37 +00:00
|
|
|
gst_debug_set_categories(0L)
|
2002-03-27 11:09:40 +00:00
|
|
|
|
|
|
|
identity = Identity()
|
|
|
|
identity.set_name('identity')
|
|
|
|
if not identity:
|
|
|
|
print 'could not create \"Identity\" element'
|
|
|
|
return -1
|
|
|
|
|
|
|
|
return filter([identity])
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
ret = main()
|
|
|
|
sys.exit (ret)
|