From 800f2e4bca2a8c04784aa4eac1a4f64dd5edc57a Mon Sep 17 00:00:00 2001 From: MaZderMind Date: Tue, 5 Aug 2014 09:56:51 +0200 Subject: experiment with fixing the signal watch and handling graceful failover of broken streams --- voctocore/experiments/failovertest.py | 49 +++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100755 voctocore/experiments/failovertest.py (limited to 'voctocore/experiments/failovertest.py') diff --git a/voctocore/experiments/failovertest.py b/voctocore/experiments/failovertest.py new file mode 100755 index 0000000..3149197 --- /dev/null +++ b/voctocore/experiments/failovertest.py @@ -0,0 +1,49 @@ +#!/usr/bin/python3 +import gi +import signal +from termcolor import colored + +# import GStreamer and GTK-Helper classes +gi.require_version('Gst', '1.0') +from gi.repository import GLib, Gst, Gtk, GObject + +# init GObject before importing local classes +GObject.threads_init() +Gst.init(None) +loop = GLib.MainLoop() + +def busfunc(bus, message): + print(colored(message.src.get_name(), 'green'), message.type, message) + if message.type == Gst.MessageType.ERROR: + (err, debug) = message.parse_error() + print(colored(err, 'red')) + print(colored(debug, 'yellow')) + + if message.src.get_name() == 'http': + failover = p.get_by_name('failover') + failover.set_property('active-pad', failover.get_static_pad('sink_1')) + +# make killable by ctrl-c +signal.signal(signal.SIGINT, signal.SIG_DFL) + +print("parse_launch") +p = Gst.parse_launch(""" + input-selector name=failover ! autovideosink + + videotestsrc ! video/x-raw,width=1280,height=720 ! failover.sink_1 + souphttpsrc name=http location="http://localhost/~peter/ED_1280.avi" ! decodebin ! failover.sink_0 +""") + +print("add_watch") +bus = p.get_bus() +bus.add_signal_watch() +bus.connect('message', busfunc) + +# print("add_watch") +# httpbus = p.get_by_name('http').get_bus() +# httpbus.add_watch(0, busfunc, None) + +print("set_state(PLAYING)") +p.set_state(Gst.State.PLAYING) + +loop.run() -- cgit v1.2.3