diff options
author | Henri Herscher <henri@oreka.org> | 2006-08-01 14:31:05 +0000 |
---|---|---|
committer | Henri Herscher <henri@oreka.org> | 2006-08-01 14:31:05 +0000 |
commit | 4d1b7ce6a753132aa2e7a70737c6cfef906d3bce (patch) | |
tree | 79ccdaaee493043377cc441a0e80027431dbfaef /orkaudio/audiocaptureplugins/voip | |
parent | 71001d96e240d03a98a73688060d476dd5f7c875 (diff) |
Applying changeset 0.5 263:
* Redundant RTP packets are now detected and discarded, on the basis of RTP timestamp.
* RTP timestamp corrective delta now unsigned int in case it is bigger than 2^31, also using another boolean variable for sign.
git-svn-id: https://oreka.svn.sourceforge.net/svnroot/oreka/trunk@316 09dcff7a-b715-0410-9601-b79a96267cd0
Diffstat (limited to 'orkaudio/audiocaptureplugins/voip')
-rw-r--r-- | orkaudio/audiocaptureplugins/voip/RtpSession.cpp | 58 | ||||
-rw-r--r-- | orkaudio/audiocaptureplugins/voip/RtpSession.h | 3 |
2 files changed, 43 insertions, 18 deletions
diff --git a/orkaudio/audiocaptureplugins/voip/RtpSession.cpp b/orkaudio/audiocaptureplugins/voip/RtpSession.cpp index ec2dd4e..8cc54d0 100644 --- a/orkaudio/audiocaptureplugins/voip/RtpSession.cpp +++ b/orkaudio/audiocaptureplugins/voip/RtpSession.cpp @@ -286,6 +286,8 @@ bool RtpSession::AddRtpPacket(RtpPacketInfoRef& rtpPacket) { CStdString logMsg; unsigned char channel = 0; + unsigned int correctedRtpTimestamp = rtpPacket->m_timestamp; + if(m_lastRtpPacket.get() == NULL) { @@ -323,6 +325,10 @@ bool RtpSession::AddRtpPacket(RtpPacketInfoRef& rtpPacket) { if((unsigned int)rtpPacket->m_sourceIp.s_addr == (unsigned int)m_lastRtpPacketSide1->m_sourceIp.s_addr) { + if(rtpPacket->m_timestamp == m_lastRtpPacketSide1->m_timestamp) + { + return true; // dismiss duplicate RTP packet + } m_lastRtpPacketSide1 = rtpPacket; channel = 1; } @@ -338,36 +344,54 @@ bool RtpSession::AddRtpPacket(RtpPacketInfoRef& rtpPacket) LOG4CXX_INFO(m_log, logMsg); } } + else + { + if(rtpPacket->m_timestamp == m_lastRtpPacketSide2->m_timestamp) + { + return true; // dismiss duplicate RTP packet + } + } m_lastRtpPacketSide2 = rtpPacket; channel = 2; } } - // Compute the corrective offset + // Compute the corrective delta if(m_rtpTimestampCorrectiveDelta == 0 && m_lastRtpPacketSide2.get() != NULL) { - int timestampOffset = m_lastRtpPacketSide2->m_timestamp - m_lastRtpPacketSide1->m_timestamp; - //if(timestampOffset > 8000 || timestampOffset < -8000) // 1s @ 8KHz - //{ - m_rtpTimestampCorrectiveDelta = timestampOffset; - if(m_log->isInfoEnabled()) - { - CStdString timestampOffsetString = IntToString(timestampOffset); - LOG4CXX_INFO(m_log, m_trackingId + ": " + m_capturePort + ": " + "Applying timestamp corrective delta:" + timestampOffsetString); - } - //} + if(m_lastRtpPacketSide2->m_timestamp > m_lastRtpPacketSide1->m_timestamp) + { + m_rtpTimestampCorrectiveSign = true; + m_rtpTimestampCorrectiveDelta = m_lastRtpPacketSide2->m_timestamp - m_lastRtpPacketSide1->m_timestamp; + } + else + { + m_rtpTimestampCorrectiveSign = false; + m_rtpTimestampCorrectiveDelta = m_lastRtpPacketSide1->m_timestamp - m_lastRtpPacketSide2->m_timestamp; + } + if(m_log->isInfoEnabled()) + { + CStdString timestampOffsetString = IntToString(m_rtpTimestampCorrectiveDelta); + LOG4CXX_INFO(m_log, m_trackingId + ": " + m_capturePort + ": " + "Applying timestamp corrective delta:" + timestampOffsetString); + } } - // apply the corrective offset - unsigned int timestamp = rtpPacket->m_timestamp; - if(m_lastRtpPacketSide2.get() != NULL) + // apply the corrective delta to packets of side 2 + if(channel == 2) { - m_lastRtpPacketSide2->m_timestamp = m_lastRtpPacketSide2->m_timestamp - m_rtpTimestampCorrectiveDelta; + if(m_rtpTimestampCorrectiveSign) + { + correctedRtpTimestamp = rtpPacket->m_timestamp - m_rtpTimestampCorrectiveDelta; + } + else + { + correctedRtpTimestamp = rtpPacket->m_timestamp + m_rtpTimestampCorrectiveDelta; + } } if(m_log->isDebugEnabled()) { CStdString debug; - debug.Format("%s: %s: Add RTP packet ts:%u, corrected ts:%u, arrival:%u, channel:%d", m_trackingId, m_capturePort, timestamp, rtpPacket->m_timestamp, rtpPacket->m_arrivalTimestamp, channel); + debug.Format("%s: %s: Add RTP packet ts:%u, corrected ts:%u, arrival:%u, channel:%d", m_trackingId, m_capturePort, rtpPacket->m_timestamp, correctedRtpTimestamp, rtpPacket->m_arrivalTimestamp, channel); LOG4CXX_DEBUG(m_log, debug); } @@ -398,7 +422,7 @@ bool RtpSession::AddRtpPacket(RtpPacketInfoRef& rtpPacket) AudioChunkDetails details; details.m_arrivalTimestamp = rtpPacket->m_arrivalTimestamp; details.m_numBytes = rtpPacket->m_payloadSize; - details.m_timestamp = rtpPacket->m_timestamp; + details.m_timestamp = correctedRtpTimestamp; details.m_rtpPayloadType = rtpPacket->m_payloadType; details.m_sequenceNumber = rtpPacket->m_seqNum; details.m_channel = channel; diff --git a/orkaudio/audiocaptureplugins/voip/RtpSession.h b/orkaudio/audiocaptureplugins/voip/RtpSession.h index fcb3cb6..1461f8e 100644 --- a/orkaudio/audiocaptureplugins/voip/RtpSession.h +++ b/orkaudio/audiocaptureplugins/voip/RtpSession.h @@ -121,7 +121,8 @@ private: CStdString m_capturePort; bool m_started; bool m_stopped; - int m_rtpTimestampCorrectiveDelta; + unsigned int m_rtpTimestampCorrectiveDelta; + bool m_rtpTimestampCorrectiveSign; }; typedef boost::shared_ptr<RtpSession> RtpSessionRef; |