make examples use Element

Original commit message from CVS:
make examples use Element
This commit is contained in:
Thomas Vander Stichele 2003-10-04 23:02:48 +00:00
parent 0ffd6e38e9
commit d13b976ed2
15 changed files with 80 additions and 160 deletions

View file

@ -1,3 +1,7 @@
2003-10-05 Thomas Vander Stichele <thomas at apestaart dot org>
* examples/gstreamer/*.py: use Element over gst_element_factory_make
2003-10-05 Thomas Vander Stichele <thomas at apestaart dot org> 2003-10-05 Thomas Vander Stichele <thomas at apestaart dot org>
* gstreamer/gstreamermodule.c: (init_gstreamer): * gstreamer/gstreamermodule.c: (init_gstreamer):

View file

@ -45,15 +45,13 @@ class BPS(object):
gtk.main_quit() gtk.main_quit()
def fakesrc(self, buffers): def fakesrc(self, buffers):
src = gst_element_factory_make('fakesrc','src') src = Element('fakesrc','src')
assert src
src.set_property('silent', 1) src.set_property('silent', 1)
src.set_property('num_buffers', buffers) src.set_property('num_buffers', buffers)
return src return src
def fakesink(self): def fakesink(self):
sink = gst_element_factory_make('fakesink','sink') sink = Element('fakesink','sink')
assert sink
sink.set_property('silent', 1) sink.set_property('silent', 1)
return sink return sink

View file

@ -38,16 +38,10 @@ def filter(filters):
# create a new bin to hold the elements # create a new bin to hold the elements
bin = Pipeline('pipeline') bin = Pipeline('pipeline')
filesrc = gst_element_factory_make('filesrc', 'source'); filesrc = Element('filesrc', 'source');
if not filesrc:
print 'could not find plugin \"filesrc\"'
return -1
filesrc.set_property('location', sys.argv[1]) filesrc.set_property('location', sys.argv[1])
filesink = gst_element_factory_make('filesink', 'sink') filesink = Element('filesink', 'sink')
if not filesink:
print 'could not find plugin \"filesink\"'
return -1
filesink.set_property('location', sys.argv[2]) filesink.set_property('location', sys.argv[2])
elements = [filesrc] + filters + [filesink] elements = [filesrc] + filters + [filesink]
@ -77,10 +71,7 @@ def main():
#gst_info_set_categories(-1) #gst_info_set_categories(-1)
#gst_debug_set_categories(-1) #gst_debug_set_categories(-1)
stats = gst_element_factory_make ('statistics', 'stats'); stats = Element ('statistics', 'stats');
if not stats:
print 'could not find plugin \"statistics\"'
return -1
stats.set_property('silent', 0) stats.set_property('silent', 0)
stats.set_property('buffer_update_freq', 1) stats.set_property('buffer_update_freq', 1)
stats.set_property('update_on_eos', 1) stats.set_property('update_on_eos', 1)

View file

@ -108,39 +108,32 @@ class DVDPlayer(object):
self.v_thread = Thread('v_thread') self.v_thread = Thread('v_thread')
assert self.v_thread assert self.v_thread
self.v_queue = gst_element_factory_make('queue','v_queue') self.v_queue = Element('queue','v_queue')
assert self.v_queue
self.v_decode = gst_element_factory_make('mpeg2dec','decode_video') self.v_decode = Element('mpeg2dec','decode_video')
assert self.v_decode
self.color = gst_element_factory_make('colorspace','color') self.color = Element('colorspace','color')
assert self.color
self.efx = gst_element_factory_make('identity','identity') self.efx = Element('identity','identity')
#self.efx = gst_element_factory_make('edgeTV','EdgeTV') #self.efx = Element('edgeTV','EdgeTV')
#self.efx = gst_element_factory_make('agingTV','AgingTV') #self.efx = Element('agingTV','AgingTV')
#effectv: diceTV: DiceTV #effectv: diceTV: DiceTV
#effectv: warpTV: WarpTV #effectv: warpTV: WarpTV
#effectv: shagadelicTV: ShagadelicTV #effectv: shagadelicTV: ShagadelicTV
#effectv: vertigoTV: VertigoTV #effectv: vertigoTV: VertigoTV
#self.efx = gst_element_factory_make('revTV','RevTV') #self.efx = Element('revTV','RevTV')
#self.efx = gst_element_factory_make('quarkTV','QuarkTV') #self.efx = Element('quarkTV','QuarkTV')
assert self.efx
self.color2 = gst_element_factory_make('colorspace','color2') self.color2 = Element('colorspace','color2')
assert self.color2
self.show = gst_element_factory_make('xvideosink','show') self.show = Element('xvideosink','show')
#self.show = gst_element_factory_make('sdlvideosink','show') #self.show = Element('sdlvideosink','show')
#self.show = gst_element_factory_make('fakesink','fakesinkv') #self.show = Element('fakesink','fakesinkv')
assert self.show
#self.show.set_property('silent', 0) #self.show.set_property('silent', 0)
#self.show.set_property('sync', 1) #self.show.set_property('sync', 1)
#self.deinterlace = gst_element_factory_make('deinterlace','deinterlace') #self.deinterlace = Element('deinterlace','deinterlace')
self.deinterlace = gst_element_factory_make('identity','deinterlace') self.deinterlace = Element('identity','deinterlace')
assert self.deinterlace
last = None last = None
for e in (self.v_queue, self.v_decode, self.color, self.efx, self.color2, self.deinterlace, self.show): for e in (self.v_queue, self.v_decode, self.color, self.efx, self.color2, self.deinterlace, self.show):
@ -160,15 +153,12 @@ class DVDPlayer(object):
self.a_thread = Thread('a_thread') self.a_thread = Thread('a_thread')
assert self.a_thread assert self.a_thread
self.a_queue = gst_element_factory_make('queue','a_queue') self.a_queue = Element('queue','a_queue')
assert self.a_queue
self.a_decode = gst_element_factory_make('a52dec','decode_audio') self.a_decode = Element('a52dec','decode_audio')
assert self.a_decode
self.osssink = gst_element_factory_make('osssink','osssink') self.osssink = Element('osssink','osssink')
#self.osssink = gst_element_factory_make('fakesink','fakesinka') #self.osssink = Element('fakesink','fakesinka')
assert self.osssink
#self.osssink.set_property('silent', 0) #self.osssink.set_property('silent', 0)
#self.osssink.set_property('sync', 0) #self.osssink.set_property('sync', 0)
@ -183,8 +173,7 @@ class DVDPlayer(object):
self.pipeline = Pipeline('pipeline') self.pipeline = Pipeline('pipeline')
assert self.pipeline assert self.pipeline
self.src = gst_element_factory_make('dvdreadsrc','src'); self.src = Element('dvdreadsrc','src');
assert self.src
self.src.connect('deep_notify',self.dnprint) self.src.connect('deep_notify',self.dnprint)
self.src.set_property('location', self.location) self.src.set_property('location', self.location)
@ -192,8 +181,7 @@ class DVDPlayer(object):
self.src.set_property('chapter', self.chapter) self.src.set_property('chapter', self.chapter)
self.src.set_property('angle', self.angle) self.src.set_property('angle', self.angle)
self.parse = gst_element_factory_make('mpegdemux','parse') self.parse = Element('mpegdemux','parse')
assert self.parse
self.parse.set_property('sync', 0) self.parse.set_property('sync', 0)
self.pipeline.add(self.src) self.pipeline.add(self.src)

View file

@ -33,14 +33,12 @@ def main():
bin = Pipeline('pipeline') bin = Pipeline('pipeline')
assert bin assert bin
src = gst_element_factory_make('fakesrc', 'src') src = Element('fakesrc', 'src')
assert src
src.connect('handoff', handoff) src.connect('handoff', handoff)
src.set_property('silent', 1) src.set_property('silent', 1)
src.set_property('num_buffers', 10) src.set_property('num_buffers', 10)
sink = gst_element_factory_make('fakesink', 'sink') sink = Element('fakesink', 'sink')
assert sink
sink.connect('handoff', handoff) sink.connect('handoff', handoff)
src.set_property('silent', 1) src.set_property('silent', 1)

View file

@ -34,13 +34,11 @@ def build(filters, b):
# create a new bin to hold the elements # create a new bin to hold the elements
bin = Pipeline('pipeline') bin = Pipeline('pipeline')
src = gst_element_factory_make('fakesrc', 'source'); src = Element('fakesrc', 'source');
assert src
src.set_property('silent', 1) src.set_property('silent', 1)
src.set_property('num_buffers', b) src.set_property('num_buffers', b)
sink = gst_element_factory_make('fakesink', 'sink') sink = Element('fakesink', 'sink')
assert sink
sink.set_property('silent', 1) sink.set_property('silent', 1)
elements = [src] + filters + [sink] elements = [src] + filters + [sink]
@ -65,8 +63,7 @@ def filter(bin):
ccnt = 0 ccnt = 0
def c(): def c():
global ccnt global ccnt
id = gst_element_factory_make ('identity', 'c identity %d' % ccnt); id = Element ('identity', 'c identity %d' % ccnt);
assert id
id.set_property('silent', 1) id.set_property('silent', 1)
id.set_property('loop_based', 0) id.set_property('loop_based', 0)
ccnt += 1 ccnt += 1

View file

@ -63,8 +63,7 @@ def identity_add(pipeline, first, count):
for i in range(count): for i in range(count):
name = 'identity_%03d' % i name = 'identity_%03d' % i
ident = gst_element_factory_make('identity', name) ident = Element('identity', name)
assert ident
ident.set_property('silent', 1) ident.set_property('silent', 1)
pipeline.add(ident) pipeline.add(ident)
last.get_pad('src').link(ident.get_pad('sink')) last.get_pad('src').link(ident.get_pad('sink'))
@ -73,16 +72,14 @@ def identity_add(pipeline, first, count):
return last return last
def fakesrc(): def fakesrc():
src = gst_element_factory_make('fakesrc','src') src = Element('fakesrc','src')
assert src
src.set_property('silent', 1) src.set_property('silent', 1)
src.set_property('num_buffers', iterations) src.set_property('num_buffers', iterations)
src.connect('handoff', handoff_src) src.connect('handoff', handoff_src)
return src return src
def fakesink(): def fakesink():
sink = gst_element_factory_make('fakesink','fakesink') sink = Element('fakesink','fakesink')
assert sink
sink.set_property('silent', 1) sink.set_property('silent', 1)
sink.connect('handoff', handoff_sink) sink.connect('handoff', handoff_sink)
return sink return sink
@ -126,8 +123,7 @@ def queue(argv):
assert src assert src
src_thr.add(src) src_thr.add(src)
src_q = gst_element_factory_make('queue','src_q') src_q = Element('queue','src_q')
assert src_q
src_thr.add(src_q) src_thr.add(src_q)
src.get_pad('src').link(src_q.get_pad('sink')) src.get_pad('src').link(src_q.get_pad('sink'))
@ -135,8 +131,7 @@ def queue(argv):
last = identity_add(pipeline, src_q, idents) last = identity_add(pipeline, src_q, idents)
sink_q = gst_element_factory_make('queue','sink_q') sink_q = Element('queue','sink_q')
assert sink_q
pipeline.add(sink_q) pipeline.add(sink_q)
last.get_pad('src').link(sink_q.get_pad('sink')) last.get_pad('src').link(sink_q.get_pad('sink'))

View file

@ -109,24 +109,15 @@ def main():
bin = Pipeline('pipeline') bin = Pipeline('pipeline')
# create a disk reader # create a disk reader
filesrc = gst_element_factory_make ('filesrc', 'disk_source'); filesrc = Element ('filesrc', 'disk_source')
if not filesrc:
print 'could not find plugin \"filesrc\"'
return -1
filesrc.set_property('location', sys.argv[1]) filesrc.set_property('location', sys.argv[1])
# now get the decoder # now get the decoder
decoder = gst_element_factory_make ('vorbisfile', 'parse'); decoder = Element ('vorbisfile', 'parse')
if not decoder:
print 'could not find plugin \"vorbisfile\"'
return -1
decoder.connect('notify', decoder_notified) decoder.connect('notify', decoder_notified)
# and an audio sink # and an audio sink
osssink = gst_element_factory_make ('osssink', 'play_audio') osssink = Element ('osssink', 'play_audio')
if not osssink:
print 'could not find plugin \"osssink\"'
return -1
# add objects to the main pipeline # add objects to the main pipeline
for e in (filesrc, decoder, osssink): for e in (filesrc, decoder, osssink):

View file

@ -45,15 +45,13 @@ class BPS(object):
gtk.main_quit() gtk.main_quit()
def fakesrc(self, buffers): def fakesrc(self, buffers):
src = gst_element_factory_make('fakesrc','src') src = Element('fakesrc','src')
assert src
src.set_property('silent', 1) src.set_property('silent', 1)
src.set_property('num_buffers', buffers) src.set_property('num_buffers', buffers)
return src return src
def fakesink(self): def fakesink(self):
sink = gst_element_factory_make('fakesink','sink') sink = Element('fakesink','sink')
assert sink
sink.set_property('silent', 1) sink.set_property('silent', 1)
return sink return sink

View file

@ -38,16 +38,10 @@ def filter(filters):
# create a new bin to hold the elements # create a new bin to hold the elements
bin = Pipeline('pipeline') bin = Pipeline('pipeline')
filesrc = gst_element_factory_make('filesrc', 'source'); filesrc = Element('filesrc', 'source');
if not filesrc:
print 'could not find plugin \"filesrc\"'
return -1
filesrc.set_property('location', sys.argv[1]) filesrc.set_property('location', sys.argv[1])
filesink = gst_element_factory_make('filesink', 'sink') filesink = Element('filesink', 'sink')
if not filesink:
print 'could not find plugin \"filesink\"'
return -1
filesink.set_property('location', sys.argv[2]) filesink.set_property('location', sys.argv[2])
elements = [filesrc] + filters + [filesink] elements = [filesrc] + filters + [filesink]
@ -77,10 +71,7 @@ def main():
#gst_info_set_categories(-1) #gst_info_set_categories(-1)
#gst_debug_set_categories(-1) #gst_debug_set_categories(-1)
stats = gst_element_factory_make ('statistics', 'stats'); stats = Element ('statistics', 'stats');
if not stats:
print 'could not find plugin \"statistics\"'
return -1
stats.set_property('silent', 0) stats.set_property('silent', 0)
stats.set_property('buffer_update_freq', 1) stats.set_property('buffer_update_freq', 1)
stats.set_property('update_on_eos', 1) stats.set_property('update_on_eos', 1)

View file

@ -108,39 +108,32 @@ class DVDPlayer(object):
self.v_thread = Thread('v_thread') self.v_thread = Thread('v_thread')
assert self.v_thread assert self.v_thread
self.v_queue = gst_element_factory_make('queue','v_queue') self.v_queue = Element('queue','v_queue')
assert self.v_queue
self.v_decode = gst_element_factory_make('mpeg2dec','decode_video') self.v_decode = Element('mpeg2dec','decode_video')
assert self.v_decode
self.color = gst_element_factory_make('colorspace','color') self.color = Element('colorspace','color')
assert self.color
self.efx = gst_element_factory_make('identity','identity') self.efx = Element('identity','identity')
#self.efx = gst_element_factory_make('edgeTV','EdgeTV') #self.efx = Element('edgeTV','EdgeTV')
#self.efx = gst_element_factory_make('agingTV','AgingTV') #self.efx = Element('agingTV','AgingTV')
#effectv: diceTV: DiceTV #effectv: diceTV: DiceTV
#effectv: warpTV: WarpTV #effectv: warpTV: WarpTV
#effectv: shagadelicTV: ShagadelicTV #effectv: shagadelicTV: ShagadelicTV
#effectv: vertigoTV: VertigoTV #effectv: vertigoTV: VertigoTV
#self.efx = gst_element_factory_make('revTV','RevTV') #self.efx = Element('revTV','RevTV')
#self.efx = gst_element_factory_make('quarkTV','QuarkTV') #self.efx = Element('quarkTV','QuarkTV')
assert self.efx
self.color2 = gst_element_factory_make('colorspace','color2') self.color2 = Element('colorspace','color2')
assert self.color2
self.show = gst_element_factory_make('xvideosink','show') self.show = Element('xvideosink','show')
#self.show = gst_element_factory_make('sdlvideosink','show') #self.show = Element('sdlvideosink','show')
#self.show = gst_element_factory_make('fakesink','fakesinkv') #self.show = Element('fakesink','fakesinkv')
assert self.show
#self.show.set_property('silent', 0) #self.show.set_property('silent', 0)
#self.show.set_property('sync', 1) #self.show.set_property('sync', 1)
#self.deinterlace = gst_element_factory_make('deinterlace','deinterlace') #self.deinterlace = Element('deinterlace','deinterlace')
self.deinterlace = gst_element_factory_make('identity','deinterlace') self.deinterlace = Element('identity','deinterlace')
assert self.deinterlace
last = None last = None
for e in (self.v_queue, self.v_decode, self.color, self.efx, self.color2, self.deinterlace, self.show): for e in (self.v_queue, self.v_decode, self.color, self.efx, self.color2, self.deinterlace, self.show):
@ -160,15 +153,12 @@ class DVDPlayer(object):
self.a_thread = Thread('a_thread') self.a_thread = Thread('a_thread')
assert self.a_thread assert self.a_thread
self.a_queue = gst_element_factory_make('queue','a_queue') self.a_queue = Element('queue','a_queue')
assert self.a_queue
self.a_decode = gst_element_factory_make('a52dec','decode_audio') self.a_decode = Element('a52dec','decode_audio')
assert self.a_decode
self.osssink = gst_element_factory_make('osssink','osssink') self.osssink = Element('osssink','osssink')
#self.osssink = gst_element_factory_make('fakesink','fakesinka') #self.osssink = Element('fakesink','fakesinka')
assert self.osssink
#self.osssink.set_property('silent', 0) #self.osssink.set_property('silent', 0)
#self.osssink.set_property('sync', 0) #self.osssink.set_property('sync', 0)
@ -183,8 +173,7 @@ class DVDPlayer(object):
self.pipeline = Pipeline('pipeline') self.pipeline = Pipeline('pipeline')
assert self.pipeline assert self.pipeline
self.src = gst_element_factory_make('dvdreadsrc','src'); self.src = Element('dvdreadsrc','src');
assert self.src
self.src.connect('deep_notify',self.dnprint) self.src.connect('deep_notify',self.dnprint)
self.src.set_property('location', self.location) self.src.set_property('location', self.location)
@ -192,8 +181,7 @@ class DVDPlayer(object):
self.src.set_property('chapter', self.chapter) self.src.set_property('chapter', self.chapter)
self.src.set_property('angle', self.angle) self.src.set_property('angle', self.angle)
self.parse = gst_element_factory_make('mpegdemux','parse') self.parse = Element('mpegdemux','parse')
assert self.parse
self.parse.set_property('sync', 0) self.parse.set_property('sync', 0)
self.pipeline.add(self.src) self.pipeline.add(self.src)

View file

@ -33,14 +33,12 @@ def main():
bin = Pipeline('pipeline') bin = Pipeline('pipeline')
assert bin assert bin
src = gst_element_factory_make('fakesrc', 'src') src = Element('fakesrc', 'src')
assert src
src.connect('handoff', handoff) src.connect('handoff', handoff)
src.set_property('silent', 1) src.set_property('silent', 1)
src.set_property('num_buffers', 10) src.set_property('num_buffers', 10)
sink = gst_element_factory_make('fakesink', 'sink') sink = Element('fakesink', 'sink')
assert sink
sink.connect('handoff', handoff) sink.connect('handoff', handoff)
src.set_property('silent', 1) src.set_property('silent', 1)

View file

@ -34,13 +34,11 @@ def build(filters, b):
# create a new bin to hold the elements # create a new bin to hold the elements
bin = Pipeline('pipeline') bin = Pipeline('pipeline')
src = gst_element_factory_make('fakesrc', 'source'); src = Element('fakesrc', 'source');
assert src
src.set_property('silent', 1) src.set_property('silent', 1)
src.set_property('num_buffers', b) src.set_property('num_buffers', b)
sink = gst_element_factory_make('fakesink', 'sink') sink = Element('fakesink', 'sink')
assert sink
sink.set_property('silent', 1) sink.set_property('silent', 1)
elements = [src] + filters + [sink] elements = [src] + filters + [sink]
@ -65,8 +63,7 @@ def filter(bin):
ccnt = 0 ccnt = 0
def c(): def c():
global ccnt global ccnt
id = gst_element_factory_make ('identity', 'c identity %d' % ccnt); id = Element ('identity', 'c identity %d' % ccnt);
assert id
id.set_property('silent', 1) id.set_property('silent', 1)
id.set_property('loop_based', 0) id.set_property('loop_based', 0)
ccnt += 1 ccnt += 1

View file

@ -63,8 +63,7 @@ def identity_add(pipeline, first, count):
for i in range(count): for i in range(count):
name = 'identity_%03d' % i name = 'identity_%03d' % i
ident = gst_element_factory_make('identity', name) ident = Element('identity', name)
assert ident
ident.set_property('silent', 1) ident.set_property('silent', 1)
pipeline.add(ident) pipeline.add(ident)
last.get_pad('src').link(ident.get_pad('sink')) last.get_pad('src').link(ident.get_pad('sink'))
@ -73,16 +72,14 @@ def identity_add(pipeline, first, count):
return last return last
def fakesrc(): def fakesrc():
src = gst_element_factory_make('fakesrc','src') src = Element('fakesrc','src')
assert src
src.set_property('silent', 1) src.set_property('silent', 1)
src.set_property('num_buffers', iterations) src.set_property('num_buffers', iterations)
src.connect('handoff', handoff_src) src.connect('handoff', handoff_src)
return src return src
def fakesink(): def fakesink():
sink = gst_element_factory_make('fakesink','fakesink') sink = Element('fakesink','fakesink')
assert sink
sink.set_property('silent', 1) sink.set_property('silent', 1)
sink.connect('handoff', handoff_sink) sink.connect('handoff', handoff_sink)
return sink return sink
@ -126,8 +123,7 @@ def queue(argv):
assert src assert src
src_thr.add(src) src_thr.add(src)
src_q = gst_element_factory_make('queue','src_q') src_q = Element('queue','src_q')
assert src_q
src_thr.add(src_q) src_thr.add(src_q)
src.get_pad('src').link(src_q.get_pad('sink')) src.get_pad('src').link(src_q.get_pad('sink'))
@ -135,8 +131,7 @@ def queue(argv):
last = identity_add(pipeline, src_q, idents) last = identity_add(pipeline, src_q, idents)
sink_q = gst_element_factory_make('queue','sink_q') sink_q = Element('queue','sink_q')
assert sink_q
pipeline.add(sink_q) pipeline.add(sink_q)
last.get_pad('src').link(sink_q.get_pad('sink')) last.get_pad('src').link(sink_q.get_pad('sink'))

View file

@ -109,24 +109,15 @@ def main():
bin = Pipeline('pipeline') bin = Pipeline('pipeline')
# create a disk reader # create a disk reader
filesrc = gst_element_factory_make ('filesrc', 'disk_source'); filesrc = Element ('filesrc', 'disk_source')
if not filesrc:
print 'could not find plugin \"filesrc\"'
return -1
filesrc.set_property('location', sys.argv[1]) filesrc.set_property('location', sys.argv[1])
# now get the decoder # now get the decoder
decoder = gst_element_factory_make ('vorbisfile', 'parse'); decoder = Element ('vorbisfile', 'parse')
if not decoder:
print 'could not find plugin \"vorbisfile\"'
return -1
decoder.connect('notify', decoder_notified) decoder.connect('notify', decoder_notified)
# and an audio sink # and an audio sink
osssink = gst_element_factory_make ('osssink', 'play_audio') osssink = Element ('osssink', 'play_audio')
if not osssink:
print 'could not find plugin \"osssink\"'
return -1
# add objects to the main pipeline # add objects to the main pipeline
for e in (filesrc, decoder, osssink): for e in (filesrc, decoder, osssink):