summaryrefslogtreecommitdiff
path: root/voctocore/experiments/startuptest/startuptest.py
blob: 58e676ad99be4126b18f65314949c411d7eeba35 (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, time
  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. print("PAUSED")
  37. self.pipeline.set_state(Gst.State.PAUSED)
  38. time.sleep(0.1)
  39. print("PLAYING")
  40. self.pipeline.set_state(Gst.State.PLAYING)
  41. self.mainloop.run()
  42. def kill(self):
  43. self.pipeline.set_state(Gst.State.NULL)
  44. self.mainloop.quit()
  45. example = Example()
  46. example.run()