jrtplib  3.6.0
rtcprrpacket.h
Go to the documentation of this file.
1 /*
2 
3  This file is a part of JRTPLIB
4  Copyright (c) 1999-2006 Jori Liesenborgs
5 
6  Contact: jori.liesenborgs@gmail.com
7 
8  This library was developed at the "Expertisecentrum Digitale Media"
9  (http://www.edm.uhasselt.be), a research center of the Hasselt University
10  (http://www.uhasselt.be). The library is based upon work done for
11  my thesis at the School for Knowledge Technology (Belgium/The Netherlands).
12 
13  Permission is hereby granted, free of charge, to any person obtaining a
14  copy of this software and associated documentation files (the "Software"),
15  to deal in the Software without restriction, including without limitation
16  the rights to use, copy, modify, merge, publish, distribute, sublicense,
17  and/or sell copies of the Software, and to permit persons to whom the
18  Software is furnished to do so, subject to the following conditions:
19 
20  The above copyright notice and this permission notice shall be included
21  in all copies or substantial portions of the Software.
22 
23  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
29  IN THE SOFTWARE.
30 
31 */
32 
37 #ifndef RTCPRRPACKET_H
38 
39 #define RTCPRRPACKET_H
40 
41 #include "rtpconfig.h"
42 #include "rtcppacket.h"
43 #include "rtpstructs.h"
44 #if ! (defined(WIN32) || defined(_WIN32_WCE))
45  #include <netinet/in.h>
46 #endif // WIN32
47 
48 class RTCPCompoundPacket;
49 
51 class RTCPRRPacket : public RTCPPacket
52 {
53 public:
59  RTCPRRPacket(uint8_t *data,size_t datalen);
60  ~RTCPRRPacket() { }
61 
63  uint32_t GetSenderSSRC() const;
64 
66  int GetReceptionReportCount() const;
67 
72  uint32_t GetSSRC(int index) const;
73 
78  uint8_t GetFractionLost(int index) const;
79 
84  int32_t GetLostPacketCount(int index) const;
85 
90  uint32_t GetExtendedHighestSequenceNumber(int index) const;
91 
96  uint32_t GetJitter(int index) const;
97 
102  uint32_t GetLSR(int index) const;
103 
108  uint32_t GetDLSR(int index) const;
109 
110 
111 #ifdef RTPDEBUG
112  void Dump();
113 #endif // RTPDEBUG
114 private:
115  RTCPReceiverReport *GotoReport(int index) const;
116 };
117 
118 inline uint32_t RTCPRRPacket::GetSenderSSRC() const
119 {
120  if (!knownformat)
121  return 0;
122 
123  uint32_t *ssrcptr = (uint32_t *)(data+sizeof(RTCPCommonHeader));
124  return ntohl(*ssrcptr);
125 }
127 {
128  if (!knownformat)
129  return 0;
130  RTCPCommonHeader *hdr = (RTCPCommonHeader *)data;
131  return ((int)hdr->count);
132 }
133 
134 inline RTCPReceiverReport *RTCPRRPacket::GotoReport(int index) const
135 {
136  RTCPReceiverReport *r = (RTCPReceiverReport *)(data+sizeof(RTCPCommonHeader)+sizeof(uint32_t)+index*sizeof(RTCPReceiverReport));
137  return r;
138 }
139 
140 inline uint32_t RTCPRRPacket::GetSSRC(int index) const
141 {
142  if (!knownformat)
143  return 0;
144  RTCPReceiverReport *r = GotoReport(index);
145  return ntohl(r->ssrc);
146 }
147 
148 inline uint8_t RTCPRRPacket::GetFractionLost(int index) const
149 {
150  if (!knownformat)
151  return 0;
152  RTCPReceiverReport *r = GotoReport(index);
153  return r->fractionlost;
154 }
155 
156 inline int32_t RTCPRRPacket::GetLostPacketCount(int index) const
157 {
158  if (!knownformat)
159  return 0;
160  RTCPReceiverReport *r = GotoReport(index);
161  uint32_t count = ((uint32_t)r->packetslost[2])|(((uint32_t)r->packetslost[1])<<8)|(((uint32_t)r->packetslost[0])<<16);
162  if ((count&0x00800000) != 0) // test for negative number
163  count |= 0xFF000000;
164  int32_t *count2 = (int32_t *)(&count);
165  return (*count2);
166 }
167 
168 inline uint32_t RTCPRRPacket::GetExtendedHighestSequenceNumber(int index) const
169 {
170  if (!knownformat)
171  return 0;
172  RTCPReceiverReport *r = GotoReport(index);
173  return ntohl(r->exthighseqnr);
174 }
175 
176 inline uint32_t RTCPRRPacket::GetJitter(int index) const
177 {
178  if (!knownformat)
179  return 0;
180  RTCPReceiverReport *r = GotoReport(index);
181  return ntohl(r->jitter);
182 }
183 
184 inline uint32_t RTCPRRPacket::GetLSR(int index) const
185 {
186  if (!knownformat)
187  return 0;
188  RTCPReceiverReport *r = GotoReport(index);
189  return ntohl(r->lsr);
190 }
191 
192 inline uint32_t RTCPRRPacket::GetDLSR(int index) const
193 {
194  if (!knownformat)
195  return 0;
196  RTCPReceiverReport *r = GotoReport(index);
197  return ntohl(r->dlsr);
198 }
199 
200 #endif // RTCPRRPACKET_H
201 
Base class for specific types of RTCP packets.
Definition: rtcppacket.h:47
Represents an RTCP compound packet.
Definition: rtcpcompoundpacket.h:50
RTCPRRPacket(uint8_t *data, size_t datalen)
Creates an instance based on the data in data with length datalen.
uint32_t GetLSR(int index) const
Returns the LSR field of the reception report block described by index which may have a value from 0 ...
Definition: rtcprrpacket.h:184
uint32_t GetDLSR(int index) const
Returns the DLSR field of the reception report block described by index which may have a value from 0...
Definition: rtcprrpacket.h:192
Describes an RTCP receiver report packet.
Definition: rtcprrpacket.h:51
int32_t GetLostPacketCount(int index) const
Returns the number of lost packets in the reception report block described by index which may have a ...
Definition: rtcprrpacket.h:156
uint32_t GetSenderSSRC() const
Returns the SSRC of the participant who sent this packet.
Definition: rtcprrpacket.h:118
uint32_t GetSSRC(int index) const
Returns the SSRC of the reception report block described by index which may have a value from 0 to Ge...
Definition: rtcprrpacket.h:140
uint8_t GetFractionLost(int index) const
Returns the `fraction lost' field of the reception report described by index which may have a value f...
Definition: rtcprrpacket.h:148
uint32_t GetExtendedHighestSequenceNumber(int index) const
Returns the extended highest sequence number of the reception report block described by index which m...
Definition: rtcprrpacket.h:168
int GetReceptionReportCount() const
Returns the number of reception report blocks present in this packet.
Definition: rtcprrpacket.h:126
uint32_t GetJitter(int index) const
Returns the jitter field of the reception report block described by index which may have a value from...
Definition: rtcprrpacket.h:176