X-Git-Url: https://git.ao2.it/experiments/gstreamer.git/blobdiff_plain/a4c52c06e5bd73066e704a476bb9388314c503b7..HEAD:/python/gst-input-selector-switch.py diff --git a/python/gst-input-selector-switch.py b/python/gst-input-selector-switch.py index f653dfa..db4754e 100755 --- a/python/gst-input-selector-switch.py +++ b/python/gst-input-selector-switch.py @@ -7,21 +7,20 @@ gi.require_version('Gst', '1.0') from gi.repository import Gst Gst.init(None) -from gi.repository import GObject -GObject.threads_init() +from gi.repository import GLib # The following pipeline works PIPELINE = """ videotestsrc pattern=0 ! selector. -videotestsrc pattern=13 ! selector. +videotestsrc pattern=18 background-color=4294901760 ! selector. input-selector name=selector ! autovideosink """ class Player: def __init__(self): - self.loop = GObject.MainLoop() + self.loop = GLib.MainLoop() self.pipeline = Gst.parse_launch(PIPELINE) self.selector = self.pipeline.get_by_name('selector') @@ -43,7 +42,7 @@ class Player: self.pipeline.set_state(Gst.State.NULL) self.loop.quit() - def switch(self): + def on_switch(self): active_pad = self.selector.get_property("active-pad") if active_pad.get_name() == "sink_0": new_pad = self.selector.get_static_pad("sink_1") @@ -76,10 +75,10 @@ def main(): def stdin_cb(source, condition): source.readline() - player.switch() + player.on_switch() return True - GObject.io_add_watch(sys.stdin, GObject.IO_IN, stdin_cb) + GLib.io_add_watch(sys.stdin, GLib.IO_IN, stdin_cb) print("\nPress Enter to switch the source\n") player.run()