From af279c8ed90de99ee16a0e58d60ed023e4fd14b3 Mon Sep 17 00:00:00 2001 From: Gerald Begumisa Date: Thu, 23 Aug 2007 10:14:57 +0000 Subject: Added on-hold support for SIP sessions git-svn-id: https://oreka.svn.sourceforge.net/svnroot/oreka/trunk@472 09dcff7a-b715-0410-9601-b79a96267cd0 --- orkaudio/audiocaptureplugins/voip/RtpSession.cpp | 49 +++++++++++++++++++++++- orkaudio/audiocaptureplugins/voip/RtpSession.h | 1 + orkaudio/audiocaptureplugins/voip/VoIp.cpp | 5 +++ 3 files changed, 53 insertions(+), 2 deletions(-) (limited to 'orkaudio') diff --git a/orkaudio/audiocaptureplugins/voip/RtpSession.cpp b/orkaudio/audiocaptureplugins/voip/RtpSession.cpp index 19f5fc1..91a483e 100644 --- a/orkaudio/audiocaptureplugins/voip/RtpSession.cpp +++ b/orkaudio/audiocaptureplugins/voip/RtpSession.cpp @@ -509,7 +509,7 @@ bool RtpSession::AddRtpPacket(RtpPacketInfoRef& rtpPacket) // If we are on hold, unmark this if(m_onHold) { - logMsg = "[" + m_trackingId + "] Going off hold due to RTP activity"; + logMsg = "[" + m_trackingId + "] Session going off hold due to RTP activity"; m_onHold = false; } @@ -797,7 +797,29 @@ void RtpSessions::ReportSipInvite(SipInviteInfoRef& invite) if (pair != m_byIpAndPort.end()) { // The session already exists, report the new INVITE + + /* + * If the sendonly attribute is present then our call is + * going on hold. + */ RtpSessionRef session = pair->second; + + if(invite->m_attrSendonly) + { + session->m_onHold = true; + LOG4CXX_INFO(m_log, "[" + session->m_trackingId + "] SIP session going on hold"); + return; + } + else + { + if(session->m_onHold) + { + session->m_onHold = false; + LOG4CXX_INFO(m_log, "[" + session->m_trackingId + "] SIP session going off hold"); + return; + } + } + session->ReportSipInvite(invite); return; } @@ -807,6 +829,28 @@ void RtpSessions::ReportSipInvite(SipInviteInfoRef& invite) // The session already exists RtpSessionRef session = pair->second; + /* + * If the sendonly attribute is present then our call is + * going on hold. + */ + if(invite->m_attrSendonly) + { + session->m_onHold = true; + LOG4CXX_INFO(m_log, "[" + session->m_trackingId + "] SIP session going on hold"); + return; + } + else + { + /* If we're already on hold and sendonly is not present + * then we go off hold */ + if(session->m_onHold) + { + session->m_onHold = false; + LOG4CXX_INFO(m_log, "[" + session->m_trackingId + "] SIP session going off hold"); + return; + } + } + // For now, do not report new INVITEs that have the same SIP call ID but a different media address // those INVITEs are ignored altogether. if(!session->m_ipAndPort.Equals(ipAndPort)) @@ -1662,7 +1706,8 @@ void RtpSessions::StartCapture(CStdString& party) SipInviteInfo::SipInviteInfo() { m_fromRtpIp.s_addr = 0; - m_validated= false; + m_validated = false; + m_attrSendonly = false; } void SipInviteInfo::ToString(CStdString& string) diff --git a/orkaudio/audiocaptureplugins/voip/RtpSession.h b/orkaudio/audiocaptureplugins/voip/RtpSession.h index 74460ef..5475cb9 100644 --- a/orkaudio/audiocaptureplugins/voip/RtpSession.h +++ b/orkaudio/audiocaptureplugins/voip/RtpSession.h @@ -40,6 +40,7 @@ public: CStdString m_to; CStdString m_callId; bool m_validated; // true when an RTP stream has been seen for the INVITE + bool m_attrSendonly; // true if the SDP has a:sendonly std::map m_extractedFields; time_t m_recvTime; diff --git a/orkaudio/audiocaptureplugins/voip/VoIp.cpp b/orkaudio/audiocaptureplugins/voip/VoIp.cpp index 863cb6c..2db26d7 100644 --- a/orkaudio/audiocaptureplugins/voip/VoIp.cpp +++ b/orkaudio/audiocaptureplugins/voip/VoIp.cpp @@ -1384,6 +1384,7 @@ bool TrySipInvite(EthernetHeaderStruct* ethernetHeader, IpHeaderStruct* ipHeader char* localExtensionField = memFindAfter("x-Local-Extension:", (char*)udpPayload, sipEnd); char* audioField = NULL; char* connectionAddressField = NULL; + char* attribSendonly = memFindAfter("a=sendonly", (char*)udpPayload, sipEnd); if(fromField) { @@ -1441,6 +1442,10 @@ bool TrySipInvite(EthernetHeaderStruct* ethernetHeader, IpHeaderStruct* ipHeader { GrabToken(audioField, sipEnd, info->m_fromRtpPort); } + if(attribSendonly) + { + info->m_attrSendonly = true; + } if(connectionAddressField) { CStdString connectionAddress; -- cgit v1.2.3