Skip to content

Instantly share code, notes, and snippets.

@skagedal
Created May 31, 2013 22:06
Show Gist options
  • Save skagedal/5688300 to your computer and use it in GitHub Desktop.
Save skagedal/5688300 to your computer and use it in GitHub Desktop.
Test case for broken GStreamer 0.10 with PyGObject
#!/usr/bin/python
"""From https://bugzilla.gnome.org/show_bug.cgi?id=631901#c7 but with
some bug fixes. Should print message objects, but on GStreamer 0.10,
just prints None."""
from gi.repository import GObject
GObject.threads_init()
from gi.repository import Gst
Gst.init(None)
mainloop = GObject.MainLoop()
pipeline = Gst.Pipeline()
def on_eos(bus, msg):
print('eos: {!r}'.format(msg))
pipeline.set_state(Gst.State.NULL)
mainloop.quit()
def on_message(bus, msg):
print('message: {!r}'.format(msg))
bus = pipeline.get_bus()
bus.add_signal_watch()
bus.connect('message::eos', on_eos)
bus.connect('message', on_message)
bus = pipeline.get_bus()
bus.add_signal_watch()
bus.connect('message::eos', on_eos)
src = Gst.ElementFactory.make('videotestsrc', None)
src.set_property('num-buffers', 10)
sink = Gst.ElementFactory.make('fakesink', None)
pipeline.add(src)
pipeline.add(sink)
src.link(sink)
pipeline.set_state(Gst.State.PLAYING)
mainloop.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment