summaryrefslogtreecommitdiff
path: root/voctocore/experiments/startuptest/startuptest.py
blob: 6e1802e71589efb6847b979391ea3d100271d16e (plain)
  1. #!/usr/bin/python3
  2. # Example for the startup-problem
  3. #
  4. # The Pipeline will start but the test-image will be still, as long as no
  5. # ShmSink at /tmp/grabber-v is present (run ../test-grabber-src.sh in another shell)
  6. #
  7. # Even though the ShmSrc is not linked to anything and logically not required for
  8. # the videotestsrc or the ximagesink, the whole pipeline won't startup when this element
  9. # fails to start.
  10. #
  11. # once the pipeline is running, it does not matter what happens to the ShmSink on the
  12. # other end, because the TestBin filters all EOS and ERROR Messages coming from the ShmSrc,
  13. # but somehow this is not enough to make the pipeline start in an error-condition..
  14. #
  15. import gi
  16. # import GStreamer and GTK-Helper classes
  17. gi.require_version('Gst', '1.0')
  18. from gi.repository import GLib, Gst, GObject
  19. # init GObject before importing local classes
  20. GObject.threads_init()
  21. Gst.init(None)
  22. from testbin import TestBin
  23. class Example:
  24. def __init__(self):
  25. self.mainloop = GObject.MainLoop()
  26. self.pipeline = Gst.Pipeline()
  27. self.src = Gst.ElementFactory.make('videotestsrc', None)
  28. self.sink = Gst.ElementFactory.make('ximagesink', None)
  29. self.testbin = TestBin()
  30. # Add elements to pipeline
  31. self.pipeline.add(self.testbin)
  32. self.pipeline.add(self.src)
  33. self.pipeline.add(self.sink)
  34. self.src.link(self.sink)
  35. def run(self):
  36. self.pipeline.set_state(Gst.State.PLAYING)
  37. self.mainloop.run()
  38. def kill(self):
  39. self.pipeline.set_state(Gst.State.NULL)
  40. self.mainloop.quit()
  41. def on_eos(self, bus, msg):
  42. print('on_eos()')
  43. #self.kill()
  44. def on_error(self, bus, msg):
  45. print('on_error():', msg.parse_error())
  46. #self.kill()
  47. example = Example()
  48. example.run()