def _NH_SIPApplicationDidStart(self, sender, data): settings = SIPSimpleSettings() settings.audio.enable_aec = settings.audio.echo_canceller.enabled settings.audio.sound_card_delay = settings.audio.echo_canceller.tail_length self._app.engine.enable_colorbar_device = False BlinkLogger().log_debug("SDK loaded") BlinkLogger().log_debug("SIP device ID: %s" % settings.instance_id) available_codecs_print = list(beautify_audio_codec(codec.decode()) for codec in self._app.engine._ua.available_codecs) codecs_print = list(beautify_audio_codec(codec) for codec in settings.rtp.audio_codec_list) BlinkLogger().log_info("Available audio codecs: %s" % ", ".join(available_codecs_print)) BlinkLogger().log_info("Enabled audio codecs: %s" % ", ".join(codecs_print)) if settings.audio.input_device is None: BlinkLogger().log_info("Switching audio input device to system default") settings.audio.input_device = 'system_default' if settings.audio.output_device is None: BlinkLogger().log_info("Switching audio output device to system default") settings.audio.output_device = 'system_default' if settings.audio.alert_device is None: BlinkLogger().log_info("Switching audio alert device to system default") settings.audio.alert_device = 'system_default' try: from VideoController import VideoController except ImportError: pass else: if settings.video.max_bitrate is not None and settings.video.max_bitrate > 10000: settings.video.max_bitrate = 4.0 available_video_codecs_print = list(beautify_video_codec(codec.decode()) for codec in self._app.engine._ua.available_video_codecs) video_codecs_print = list(beautify_video_codec(codec) for codec in settings.rtp.video_codec_list) BlinkLogger().log_info("Available video codecs: %s" % ", ".join(available_video_codecs_print)) BlinkLogger().log_info("Enabled video codecs: %s" % ", ".join(video_codecs_print)) BlinkLogger().log_info(u"Available video cameras: %s" % ", ".join(NSApp.delegate().video_devices)) if settings.video.device != "system_default" and settings.video.device != self._app.video_device.real_name and self._app.video_device.real_name != None: settings.video.device = self._app.video_device.real_name BlinkLogger().log_info(u"Using video camera %s" % self._app.video_device.real_name) elif settings.video.device is None: devices = list(device for device in self._app.engine.video_devices if device not in ('system_default', None)) if devices: BlinkLogger().log_info("Switching video camera to %s" % devices[0]) settings.video.device = devices[0] else: BlinkLogger().log_info("Using video camera %s" % self._app.video_device.real_name) settings.save() bonjour_account = BonjourAccount() if bonjour_account.enabled: for transport in settings.sip.transport_list: try: BlinkLogger().log_debug('Bonjour Account listens on %s' % bonjour_account.contact[transport]) except KeyError: pass self.init_configurations()
def _NH_SIPApplicationDidStart(self, sender, data): settings = SIPSimpleSettings() BlinkLogger().log_info(u"Core started") BlinkLogger().log_info(u"SIP device ID: %s" % settings.instance_id) codecs_print = [] for codec in settings.rtp.audio_codec_list: codecs_print.append(beautify_audio_codec(codec)) BlinkLogger().log_info(u"Enabled audio codecs: %s" % ", ".join(codecs_print)) bonjour_account = BonjourAccount() if bonjour_account.enabled: for transport in settings.sip.transport_list: try: BlinkLogger().log_debug(u'Bonjour Account listens on %s' % bonjour_account.contact[transport]) except KeyError: pass self.init_configurations()
def updateAudio(self): if self.audio_status.stringValue() and ( self.sessionController is None or self.audio_stream is None or self.audio_stream.stream is None): self.resetAudio() elif (self.sessionController is not None and self.audio_stream is not None and self.audio_stream.stream is not None): self.updateAudioStatus() self.audio_rtt_graph.setDataQueue_needsDisplay_( self.audio_stream.rtt_history, True if self.window.isVisible() else False) self.rx_speed_graph.setDataQueue_needsDisplay_( self.audio_stream.rx_speed_history, True if self.window.isVisible() else False) self.tx_speed_graph.setDataQueue_needsDisplay_( self.audio_stream.tx_speed_history, True if self.window.isVisible() else False) self.audio_packet_loss_rx_graph.setDataQueue_needsDisplay_( self.audio_stream.loss_rx_history, True if self.window.isVisible() else False) self.audio_packet_loss_tx_graph.setDataQueue_needsDisplay_( self.audio_stream.loss_tx_history, True if self.window.isVisible() else False) rtt = self.audio_stream.statistics['rtt'] if rtt > 1000: text = '%.1f s' % (float(rtt) / 1000.0) elif rtt > 100: text = '%d ms' % rtt elif rtt: text = '%d ms' % rtt else: text = '' self.rx_speed.setStringValue_('Rx %s/s' % format_size( self.audio_stream.statistics['rx_bytes'], bits=True)) self.tx_speed.setStringValue_('Tx %s/s' % format_size( self.audio_stream.statistics['tx_bytes'], bits=True)) self.audio_rtt.setStringValue_(text) if self.audio_stream.statistics['loss_rx'] > 3: self.audio_packet_loss_rx.setStringValue_( 'Local: %.1f %%' % self.audio_stream.statistics['loss_rx']) else: self.audio_packet_loss_rx.setStringValue_('') if self.audio_stream.statistics['loss_tx'] > 3: self.audio_packet_loss_tx.setStringValue_( 'Remote: %.1f %%' % self.audio_stream.statistics['loss_tx']) else: self.audio_packet_loss_tx.setStringValue_('') if self.audio_stream.stream.codec and self.audio_stream.stream.sample_rate: codec = beautify_audio_codec(self.audio_stream.stream.codec) try: settings = SIPSimpleSettings() sample_rate = self.audio_stream.stream.sample_rate / 1000 codec = codec + " %0.fkHz" % sample_rate except TypeError: pass self.audio_codec.setStringValue_(codec) self.audio_srtp_lock.setHidden_( False if self.audio_stream.encryption_active else True) if self.audio_stream.encryption_active: if self.audio_stream.zrtp_active: self.audio_srtp_lock.setImage_( NSImage.imageNamed_("locked-green") if self. audio_stream.zrtp_verified else NSImage. imageNamed_("locked-red")) else: self.audio_srtp_lock.setImage_( NSImage.imageNamed_("srtp")) else: self.audio_codec.setStringValue_('') self.audio_srtp_lock.setHidden_(True) self.audio_remote_endpoint.setStringValue_( '%s:%s' % (self.audio_stream.stream.remote_rtp_address, self.audio_stream.stream.remote_rtp_port) if self. audio_stream.stream.remote_rtp_address else '') if self.audio_stream.stream.ice_active: ice_status = self.audio_stream.ice_negotiation_status if self.audio_stream.ice_negotiation_status is not None else '' if self.audio_stream.stream.ice_active: if self.audio_stream.stream.local_rtp_candidate and self.audio_stream.stream.remote_rtp_candidate: if self.audio_stream.stream.local_rtp_candidate.type.lower( ) != 'relay' and self.audio_stream.stream.remote_rtp_candidate.type.lower( ) != 'relay': if self.audio_stream.stream.local_rtp_candidate.type.lower( ) == 'host' and self.audio_stream.stream.remote_rtp_candidate.type.lower( ) == 'host': ice_status = NSLocalizedString( "Host to Host", "Label") else: ice_status = NSLocalizedString( "Peer to Peer", "Label") else: ice_status = NSLocalizedString( "Server Relayed", "Label") else: ice_status = self.audio_stream.ice_negotiation_status if self.audio_stream.ice_negotiation_status is not None else '' if ice_status == b"All ICE checklists failed (PJNATH_EICEFAILED)": ice_status = NSLocalizedString("Probing Failed", "Label") elif ice_status == b"Remote answer doesn't support ICE": ice_status = NSLocalizedString("Not Supported", "Label") self.audio_ice_negotiation.setStringValue_(ice_status)
def updateAudio(self): if self.audio_status.stringValue() and (self.sessionController is None or self.audio_stream is None or self.audio_stream.stream is None): self.resetAudio() elif (self.sessionController is not None and self.audio_stream is not None and self.audio_stream.stream is not None): self.updateAudioStatus() self.audio_rtt_graph.setDataQueue_needsDisplay_(self.audio_stream.rtt_history, True if self.window.isVisible() else False) self.rx_speed_graph.setDataQueue_needsDisplay_(self.audio_stream.rx_speed_history, True if self.window.isVisible() else False) self.tx_speed_graph.setDataQueue_needsDisplay_(self.audio_stream.tx_speed_history, True if self.window.isVisible() else False) self.audio_packet_loss_graph.setDataQueue_needsDisplay_(self.audio_stream.loss_history, True if self.window.isVisible() else False) rtt = self.audio_stream.statistics['rtt'] if rtt > 1000: text = '%.1f s' % (float(rtt)/1000.0) elif rtt > 100: text = '%d ms' % rtt elif rtt: text = '%d ms' % rtt else: text = '' self.rx_speed.setStringValue_('Rx %s/s' % format_size(self.audio_stream.statistics['rx_bytes'], bits=True)) self.tx_speed.setStringValue_('Tx %s/s' % format_size(self.audio_stream.statistics['tx_bytes'], bits=True)) self.audio_rtt.setStringValue_(text) self.audio_packet_loss.setStringValue_('%.1f %%' % self.audio_stream.statistics['loss'] if self.audio_stream.statistics['loss'] else '') if self.audio_stream.stream.codec and self.audio_stream.stream.sample_rate: codec = beautify_audio_codec(self.audio_stream.stream.codec) try: settings = SIPSimpleSettings() sample_rate = self.audio_stream.stream.sample_rate/1000 codec = codec + " %0.fkHz" % sample_rate except TypeError: pass self.audio_codec.setStringValue_(codec) self.audio_srtp_lock.setHidden_(False if self.audio_stream.stream.srtp_active else True) else: self.audio_codec.setStringValue_('') self.audio_srtp_lock.setHidden_(True) self.audio_remote_endpoint.setStringValue_('%s:%s' % (self.audio_stream.stream.remote_rtp_address, self.audio_stream.stream.remote_rtp_port) if self.audio_stream.stream.remote_rtp_address else '') if self.audio_stream.stream.ice_active: if self.audio_stream.stream.local_rtp_candidate is not None: try: candidate = ice_candidates[self.audio_stream.stream.local_rtp_candidate.type.lower()] except KeyError: candidate = self.audio_stream.stream.local_rtp_candidate.type.capitalize() else: candidate = '' self.audio_ice_local_candidate.setStringValue_(candidate) if self.audio_stream.stream.remote_rtp_candidate is not None: try: candidate = ice_candidates[self.audio_stream.stream.remote_rtp_candidate.type.lower()] except KeyError: candidate = self.audio_stream.stream.remote_rtp_candidate.type.capitalize() else: candidate = '' self.audio_ice_remote_candidate.setStringValue_(candidate) ice_status = self.audio_stream.ice_negotiation_status if self.audio_stream.ice_negotiation_status is not None else '' if self.audio_stream.stream.ice_active: if self.audio_stream.stream.local_rtp_candidate and self.audio_stream.stream.remote_rtp_candidate: if self.audio_stream.stream.local_rtp_candidate.type.lower() != 'relay' and self.audio_stream.stream.remote_rtp_candidate.type.lower() != 'relay': ice_status += ' ('+ NSLocalizedString("Peer to Peer", "Label")+')' else: ice_status += ' ('+ NSLocalizedString("Server Relayed", "Label") + ')' else: self.audio_ice_local_candidate.setStringValue_('') self.audio_ice_remote_candidate.setStringValue_('') ice_status = self.audio_stream.ice_negotiation_status if self.audio_stream.ice_negotiation_status is not None else '' self.audio_ice_negotiation.setStringValue_(ice_status)
def updateAudio(self): if self.audio_status.stringValue() and (self.sessionController is None or self.audio_stream is None or self.audio_stream.stream is None): self.resetAudio() elif (self.sessionController is not None and self.audio_stream is not None and self.audio_stream.stream is not None): self.updateAudioStatus() self.audio_rtt_graph.setDataQueue_needsDisplay_(self.audio_stream.rtt_history, True if self.window.isVisible() else False) self.audio_packet_loss_graph.setDataQueue_needsDisplay_(self.audio_stream.loss_history, True if self.window.isVisible() else False) rtt = self.audio_stream.statistics['rtt'] if rtt > 1000: text = '%.1f s' % (float(rtt)/1000.0) elif rtt > 100: text = '%d ms' % rtt elif rtt: text = '%d ms' % rtt else: text = '' self.audio_rtt.setStringValue_(text) self.audio_packet_loss.setStringValue_('%.1f %%' % self.audio_stream.statistics['loss'] if self.audio_stream.statistics['loss'] else '') if self.audio_stream.stream.codec and self.audio_stream.stream.sample_rate: codec = beautify_audio_codec(self.audio_stream.stream.codec) self.audio_codec.setStringValue_(codec) try: settings = SIPSimpleSettings() sample_rate = self.audio_stream.stream.sample_rate/1000 self.audio_sample_rate.setStringValue_("%0.fkHz" % sample_rate) except TypeError: pass if self.audio_stream.zrtp_active: label = 'zRTP Diffie-Hellman' elif self.audio_stream.stream.srtp_active: label = 'SDES' else: label = 'Disabled' self.audio_srtp_active.setStringValue_(label) self.audio_srtp_lock.setHidden_(False if self.audio_stream.stream.srtp_active else True) else: self.audio_codec.setStringValue_('') self.audio_sample_rate.setStringValue_('') self.audio_srtp_active.setStringValue_('') self.audio_srtp_lock.setHidden_(True) self.audio_local_endpoint.setStringValue_('%s:%s' % (self.audio_stream.stream.local_rtp_address, self.audio_stream.stream.local_rtp_port) if self.audio_stream.stream.local_rtp_address else '') self.audio_remote_endpoint.setStringValue_('%s:%s' % (self.audio_stream.stream.remote_rtp_address, self.audio_stream.stream.remote_rtp_port) if self.audio_stream.stream.remote_rtp_address else '') if self.audio_stream.stream.ice_active: if self.audio_stream.stream.local_rtp_candidate is not None: try: candidate = ice_candidates[self.audio_stream.stream.local_rtp_candidate.type.lower()] except KeyError: candidate = self.audio_stream.stream.local_rtp_candidate.type.capitalize() else: candidate = '' self.audio_ice_local_candidate.setStringValue_(candidate) if self.audio_stream.stream.remote_rtp_candidate is not None: try: candidate = ice_candidates[self.audio_stream.stream.remote_rtp_candidate.type.lower()] except KeyError: candidate = self.audio_stream.stream.remote_rtp_candidate.type.capitalize() else: candidate = '' self.audio_ice_remote_candidate.setStringValue_(candidate) ice_status = self.audio_stream.ice_negotiation_status if self.audio_stream.ice_negotiation_status is not None else '' if self.audio_stream.stream.ice_active: if self.audio_stream.stream.local_rtp_candidate and self.audio_stream.stream.remote_rtp_candidate: if self.audio_stream.stream.local_rtp_candidate.type.lower() != 'relay' and self.audio_stream.stream.remote_rtp_candidate.type.lower() != 'relay': ice_status += ' (Peer to Peer)' else: ice_status += ' (Server Relayed)' else: self.audio_ice_local_candidate.setStringValue_('') self.audio_ice_remote_candidate.setStringValue_('') ice_status = self.audio_stream.ice_negotiation_status if self.audio_stream.ice_negotiation_status is not None else '' self.audio_ice_negotiation.setStringValue_(ice_status)