Skip to content
Snippets Groups Projects
Commit 17e340f7 authored by Alexandre Savard's avatar Alexandre Savard
Browse files

[#4367] Dispatch ZRTP packets

parent 06932dca
No related branches found
No related tags found
No related merge requests found
...@@ -57,6 +57,10 @@ static const int g722PayloadType = 9; ...@@ -57,6 +57,10 @@ static const int g722PayloadType = 9;
static const int g722RtpClockRate = 8000; static const int g722RtpClockRate = 8000;
static const int g722RtpTimeincrement = 160; static const int g722RtpTimeincrement = 160;
inline uint32
timeval2microtimeout(const timeval& t)
{ return ((t.tv_sec * 1000000ul) + t.tv_usec); }
class AudioRtpSessionException: public std::exception class AudioRtpSessionException: public std::exception
{ {
virtual const char* what() const throw() { virtual const char* what() const throw() {
......
...@@ -41,11 +41,6 @@ ...@@ -41,11 +41,6 @@
namespace sfl namespace sfl
{ {
inline uint32
timeval2microtimeout(const timeval& t)
{ return ((t.tv_sec * 1000000ul) + t.tv_usec); }
AudioRtpSession::AudioRtpSession (ManagerImpl * manager, SIPCall * sipcall) : AudioRtpSession::AudioRtpSession (ManagerImpl * manager, SIPCall * sipcall) :
// ost::SymmetricRTPSession (ost::InetHostAddress (sipcall->getLocalIp().c_str()), sipcall->getLocalAudioPort()), // ost::SymmetricRTPSession (ost::InetHostAddress (sipcall->getLocalIp().c_str()), sipcall->getLocalAudioPort()),
AudioRtpRecordHandler(manager, sipcall), AudioRtpRecordHandler(manager, sipcall),
......
...@@ -380,24 +380,15 @@ void AudioZrtpSession::run () ...@@ -380,24 +380,15 @@ void AudioZrtpSession::run ()
_debug ("AudioZrtpSession: Entering mainloop for call %s",_ca->getCallId().c_str()); _debug ("AudioZrtpSession: Entering mainloop for call %s",_ca->getCallId().c_str());
while (!testCancel()) { uint32 timeout = 0;
while ( isActive() ) {
_debug("run"); if ( timeout < 1000 ){ // !(timeout/1000)
timeout = getSchedulingTimeout();
// Reset timestamp to make sure the timing information are up to date
if (_timestampCount > RTP_TIMESTAMP_RESET_FREQ) {
_timestamp = getCurrentTimestamp();
_timestampCount = 0;
} }
_timestampCount++;
_manager->getAudioLayerMutex()->enter(); _manager->getAudioLayerMutex()->enter();
// TODO should not be linked to audio layer here
// converterSamplingRate = _audiolayer->getMainBuffer()->getInternalSamplingRate();
// _converterSamplingRate = _manager->getAudioDriver()->getMainBuffer()->getInternalSamplingRate();
// Send session // Send session
if (getEventQueueSize() > 0) { if (getEventQueueSize() > 0) {
sendDtmfEvent (getEventQueue()->front()); sendDtmfEvent (getEventQueue()->front());
...@@ -405,15 +396,37 @@ void AudioZrtpSession::run () ...@@ -405,15 +396,37 @@ void AudioZrtpSession::run ()
sendMicData (); sendMicData ();
} }
// Recv session // This also should be moved
// TODO should not be called here anymore notifyIncomingCall();
// receiveSpeakerData ();
_manager->getAudioLayerMutex()->leave(); _manager->getAudioLayerMutex()->leave();
// Let's wait for the next transmit cycle setCancel(cancelDeferred);
Thread::sleep (TimerPort::getTimer()); controlReceptionService();
TimerPort::incTimer (threadSleep); controlTransmissionService();
setCancel(cancelImmediate);
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)
setCancel(cancelDeferred);
dispatchDataPacket();
setCancel(cancelImmediate);
timerTick();
} else {
if ( isPendingData(timeout/1000) ) {
setCancel(cancelDeferred);
if (isActive()) { // take in only if active
takeInDataPacket();
}
setCancel(cancelImmediate);
}
timeout = 0;
}
} }
_debug ("AudioZrtpSession: Left main loop for call %s", _ca->getCallId().c_str()); _debug ("AudioZrtpSession: Left main loop for call %s", _ca->getCallId().c_str());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment