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.
rtcpsrpacket.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 RTCPSRPACKET_H
38 
39 #define RTCPSRPACKET_H
40 
41 #include "rtpconfig.h"
42 #include "rtcppacket.h"
43 #include "rtptimeutilities.h"
44 #include "rtpstructs.h"
45 #include "rtpendian.h"
46 
47 #include "export.h"
48 
49 namespace qrtplib
50 {
51 
52 class RTCPCompoundPacket;
53 
56 {
57 public:
63  RTCPSRPacket(uint8_t *data, std::size_t datalength);
65  {
66  }
67 
69  uint32_t GetSenderSSRC() const;
70 
72  RTPNTPTime GetNTPTimestamp() const;
73 
75  uint32_t GetRTPTimestamp() const;
76 
78  uint32_t GetSenderPacketCount() const;
79 
81  uint32_t GetSenderOctetCount() const;
82 
84  int GetReceptionReportCount() const;
85 
90  uint32_t GetSSRC(int index) const;
91 
96  uint8_t GetFractionLost(int index) const;
97 
102  int32_t GetLostPacketCount(int index) const;
103 
108  uint32_t GetExtendedHighestSequenceNumber(int index) const;
109 
114  uint32_t GetJitter(int index) const;
115 
120  uint32_t GetLSR(int index) const;
121 
126  uint32_t GetDLSR(int index) const;
127 
128 private:
129  RTCPReceiverReport *GotoReport(int index) const;
130 
132 };
133 
135 {
136  if (!knownformat)
137  return 0;
138 
139  uint32_t *ssrcptr = (uint32_t *) (data + sizeof(RTCPCommonHeader));
140  return m_endian.qToHost(*ssrcptr);
141 }
142 
144 {
145  if (!knownformat)
146  return RTPNTPTime(0, 0);
147 
148  RTCPSenderReport *sr = (RTCPSenderReport *) (data + sizeof(RTCPCommonHeader) + sizeof(uint32_t));
149  return RTPNTPTime(m_endian.qToHost(sr->ntptime_msw), m_endian.qToHost(sr->ntptime_lsw));
150 }
151 
153 {
154  if (!knownformat)
155  return 0;
156  RTCPSenderReport *sr = (RTCPSenderReport *) (data + sizeof(RTCPCommonHeader) + sizeof(uint32_t));
157  return m_endian.qToHost(sr->rtptimestamp);
158 }
159 
161 {
162  if (!knownformat)
163  return 0;
164  RTCPSenderReport *sr = (RTCPSenderReport *) (data + sizeof(RTCPCommonHeader) + sizeof(uint32_t));
165  return m_endian.qToHost(sr->packetcount);
166 }
167 
169 {
170  if (!knownformat)
171  return 0;
172  RTCPSenderReport *sr = (RTCPSenderReport *) (data + sizeof(RTCPCommonHeader) + sizeof(uint32_t));
173  return m_endian.qToHost(sr->octetcount);
174 }
175 
177 {
178  if (!knownformat)
179  return 0;
180  RTCPCommonHeader *hdr = (RTCPCommonHeader *) data;
181  return ((int) hdr->count);
182 }
183 
185 {
186  RTCPReceiverReport *r = (RTCPReceiverReport *) (data + sizeof(RTCPCommonHeader) + sizeof(uint32_t) + sizeof(RTCPSenderReport) + index * sizeof(RTCPReceiverReport));
187  return r;
188 }
189 
190 inline uint32_t RTCPSRPacket::GetSSRC(int index) const
191 {
192  if (!knownformat)
193  return 0;
194  RTCPReceiverReport *r = GotoReport(index);
195  return m_endian.qToHost(r->ssrc);
196 }
197 
198 inline uint8_t RTCPSRPacket::GetFractionLost(int index) const
199 {
200  if (!knownformat)
201  return 0;
202  RTCPReceiverReport *r = GotoReport(index);
203  return r->fractionlost;
204 }
205 
207 {
208  if (!knownformat)
209  return 0;
210  RTCPReceiverReport *r = GotoReport(index);
211  uint32_t count = ((uint32_t) r->packetslost[2]) | (((uint32_t) r->packetslost[1]) << 8) | (((uint32_t) r->packetslost[0]) << 16);
212  if ((count & 0x00800000) != 0) // test for negative number
213  count |= 0xFF000000;
214  int32_t *count2 = (int32_t *) (&count);
215  return (*count2);
216 }
217 
219 {
220  if (!knownformat)
221  return 0;
222  RTCPReceiverReport *r = GotoReport(index);
223  return m_endian.qToHost(r->exthighseqnr);
224 }
225 
226 inline uint32_t RTCPSRPacket::GetJitter(int index) const
227 {
228  if (!knownformat)
229  return 0;
230  RTCPReceiverReport *r = GotoReport(index);
231  return m_endian.qToHost(r->jitter);
232 }
233 
234 inline uint32_t RTCPSRPacket::GetLSR(int index) const
235 {
236  if (!knownformat)
237  return 0;
238  RTCPReceiverReport *r = GotoReport(index);
239  return m_endian.qToHost(r->lsr);
240 }
241 
242 inline uint32_t RTCPSRPacket::GetDLSR(int index) const
243 {
244  if (!knownformat)
245  return 0;
246  RTCPReceiverReport *r = GotoReport(index);
247  return m_endian.qToHost(r->dlsr);
248 }
249 
250 } // end namespace
251 
252 #endif // RTCPSRPACKET_H
253 
uint8_t GetFractionLost(int index) const
Definition: rtcpsrpacket.h:198
uint32_t GetJitter(int index) const
Definition: rtcpsrpacket.h:226
uint32_t GetLSR(int index) const
Definition: rtcpsrpacket.h:234
int GetReceptionReportCount() const
Definition: rtcpsrpacket.h:176
uint32_t GetSSRC(int index) const
Definition: rtcpsrpacket.h:190
#define QRTPLIB_API
Definition: export.h:112
unsigned int uint32_t
Definition: rtptypes_win.h:46
unsigned char uint8_t
Definition: rtptypes_win.h:42
uint32_t GetSenderPacketCount() const
Definition: rtcpsrpacket.h:160
int32_t GetLostPacketCount(int index) const
Definition: rtcpsrpacket.h:206
int int32_t
Definition: rtptypes_win.h:45
RTCPReceiverReport * GotoReport(int index) const
Definition: rtcpsrpacket.h:184
uint32_t GetExtendedHighestSequenceNumber(int index) const
Definition: rtcpsrpacket.h:218
RTPNTPTime GetNTPTimestamp() const
Definition: rtcpsrpacket.h:143
uint32_t GetSenderSSRC() const
Definition: rtcpsrpacket.h:134
uint32_t GetRTPTimestamp() const
Definition: rtcpsrpacket.h:152
uint32_t GetSenderOctetCount() const
Definition: rtcpsrpacket.h:168
uint32_t GetDLSR(int index) const
Definition: rtcpsrpacket.h:242