JRTPLIB  3.11.1
rtcprrpacket.h
Go to the documentation of this file.
1 /*
2 
3  This file is a part of JRTPLIB
4  Copyright (c) 1999-2017 Jori Liesenborgs
5 
6  Contact: jori.liesenborgs@gmail.com
7 
8  This library was developed at the Expertise Centre for Digital 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 #ifdef RTP_SUPPORT_NETINET_IN
45  #include <netinet/in.h>
46 #endif // RTP_SUPPORT_NETINET_IN
47 
48 namespace jrtplib
49 {
50 
51 class RTCPCompoundPacket;
52 
54 class JRTPLIB_IMPORTEXPORT RTCPRRPacket : public RTCPPacket
55 {
56 public:
62  RTCPRRPacket(uint8_t *data,size_t datalen);
63  ~RTCPRRPacket() { }
64 
66  uint32_t GetSenderSSRC() const;
67 
69  int GetReceptionReportCount() const;
70 
75  uint32_t GetSSRC(int index) const;
76 
81  uint8_t GetFractionLost(int index) const;
82 
87  int32_t GetLostPacketCount(int index) const;
88 
93  uint32_t GetExtendedHighestSequenceNumber(int index) const;
94 
99  uint32_t GetJitter(int index) const;
100 
105  uint32_t GetLSR(int index) const;
106 
111  uint32_t GetDLSR(int index) const;
112 
113 
114 #ifdef RTPDEBUG
115  void Dump();
116 #endif // RTPDEBUG
117 private:
118  RTCPReceiverReport *GotoReport(int index) const;
119 };
120 
121 inline uint32_t RTCPRRPacket::GetSenderSSRC() const
122 {
123  if (!knownformat)
124  return 0;
125 
126  uint32_t *ssrcptr = (uint32_t *)(data+sizeof(RTCPCommonHeader));
127  return ntohl(*ssrcptr);
128 }
130 {
131  if (!knownformat)
132  return 0;
133  RTCPCommonHeader *hdr = (RTCPCommonHeader *)data;
134  return ((int)hdr->count);
135 }
136 
137 inline RTCPReceiverReport *RTCPRRPacket::GotoReport(int index) const
138 {
139  RTCPReceiverReport *r = (RTCPReceiverReport *)(data+sizeof(RTCPCommonHeader)+sizeof(uint32_t)+index*sizeof(RTCPReceiverReport));
140  return r;
141 }
142 
143 inline uint32_t RTCPRRPacket::GetSSRC(int index) const
144 {
145  if (!knownformat)
146  return 0;
147  RTCPReceiverReport *r = GotoReport(index);
148  return ntohl(r->ssrc);
149 }
150 
151 inline uint8_t RTCPRRPacket::GetFractionLost(int index) const
152 {
153  if (!knownformat)
154  return 0;
155  RTCPReceiverReport *r = GotoReport(index);
156  return r->fractionlost;
157 }
158 
159 inline int32_t RTCPRRPacket::GetLostPacketCount(int index) const
160 {
161  if (!knownformat)
162  return 0;
163  RTCPReceiverReport *r = GotoReport(index);
164  uint32_t count = ((uint32_t)r->packetslost[2])|(((uint32_t)r->packetslost[1])<<8)|(((uint32_t)r->packetslost[0])<<16);
165  if ((count&0x00800000) != 0) // test for negative number
166  count |= 0xFF000000;
167  int32_t *count2 = (int32_t *)(&count);
168  return (*count2);
169 }
170 
171 inline uint32_t RTCPRRPacket::GetExtendedHighestSequenceNumber(int index) const
172 {
173  if (!knownformat)
174  return 0;
175  RTCPReceiverReport *r = GotoReport(index);
176  return ntohl(r->exthighseqnr);
177 }
178 
179 inline uint32_t RTCPRRPacket::GetJitter(int index) const
180 {
181  if (!knownformat)
182  return 0;
183  RTCPReceiverReport *r = GotoReport(index);
184  return ntohl(r->jitter);
185 }
186 
187 inline uint32_t RTCPRRPacket::GetLSR(int index) const
188 {
189  if (!knownformat)
190  return 0;
191  RTCPReceiverReport *r = GotoReport(index);
192  return ntohl(r->lsr);
193 }
194 
195 inline uint32_t RTCPRRPacket::GetDLSR(int index) const
196 {
197  if (!knownformat)
198  return 0;
199  RTCPReceiverReport *r = GotoReport(index);
200  return ntohl(r->dlsr);
201 }
202 
203 } // end namespace
204 
205 #endif // RTCPRRPACKET_H
206 
int GetReceptionReportCount() const
Returns the number of reception report blocks present in this packet.
Definition: rtcprrpacket.h:129
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:171
Describes an RTCP receiver report packet.
Definition: rtcprrpacket.h:54
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:143
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:179
Definition: rtpfaketransmitter.h:64
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:187
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:195
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:159
uint32_t GetSenderSSRC() const
Returns the SSRC of the participant who sent this packet.
Definition: rtcprrpacket.h:121
uint8_t GetFractionLost(int index) const
Returns the `fraction lost&#39; field of the reception report described by index which may have a value f...
Definition: rtcprrpacket.h:151
Base class for specific types of RTCP packets.
Definition: rtcppacket.h:50