3 # vi:si:et:sw=4:sts=4:ts=4
6 # Copyright (C) 2003 David I. Lehn
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.
23 # Author: David I. Lehn <dlehn@users.sourceforge.net>
49 print '\t%d buffers / %fs\t= %f bps\t= %f spb' % (self.buffers, dt, bps, spb)
51 def fakesrc(self, buffers):
52 src = gst.element_factory_make('fakesrc','src')
53 src.set_property('silent', 1)
54 src.set_property('num_buffers', buffers)
58 sink = gst.element_factory_make('fakesink','sink')
59 sink.set_property('silent', 1)
62 def build_pipeline(self, buffers):
63 pipeline = gst.Pipeline('pipeline')
65 src = self.fakesrc(buffers)
67 sink = self.fakesink()
73 def idle(self, pipeline):
74 return pipeline.iterate()
77 self.bus = self.pipeline.get_bus()
79 self.start = time.time()
81 self.pipeline.set_state(gst.STATE_PLAYING)
84 msg = self.bus.poll(gst.MESSAGE_EOS | gst.MESSAGE_ERROR, gst.SECOND)
88 self.pipeline.set_state(gst.STATE_NULL)
91 def run(self, buffers):
92 self.buffers = buffers
94 print '# Testing buffer processing rate for "fakesrc ! fakesink"'
95 print '# bps = buffers per second'
96 print '# spb = seconds per buffer'
98 self.pipeline = self.build_pipeline(buffers)
104 "GStreamer Buffers-Per-Second tester"
107 print 'usage: %s buffers' % args[0]
112 buffers = int(args[1])
114 print 'buffers must be higher than 0'
119 if __name__ == '__main__':
120 sys.exit(main(sys.argv))