2002-10-03 22:11:37 +00:00
|
|
|
#!/usr/bin/env python
|
2002-03-24 11:41:24 +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-24 11:41:24 +00:00
|
|
|
#
|
2002-03-24 07:49:36 +00:00
|
|
|
|
|
|
|
from gobject import GObject
|
|
|
|
from gstreamer import *
|
|
|
|
|
|
|
|
def handoff(sender, *args):
|
|
|
|
print sender.get_name(), args
|
|
|
|
|
|
|
|
def main():
|
|
|
|
# create a new bin to hold the elements
|
|
|
|
#gst_debug_set_categories(-1)
|
2002-10-03 22:11:37 +00:00
|
|
|
bin = Pipeline('pipeline')
|
2002-03-24 07:49:36 +00:00
|
|
|
assert bin
|
|
|
|
|
2003-10-04 23:02:48 +00:00
|
|
|
src = Element('fakesrc', 'src')
|
2003-01-10 00:18:33 +00:00
|
|
|
src.connect('handoff', handoff)
|
2002-03-24 07:49:36 +00:00
|
|
|
src.set_property('silent', 1)
|
|
|
|
src.set_property('num_buffers', 10)
|
|
|
|
|
2003-10-04 23:02:48 +00:00
|
|
|
sink = Element('fakesink', 'sink')
|
2003-01-10 00:18:33 +00:00
|
|
|
sink.connect('handoff', handoff)
|
2002-03-24 07:49:36 +00:00
|
|
|
src.set_property('silent', 1)
|
|
|
|
|
|
|
|
# add objects to the main pipeline
|
|
|
|
for e in (src, sink):
|
|
|
|
bin.add(e)
|
|
|
|
|
2003-01-10 00:18:33 +00:00
|
|
|
# link the elements
|
|
|
|
res = src.link(sink)
|
2002-03-24 07:49:36 +00:00
|
|
|
assert res
|
|
|
|
|
|
|
|
# start playing
|
|
|
|
res = bin.set_state(STATE_PLAYING);
|
|
|
|
assert res
|
|
|
|
|
|
|
|
while bin.iterate(): pass
|
|
|
|
|
|
|
|
# stop the bin
|
|
|
|
res = bin.set_state(STATE_NULL)
|
|
|
|
assert res
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|