diff options
author | MaZderMind <github@mazdermind.de> | 2015-05-14 11:57:38 +0200 |
---|---|---|
committer | MaZderMind <github@mazdermind.de> | 2015-05-14 11:57:38 +0200 |
commit | 912081c7563dd48d3718fe1aabc285da02992868 (patch) | |
tree | 70c4dbb1bf56113d5d27677a91d598612e7bf764 /voctocore/lib/avrawoutput.py | |
parent | 06fac2f7387b40b77a1d76335c0afe30d469e659 (diff) |
Handle Disconnects
Diffstat (limited to 'voctocore/lib/avrawoutput.py')
-rw-r--r-- | voctocore/lib/avrawoutput.py | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/voctocore/lib/avrawoutput.py b/voctocore/lib/avrawoutput.py index 70243bd..fd16e58 100644 --- a/voctocore/lib/avrawoutput.py +++ b/voctocore/lib/avrawoutput.py @@ -50,7 +50,6 @@ class AVRawOutput(object): ) self.log.debug('Launching Output-Pipeline:\n%s', pipeline) self.receiverPipeline = Gst.parse_launch(pipeline) - self.receiverPipeline.bus.add_signal_watch() self.receiverPipeline.set_state(Gst.State.PLAYING) self.log.debug('Binding to Output-Socket on [::]:%u', port) @@ -67,15 +66,19 @@ class AVRawOutput(object): conn, addr = sock.accept() self.log.info("Incomming Connection from %s", addr) - self.log.info('Adding fd %u to multifdsink', conn.fileno()) - self.receiverPipeline.get_by_name('fd').emit('add', conn.fileno()) + def on_disconnect(multifdsink, fileno): + if fileno == conn.fileno(): + self.log.debug('fd %u removed from multifdsink', fileno) + + self.currentConnections.remove(conn) + self.log.info('Disconnected Receiver %s, now %u Receiver connected', addr, len(self.currentConnections)) + + self.log.debug('Adding fd %u to multifdsink', conn.fileno()) + fdsink = self.receiverPipeline.get_by_name('fd') + fdsink.emit('add', conn.fileno()) + fdsink.connect('client-fd-removed', on_disconnect) self.currentConnections.append(conn) self.log.info('Now %u Receiver connected', len(self.currentConnections)) return True - - # FIXME handle disconnects - def disconnect(self, receiverPipeline, currentConnection): - self.currentConnections.remove(currentConnection) - self.log.info('Disconnected Receiver, now %u Receiver connected', len(self.currentConnections)) |