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 RTCPSRPACKET_H
00038
00039 #define RTCPSRPACKET_H
00040
00041 #include "rtpconfig.h"
00042 #include "rtcppacket.h"
00043 #include "rtptimeutilities.h"
00044 #include "rtpstructs.h"
00045 #if ! (defined(WIN32) || defined(_WIN32_WCE))
00046 #include <netinet/in.h>
00047 #endif // WIN32
00048
00049 class RTCPCompoundPacket;
00050
00052 class RTCPSRPacket : public RTCPPacket
00053 {
00054 public:
00060 RTCPSRPacket(uint8_t *data,size_t datalength);
00061 ~RTCPSRPacket() { }
00062
00064 uint32_t GetSenderSSRC() const;
00065
00067 RTPNTPTime GetNTPTimestamp() const;
00068
00070 uint32_t GetRTPTimestamp() const;
00071
00073 uint32_t GetSenderPacketCount() const;
00074
00076 uint32_t GetSenderOctetCount() const;
00077
00079 int GetReceptionReportCount() const;
00080
00085 uint32_t GetSSRC(int index) const;
00086
00091 uint8_t GetFractionLost(int index) const;
00092
00097 int32_t GetLostPacketCount(int index) const;
00098
00103 uint32_t GetExtendedHighestSequenceNumber(int index) const;
00104
00109 uint32_t GetJitter(int index) const;
00110
00115 uint32_t GetLSR(int index) const;
00116
00121 uint32_t GetDLSR(int index) const;
00122
00123 #ifdef RTPDEBUG
00124 void Dump();
00125 #endif // RTPDEBUG
00126 private:
00127 RTCPReceiverReport *GotoReport(int index) const;
00128 };
00129
00130 inline uint32_t RTCPSRPacket::GetSenderSSRC() const
00131 {
00132 if (!knownformat)
00133 return 0;
00134
00135 uint32_t *ssrcptr = (uint32_t *)(data+sizeof(RTCPCommonHeader));
00136 return ntohl(*ssrcptr);
00137 }
00138
00139 inline RTPNTPTime RTCPSRPacket::GetNTPTimestamp() const
00140 {
00141 if (!knownformat)
00142 return RTPNTPTime(0,0);
00143
00144 RTCPSenderReport *sr = (RTCPSenderReport *)(data+sizeof(RTCPCommonHeader)+sizeof(uint32_t));
00145 return RTPNTPTime(ntohl(sr->ntptime_msw),ntohl(sr->ntptime_lsw));
00146 }
00147
00148 inline uint32_t RTCPSRPacket::GetRTPTimestamp() const
00149 {
00150 if (!knownformat)
00151 return 0;
00152 RTCPSenderReport *sr = (RTCPSenderReport *)(data+sizeof(RTCPCommonHeader)+sizeof(uint32_t));
00153 return ntohl(sr->rtptimestamp);
00154 }
00155
00156 inline uint32_t RTCPSRPacket::GetSenderPacketCount() const
00157 {
00158 if (!knownformat)
00159 return 0;
00160 RTCPSenderReport *sr = (RTCPSenderReport *)(data+sizeof(RTCPCommonHeader)+sizeof(uint32_t));
00161 return ntohl(sr->packetcount);
00162 }
00163
00164 inline uint32_t RTCPSRPacket::GetSenderOctetCount() const
00165 {
00166 if (!knownformat)
00167 return 0;
00168 RTCPSenderReport *sr = (RTCPSenderReport *)(data+sizeof(RTCPCommonHeader)+sizeof(uint32_t));
00169 return ntohl(sr->octetcount);
00170 }
00171
00172 inline int RTCPSRPacket::GetReceptionReportCount() const
00173 {
00174 if (!knownformat)
00175 return 0;
00176 RTCPCommonHeader *hdr = (RTCPCommonHeader *)data;
00177 return ((int)hdr->count);
00178 }
00179
00180 inline RTCPReceiverReport *RTCPSRPacket::GotoReport(int index) const
00181 {
00182 RTCPReceiverReport *r = (RTCPReceiverReport *)(data+sizeof(RTCPCommonHeader)+sizeof(uint32_t)+sizeof(RTCPSenderReport)+index*sizeof(RTCPReceiverReport));
00183 return r;
00184 }
00185
00186 inline uint32_t RTCPSRPacket::GetSSRC(int index) const
00187 {
00188 if (!knownformat)
00189 return 0;
00190 RTCPReceiverReport *r = GotoReport(index);
00191 return ntohl(r->ssrc);
00192 }
00193
00194 inline uint8_t RTCPSRPacket::GetFractionLost(int index) const
00195 {
00196 if (!knownformat)
00197 return 0;
00198 RTCPReceiverReport *r = GotoReport(index);
00199 return r->fractionlost;
00200 }
00201
00202 inline int32_t RTCPSRPacket::GetLostPacketCount(int index) const
00203 {
00204 if (!knownformat)
00205 return 0;
00206 RTCPReceiverReport *r = GotoReport(index);
00207 uint32_t count = ((uint32_t)r->packetslost[2])|(((uint32_t)r->packetslost[1])<<8)|(((uint32_t)r->packetslost[0])<<16);
00208 if ((count&0x00800000) != 0)
00209 count |= 0xFF000000;
00210 int32_t *count2 = (int32_t *)(&count);
00211 return (*count2);
00212 }
00213
00214 inline uint32_t RTCPSRPacket::GetExtendedHighestSequenceNumber(int index) const
00215 {
00216 if (!knownformat)
00217 return 0;
00218 RTCPReceiverReport *r = GotoReport(index);
00219 return ntohl(r->exthighseqnr);
00220 }
00221
00222 inline uint32_t RTCPSRPacket::GetJitter(int index) const
00223 {
00224 if (!knownformat)
00225 return 0;
00226 RTCPReceiverReport *r = GotoReport(index);
00227 return ntohl(r->jitter);
00228 }
00229
00230 inline uint32_t RTCPSRPacket::GetLSR(int index) const
00231 {
00232 if (!knownformat)
00233 return 0;
00234 RTCPReceiverReport *r = GotoReport(index);
00235 return ntohl(r->lsr);
00236 }
00237
00238 inline uint32_t RTCPSRPacket::GetDLSR(int index) const
00239 {
00240 if (!knownformat)
00241 return 0;
00242 RTCPReceiverReport *r = GotoReport(index);
00243 return ntohl(r->dlsr);
00244 }
00245
00246 #endif // RTCPSRPACKET_H
00247