def setup(robot_config): global robotKey global no_mic global no_camera global stream_key global server global x_res global y_res global ffmpeg_location global v4l2_ctl_location global audio_hw_num global audio_device global audio_codec global audio_channels global audio_bitrate global audio_sample_rate global video_codec global video_bitrate global video_filter global video_device global audio_input_format global audio_input_options global audio_output_options global video_input_format global video_input_options global video_output_options global brightness global contrast global saturation robotKey = robot_config.get('robot', 'robot_key') if robot_config.has_option('misc', 'video_server'): server = robot_config.get('misc', 'video_server') else: server = robot_config.get('misc', 'server') no_mic = robot_config.getboolean('camera', 'no_mic') no_camera = robot_config.getboolean('camera', 'no_camera') ffmpeg_location = robot_config.get('ffmpeg', 'ffmpeg_location') v4l2_ctl_location = robot_config.get('ffmpeg', 'v4l2-ctl_location') x_res = robot_config.getint('camera', 'x_res') y_res = robot_config.getint('camera', 'y_res') if not no_camera: if robot_config.has_option('camera', 'brightness'): brightness = robot_config.get('camera', 'brightness') if robot_config.has_option('camera', 'contrast'): contrast = robot_config.get('camera', 'contrast') if robot_config.has_option('camera', 'saturation'): saturation = robot_config.get('camera', 'saturation') video_device = robot_config.get('camera', 'camera_device') video_codec = robot_config.get('ffmpeg', 'video_codec') video_bitrate = robot_config.get('ffmpeg', 'video_bitrate') video_input_format = robot_config.get('ffmpeg', 'video_input_format') video_input_options = robot_config.get('ffmpeg', 'video_input_options') video_output_options = robot_config.get('ffmpeg', 'video_output_options') if robot_config.has_option('ffmpeg', 'video_filter'): video_filter = robot_config.get('ffmpeg', 'video_filter') video_filter = '-vf %s' % video_filter if robot_config.getboolean('tts', 'ext_chat'): extended_command.add_command('.video', videoChatHandler) extended_command.add_command('.brightness', brightnessChatHandler) extended_command.add_command('.contrast', contrastChatHandler) extended_command.add_command('.saturation', saturationChatHandler) if not no_mic: if robot_config.has_option('camera', 'mic_num'): audio_hw_num = robot_config.get('camera', 'mic_num') else: log.warn("controller.conf is out of date. Consider updating.") audio_hw_num = robot_config.get('camera', 'audio_hw_num') if robot_config.has_option('camera', 'mic_device'): audio_device = robot_config.get('camera', 'mic_device') else: audio_device = robot_config.get('camera', 'audio_device') audio_codec = robot_config.get('ffmpeg', 'audio_codec') audio_bitrate = robot_config.get('ffmpeg', 'audio_bitrate') audio_sample_rate = robot_config.get('ffmpeg', 'audio_sample_rate') audio_channels = robot_config.get('ffmpeg', 'audio_channels') audio_input_format = robot_config.get('ffmpeg', 'audio_input_format') audio_input_options = robot_config.get('ffmpeg', 'audio_input_options') audio_output_options = robot_config.get('ffmpeg', 'audio_output_options') if robot_config.getboolean('tts', 'ext_chat'): extended_command.add_command('.audio', audioChatHandler) if audio_input_format == "alsa": extended_command.add_command('.mic', micHandler) # resolve device name to hw num, only with alsa if audio_input_format == "alsa": if audio_device != '': temp_hw_num = audio_util.getMicByName(audio_device.encode('utf-8')) if temp_hw_num != None: audio_hw_num = temp_hw_num # format the device for hw number if using alsa if audio_input_format == 'alsa': audio_device = 'hw:' + str(audio_hw_num)
def setup(robot_config): global robotID global no_mic global no_camera global messenger global videoPort global videoHost global audioHost global audioPort global stream_key global x_res global y_res global ffmpeg_location global v4l2_ctl_location global audio_hw_num global audio_device global audio_codec global audio_channels global audio_bitrate global audio_sample_rate global video_codec global video_bitrate global video_filter global video_device global audio_input_format global audio_input_options global audio_output_options global video_input_format global video_input_options global video_output_options global brightness global contrast global saturation global server_override robotID = robot_config.get('robot', 'robot_id') no_mic = robot_config.getboolean('camera', 'no_mic') no_camera = robot_config.getboolean('camera', 'no_camera') messenger = robot_config.getboolean('messenger', 'enable') ffmpeg_location = robot_config.get('ffmpeg', 'ffmpeg_location') v4l2_ctl_location = robot_config.get('ffmpeg', 'v4l2-ctl_location') stream_key = robot_config.get('robot', 'stream_key') x_res = robot_config.get('camera', 'x_res') y_res = robot_config.get('camera', 'y_res') server_override = robot_config.getboolean('misc', 'server_override') log.info("getting websocket relay host") websocketRelayHost = networking.getWebsocketRelayHost() if not no_camera: if robot_config.has_option('camera', 'brightness'): brightness = robot_config.get('camera', 'brightness') if robot_config.has_option('camera', 'contrast'): contrast = robot_config.get('camera', 'contrast') if robot_config.has_option('camera', 'saturation'): saturation = robot_config.get('camera', 'saturation') videoHost = websocketRelayHost['host'] videoPort = networking.videoPort log.debug("Relay host for video: %s:%s" % (videoHost, videoPort)) video_device = robot_config.get('camera', 'camera_device') video_codec = robot_config.get('ffmpeg', 'video_codec') video_bitrate = robot_config.get('ffmpeg', 'video_bitrate') video_input_format = robot_config.get('ffmpeg', 'video_input_format') video_input_options = robot_config.get('ffmpeg', 'video_input_options') video_output_options = robot_config.get('ffmpeg', 'video_output_options') if robot_config.has_option('ffmpeg', 'video_filter'): video_filter = robot_config.get('ffmpeg', 'video_filter') video_filter = '-vf %s' % video_filter if robot_config.getboolean('tts', 'ext_chat'): extended_command.add_command('.video', videoChatHandler) extended_command.add_command('.brightness', brightnessChatHandler) extended_command.add_command('.contrast', contrastChatHandler) extended_command.add_command('.saturation', saturationChatHandler) if not no_mic: audio_hw_num = robot_config.get('camera', 'audio_hw_num') audio_device = robot_config.get('camera', 'audio_device') if audio_device != '': temp_hw_num = audio_util.getMicByName(audio_device.encode('utf-8')) if temp_hw_num != None: audio_hw_num = temp_hw_num audioHost = websocketRelayHost['host'] audioPort = networking.audioPort log.debug("Relay host for audio: %s:%s" % (audioHost, audioPort)) audio_codec = robot_config.get('ffmpeg', 'audio_codec') audio_bitrate = robot_config.get('ffmpeg', 'audio_bitrate') audio_sample_rate = robot_config.get('ffmpeg', 'audio_sample_rate') audio_channels = robot_config.get('ffmpeg', 'audio_channels') audio_input_format = robot_config.get('ffmpeg', 'audio_input_format') audio_input_options = robot_config.get('ffmpeg', 'audio_input_options') audio_output_options = robot_config.get('ffmpeg', 'audio_output_options') if robot_config.getboolean('tts', 'ext_chat'): extended_command.add_command('.audio', audioChatHandler) # format the device for hw number if using alsa if audio_input_format == 'alsa': audio_device = 'hw:' + str(audio_hw_num) # load settings from site if not server_override: refreshFromOnlineSettings() networking.appServerSocketIO.on('command_to_robot', onCommandToRobot) networking.appServerSocketIO.on('robot_settings_changed', onRobotSettingsChanged)