summaryrefslogtreecommitdiff
path: root/voctocore/experiments/failovertest.py
blob: fd43d83ece0b9b130164ef6a14fdeb162204dbb5 (plain)
  1. #!/usr/bin/python3
  2. import gi
  3. # import GStreamer and GTK-Helper classes
  4. gi.require_version('Gst', '1.0')
  5. from gi.repository import GLib, Gst, GObject
  6. # init GObject before importing local classes
  7. GObject.threads_init()
  8. Gst.init(None)
  9. from videodisplay import VideomixerWithDisplay
  10. from shmsrc import ShmSrc
  11. class Example:
  12. def __init__(self):
  13. self.mainloop = GObject.MainLoop()
  14. self.pipeline = Gst.Pipeline()
  15. self.bus = self.pipeline.get_bus()
  16. self.bus.add_signal_watch()
  17. self.bus.connect('message::eos', self.on_eos)
  18. self.bus.connect('message::error', self.on_error)
  19. self.mixdisplay = VideomixerWithDisplay()
  20. self.grabbersrc = ShmSrc('/tmp/grabber-v', Gst.Caps.from_string('video/x-raw,width=1280,height=720,framerate=25/1,format=BGRA'))
  21. # Add elements to pipeline
  22. self.pipeline.add(self.mixdisplay)
  23. self.pipeline.add(self.grabbersrc)
  24. self.grabbersrc.link(self.mixdisplay)
  25. def run(self):
  26. self.pipeline.set_state(Gst.State.PLAYING)
  27. self.mainloop.run()
  28. def kill(self):
  29. self.pipeline.set_state(Gst.State.NULL)
  30. self.mainloop.quit()
  31. def on_eos(self, bus, msg):
  32. print('on_eos()')
  33. #self.kill()
  34. def on_error(self, bus, msg):
  35. print('on_error():', msg.parse_error())
  36. #self.kill()
  37. example = Example()
  38. example.run()