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.
rtcppacketbuilder.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 RTCPPACKETBUILDER_H
38 
39 #define RTCPPACKETBUILDER_H
40 
41 #include "rtpconfig.h"
42 #include "rtptypes.h"
43 #include "rtperrors.h"
44 #include "rtcpsdesinfo.h"
45 #include "rtptimeutilities.h"
46 
47 #include "export.h"
48 
49 namespace qrtplib
50 {
51 
52 class RTPSources;
53 class RTPPacketBuilder;
54 class RTCPScheduler;
55 class RTCPCompoundPacket;
56 class RTCPCompoundPacketBuilder;
57 
65 {
66 public:
72  RTCPPacketBuilder(RTPSources &sources, RTPPacketBuilder &rtppackbuilder);
74 
81  int Init(std::size_t maxpacksize, double timestampunit, const void *cname, std::size_t cnamelen);
82 
84  void Destroy();
85 
91  int SetTimestampUnit(double tsunit)
92  {
93  if (!init)
95  if (tsunit < 0)
97  timestampunit = tsunit;
98  return 0;
99  }
100 
102  int SetMaximumPacketSize(std::size_t maxpacksize)
103  {
104  if (!init)
106  if (maxpacksize < RTP_MINPACKETSIZE)
108  maxpacketsize = maxpacksize;
109  return 0;
110  }
111 
119  {
120  if (!init)
122  transmissiondelay = delay;
123  return 0;
124  }
125 
127  int BuildNextPacket(RTCPCompoundPacket **pack);
128 
134  int BuildBYEPacket(RTCPCompoundPacket **pack, const void *reason, std::size_t reasonlength, bool useSRifpossible = true);
135 
142  void SetNameInterval(int count)
143  {
144  if (!init)
145  return;
146  interval_name = count;
147  }
148 
155  void SetEMailInterval(int count)
156  {
157  if (!init)
158  return;
159  interval_email = count;
160  }
161 
168  void SetLocationInterval(int count)
169  {
170  if (!init)
171  return;
172  interval_location = count;
173  }
174 
181  void SetPhoneInterval(int count)
182  {
183  if (!init)
184  return;
185  interval_phone = count;
186  }
187 
194  void SetToolInterval(int count)
195  {
196  if (!init)
197  return;
198  interval_tool = count;
199  }
200 
207  void SetNoteInterval(int count)
208  {
209  if (!init)
210  return;
211  interval_note = count;
212  }
213 
215  int SetLocalName(const void *s, std::size_t len)
216  {
217  if (!init)
219  return ownsdesinfo.SetName((const uint8_t *) s, len);
220  }
221 
223  int SetLocalEMail(const void *s, std::size_t len)
224  {
225  if (!init)
227  return ownsdesinfo.SetEMail((const uint8_t *) s, len);
228  }
229 
231  int SetLocalLocation(const void *s, std::size_t len)
232  {
233  if (!init)
235  return ownsdesinfo.SetLocation((const uint8_t *) s, len);
236  }
237 
239  int SetLocalPhone(const void *s, std::size_t len)
240  {
241  if (!init)
243  return ownsdesinfo.SetPhone((const uint8_t *) s, len);
244  }
245 
247  int SetLocalTool(const void *s, std::size_t len)
248  {
249  if (!init)
251  return ownsdesinfo.SetTool((const uint8_t *) s, len);
252  }
253 
255  int SetLocalNote(const void *s, std::size_t len)
256  {
257  if (!init)
259  return ownsdesinfo.SetNote((const uint8_t *) s, len);
260  }
261 
263  uint8_t *GetLocalCNAME(std::size_t *len) const
264  {
265  if (!init)
266  return 0;
267  return ownsdesinfo.GetCNAME(len);
268  }
269 private:
270  void ClearAllSourceFlags();
271  int FillInReportBlocks(RTCPCompoundPacketBuilder *pack, const RTPTime &curtime, int maxcount, bool *full, int *added, int *skipped, bool *atendoflist);
272  int FillInSDES(RTCPCompoundPacketBuilder *pack, bool *full, bool *processedall, int *added);
273  void ClearAllSDESFlags();
274 
277 
278  bool init;
279  std::size_t maxpacketsize;
282  RTPTime prevbuildtime, transmissiondelay;
283 
285  {
286  public:
288  {
289  ClearFlags();
290  }
291  void ClearFlags()
292  {
293  pname = false;
294  pemail = false;
295  plocation = false;
296  pphone = false;
297  ptool = false;
298  pnote = false;
299  }
300  bool ProcessedName() const
301  {
302  return pname;
303  }
304  bool ProcessedEMail() const
305  {
306  return pemail;
307  }
308  bool ProcessedLocation() const
309  {
310  return plocation;
311  }
312  bool ProcessedPhone() const
313  {
314  return pphone;
315  }
316  bool ProcessedTool() const
317  {
318  return ptool;
319  }
320  bool ProcessedNote() const
321  {
322  return pnote;
323  }
324  void SetProcessedName(bool v)
325  {
326  pname = v;
327  }
328  void SetProcessedEMail(bool v)
329  {
330  pemail = v;
331  }
332  void SetProcessedLocation(bool v)
333  {
334  plocation = v;
335  }
336  void SetProcessedPhone(bool v)
337  {
338  pphone = v;
339  }
340  void SetProcessedTool(bool v)
341  {
342  ptool = v;
343  }
344  void SetProcessedNote(bool v)
345  {
346  pnote = v;
347  }
348  private:
349  bool pname, pemail, plocation, pphone, ptool, pnote;
350  };
351 
353  int interval_name, interval_email, interval_location;
354  int interval_phone, interval_tool, interval_note;
355  bool doname, doemail, doloc, dophone, dotool, donote;
357 
359 };
360 
361 } // end namespace
362 
363 #endif // RTCPPACKETBUILDER_H
364 
int SetLocalNote(const void *s, std::size_t len)
int SetLocalPhone(const void *s, std::size_t len)
RTCPSDESInfoInternal ownsdesinfo
#define ERR_RTP_RTCPPACKETBUILDER_ILLEGALTIMESTAMPUNIT
Definition: rtperrors.h:101
int SetLocalTool(const void *s, std::size_t len)
#define QRTPLIB_API
Definition: export.h:112
int SetMaximumPacketSize(std::size_t maxpacksize)
#define RTP_MINPACKETSIZE
Definition: rtpdefines.h:39
unsigned char uint8_t
Definition: rtptypes_win.h:42
int SetLocalEMail(const void *s, std::size_t len)
int SetTimestampUnit(double tsunit)
#define ERR_RTP_RTCPPACKETBUILDER_ILLEGALMAXPACKSIZE
Definition: rtperrors.h:100
void SetLocationInterval(int count)
int SetLocalLocation(const void *s, std::size_t len)
#define ERR_RTP_RTCPPACKETBUILDER_NOTINIT
Definition: rtperrors.h:102
int SetPreTransmissionDelay(const RTPTime &delay)
RTPPacketBuilder & rtppacketbuilder
uint8_t * GetLocalCNAME(std::size_t *len) const
int SetLocalName(const void *s, std::size_t len)