mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-24 02:31:03 +00:00
a37dede09c
Original commit message from CVS: * examples/gstreamer/filesrc.py,player.py: New examples * gstreamer/gstreamer.override: Add a dict like interface to GstTagList * gstreamer/gstpad-handlers.override: New file, split out from gstreamer.override * gstreamer/gst-types.defs: Don't use gst_buffer_free/gst_data_free, use gst_data_unref instead. * gstreamer/gst-types.c (PyGstData_to_value): Don't send address here. * gstreamer/arg-types.py (GstDataPtrArg.write_param): Send the address to stuff, since we really want to avoid segfaults :) * gstreamer/0.6.[c,defs,h,override]: Remove, we're focusing on 0.7 * gstreamer/0.7.[c,defs,h,override]: Remove, merge with gstreamer.* * gstreamer/Makefile.am: Clean up, remove versioning support.
91 lines
2.5 KiB
Python
Executable file
91 lines
2.5 KiB
Python
Executable file
#!/usr/bin/env python
|
|
#
|
|
# gst-python
|
|
# Copyright (C) 2002 David I. Lehn
|
|
# 2004 Johan Dahlin
|
|
#
|
|
# 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.
|
|
#
|
|
# Author: David I. Lehn <dlehn@users.sourceforge.net>
|
|
#
|
|
|
|
import sys
|
|
import gobject
|
|
import gst
|
|
|
|
class Identity(gst.Element):
|
|
def __init__(self):
|
|
self.__gobject_init__()
|
|
self.sinkpad = gst.Pad('sink', gst.PAD_SINK)
|
|
self.add_pad(self.sinkpad)
|
|
self.sinkpad.set_chain_function(self.chain)
|
|
self.sinkpad.set_link_function(self.pad_link)
|
|
|
|
self.srcpad = gst.Pad('src', gst.PAD_SRC)
|
|
self.add_pad(self.srcpad)
|
|
self.srcpad.set_link_function(self.pad_link)
|
|
|
|
def get_bufferpool(self, pad):
|
|
print 'get_bufferpool:', self, pad
|
|
return self.srcpad.get_bufferpool()
|
|
|
|
def pad_link(self, pad, caps):
|
|
print 'pad_link:', self, pad, caps
|
|
return gst.PAD_LINK_OK
|
|
|
|
def chain(self, pad, buf):
|
|
self.srcpad.push(buf)
|
|
|
|
gobject.type_register(Identity)
|
|
|
|
def filter(element):
|
|
# create a new bin to hold the elements
|
|
bin = gst.Pipeline('pipeline')
|
|
|
|
filesrc = gst.Element('sinesrc', 'source');
|
|
filesink = gst.Element('fakesink', 'sink')
|
|
|
|
stats = gst.Element('statistics', 'stats');
|
|
stats.set_property('silent', False)
|
|
stats.set_property('buffer_update_freq', True)
|
|
stats.set_property('update_on_eos', True)
|
|
|
|
bin.add_many(filesrc, element, stats, filesink)
|
|
gst.element_link_many(filesrc, element, stats, filesink)
|
|
|
|
# start playing
|
|
bin.set_state(gst.STATE_PLAYING);
|
|
|
|
while bin.iterate():
|
|
pass
|
|
|
|
# stop the bin
|
|
bin.set_state(gst.STATE_NULL)
|
|
|
|
def main(args):
|
|
"A GStreamer Python subclassing example of an identity filter"
|
|
|
|
identity = Identity()
|
|
identity.set_name('identity')
|
|
if not identity:
|
|
print 'could not create \"Identity\" element'
|
|
return -1
|
|
|
|
return filter(identity)
|
|
|
|
if __name__ == '__main__':
|
|
sys.exit(main(sys.argv))
|
|
|