diff options
author | MaZderMind <github@mazdermind.de> | 2014-08-05 09:56:51 +0200 |
---|---|---|
committer | MaZderMind <github@mazdermind.de> | 2014-08-05 09:56:51 +0200 |
commit | 800f2e4bca2a8c04784aa4eac1a4f64dd5edc57a (patch) | |
tree | fb42c0fce4ae8d6fda89ac962f9d7bab8ac022d1 /voctocore | |
parent | 440eb104cb53253646d2f55defc0120fb8c34687 (diff) |
experiment with fixing the signal watch and handling graceful failover of broken streams
Diffstat (limited to 'voctocore')
-rwxr-xr-x | voctocore/experiments/failovertest.py | 49 |
1 files changed, 49 insertions, 0 deletions
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() |