aboutsummaryrefslogtreecommitdiff
path: root/voctocore/experiments/failovertest.py
blob: 47b4341e8afcfa34e13264c4c243e261d7584f0c (plain)
  1. #!/usr/bin/python3
  2. import gi, time
  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=RGBx'))
  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.PAUSED)
  27. time.sleep(0.5)
  28. self.pipeline.set_state(Gst.State.PLAYING)
  29. self.mainloop.run()
  30. def kill(self):
  31. self.pipeline.set_state(Gst.State.NULL)
  32. self.mainloop.quit()
  33. def on_eos(self, bus, msg):
  34. print('on_eos()')
  35. #self.kill()
  36. def on_error(self, bus, msg):
  37. print('on_error():', msg.parse_error())
  38. #self.kill()
  39. example = Example()
  40. example.run()