diff options
author | MaZderMind <github@mazdermind.de> | 2015-05-23 14:52:23 +0200 |
---|---|---|
committer | MaZderMind <github@mazdermind.de> | 2015-05-23 14:52:23 +0200 |
commit | 4559b8f400da068623d1fa08a4a126fa8ded2117 (patch) | |
tree | 8fdb4f9d36c78835c8c72d5719a3d8978dbf3d3d /voctocore/lib/backgroundsource.py | |
parent | 84d4a5c1a43dd663392b899e986f162c7fbeb6b6 (diff) |
mixer background
Diffstat (limited to 'voctocore/lib/backgroundsource.py')
-rw-r--r-- | voctocore/lib/backgroundsource.py | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/voctocore/lib/backgroundsource.py b/voctocore/lib/backgroundsource.py new file mode 100644 index 0000000..1f3da54 --- /dev/null +++ b/voctocore/lib/backgroundsource.py @@ -0,0 +1,51 @@ +#!/usr/bin/python3 +import logging +from gi.repository import Gst + +from lib.config import Config +from lib.tcpsingleconnection import TCPSingleConnection + +class BackgroundSource(TCPSingleConnection): + def __init__(self, port): + self.log = logging.getLogger('BackgroundSource') + super().__init__(port) + + def on_accepted(self, conn, addr): + pipeline = """ + fdsrc fd={fd} ! + matroskademux ! + {vcaps} ! + intervideosink channel=mixer_background + """.format( + fd=conn.fileno(), + vcaps=Config.get('mix', 'videocaps') + ) + + self.log.debug('Launching Source-Pipeline:\n%s', pipeline) + self.receiverPipeline = Gst.parse_launch(pipeline) + + self.log.debug('Binding End-of-Stream-Signal on Source-Pipeline') + self.receiverPipeline.bus.add_signal_watch() + self.receiverPipeline.bus.connect("message::eos", self.on_eos) + self.receiverPipeline.bus.connect("message::error", self.on_error) + + self.receiverPipeline.set_state(Gst.State.PLAYING) + + + def on_eos(self, bus, message): + self.log.debug('Received End-of-Stream-Signal on Source-Pipeline') + if self.currentConnection is not None: + self.disconnect() + + def on_error(self, bus, message): + self.log.debug('Received Error-Signal on Source-Pipeline') + (error, debug) = message.parse_error() + self.log.debug('Error-Details: #%u: %s', error.code, debug) + + if self.currentConnection is not None: + self.disconnect() + + def disconnect(self): + self.receiverPipeline.set_state(Gst.State.NULL) + self.receiverPipeline = None + self.close_connection() |