From bae9298203aeffca8f9bc8f5abe67e1ecd9ac904 Mon Sep 17 00:00:00 2001
From: Alexandre Savard <alexandre.savard@savoirfairelinux.com>
Date: Tue, 2 Nov 2010 11:41:58 -0400
Subject: [PATCH] [#4367] Fix audio zrtp timing

---
 .../src/audio/audiortp/AudioRtpSession.cpp       |  8 ++++----
 .../src/audio/audiortp/AudioZrtpSession.cpp      | 16 +++++++++++++---
 .../src/audio/audiortp/AudioZrtpSession.h        |  8 +++++++-
 3 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/sflphone-common/src/audio/audiortp/AudioRtpSession.cpp b/sflphone-common/src/audio/audiortp/AudioRtpSession.cpp
index 2ccda8216e..e6143b9f34 100644
--- a/sflphone-common/src/audio/audiortp/AudioRtpSession.cpp
+++ b/sflphone-common/src/audio/audiortp/AudioRtpSession.cpp
@@ -45,10 +45,10 @@ AudioRtpSession::AudioRtpSession (ManagerImpl * manager, SIPCall * sipcall) :
 		// ost::SymmetricRTPSession (ost::InetHostAddress (sipcall->getLocalIp().c_str()), sipcall->getLocalAudioPort()),
 		AudioRtpRecordHandler(manager, sipcall),
 		ost::TRTPSessionBase<ost::SymmetricRTPChannel,ost::SymmetricRTPChannel,ost::AVPQueue>(ost::InetHostAddress (sipcall->getLocalIp().c_str()),
-																sipcall->getLocalAudioPort(),
-																0,
-																ost::MembershipBookkeeping::defaultMembersHashSize,
-																ost::defaultApplication())
+									sipcall->getLocalAudioPort(),
+									0,
+									ost::MembershipBookkeeping::defaultMembersHashSize,
+									ost::defaultApplication())
 																		, _time (new ost::Time())
         																	, _mainloopSemaphore (0)
         																	, _manager (manager)
diff --git a/sflphone-common/src/audio/audiortp/AudioZrtpSession.cpp b/sflphone-common/src/audio/audiortp/AudioZrtpSession.cpp
index d3041fe45b..d78818a494 100644
--- a/sflphone-common/src/audio/audiortp/AudioZrtpSession.cpp
+++ b/sflphone-common/src/audio/audiortp/AudioZrtpSession.cpp
@@ -35,6 +35,7 @@
 #include "audio/audiolayer.h"
 #include "manager.h"
 
+#include <libzrtpcpp/zrtpccrtp.h>
 #include <libzrtpcpp/ZrtpQueue.h>
 #include <libzrtpcpp/ZrtpUserCallback.h>
 
@@ -42,13 +43,20 @@
 #include <cstring>
 #include <cerrno>
 
+#include <ccrtp/rtp.h>
+
 namespace sfl
 {
 
 AudioZrtpSession::AudioZrtpSession (ManagerImpl * manager, SIPCall * sipcall, const std::string& zidFilename) :
-        ost::SymmetricZRTPSession (ost::InetHostAddress (sipcall->getLocalIp().c_str()), sipcall->getLocalAudioPort()),
-        AudioRtpRecordHandler(manager, sipcall)
-																											  , _zidFilename (zidFilename)
+        // ost::SymmetricZRTPSession (ost::InetHostAddress (sipcall->getLocalIp().c_str()), sipcall->getLocalAudioPort()),
+        AudioRtpRecordHandler(manager, sipcall),
+        ost::TRTPSessionBase<ost::SymmetricRTPChannel, ost::SymmetricRTPChannel, ost::ZrtpQueue> (ost::InetHostAddress (sipcall->getLocalIp().c_str()),
+				sipcall->getLocalAudioPort(),
+				0,
+				ost::MembershipBookkeeping::defaultMembersHashSize,
+				ost::defaultApplication())
+        																									  , _zidFilename (zidFilename)
 																											  , _time (new ost::Time())
 																											  , _mainloopSemaphore (0)
 																											  , _manager (manager)
@@ -361,6 +369,7 @@ void AudioZrtpSession::run ()
     // Timestamp must be initialized randomly
     _timestamp = getCurrentTimestamp();
 
+    /*
     int threadSleep = 0;
 
     if (getCodecSampleRate() != 0) {
@@ -371,6 +380,7 @@ void AudioZrtpSession::run ()
     }
 
     TimerPort::setTimer (threadSleep);
+	*/
 
     // Set recording sampling rate
     _ca->setRecordingSmplRate (getCodecSampleRate());
diff --git a/sflphone-common/src/audio/audiortp/AudioZrtpSession.h b/sflphone-common/src/audio/audiortp/AudioZrtpSession.h
index 91c77019e7..0d0de47cb8 100644
--- a/sflphone-common/src/audio/audiortp/AudioZrtpSession.h
+++ b/sflphone-common/src/audio/audiortp/AudioZrtpSession.h
@@ -29,7 +29,12 @@
 #ifndef __SFL_AUDIO_ZRTP_SESSION_H__
 #define __SFL_AUDIO_ZRTP_SESSION_H__
 
+
+#include <ccrtp/rtp.h>
+
 #include <libzrtpcpp/zrtpccrtp.h>
+#include <libzrtpcpp/ZrtpQueue.h>
+#include <libzrtpcpp/ZrtpUserCallback.h>
 
 #include "AudioRtpRecordHandler.h"
 #include <cc++/numbers.h> // OST::Time
@@ -47,7 +52,8 @@ class ZrtpZidException: public std::exception
         }
 };
 
-class AudioZrtpSession : public ost::TimerPort, public ost::SymmetricZRTPSession, public AudioRtpRecordHandler
+// class AudioZrtpSession : public ost::TimerPort, public ost::SymmetricZRTPSession, public AudioRtpRecordHandler
+class AudioZrtpSession : protected ost::Thread, public AudioRtpRecordHandler, public ost::TRTPSessionBase<ost::SymmetricRTPChannel, ost::SymmetricRTPChannel, ost::ZrtpQueue>
 {
     public:
         AudioZrtpSession (ManagerImpl * manager, SIPCall * sipcall, const std::string& zidFilename);
-- 
GitLab