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
97e78194
Commit
97e78194
authored
Apr 22, 2012
by
Alexandre Savard
Browse files
#9902: Move logic for ip2ip call in SIPVoIPLink
parent
5738798c
Changes
5
Hide whitespace changes
Inline
Side-by-side
daemon/src/managerimpl.cpp
View file @
97e78194
...
...
@@ -195,14 +195,6 @@ bool ManagerImpl::outgoingCall(const std::string& account_id,
std
::
string
to_cleaned
(
NumberCleaner
::
clean
(
to
,
prefix
));
static
const
char
*
const
SIP_SCHEME
=
"sip:"
;
static
const
char
*
const
SIPS_SCHEME
=
"sips:"
;
bool
IPToIP
=
to_cleaned
.
find
(
SIP_SCHEME
)
==
0
or
to_cleaned
.
find
(
SIPS_SCHEME
)
==
0
;
setIPToIPForCall
(
call_id
,
IPToIP
);
// in any cases we have to detach from current communication
if
(
hasCurrentCall
())
{
DEBUG
(
"Manager: Has current call (%s) put it onhold"
,
current_call_id
.
c_str
());
...
...
@@ -214,29 +206,21 @@ bool ManagerImpl::outgoingCall(const std::string& account_id,
detachParticipant
(
MainBuffer
::
DEFAULT_ID
,
current_call_id
);
}
if
(
IPToIP
)
{
DEBUG
(
"Manager: Start IP2IP call"
);
/* We need to retrieve the sip voiplink instance */
if
(
SIPVoIPLink
::
instance
()
->
SIPNewIpToIpCall
(
call_id
,
to_cleaned
))
{
switchCall
(
call_id
);
return
true
;
}
else
callFailure
(
call_id
);
return
false
;
}
DEBUG
(
"Manager: Selecting account %s"
,
account_id
.
c_str
());
// Is this account exist
// fallback using the default sip account if the specied doesn't exist
std
::
string
use_account_id
=
""
;
if
(
!
accountExists
(
account_id
))
{
ERROR
(
"Manager: Error: Account doesn't exist in new outgoing call"
);
return
false
;
WARN
(
"Manager: Account does not exist, trying with default SIP account"
);
use_account_id
=
SIPAccount
::
IP2IP_PROFILE
;
}
else
{
use_account_id
=
account_id
;
}
if
(
!
associateCallToAccount
(
call_id
,
account_id
))
WARN
(
"Manager: Warning: Could not associate call id %s to account id %s"
,
call_id
.
c_str
(),
account_id
.
c_str
());
// Is this account exist
if
(
!
associateCallToAccount
(
call_id
,
use_account_id
))
WARN
(
"Manager: Warning: Could not associate call id %s to account id %s"
,
call_id
.
c_str
(),
use_account_id
.
c_str
());
try
{
Call
*
call
=
getAccountLink
(
account_id
)
->
newOutgoingCall
(
call_id
,
to_cleaned
);
...
...
@@ -2489,6 +2473,8 @@ void ManagerImpl::removeAccount(const std::string& accountID)
bool
ManagerImpl
::
associateCallToAccount
(
const
std
::
string
&
callID
,
const
std
::
string
&
accountID
)
{
std
::
string
useAccountID
=
accountID
;
if
(
getAccountFromCall
(
callID
).
empty
()
and
accountExists
(
accountID
))
{
// account id exist in AccountMap
ost
::
MutexLock
m
(
callAccountMapMutex_
);
...
...
@@ -2667,8 +2653,8 @@ ManagerImpl::getAccount(const std::string& accountID)
AccountMap
::
const_iterator
iter
=
accountMap_
.
find
(
accountID
);
if
(
iter
!=
accountMap_
.
end
())
return
iter
->
second
;
else
return
accountMap_
[
SIPAccount
::
IP2IP_PROFILE
];
return
accountMap_
[
SIPAccount
::
IP2IP_PROFILE
];
}
std
::
string
ManagerImpl
::
getAccountIdFromNameAndServer
(
const
std
::
string
&
userName
,
const
std
::
string
&
server
)
const
...
...
daemon/src/managerimpl.h
View file @
97e78194
...
...
@@ -961,7 +961,6 @@ class ManagerImpl {
std
::
map
<
std
::
string
,
bool
>
IPToIPMap_
;
void
setIPToIPForCall
(
const
std
::
string
&
callID
,
bool
IPToIP
);
bool
isIPToIP
(
const
std
::
string
&
callID
)
const
;
...
...
@@ -994,6 +993,8 @@ class ManagerImpl {
public:
void
setIPToIPForCall
(
const
std
::
string
&
callID
,
bool
IPToIP
);
/** Associate a new std::string to a std::string
* Protected by mutex
* @param callID the new CallID not in the list yet
...
...
daemon/src/sip/sipvoiplink.cpp
View file @
97e78194
...
...
@@ -617,6 +617,78 @@ void SIPVoIPLink::cancelKeepAliveTimer(pj_timer_entry& timer)
Call
*
SIPVoIPLink
::
newOutgoingCall
(
const
std
::
string
&
id
,
const
std
::
string
&
toUrl
)
{
static
const
char
*
const
SIP_SCHEME
=
"sip:"
;
static
const
char
*
const
SIPS_SCHEME
=
"sips:"
;
DEBUG
(
"UserAgent: New outgoing call"
);
bool
IPToIP
=
toUrl
.
find
(
SIP_SCHEME
)
==
0
or
toUrl
.
find
(
SIPS_SCHEME
)
==
0
;
Manager
::
instance
().
setIPToIPForCall
(
id
,
IPToIP
);
try
{
if
(
IPToIP
)
{
return
SIPNewIpToIpCall
(
id
,
toUrl
);
}
else
{
return
newRegisteredAccountCall
(
id
,
toUrl
);
}
}
catch
(...)
{
throw
;
}
}
Call
*
SIPVoIPLink
::
SIPNewIpToIpCall
(
const
std
::
string
&
id
,
const
std
::
string
&
to
)
{
DEBUG
(
"UserAgent: New IP to IP call to %s"
,
to
.
c_str
());
SIPAccount
*
account
=
Manager
::
instance
().
getIP2IPAccount
();
if
(
!
account
)
throw
VoipLinkException
(
"Could not retrieve default account for IP2IP call"
);
SIPCall
*
call
=
new
SIPCall
(
id
,
Call
::
OUTGOING
,
cp_
);
call
->
setIPToIP
(
true
);
call
->
initRecFilename
(
to
);
std
::
string
localAddress
(
SipTransport
::
getInterfaceAddrFromName
(
account
->
getLocalInterface
()));
if
(
localAddress
==
"0.0.0.0"
)
localAddress
=
SipTransport
::
getSIPLocalIP
();
setCallMediaLocal
(
call
,
localAddress
);
std
::
string
toUri
=
account
->
getToUri
(
to
);
call
->
setPeerNumber
(
toUri
);
sfl
::
Codec
*
audiocodec
=
Manager
::
instance
().
audioCodecFactory
.
instantiateCodec
(
PAYLOAD_CODEC_ULAW
);
// Audio Rtp Session must be initialized before creating initial offer in SDP session
// since SDES require crypto attribute.
call
->
getAudioRtp
().
initConfig
();
call
->
getAudioRtp
().
initSession
();
call
->
getAudioRtp
().
initLocalCryptoInfo
();
call
->
getAudioRtp
().
start
(
static_cast
<
sfl
::
AudioCodec
*>
(
audiocodec
));
// Building the local SDP offer
call
->
getLocalSDP
()
->
setLocalIP
(
localAddress
);
call
->
getLocalSDP
()
->
createOffer
(
account
->
getActiveCodecs
());
if
(
!
SIPStartCall
(
call
))
{
delete
call
;
throw
VoipLinkException
(
"Could not create new call"
);
}
return
call
;
}
Call
*
SIPVoIPLink
::
newRegisteredAccountCall
(
const
std
::
string
&
id
,
const
std
::
string
&
toUrl
)
{
DEBUG
(
"UserAgent: New registered account call to %s"
,
toUrl
.
c_str
());
SIPAccount
*
account
=
dynamic_cast
<
SIPAccount
*>
(
Manager
::
instance
().
getAccount
(
Manager
::
instance
().
getAccountFromCall
(
id
)));
if
(
account
==
NULL
)
// TODO: We should investigate how we could get rid of this error and create a IP2IP call instead
...
...
@@ -1102,51 +1174,6 @@ SIPVoIPLink::getSIPCall(const std::string& id)
return
result
;
}
bool
SIPVoIPLink
::
SIPNewIpToIpCall
(
const
std
::
string
&
id
,
const
std
::
string
&
to
)
{
SIPAccount
*
account
=
Manager
::
instance
().
getIP2IPAccount
();
if
(
!
account
)
{
ERROR
(
"Error could not retrieve default account for IP2IP call"
);
return
false
;
}
SIPCall
*
call
=
new
SIPCall
(
id
,
Call
::
OUTGOING
,
cp_
);
call
->
setIPToIP
(
true
);
call
->
initRecFilename
(
to
);
std
::
string
localAddress
(
SipTransport
::
getInterfaceAddrFromName
(
account
->
getLocalInterface
()));
if
(
localAddress
==
"0.0.0.0"
)
localAddress
=
SipTransport
::
getSIPLocalIP
();
setCallMediaLocal
(
call
,
localAddress
);
std
::
string
toUri
=
account
->
getToUri
(
to
);
call
->
setPeerNumber
(
toUri
);
sfl
::
Codec
*
audiocodec
=
Manager
::
instance
().
audioCodecFactory
.
instantiateCodec
(
PAYLOAD_CODEC_ULAW
);
// Audio Rtp Session must be initialized before creating initial offer in SDP session
// since SDES require crypto attribute.
call
->
getAudioRtp
().
initConfig
();
call
->
getAudioRtp
().
initSession
();
call
->
getAudioRtp
().
initLocalCryptoInfo
();
call
->
getAudioRtp
().
start
(
static_cast
<
sfl
::
AudioCodec
*>
(
audiocodec
));
// Building the local SDP offer
call
->
getLocalSDP
()
->
setLocalIP
(
localAddress
);
call
->
getLocalSDP
()
->
createOffer
(
account
->
getActiveCodecs
());
if
(
!
SIPStartCall
(
call
))
{
delete
call
;
return
false
;
}
return
true
;
}
///////////////////////////////////////////////////////////////////////////////
// Private functions
///////////////////////////////////////////////////////////////////////////////
...
...
daemon/src/sip/sipvoiplink.h
View file @
97e78194
...
...
@@ -107,6 +107,20 @@ class SIPVoIPLink : public VoIPLink {
*/
virtual
Call
*
newOutgoingCall
(
const
std
::
string
&
id
,
const
std
::
string
&
toUrl
);
/**
* Start a new SIP call using the IP2IP profile
* @param The call id
* @param The target sip uri
*/
Call
*
SIPNewIpToIpCall
(
const
std
::
string
&
id
,
const
std
::
string
&
to
);
/**
* Place a call using the currently selected account
* @param The call id
* @param The target sip uri
*/
Call
*
newRegisteredAccountCall
(
const
std
::
string
&
id
,
const
std
::
string
&
toUrl
);
/**
* Answer the call
* @param c The call
...
...
@@ -169,13 +183,6 @@ class SIPVoIPLink : public VoIPLink {
*/
virtual
void
carryingDTMFdigits
(
const
std
::
string
&
id
,
char
code
);
/**
* Start a new SIP call using the IP2IP profile
* @param The call id
* @param The target sip uri
*/
bool
SIPNewIpToIpCall
(
const
std
::
string
&
id
,
const
std
::
string
&
to
);
/**
* Tell the user that the call was answered
* @param
...
...
gnome/src/actions.c
View file @
97e78194
...
...
@@ -816,7 +816,9 @@ void
sflphone_place_call
(
callable_obj_t
*
c
)
{
DEBUG
(
"Actions: Placing call with %s @ %s and accountid %s"
,
c
->
_display_name
,
c
->
_peer_number
,
c
->
_accountID
);
if
(
place_registered_call
(
c
)
<
0
)
DEBUG
(
"An error occured while placing registered call in %s at %d"
,
__FILE__
,
__LINE__
);
/*
if (is_direct_call(c)) {
gchar *msg = g_markup_printf_escaped(_("Direct SIP call"));
statusbar_pop_message(__MSG_ACCOUNT_DEFAULT);
...
...
@@ -826,6 +828,7 @@ sflphone_place_call(callable_obj_t * c)
place_direct_call(c);
} else if (place_registered_call(c) < 0)
DEBUG("An error occured while placing registered call in %s at %d", __FILE__, __LINE__);
*/
}
...
...
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