rtcprrpacket.h

Go to the documentation of this file.
00001 /*
00002 
00003   This file is a part of JRTPLIB
00004   Copyright (c) 1999-2007 Jori Liesenborgs
00005 
00006   Contact: jori.liesenborgs@gmail.com
00007 
00008   This library was developed at the "Expertisecentrum Digitale Media"
00009   (http://www.edm.uhasselt.be), a research center of the Hasselt University
00010   (http://www.uhasselt.be). The library is based upon work done for 
00011   my thesis at the School for Knowledge Technology (Belgium/The Netherlands).
00012 
00013   Permission is hereby granted, free of charge, to any person obtaining a
00014   copy of this software and associated documentation files (the "Software"),
00015   to deal in the Software without restriction, including without limitation
00016   the rights to use, copy, modify, merge, publish, distribute, sublicense,
00017   and/or sell copies of the Software, and to permit persons to whom the
00018   Software is furnished to do so, subject to the following conditions:
00019 
00020   The above copyright notice and this permission notice shall be included
00021   in all copies or substantial portions of the Software.
00022 
00023   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00024   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00025   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
00026   THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00027   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00028   FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
00029   IN THE SOFTWARE.
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) // test for negative number
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 

Generated on Thu Feb 8 16:22:05 2007 for jrtplib by  doxygen 1.5.1