Commit ad4e6fd7 authored by Johan Dahlin's avatar Johan Dahlin

gstreamer/gstreamer.defs: rename all functions, remove gst_ suffix.

Original commit message from CVS:
* gstreamer/gstreamer.defs: rename all functions, remove
gst_ suffix.
* gstreamer/examples/gstreamer/*.py: Update to new API.
parent d178fff2
2004-02-24 Johan Dahlin <johan@gnome.org>
* gstreamer/gstreamer.defs: rename all functions, remove
gst_ suffix.
* gstreamer/examples/gstreamer/*.py: Update to new API.
2004-02-23 Johan Dahlin <johan@gnome.org>
* gstreamer/gstreamer.defs (element_link_many): This is function
......
......@@ -23,8 +23,8 @@
import sys
import time
from gstreamer import *
from gobject import GObject
import gobject
import gst
import gtk
class BPS(object):
......@@ -42,21 +42,21 @@ class BPS(object):
def eos(self, sink):
self.done()
if self.method in ('gtk', 'c'):
gtk.main_quit()
gst.main_quit()
def fakesrc(self, buffers):
src = Element('fakesrc','src')
src = gst.Element('fakesrc','src')
src.set_property('silent', 1)
src.set_property('num_buffers', buffers)
return src
def fakesink(self):
sink = Element('fakesink','sink')
sink = gst.Element('fakesink','sink')
sink.set_property('silent', 1)
return sink
def build_pipeline(self, buffers):
pipeline = Pipeline('pipeline')
pipeline = gst.Pipeline('pipeline')
src = self.fakesrc(buffers)
pipeline.add(src)
......@@ -77,8 +77,9 @@ class BPS(object):
def test(self, method):
print '%s:' % (method,),
self.pipeline.set_state(STATE_PLAYING)
self.method = method
self.pipeline.set_state(gst.STATE_PLAYING)
if method == 'py':
self.start = time.time()
......@@ -86,50 +87,50 @@ class BPS(object):
pass
elif method == 'c':
self.start = time.time()
self.iter_id = add_iterate_bin(self.pipeline)
gtk.main()
elif method == 'gtk':
self.start = time.time()
gtk.idle_add(self.idle, self.pipeline)
gtk.main()
self.iter_id = gst.add_iterate_bin(self.pipeline)
gst.main()
#elif method == 'gst':
# self.start = time.time()
# gtk.idle_add(self.idle, self.pipeline)
# gtk.main()
elif method == 'all':
self.start = time.time()
iterate_bin_all(self.pipeline)
self.pipeline.set_state(STATE_NULL)
def __main__(self):
"GStreamer Buffers-Per-Second tester"
gst_info_set_categories(0L)
gst_debug_set_categories(0L)
if len(sys.argv) < 2:
print 'usage: %s buffers [method method ...]' % sys.argv[0]
return 1
else:
self.buffers = int(sys.argv[1])
self.methods = sys.argv[2:]
if self.methods == []:
self.methods = ('gtk', 'c', 'py', 'all')
self.pipeline.set_state(gst.STATE_NULL)
def run(self, buffers, methods):
self.buffers = buffers
print '# Testing buffer processing rate for "fakesrc ! fakesink"'
print '# gtk = gtk idle loop function in python'
#print '# gst = gtk idle loop function in python'
print '# c = gtk idle loop function in C'
print '# py = full iterate loop in python'
print '# all = full iterate loop in C'
print '# bps = buffers per second'
print '# spb = seconds per buffer'
self.pipeline = self.build_pipeline(self.buffers)
self.pipeline = self.build_pipeline(buffers)
assert self.pipeline
#self.pipeline.connect('deep-notify', self.notify)
map(self.test, methods)
def main(args):
"GStreamer Buffers-Per-Second tester"
if len(args) < 2:
print 'usage: %s buffers [method method ...]' % args[0]
return 1
bps = BPS()
buffers = int(args[1])
methods = args[2:]
if not methods:
methods = ('gtk', 'c', 'py', 'all')
for m in self.methods:
self.method = m
self.test(m)
return 0;
bps.run(buffers, methods)
if __name__ == '__main__':
bps = BPS()
ret = bps.__main__()
sys.exit (ret)
sys.exit(main(sys.argv))
......@@ -23,6 +23,7 @@
#
import sys
import gst
def filter(input, output):
......
......@@ -22,16 +22,11 @@
#
import sys
#from gnome import *
from gstreamer import *
from gobject import GObject
import gst
import gtk
gtk.threads_init()
class DVDPlayer(object):
def __init__(self):
pass
def idle(self, pipeline):
#gtk.threads_enter()
pipeline.iterate()
......@@ -47,16 +42,16 @@ class DVDPlayer(object):
print '***** a new pad %s was created' % pad.get_name()
if pad.get_name()[:6] == 'video_':
pad.link(self.v_queue.get_pad('sink'))
self.pipeline.set_state(STATE_PAUSED)
self.pipeline.set_state(gst.STATE_PAUSED)
self.pipeline.add(self.v_thread)
#self.v_thread.set_state(STATE_PLAYING)
self.pipeline.set_state(STATE_PLAYING)
#self.v_thread.set_state(gst.STATE_PLAYING)
self.pipeline.set_state(gst.STATE_PLAYING)
elif pad.get_name() == 'private_stream_1.0':
pad.link(self.a_queue.get_pad('sink'))
self.pipeline.set_state(STATE_PAUSED)
self.pipeline.set_state(gst.STATE_PAUSED)
self.pipeline.add(self.a_thread)
#self.a_thread.set_state(STATE_PLAYING);
self.pipeline.set_state(STATE_PLAYING)
#self.a_thread.set_state(gst.STATE_PLAYING);
self.pipeline.set_state(gst.STATE_PLAYING)
else:
print 'unknown pad: %s' % pad.get_name()
#gtk.threads_leave()
......@@ -67,16 +62,12 @@ class DVDPlayer(object):
self.appwindow.show_all()
gtk.threads_leave()
def main(self):
if len(sys.argv) < 5:
print 'usage: %s dvdlocation title chapter angle' % sys.argv[0]
return -1
self.location = sys.argv[1]
self.title = int(sys.argv[2])
self.chapter = int(sys.argv[3])
self.angle = int(sys.argv[4])
def main(self, location, title, chapter, angle):
self.location = location
self.title = title
self.chapter = chapter
self.angle = angle
#gst_init(&argc,&argv);
#gnome_init('MPEG2 Video player','0.0.1',argc,argv);
......@@ -91,13 +82,13 @@ class DVDPlayer(object):
gtk.threads_enter()
self.pipeline.set_state(STATE_PLAYING)
self.pipeline.set_state(gst.STATE_PLAYING)
gtk.idle_add(self.idle,self.pipeline)
gtk.main()
self.pipeline.set_state(STATE_NULL)
self.pipeline.set_state(gst.STATE_NULL)
gtk.threads_leave()
......@@ -105,34 +96,34 @@ class DVDPlayer(object):
def build_video_thread(self):
# ***** pre-construct the video thread *****
self.v_thread = Thread('v_thread')
self.v_thread = gst.Thread('v_thread')
self.v_queue = Element('queue','v_queue')
self.v_queue = gst.Element('queue','v_queue')
self.v_decode = Element('mpeg2dec','decode_video')
self.v_decode = gst.Element('mpeg2dec','decode_video')
self.color = Element('colorspace','color')
self.color = gst.Element('colorspace','color')
self.efx = Element('identity','identity')
#self.efx = Element('edgeTV','EdgeTV')
#self.efx = Element('agingTV','AgingTV')
self.efx = gst.Element('identity','identity')
#self.efx = gst.Element('edgeTV','EdgeTV')
#self.efx = gst.Element('agingTV','AgingTV')
#effectv: diceTV: DiceTV
#effectv: warpTV: WarpTV
#effectv: shagadelicTV: ShagadelicTV
#effectv: vertigoTV: VertigoTV
#self.efx = Element('revTV','RevTV')
#self.efx = Element('quarkTV','QuarkTV')
#self.efx = gst.Element('revTV','RevTV')
#self.efx = gst.Element('quarkTV','QuarkTV')
self.color2 = Element('colorspace','color2')
self.color2 = gst.Element('colorspace','color2')
self.show = Element('xvideosink','show')
self.show = gst.Element('xvideosink','show')
#self.show = Element('sdlvideosink','show')
#self.show = Element('fakesink','fakesinkv')
#self.show.set_property('silent', 0)
#self.show.set_property('sync', 1)
#self.deinterlace = Element('deinterlace','deinterlace')
self.deinterlace = Element('identity','deinterlace')
#self.deinterlace = gst.Element('deinterlace','deinterlace')
self.deinterlace = gst.Element('identity','deinterlace')
last = None
for e in (self.v_queue, self.v_decode, self.color, self.efx, self.color2, self.deinterlace, self.show):
......@@ -149,13 +140,13 @@ class DVDPlayer(object):
def build_audio_thread(self):
# ***** pre-construct the audio thread *****
self.a_thread = Thread('a_thread')
self.a_thread = gst.Thread('a_thread')
self.a_queue = Element('queue','a_queue')
self.a_queue = gst.Element('queue','a_queue')
self.a_decode = Element('a52dec','decode_audio')
self.a_decode = gst.Element('a52dec','decode_audio')
self.osssink = Element('osssink','osssink')
self.osssink = gst.Element('osssink','osssink')
#self.osssink = Element('fakesink','fakesinka')
#self.osssink.set_property('silent', 0)
#self.osssink.set_property('sync', 0)
......@@ -168,9 +159,9 @@ class DVDPlayer(object):
def build(self):
# ***** construct the main pipeline *****
self.pipeline = Pipeline('pipeline')
self.pipeline = gst.Pipeline('pipeline')
self.src = Element('dvdreadsrc','src');
self.src = gst.Element('dvdreadsrc','src');
self.src.connect('deep_notify',self.dnprint)
self.src.set_property('location', self.location)
......@@ -178,7 +169,7 @@ class DVDPlayer(object):
self.src.set_property('chapter', self.chapter)
self.src.set_property('angle', self.angle)
self.parse = Element('mpegdemux','parse')
self.parse = gst.Element('mpegdemux','parse')
self.parse.set_property('sync', 0)
self.pipeline.add(self.src)
......@@ -219,9 +210,18 @@ class DVDPlayer(object):
str = obj.get_property(param.name)
print '%s: %s = %s' % (sender.get_name(), param.name, str)
if __name__ == '__main__':
#gst_debug_set_categories(0xFFFFFFFFL)
#gst_info_set_categories(0xFFFFFFFFL)
def main(args):
if len(sys.argv) < 5:
print 'usage: %s dvdlocation title chapter angle' % sys.argv[0]
return -1
location = sys.argv[1]
title = int(sys.argv[2])
chapter = int(sys.argv[3])
angle = int(sys.argv[4])
player = DVDPlayer()
ret = player.main()
sys.exit(ret)
return player.main(location, title, chapter, angle)
if __name__ == '__main__':
sys.exit(main(sys.argv))
......@@ -21,23 +21,24 @@
# Author: David I. Lehn <dlehn@users.sourceforge.net>
#
from gobject import GObject
from gstreamer import *
import sys
import gst
def handoff(sender, *args):
print sender.get_name(), args
def main():
def main(args):
# create a new bin to hold the elements
#gst_debug_set_categories(-1)
bin = Pipeline('pipeline')
bin = gst.Pipeline('pipeline')
src = Element('fakesrc', 'src')
src = gst.Element('fakesrc', 'src')
src.connect('handoff', handoff)
src.set_property('silent', 1)
src.set_property('num_buffers', 10)
sink = Element('fakesink', 'sink')
sink = gst.Element('fakesink', 'sink')
sink.connect('handoff', handoff)
src.set_property('silent', 1)
......@@ -50,14 +51,15 @@ def main():
assert res
# start playing
res = bin.set_state(STATE_PLAYING);
res = bin.set_state(gst.STATE_PLAYING);
assert res
while bin.iterate(): pass
while bin.iterate():
pass
# stop the bin
res = bin.set_state(STATE_NULL)
res = bin.set_state(gst.STATE_NULL)
assert res
if __name__ == '__main__':
main()
sys.exit(main(sys.argv))
......@@ -22,19 +22,18 @@
#
import sys
from gstreamer import *
import gobject
from cp import filter
import gst
class Identity(Element):
class Identity(gst.Element):
def __init__(self):
self.__gobject_init__()
self.sinkpad = Pad('sink', PAD_SINK)
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 = Pad('src', PAD_SRC)
self.srcpad = gst.Pad('src', gst.PAD_SRC)
self.add_pad(self.srcpad)
self.srcpad.set_link_function(self.pad_link)
......@@ -44,16 +43,33 @@ class Identity(Element):
def pad_link(self, pad, caps):
print 'pad_link:', self, pad, caps
return PAD_LINK_OK
return gst.PAD_LINK_OK
def chain(self, pad, buf):
self.srcpad.push(buf)
gobject.type_register(Identity)
def main():
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')
bin.add_many(filesrc, element, filesink)
gst.element_link_many(filesrc, element, 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"
gst_debug_set_categories(0L)
identity = Identity()
identity.set_name('identity')
......@@ -61,8 +77,8 @@ def main():
print 'could not create \"Identity\" element'
return -1
return filter([identity])
return filter(identity)
if __name__ == '__main__':
ret = main()
sys.exit (ret)
sys.exit(main(sys.argv))
......@@ -22,8 +22,7 @@
#
import sys
from gstreamer import *
from gobject import GObject
import gst
import time
from identity import Identity
......@@ -32,38 +31,30 @@ def update(sender, *args):
def build(filters, b):
# create a new bin to hold the elements
bin = Pipeline('pipeline')
bin = gst.Pipeline('pipeline')
src = Element('fakesrc', 'source');
src = gst.Element('fakesrc', 'source');
src.set_property('silent', 1)
src.set_property('num_buffers', b)
sink = Element('fakesink', 'sink')
sink = gst.Element('fakesink', 'sink')
sink.set_property('silent', 1)
elements = [src] + filters + [sink]
# add objects to the main pipeline
for e in elements:
bin.add(e)
# link the elements
previous = None
for e in elements:
if previous:
previous.link(e)
previous = e
bin.add_many(*elements)
gst.element_link_many(*elements)
return bin
def filter(bin):
bin.set_state(STATE_PLAYING);
while bin.iterate(): pass
bin.set_state(STATE_NULL)
bin.set_state(gst.STATE_PLAYING);
while bin.iterate():
pass
bin.set_state(gst.STATE_NULL)
ccnt = 0
def c():
global ccnt
id = Element ('identity', 'c identity %d' % ccnt);
id = gst.Element('identity', 'c identity %d' % ccnt);
id.set_property('silent', 1)
id.set_property('loop_based', 0)
ccnt += 1
......@@ -91,19 +82,17 @@ def check(f, n, b):
print '%s b:%d i:%d t:%f' % (f, b, n, end - start)
return ret
def main():
def main(args):
"Identity timer and latency check"
if gst_version() < (0,7,0):
gst_debug_set_categories(0L)
if len(sys.argv) < 3:
print 'usage: %s identites buffers' % (sys.argv[0],)
if len(args) < 3:
print 'usage: %s identites buffers' % args[0]
return -1
n = int(sys.argv[1])
b = int(sys.argv[2])
n = int(args[1])
b = int(args[2])
for f in (c, py):
check(f, n, b)
if __name__ == '__main__':
ret = main()
sys.exit (ret)
sys.exit(main(sys.argv))
......@@ -23,8 +23,7 @@
import sys
import time
from gstreamer import *
from gobject import GObject
import gst
def update(sender, *args):
print sender.get_name(), args
......@@ -63,7 +62,7 @@ def identity_add(pipeline, first, count):
for i in range(count):
name = 'identity_%03d' % i
ident = Element('identity', name)
ident = gst.Element('identity', name)
ident.set_property('silent', 1)
pipeline.add(ident)
last.get_pad('src').link(ident.get_pad('sink'))
......@@ -72,14 +71,14 @@ def identity_add(pipeline, first, count):
return last
def fakesrc():
src = Element('fakesrc','src')
src = gst.Element('fakesrc','src')
src.set_property('silent', 1)
src.set_property('num_buffers', iterations)
src.connect('handoff', handoff_src)
return src
def fakesink():
sink = Element('fakesink','fakesink')
sink = gst.Element('fakesink','fakesink')
sink.set_property('silent', 1)
sink.connect('handoff', handoff_sink)
return sink
......@@ -89,10 +88,8 @@ def simple(argv):
print 'simple: bad params'
return None
idents = int(argv[0])
if len(argv) == 2:
gst_schedulerfactory_set_default_name (argv[1])
pipeline = Pipeline('pipeline')
pipeline = gst.Pipeline('pipeline')
src = fakesrc()
pipeline.add(src)
......@@ -109,17 +106,14 @@ def queue(argv):
return None
idents = int(argv[0])
if len(arv) == 2:
gst_schedulerfactory_set_default_name (argv[1])
pipeline = gst.Pipeline('pipeline')
pipeline = Pipeline('pipeline')
src_thr = Thread('src_thread')
src_thr = gst.Thread('src_thread')
src = fakesrc()
src_thr.add(src)
src_q = Element('queue','src_q')
src_q = gst.Element('queue','src_q')
src_thr.add(src_q)
src.get_pad('src').link(src_q.get_pad('sink'))
......@@ -127,11 +121,11 @@ def queue(argv):
last = identity_add(pipeline, src_q, idents)
sink_q = Element('queue','sink_q')
sink_q = gst.Element('queue','sink_q')
pipeline.add(sink_q)
last.get_pad('src').link(sink_q.get_pad('sink'))
sink_thr = Thread('sink_thread')
sink_thr = gst.Thread('sink_thread')
sink = fakesink()
......@@ -169,12 +163,12 @@ def main():
#xmlSaveFile('lat.gst', gst_xml_write(pipeline))
pipeline.set_state(STATE_PLAYING)
pipeline.set_state(gst.STATE_PLAYING)
while count < iterations:
pipeline.iterate()
pipeline.set_state(STATE_NULL)
pipeline.set_state(gst.STATE_NULL)
print
......
......@@ -22,8 +22,7 @@
#
import sys
from gstreamer import *
import gobject
import gst
from identity import Identity
from cp import filter
......@@ -41,15 +40,14 @@ class Rot13(Identity):
a = 'A'
c = chr((((ord(c) - ord(a)) + 13) % 26) + ord(a))
data2 = data2 + c
newbuf = Buffer()
newbuf = gst.Buffer()
newbuf.set_data(data2)
self.srcpad.push(newbuf)
gobject.type_register(Rot13)
def main():
def main(args):
"A GStreamer Python subclassing example of a rot13 filter"
gst_debug_set_categories(0L)
rot13 = Rot13()
rot13.set_name('rot13')
......@@ -60,5 +58,4 @@ def main():
return filter([rot13])
if __name__ == '__main__':
ret = main()
sys.exit (ret)
sys.exit(main(sys.argv))
......@@ -23,8 +23,8 @@
import sys
import time
from gstreamer import *
from gobject import GObject
import gobject
import gst
import gtk