00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00037 #ifndef RTCPRRPACKET_H
00038
00039 #define RTCPRRPACKET_H
00040
00041 #include "rtpconfig.h"
00042 #include "rtcppacket.h"
00043 #include "rtpstructs.h"
00044 #if ! (defined(WIN32) || defined(_WIN32_WCE))
00045 #include <netinet/in.h>
00046 #endif // WIN32
00047
00048 class RTCPCompoundPacket;
00049
00051 class RTCPRRPacket : public RTCPPacket
00052 {
00053 public:
00059 RTCPRRPacket(uint8_t *data,size_t datalen);
00060 ~RTCPRRPacket() { }
00061
00063 uint32_t GetSenderSSRC() const;
00064
00066 int GetReceptionReportCount() const;
00067
00072 uint32_t GetSSRC(int index) const;
00073
00078 uint8_t GetFractionLost(int index) const;
00079
00084 int32_t GetLostPacketCount(int index) const;
00085
00090 uint32_t GetExtendedHighestSequenceNumber(int index) const;
00091
00096 uint32_t GetJitter(int index) const;
00097
00102 uint32_t GetLSR(int index) const;
00103
00108 uint32_t GetDLSR(int index) const;
00109
00110
00111 #ifdef RTPDEBUG
00112 void Dump();
00113 #endif // RTPDEBUG
00114 private:
00115 RTCPReceiverReport *GotoReport(int index) const;
00116 };
00117
00118 inline uint32_t RTCPRRPacket::GetSenderSSRC() const
00119 {
00120 if (!knownformat)
00121 return 0;
00122
00123 uint32_t *ssrcptr = (uint32_t *)(data+sizeof(RTCPCommonHeader));
00124 return ntohl(*ssrcptr);
00125 }
00126 inline int RTCPRRPacket::GetReceptionReportCount() const
00127 {
00128 if (!knownformat)
00129 return 0;
00130 RTCPCommonHeader *hdr = (RTCPCommonHeader *)data;
00131 return ((int)hdr->count);
00132 }
00133
00134 inline RTCPReceiverReport *RTCPRRPacket::GotoReport(int index) const
00135 {
00136 RTCPReceiverReport *r = (RTCPReceiverReport *)(data+sizeof(RTCPCommonHeader)+sizeof(uint32_t)+index*sizeof(RTCPReceiverReport));
00137 return r;
00138 }
00139
00140 inline uint32_t RTCPRRPacket::GetSSRC(int index) const
00141 {
00142 if (!knownformat)
00143 return 0;
00144 RTCPReceiverReport *r = GotoReport(index);
00145 return ntohl(r->ssrc);
00146 }
00147
00148 inline uint8_t RTCPRRPacket::GetFractionLost(int index) const
00149 {
00150 if (!knownformat)
00151 return 0;
00152 RTCPReceiverReport *r = GotoReport(index);
00153 return r->fractionlost;
00154 }
00155
00156 inline int32_t RTCPRRPacket::GetLostPacketCount(int index) const
00157 {
00158 if (!knownformat)
00159 return 0;
00160 RTCPReceiverReport *r = GotoReport(index);
00161 uint32_t count = ((uint32_t)r->packetslost[2])|(((uint32_t)r->packetslost[1])<<8)|(((uint32_t)r->packetslost[0])<<16);
00162 if ((count&0x00800000) != 0)
00163 count |= 0xFF000000;
00164 int32_t *count2 = (int32_t *)(&count);
00165 return (*count2);
00166 }
00167
00168 inline uint32_t RTCPRRPacket::GetExtendedHighestSequenceNumber(int index) const
00169 {
00170 if (!knownformat)
00171 return 0;
00172 RTCPReceiverReport *r = GotoReport(index);
00173 return ntohl(r->exthighseqnr);
00174 }
00175
00176 inline uint32_t RTCPRRPacket::GetJitter(int index) const
00177 {
00178 if (!knownformat)
00179 return 0;
00180 RTCPReceiverReport *r = GotoReport(index);
00181 return ntohl(r->jitter);
00182 }
00183
00184 inline uint32_t RTCPRRPacket::GetLSR(int index) const
00185 {
00186 if (!knownformat)
00187 return 0;
00188 RTCPReceiverReport *r = GotoReport(index);
00189 return ntohl(r->lsr);
00190 }
00191
00192 inline uint32_t RTCPRRPacket::GetDLSR(int index) const
00193 {
00194 if (!knownformat)
00195 return 0;
00196 RTCPReceiverReport *r = GotoReport(index);
00197 return ntohl(r->dlsr);
00198 }
00199
00200 #endif // RTCPRRPACKET_H
00201