mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-18 20:25:25 +00:00
Some example apps
Original commit message from CVS: Some example apps
This commit is contained in:
parent
4fb934cf51
commit
26a76f6af0
8 changed files with 340 additions and 0 deletions
3
examples/gst/.gitignore
vendored
3
examples/gst/.gitignore
vendored
|
@ -1,2 +1,5 @@
|
||||||
Makefile.in
|
Makefile.in
|
||||||
Makefile
|
Makefile
|
||||||
|
*.pyc
|
||||||
|
*.pyo
|
||||||
|
*.swp
|
||||||
|
|
64
examples/gst/cp.py
Executable file
64
examples/gst/cp.py
Executable file
|
@ -0,0 +1,64 @@
|
||||||
|
#!/usr/bin/env python2.2
|
||||||
|
|
||||||
|
from gstreamer import *
|
||||||
|
from gobject import GObject
|
||||||
|
|
||||||
|
def update(sender, *args):
|
||||||
|
print sender.get_name(), args
|
||||||
|
|
||||||
|
def main():
|
||||||
|
"A GStreamer based cp(1) with stats"
|
||||||
|
#gst_debug_set_categories(-1)
|
||||||
|
|
||||||
|
if len(sys.argv) != 3:
|
||||||
|
print 'usage: %s source dest' % (sys.argv[0])
|
||||||
|
return -1
|
||||||
|
|
||||||
|
# create a new bin to hold the elements
|
||||||
|
bin = gst_pipeline_new ('pipeline')
|
||||||
|
|
||||||
|
filesrc = gst_elementfactory_make ('filesrc', 'source');
|
||||||
|
if not filesrc:
|
||||||
|
print 'could not find plugin \"filesrc\"'
|
||||||
|
return -1
|
||||||
|
filesrc.set_property('location', sys.argv[1])
|
||||||
|
|
||||||
|
stats = gst_elementfactory_make ('statistics', 'stats');
|
||||||
|
if not stats:
|
||||||
|
print 'could not find plugin \"statistics\"'
|
||||||
|
return -1
|
||||||
|
stats.set_property('silent', 0)
|
||||||
|
stats.set_property('buffer_update_freq', 1)
|
||||||
|
stats.set_property('update_on_eos', 1)
|
||||||
|
#GObject.connect(stats, 'update', update)
|
||||||
|
|
||||||
|
filesink = gst_elementfactory_make ('disksink', 'sink')
|
||||||
|
if not filesink:
|
||||||
|
print 'could not find plugin \"disksink\"'
|
||||||
|
return -1
|
||||||
|
filesink.set_property('location', sys.argv[2])
|
||||||
|
|
||||||
|
# add objects to the main pipeline
|
||||||
|
for e in (filesrc, stats, filesink):
|
||||||
|
bin.add(e)
|
||||||
|
|
||||||
|
# connect the elements
|
||||||
|
previous = None
|
||||||
|
for e in (filesrc, stats, filesink):
|
||||||
|
if previous:
|
||||||
|
previous.connect('src', e, 'sink')
|
||||||
|
previous = e
|
||||||
|
|
||||||
|
# start playing
|
||||||
|
bin.set_state(STATE_PLAYING);
|
||||||
|
|
||||||
|
while bin.iterate(): pass
|
||||||
|
|
||||||
|
# stop the bin
|
||||||
|
bin.set_state(STATE_NULL)
|
||||||
|
|
||||||
|
return 0
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
ret = main()
|
||||||
|
sys.exit (ret)
|
45
examples/gst/f2f.py
Executable file
45
examples/gst/f2f.py
Executable file
|
@ -0,0 +1,45 @@
|
||||||
|
#!/usr/bin/env python2.2
|
||||||
|
|
||||||
|
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)
|
||||||
|
bin = gst_pipeline_new ('pipeline')
|
||||||
|
assert bin
|
||||||
|
|
||||||
|
src = gst_elementfactory_make ('fakesrc', 'src')
|
||||||
|
assert src
|
||||||
|
GObject.connect(src, 'handoff', handoff)
|
||||||
|
src.set_property('silent', 1)
|
||||||
|
src.set_property('num_buffers', 10)
|
||||||
|
|
||||||
|
sink = gst_elementfactory_make ('fakesink', 'sink')
|
||||||
|
assert sink
|
||||||
|
GObject.connect(sink, 'handoff', handoff)
|
||||||
|
src.set_property('silent', 1)
|
||||||
|
|
||||||
|
# add objects to the main pipeline
|
||||||
|
for e in (src, sink):
|
||||||
|
bin.add(e)
|
||||||
|
|
||||||
|
# connect the elements
|
||||||
|
res = src.connect('src', sink, 'sink')
|
||||||
|
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()
|
58
examples/gst/oggplay.py
Executable file
58
examples/gst/oggplay.py
Executable file
|
@ -0,0 +1,58 @@
|
||||||
|
#!/usr/bin/env python2.2
|
||||||
|
|
||||||
|
from gstreamer import *
|
||||||
|
|
||||||
|
def main():
|
||||||
|
"Basic example to play an Ogg Vorbis stream through OSS"
|
||||||
|
#gst_debug_set_categories(-1)
|
||||||
|
|
||||||
|
if len(sys.argv) != 2:
|
||||||
|
print 'usage: %s <Ogg Vorbis file>' % (sys.argv[0])
|
||||||
|
return -1
|
||||||
|
|
||||||
|
# create a new bin to hold the elements
|
||||||
|
bin = gst_pipeline_new ('pipeline')
|
||||||
|
|
||||||
|
# create a disk reader
|
||||||
|
filesrc = gst_elementfactory_make ('filesrc', 'disk_source');
|
||||||
|
if not filesrc:
|
||||||
|
print 'could not find plugin \"filesrc\"'
|
||||||
|
return -1
|
||||||
|
filesrc.set_property('location', sys.argv[1])
|
||||||
|
|
||||||
|
# now get the decoder
|
||||||
|
decoder = gst_elementfactory_make ('vorbisdec', 'parse');
|
||||||
|
if not decoder:
|
||||||
|
print 'could not find plugin \"vorbisdec\"'
|
||||||
|
return -1
|
||||||
|
|
||||||
|
# and an audio sink
|
||||||
|
osssink = gst_elementfactory_make ('osssink', 'play_audio')
|
||||||
|
if not osssink:
|
||||||
|
print 'could not find plugin \"osssink\"'
|
||||||
|
return -1
|
||||||
|
|
||||||
|
# add objects to the main pipeline
|
||||||
|
for e in (filesrc, decoder, osssink):
|
||||||
|
bin.add(e)
|
||||||
|
|
||||||
|
# connect the elements
|
||||||
|
previous = None
|
||||||
|
for e in (filesrc, decoder, osssink):
|
||||||
|
if previous:
|
||||||
|
previous.connect('src', e, 'sink')
|
||||||
|
previous = e
|
||||||
|
|
||||||
|
# start playing
|
||||||
|
bin.set_state(STATE_PLAYING);
|
||||||
|
|
||||||
|
while bin.iterate(): pass
|
||||||
|
|
||||||
|
# stop the bin
|
||||||
|
bin.set_state(STATE_NULL)
|
||||||
|
|
||||||
|
return 0
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
ret = main()
|
||||||
|
sys.exit(ret)
|
3
examples/gstreamer/.gitignore
vendored
3
examples/gstreamer/.gitignore
vendored
|
@ -1,2 +1,5 @@
|
||||||
Makefile.in
|
Makefile.in
|
||||||
Makefile
|
Makefile
|
||||||
|
*.pyc
|
||||||
|
*.pyo
|
||||||
|
*.swp
|
||||||
|
|
64
examples/gstreamer/cp.py
Executable file
64
examples/gstreamer/cp.py
Executable file
|
@ -0,0 +1,64 @@
|
||||||
|
#!/usr/bin/env python2.2
|
||||||
|
|
||||||
|
from gstreamer import *
|
||||||
|
from gobject import GObject
|
||||||
|
|
||||||
|
def update(sender, *args):
|
||||||
|
print sender.get_name(), args
|
||||||
|
|
||||||
|
def main():
|
||||||
|
"A GStreamer based cp(1) with stats"
|
||||||
|
#gst_debug_set_categories(-1)
|
||||||
|
|
||||||
|
if len(sys.argv) != 3:
|
||||||
|
print 'usage: %s source dest' % (sys.argv[0])
|
||||||
|
return -1
|
||||||
|
|
||||||
|
# create a new bin to hold the elements
|
||||||
|
bin = gst_pipeline_new ('pipeline')
|
||||||
|
|
||||||
|
filesrc = gst_elementfactory_make ('filesrc', 'source');
|
||||||
|
if not filesrc:
|
||||||
|
print 'could not find plugin \"filesrc\"'
|
||||||
|
return -1
|
||||||
|
filesrc.set_property('location', sys.argv[1])
|
||||||
|
|
||||||
|
stats = gst_elementfactory_make ('statistics', 'stats');
|
||||||
|
if not stats:
|
||||||
|
print 'could not find plugin \"statistics\"'
|
||||||
|
return -1
|
||||||
|
stats.set_property('silent', 0)
|
||||||
|
stats.set_property('buffer_update_freq', 1)
|
||||||
|
stats.set_property('update_on_eos', 1)
|
||||||
|
#GObject.connect(stats, 'update', update)
|
||||||
|
|
||||||
|
filesink = gst_elementfactory_make ('disksink', 'sink')
|
||||||
|
if not filesink:
|
||||||
|
print 'could not find plugin \"disksink\"'
|
||||||
|
return -1
|
||||||
|
filesink.set_property('location', sys.argv[2])
|
||||||
|
|
||||||
|
# add objects to the main pipeline
|
||||||
|
for e in (filesrc, stats, filesink):
|
||||||
|
bin.add(e)
|
||||||
|
|
||||||
|
# connect the elements
|
||||||
|
previous = None
|
||||||
|
for e in (filesrc, stats, filesink):
|
||||||
|
if previous:
|
||||||
|
previous.connect('src', e, 'sink')
|
||||||
|
previous = e
|
||||||
|
|
||||||
|
# start playing
|
||||||
|
bin.set_state(STATE_PLAYING);
|
||||||
|
|
||||||
|
while bin.iterate(): pass
|
||||||
|
|
||||||
|
# stop the bin
|
||||||
|
bin.set_state(STATE_NULL)
|
||||||
|
|
||||||
|
return 0
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
ret = main()
|
||||||
|
sys.exit (ret)
|
45
examples/gstreamer/f2f.py
Executable file
45
examples/gstreamer/f2f.py
Executable file
|
@ -0,0 +1,45 @@
|
||||||
|
#!/usr/bin/env python2.2
|
||||||
|
|
||||||
|
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)
|
||||||
|
bin = gst_pipeline_new ('pipeline')
|
||||||
|
assert bin
|
||||||
|
|
||||||
|
src = gst_elementfactory_make ('fakesrc', 'src')
|
||||||
|
assert src
|
||||||
|
GObject.connect(src, 'handoff', handoff)
|
||||||
|
src.set_property('silent', 1)
|
||||||
|
src.set_property('num_buffers', 10)
|
||||||
|
|
||||||
|
sink = gst_elementfactory_make ('fakesink', 'sink')
|
||||||
|
assert sink
|
||||||
|
GObject.connect(sink, 'handoff', handoff)
|
||||||
|
src.set_property('silent', 1)
|
||||||
|
|
||||||
|
# add objects to the main pipeline
|
||||||
|
for e in (src, sink):
|
||||||
|
bin.add(e)
|
||||||
|
|
||||||
|
# connect the elements
|
||||||
|
res = src.connect('src', sink, 'sink')
|
||||||
|
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()
|
58
examples/gstreamer/oggplay.py
Executable file
58
examples/gstreamer/oggplay.py
Executable file
|
@ -0,0 +1,58 @@
|
||||||
|
#!/usr/bin/env python2.2
|
||||||
|
|
||||||
|
from gstreamer import *
|
||||||
|
|
||||||
|
def main():
|
||||||
|
"Basic example to play an Ogg Vorbis stream through OSS"
|
||||||
|
#gst_debug_set_categories(-1)
|
||||||
|
|
||||||
|
if len(sys.argv) != 2:
|
||||||
|
print 'usage: %s <Ogg Vorbis file>' % (sys.argv[0])
|
||||||
|
return -1
|
||||||
|
|
||||||
|
# create a new bin to hold the elements
|
||||||
|
bin = gst_pipeline_new ('pipeline')
|
||||||
|
|
||||||
|
# create a disk reader
|
||||||
|
filesrc = gst_elementfactory_make ('filesrc', 'disk_source');
|
||||||
|
if not filesrc:
|
||||||
|
print 'could not find plugin \"filesrc\"'
|
||||||
|
return -1
|
||||||
|
filesrc.set_property('location', sys.argv[1])
|
||||||
|
|
||||||
|
# now get the decoder
|
||||||
|
decoder = gst_elementfactory_make ('vorbisdec', 'parse');
|
||||||
|
if not decoder:
|
||||||
|
print 'could not find plugin \"vorbisdec\"'
|
||||||
|
return -1
|
||||||
|
|
||||||
|
# and an audio sink
|
||||||
|
osssink = gst_elementfactory_make ('osssink', 'play_audio')
|
||||||
|
if not osssink:
|
||||||
|
print 'could not find plugin \"osssink\"'
|
||||||
|
return -1
|
||||||
|
|
||||||
|
# add objects to the main pipeline
|
||||||
|
for e in (filesrc, decoder, osssink):
|
||||||
|
bin.add(e)
|
||||||
|
|
||||||
|
# connect the elements
|
||||||
|
previous = None
|
||||||
|
for e in (filesrc, decoder, osssink):
|
||||||
|
if previous:
|
||||||
|
previous.connect('src', e, 'sink')
|
||||||
|
previous = e
|
||||||
|
|
||||||
|
# start playing
|
||||||
|
bin.set_state(STATE_PLAYING);
|
||||||
|
|
||||||
|
while bin.iterate(): pass
|
||||||
|
|
||||||
|
# stop the bin
|
||||||
|
bin.set_state(STATE_NULL)
|
||||||
|
|
||||||
|
return 0
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
ret = main()
|
||||||
|
sys.exit(ret)
|
Loading…
Reference in a new issue