2004-03-18 15:51:54 +00:00
|
|
|
#!/usr/bin/env python
|
examples/gstreamer/filesrc.py,player.py: New examples
Original commit message from CVS:
* examples/gstreamer/filesrc.py,player.py: New examples
* gstreamer/gstreamer.override: Add a dict like interface to GstTagList
* gstreamer/gstpad-handlers.override: New file, split out from gstreamer.override
* gstreamer/gst-types.defs: Don't use
gst_buffer_free/gst_data_free, use gst_data_unref instead.
* gstreamer/gst-types.c (PyGstData_to_value): Don't send address here.
* gstreamer/arg-types.py (GstDataPtrArg.write_param): Send the
address to stuff, since we really want to avoid segfaults :)
* gstreamer/0.6.[c,defs,h,override]: Remove, we're focusing on 0.7
* gstreamer/0.7.[c,defs,h,override]: Remove, merge with
gstreamer.*
* gstreamer/Makefile.am: Clean up, remove versioning support.
2004-02-27 18:01:52 +00:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
|
|
|
import gst
|
|
|
|
|
|
|
|
def found_tags(element, source, tags):
|
2004-03-08 14:32:14 +00:00
|
|
|
for tag in tags.keys():
|
2004-03-18 15:51:54 +00:00
|
|
|
print "%s: %s" % (gst.tag_get_nick(tag), tags[tag])
|
|
|
|
|
|
|
|
#def error(source, error, debug):
|
|
|
|
|
|
|
|
def deep_notify(*args):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def error(*args):
|
|
|
|
print args
|
examples/gstreamer/filesrc.py,player.py: New examples
Original commit message from CVS:
* examples/gstreamer/filesrc.py,player.py: New examples
* gstreamer/gstreamer.override: Add a dict like interface to GstTagList
* gstreamer/gstpad-handlers.override: New file, split out from gstreamer.override
* gstreamer/gst-types.defs: Don't use
gst_buffer_free/gst_data_free, use gst_data_unref instead.
* gstreamer/gst-types.c (PyGstData_to_value): Don't send address here.
* gstreamer/arg-types.py (GstDataPtrArg.write_param): Send the
address to stuff, since we really want to avoid segfaults :)
* gstreamer/0.6.[c,defs,h,override]: Remove, we're focusing on 0.7
* gstreamer/0.7.[c,defs,h,override]: Remove, merge with
gstreamer.*
* gstreamer/Makefile.am: Clean up, remove versioning support.
2004-02-27 18:01:52 +00:00
|
|
|
|
|
|
|
def playfile(filename):
|
|
|
|
bin = gst.Pipeline('player')
|
2004-03-18 15:51:54 +00:00
|
|
|
bin.connect('deep-notify', deep_notify)
|
|
|
|
bin.connect('error', error)
|
examples/gstreamer/filesrc.py,player.py: New examples
Original commit message from CVS:
* examples/gstreamer/filesrc.py,player.py: New examples
* gstreamer/gstreamer.override: Add a dict like interface to GstTagList
* gstreamer/gstpad-handlers.override: New file, split out from gstreamer.override
* gstreamer/gst-types.defs: Don't use
gst_buffer_free/gst_data_free, use gst_data_unref instead.
* gstreamer/gst-types.c (PyGstData_to_value): Don't send address here.
* gstreamer/arg-types.py (GstDataPtrArg.write_param): Send the
address to stuff, since we really want to avoid segfaults :)
* gstreamer/0.6.[c,defs,h,override]: Remove, we're focusing on 0.7
* gstreamer/0.7.[c,defs,h,override]: Remove, merge with
gstreamer.*
* gstreamer/Makefile.am: Clean up, remove versioning support.
2004-02-27 18:01:52 +00:00
|
|
|
|
|
|
|
source = gst.Element('filesrc', 'src')
|
|
|
|
source.set_property('location', filename)
|
|
|
|
|
|
|
|
spider = gst.Element('spider', 'spider')
|
|
|
|
spider.connect('found-tag', found_tags)
|
2004-03-18 15:51:54 +00:00
|
|
|
|
examples/gstreamer/filesrc.py,player.py: New examples
Original commit message from CVS:
* examples/gstreamer/filesrc.py,player.py: New examples
* gstreamer/gstreamer.override: Add a dict like interface to GstTagList
* gstreamer/gstpad-handlers.override: New file, split out from gstreamer.override
* gstreamer/gst-types.defs: Don't use
gst_buffer_free/gst_data_free, use gst_data_unref instead.
* gstreamer/gst-types.c (PyGstData_to_value): Don't send address here.
* gstreamer/arg-types.py (GstDataPtrArg.write_param): Send the
address to stuff, since we really want to avoid segfaults :)
* gstreamer/0.6.[c,defs,h,override]: Remove, we're focusing on 0.7
* gstreamer/0.7.[c,defs,h,override]: Remove, merge with
gstreamer.*
* gstreamer/Makefile.am: Clean up, remove versioning support.
2004-02-27 18:01:52 +00:00
|
|
|
sink = gst.Element('osssink', 'sink')
|
2004-03-18 15:51:54 +00:00
|
|
|
#sink.set_property('release-device', 1)
|
examples/gstreamer/filesrc.py,player.py: New examples
Original commit message from CVS:
* examples/gstreamer/filesrc.py,player.py: New examples
* gstreamer/gstreamer.override: Add a dict like interface to GstTagList
* gstreamer/gstpad-handlers.override: New file, split out from gstreamer.override
* gstreamer/gst-types.defs: Don't use
gst_buffer_free/gst_data_free, use gst_data_unref instead.
* gstreamer/gst-types.c (PyGstData_to_value): Don't send address here.
* gstreamer/arg-types.py (GstDataPtrArg.write_param): Send the
address to stuff, since we really want to avoid segfaults :)
* gstreamer/0.6.[c,defs,h,override]: Remove, we're focusing on 0.7
* gstreamer/0.7.[c,defs,h,override]: Remove, merge with
gstreamer.*
* gstreamer/Makefile.am: Clean up, remove versioning support.
2004-02-27 18:01:52 +00:00
|
|
|
|
|
|
|
bin.add_many(source, spider, sink)
|
2004-03-18 15:51:54 +00:00
|
|
|
if not gst.element_link_many(source, spider, sink):
|
|
|
|
print "ERROR: could not link"
|
|
|
|
sys.exit (1)
|
examples/gstreamer/filesrc.py,player.py: New examples
Original commit message from CVS:
* examples/gstreamer/filesrc.py,player.py: New examples
* gstreamer/gstreamer.override: Add a dict like interface to GstTagList
* gstreamer/gstpad-handlers.override: New file, split out from gstreamer.override
* gstreamer/gst-types.defs: Don't use
gst_buffer_free/gst_data_free, use gst_data_unref instead.
* gstreamer/gst-types.c (PyGstData_to_value): Don't send address here.
* gstreamer/arg-types.py (GstDataPtrArg.write_param): Send the
address to stuff, since we really want to avoid segfaults :)
* gstreamer/0.6.[c,defs,h,override]: Remove, we're focusing on 0.7
* gstreamer/0.7.[c,defs,h,override]: Remove, merge with
gstreamer.*
* gstreamer/Makefile.am: Clean up, remove versioning support.
2004-02-27 18:01:52 +00:00
|
|
|
|
|
|
|
print 'Playing:', os.path.basename(filename)
|
2004-03-18 15:51:54 +00:00
|
|
|
if not bin.set_state(gst.STATE_PLAYING):
|
|
|
|
print "ERROR: could not set bin to playing"
|
|
|
|
sys.exit (1)
|
examples/gstreamer/filesrc.py,player.py: New examples
Original commit message from CVS:
* examples/gstreamer/filesrc.py,player.py: New examples
* gstreamer/gstreamer.override: Add a dict like interface to GstTagList
* gstreamer/gstpad-handlers.override: New file, split out from gstreamer.override
* gstreamer/gst-types.defs: Don't use
gst_buffer_free/gst_data_free, use gst_data_unref instead.
* gstreamer/gst-types.c (PyGstData_to_value): Don't send address here.
* gstreamer/arg-types.py (GstDataPtrArg.write_param): Send the
address to stuff, since we really want to avoid segfaults :)
* gstreamer/0.6.[c,defs,h,override]: Remove, we're focusing on 0.7
* gstreamer/0.7.[c,defs,h,override]: Remove, merge with
gstreamer.*
* gstreamer/Makefile.am: Clean up, remove versioning support.
2004-02-27 18:01:52 +00:00
|
|
|
|
2004-03-18 15:51:54 +00:00
|
|
|
playing = 1
|
|
|
|
while playing:
|
|
|
|
try:
|
|
|
|
if not bin.iterate():
|
|
|
|
playing = 0
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
if not bin.set_state(gst.STATE_PAUSED):
|
|
|
|
print "ERROR: could not set bin to paused"
|
|
|
|
sys.exit (1)
|
|
|
|
print "Paused. Press Enter to go back to playing."
|
|
|
|
try:
|
|
|
|
sys.stdin.readline ()
|
|
|
|
if not bin.set_state(gst.STATE_PLAYING):
|
|
|
|
print "ERROR: could not set bin to playing"
|
|
|
|
sys.exit (1)
|
|
|
|
print "Playing."
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
playing = 0
|
|
|
|
print "DONE playing"
|
examples/gstreamer/filesrc.py,player.py: New examples
Original commit message from CVS:
* examples/gstreamer/filesrc.py,player.py: New examples
* gstreamer/gstreamer.override: Add a dict like interface to GstTagList
* gstreamer/gstpad-handlers.override: New file, split out from gstreamer.override
* gstreamer/gst-types.defs: Don't use
gst_buffer_free/gst_data_free, use gst_data_unref instead.
* gstreamer/gst-types.c (PyGstData_to_value): Don't send address here.
* gstreamer/arg-types.py (GstDataPtrArg.write_param): Send the
address to stuff, since we really want to avoid segfaults :)
* gstreamer/0.6.[c,defs,h,override]: Remove, we're focusing on 0.7
* gstreamer/0.7.[c,defs,h,override]: Remove, merge with
gstreamer.*
* gstreamer/Makefile.am: Clean up, remove versioning support.
2004-02-27 18:01:52 +00:00
|
|
|
bin.set_state(gst.STATE_NULL)
|
|
|
|
|
|
|
|
def main(args):
|
|
|
|
map(playfile, args[1:])
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
sys.exit(main(sys.argv))
|
|
|
|
|