[Opalvoip-svn] SF.net SVN: opalvoip:[34770] opal/trunk
Brought to you by:
csoutheren,
rjongbloed
From: <rjo...@us...> - 2016-04-06 13:34:35
|
Revision: 34770 http://sourceforge.net/p/opalvoip/code/34770 Author: rjongbloed Date: 2016-04-06 13:34:33 +0000 (Wed, 06 Apr 2016) Log Message: ----------- Added time that RTP packet physically was read into the system. Also collected various items of meta data around the RTP packet into a separate struct for ease of copying. Especially as we add more in the future. Modified Paths: -------------- opal/trunk/include/rtp/h235_session.h opal/trunk/include/rtp/rtp.h opal/trunk/include/rtp/rtp_session.h opal/trunk/src/rtp/h235_session.cxx opal/trunk/src/rtp/rtp.cxx opal/trunk/src/rtp/rtp_session.cxx Modified: opal/trunk/include/rtp/h235_session.h =================================================================== --- opal/trunk/include/rtp/h235_session.h 2016-04-05 20:20:41 UTC (rev 34769) +++ opal/trunk/include/rtp/h235_session.h 2016-04-06 13:34:33 UTC (rev 34770) @@ -124,7 +124,7 @@ virtual SendReceiveStatus OnSendData(RTP_DataFrame & frame, RewriteMode rewrite); #if !H235_6_CODED_TO_CORRECT_SPECIFICATION - virtual SendReceiveStatus OnReceiveData(RTP_DataFrame & frame, PINDEX pduSize); + virtual SendReceiveStatus OnPreReceiveData(RTP_DataFrame & frame); #endif virtual SendReceiveStatus OnReceiveData(RTP_DataFrame & frame); Modified: opal/trunk/include/rtp/rtp.h =================================================================== --- opal/trunk/include/rtp/rtp.h 2016-04-05 20:20:41 UTC (rev 34769) +++ opal/trunk/include/rtp/rtp.h 2016-04-06 13:34:33 UTC (rev 34770) @@ -504,6 +504,7 @@ public: RTP_DataFrame(PINDEX payloadSize = 0, PINDEX bufferSize = 0); RTP_DataFrame(const BYTE * data, PINDEX len, bool dynamic = true); + RTP_DataFrame(const PBYTEArray data); enum { ProtocolVersion = 2, @@ -651,36 +652,50 @@ // Get the packet size including headers, padding etc. PINDEX GetPacketSize() const; + struct MetaData + { + MetaData(); + + PTime m_absoluteTime; // Wall clock time packet was sent, as calculated via RTCP and timestamp + PTime m_networkTime; // Wall clock time packet physically read from socket + unsigned m_discontinuity; + PString m_lipSyncId; + }; + + /**Get meta data for RTP packet. + */ + const MetaData & GetMetaData() const { return m_metaData; } + /**Get absolute (wall clock) time of packet, if known. */ - PTime GetAbsoluteTime() const { return m_absoluteTime; } + PTime GetAbsoluteTime() const { return m_metaData.m_absoluteTime; } /**Set absolute (wall clock) time of packet. */ - void SetAbsoluteTime() { m_absoluteTime.SetCurrentTime(); } - void SetAbsoluteTime(const PTime & t) { m_absoluteTime = t; } + void SetAbsoluteTime() { m_metaData.m_absoluteTime.SetCurrentTime(); } + void SetAbsoluteTime(const PTime & t) { m_metaData.m_absoluteTime = t; } /** Get sequence number discontinuity. If non-zero this indicates the number of packets detected as missing before this packet. */ - unsigned GetDiscontinuity() const { return m_discontinuity; } + unsigned GetDiscontinuity() const { return m_metaData.m_discontinuity; } - void SetDiscontinuity(unsigned lost) { m_discontinuity = lost; } + void SetDiscontinuity(unsigned lost) { m_metaData.m_discontinuity = lost; } /** Get the identifier that links audio and video streams for "lip synch" purposes. */ - const PString & GetLipSyncId() const { return m_lipSyncId; } + const PString & GetLipSyncId() const { return m_metaData.m_lipSyncId; } /** Set the identifier that links audio and video streams for "lip synch" purposes. */ - void SetLipSyncId(const PString & id) { m_lipSyncId = id; } + void SetLipSyncId(const PString & id) { m_metaData.m_lipSyncId = id; } // backward compatibility - P_DEPRECATED const PString & GetBundleId() const { return m_lipSyncId; } - P_DEPRECATED void SetBundleId(const PString & id) { m_lipSyncId = id; } + P_DEPRECATED const PString & GetBundleId() const { return m_metaData.m_lipSyncId; } + P_DEPRECATED void SetBundleId(const PString & id) { m_metaData.m_lipSyncId = id; } protected: bool AdjustHeaderSize(PINDEX newSize); @@ -688,9 +703,7 @@ PINDEX m_headerSize; PINDEX m_payloadSize; PINDEX m_paddingSize; - PTime m_absoluteTime; - unsigned m_discontinuity; - PString m_lipSyncId; + MetaData m_metaData; #if PTRACING friend ostream & operator<<(ostream & o, PayloadTypes t); Modified: opal/trunk/include/rtp/rtp_session.h =================================================================== --- opal/trunk/include/rtp/rtp_session.h 2016-04-05 20:20:41 UTC (rev 34769) +++ opal/trunk/include/rtp/rtp_session.h 2016-04-06 13:34:33 UTC (rev 34770) @@ -214,7 +214,7 @@ virtual SendReceiveStatus OnSendData(RTP_DataFrame & frame, RewriteMode rewrite); virtual SendReceiveStatus OnSendControl(RTP_ControlFrame & frame); - virtual SendReceiveStatus OnReceiveData(RTP_DataFrame & frame, PINDEX pduSize); + virtual SendReceiveStatus OnPreReceiveData(RTP_DataFrame & frame); virtual SendReceiveStatus OnReceiveData(RTP_DataFrame & frame); virtual SendReceiveStatus OnReceiveControl(RTP_ControlFrame & frame); virtual SendReceiveStatus OnOutOfOrderPacket(RTP_DataFrame & frame); @@ -813,8 +813,8 @@ P_REMOVE_VIRTUAL(SendReceiveStatus,OnReadTimeout(RTP_DataFrame&),e_AbortTransport); P_REMOVE_VIRTUAL(SendReceiveStatus,InternalReadData(RTP_DataFrame &),e_AbortTransport); P_REMOVE_VIRTUAL(SendReceiveStatus,SendReport(bool),e_AbortTransport); + P_REMOVE_VIRTUAL(SendReceiveStatus,OnReceiveData(RTP_DataFrame&, PINDEX),e_AbortTransport); - friend class RTCP_XR_Metrics; }; Modified: opal/trunk/src/rtp/h235_session.cxx =================================================================== --- opal/trunk/src/rtp/h235_session.cxx 2016-04-05 20:20:41 UTC (rev 34769) +++ opal/trunk/src/rtp/h235_session.cxx 2016-04-06 13:34:33 UTC (rev 34770) @@ -290,13 +290,13 @@ #if !H235_6_CODED_TO_CORRECT_SPECIFICATION -OpalRTPSession::SendReceiveStatus H2356_Session::OnReceiveData(RTP_DataFrame & frame, PINDEX pduSize) +OpalRTPSession::SendReceiveStatus H2356_Session::OnPreReceiveData(RTP_DataFrame & frame) { // Allow for broken implementations that set padding bit but do not set the padding length! bool padding = frame.GetPadding(); frame.SetPadding(false); - SendReceiveStatus status = OpalRTPSession::OnReceiveData(frame, pduSize); + SendReceiveStatus status = OpalRTPSession::OnPreReceiveData(frame); frame.SetPadding(padding); Modified: opal/trunk/src/rtp/rtp.cxx =================================================================== --- opal/trunk/src/rtp/rtp.cxx 2016-04-05 20:20:41 UTC (rev 34769) +++ opal/trunk/src/rtp/rtp.cxx 2016-04-06 13:34:33 UTC (rev 34770) @@ -55,13 +55,19 @@ ///////////////////////////////////////////////////////////////////////////// +RTP_DataFrame::MetaData::MetaData() + : m_absoluteTime(0) + , m_networkTime(0) + , m_discontinuity(0) +{ +} + + RTP_DataFrame::RTP_DataFrame(PINDEX payloadSz, PINDEX bufferSz) : PBYTEArray(max(bufferSz, MinHeaderSize+payloadSz)) , m_headerSize(MinHeaderSize) , m_payloadSize(payloadSz) , m_paddingSize(0) - , m_absoluteTime(0) - , m_discontinuity(0) { theArray[0] = '\x80'; // Default to version 2 theArray[1] = '\x7f'; // Default to MaxPayloadType @@ -73,16 +79,29 @@ , m_headerSize(MinHeaderSize) , m_payloadSize(0) , m_paddingSize(0) - , m_absoluteTime(0) - , m_discontinuity(0) { SetPacketSize(len); } +RTP_DataFrame::RTP_DataFrame(const PBYTEArray data) + : PBYTEArray(data) + , m_headerSize(MinHeaderSize) + , m_payloadSize(0) + , m_paddingSize(0) +{ + if (SetPacketSize(data.GetSize())) + m_metaData.m_networkTime.SetCurrentTime(); + else { + SetSize(MinHeaderSize); + theArray[0] = 0; // Make illegal RTP frame + } +} + + bool RTP_DataFrame::SetPacketSize(PINDEX sz) { - m_discontinuity = 0; + m_metaData.m_discontinuity = 0; if (sz < RTP_DataFrame::MinHeaderSize) { PTRACE(2, "RTP\tInvalid RTP packet, " @@ -193,9 +212,7 @@ { if (AdjustHeaderSize(other.m_headerSize)) memcpy(theArray, other.theArray, m_headerSize); - SetDiscontinuity(other.GetDiscontinuity()); - SetAbsoluteTime(other.GetAbsoluteTime()); - SetLipSyncId(other.GetLipSyncId()); + m_metaData = other.m_metaData; } @@ -207,9 +224,7 @@ m_headerSize = other.m_headerSize; m_payloadSize = other.m_payloadSize; m_paddingSize = other.m_paddingSize; - SetDiscontinuity(other.GetDiscontinuity()); - SetAbsoluteTime(other.GetAbsoluteTime()); - SetLipSyncId(other.GetLipSyncId()); + m_metaData = other.m_metaData; } } Modified: opal/trunk/src/rtp/rtp_session.cxx =================================================================== --- opal/trunk/src/rtp/rtp_session.cxx 2016-04-05 20:20:41 UTC (rev 34769) +++ opal/trunk/src/rtp/rtp_session.cxx 2016-04-06 13:34:33 UTC (rev 34770) @@ -1207,16 +1207,13 @@ } -OpalRTPSession::SendReceiveStatus OpalRTPSession::OnReceiveData(RTP_DataFrame & frame, PINDEX pduSize) +OpalRTPSession::SendReceiveStatus OpalRTPSession::OnPreReceiveData(RTP_DataFrame & frame) { for (SyncSourceMap::iterator it = m_SSRC.begin(); it != m_SSRC.end(); ++it) { if (!it->second->HandlePendingFrames()) return e_AbortTransport; } - if (pduSize < RTP_DataFrame::MinHeaderSize) - return e_IgnorePacket; // Non fatal error, just ignore - // Check that the PDU is the right version if (frame.GetVersion() != RTP_DataFrame::ProtocolVersion) return e_IgnorePacket; // Non fatal error, just ignore @@ -1232,9 +1229,6 @@ return e_IgnorePacket; // Non fatal error, just ignore } - if (!frame.SetPacketSize(pduSize)) - return e_IgnorePacket; // Non fatal error, just ignore - SyncSource * receiver = UseSyncSource(frame.GetSyncSource(), e_Receiver, false); if (receiver == NULL) return e_IgnorePacket; @@ -2554,9 +2548,8 @@ CheckMediaFailed(e_Control); } else { - RTP_DataFrame frame; - frame.PBYTEArray::operator=(data); - if (OnReceiveData(frame, data.GetSize()) == e_AbortTransport) + RTP_DataFrame frame(data); + if (OnPreReceiveData(frame) == e_AbortTransport) CheckMediaFailed(e_Data); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |