From 90001a38c03e41faeccd0b959753a00db670c61a Mon Sep 17 00:00:00 2001 From: MaZderMind Date: Sun, 24 Aug 2014 15:36:26 +0200 Subject: basic quadmix impl --- voctocore/voctocore.py | 77 ++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 65 insertions(+), 12 deletions(-) (limited to 'voctocore/voctocore.py') diff --git a/voctocore/voctocore.py b/voctocore/voctocore.py index 454a09d..8c15463 100755 --- a/voctocore/voctocore.py +++ b/voctocore/voctocore.py @@ -1,31 +1,84 @@ #!/usr/bin/python3 -import gi, signal +import gi, signal, logging, sys -# import GStreamer and GTK-Helper classes +# import GStreamer and GLib-Helper classes gi.require_version('Gst', '1.0') -from gi.repository import GLib, Gst, Gtk, GObject +from gi.repository import GLib, Gst, GObject + +# check min-version +minGst = (1, 4) +minPy = (3, 0) + +if Gst.version() < minGst: + raise Exception("GStreamer version", Gst.version(), 'is too old, at least', minGst, 'is required') + +if sys.version_info < minPy: + raise Exception("Python version", sys.version_info, 'is too old, at least', minPy, 'is required') + # init GObject before importing local classes GObject.threads_init() Gst.init(None) # import local classes -from lib.videomix import Videomix +from lib.pipeline import Pipeline from lib.controlserver import ControlServer -class Main: +# main class +class Voctocore: + log = logging.getLogger('Voctocore') + def __init__(self): + self.log.debug('creating GObject-MainLoop') + self.mainloop = GObject.MainLoop() + # initialize subsystem - self.videomix = Videomix() - self.controlserver = ControlServer(self.videomix) + self.log.debug('creating Video-Pipeline') + self.pipeline = Pipeline() + + self.log.debug('creating ControlServer') + self.controlserver = ControlServer(self.pipeline) + + def run(self): + self.log.info('running Video-Pipeline') + self.pipeline.run() + + self.log.info('running GObject-MainLoop') + self.mainloop.run() + + def kill(self): + self.log.info('quitting Video-Pipeline') + self.pipeline.quit() + + self.log.info('quitting GObject-MainLoop') + self.mainloop.quit() + + def on_eos(self, bus, msg): + self.log.warning('received EOS-Signal on the Video-Bus from Element %s. This shouldn\'t happen if the program is not terminating right now', msg.src) + self.kill() + + def on_error(self, bus, msg): + err = msg.parse_error() + self.log.error('received Error-Signal on the Video-Bus from Element %s: %s', msg.src, err[1]) + self.kill() + + +# run mainclass +def main(argv): + # configure logging + logging.basicConfig(level=logging.DEBUG, + format='%(levelname)8s %(name)s: %(message)s') -def runmain(): # make killable by ctrl-c + logging.debug('setting SIGINT handler') signal.signal(signal.SIGINT, signal.SIG_DFL) - # start main-class and main-loop - start = Main() - Gtk.main() + # init main-class and main-loop + logging.debug('initializing Voctocore') + voctocore = Voctocore() + + logging.debug('running Voctocore') + voctocore.run() if __name__ == '__main__': - runmain() + main(sys.argv) -- cgit v1.2.3