From 8c718173266eca322377769f9c156b8ec46f65de Mon Sep 17 00:00:00 2001 From: Alexandre Savard <alexandresavard@alexandresavard-desktop.(none)> Date: Fri, 15 Jan 2010 16:22:41 -0500 Subject: [PATCH] [#1722] Add RTP fallback for SRTP --- .../src/audio/audiortp/AudioRtpFactory.h | 5 ++++ sflphone-common/src/sip/sipvoiplink.cpp | 30 ++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/sflphone-common/src/audio/audiortp/AudioRtpFactory.h b/sflphone-common/src/audio/audiortp/AudioRtpFactory.h index 664bf3ae2c..dab313e1a9 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 8bbd1a64db..e6f77b2f2c 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 { -- GitLab