class DVBStreamerController(Controller): """ Class to control a DVBStreamer server. """ def __init__(self): Controller.__init__(self) # Create DVBStreamer objects username = '******' password = '******' try: username = config.DVBSTREAMER_USERNAME password = config.DVBSTREAMER_PASSWORD except: pass self.manager = DVBStreamerManager(username, password) self.last_device = None def start_filling(self, buffer, videogroup, channel, timeout): """ Start filling the supplied buffer using the device supplied (VideoGroup) after tuning to the channel specified. If no data is received after timeout seconds send a Data Timed out event. """ device = videogroup.vdev try: self.manager.select(device, channel) except: traceback.print_exc() port = 1235 if device.find(':') != -1: ip_address = self.manager.controllers[device].my_ip else: ip_address = 'localhost' try: controller = self.manager.get_controller(device) controller.execute_command('setprop adapter.active true', True) except: logger.debug('Not DVBStreamer 2.x?') try: self.manager.enable_udp_output(device, ip_address, port) except: traceback.print_exc() self.last_device = device buffer.fill('udp', '%s:%d' % (ip_address, port)) def stop_filling(self): """ Stop filling the buffer supplied in the previous start_filling call. """ try: self.manager.disable_output(self.last_device) except: traceback.print_exc() try: controller = self.manager.get_controller(self.last_device) controller.execute_command('setprop adapter.active false', True) except: logger.debug('Not DVBStreamer 2.x?')