summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenri Herscher <henri@oreka.org>2006-02-03 03:47:47 +0000
committerHenri Herscher <henri@oreka.org>2006-02-03 03:47:47 +0000
commit94ceee3f8514c6f368ae24e45ac7051f57885f31 (patch)
tree71e85f64f2d35ae561ad8d9ffa79a73977450455
parentcf76fd8d0bc169cf35948ac48e08fd03280a6a1f (diff)
Duplicate SIP invites now disregarded so that sessions do not stop spuriously. Also when a pcap file is replayed, all RTP sessions are now closed before the thread ends so as to avoid hanging RTP sessions.
git-svn-id: https://oreka.svn.sourceforge.net/svnroot/oreka/trunk@156 09dcff7a-b715-0410-9601-b79a96267cd0
-rw-r--r--orkaudio/audiocaptureplugins/voip/RtpSession.cpp30
-rw-r--r--orkaudio/audiocaptureplugins/voip/RtpSession.h1
-rw-r--r--orkaudio/audiocaptureplugins/voip/VoIp.cpp20
3 files changed, 39 insertions, 12 deletions
diff --git a/orkaudio/audiocaptureplugins/voip/RtpSession.cpp b/orkaudio/audiocaptureplugins/voip/RtpSession.cpp
index 8cfbab7..e164291 100644
--- a/orkaudio/audiocaptureplugins/voip/RtpSession.cpp
+++ b/orkaudio/audiocaptureplugins/voip/RtpSession.cpp
@@ -13,6 +13,8 @@
#define _WINSOCKAPI_ // prevents the inclusion of winsock.h
+#define RTP_SESSION_TIMEOUT 10
+
#include "Utils.h"
#include "RtpSession.h"
#include "AudioCapturePlugin.h"
@@ -417,16 +419,26 @@ void RtpSessions::ReportSipInvite(SipInviteInfoRef& invite)
pair = m_byIpAndPort.find(ipAndPort);
if (pair != m_byIpAndPort.end())
{
+ // #### old behaviour
// A session exists ont the same IP+port, stop old session
- RtpSessionRef session = pair->second;
- Stop(session);
+ //RtpSessionRef session = pair->second;
+ //Stop(session);
+
+ // #### new behaviour
+ // The session already exists, do nothing
+ return;
}
pair = m_byCallId.find(invite->m_callId);
if (pair != m_byCallId.end())
{
+ // #### old behaviour
// A session exists ont the same CallId, stop old session
- RtpSessionRef session = pair->second;
- Stop(session);
+ //RtpSessionRef session = pair->second;
+ //Stop(session);
+
+ // #### new behaviour
+ // The session already exists, do nothing
+ return;
}
// create new session and insert into both maps
@@ -641,6 +653,12 @@ void RtpSessions::ReportRtpPacket(RtpPacketInfoRef& rtpPacket)
}
}
+void RtpSessions::StopAll()
+{
+ time_t forceExpiryTime = time(NULL) + 2*RTP_SESSION_TIMEOUT;
+ Hoover(forceExpiryTime);
+}
+
void RtpSessions::Hoover(time_t now)
{
CStdString numSessions = IntToString(m_byIpAndPort.size());
@@ -653,7 +671,7 @@ void RtpSessions::Hoover(time_t now)
for(pair = m_byIpAndPort.begin(); pair != m_byIpAndPort.end(); pair++)
{
RtpSessionRef session = pair->second;
- if((now - session->m_lastUpdated) > 10)
+ if((now - session->m_lastUpdated) > RTP_SESSION_TIMEOUT)
{
toDismiss.push_back(session);
}
@@ -672,7 +690,7 @@ void RtpSessions::Hoover(time_t now)
for(pair = m_byCallId.begin(); pair != m_byCallId.end(); pair++)
{
RtpSessionRef session = pair->second;
- if((now - session->m_lastUpdated) > 10)
+ if((now - session->m_lastUpdated) > RTP_SESSION_TIMEOUT)
{
toDismiss.push_back(session);
}
diff --git a/orkaudio/audiocaptureplugins/voip/RtpSession.h b/orkaudio/audiocaptureplugins/voip/RtpSession.h
index cf6844a..85540a0 100644
--- a/orkaudio/audiocaptureplugins/voip/RtpSession.h
+++ b/orkaudio/audiocaptureplugins/voip/RtpSession.h
@@ -121,6 +121,7 @@ class RtpSessions
public:
RtpSessions();
void Stop(RtpSessionRef& session);
+ void StopAll();
void ReportSipInvite(SipInviteInfoRef& invite);
void ReportSipBye(SipByeInfo bye);
void ReportSkinnyCallInfo(SkCallInfoStruct*);
diff --git a/orkaudio/audiocaptureplugins/voip/VoIp.cpp b/orkaudio/audiocaptureplugins/voip/VoIp.cpp
index e03e25a..8ede689 100644
--- a/orkaudio/audiocaptureplugins/voip/VoIp.cpp
+++ b/orkaudio/audiocaptureplugins/voip/VoIp.cpp
@@ -16,6 +16,7 @@
#include <list>
#include "ace/OS_NS_unistd.h"
#include "ace/OS_NS_string.h"
+#include "ace/OS_NS_strings.h"
#include "ace/Singleton.h"
#include "ace/Min_Max.h"
#include "ace/OS_NS_arpa_inet.h"
@@ -42,16 +43,16 @@ static LoggerPtr s_rtpPacketLog;
static LoggerPtr s_sipPacketLog;
static LoggerPtr s_skinnyPacketLog;
static LoggerPtr s_sipExtractionLog;
-time_t s_lastHooveringTime;
-
+static time_t s_lastHooveringTime;
static ACE_Thread_Mutex s_mutex;
+static bool s_liveCapture;
VoIpConfigTopObjectRef g_VoIpConfigTopObjectRef;
#define DLLCONFIG g_VoIpConfigTopObjectRef.get()->m_config
#define PROMISCUOUS 1
-// Convert a piece of memnory to hex string
+// Convert a piece of memory to hex string
void memToHex(unsigned char* input, size_t len, CStdString&output)
{
char byteAsHex[10];
@@ -62,12 +63,12 @@ void memToHex(unsigned char* input, size_t len, CStdString&output)
}
}
-// find the address that follows the given search string between start and stop pointers
+// find the address that follows the given search string between start and stop pointers - case insensitive
char* memFindAfter(char* toFind, char* start, char* stop)
{
for(char * ptr = start; (ptr<stop) && (ptr != NULL); ptr = (char *)memchr(ptr+1, toFind[0],(stop - start)))
{
- if(memcmp(toFind, ptr, strlen(toFind)) == 0)
+ if(ACE_OS::strncasecmp(toFind, ptr, strlen(toFind)) == 0)
{
return (ptr+strlen(toFind));
}
@@ -420,6 +421,11 @@ void SingleDeviceCaptureThreadHandler(pcap_t* pcapHandle)
log.Format("Start Capturing: pcap handle:%x", pcapHandle);
LOG4CXX_INFO(s_packetLog, log);
pcap_loop(pcapHandle, 0, HandlePacket, NULL);
+ if(!s_liveCapture)
+ {
+ // This is a pcap file replay, stop all sessions before exiting
+ RtpSessionsSingleton::instance()->StopAll();
+ }
log.Format("Stop Capturing: pcap handle:%x", pcapHandle);
LOG4CXX_INFO(s_packetLog, log);
}
@@ -592,8 +598,8 @@ void VoIp::Initialize()
s_rtpPacketLog = Logger::getLogger("packet.rtp");
s_sipPacketLog = Logger::getLogger("packet.sip");
s_skinnyPacketLog = Logger::getLogger("packet.skinny");
-
s_sipExtractionLog = Logger::getLogger("sipextraction");
+
LOG4CXX_INFO(s_packetLog, "Initializing VoIP plugin");
// create a default config object in case it was not properly initialized by Configure
@@ -605,10 +611,12 @@ void VoIp::Initialize()
if(DLLCONFIG.m_pcapFile.size() > 0)
{
OpenPcapFile(DLLCONFIG.m_pcapFile);
+ s_liveCapture = false;
}
else
{
OpenDevices();
+ s_liveCapture = true;
}
}