def Reset(self): """Reset all detected chameleon devices.""" logging.info( 'Apply the default EDID and enable DDC on all video inputs') self._selected_input = None self._selected_output = None for port_id in self.GetSupportedInputs(): if self.HasVideoSupport(port_id): self.ApplyEdid(port_id, ids.EDID_ID_DEFAULT) self.SetDdcState(port_id, enabled=True) for port_id in self.GetSupportedPorts(): if self.HasAudioSupport(port_id): # Stops all audio capturing. if ids.IsInputPort( port_id) and self.flows[port_id].is_capturing_audio: try: self.flows[port_id].StopCapturingAudio() except Exception as e: logging.error('Failed to stop capturing audio: %s', str(e)) self.flows[port_id].ResetRoute() # Set all ports unplugged on initialization. for port_id in self.GetSupportedPorts(): self.Unplug(port_id)
def wrapper(instance, port_id, *args, **kwargs): if not ids.IsAudioPort(port_id): raise FlowManagerError( 'Not a valid port_id for audio operation: %d' % port_id) if input_only and not ids.IsInputPort(port_id): raise FlowManagerError( 'Not a valid port_id for input operation: %d' % port_id) elif output_only and not ids.IsOutputPort(port_id): raise FlowManagerError( 'Not a valid port_id for output operation: %d' % port_id) return func(instance, port_id, *args, **kwargs)
def StartPlayingEcho(self, port_id, input_id): """Echoes audio data received from input_id and plays to port_id. Echoes audio data received from input_id and plays to port_id. Chameleon does not support echoing from HDMI and capturing from LineIn/Mic at the same time. The echoing/capturing needs to be stop first before another action starts. For example, user can call StartPlayingEcho(3, 7) --> StopPlayingAudio(3) --> StartCapturingAudio(6) or StartCapturingAudio(6) --> StopCapturingAudio(6) --> StartPlayingEcho(3, 7) but user can not call StartPlayingEcho(3, 7) --> StartCapturingAudio(6) or StartCapturingAudio(6) --> StartPlayingEcho(3, 7) Exception is raised when conflicting actions are performed. Args: port_id: The ID of the output connector. Check the value in ids.py. input_id: The ID of the input connector. Check the value in ids.py. Raises: FlowManagerError: input_id is not valid for audio operation. """ if not ids.IsAudioPort(input_id) or not ids.IsInputPort(input_id): raise FlowManagerError( 'Not a valid input_id for audio operation: %d' % input_id) self.SelectInput(input_id) self.SelectOutput(port_id) logging.info( 'Start playing echo from port #%d using source from port#%d', port_id, input_id) self.flows[port_id].StartPlayingEcho(input_id)