Logo Search packages:      
Sourcecode: scenic version File versions  Download package

def scenic::application::Application::handle_invite (   self,
  message,
  addr 
)
handles the INVITE message. 
Refuses if : 
 * jackd is not running
 * We already just got an INVITE and didn't answer yet.

Definition at line 620 of file application.py.

                                          :
        """
        handles the INVITE message. 
        Refuses if : 
         * jackd is not running
         * We already just got an INVITE and didn't answer yet.
        """
        send_to_port = message["please_send_to_port"]
        def _simply_refuse(reason, become_available=False):
            communication.connect_send_and_disconnect(addr, send_to_port, {'msg':'REFUSE', 'reason':reason, 'sid':0})
            if become_available:
                self._is_negotiating = False

        if self.has_session():
            _simply_refuse(communication.REFUSE_REASON_BUSY)
            return
        
        self.got_bye = False
        self._check_protocol_version(message)
        
        def _on_contact_request_dialog_response(response):
            """
            User is accepting or declining an offer.
            @param result: Answer to the dialog.
            """
            if response:
                self.send_accept(addr)
            else:
                self.send_refuse_and_disconnect() 
        # check if the contact is in the addressbook
        contact = self._get_contact_by_addr(addr)
        invited_by = addr
        
        if contact is not None:
            invited_by = contact["name"]
        if self.has_negotiation_in_progress():
            log.info("REFUSING an INVITE, since we are already negotiating with some peer.")
            _simply_refuse(communication.REFUSE_REASON_BUSY)
            return
        self._is_negotiating = True
        
        def _preflight_check_cb(result):
            if result is False:
                _simply_refuse(communication.REFUSE_REASON_PROBLEMS, True)
            elif result is True:
                # FIXME: the copy of dict should be more straightforward.
                self.remote_config = {
                    "audio": message["audio"],
                    "video": message["video"],
                    "midi": message["midi"]
                    }
                if (self.config.audio_recv_enabled or self.config.audio_send_enabled) and (self.remote_config["audio"]["recv_enabled"] or self.remote_config["audio"]["send_enabled"]):
                    if message["audio"]["sampling_rate"] != self.get_local_sampling_rate():
                        msg = _("A mismatch in the sampling rate of JACK with remote peer has been detected.\nLocal sampling rate is %(local)s, whereas remote sampling rate is %(remote)s.") % {"local": self.get_local_sampling_rate(), "remote": message["audio"]["sampling_rate"]}
                        log.error(msg)
                        self.gui.show_error_dialog(msg)
                        _simply_refuse(communication.REFUSE_REASON_PROBLEM_JACKD_RATE_MISMATCH, True)
                        return
                if self.remote_config["audio"]["codec"] not in self._supported_codecs["audio"] and self.remote_config["audio"]["recv_enabled"] and self.config.audio_send_enabled:
                    msg = _("The remote peer is asking an audio codec that is not installed on your computer.")
                    log.error(msg)
                    self.gui.show_error_dialog(msg, self.remote_config["audio"]["codec"])
                    _simply_refuse(communication.REFUSE_REASON_PROBLEM_UNSUPPORTED_AUDIO_CODEC, True)
                    return
                if self.remote_config["video"]["codec"] not in self._supported_codecs["video"] and self.remote_config["video"]["send_enabled"] and self.config.video_send_enabled:
                    msg = _("The remote peer is asking a video codec that is not installed on your computer.")
                    log.error(msg)
                    self.gui.show_error_dialog(msg, self.remote_config["video"]["codec"])
                    _simply_refuse(communication.REFUSE_REASON_PROBLEM_UNSUPPORTED_VIDEO_CODEC, True)
                    return

                connected_deferred = self.client.connect(addr, message["please_send_to_port"])
                if contact is not None and contact["auto_accept"]:
                    log.info("Contact %s is on auto_accept. Accepting." % (invited_by))
                    def _connected_cb(proto):
                        self.send_accept(addr)
                    connected_deferred.addCallback(_connected_cb)
                else:
                    text = _("<b><big>%(invited_by)s is inviting you.</big></b>\n\nDo you accept?" % {"invited_by": invited_by})
                    dialog_deferred = self.gui.show_invited_dialog(text)
                    dialog_deferred.addCallback(_on_contact_request_dialog_response)
            else:
                _simply_refuse(result, True) # passing it the reason
        
        flight_check_deferred = self.check_if_ready_to_stream(role="answerer")
        flight_check_deferred.addCallback(_preflight_check_cb)
    

Generated by  Doxygen 1.6.0   Back to index