diff options
author | MaZderMind <peter@mazdermind.de> | 2014-08-24 15:36:26 +0200 |
---|---|---|
committer | MaZderMind <peter@mazdermind.de> | 2014-08-24 15:36:26 +0200 |
commit | 90001a38c03e41faeccd0b959753a00db670c61a (patch) | |
tree | 5b615386c6033fc40fa05c931ff4a435041f5183 /voctocore/voctocore.py | |
parent | e8775c12ff7027675a564cf722c7778ffd060cc9 (diff) |
basic quadmix impl
Diffstat (limited to 'voctocore/voctocore.py')
-rwxr-xr-x | voctocore/voctocore.py | 77 |
1 files changed, 65 insertions, 12 deletions
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) |