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.
rtppacket.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 RTPPACKET_H
38 
39 #define RTPPACKET_H
40 
41 #include "rtpconfig.h"
42 #include "rtptypes.h"
43 #include "rtptimeutilities.h"
44 #include "rtpendian.h"
45 
46 namespace qrtplib
47 {
48 
49 class RTPRawPacket;
50 
56 class RTPPacket
57 {
58 public:
63  RTPPacket(RTPRawPacket &rawpack);
64 
72  const void *payloaddata,
73  unsigned int payloadlen,
74  uint16_t seqnr,
76  uint32_t ssrc,
77  bool gotmarker,
79  const uint32_t *csrcs,
80  bool gotextension,
81  uint16_t extensionid,
82  uint16_t extensionlen_numwords,
83  const void *extensiondata,
84  unsigned int maxpacksize);
85 
88  RTPPacket(uint8_t payloadtype,
89  const void *payloaddata,
90  unsigned int payloadlen,
91  uint16_t seqnr,
92  uint32_t timestamp,
93  uint32_t ssrc,
94  bool gotmarker,
95  uint8_t numcsrcs,
96  const uint32_t *csrcs,
97  bool gotextension,
98  uint16_t extensionid,
99  uint16_t extensionlen_numwords,
100  const void *extensiondata,
101  void *buffer,
102  unsigned int buffersize);
103 
104  virtual ~RTPPacket()
105  {
106  if (packet && !externalbuffer)
107  delete[] packet;
108  }
109 
111  int GetCreationError() const
112  {
113  return error;
114  }
115 
117  bool HasExtension() const
118  {
119  return hasextension;
120  }
121 
123  bool HasMarker() const
124  {
125  return hasmarker;
126  }
127 
129  int GetCSRCCount() const
130  {
131  return numcsrcs;
132  }
133 
137  uint32_t GetCSRC(int num) const;
138 
141  {
142  return payloadtype;
143  }
144 
150  {
151  return extseqnr;
152  }
153 
156  {
157  return (uint16_t) (extseqnr & 0x0000FFFF);
158  }
159 
162  {
163  extseqnr = seq;
164  }
165 
168  {
169  return timestamp;
170  }
171 
174  {
175  return ssrc;
176  }
177 
180  {
181  return packet;
182  }
183 
186  {
187  return payload;
188  }
189 
191  unsigned int GetPacketLength() const
192  {
193  return packetlength;
194  }
195 
197  unsigned int GetPayloadLength() const
198  {
199  return payloadlength;
200  }
201 
204  {
205  return extid;
206  }
207 
210  {
211  return extension;
212  }
213 
215  unsigned int GetExtensionLength() const
216  {
217  return extensionlength;
218  }
219 
226  {
227  return receivetime;
228  }
229 private:
230  void Clear();
231  int ParseRawPacket(RTPRawPacket &rawpack);
232  int BuildPacket(uint8_t payloadtype, const void *payloaddata, unsigned int payloadlen, uint16_t seqnr, uint32_t timestamp, uint32_t ssrc, bool gotmarker, uint8_t numcsrcs,
233  const uint32_t *csrcs, bool gotextension, uint16_t extensionid, uint16_t extensionlen_numwords, const void *extensiondata, void *buffer, unsigned int maxsize);
234 
236  int error;
237 
239  int numcsrcs;
240 
245 
248  unsigned int extensionlength;
249 
251 
253 };
254 
255 } // end namespace
256 
257 #endif // RTPPACKET_H
258 
unsigned int GetPayloadLength() const
Definition: rtppacket.h:197
uint8_t GetPayloadType() const
Definition: rtppacket.h:140
uint8_t * payload
Definition: rtppacket.h:243
bool HasMarker() const
Definition: rtppacket.h:123
uint16_t GetExtensionID() const
Definition: rtppacket.h:203
unsigned int GetExtensionLength() const
Definition: rtppacket.h:215
unsigned int extensionlength
Definition: rtppacket.h:248
RTPEndian m_endian
Definition: rtppacket.h:235
unsigned int GetPacketLength() const
Definition: rtppacket.h:191
uint8_t * extension
Definition: rtppacket.h:247
virtual ~RTPPacket()
Definition: rtppacket.h:104
unsigned int uint32_t
Definition: rtptypes_win.h:46
uint8_t * GetExtensionData() const
Definition: rtppacket.h:209
uint32_t extseqnr
Definition: rtppacket.h:242
RTPPacket(RTPRawPacket &rawpack)
Definition: rtppacket.cpp:63
uint32_t timestamp
Definition: rtppacket.h:242
uint16_t GetSequenceNumber() const
Definition: rtppacket.h:155
int BuildPacket(uint8_t payloadtype, const void *payloaddata, unsigned int payloadlen, uint16_t seqnr, uint32_t timestamp, uint32_t ssrc, bool gotmarker, uint8_t numcsrcs, const uint32_t *csrcs, bool gotextension, uint16_t extensionid, uint16_t extensionlen_numwords, const void *extensiondata, void *buffer, unsigned int maxsize)
Definition: rtppacket.cpp:264
unsigned char uint8_t
Definition: rtptypes_win.h:42
unsigned int packetlength
Definition: rtppacket.h:244
int GetCreationError() const
Definition: rtppacket.h:111
uint8_t * packet
Definition: rtppacket.h:243
unsigned short uint16_t
Definition: rtptypes_win.h:44
uint32_t GetSSRC() const
Definition: rtppacket.h:173
uint8_t * GetPacketData() const
Definition: rtppacket.h:179
uint32_t GetExtendedSequenceNumber() const
Definition: rtppacket.h:149
RTPTime GetReceiveTime() const
Definition: rtppacket.h:225
uint8_t * GetPayloadData() const
Definition: rtppacket.h:185
int GetCSRCCount() const
Definition: rtppacket.h:129
void SetExtendedSequenceNumber(uint32_t seq)
Definition: rtppacket.h:161
unsigned int payloadlength
Definition: rtppacket.h:244
int ParseRawPacket(RTPRawPacket &rawpack)
Definition: rtppacket.cpp:148
uint32_t GetTimestamp() const
Definition: rtppacket.h:167
uint8_t payloadtype
Definition: rtppacket.h:241
bool HasExtension() const
Definition: rtppacket.h:117
uint32_t GetCSRC(int num) const
Definition: rtppacket.cpp:249
RTPTime receivetime
Definition: rtppacket.h:252