Skip to content
Snippets Groups Projects
Commit 35e3d0e5 authored by Tristan Matthews's avatar Tristan Matthews
Browse files

* #6143: don't use getType outside of serialization methods

In AudioRtpFactory, we now have a registerAccount method that deals with
Account objects and another to deal with SIPAccount objects.
parent 74b3465b
No related branches found
No related tags found
No related merge requests found
...@@ -35,13 +35,12 @@ ...@@ -35,13 +35,12 @@
#include "AudioSrtpSession.h" #include "AudioSrtpSession.h"
#include "AudioSymmetricRtpSession.h" #include "AudioSymmetricRtpSession.h"
#include "manager.h" #include "manager.h"
#include "account.h"
#include "sip/sdp.h" #include "sip/sdp.h"
#include "sip/sipcall.h" #include "sip/sipcall.h"
#include "sip/sipaccount.h" #include "sip/sipaccount.h"
#include "sip/SdesNegotiator.h" #include "sip/SdesNegotiator.h"
#include <assert.h> #include <cassert>
namespace sfl namespace sfl
{ {
...@@ -77,7 +76,7 @@ void AudioRtpFactory::initAudioRtpConfig (SIPCall *ca) ...@@ -77,7 +76,7 @@ void AudioRtpFactory::initAudioRtpConfig (SIPCall *ca)
stop(); stop();
} }
AccountID accountId = Manager::instance().getAccountFromCall (ca->getCallId()); AccountID accountId(Manager::instance().getAccountFromCall (ca->getCallId()));
_debug ("AudioRtpFactory: Init rtp session for account %s", accountId.c_str()); _debug ("AudioRtpFactory: Init rtp session for account %s", accountId.c_str());
...@@ -87,10 +86,21 @@ void AudioRtpFactory::initAudioRtpConfig (SIPCall *ca) ...@@ -87,10 +86,21 @@ void AudioRtpFactory::initAudioRtpConfig (SIPCall *ca)
if (!account) if (!account)
_error ("AudioRtpFactory: Error no account found"); _error ("AudioRtpFactory: Error no account found");
if (account->getType() == "SIP") { registerAccount(account, accountId);
SIPAccount *sipaccount = static_cast<SIPAccount *> (account); }
void AudioRtpFactory::registerAccount(Account * /*account*/, const AccountID & /* id */)
{
_srtpEnabled = false;
_keyExchangeProtocol = Symmetric;
_helloHashEnabled = false;
}
void AudioRtpFactory::registerAccount(SIPAccount *sipaccount, const AccountID& accountId)
{
_srtpEnabled = sipaccount->getSrtpEnable(); _srtpEnabled = sipaccount->getSrtpEnable();
std::string tempkey = sipaccount->getSrtpKeyExchange(); std::string tempkey(sipaccount->getSrtpKeyExchange());
if (tempkey == "sdes") if (tempkey == "sdes")
_keyExchangeProtocol = Sdes; _keyExchangeProtocol = Sdes;
...@@ -101,12 +111,6 @@ void AudioRtpFactory::initAudioRtpConfig (SIPCall *ca) ...@@ -101,12 +111,6 @@ void AudioRtpFactory::initAudioRtpConfig (SIPCall *ca)
_debug ("AudioRtpFactory: Registered account %s profile selected with key exchange protocol number %d", accountId.c_str(), _keyExchangeProtocol); _debug ("AudioRtpFactory: Registered account %s profile selected with key exchange protocol number %d", accountId.c_str(), _keyExchangeProtocol);
_helloHashEnabled = sipaccount->getZrtpHelloHash(); _helloHashEnabled = sipaccount->getZrtpHelloHash();
} else {
_srtpEnabled = false;
_keyExchangeProtocol = Symmetric;
_helloHashEnabled = false;
}
} }
void AudioRtpFactory::initAudioRtpSession (SIPCall * ca) void AudioRtpFactory::initAudioRtpSession (SIPCall * ca)
......
...@@ -33,13 +33,15 @@ ...@@ -33,13 +33,15 @@
#include <stdexcept> #include <stdexcept>
#include <cc++/thread.h> #include <cc++/thread.h>
#include "account.h" // for typedef of AccountID (std::string)
#include <ccrtp/CryptoContext.h> #include <ccrtp/CryptoContext.h>
#include "sip/SdesNegotiator.h" #include "sip/SdesNegotiator.h"
#include "audio/codecs/audiocodec.h"
class SdesNegotiator; class SdesNegotiator;
class SIPCall; class SIPCall;
class Account;
class SIPAccount;
/* /*
namespace sfl namespace sfl
...@@ -56,6 +58,7 @@ namespace sfl ...@@ -56,6 +58,7 @@ namespace sfl
class AudioZrtpSession; class AudioZrtpSession;
class AudioSrtpSession; class AudioSrtpSession;
class AudioSymmetricRtpSession; class AudioSymmetricRtpSession;
class AudioCodec;
// Possible kind of rtp session // Possible kind of rtp session
typedef enum RtpMethod { typedef enum RtpMethod {
...@@ -200,6 +203,8 @@ class AudioRtpFactory ...@@ -200,6 +203,8 @@ class AudioRtpFactory
void sendDtmfDigit (int digit); void sendDtmfDigit (int digit);
private: private:
void registerAccount(Account *account, const AccountID &id);
void registerAccount(SIPAccount *account, const AccountID &id);
void * _rtpSession; void * _rtpSession;
RtpMethod _rtpSessionType; RtpMethod _rtpSessionType;
ost::Mutex _audioRtpThreadMutex; ost::Mutex _audioRtpThreadMutex;
......
...@@ -661,8 +661,6 @@ void SIPAccount::setAccountDetails (const std::map<std::string, std::string>& de ...@@ -661,8 +661,6 @@ void SIPAccount::setAccountDetails (const std::map<std::string, std::string>& de
setMailBox (mailbox); setMailBox (mailbox);
// SIP specific account settings // SIP specific account settings
if (getType() == "SIP") {
std::string ua_name; std::string ua_name;
std::string realm; std::string realm;
std::string routeset; std::string routeset;
...@@ -814,7 +812,6 @@ void SIPAccount::setAccountDetails (const std::map<std::string, std::string>& de ...@@ -814,7 +812,6 @@ void SIPAccount::setAccountDetails (const std::map<std::string, std::string>& de
} }
} }
} }
}
std::map<std::string, std::string> SIPAccount::getAccountDetails() const std::map<std::string, std::string> SIPAccount::getAccountDetails() const
{ {
...@@ -863,10 +860,7 @@ std::map<std::string, std::string> SIPAccount::getAccountDetails() const ...@@ -863,10 +860,7 @@ std::map<std::string, std::string> SIPAccount::getAccountDetails() const
a.insert (std::pair<std::string, std::string> (REGISTRATION_STATE_CODE, registrationStateCode)); a.insert (std::pair<std::string, std::string> (REGISTRATION_STATE_CODE, registrationStateCode));
a.insert (std::pair<std::string, std::string> (REGISTRATION_STATE_DESCRIPTION, registrationStateDescription)); a.insert (std::pair<std::string, std::string> (REGISTRATION_STATE_DESCRIPTION, registrationStateDescription));
// Add sip specific details // Add sip specific details
if (getType() == "SIP") {
a.insert (std::pair<std::string, std::string> (ROUTESET, getServiceRoute())); a.insert (std::pair<std::string, std::string> (ROUTESET, getServiceRoute()));
a.insert (std::pair<std::string, std::string> (CONFIG_ACCOUNT_RESOLVE_ONCE, isResolveOnce() ? "true" : "false")); a.insert (std::pair<std::string, std::string> (CONFIG_ACCOUNT_RESOLVE_ONCE, isResolveOnce() ? "true" : "false"));
a.insert (std::pair<std::string, std::string> (REALM, _realm)); a.insert (std::pair<std::string, std::string> (REALM, _realm));
...@@ -914,10 +908,7 @@ std::map<std::string, std::string> SIPAccount::getAccountDetails() const ...@@ -914,10 +908,7 @@ std::map<std::string, std::string> SIPAccount::getAccountDetails() const
a.insert (std::pair<std::string, std::string> (TLS_NEGOTIATION_TIMEOUT_SEC, getTlsNegotiationTimeoutSec())); a.insert (std::pair<std::string, std::string> (TLS_NEGOTIATION_TIMEOUT_SEC, getTlsNegotiationTimeoutSec()));
a.insert (std::pair<std::string, std::string> (TLS_NEGOTIATION_TIMEOUT_MSEC, getTlsNegotiationTimeoutMsec())); a.insert (std::pair<std::string, std::string> (TLS_NEGOTIATION_TIMEOUT_MSEC, getTlsNegotiationTimeoutMsec()));
}
return a; return a;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment