SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
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 #include "rtpendian.h"
45 
46 #include "export.h"
47 
48 namespace qrtplib
49 {
50 
51 class RTCPCompoundPacket;
52 
55 {
56 public:
62  RTCPRRPacket(uint8_t *data, std::size_t datalen);
64  {
65  }
66 
68  uint32_t GetSenderSSRC() const;
69 
71  int GetReceptionReportCount() const;
72 
77  uint32_t GetSSRC(int index) const;
78 
83  uint8_t GetFractionLost(int index) const;
84 
89  int32_t GetLostPacketCount(int index) const;
90 
95  uint32_t GetExtendedHighestSequenceNumber(int index) const;
96 
101  uint32_t GetJitter(int index) const;
102 
107  uint32_t GetLSR(int index) const;
108 
113  uint32_t GetDLSR(int index) const;
114 
115 private:
116  RTCPReceiverReport *GotoReport(int index) const;
117 
119 };
120 
122 {
123  if (!knownformat)
124  return 0;
125 
126  uint32_t *ssrcptr = (uint32_t *) (data + sizeof(RTCPCommonHeader));
127  return m_endian.qToHost(*ssrcptr);
128 }
130 {
131  if (!knownformat)
132  return 0;
133  RTCPCommonHeader *hdr = (RTCPCommonHeader *) data;
134  return ((int) hdr->count);
135 }
136 
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 m_endian.qToHost(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 
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 
172 {
173  if (!knownformat)
174  return 0;
175  RTCPReceiverReport *r = GotoReport(index);
176  return m_endian.qToHost(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 m_endian.qToHost(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 m_endian.qToHost(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 m_endian.qToHost(r->dlsr);
201 }
202 
203 } // end namespace
204 
205 #endif // RTCPRRPACKET_H
206 
uint32_t GetExtendedHighestSequenceNumber(int index) const
Definition: rtcprrpacket.h:171
#define QRTPLIB_API
Definition: export.h:112
int GetReceptionReportCount() const
Definition: rtcprrpacket.h:129
unsigned int uint32_t
Definition: rtptypes_win.h:46
uint32_t GetSenderSSRC() const
Definition: rtcprrpacket.h:121
unsigned char uint8_t
Definition: rtptypes_win.h:42
uint32_t GetSSRC(int index) const
Definition: rtcprrpacket.h:143
uint32_t GetJitter(int index) const
Definition: rtcprrpacket.h:179
uint8_t GetFractionLost(int index) const
Definition: rtcprrpacket.h:151
int int32_t
Definition: rtptypes_win.h:45
RTCPReceiverReport * GotoReport(int index) const
Definition: rtcprrpacket.h:137
int32_t GetLostPacketCount(int index) const
Definition: rtcprrpacket.h:159
uint32_t GetLSR(int index) const
Definition: rtcprrpacket.h:187
uint32_t GetDLSR(int index) const
Definition: rtcprrpacket.h:195