Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
savoirfairelinux
jami-daemon
Commits
c5f8f631
Commit
c5f8f631
authored
Jul 28, 2011
by
Rafaël Carré
Browse files
SIPVoIPLink is instanciated only once and is not associated to a single account
So move accountID from SIPVoIPLink to IAXVoIPLink
parent
c1fae971
Changes
11
Hide whitespace changes
Inline
Side-by-side
sflphone-common/src/dbus/configurationmanager.cpp
View file @
c5f8f631
...
...
@@ -803,38 +803,17 @@ void ConfigurationManager::setHistory (const std::vector<std::string>& entries)
std
::
string
ConfigurationManager
::
getAddrFromInterfaceName
(
const
std
::
string
&
interface
)
{
std
::
string
address
=
SIPVoIPLink
::
instance
(
""
)
->
getInterfaceAddrFromName
(
interface
);
return
address
;
return
SIPVoIPLink
::
instance
()
->
getInterfaceAddrFromName
(
interface
);
}
std
::
vector
<
std
::
string
>
ConfigurationManager
::
getAllIpInterface
(
void
)
{
std
::
vector
<
std
::
string
>
vector
;
SIPVoIPLink
*
sipLink
=
NULL
;
sipLink
=
SIPVoIPLink
::
instance
(
""
);
if
(
sipLink
!=
NULL
)
{
vector
=
sipLink
->
getAllIpInterface
();
}
return
vector
;
return
SIPVoIPLink
::
instance
()
->
getAllIpInterface
();
}
std
::
vector
<
std
::
string
>
ConfigurationManager
::
getAllIpInterfaceByName
(
void
)
{
std
::
vector
<
std
::
string
>
vector
;
SIPVoIPLink
*
sipLink
=
NULL
;
sipLink
=
SIPVoIPLink
::
instance
(
""
);
if
(
sipLink
!=
NULL
)
{
vector
=
sipLink
->
getAllIpInterfaceByName
();
}
return
vector
;
return
SIPVoIPLink
::
instance
()
->
getAllIpInterfaceByName
();
}
...
...
sflphone-common/src/iax/iaxvoiplink.cpp
View file @
c5f8f631
...
...
@@ -57,7 +57,7 @@ namespace {
const
char
*
const
URLHOOK_COMMAND
=
"Hooks.url_command"
;
}
// end anonymous namespace
IAXVoIPLink
::
IAXVoIPLink
(
const
std
::
string
&
accountID
)
:
VoIPLink
(
accountID
)
IAXVoIPLink
::
IAXVoIPLink
(
const
std
::
string
&
accountID
)
:
VoIPLink
()
,
_evThread
(
NULL
)
,
_regSession
(
NULL
)
,
_nextRefreshStamp
(
0
)
...
...
@@ -70,6 +70,7 @@ IAXVoIPLink::IAXVoIPLink (const std::string& accountID) : VoIPLink (accountID)
,
converter
(
NULL
)
,
converterSamplingRate
(
0
)
,
urlhook
(
NULL
)
,
_accountID
(
accountID
)
{
_evThread
=
new
EventThread
(
this
);
...
...
@@ -764,8 +765,8 @@ IAXVoIPLink::iaxOutgoingInvite (IAXCall* call)
wait
=
0
;
/** @todo Make preference dynamic, and configurable */
audio_format_preferred
=
call
->
getFirstMatchingFormat
(
call
->
getSupportedFormat
(
getA
ccountID
()
),
getA
ccountID
()
);
audio_format_capability
=
call
->
getSupportedFormat
(
getA
ccountID
()
);
audio_format_preferred
=
call
->
getFirstMatchingFormat
(
call
->
getSupportedFormat
(
_a
ccountID
),
_a
ccountID
);
audio_format_capability
=
call
->
getSupportedFormat
(
_a
ccountID
);
_debug
(
"IAX New call: %s"
,
strNum
.
c_str
());
iax_call
(
newsession
,
username
.
c_str
(),
username
.
c_str
(),
strNum
.
c_str
(),
lang
,
wait
,
audio_format_preferred
,
audio_format_capability
);
...
...
@@ -1073,8 +1074,7 @@ IAXVoIPLink::iaxHandleRegReply (iax_event* event)
std
::
string
account_id
;
IAXAccount
*
account
;
account_id
=
getAccountID
();
account
=
dynamic_cast
<
IAXAccount
*>
(
Manager
::
instance
().
getAccount
(
account_id
));
account
=
dynamic_cast
<
IAXAccount
*>
(
Manager
::
instance
().
getAccount
(
_accountID
));
if
(
event
->
etype
==
IAX_EVENT_REGREJ
)
{
/* Authentication failed! */
...
...
@@ -1184,14 +1184,14 @@ IAXVoIPLink::iaxHandlePrecallEvent (iax_event* event)
// if peerNumber exist append it to the name string
call
->
initRecFileName
(
std
::
string
(
event
->
ies
.
calling_number
));
if
(
Manager
::
instance
().
incomingCall
(
call
,
getA
ccountID
()
))
{
if
(
Manager
::
instance
().
incomingCall
(
call
,
_a
ccountID
))
{
/** @todo Faudra considérer éventuellement le champ CODEC PREFS pour
* l'établissement du codec de transmission */
// Remote lists its capabilities
int
format
=
call
->
getFirstMatchingFormat
(
event
->
ies
.
capability
,
getA
ccountID
()
);
int
format
=
call
->
getFirstMatchingFormat
(
event
->
ies
.
capability
,
_a
ccountID
);
// Remote asks for preferred codec voiceformat
int
pref_format
=
call
->
getFirstMatchingFormat
(
event
->
ies
.
format
,
getA
ccountID
()
);
int
pref_format
=
call
->
getFirstMatchingFormat
(
event
->
ies
.
format
,
_a
ccountID
);
// Priority to remote's suggestion. In case it's a forwarding, no transcoding
// will be needed from the server, thus less latency.
...
...
@@ -1248,3 +1248,7 @@ void IAXVoIPLink::updateAudiolayer (void)
_mutexIAX
.
leaveMutex
();
}
Account
*
IAXVoIPLink
::
getAccountPtr
(
void
)
{
return
Manager
::
instance
().
getAccount
(
_accountID
);
}
sflphone-common/src/iax/iaxvoiplink.h
View file @
c5f8f631
...
...
@@ -218,6 +218,8 @@ class IAXVoIPLink : public VoIPLink
private:
Account
*
getAccountPtr
(
void
);
/*
* Decode the message count IAX send.
* Returns only the new messages number
...
...
@@ -324,6 +326,8 @@ class IAXVoIPLink : public VoIPLink
/* URL hook */
UrlHook
*
urlhook
;
const
std
::
string
_accountID
;
};
#endif
sflphone-common/src/managerimpl.cpp
View file @
c5f8f631
...
...
@@ -285,7 +285,7 @@ bool ManagerImpl::outgoingCall (const std::string& account_id,
if
(
callConfig
==
Call
::
IPtoIP
)
{
_debug
(
"Manager: Start IP2IP call"
);
/* We need to retrieve the sip voiplink instance */
siplink
=
SIPVoIPLink
::
instance
(
""
);
siplink
=
SIPVoIPLink
::
instance
();
if
(
siplink
->
SIPNewIpToIpCall
(
call_id
,
to_cleaned
))
{
switchCall
(
call_id
);
...
...
@@ -473,7 +473,7 @@ bool ManagerImpl::hangupCall (const CallID& callId)
if
(
getConfigFromCall
(
callId
)
==
Call
::
IPtoIP
)
{
/* Direct IP to IP call */
returnValue
=
SIPVoIPLink
::
instance
(
""
)
->
hangup
(
callId
);
returnValue
=
SIPVoIPLink
::
instance
()
->
hangup
(
callId
);
}
else
{
std
::
string
accountId
=
getAccountFromCall
(
callId
);
...
...
@@ -529,7 +529,7 @@ bool ManagerImpl::cancelCall (const CallID& id)
/* Direct IP to IP call */
if
(
getConfigFromCall
(
id
)
==
Call
::
IPtoIP
)
{
returnValue
=
SIPVoIPLink
::
instance
(
""
)
->
cancel
(
id
);
returnValue
=
SIPVoIPLink
::
instance
()
->
cancel
(
id
);
}
/* Classic call, attached to an account */
...
...
@@ -574,7 +574,7 @@ bool ManagerImpl::onHoldCall (const CallID& callId)
if
(
getConfigFromCall
(
callId
)
==
Call
::
IPtoIP
)
{
/* Direct IP to IP call */
returnValue
=
SIPVoIPLink
::
instance
(
""
)
->
onhold
(
callId
);
returnValue
=
SIPVoIPLink
::
instance
()
->
onhold
(
callId
);
}
else
{
/* Classic call, attached to an account */
...
...
@@ -646,8 +646,8 @@ bool ManagerImpl::offHoldCall (const CallID& callId)
/* Direct IP to IP call */
if
(
getConfigFromCall
(
callId
)
==
Call
::
IPtoIP
)
{
// is_rec = SIPVoIPLink::instance (
""
)-> isRecording (call_id);
returnValue
=
SIPVoIPLink
::
instance
(
""
)
->
offhold
(
callId
);
// is_rec = SIPVoIPLink::instance ()-> isRecording (call_id);
returnValue
=
SIPVoIPLink
::
instance
()
->
offhold
(
callId
);
}
/* Classic call, attached to an account */
else
{
...
...
@@ -716,7 +716,7 @@ bool ManagerImpl::transferCall (const CallID& callId, const std::string& to)
// Direct IP to IP call
if
(
getConfigFromCall
(
callId
)
==
Call
::
IPtoIP
)
{
returnValue
=
SIPVoIPLink
::
instance
(
""
)
->
transfer
(
callId
,
to
);
returnValue
=
SIPVoIPLink
::
instance
()
->
transfer
(
callId
,
to
);
}
// Classic call, attached to an account
else
{
...
...
@@ -767,7 +767,7 @@ bool ManagerImpl::attendedTransfer(const CallID& transferID, const CallID& targe
// Direct IP to IP call
if
(
getConfigFromCall
(
transferID
)
==
Call
::
IPtoIP
)
{
returnValue
=
SIPVoIPLink
::
instance
(
""
)
->
attendedTransfer
(
transferID
,
targetID
);
returnValue
=
SIPVoIPLink
::
instance
()
->
attendedTransfer
(
transferID
,
targetID
);
}
else
{
// Classic call, attached to an account
...
...
@@ -812,7 +812,7 @@ bool ManagerImpl::refuseCall (const CallID& id)
/* Direct IP to IP call */
if
(
getConfigFromCall
(
id
)
==
Call
::
IPtoIP
)
{
returnValue
=
SIPVoIPLink
::
instance
(
""
)
->
refuse
(
id
);
returnValue
=
SIPVoIPLink
::
instance
()
->
refuse
(
id
);
}
/* Classic call, attached to an account */
...
...
@@ -2155,7 +2155,7 @@ void ManagerImpl::peerHungupCall (const CallID& call_id)
/* Direct IP to IP call */
if
(
getConfigFromCall
(
call_id
)
==
Call
::
IPtoIP
)
{
SIPVoIPLink
::
instance
(
""
)
->
hangup
(
call_id
);
SIPVoIPLink
::
instance
()
->
hangup
(
call_id
);
}
else
{
account_id
=
getAccountFromCall
(
call_id
);
...
...
@@ -4236,7 +4236,6 @@ void ManagerImpl::loadIptoipProfile()
// We need the IP2IP settings to be loaded at this time as they are used
// for default sip transport
// _directIpAccount->setVoIPLink(SIPVoIPLink::instance (""));
_directIpAccount
->
setVoIPLink
();
}
...
...
sflphone-common/src/managerimpl_registration.cpp
View file @
c5f8f631
...
...
@@ -154,7 +154,7 @@ void ManagerImpl::restartPJSIP (void)
if
(
siplink
)
{
_debug
(
"ManagerImpl::Terminate sip
\n
"
);
siplink
->
terminate
();
siplink
=
SIPVoIPLink
::
instance
(
""
);
siplink
=
SIPVoIPLink
::
instance
();
_debug
(
"ManagerImpl::Init new sip
\n
"
);
siplink
->
init
();
}
...
...
@@ -176,7 +176,7 @@ VoIPLink* ManagerImpl::getAccountLink (const std::string& accountID)
return
0
;
}
else
return
SIPVoIPLink
::
instance
(
""
);
return
SIPVoIPLink
::
instance
();
}
VoIPLink
*
ManagerImpl
::
getSIPAccountLink
()
...
...
sflphone-common/src/sip/sipaccount.cpp
View file @
c5f8f631
...
...
@@ -553,7 +553,7 @@ std::map<std::string, std::string> SIPAccount::getAccountDetails() const
void
SIPAccount
::
setVoIPLink
()
{
_link
=
SIPVoIPLink
::
instance
(
""
);
_link
=
SIPVoIPLink
::
instance
();
dynamic_cast
<
SIPVoIPLink
*>
(
_link
)
->
incrementClients
();
}
...
...
sflphone-common/src/sip/sipvoiplink.cpp
View file @
c5f8f631
...
...
@@ -289,8 +289,8 @@ void onCallTransfered (pjsip_inv_session *inv, pjsip_rx_data *rdata);
SIPVoIPLink
*
SIPVoIPLink
::
_instance
=
NULL
;
SIPVoIPLink
::
SIPVoIPLink
(
const
std
::
string
&
accountID
)
:
VoIPLink
(
accountID
)
SIPVoIPLink
::
SIPVoIPLink
()
:
VoIPLink
()
,
_nbTryListenAddr
(
2
)
// number of times to try to start SIP listener
,
_regPort
(
atoi
(
DEFAULT_SIP_PORT
))
,
_clients
(
0
)
...
...
@@ -314,12 +314,12 @@ SIPVoIPLink::~SIPVoIPLink()
}
SIPVoIPLink
*
SIPVoIPLink
::
instance
(
const
std
::
string
&
id
)
SIPVoIPLink
*
SIPVoIPLink
::
instance
()
{
if
(
!
_instance
)
{
_debug
(
"UserAgent: Create new SIPVoIPLink instance"
);
_instance
=
new
SIPVoIPLink
(
id
)
;
_instance
=
new
SIPVoIPLink
;
}
return
_instance
;
...
...
@@ -3162,7 +3162,7 @@ void invite_session_state_changed_cb (pjsip_inv_session *inv, pjsip_event *e)
// If the call is a direct IP-to-IP call
SIPVoIPLink
*
link
=
NULL
;
if
(
call
->
getCallConfiguration
()
==
Call
::
IPtoIP
)
{
link
=
SIPVoIPLink
::
instance
(
""
);
link
=
SIPVoIPLink
::
instance
();
}
else
{
std
::
string
accId
=
Manager
::
instance
().
getAccountFromCall
(
call
->
getCallId
());
link
=
dynamic_cast
<
SIPVoIPLink
*>
(
Manager
::
instance
().
getAccountLink
(
accId
));
...
...
@@ -3741,7 +3741,7 @@ void registration_cb (struct pjsip_regc_cbparam *param)
// shutdown this transport since useless
// if(account->getAccountTransport() != _localUDPTransport) {
SIPVoIPLink
::
instance
(
""
)
->
shutdownSipTransport
(
account
->
getAccountID
());
SIPVoIPLink
::
instance
()
->
shutdownSipTransport
(
account
->
getAccountID
());
//}
}
else
{
...
...
@@ -3752,7 +3752,7 @@ void registration_cb (struct pjsip_regc_cbparam *param)
account
->
setRegistrationState
(
Unregistered
);
account
->
setRegister
(
false
);
SIPVoIPLink
::
instance
(
""
)
->
shutdownSipTransport
(
account
->
getAccountID
());
SIPVoIPLink
::
instance
()
->
shutdownSipTransport
(
account
->
getAccountID
());
// pjsip_regc_destroy(param->regc);
// account->setRegistrationInfo(NULL);
...
...
@@ -3762,7 +3762,7 @@ void registration_cb (struct pjsip_regc_cbparam *param)
account
->
setRegistrationState
(
ErrorAuth
);
account
->
setRegister
(
false
);
SIPVoIPLink
::
instance
(
""
)
->
shutdownSipTransport
(
account
->
getAccountID
());
SIPVoIPLink
::
instance
()
->
shutdownSipTransport
(
account
->
getAccountID
());
}
}
...
...
@@ -3938,7 +3938,7 @@ transaction_request_cb (pjsip_rx_data *rdata)
// May use the published address as well
addrToUse
=
SIPVoIPLink
::
instance
(
""
)
->
getInterfaceAddrFromName
(
account
->
getLocalInterface
());
addrToUse
=
SIPVoIPLink
::
instance
()
->
getInterfaceAddrFromName
(
account
->
getLocalInterface
());
account
->
isStunEnabled
()
?
addrSdp
=
account
->
getPublishedAddress
()
:
addrSdp
=
addrToUse
;
// Set the appropriate transport to have the right VIA header
link
->
initTransportSelector
(
account
->
getAccountTransport
(),
&
tp
,
call
->
getMemoryPool
());
...
...
@@ -4353,7 +4353,7 @@ void onCallTransfered (pjsip_inv_session *inv, pjsip_rx_data *rdata)
CallID
newCallId
=
Manager
::
instance
().
getNewCallID
();
Call
*
newCall
=
SIPVoIPLink
::
instance
(
IP2IP_PROFILE
)
->
newOutgoingCall
(
newCallId
,
sipUri
);
Call
*
newCall
=
SIPVoIPLink
::
instance
()
->
newOutgoingCall
(
newCallId
,
sipUri
);
// if (!Manager::instance().outgoingCall (accId, newCallId, sipUri)) {
if
(
newCall
==
NULL
)
{
...
...
sflphone-common/src/sip/sipvoiplink.h
View file @
c5f8f631
...
...
@@ -90,7 +90,7 @@ class SIPVoIPLink : public VoIPLink
* Singleton method. Enable to retrieve the unique static instance
* @return SIPVoIPLink* A pointer on the object
*/
static
SIPVoIPLink
*
instance
(
const
std
::
string
&
id
);
static
SIPVoIPLink
*
instance
();
/**
* Increment the number of SIP account connected to this link
...
...
@@ -405,11 +405,7 @@ class SIPVoIPLink : public VoIPLink
int
_nbTryListenAddr
;
private:
/**
* Constructor
* @param accountID The account identifier
*/
SIPVoIPLink
(
const
std
::
string
&
accountID
);
SIPVoIPLink
();
/* The singleton instance */
static
SIPVoIPLink
*
_instance
;
...
...
sflphone-common/src/voiplink.cpp
View file @
c5f8f631
...
...
@@ -34,7 +34,7 @@
#include
"voiplink.h"
#include
"manager.h"
VoIPLink
::
VoIPLink
(
const
std
::
string
&
accountID
)
:
_accountID
(
accountID
),
_localPort
(
0
),
_initDone
(
false
)
VoIPLink
::
VoIPLink
(
)
:
_localPort
(
0
),
_initDone
(
false
)
{
}
...
...
@@ -99,8 +99,3 @@ bool VoIPLink::clearCallMap()
return
true
;
}
Account
*
VoIPLink
::
getAccountPtr
(
void
)
{
return
Manager
::
instance
().
getAccount
(
_accountID
);
}
sflphone-common/src/voiplink.h
View file @
c5f8f631
...
...
@@ -59,9 +59,8 @@ class VoIPLink
public:
/**
* Constructor
* @param accountID The account identifier
*/
VoIPLink
(
const
std
::
string
&
accountID
);
VoIPLink
();
/**
* Virtual destructor
...
...
@@ -222,15 +221,6 @@ class VoIPLink
*/
bool
clearCallMap
();
/**
* @return std::string parent Account's ID
*/
std
::
string
&
getAccountID
(
void
)
{
return
_accountID
;
}
Account
*
getAccountPtr
(
void
);
/**
* Get the call pointer from the call map (protected by mutex)
* @param id A Call ID
...
...
@@ -238,12 +228,6 @@ class VoIPLink
*/
Call
*
getCall
(
const
CallID
&
id
);
private:
/**
* ID of parent's Account
*/
std
::
string
_accountID
;
protected:
/** Contains all the calls for this Link, protected by mutex */
CallMap
_callMap
;
...
...
sflphone-common/test/siptest.cpp
View file @
c5f8f631
...
...
@@ -202,7 +202,7 @@ void SIPTest::testSimpleIncomingIpCall ()
sleep
(
2
);
// gtrab call id from sipvoiplink
SIPVoIPLink
*
siplink
=
SIPVoIPLink
::
instance
(
""
);
SIPVoIPLink
*
siplink
=
SIPVoIPLink
::
instance
();
CPPUNIT_ASSERT
(
siplink
->
_callMap
.
size
()
==
1
);
CallMap
::
iterator
iterCallId
=
siplink
->
_callMap
.
begin
();
...
...
@@ -318,7 +318,7 @@ void SIPTest::testTwoIncomingIpCall ()
sleep
(
1
);
// gtrab call id from sipvoiplink
SIPVoIPLink
*
sipLink
=
SIPVoIPLink
::
instance
(
""
);
SIPVoIPLink
*
sipLink
=
SIPVoIPLink
::
instance
();
CPPUNIT_ASSERT
(
sipLink
->
_callMap
.
size
()
==
1
);
CallMap
::
iterator
iterCallId
=
sipLink
->
_callMap
.
begin
();
...
...
@@ -428,7 +428,7 @@ void SIPTest::testIncomingIpCallSdp ()
sleep
(
2
);
// gtrab call id from sipvoiplink
SIPVoIPLink
*
siplink
=
SIPVoIPLink
::
instance
(
""
);
SIPVoIPLink
*
siplink
=
SIPVoIPLink
::
instance
();
CPPUNIT_ASSERT
(
siplink
->
_callMap
.
size
()
==
1
);
CallMap
::
iterator
iterCallId
=
siplink
->
_callMap
.
begin
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment