Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
savoirfairelinux
jami-daemon
Commits
d3d74da0
Commit
d3d74da0
authored
Sep 19, 2011
by
Rafaël Carré
Browse files
* #6905 : simplify udp/stun/tls pjsip transport creation
parent
014cf030
Changes
7
Expand all
Show whitespace changes
Inline
Side-by-side
daemon/src/audio/audiortp/AudioRtpFactory.cpp
View file @
d3d74da0
...
...
@@ -57,47 +57,29 @@ AudioRtpFactory::~AudioRtpFactory()
void
AudioRtpFactory
::
initAudioRtpConfig
()
{
if
(
_rtpSession
!=
NULL
)
{
_debug
(
"An audio rtp thread was already created but not"
\
"destroyed. Forcing it before continuing."
);
if
(
_rtpSession
!=
NULL
)
stop
();
}
std
::
string
accountId
(
Manager
::
instance
().
getAccountFromCall
(
ca_
->
getCallId
()));
_debug
(
"AudioRtpFactory: Init rtp session for account %s"
,
accountId
.
c_str
());
// Manager::instance().getAccountLink (accountId);
Account
*
account
=
Manager
::
instance
().
getAccount
(
accountId
);
if
(
!
account
)
_error
(
"AudioRtpFactory: Error no account found"
);
registerAccount
(
account
,
accountId
);
}
void
AudioRtpFactory
::
registerAccount
(
Account
*
/*account*/
,
const
std
::
string
&
/* id */
)
{
_srtpEnabled
=
false
;
_keyExchangeProtocol
=
Symmetric
;
_helloHashEnabled
=
false
;
}
std
::
string
accountId
(
Manager
::
instance
().
getAccountFromCall
(
ca_
->
getCallId
()));
void
AudioRtpFactory
::
registerAccount
(
SIPAccount
*
sip
account
,
const
std
::
string
&
accountId
)
{
_srtpEnabled
=
sip
account
->
getSrtpEnabled
();
std
::
string
temp
key
(
sip
account
->
getSrtpKeyExchange
());
SIPAccount
*
account
=
dynamic_cast
<
SIPAccount
*>
(
Manager
::
instance
().
getAccount
(
accountId
)
);
if
(
account
)
{
_srtpEnabled
=
account
->
getSrtpEnabled
();
std
::
string
key
(
account
->
getSrtpKeyExchange
());
if
(
temp
key
==
"sdes"
)
if
(
key
==
"sdes"
)
_keyExchangeProtocol
=
Sdes
;
else
if
(
temp
key
==
"zrtp"
)
else
if
(
key
==
"zrtp"
)
_keyExchangeProtocol
=
Zrtp
;
else
_keyExchangeProtocol
=
Symmetric
;
_debug
(
"AudioRtpFactory: Registered account %s profile selected with key exchange protocol number %d"
,
accountId
.
c_str
(),
_keyExchangeProtocol
);
_helloHashEnabled
=
sipaccount
->
getZrtpHelloHash
();
_helloHashEnabled
=
account
->
getZrtpHelloHash
();
}
else
{
_srtpEnabled
=
false
;
_keyExchangeProtocol
=
Symmetric
;
_helloHashEnabled
=
false
;
}
}
void
AudioRtpFactory
::
initAudioSymmetricRtpSession
()
...
...
@@ -113,24 +95,20 @@ void AudioRtpFactory::initAudioSymmetricRtpSession ()
case
Zrtp
:
_rtpSession
=
new
AudioZrtpSession
(
ca_
,
zidFilename
);
if
(
_helloHashEnabled
)
{
// TODO: be careful with that. The hello hash is computed asynchronously. Maybe it's
// not even available at that point.
ca_
->
getLocalSDP
()
->
setZrtpHash
(
static_cast
<
AudioZrtpSession
*>
(
_rtpSession
)
->
getHelloHash
());
_debug
(
"AudioRtpFactory: Zrtp hello hash fed to SDP"
);
}
break
;
case
Sdes
:
_rtpSession
=
new
AudioSrtpSession
(
ca_
);
break
;
default:
_debug
(
"AudioRtpFactory: Unsupported Rtp Session Exception Type!"
);
throw
UnsupportedRtpSessionType
();
throw
UnsupportedRtpSessionType
(
"Unsupported Rtp Session Exception Type!"
);
}
}
else
{
_rtpSession
=
new
AudioSymmetricRtpSession
(
ca_
);
...
...
daemon/src/audio/audiortp/AudioRtpFactory.h
View file @
d3d74da0
...
...
@@ -152,8 +152,6 @@ class AudioRtpFactory
void
sendDtmfDigit
(
int
digit
);
private:
void
registerAccount
(
Account
*
account
,
const
std
::
string
&
id
);
void
registerAccount
(
SIPAccount
*
account
,
const
std
::
string
&
id
);
AudioRtpSession
*
_rtpSession
;
ost
::
Mutex
_audioRtpThreadMutex
;
...
...
daemon/src/iax/iaxvoiplink.cpp
View file @
d3d74da0
...
...
@@ -165,10 +165,9 @@ IAXVoIPLink::terminateIAXCall()
void
IAXVoIPLink
::
getEvent
()
{
iax_event
*
event
=
NULL
;
{
ost
::
MutexLock
m
(
mutexIAX_
);
iax_event
*
event
;
while
((
event
=
iax_get_event
(
IAX_NONBLOCKING
))
!=
NULL
)
{
// If we received an 'ACK', libiax2 tells apps to ignore them.
if
(
event
->
etype
==
IAX_EVENT_NULL
)
...
...
@@ -263,8 +262,6 @@ IAXVoIPLink::getIAXCall (const std::string& id)
void
IAXVoIPLink
::
sendRegister
(
Account
*
a
)
{
_debug
(
"IAX: Sending registration"
);
IAXAccount
*
account
=
dynamic_cast
<
IAXAccount
*>
(
a
);
if
(
account
->
getHostname
().
empty
())
...
...
@@ -273,43 +270,28 @@ IAXVoIPLink::sendRegister (Account *a)
if
(
account
->
getUsername
().
empty
())
throw
VoipLinkException
(
"Account username is empty"
);
// lock
ost
::
MutexLock
m
(
mutexIAX_
);
// Always use a brand new session
if
(
regSession_
)
iax_destroy
(
regSession_
);
regSession_
=
iax_session_new
();
if
(
!
regSession_
)
_debug
(
"IAX: Error when generating new session for register"
);
else
{
_debug
(
"IAX: Sending registration to %s with user %s"
,
account
->
getHostname
().
c_str
()
,
account
->
getUsername
().
c_str
());
int
val
=
iax_register
(
regSession_
,
account
->
getHostname
().
data
(),
account
->
getUsername
().
data
(),
account
->
getPassword
().
data
(),
120
);
_debug
(
"IAX: Return value: %d"
,
val
);
// set the time-out to 15 seconds, after that, resend a registration request.
// until we unregister.
if
(
regSession_
)
{
iax_register
(
regSession_
,
account
->
getHostname
().
data
(),
account
->
getUsername
().
data
(),
account
->
getPassword
().
data
(),
120
);
nextRefreshStamp_
=
time
(
NULL
)
+
10
;
account
->
setRegistrationState
(
Trying
);
account
->
setRegistrationState
(
Trying
);
}
}
void
IAXVoIPLink
::
sendUnregister
(
Account
*
a
)
{
_debug
(
"IAXVoipLink: Send unregister"
);
{
ost
::
MutexLock
m
(
mutexIAX_
);
if
(
regSession_
)
{
iax_destroy
(
regSession_
);
regSession_
=
NULL
;
}
}
mutexIAX_
.
leaveMutex
();
nextRefreshStamp_
=
0
;
...
...
daemon/src/managerimpl.cpp
View file @
d3d74da0
...
...
@@ -2755,10 +2755,6 @@ void ManagerImpl::loadAccountMap(Conf::YamlParser *parser)
// IP to IP settings (most likely using port 5060)
link
->
createDefaultSipUdpTransport
();
// Call this method to create TLS listener
link
->
createDefaultSipTlsListener
();
// Force IP2IP settings to be loaded to be loaded
// No registration in the sense of the REGISTER method is performed.
ip2ip
->
registerVoIPLink
();
...
...
daemon/src/sip/sipaccount.cpp
View file @
d3d74da0
...
...
@@ -535,7 +535,7 @@ void SIPAccount::registerVoIPLink()
return
;
try
{
link_
->
sendRegister
(
this
);
link_
->
sendRegister
(
this
);
}
catch
(
const
VoipLinkException
&
e
)
{
_error
(
"SIPAccount: %s"
,
e
.
what
());
...
...
daemon/src/sip/sipvoiplink.cpp
View file @
d3d74da0
This diff is collapsed.
Click to expand it.
daemon/src/sip/sipvoiplink.h
View file @
d3d74da0
...
...
@@ -257,16 +257,7 @@ class SIPVoIPLink : public VoIPLink
pjsip_tpselector
*
initTransportSelector
(
pjsip_transport
*
,
pj_pool_t
*
);
/**
* Helper function for creating a route set from information
* stored in configuration file.
*/
pjsip_route_hdr
*
createRouteSet
(
Account
*
account
,
pj_pool_t
*
pool
);
/**
* This function unset the transport for a given account. It tests wether the
* associated transport is used by other accounts. If not, it shutdown the transport
* putting its reference counter to zero. PJSIP assumes transport destruction since
* this action can be delayed by ongoing SIP transactions.
* This function unset the transport for a given account.
*/
void
shutdownSipTransport
(
SIPAccount
*
account
);
...
...
@@ -285,11 +276,6 @@ class SIPVoIPLink : public VoIPLink
*/
void
createDefaultSipUdpTransport
();
/**
* Create the default TLS litener using IP2IP_PROFILE settings
*/
void
createDefaultSipTlsListener
();
private:
/**
* Start a SIP Call
...
...
@@ -313,49 +299,35 @@ class SIPVoIPLink : public VoIPLink
*/
pj_status_t
stunServerResolve
(
SIPAccount
*
);
/**
* Function used to create a new sip transport or get an existing one from the map.
* The SIP transport is "acquired" according to account's current settings.
* This function should be called before registering an account
* @param account An account for which transport is to be set
*
*/
void
acquireTransport
(
SIPAccount
*
account
);
/**
* Create the default TLS litener
according to account settings
.
* Create the default TLS li
s
tener.
*/
void
createTlsListener
(
SIPAccount
*
);
void
createTlsListener
(
SIPAccount
*
,
pjsip_tpfactory
**
listener
);
/**
* General Sip transport creation method according to the
* transport type specified in account settings
* @param account The account for which a transport must be created.
*/
bool
createSipTransport
(
SIPAccount
*
account
);
void
createSipTransport
(
SIPAccount
*
account
);
/**
* Create SIP UDP transport from account's setting
* @param account The account for which a transport must be created.
* @param local True if the account is IP2IP
* @return the transport
*/
pjsip_transport
*
createUdpTransport
(
SIPAccount
*
account
,
bool
local
);
void
createUdpTransport
(
SIPAccount
*
account
);
/**
* Create a TLS transport from the default TLS listener from
* @param account The account for which a transport must be created.
* @return pj_status_t PJ_SUCCESS on success
*/
pj_status_t
createTlsTransport
(
SIPAccount
*
,
std
::
string
remoteAddr
);
void
createTlsTransport
(
SIPAccount
*
,
std
::
string
remoteAddr
);
/**
* Create a UDP transport using stun server to resove public address
* @param account The account for which a transport must be created.
* @return pj_status_t PJ_SUCCESS on success
*/
pj_status_t
createAlternateUdp
Transport
(
SIPAccount
*
account
);
void
createStun
Transport
(
SIPAccount
*
account
);
/**
* Get the correct address to use (ie advertised) from
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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