diff --git a/sflphone-common/src/audio/audiortp/AudioRtpFactory.h b/sflphone-common/src/audio/audiortp/AudioRtpFactory.h index 664bf3ae2cda5b2ae39804f6bfbcfc7b757413a7..dab313e1a90fe7421da0f8b4b3b77e908142c817 100644 --- a/sflphone-common/src/audio/audiortp/AudioRtpFactory.h +++ b/sflphone-common/src/audio/audiortp/AudioRtpFactory.h @@ -104,6 +104,11 @@ namespace sfl { * Sdes = 2 */ inline RtpMethod getAudioRtpType(void) { return _rtpSessionType; } + + /** + * @param Set internal audio rtp session type (Symmetric, Zrtp, Sdes) + */ + inline RtpMethod getAudioRtpType(RtpMethod type) { return _rtpSessionType = type; } /** * Get the current AudioZrtpSession. Throws an AudioRtpFactoryException diff --git a/sflphone-common/src/sip/sipvoiplink.cpp b/sflphone-common/src/sip/sipvoiplink.cpp index 8bbd1a64db98a73554d442a4a6139bc6cfb5b56e..e6f77b2f2c26eebb1fef597125c9b544859a24f2 100644 --- a/sflphone-common/src/sip/sipvoiplink.cpp +++ b/sflphone-common/src/sip/sipvoiplink.cpp @@ -3226,6 +3226,7 @@ void call_on_media_update (pjsip_inv_session *inv, pj_status_t status) CryptoOffer crypto_offer; call->getLocalSDP()->get_remote_sdp_crypto_from_offer(remote_sdp, crypto_offer); + bool nego_success = false; if(!crypto_offer.empty()) { _debug("Crypto attribute in SDP: init Srtp session"); @@ -3240,10 +3241,37 @@ void call_on_media_update (pjsip_inv_session *inv, pj_status_t status) if(sdesnego.negotiate()) { _debug("SDES negociation successfull \n"); - + nego_success = true; call->getAudioRtp()->setRemoteCryptoInfo(sdesnego); } + else { + + //@TODO Handle fallback mechanism here + // - Call may Failed if SrtpOnly + // - Call fallback to RTP (make sure PBX support it, if not ...) + // - Ask (display a pop-up message) + + call->getAudioRtp()->getAudioRtpType(); + + } + } + + // We did not found any crypto context for this media + if(!nego_success && call->getAudioRtp()->getAudioRtpType() == sfl::Sdes) { + + // We did not found any crypto context for this media + // @TODO if SRTPONLY, CallFail + + // if RTPFALLBACK, change RTP session + call->getAudioRtp()->stop(); + call->getAudioRtp()->getAudioRtpType(sfl::Symmetric); + call->getAudioRtp()->initAudioRtpSession(call); + } + if(nego_success && call->getAudioRtp()->getAudioRtpType() != sfl::Sdes) { + + // We found a crypto context for this media bt Sdes is not + // enabled for this call, make a try using RTP only } try {