3 # vi:si:et:sw=4:sts=4:ts=4
6 # Copyright (C) 2005 Thomas Vander Stichele
8 # This library is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU Library General Public
10 # License as published by the Free Software Foundation; either
11 # version 2 of the License, or (at your option) any later version.
13 # This library is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # Library General Public License for more details.
18 # You should have received a copy of the GNU Library General Public
19 # License along with this library; if not, write to the
20 # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 # Boston, MA 02110-1301, USA.
27 #gobject.threads_init() # so we can safely receive signals from threads
31 def on_message_application(cutter, message, loop):
35 if s['above']: which = 'above'
36 print "%s: %s threshold" % (gst.TIME_ARGS(s['timestamp']), which)
37 if s['above']: count += 1
38 if count > 2: loop.quit()
42 loop = gobject.MainLoop()
44 pipeline = gst.Pipeline("cutter")
45 src = gst.element_factory_make("sinesrc", "src")
46 cutter = gst.element_factory_make("cutter")
47 cutter.set_property('threshold', 0.5)
48 sink = gst.element_factory_make("fakesink", "sink")
49 pipeline.add(src, cutter, sink)
53 control = gst.Controller(src, "volume")
54 control.set_interpolation_mode("volume", gst.INTERPOLATE_LINEAR)
56 control.set("volume", 0, 0.0)
57 control.set("volume", 2 * gst.SECOND, 1.0)
58 control.set("volume", 4 * gst.SECOND, 0.0)
59 control.set("volume", 6 * gst.SECOND, 1.0)
60 control.set("volume", 8 * gst.SECOND, 0.0)
61 control.set("volume", 10 * gst.SECOND, 1.0)
63 bus = pipeline.get_bus()
66 bus.add_signal_watch()
67 bus.connect('message::element', on_message_application, loop)
69 # FIXME: needs wrapping in gst-python
70 bus.set_sync_handler(bus.sync_signal_handler)
71 bus.connect('sync-message::element', on_message_application, loop)
73 pipeline.set_state(gst.STATE_PLAYING)
77 pipeline.set_state(gst.STATE_NULL)
79 if __name__ == "__main__":