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
dfda5df8
Commit
dfda5df8
authored
Jul 19, 2012
by
Alexandre Savard
Browse files
#13678: Fix Zrtp thread may hang when hanging up a call
parent
eac7e9a3
Changes
2
Hide whitespace changes
Inline
Side-by-side
daemon/src/audio/audiortp/audio_zrtp_session.cpp
View file @
dfda5df8
...
...
@@ -47,25 +47,27 @@
namespace
sfl
{
AudioZrtpSession
::
AudioZrtpSession
(
SIPCall
&
call
,
const
std
::
string
&
zidFilename
)
:
AudioRtpSession
(
call
,
*
this
,
*
this
),
ost
::
TRTPSessionBase
<
ost
::
SymmetricRTPChannel
,
ost
::
SymmetricRTPChannel
,
ost
::
ZrtpQueue
>
(
ost
::
InetHostAddress
(
call_
.
getLocalIp
().
c_str
()),
call_
.
getLocalAudioPort
(),
0
,
ost
::
MembershipBookkeeping
::
defaultMembersHashSize
,
ost
::
defaultApplication
()),
zidFilename_
(
zidFilename
)
ost
::
TimerPort
()
,
ost
::
SymmetricZRTPSession
(
ost
::
InetHostAddress
(
call
.
getLocalIp
().
c_str
()),
call
.
getLocalAudioPort
())
,
AudioRtpSession
(
call
,
*
this
,
*
this
)
,
zidFilename_
(
zidFilename
)
,
rtpThread_
(
*
this
)
{
initializeZid
();
DEBUG
(
"Setting new RTP session with destination %s:%d"
,
call_
.
getLocalIp
().
c_str
(),
call_
.
getLocalAudioPort
());
audioRtpRecord_
.
callId_
=
call_
.
getCallId
();
}
AudioZrtpSession
::~
AudioZrtpSession
()
{
ost
::
Thread
::
terminate
();
Manager
::
instance
().
getMainBuffer
()
->
unBindAll
(
call_
.
getCallId
());
if
(
rtpThread_
.
running_
)
{
rtpThread_
.
running_
=
false
;
rtpThread_
.
join
();
}
}
void
AudioZrtpSession
::
initializeZid
()
{
if
(
zidFilename_
.
empty
())
...
...
@@ -120,46 +122,31 @@ void AudioZrtpSession::sendMicData()
queue_
.
sendImmediate
(
timestamp_
,
getMicDataEncoded
(),
compSize
);
}
void
AudioZrtpSession
::
run
()
AudioZrtpSession
::
AudioZrtpThread
::
AudioZrtpThread
(
AudioZrtpSession
&
session
)
:
running_
(
true
),
zrtpSession_
(
session
)
{}
void
AudioZrtpSession
::
AudioZrtpThread
::
run
()
{
// Set recording sampling rate
call_
.
setRecordingSmplRate
(
getCodecSampleRate
());
DEBUG
(
"Entering mainloop for call %s"
,
call_
.
getCallId
().
c_str
());
int
threadSleep
=
20
;
uint32
timeout
=
0
;
DEBUG
(
"Entering Audio zrtp thread main loop %s"
,
running_
?
"running"
:
"not running"
)
;
while
(
isActive
())
{
if
(
timeout
<
1000
)
timeout
=
getSchedulingTimeout
();
TimerPort
::
setTimer
(
threadSleep
);
while
(
running_
)
{
// Send session
if
(
hasDTMFPending
())
sendDtmfEvent
();
if
(
zrtpSession_
.
hasDTMFPending
())
zrtpSession_
.
sendDtmfEvent
();
else
sendMicData
();
controlReceptionService
();
controlTransmissionService
();
uint32
maxWait
=
timeval2microtimeout
(
getRTCPCheckInterval
());
// make sure the scheduling timeout is
// <= the check interval for RTCP
// packets
timeout
=
(
timeout
>
maxWait
)
?
maxWait
:
timeout
;
if
(
timeout
<
1000
)
{
// !(timeout/1000)
// dispatchDataPacket();
timerTick
();
}
else
{
if
(
isPendingData
(
timeout
/
1000
))
{
if
(
isActive
())
takeInDataPacket
();
}
timeout
=
0
;
}
zrtpSession_
.
sendMicData
();
Thread
::
sleep
(
TimerPort
::
getTimer
());
TimerPort
::
incTimer
(
threadSleep
);
}
DEBUG
(
"Le
ft main loop for call %s"
,
call_
.
getCallId
().
c_str
()
);
DEBUG
(
"Le
aving audio rtp thread loop"
);
}
int
AudioZrtpSession
::
getIncrementForDTMF
()
const
...
...
@@ -172,4 +159,13 @@ void AudioZrtpSession::setSessionMedia(AudioCodec &audioCodec)
AudioRtpSession
::
setSessionMedia
(
audioCodec
);
}
int
AudioZrtpSession
::
startRtpThread
(
AudioCodec
&
audiocodec
)
{
if
(
isStarted_
)
return
0
;
AudioRtpSession
::
startRtpThread
(
audiocodec
);
return
startZrtpThread
();
}
}
daemon/src/audio/audiortp/audio_zrtp_session.h
View file @
dfda5df8
...
...
@@ -54,25 +54,46 @@ class ZrtpZidException : public std::runtime_error {
};
class
AudioZrtpSession
:
public
AudioRtpSession
,
protected
ost
::
Thread
,
public
ost
::
TRTPSessionBase
<
ost
::
SymmetricRTPChannel
,
ost
::
SymmetricRTPChannel
,
ost
::
ZrtpQueue
>
{
public
ost
::
TimerPort
,
// public ost::TRTPSessionBase<ost::SymmetricRTPChannel, ost::SymmetricRTPChannel, ost::ZrtpQueue> {
public
ost
::
SymmetricZRTPSession
,
public
AudioRtpSession
{
public:
AudioZrtpSession
(
SIPCall
&
call
,
const
std
::
string
&
zidFilename
);
~
AudioZrtpSession
();
// Thread associated method
virtual
void
run
();
int
startZrtpThread
()
{
rtpThread_
.
start
();
return
0
;
}
virtual
bool
onRTPPacketRecv
(
ost
::
IncomingRTPPkt
&
pkt
)
{
return
AudioRtpSession
::
onRTPPacketRecv
(
pkt
);
}
private:
NON_COPYABLE
(
AudioZrtpSession
);
class
AudioZrtpThread
:
public
ost
::
Thread
,
public
ost
::
TimerPort
{
public:
AudioZrtpThread
(
AudioZrtpSession
&
session
);
virtual
void
run
();
bool
running_
;
private:
NON_COPYABLE
(
AudioZrtpThread
);
AudioZrtpSession
&
zrtpSession_
;
};
void
sendMicData
();
void
initializeZid
();
std
::
string
zidFilename_
;
void
setSessionMedia
(
AudioCodec
&
codec
);
int
startRtpThread
(
AudioCodec
&
audiocodec
);
virtual
int
getIncrementForDTMF
()
const
;
AudioZrtpThread
rtpThread_
;
};
}
...
...
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