Commit 1c205c4d authored by Rafaël Carré's avatar Rafaël Carré

SIPVoIPLink: simplify / refactor

parent cb4c0d51
......@@ -184,8 +184,6 @@ int AudioRtpFactory::getSessionMedia()
void AudioRtpFactory::updateSessionMedia (AudioCodec *audiocodec)
{
_info ("AudioRtpFactory: Updating session media");
if (_rtpSession == NULL) {
throw AudioRtpFactoryException ("AudioRtpFactory: Error: _rtpSession was null when trying to update IP address");
}
......@@ -194,8 +192,6 @@ void AudioRtpFactory::updateSessionMedia (AudioCodec *audiocodec)
void AudioRtpFactory::updateDestinationIpAddress (void)
{
_info ("AudioRtpFactory: Updating IP address");
if (_rtpSession == NULL) {
throw AudioRtpFactoryException ("AudioRtpFactory: Error: RtpSession was null when trying to update IP address");
}
......
......@@ -65,9 +65,6 @@ AudioRtpSession::~AudioRtpSession()
void AudioRtpSession::updateSessionMedia (AudioCodec *audioCodec)
{
_debug ("AudioSymmetricRtpSession: Update session media");
// Update internal codec for this session
int lastSamplingRate = _audioRtpRecord._codecSampleRate;
setSessionMedia(audioCodec);
......@@ -83,9 +80,6 @@ void AudioRtpSession::updateSessionMedia (AudioCodec *audioCodec)
void AudioRtpSession::setSessionMedia (AudioCodec *audioCodec)
{
_debug ("AudioSymmetricRtpSession: Set session media");
// set internal codec info for this session
setRtpMedia (audioCodec);
// store codec info locally
......
......@@ -170,7 +170,7 @@ IAXVoIPLink::getEvent()
{
ost::MutexLock m(mutexIAX_);
while ((event = iax_get_event (IAX_NONBLOCKING)) != NULL) {
// If we received an 'ACK', libiax2 tells apps to ignore them.
// If we received an 'ACK', libiax2 tells apps to ignore them.
if (event->etype == IAX_EVENT_NULL)
continue;
......@@ -178,24 +178,20 @@ IAXVoIPLink::getEvent()
if (call)
iaxHandleCallEvent (event, call);
else if (event->session && event->session == regSession_) {
// This is a registration session, deal with it
else if (event->session && event->session == regSession_) // This is a registration session, deal with it
iaxHandleRegReply (event);
} else {
// We've got an event before it's associated with any call
else // We've got an event before it's associated with any call
iaxHandlePrecallEvent (event);
}
iax_event_free (event);
}
free(event);
}
sendAudioFromMic();
// thread wait 3 millisecond
evThread_->sleep(3);
free (event);
}
void
......@@ -432,11 +428,12 @@ IAXVoIPLink::offhold (const std::string& id)
call->setState (Call::Active);
}
bool
void
IAXVoIPLink::transfer (const std::string& id, const std::string& to)
{
IAXCall* call = getIAXCall (id);
CHK_VALID_CALL;
if (!call)
return;
char callto[to.length() +1];
strcpy (callto, to.c_str());
......@@ -444,11 +441,6 @@ IAXVoIPLink::transfer (const std::string& id, const std::string& to)
mutexIAX_.enterMutex();
iax_transfer (call->getSession(), callto);
mutexIAX_.leaveMutex();
return true;
// should we remove it?
// removeCall(id);
}
bool
......
......@@ -150,10 +150,8 @@ class IAXVoIPLink : public VoIPLink
* Transfer a call
* @param id The ID of the call
* @param to The recipient of the transfer
* @return bool true on success
* false otherwise
*/
virtual bool transfer (const std::string& id, const std::string& to);
virtual void transfer (const std::string& id, const std::string& to);
/**
* Perform attended transfer
......
......@@ -108,7 +108,7 @@ void InstantMessaging::send_sip_message (pjsip_inv_session *session, const std::
}
void InstantMessaging::send_iax_message (iax_session* session, const std::string& id, const std::string& message)
void InstantMessaging::send_iax_message (iax_session* session, const std::string& /* id */, const std::string& message)
{
std::vector<std::string> msgs = split_message (message);
std::vector<std::string>::const_iterator iter;
......
......@@ -539,35 +539,21 @@ void ManagerImpl::offHoldCall (const std::string& callId)
//THREAD=Main
bool ManagerImpl::transferCall (const std::string& callId, const std::string& to)
{
bool returnValue = false;;
_info ("Manager: Transfer call %s", callId.c_str());
std::string currentCallId = getCurrentCallId();
if (participToConference(callId)) {
Conference *conf = getConferenceFromCallID(callId);
if (conf == NULL)
_error("Manager: Error: Could not find conference from call id");
removeParticipant (callId);
processRemainingParticipant (callId, conf);
}
else if (!isConference(currentCallId))
processRemainingParticipant (callId, getConferenceFromCallID(callId));
} else if (!isConference(getCurrentCallId()))
switchCall("");
// Direct IP to IP call
if (getConfigFromCall (callId) == Call::IPtoIP)
returnValue = SIPVoIPLink::instance ()-> transfer (callId, to);
if (getConfigFromCall(callId) == Call::IPtoIP)
SIPVoIPLink::instance()->transfer (callId, to);
else {
std::string accountid (getAccountFromCall (callId));
if (accountid == "") {
_warn ("Manager: Call doesn't exists");
std::string accountid(getAccountFromCall (callId));
if (accountid == "")
return false;
}
returnValue = getAccountLink (accountid)->transfer (callId, to);
getAccountLink(accountid)->transfer (callId, to);
}
// remove waiting call in case we make transfer without even answer
......@@ -575,7 +561,7 @@ bool ManagerImpl::transferCall (const std::string& callId, const std::string& to
getMainBuffer()->stateInfo();
return returnValue;
return true;
}
void ManagerImpl::transferFailed ()
......
......@@ -66,7 +66,7 @@ VoIPLink* ManagerImpl::getAccountLink (const std::string& accountID) const
if (not accountID.empty())
return getAccount (accountID)->getVoIPLink();
else
return SIPVoIPLink::instance ();
return SIPVoIPLink::instance();
}
......
......@@ -40,6 +40,7 @@
SIPAccount::SIPAccount (const std::string& accountID)
: Account (accountID, "SIP")
, transport (NULL)
, regc_ (NULL)
, bRegister_ (false)
, registrationExpire_ ("")
......@@ -51,7 +52,6 @@ SIPAccount::SIPAccount (const std::string& accountID)
, serviceRoute_ ("")
, tlsListenerPort_ (DEFAULT_SIP_TLS_PORT)
, transportType_ (PJSIP_TRANSPORT_UNSPECIFIED)
, transport_ (NULL)
, cred_ (NULL)
, stunPort_(0)
, dtmfType_ (OVERRTP)
......@@ -652,8 +652,8 @@ std::string SIPAccount::getLoginName (void)
std::string SIPAccount::getFromUri (void) const
{
std::string scheme;
std::string transport;
std::string scheme("");
std::string transport("");
std::string username = username_;
std::string hostname = hostname_;
......@@ -670,7 +670,7 @@ std::string SIPAccount::getFromUri (void) const
// Get machine hostname if not provided
if (hostname_.empty())
hostname = std::string (pj_gethostname()->ptr, pj_gethostname()->slen);
hostname = std::string(pj_gethostname()->ptr, pj_gethostname()->slen);
return "<" + scheme + username + "@" + hostname + transport + ">";
}
......
......@@ -363,14 +363,6 @@ class SIPAccount : public Account
return tlsListenerPort_;
}
/**
* Set the local port for TLS listener.
* @pram port The port used for TLS listener.
*/
void setTlsListenerPort (pj_uint16_t port) {
tlsListenerPort_ = port;
}
/**
* Get the public IP address set by the user for this account.
* If this setting is not provided, the local bound adddress
......@@ -394,14 +386,6 @@ class SIPAccount : public Account
return serviceRoute_;
}
pjsip_transport* getAccountTransport (void) const {
return transport_;
}
void setAccountTransport (pjsip_transport *transport) {
transport_ = transport;
}
DtmfType getDtmfType (void) const {
return dtmfType_;
}
......@@ -422,6 +406,8 @@ class SIPAccount : public Account
return zrtpHelloHash_;
}
pjsip_transport* transport;
private:
std::vector< std::map<std::string, std::string > > credentials_;
......@@ -481,8 +467,6 @@ class SIPAccount : public Account
pjsip_transport_type_e transportType_;
pjsip_transport* transport_;
//Credential information
pjsip_cred_info *cred_;
......
This diff is collapsed.
......@@ -148,9 +148,8 @@ class SIPVoIPLink : public VoIPLink
* Transfer the call
* @param id The call identifier
* @param to The recipient of the transfer
* @return bool True on success
*/
virtual bool transfer (const std::string& id, const std::string& to);
virtual void transfer (const std::string& id, const std::string& to);
/**
* Attended transfer
......@@ -309,22 +308,6 @@ class SIPVoIPLink : public VoIPLink
SIPVoIPLink ();
/* The singleton instance */
static SIPVoIPLink* instance_;
/**
* Initialize the PJSIP library
* Must be called before any other calls to the SIP layer
*
* @return bool True on success
*/
void pjsipInit();
/**
* Delete link-related stuff like calls
*/
void pjsipShutdown (void);
/**
* Resolve public address for this account
*/
......@@ -381,17 +364,8 @@ class SIPVoIPLink : public VoIPLink
*
* @param uri The uri from which we want to discover the address to use
* @param transport The transport to use to discover the address
* @return pj_str_t The extern (public) address
*/
std::string findLocalAddressFromUri (const std::string& uri, pjsip_transport *transport);
/*
* Does the same as findLocalAddressFromUri but returns a port.
* @param uri The uri from which we want to discover the port to use
* @param transport The transport to use to discover the port
* @return int The extern (public) port
*/
int findLocalPortFromUri (const std::string& uri, pjsip_transport *transport);
void findLocalAddressFromUri (const std::string& uri, pjsip_transport *transport, std::string &address, std::string &port);
/**
* UDP Transports are stored in this map in order to retreive them in case
......@@ -402,7 +376,7 @@ class SIPVoIPLink : public VoIPLink
/**
* Threading object
*/
EventThread* evThread_;
EventThread *evThread_;
/**
* Global mutex for the sip voiplink
......
......@@ -134,9 +134,8 @@ class VoIPLink
* Transfer a call to specified URI
* @param id The call identifier
* @param to The recipient of the call
* @return bool True on success
*/
virtual bool transfer (const std::string& id, const std::string& to) = 0;
virtual void transfer (const std::string& id, const std::string& to) = 0;
/**
* Attended transfer
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment