summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbeg_g <beg_g@09dcff7a-b715-0410-9601-b79a96267cd0>2009-10-27 09:50:35 +0000
committerbeg_g <beg_g@09dcff7a-b715-0410-9601-b79a96267cd0>2009-10-27 09:50:35 +0000
commitf34f0ec5187ab8d0d6d67afc4be791cefc0ad93d (patch)
tree6e4ca66a9e493e94a8cd9da0521373e6508e6bea
parent431b8771bce2f011e570f32c6d21642394e356a2 (diff)
Modified the VoIP plugin to support the cases where Skinny CallInfo is sent without corresponding StartMediaTransmission or OpenReceiveChannelAck messages.
git-svn-id: https://oreka.svn.sourceforge.net/svnroot/oreka/trunk@650 09dcff7a-b715-0410-9601-b79a96267cd0
-rw-r--r--orkaudio/audiocaptureplugins/voip/RtpSession.cpp130
-rw-r--r--orkaudio/audiocaptureplugins/voip/RtpSession.h6
2 files changed, 130 insertions, 6 deletions
diff --git a/orkaudio/audiocaptureplugins/voip/RtpSession.cpp b/orkaudio/audiocaptureplugins/voip/RtpSession.cpp
index 4e2303c..bf19956 100644
--- a/orkaudio/audiocaptureplugins/voip/RtpSession.cpp
+++ b/orkaudio/audiocaptureplugins/voip/RtpSession.cpp
@@ -88,6 +88,11 @@ void RtpSession::Stop()
}
}
+bool RtpSession::Stopped()
+{
+ return m_stopped;
+}
+
void RtpSession::ReportRtcpSrcDescription(RtcpSrcDescriptionPacketInfoRef& rtcpInfo)
{
if(!m_rtcpLocalParty)
@@ -1664,19 +1669,20 @@ void RtpSessions::ReportSipBye(SipByeInfoRef& bye)
void RtpSessions::UpdateEndpointWithCallInfo(SkCallInfoStruct* callInfo, IpHeaderStruct* ipHeader)
{
CStdString extension;
+ CStdString callId = GenerateSkinnyCallId(ipHeader->ip_dest, callInfo->callId);
switch(callInfo->callType)
{
case SKINNY_CALL_TYPE_INBOUND:
{
extension = callInfo->calledParty;
- SetEndpointExtension(extension, &ipHeader->ip_dest);
+ SetEndpointExtension(extension, &ipHeader->ip_dest, callId);
break;
}
case SKINNY_CALL_TYPE_OUTBOUND:
{
extension = callInfo->callingParty;
- SetEndpointExtension(extension, &ipHeader->ip_dest);
+ SetEndpointExtension(extension, &ipHeader->ip_dest, callId);
break;
}
}
@@ -1730,6 +1736,72 @@ void RtpSessions::UpdateSessionWithCallInfo(SkCallInfoStruct* callInfo, RtpSessi
}
}
+bool RtpSessions::TrySkinnySession(RtpPacketInfoRef& rtpPacket, EndpointInfoRef& endpoint)
+{
+ std::map<unsigned int, EndpointInfoRef>::iterator pair;
+ std::map<CStdString, RtpSessionRef>::iterator sessionpair;
+ RtpSessionRef session;
+ bool srcmatch = false;
+ CStdString logMsg;
+
+ pair = m_endpoints.find((unsigned int)(rtpPacket->m_sourceIp.s_addr));
+ if(pair != m_endpoints.end())
+ {
+ endpoint = pair->second;
+ srcmatch = true;
+ }
+ else
+ {
+ pair = m_endpoints.find((unsigned int)(rtpPacket->m_destIp.s_addr));
+ if(pair == m_endpoints.end())
+ {
+ return false;
+ }
+
+ endpoint = pair->second;
+ }
+
+ if(!(endpoint->m_latestCallId).size())
+ {
+ return false;
+ }
+
+ sessionpair = m_byCallId.find(endpoint->m_latestCallId);
+ if(sessionpair == m_byCallId.end())
+ {
+ return false;
+ }
+
+ session = sessionpair->second;
+ if(session->Stopped())
+ {
+ return false;
+ }
+
+ char szEndPointIp[16];
+ char szRtpSrcIp[16];
+ char szRtpDstIp[16];
+
+ ACE_OS::inet_ntop(AF_INET, (void*)&rtpPacket->m_sourceIp, szRtpSrcIp, sizeof(szRtpSrcIp));
+ ACE_OS::inet_ntop(AF_INET, (void*)&rtpPacket->m_destIp, szRtpDstIp, sizeof(szRtpDstIp));
+
+ if(srcmatch == true)
+ {
+ SetMediaAddress(session, rtpPacket->m_sourceIp, rtpPacket->m_sourcePort);
+ ACE_OS::inet_ntop(AF_INET, (void*)&rtpPacket->m_sourceIp, szEndPointIp, sizeof(szEndPointIp));
+ }
+ else
+ {
+ SetMediaAddress(session, rtpPacket->m_destIp, rtpPacket->m_destPort);
+ ACE_OS::inet_ntop(AF_INET, (void*)&rtpPacket->m_destIp, szEndPointIp, sizeof(szEndPointIp));
+ }
+
+ logMsg.Format("[%s] RTP stream detected on endpoint:%s extension:%s RTP:%s,%d %s,%d callid:%s", session->m_trackingId, szEndPointIp, endpoint->m_extension, szRtpSrcIp, rtpPacket->m_sourcePort, szRtpDstIp, rtpPacket->m_destPort, endpoint->m_latestCallId);
+ LOG4CXX_INFO(m_log, logMsg);
+
+ return true;
+}
+
void RtpSessions::ReportSkinnyCallInfo(SkCallInfoStruct* callInfo, IpHeaderStruct* ipHeader)
{
CStdString callId = GenerateSkinnyCallId(ipHeader->ip_dest, callInfo->callId);
@@ -2315,7 +2387,7 @@ void RtpSessions::ReportSkinnyStopMediaTransmission(SkStopMediaTransmissionStruc
}
}
-void RtpSessions::SetEndpointExtension(CStdString& extension, struct in_addr* endpointIp)
+void RtpSessions::SetEndpointExtension(CStdString& extension, struct in_addr* endpointIp, CStdString& callId)
{
std::map<unsigned int, EndpointInfoRef>::iterator pair;
EndpointInfoRef endpoint;
@@ -2326,12 +2398,21 @@ void RtpSessions::SetEndpointExtension(CStdString& extension, struct in_addr* en
// Update the existing endpoint info
endpoint = pair->second;
endpoint->m_extension = extension;
+ if(callId.size())
+ {
+ endpoint->m_latestCallId = callId;
+ }
}
else
{
// Create endpoint info for the new endpoint
endpoint.reset(new EndpointInfo());
endpoint->m_extension = extension;
+ ACE_OS::memcpy(&endpoint->m_ip, endpointIp, sizeof(endpoint->m_ip));
+ if(callId.size())
+ {
+ endpoint->m_latestCallId = callId;
+ }
m_endpoints.insert(std::make_pair((unsigned int)(endpointIp->s_addr), endpoint));
}
if(endpoint.get())
@@ -2340,19 +2421,21 @@ void RtpSessions::SetEndpointExtension(CStdString& extension, struct in_addr* en
char szEndpointIp[16];
ACE_OS::inet_ntop(AF_INET, (void*)endpointIp, szEndpointIp, sizeof(szEndpointIp));
- logMsg.Format("Extension:%s is on endpoint:%s", endpoint->m_extension, szEndpointIp);
+ logMsg.Format("Extension:%s callId:%s is on endpoint:%s", endpoint->m_extension, endpoint->m_latestCallId, szEndpointIp);
LOG4CXX_INFO(m_log, logMsg);
}
}
void RtpSessions::ReportSkinnyLineStat(SkLineStatStruct* lineStat, IpHeaderStruct* ipHeader)
{
+ CStdString callId = "";
+
if(strlen(lineStat->lineDirNumber) > 1)
{
CStdString extension;
extension = lineStat->lineDirNumber;
- SetEndpointExtension(extension, &ipHeader->ip_dest);
+ SetEndpointExtension(extension, &ipHeader->ip_dest, callId);
}
}
@@ -2651,6 +2734,14 @@ void RtpSessions::ReportRtpPacket(RtpPacketInfoRef& rtpPacket)
}
else if((numSessionsFound == 0) && (CONFIG.m_lookBackRecording == true))
{
+ EndpointInfoRef endpoint;
+
+ // Check if this is a Skinny session
+ if(TrySkinnySession(rtpPacket, endpoint) == true)
+ {
+ return;
+ }
+
// create new Raw RTP session and insert into IP+Port map
CStdString trackingId = m_alphaCounter.GetNext();
RtpSessionRef session(new RtpSession(trackingId));
@@ -2688,6 +2779,35 @@ void RtpSessions::ReportRtpPacket(RtpPacketInfoRef& rtpPacket)
LOG4CXX_DEBUG(m_log, CStdString("ByIpAndPort: ") + numSessions);
LOG4CXX_INFO(m_log, "[" + trackingId + "] created by RTP packet");
+
+ if(endpoint.get())
+ {
+ // Skinny endpoint was got but no RTP session or existing
+ // RTP session is already stopped
+ char szEndpointIp[16];
+ char szRtpSrcIp[16];
+ char szRtpDstIp[16];
+ CStdString logMsg;
+
+ ACE_OS::inet_ntop(AF_INET, (void*)&endpoint->m_ip, szEndpointIp, sizeof(szEndpointIp));
+ ACE_OS::inet_ntop(AF_INET, (void*)&rtpPacket->m_sourceIp, szRtpSrcIp, sizeof(szRtpSrcIp));
+ ACE_OS::inet_ntop(AF_INET, (void*)&rtpPacket->m_destIp, szRtpDstIp, sizeof(szRtpDstIp));
+
+ session->m_localParty = endpoint->m_extension;
+ if(endpoint->m_ip.s_addr == rtpPacket->m_sourceIp.s_addr)
+ {
+ session->m_remoteParty = szRtpDstIp;
+ }
+ else
+ {
+ session->m_remoteParty = szRtpSrcIp;
+ }
+
+ logMsg.Format("[%s] RTP stream detected on endpoint:%s extension:%s RTP:%s,%d %s,%d", session->m_trackingId, szEndpointIp, endpoint->m_extension, szRtpSrcIp, rtpPacket->m_sourcePort, szRtpDstIp, rtpPacket->m_destPort);
+ LOG4CXX_INFO(m_log, logMsg);
+
+ return;
+ }
}
}
diff --git a/orkaudio/audiocaptureplugins/voip/RtpSession.h b/orkaudio/audiocaptureplugins/voip/RtpSession.h
index ec14d1e..2dd7f15 100644
--- a/orkaudio/audiocaptureplugins/voip/RtpSession.h
+++ b/orkaudio/audiocaptureplugins/voip/RtpSession.h
@@ -154,6 +154,8 @@ class EndpointInfo
{
public:
CStdString m_extension;
+ CStdString m_latestCallId;
+ struct in_addr m_ip;
};
typedef boost::shared_ptr<EndpointInfo> EndpointInfoRef;
@@ -186,6 +188,7 @@ public:
void ReportSkinnyCallInfo(SkCallInfoStruct*, IpHeaderStruct* ipHeader);
CStdString GetOrkUid();
void MarkAsOnDemand();
+ bool Stopped();
CStdString m_capturePort;
CStdString m_trackingId;
@@ -285,7 +288,7 @@ public:
void ReportSkinnyStartMediaTransmission(SkStartMediaTransmissionStruct*, IpHeaderStruct* ipHeader);
void ReportSkinnyStopMediaTransmission(SkStopMediaTransmissionStruct*, IpHeaderStruct* ipHeader);
void ReportSkinnyOpenReceiveChannelAck(SkOpenReceiveChannelAckStruct*);
- void SetEndpointExtension(CStdString& extension, struct in_addr* endpointIp);
+ void SetEndpointExtension(CStdString& extension, struct in_addr* endpointIp, CStdString& callId);
void ReportSkinnyLineStat(SkLineStatStruct*, IpHeaderStruct* ipHeader);
void ReportSkinnySoftKeyHold(SkSoftKeyEventMessageStruct* skEvent, IpHeaderStruct* ipHeader);
void ReportSkinnySoftKeyResume(SkSoftKeyEventMessageStruct* skEvent, IpHeaderStruct* ipHeader);
@@ -322,6 +325,7 @@ private:
CStdString GenerateSkinnyCallId(struct in_addr endpointIp, unsigned int callId);
void UpdateEndpointWithCallInfo(SkCallInfoStruct* callInfo, IpHeaderStruct* ipHeader);
void UpdateSessionWithCallInfo(SkCallInfoStruct*, RtpSessionRef&);
+ bool TrySkinnySession(RtpPacketInfoRef& rtpPacket, EndpointInfoRef&);
std::map<CStdString, RtpSessionRef> m_byIpAndPort;
std::map<CStdString, RtpSessionRef> m_byCallId;