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
a906eff2
Commit
a906eff2
authored
Oct 12, 2011
by
Tristan Matthews
Browse files
* #7131: remove underscore prefix in voiplink classes
parent
117ccab6
Changes
4
Hide whitespace changes
Inline
Side-by-side
daemon/src/iax/iaxvoiplink.cpp
View file @
a906eff2
...
...
@@ -82,9 +82,9 @@ IAXVoIPLink::terminate()
if
(
!
initDone_
)
return
;
ost
::
MutexLock
m
(
_
callMapMutex
);
ost
::
MutexLock
m
(
callMapMutex
_
);
for
(
CallMap
::
iterator
iter
=
_
callMap
.
begin
();
iter
!=
_
callMap
.
end
();
++
iter
)
{
for
(
CallMap
::
iterator
iter
=
callMap
_
.
begin
();
iter
!=
callMap
_
.
end
();
++
iter
)
{
IAXCall
*
call
=
dynamic_cast
<
IAXCall
*>
(
iter
->
second
);
if
(
call
)
{
...
...
@@ -94,7 +94,7 @@ IAXVoIPLink::terminate()
}
}
_
callMap
.
clear
();
callMap
_
.
clear
();
initDone_
=
false
;
}
...
...
@@ -138,7 +138,7 @@ IAXVoIPLink::getEvent()
void
IAXVoIPLink
::
sendAudioFromMic
(
void
)
{
for
(
CallMap
::
const_iterator
iter
=
_
callMap
.
begin
();
iter
!=
_
callMap
.
end
()
;
++
iter
)
{
for
(
CallMap
::
const_iterator
iter
=
callMap
_
.
begin
();
iter
!=
callMap
_
.
end
()
;
++
iter
)
{
IAXCall
*
currentCall
=
dynamic_cast
<
IAXCall
*>
(
iter
->
second
);
if
(
!
currentCall
or
currentCall
->
getState
()
!=
Call
::
Active
)
...
...
@@ -441,9 +441,9 @@ IAXVoIPLink::iaxOutgoingInvite(IAXCall* call)
IAXCall
*
IAXVoIPLink
::
iaxFindCallBySession
(
struct
iax_session
*
session
)
{
ost
::
MutexLock
m
(
_
callMapMutex
);
ost
::
MutexLock
m
(
callMapMutex
_
);
for
(
CallMap
::
const_iterator
iter
=
_
callMap
.
begin
();
iter
!=
_
callMap
.
end
();
++
iter
)
{
for
(
CallMap
::
const_iterator
iter
=
callMap
_
.
begin
();
iter
!=
callMap
_
.
end
();
++
iter
)
{
IAXCall
*
call
=
dynamic_cast
<
IAXCall
*>
(
iter
->
second
);
if
(
call
and
call
->
session
==
session
)
...
...
daemon/src/voiplink.cpp
View file @
a906eff2
...
...
@@ -31,45 +31,45 @@
* as that of the covered work.
*/
#include
"call.h"
#include
"voiplink.h"
#include
"manager.h"
VoIPLink
::~
VoIPLink
(
void
)
VoIPLink
::~
VoIPLink
()
{
ost
::
MutexLock
m
(
_
callMapMutex
);
ost
::
MutexLock
m
(
callMapMutex
_
);
for
(
CallMap
::
const_iterator
iter
=
_
callMap
.
begin
();
iter
!=
_
callMap
.
end
();
++
iter
)
for
(
CallMap
::
const_iterator
iter
=
callMap
_
.
begin
();
iter
!=
callMap
_
.
end
();
++
iter
)
delete
iter
->
second
;
_
callMap
.
clear
();
callMap
_
.
clear
();
}
void
VoIPLink
::
addCall
(
Call
*
call
)
{
if
(
call
and
getCall
(
call
->
getCallId
())
==
NULL
)
{
ost
::
MutexLock
m
(
_
callMapMutex
);
_
callMap
[
call
->
getCallId
()]
=
call
;
ost
::
MutexLock
m
(
callMapMutex
_
);
callMap
_
[
call
->
getCallId
()]
=
call
;
}
}
void
VoIPLink
::
removeCall
(
const
std
::
string
&
id
)
{
ost
::
MutexLock
m
(
_
callMapMutex
);
ost
::
MutexLock
m
(
callMapMutex
_
);
_debug
(
"VoipLink: removing call %s from list"
,
id
.
c_str
());
delete
_
callMap
[
id
];
_
callMap
.
erase
(
id
);
delete
callMap
_
[
id
];
callMap
_
.
erase
(
id
);
}
Call
*
VoIPLink
::
getCall
(
const
std
::
string
&
id
)
{
ost
::
MutexLock
m
(
_
callMapMutex
);
CallMap
::
iterator
iter
=
_
callMap
.
find
(
id
);
ost
::
MutexLock
m
(
callMapMutex
_
);
CallMap
::
iterator
iter
=
callMap
_
.
find
(
id
);
if
(
iter
!=
_
callMap
.
end
())
if
(
iter
!=
callMap
_
.
end
())
return
iter
->
second
;
else
return
NULL
;
...
...
daemon/src/voiplink.h
View file @
a906eff2
...
...
@@ -35,10 +35,12 @@
#define __VOIP_LINK_H__
#include
<stdexcept>
#include
<map>
#include
<cc++/thread.h>
// for ost::Mutex
#include
"call.h"
class
Call
;
class
Account
;
namespace
sfl
{
class
InstantMessaging
;
};
...
...
@@ -48,7 +50,7 @@ typedef std::map<std::string, Call*> CallMap;
class
VoipLinkException
:
public
std
::
runtime_error
{
public:
VoipLinkException
(
const
std
::
string
&
str
=
""
)
:
VoipLinkException
(
const
std
::
string
&
str
=
""
)
:
std
::
runtime_error
(
"UserAgent: VoipLinkException occured: "
+
str
)
{}
};
...
...
@@ -61,20 +63,20 @@ class VoIPLink {
/**
* Virtual destructor
*/
virtual
~
VoIPLink
(
void
);
virtual
~
VoIPLink
();
/**
* Virtual method
* Event listener. Each event send by the call manager is received and handled from here
*/
virtual
void
getEvent
(
void
)
=
0
;
virtual
void
getEvent
()
=
0
;
/**
* Virtual method
* Try to initiate the communication layer and set config
*/
virtual
void
init
(
void
)
=
0
;
virtual
void
init
()
=
0
;
/**
* Virtual method
...
...
@@ -187,10 +189,10 @@ class VoIPLink {
protected:
/** Contains all the calls for this Link, protected by mutex */
CallMap
_
callMap
;
CallMap
callMap
_
;
/** Mutex to protect call map */
ost
::
Mutex
_
callMapMutex
;
ost
::
Mutex
callMapMutex
_
;
/** Remove a call from the call map (protected by mutex)
* @param id A Call ID
...
...
daemon/test/siptest.cpp
View file @
a906eff2
...
...
@@ -43,14 +43,15 @@
using
std
::
cout
;
using
std
::
endl
;
// anonymous namespace
namespace
{
pthread_mutex_t
count_mutex
;
pthread_cond_t
count_nb_thread
;
int
counter
=
0
;
}
void
*
sippThreadWithCount
(
void
*
str
)
{
pthread_mutex_lock
(
&
count_mutex
);
counter
++
;
pthread_mutex_unlock
(
&
count_mutex
);
...
...
@@ -79,13 +80,11 @@ void *sippThreadWithCount(void *str)
pthread_mutex_unlock
(
&
count_mutex
);
pthread_exit
(
NULL
);
}
void
*
sippThread
(
void
*
str
)
{
std
::
string
*
command
=
(
std
::
string
*
)(
str
);
std
::
cout
<<
"SIPTest: "
<<
command
<<
std
::
endl
;
...
...
@@ -102,7 +101,6 @@ void *sippThread(void *str)
CPPUNIT_ASSERT
(
i
==
0
);
pthread_exit
(
NULL
);
}
...
...
@@ -128,16 +126,14 @@ void SIPTest::tearDown()
void
SIPTest
::
testSimpleOutgoingIpCall
()
{
pthread_t
thethread
;
void
*
status
;
// command to be executed by the thread, user agent server waiting for a call
std
::
string
command
(
"sipp -sn uas -i 127.0.0.1 -p 5062 -m 1"
);
int
rc
=
pthread_create
(
&
thethread
,
NULL
,
sippThread
,
(
void
*
)(
&
command
));
if
(
rc
)
{
if
(
rc
)
std
::
cout
<<
"SIPTest: ERROR; return code from pthread_create()"
<<
std
::
endl
;
}
std
::
string
testaccount
(
"IP2IP"
);
std
::
string
testcallid
(
"callid1234"
);
...
...
@@ -175,20 +171,18 @@ void SIPTest::testSimpleOutgoingIpCall()
Manager
::
instance
().
hangupCall
(
testcallid
);
void
*
status
;
rc
=
pthread_join
(
thethread
,
&
status
);
if
(
rc
)
{
if
(
rc
)
std
::
cout
<<
"SIPTest: ERROR; return code from pthread_join(): "
<<
rc
<<
std
::
endl
;
}
else
else
std
::
cout
<<
"SIPTest: completed join with thread"
<<
std
::
endl
;
}
void
SIPTest
::
testSimpleIncomingIpCall
()
{
pthread_t
thethread
;
void
*
status
;
...
...
@@ -197,10 +191,8 @@ void SIPTest::testSimpleIncomingIpCall()
int
rc
=
pthread_create
(
&
thethread
,
NULL
,
sippThread
,
(
void
*
)(
&
command
));
if
(
rc
)
{
if
(
rc
)
std
::
cout
<<
"SIPTest: ERROR; return code from pthread_create()"
<<
std
::
endl
;
}
// sleep a while to make sure that sipp insdtance is initialized and sflphoned received
// the incoming invite.
...
...
@@ -209,8 +201,8 @@ void SIPTest::testSimpleIncomingIpCall()
// gtrab call id from sipvoiplink
SIPVoIPLink
*
siplink
=
SIPVoIPLink
::
instance
();
CPPUNIT_ASSERT
(
siplink
->
_
callMap
.
size
()
==
1
);
CallMap
::
iterator
iterCallId
=
siplink
->
_
callMap
.
begin
();
CPPUNIT_ASSERT
(
siplink
->
callMap
_
.
size
()
==
1
);
CallMap
::
iterator
iterCallId
=
siplink
->
callMap
_
.
begin
();
std
::
string
testcallid
=
iterCallId
->
first
;
// TODO: hmmm, should IP2IP call be stored in call list....
...
...
@@ -219,14 +211,13 @@ void SIPTest::testSimpleIncomingIpCall()
// Answer this call
CPPUNIT_ASSERT
(
Manager
::
instance
().
answerCall
(
testcallid
));
sleep
(
1
);
rc
=
pthread_join
(
thethread
,
&
status
);
if
(
rc
)
{
if
(
rc
)
std
::
cout
<<
"SIPTest: ERROR; return code from pthread_join(): "
<<
rc
<<
std
::
endl
;
}
else
else
std
::
cout
<<
"SIPTest: completed join with thread"
<<
std
::
endl
;
}
...
...
@@ -244,15 +235,13 @@ void SIPTest::testTwoOutgoingIpCall()
int
rc
=
pthread_create
(
&
firstCallThread
,
NULL
,
sippThread
,
(
void
*
)(
&
firstCallCommand
));
if
(
rc
)
{
if
(
rc
)
std
::
cout
<<
"SIPTest: ERROR; return code from pthread_create()"
<<
std
::
endl
;
}
rc
=
pthread_create
(
&
secondCallThread
,
NULL
,
sippThread
,
(
void
*
)(
&
secondCallCommand
));
if
(
rc
)
{
if
(
rc
)
std
::
cout
<<
"SIPTest: ERROR; return code from pthread_create()"
<<
std
::
endl
;
}
sleep
(
1
);
...
...
@@ -281,9 +270,8 @@ void SIPTest::testTwoOutgoingIpCall()
rc
=
pthread_join
(
firstCallThread
,
&
status
);
if
(
rc
)
{
if
(
rc
)
std
::
cout
<<
"SIPTest: ERROR; return code from pthread_join(): "
<<
rc
<<
std
::
endl
;
}
std
::
cout
<<
"SIPTest: completed join with thread"
<<
std
::
endl
;
...
...
@@ -291,15 +279,14 @@ void SIPTest::testTwoOutgoingIpCall()
rc
=
pthread_join
(
secondCallThread
,
&
status
);
if
(
rc
)
{
if
(
rc
)
std
::
cout
<<
"SIPTest: ERROR; return code from pthread_join(): "
<<
rc
<<
std
::
endl
;
}
else
else
std
::
cout
<<
"SIPTest: completed join with thread"
<<
std
::
endl
;
}
void
SIPTest
::
testTwoIncomingIpCall
()
{
pthread_mutex_init
(
&
count_mutex
,
NULL
);
pthread_cond_init
(
&
count_nb_thread
,
NULL
);
...
...
@@ -318,10 +305,8 @@ void SIPTest::testTwoIncomingIpCall()
int
rc
=
pthread_create
(
&
firstCallThread
,
&
attr
,
sippThreadWithCount
,
(
void
*
)(
&
firstCallCommand
));
if
(
rc
)
{
if
(
rc
)
std
::
cout
<<
"SIPTest: ERROR; return code from pthread_create()"
<<
std
::
endl
;
}
// sleep a while to make sure that sipp insdtance is initialized and sflphoned received
// the incoming invite.
...
...
@@ -330,8 +315,8 @@ void SIPTest::testTwoIncomingIpCall()
// gtrab call id from sipvoiplink
SIPVoIPLink
*
sipLink
=
SIPVoIPLink
::
instance
();
CPPUNIT_ASSERT
(
sipLink
->
_
callMap
.
size
()
==
1
);
CallMap
::
iterator
iterCallId
=
sipLink
->
_
callMap
.
begin
();
CPPUNIT_ASSERT
(
sipLink
->
callMap
_
.
size
()
==
1
);
CallMap
::
iterator
iterCallId
=
sipLink
->
callMap
_
.
begin
();
std
::
string
firstCallID
=
iterCallId
->
first
;
// Answer this call
...
...
@@ -347,8 +332,8 @@ void SIPTest::testTwoIncomingIpCall()
sleep
(
1
);
CPPUNIT_ASSERT
(
sipLink
->
_
callMap
.
size
()
==
2
);
iterCallId
=
sipLink
->
_
callMap
.
begin
();
CPPUNIT_ASSERT
(
sipLink
->
callMap
_
.
size
()
==
2
);
iterCallId
=
sipLink
->
callMap
_
.
begin
();
if
(
iterCallId
->
first
==
firstCallID
)
iterCallId
++
;
...
...
@@ -366,25 +351,8 @@ void SIPTest::testTwoIncomingIpCall()
pthread_mutex_unlock
(
&
count_mutex
);
/*
rc = pthread_join(firstCallThread, &status);
if (rc) {
std::cout << "SIPTest: ERROR; return code from pthread_join(): " << rc << std::endl;
}
else
std::cout << "SIPTest: completed join with thread 1" << std::endl;
rc = pthread_join(secondCallThread, &status);
if (rc) {
std::cout << "SIPTest: ERROR; return code from pthread_join(): " << rc << std::endl;
}
else
std::cout << "SIPTest: completed join with thread 2" << std::endl;
*/
pthread_mutex_destroy
(
&
count_mutex
);
pthread_cond_destroy
(
&
count_nb_thread
);
}
...
...
@@ -425,7 +393,6 @@ void SIPTest::testHoldIpCall()
void
SIPTest
::
testIncomingIpCallSdp
()
{
pthread_t
thethread
;
void
*
status
;
...
...
@@ -434,10 +401,8 @@ void SIPTest::testIncomingIpCallSdp()
int
rc
=
pthread_create
(
&
thethread
,
NULL
,
sippThread
,
(
void
*
)(
&
command
));
if
(
rc
)
{
if
(
rc
)
std
::
cout
<<
"SIPTest: ERROR; return code from pthread_create()"
<<
std
::
endl
;
}
// sleep a while to make sure that sipp insdtance is initialized and sflphoned received
// the incoming invite.
...
...
@@ -446,8 +411,8 @@ void SIPTest::testIncomingIpCallSdp()
// gtrab call id from sipvoiplink
SIPVoIPLink
*
siplink
=
SIPVoIPLink
::
instance
();
CPPUNIT_ASSERT
(
siplink
->
_
callMap
.
size
()
==
1
);
CallMap
::
iterator
iterCallId
=
siplink
->
_
callMap
.
begin
();
CPPUNIT_ASSERT
(
siplink
->
callMap
_
.
size
()
==
1
);
CallMap
::
iterator
iterCallId
=
siplink
->
callMap
_
.
begin
();
std
::
string
testcallid
=
iterCallId
->
first
;
// TODO: hmmm, should IP2IP call be stored in call list....
...
...
@@ -461,8 +426,8 @@ void SIPTest::testIncomingIpCallSdp()
rc
=
pthread_join
(
thethread
,
&
status
);
if
(
rc
)
{
if
(
rc
)
std
::
cout
<<
"SIPTest: ERROR; return code from pthread_join(): "
<<
rc
<<
std
::
endl
;
}
else
else
std
::
cout
<<
"SIPTest: completed join with thread"
<<
std
::
endl
;
}
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