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.
rtpsources.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 RTPSOURCES_H
38 
39 #define RTPSOURCES_H
40 
41 #include "rtpconfig.h"
42 #include "rtpkeyhashtable.h"
43 #include "rtcpsdespacket.h"
44 #include "rtptypes.h"
45 
46 #include "export.h"
47 
48 #define RTPSOURCES_HASHSIZE 8317
49 
50 namespace qrtplib
51 {
52 
54 {
55 public:
56  static int GetIndex(const uint32_t &ssrc)
57  {
58  return ssrc % RTPSOURCES_HASHSIZE;
59  }
60 };
61 
62 class RTPNTPTime;
63 class RTPTransmitter;
64 class RTCPAPPPacket;
66 class RTPRawPacket;
67 class RTPPacket;
68 class RTPTime;
69 class RTPAddress;
70 class RTPSourceData;
71 
79 {
80 public:
83  {
86  ProbationStore
87  };
88 
90  RTPSources();
91  virtual ~RTPSources();
92 
94  void Clear();
95 
97  int CreateOwnSSRC(uint32_t ssrc);
98 
100  int DeleteOwnSSRC();
101 
106  void SentRTPPacket();
107 
113  int ProcessRawPacket(RTPRawPacket *rawpack, RTPTransmitter *trans, bool acceptownpackets);
114 
120  int ProcessRawPacket(RTPRawPacket *rawpack, RTPTransmitter *trans[], int numtrans, bool acceptownpackets);
121 
129  int ProcessRTPPacket(RTPPacket *rtppack, const RTPTime &receivetime, const RTPAddress *senderaddress, bool *stored);
130 
135  int ProcessRTCPCompoundPacket(RTCPCompoundPacket *rtcpcomppack, const RTPTime &receivetime, const RTPAddress *senderaddress);
136 
142  int ProcessRTCPSenderInfo(uint32_t ssrc, const RTPNTPTime &ntptime, uint32_t rtptime, uint32_t packetcount, uint32_t octetcount, const RTPTime &receivetime,
143  const RTPAddress *senderaddress);
144 
150  int ProcessRTCPReportBlock(uint32_t ssrc, uint8_t fractionlost, int32_t lostpackets, uint32_t exthighseqnr, uint32_t jitter, uint32_t lsr, uint32_t dlsr,
151  const RTPTime &receivetime, const RTPAddress *senderaddress);
152 
158  int ProcessSDESNormalItem(uint32_t ssrc, RTCPSDESPacket::ItemType t, std::size_t itemlength, const void *itemdata, const RTPTime &receivetime, const RTPAddress *senderaddress);
159 #ifdef RTP_SUPPORT_SDESPRIV
160 
165  int ProcessSDESPrivateItem(uint32_t ssrc, std::size_t prefixlen, const void *prefixdata, std::size_t valuelen, const void *valuedata, const RTPTime &receivetime,
166  const RTPAddress *senderaddress);
167 #endif //RTP_SUPPORT_SDESPRIV
168 
173  int ProcessBYE(uint32_t ssrc, std::size_t reasonlength, const void *reasondata, const RTPTime &receivetime, const RTPAddress *senderaddress);
174 
184  int UpdateReceiveTime(uint32_t ssrc, const RTPTime &receivetime, const RTPAddress *senderaddress);
185 
190  bool GotoFirstSource();
191 
196  bool GotoNextSource();
197 
202  bool GotoPreviousSource();
203 
210  bool GotoFirstSourceWithData();
211 
218  bool GotoNextSourceWithData();
219 
226  bool GotoPreviousSourceWithData();
227 
229  RTPSourceData *GetCurrentSourceInfo();
230 
234  RTPSourceData *GetSourceInfo(uint32_t ssrc);
235 
237  RTPPacket *GetNextPacket();
238 
240  bool GotEntry(uint32_t ssrc);
241 
244  {
245  return (RTPSourceData *) owndata;
246  }
247 
251  void Timeout(const RTPTime &curtime, const RTPTime &timeoutdelay);
252 
256  void SenderTimeout(const RTPTime &curtime, const RTPTime &timeoutdelay);
257 
261  void BYETimeout(const RTPTime &curtime, const RTPTime &timeoutdelay);
262 
266  void NoteTimeout(const RTPTime &curtime, const RTPTime &timeoutdelay);
267 
272  void MultipleTimeouts(const RTPTime &curtime, const RTPTime &sendertimeout, const RTPTime &byetimeout, const RTPTime &generaltimeout, const RTPTime &notetimeout);
273 
275  int GetSenderCount() const
276  {
277  return sendercount;
278  }
279 
281  int GetTotalCount() const
282  {
283  return totalcount;
284  }
285 
288  {
289  return activecount;
290  }
291 
292 protected:
294  virtual void OnRTPPacket(RTPPacket *pack, const RTPTime &receivetime, const RTPAddress *senderaddress);
295 
297  virtual void OnRTCPCompoundPacket(RTCPCompoundPacket *pack, const RTPTime &receivetime, const RTPAddress *senderaddress);
298 
304  virtual void OnSSRCCollision(RTPSourceData *srcdat, const RTPAddress *senderaddress, bool isrtp);
305 
307  virtual void OnCNAMECollision(RTPSourceData *srcdat, const RTPAddress *senderaddress, const uint8_t *cname, std::size_t cnamelength);
308 
310  virtual void OnNewSource(RTPSourceData *srcdat);
311 
313  virtual void OnRemoveSource(RTPSourceData *srcdat);
314 
316  virtual void OnTimeout(RTPSourceData *srcdat);
317 
319  virtual void OnBYETimeout(RTPSourceData *srcdat);
320 
322  virtual void OnBYEPacket(RTPSourceData *srcdat);
323 
325  virtual void OnRTCPSenderReport(RTPSourceData *srcdat);
326 
328  virtual void OnRTCPReceiverReport(RTPSourceData *srcdat);
329 
331  virtual void OnRTCPSDESItem(RTPSourceData *srcdat, RTCPSDESPacket::ItemType t, const void *itemdata, std::size_t itemlength);
332 #ifdef RTP_SUPPORT_SDESPRIV
333 
334  virtual void OnRTCPSDESPrivateItem(RTPSourceData *srcdat, const void *prefixdata, std::size_t prefixlen, const void *valuedata, std::size_t valuelen);
335 #endif // RTP_SUPPORT_SDESPRIV
336 
340  virtual void OnAPPPacket(RTCPAPPPacket *apppacket, const RTPTime &receivetime, const RTPAddress *senderaddress);
341 
343  virtual void OnUnknownPacketType(RTCPPacket *rtcppack, const RTPTime &receivetime, const RTPAddress *senderaddress);
344 
346  virtual void OnUnknownPacketFormat(RTCPPacket *rtcppack, const RTPTime &receivetime, const RTPAddress *senderaddress);
347 
349  virtual void OnNoteTimeout(RTPSourceData *srcdat);
350 
355  virtual void OnValidatedRTPPacket(RTPSourceData *srcdat, RTPPacket *rtppack, bool isonprobation, bool *ispackethandled);
356 private:
357  void ClearSourceList();
358  int ObtainSourceDataInstance(uint32_t ssrc, RTPInternalSourceData **srcdat, bool *created);
359  int GetRTCPSourceData(uint32_t ssrc, const RTPAddress *senderaddress, RTPInternalSourceData **srcdat, bool *newsource);
360  bool CheckCollision(RTPInternalSourceData *srcdat, const RTPAddress *senderaddress, bool isrtp);
361 
363 
367 
369 
370  friend class RTPInternalSourceData;
371 };
372 
373 // Inlining the default implementations to avoid unused-parameter errors.
374 inline void RTPSources::OnRTPPacket(RTPPacket *, const RTPTime &, const RTPAddress *)
375 {
376 }
378 {
379 }
381 {
382 }
383 inline void RTPSources::OnCNAMECollision(RTPSourceData *, const RTPAddress *, const uint8_t *, std::size_t)
384 {
385 }
387 {
388 }
390 {
391 }
393 {
394 }
396 {
397 }
399 {
400 }
402 {
403 }
405 {
406 }
407 inline void RTPSources::OnRTCPSDESItem(RTPSourceData *, RTCPSDESPacket::ItemType, const void *, std::size_t)
408 {
409 }
410 #ifdef RTP_SUPPORT_SDESPRIV
411 inline void RTPSources::OnRTCPSDESPrivateItem(RTPSourceData *, const void *, std::size_t, const void *, std::size_t)
412 {
413 }
414 #endif // RTP_SUPPORT_SDESPRIV
415 inline void RTPSources::OnAPPPacket(RTCPAPPPacket *, const RTPTime &, const RTPAddress *)
416 {
417 }
419 {
420 }
422 {
423 }
425 {
426 }
428 {
429 }
430 
431 } // end namespace
432 
433 #endif // RTPSOURCES_H
434 
int GetSenderCount() const
Definition: rtpsources.h:275
RTPSourceData * GetOwnSourceInfo()
Definition: rtpsources.h:243
virtual void OnRTCPSenderReport(RTPSourceData *srcdat)
Definition: rtpsources.h:401
virtual void OnValidatedRTPPacket(RTPSourceData *srcdat, RTPPacket *rtppack, bool isonprobation, bool *ispackethandled)
Definition: rtpsources.h:427
virtual void OnRTCPSDESItem(RTPSourceData *srcdat, RTCPSDESPacket::ItemType t, const void *itemdata, std::size_t itemlength)
Definition: rtpsources.h:407
int GetTotalCount() const
Definition: rtpsources.h:281
virtual void OnAPPPacket(RTCPAPPPacket *apppacket, const RTPTime &receivetime, const RTPAddress *senderaddress)
Definition: rtpsources.h:415
virtual void OnNoteTimeout(RTPSourceData *srcdat)
Definition: rtpsources.h:424
#define QRTPLIB_API
Definition: export.h:112
virtual void OnRTCPCompoundPacket(RTCPCompoundPacket *pack, const RTPTime &receivetime, const RTPAddress *senderaddress)
Definition: rtpsources.h:377
RTPInternalSourceData * owndata
Definition: rtpsources.h:368
#define RTPSOURCES_HASHSIZE
Definition: rtpsources.h:48
unsigned int uint32_t
Definition: rtptypes_win.h:46
int GetActiveMemberCount() const
Definition: rtpsources.h:287
virtual void OnBYEPacket(RTPSourceData *srcdat)
Definition: rtpsources.h:398
unsigned char uint8_t
Definition: rtptypes_win.h:42
virtual void OnRTPPacket(RTPPacket *pack, const RTPTime &receivetime, const RTPAddress *senderaddress)
Definition: rtpsources.h:374
virtual void OnCNAMECollision(RTPSourceData *srcdat, const RTPAddress *senderaddress, const uint8_t *cname, std::size_t cnamelength)
Definition: rtpsources.h:383
RTPKeyHashTable< const uint32_t, RTPInternalSourceData *, RTPSources_GetHashIndex, RTPSOURCES_HASHSIZE > sourcelist
Definition: rtpsources.h:362
int int32_t
Definition: rtptypes_win.h:45
virtual void OnBYETimeout(RTPSourceData *srcdat)
Definition: rtpsources.h:395
virtual void OnUnknownPacketType(RTCPPacket *rtcppack, const RTPTime &receivetime, const RTPAddress *senderaddress)
Definition: rtpsources.h:418
virtual void OnTimeout(RTPSourceData *srcdat)
Definition: rtpsources.h:392
virtual void OnSSRCCollision(RTPSourceData *srcdat, const RTPAddress *senderaddress, bool isrtp)
Definition: rtpsources.h:380
virtual void OnRemoveSource(RTPSourceData *srcdat)
Definition: rtpsources.h:389
virtual void OnRTCPReceiverReport(RTPSourceData *srcdat)
Definition: rtpsources.h:404
virtual void OnRTCPSDESPrivateItem(RTPSourceData *srcdat, const void *prefixdata, std::size_t prefixlen, const void *valuedata, std::size_t valuelen)
Definition: rtpsources.h:411
virtual void OnNewSource(RTPSourceData *srcdat)
Definition: rtpsources.h:386
virtual void OnUnknownPacketFormat(RTCPPacket *rtcppack, const RTPTime &receivetime, const RTPAddress *senderaddress)
Definition: rtpsources.h:421
static int GetIndex(const uint32_t &ssrc)
Definition: rtpsources.h:56