📄 rtpsourcedata.h
字号:
/* This file is a part of JRTPLIB Copyright (c) 1999-2007 Jori Liesenborgs Contact: jori.liesenborgs@gmail.com This library was developed at the "Expertisecentrum Digitale Media" (http://www.edm.uhasselt.be), a research center of the Hasselt University (http://www.uhasselt.be). The library is based upon work done for my thesis at the School for Knowledge Technology (Belgium/The Netherlands). Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*//** * \file rtpsourcedata.h */#ifndef RTPSOURCEDATA_H#define RTPSOURCEDATA_H#include "rtpconfig.h"#include "rtptimeutilities.h"#include "rtppacket.h"#include "rtcpsdesinfo.h"#include "rtptypes.h"#include "rtpsources.h"#include "rtpmemoryobject.h"#include <list>class RTPAddress;class RTCPSenderReportInfo{public: RTCPSenderReportInfo():ntptimestamp(0,0),receivetime(0,0) { hasinfo = false; rtptimestamp = 0; packetcount = 0; bytecount = 0; } void Set(const RTPNTPTime &ntptime,uint32_t rtptime,uint32_t pcount, uint32_t bcount,const RTPTime &rcvtime) { ntptimestamp = ntptime; rtptimestamp = rtptime; packetcount = pcount; bytecount = bcount; receivetime = rcvtime; hasinfo = true; } bool HasInfo() const { return hasinfo; } RTPNTPTime GetNTPTimestamp() const { return ntptimestamp; } uint32_t GetRTPTimestamp() const { return rtptimestamp; } uint32_t GetPacketCount() const { return packetcount; } uint32_t GetByteCount() const { return bytecount; } RTPTime GetReceiveTime() const { return receivetime; }private: bool hasinfo; RTPNTPTime ntptimestamp; uint32_t rtptimestamp; uint32_t packetcount; uint32_t bytecount; RTPTime receivetime;};class RTCPReceiverReportInfo{public: RTCPReceiverReportInfo():receivetime(0,0) { hasinfo = false; fractionlost = 0; packetslost = 0; exthighseqnr = 0; jitter = 0; lsr = 0; dlsr = 0; } void Set(uint8_t fraclost,int32_t plost,uint32_t exthigh, uint32_t jit,uint32_t l,uint32_t dl,const RTPTime &rcvtime) { fractionlost = ((double)fraclost)/256.0; packetslost = plost; exthighseqnr = exthigh; jitter = jit; lsr = l; dlsr = dl; receivetime = rcvtime; hasinfo = true; } bool HasInfo() const { return hasinfo; } double GetFractionLost() const { return fractionlost; } int32_t GetPacketsLost() const { return packetslost; } uint32_t GetExtendedHighestSequenceNumber() const { return exthighseqnr; } uint32_t GetJitter() const { return jitter; } uint32_t GetLastSRTimestamp() const { return lsr; } uint32_t GetDelaySinceLastSR() const { return dlsr; } RTPTime GetReceiveTime() const { return receivetime; }private: bool hasinfo; double fractionlost; int32_t packetslost; uint32_t exthighseqnr; uint32_t jitter; uint32_t lsr; uint32_t dlsr; RTPTime receivetime;};class RTPSourceStats{public: RTPSourceStats(); void ProcessPacket(RTPPacket *pack,const RTPTime &receivetime,double tsunit,bool ownpacket,bool *accept,bool applyprobation,bool *onprobation); bool HasSentData() const { return sentdata; } uint32_t GetNumPacketsReceived() const { return packetsreceived; } uint32_t GetBaseSequenceNumber() const { return baseseqnr; } uint32_t GetExtendedHighestSequenceNumber() const { return exthighseqnr; } uint32_t GetJitter() const { return jitter; } int32_t GetNumPacketsReceivedInInterval() const { return numnewpackets; } uint32_t GetSavedExtendedSequenceNumber() const { return savedextseqnr; } void StartNewInterval() { numnewpackets = 0; savedextseqnr = exthighseqnr; } void SetLastMessageTime(const RTPTime &t) { lastmsgtime = t; } RTPTime GetLastMessageTime() const { return lastmsgtime; } void SetLastRTPPacketTime(const RTPTime &t) { lastrtptime = t; } RTPTime GetLastRTPPacketTime() const { return lastrtptime; } void SetLastNoteTime(const RTPTime &t) { lastnotetime = t; } RTPTime GetLastNoteTime() const { return lastnotetime; }private: bool sentdata; uint32_t packetsreceived; uint32_t numcycles; // shifted left 16 bits uint32_t baseseqnr; uint32_t exthighseqnr,prevexthighseqnr; uint32_t jitter,prevtimestamp; double djitter; RTPTime prevpacktime; RTPTime lastmsgtime; RTPTime lastrtptime; RTPTime lastnotetime; uint32_t numnewpackets; uint32_t savedextseqnr;#ifdef RTP_SUPPORT_PROBATION uint16_t prevseqnr; int probation; RTPSources::ProbationType probationtype;#endif // RTP_SUPPORT_PROBATION}; inline RTPSourceStats::RTPSourceStats():prevpacktime(0,0),lastmsgtime(0,0),lastrtptime(0,0),lastnotetime(0,0){ sentdata = false; packetsreceived = 0; baseseqnr = 0; exthighseqnr = 0; prevexthighseqnr = 0; jitter = 0; numcycles = 0; numnewpackets = 0; prevtimestamp = 0; djitter = 0; savedextseqnr = 0;#ifdef RTP_SUPPORT_PROBATION probation = 0; prevseqnr = 0; #endif // RTP_SUPPORT_PROBATION}/** Describes an entry in the RTPSources source table. */class RTPSourceData : public RTPMemoryObject{protected: RTPSourceData(uint32_t ssrc, RTPMemoryManager *mgr = 0); virtual ~RTPSourceData();public: /** Extracts the first packet of this participants RTP packet queue. */ RTPPacket *GetNextPacket(); /** Clears the participant's RTP packet list. */ void FlushPackets(); /** Returns \c true if there are RTP packets which can be extracted. */ bool HasData() const { if (!validated) return false; return packetlist.empty()?false:true; } /** Returns the SSRC identifier for this member. */ uint32_t GetSSRC() const { return ssrc; } /** Returns \c true if the participant was added using the RTPSources member function CreateOwnSSRC and * returns \c false otherwise. */ bool IsOwnSSRC() const { return ownssrc; } /** Returns \c true if the source identifier is actually a CSRC from an RTP packet. */ bool IsCSRC() const { return iscsrc; } /** Returns \c true if this member is marked as a sender and \c false if not. */ bool IsSender() const { return issender; } /** Returns \c true if the participant is validated, which is the case if a number of * consecutive RTP packets have been received or if a CNAME item has been received for * this participant. */ bool IsValidated() const { return validated; } /** Returns \c true if the source was validated and had not yet sent a BYE packet. */ bool IsActive() const { if (!validated) return false; if (receivedbye) return false; return true; } /** This function is used by the RTCPPacketBuilder class to mark whether this participant's * information has been processed in a report block or not. */ void SetProcessedInRTCP(bool v) { processedinrtcp = v; } /** This function is used by the RTCPPacketBuilder class and returns whether this participant * has been processed in a report block or not. */ bool IsProcessedInRTCP() const { return processedinrtcp; } /** Returns \c true if the address from which this participant's RTP packets originate has * already been set. */ bool IsRTPAddressSet() const { return isrtpaddrset; } /** Returns \c true if the address from which this participant's RTCP packets originate has * already been set. */ bool IsRTCPAddressSet() const { return isrtcpaddrset; } /** Returns the address from which this participant's RTP packets originate. * Returns the address from which this participant's RTP packets originate. If the address has * been set and the returned value is NULL, this indicates that it originated from the local * participant. */ const RTPAddress *GetRTPDataAddress() const { return rtpaddr; } /** Returns the address from which this participant's RTCP packets originate. * Returns the address from which this participant's RTCP packets originate. If the address has * been set and the returned value is NULL, this indicates that it originated from the local * participant. */ const RTPAddress *GetRTCPDataAddress() const { return rtcpaddr; } /** Returns \c true if we received a BYE message for this participant and \c false otherwise. */ bool ReceivedBYE() const { return receivedbye; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -