diff --git a/sflphone-common/src/audio/audiortp/AudioRtpFactory.cpp b/sflphone-common/src/audio/audiortp/AudioRtpFactory.cpp index 84d44d91ea93fe6ce65ed0fdacd5569ecd928507..c88ecc6101e16ec71f237b1ebbae5f53230b6994 100644 --- a/sflphone-common/src/audio/audiortp/AudioRtpFactory.cpp +++ b/sflphone-common/src/audio/audiortp/AudioRtpFactory.cpp @@ -46,7 +46,7 @@ namespace sfl { -AudioRtpFactory::AudioRtpFactory() : _rtpSession (NULL) +AudioRtpFactory::AudioRtpFactory() : _rtpSession (NULL), remoteContext(NULL), localContext(NULL) { } @@ -160,6 +160,10 @@ void AudioRtpFactory::start (AudioCodec* audiocodec) case Sdes: + if(localContext && remoteContext) { + static_cast<AudioSrtpSession *> (_rtpSession)->restoreCryptoContext(localContext, remoteContext); + } + if (static_cast<AudioSrtpSession *> (_rtpSession)->startRtpThread (audiocodec) != 0) { throw AudioRtpFactoryException ("AudioRtpFactory: Error: Failed to start AudioSRtpSession thread"); } @@ -199,6 +203,8 @@ void AudioRtpFactory::stop (void) switch (_rtpSessionType) { case Sdes: + localContext = static_cast<AudioSrtpSession *> (_rtpSession)->_localCryptoCtx; + remoteContext = static_cast<AudioSrtpSession *> (_rtpSession)->_remoteCryptoCtx; static_cast<AudioSrtpSession *> (_rtpSession)->stopRtpThread(); break; diff --git a/sflphone-common/src/audio/audiortp/AudioRtpFactory.h b/sflphone-common/src/audio/audiortp/AudioRtpFactory.h index 8b5af4a0c671bec379adfb0001f02321171f1621..65983259a4f1f373df63a494feb141602d1ae000 100644 --- a/sflphone-common/src/audio/audiortp/AudioRtpFactory.h +++ b/sflphone-common/src/audio/audiortp/AudioRtpFactory.h @@ -33,6 +33,7 @@ #include <stdexcept> #include <cc++/thread.h> +#include <ccrtp/CryptoContext.h> #include "sip/SdesNegotiator.h" #include "audio/codecs/audiocodec.h" @@ -212,6 +213,12 @@ class AudioRtpFactory // Field used when initializinga udio rtp session // May be set manually or from config using initAudioRtpConfig bool _helloHashEnabled; + + /** Remote srtp crypto context to be set into incoming data queue. */ + ost::CryptoContext *remoteContext; + + /** Local srtp crypto context to be set into outgoing data queue. */ + ost::CryptoContext *localContext; }; } #endif // __AUDIO_RTP_FACTORY_H__ diff --git a/sflphone-common/src/audio/audiortp/AudioSrtpSession.cpp b/sflphone-common/src/audio/audiortp/AudioSrtpSession.cpp index 12ceea540ef6a313b2322e431e97cccf0fbd5fbc..e03c5a0e465f20c505320a885547c3acb7779cd2 100644 --- a/sflphone-common/src/audio/audiortp/AudioSrtpSession.cpp +++ b/sflphone-common/src/audio/audiortp/AudioSrtpSession.cpp @@ -65,6 +65,7 @@ AudioSrtpSession::AudioSrtpSession (ManagerImpl * manager, SIPCall * sipcall) : AudioSrtpSession::~AudioSrtpSession() { + _debug("AudioSrtp: Destroy audio srtp session"); } void AudioSrtpSession::initLocalCryptoInfo() @@ -294,7 +295,11 @@ void AudioSrtpSession::initializeLocalCryptoContext (void) } -#pragma GCC diagnostic ignored "-Wunused-value" +void AudioSrtpSession::restoreCryptoContext(ost::CryptoContext *localContext, ost::CryptoContext *remoteContext) { + setInQueueCryptoContext (remoteContext); + setOutQueueCryptoContext (localContext); +} + char* AudioSrtpSession::encodeBase64 (unsigned char *input, int length) { BIO *b64, *bmem; diff --git a/sflphone-common/src/audio/audiortp/AudioSrtpSession.h b/sflphone-common/src/audio/audiortp/AudioSrtpSession.h index 1a2ae15de08653ad537e228ac3b8dc86efcb0bec..f236dec7d0eead3bb299713908982c1b7f76f040 100644 --- a/sflphone-common/src/audio/audiortp/AudioSrtpSession.h +++ b/sflphone-common/src/audio/audiortp/AudioSrtpSession.h @@ -104,6 +104,19 @@ class AudioSrtpSession : public AudioRtpSession */ void initLocalCryptoInfo (void); + /** + * Restore the cryptographic context. most likely useful to restore + * a call after hold action + */ + void restoreCryptoContext(ost::CryptoContext *, ost::CryptoContext *); + + + /** Remote srtp crypto context to be set into incoming data queue. */ + ost::CryptoContext* _remoteCryptoCtx; + + /** Local srtp crypto context to be set into outgoing data queue. */ + ost::CryptoContext* _localCryptoCtx; + private: /** @@ -176,12 +189,6 @@ class AudioSrtpSession : public AudioRtpSession /** remote master salt length in byte */ int _remoteMasterSaltLength; - /** Remote srtp crypto context to be set into incoming data queue. */ - ost::CryptoContext* _remoteCryptoCtx; - - /** Local srtp crypto context to be set into outgoing data queue. */ - ost::CryptoContext* _localCryptoCtx; - /** Used to make sure remote crypto context not initialized wice. */ bool _remoteOfferIsSet; };