Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
83f9a6ff
Commit
83f9a6ff
authored
11 years ago
by
Guillaume Roguez
Committed by
Tristan Matthews
11 years ago
Browse files
Options
Downloads
Patches
Plain Diff
iax: make IAX lock global
Refs #51555 Change-Id: I7b4583a4e6b63a83f69947eec1e674cd9ba580ec
parent
1f9ea697
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
daemon/src/iax/iaxvoiplink.cpp
+18
-18
18 additions, 18 deletions
daemon/src/iax/iaxvoiplink.cpp
daemon/src/iax/iaxvoiplink.h
+4
-4
4 additions, 4 deletions
daemon/src/iax/iaxvoiplink.h
with
22 additions
and
22 deletions
daemon/src/iax/iaxvoiplink.cpp
+
18
−
18
View file @
83f9a6ff
...
@@ -48,11 +48,11 @@
...
@@ -48,11 +48,11 @@
AccountMap
IAXVoIPLink
::
iaxAccountMap_
;
AccountMap
IAXVoIPLink
::
iaxAccountMap_
;
IAXCallMap
IAXVoIPLink
::
iaxCallMap_
;
IAXCallMap
IAXVoIPLink
::
iaxCallMap_
;
std
::
mutex
IAXVoIPLink
::
iaxCallMapMutex_
;
std
::
mutex
IAXVoIPLink
::
iaxCallMapMutex_
;
std
::
mutex
IAXVoIPLink
::
mutexIAX
=
{};
IAXVoIPLink
::
IAXVoIPLink
(
const
std
::
string
&
accountID
)
:
IAXVoIPLink
::
IAXVoIPLink
(
const
std
::
string
&
accountID
)
:
regSession_
(
NULL
)
regSession_
(
NULL
)
,
nextRefreshStamp_
(
0
)
,
nextRefreshStamp_
(
0
)
,
mutexIAX_
()
,
rawBuffer_
(
RAW_BUFFER_SIZE
,
AudioFormat
::
MONO
)
,
rawBuffer_
(
RAW_BUFFER_SIZE
,
AudioFormat
::
MONO
)
,
resampledData_
(
RAW_BUFFER_SIZE
*
4
,
AudioFormat
::
MONO
)
,
resampledData_
(
RAW_BUFFER_SIZE
*
4
,
AudioFormat
::
MONO
)
,
encodedData_
()
,
encodedData_
()
...
@@ -103,7 +103,7 @@ IAXVoIPLink::terminate()
...
@@ -103,7 +103,7 @@ IAXVoIPLink::terminate()
for
(
auto
&
item
:
iaxCallMap_
)
{
for
(
auto
&
item
:
iaxCallMap_
)
{
auto
&
call
=
item
.
second
;
auto
&
call
=
item
.
second
;
if
(
call
)
{
if
(
call
)
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutexIAX
_
);
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutexIAX
);
iax_hangup
(
call
->
session
,
const_cast
<
char
*>
(
"Dumped Call"
));
iax_hangup
(
call
->
session
,
const_cast
<
char
*>
(
"Dumped Call"
));
call
.
reset
();
call
.
reset
();
}
}
...
@@ -121,7 +121,7 @@ IAXVoIPLink::getEvent()
...
@@ -121,7 +121,7 @@ IAXVoIPLink::getEvent()
iax_event
*
event
=
NULL
;
iax_event
*
event
=
NULL
;
{
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutexIAX
_
);
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutexIAX
);
event
=
iax_get_event
(
0
);
event
=
iax_get_event
(
0
);
}
}
...
@@ -129,7 +129,7 @@ IAXVoIPLink::getEvent()
...
@@ -129,7 +129,7 @@ IAXVoIPLink::getEvent()
// 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
)
{
if
(
event
->
etype
==
IAX_EVENT_NULL
)
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutexIAX
_
);
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutexIAX
);
iax_event_free
(
event
);
iax_event_free
(
event
);
event
=
iax_get_event
(
0
);
event
=
iax_get_event
(
0
);
continue
;
continue
;
...
@@ -148,7 +148,7 @@ IAXVoIPLink::getEvent()
...
@@ -148,7 +148,7 @@ IAXVoIPLink::getEvent()
}
}
{
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutexIAX
_
);
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutexIAX
);
iax_event_free
(
event
);
iax_event_free
(
event
);
event
=
iax_get_event
(
0
);
event
=
iax_get_event
(
0
);
}
}
...
@@ -237,7 +237,7 @@ IAXVoIPLink::sendAudioFromMic()
...
@@ -237,7 +237,7 @@ IAXVoIPLink::sendAudioFromMic()
compSize
=
audioCodec
->
encode
(
in
->
getData
(),
encodedData_
,
RAW_BUFFER_SIZE
);
compSize
=
audioCodec
->
encode
(
in
->
getData
(),
encodedData_
,
RAW_BUFFER_SIZE
);
if
(
currentCall
->
session
and
samples
>
0
)
{
if
(
currentCall
->
session
and
samples
>
0
)
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutexIAX
_
);
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutexIAX
);
if
(
iax_send_voice
(
currentCall
->
session
,
currentCall
->
format
,
encodedData_
,
compSize
,
outSamples
)
==
-
1
)
if
(
iax_send_voice
(
currentCall
->
session
,
currentCall
->
format
,
encodedData_
,
compSize
,
outSamples
)
==
-
1
)
ERROR
(
"IAX: Error sending voice data."
);
ERROR
(
"IAX: Error sending voice data."
);
...
@@ -266,7 +266,7 @@ IAXVoIPLink::sendRegister(Account& a)
...
@@ -266,7 +266,7 @@ IAXVoIPLink::sendRegister(Account& a)
if
(
account
.
getUsername
().
empty
())
if
(
account
.
getUsername
().
empty
())
throw
VoipLinkException
(
"Account username is empty"
);
throw
VoipLinkException
(
"Account username is empty"
);
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutexIAX
_
);
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutexIAX
);
if
(
regSession_
)
if
(
regSession_
)
iax_destroy
(
regSession_
);
iax_destroy
(
regSession_
);
...
@@ -284,7 +284,7 @@ void
...
@@ -284,7 +284,7 @@ void
IAXVoIPLink
::
sendUnregister
(
Account
&
a
,
std
::
function
<
void
(
bool
)
>
cb
)
IAXVoIPLink
::
sendUnregister
(
Account
&
a
,
std
::
function
<
void
(
bool
)
>
cb
)
{
{
if
(
regSession_
)
{
if
(
regSession_
)
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutexIAX
_
);
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutexIAX
);
iax_destroy
(
regSession_
);
iax_destroy
(
regSession_
);
regSession_
=
NULL
;
regSession_
=
NULL
;
}
}
...
@@ -320,7 +320,7 @@ IAXVoIPLink::answer(Call *call)
...
@@ -320,7 +320,7 @@ IAXVoIPLink::answer(Call *call)
Manager
::
instance
().
addStream
(
call
->
getCallId
());
Manager
::
instance
().
addStream
(
call
->
getCallId
());
{
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutexIAX
_
);
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutexIAX
);
call
->
answer
();
call
->
answer
();
}
}
...
@@ -342,7 +342,7 @@ IAXVoIPLink::hangup(const std::string& id, int reason UNUSED)
...
@@ -342,7 +342,7 @@ IAXVoIPLink::hangup(const std::string& id, int reason UNUSED)
throw
VoipLinkException
(
"Could not find call"
);
throw
VoipLinkException
(
"Could not find call"
);
{
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutexIAX
_
);
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutexIAX
);
iax_hangup
(
call
->
session
,
(
char
*
)
"Dumped Call"
);
iax_hangup
(
call
->
session
,
(
char
*
)
"Dumped Call"
);
}
}
call
->
session
=
NULL
;
call
->
session
=
NULL
;
...
@@ -382,7 +382,7 @@ IAXVoIPLink::onhold(const std::string& id)
...
@@ -382,7 +382,7 @@ IAXVoIPLink::onhold(const std::string& id)
if
(
!
call
)
if
(
!
call
)
throw
VoipLinkException
(
"Could not find call"
);
throw
VoipLinkException
(
"Could not find call"
);
{
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutexIAX
_
);
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutexIAX
);
iax_quelch_moh
(
call
->
session
,
true
);
iax_quelch_moh
(
call
->
session
,
true
);
}
}
call
->
setState
(
Call
::
HOLD
);
call
->
setState
(
Call
::
HOLD
);
...
@@ -402,7 +402,7 @@ IAXVoIPLink::offhold(const std::string& id)
...
@@ -402,7 +402,7 @@ IAXVoIPLink::offhold(const std::string& id)
throw
VoipLinkException
(
"Could not find call"
);
throw
VoipLinkException
(
"Could not find call"
);
{
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutexIAX
_
);
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutexIAX
);
iax_unquelch
(
call
->
session
);
iax_unquelch
(
call
->
session
);
}
}
...
@@ -424,7 +424,7 @@ IAXVoIPLink::transfer(const std::string& id, const std::string& to)
...
@@ -424,7 +424,7 @@ IAXVoIPLink::transfer(const std::string& id, const std::string& to)
if
(
!
call
)
if
(
!
call
)
return
;
return
;
{
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutexIAX
_
);
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutexIAX
);
iax_transfer
(
call
->
session
,
callto
);
iax_transfer
(
call
->
session
,
callto
);
}
}
}
}
...
@@ -445,7 +445,7 @@ IAXVoIPLink::refuse(const std::string& id)
...
@@ -445,7 +445,7 @@ IAXVoIPLink::refuse(const std::string& id)
if
(
!
call
)
if
(
!
call
)
return
;
return
;
{
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutexIAX
_
);
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutexIAX
);
iax_reject
(
call
->
session
,
(
char
*
)
"Call rejected manually."
);
iax_reject
(
call
->
session
,
(
char
*
)
"Call rejected manually."
);
}
}
}
}
...
@@ -462,7 +462,7 @@ IAXVoIPLink::carryingDTMFdigits(const std::string& id, char code)
...
@@ -462,7 +462,7 @@ IAXVoIPLink::carryingDTMFdigits(const std::string& id, char code)
return
;
return
;
{
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutexIAX
_
);
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutexIAX
);
iax_send_dtmf
(
call
->
session
,
code
);
iax_send_dtmf
(
call
->
session
,
code
);
}
}
}
}
...
@@ -479,7 +479,7 @@ IAXVoIPLink::sendTextMessage(const std::string& callID,
...
@@ -479,7 +479,7 @@ IAXVoIPLink::sendTextMessage(const std::string& callID,
return
;
return
;
{
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutexIAX
_
);
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutexIAX
);
sfl
::
InstantMessaging
::
send_iax_message
(
call
->
session
,
callID
,
message
.
c_str
());
sfl
::
InstantMessaging
::
send_iax_message
(
call
->
session
,
callID
,
message
.
c_str
());
}
}
}
}
...
@@ -526,7 +526,7 @@ IAXVoIPLink::getIaxCall(const std::string& id)
...
@@ -526,7 +526,7 @@ IAXVoIPLink::getIaxCall(const std::string& id)
void
void
IAXVoIPLink
::
iaxOutgoingInvite
(
IAXCall
*
call
)
IAXVoIPLink
::
iaxOutgoingInvite
(
IAXCall
*
call
)
{
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutexIAX
_
);
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutexIAX
);
call
->
session
=
iax_session_new
();
call
->
session
=
iax_session_new
();
...
@@ -764,7 +764,7 @@ void IAXVoIPLink::iaxHandleRegReply(iax_event* event)
...
@@ -764,7 +764,7 @@ void IAXVoIPLink::iaxHandleRegReply(iax_event* event)
return
;
return
;
{
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutexIAX
_
);
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutexIAX
);
iax_destroy
(
regSession_
);
iax_destroy
(
regSession_
);
regSession_
=
NULL
;
regSession_
=
NULL
;
}
}
...
...
This diff is collapsed.
Click to expand it.
daemon/src/iax/iaxvoiplink.h
+
4
−
4
View file @
83f9a6ff
...
@@ -199,6 +199,10 @@ class IAXVoIPLink : public VoIPLink {
...
@@ -199,6 +199,10 @@ class IAXVoIPLink : public VoIPLink {
static
std
::
shared_ptr
<
IAXCall
>
getIaxCall
(
const
std
::
string
&
id
);
static
std
::
shared_ptr
<
IAXCall
>
getIaxCall
(
const
std
::
string
&
id
);
static
void
removeIaxCall
(
const
std
::
string
&
id
);
static
void
removeIaxCall
(
const
std
::
string
&
id
);
/** Mutex for iax_ calls, since we're the only one dealing with the incorporated
* iax_stuff inside this class. */
static
std
::
mutex
mutexIAX
;
private
:
private
:
NON_COPYABLE
(
IAXVoIPLink
);
NON_COPYABLE
(
IAXVoIPLink
);
...
@@ -286,10 +290,6 @@ class IAXVoIPLink : public VoIPLink {
...
@@ -286,10 +290,6 @@ class IAXVoIPLink : public VoIPLink {
* to force a registration. */
* to force a registration. */
int
nextRefreshStamp_
;
int
nextRefreshStamp_
;
/** Mutex for iax_ calls, since we're the only one dealing with the incorporated
* iax_stuff inside this class. */
std
::
mutex
mutexIAX_
;
/** encoder/decoder/resampler buffers */
/** encoder/decoder/resampler buffers */
AudioBuffer
rawBuffer_
;
AudioBuffer
rawBuffer_
;
AudioBuffer
resampledData_
;
AudioBuffer
resampledData_
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment