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.
Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
qrtplib::RTPSources Class Reference

#include <rtpsources.h>

+ Inheritance diagram for qrtplib::RTPSources:
+ Collaboration diagram for qrtplib::RTPSources:

Public Types

enum  ProbationType { NoProbation, ProbationDiscard, ProbationStore }
 

Public Member Functions

 RTPSources ()
 
virtual ~RTPSources ()
 
void Clear ()
 
int CreateOwnSSRC (uint32_t ssrc)
 
int DeleteOwnSSRC ()
 
void SentRTPPacket ()
 
int ProcessRawPacket (RTPRawPacket *rawpack, RTPTransmitter *trans, bool acceptownpackets)
 
int ProcessRawPacket (RTPRawPacket *rawpack, RTPTransmitter *trans[], int numtrans, bool acceptownpackets)
 
int ProcessRTPPacket (RTPPacket *rtppack, const RTPTime &receivetime, const RTPAddress *senderaddress, bool *stored)
 
int ProcessRTCPCompoundPacket (RTCPCompoundPacket *rtcpcomppack, const RTPTime &receivetime, const RTPAddress *senderaddress)
 
int ProcessRTCPSenderInfo (uint32_t ssrc, const RTPNTPTime &ntptime, uint32_t rtptime, uint32_t packetcount, uint32_t octetcount, const RTPTime &receivetime, const RTPAddress *senderaddress)
 
int ProcessRTCPReportBlock (uint32_t ssrc, uint8_t fractionlost, int32_t lostpackets, uint32_t exthighseqnr, uint32_t jitter, uint32_t lsr, uint32_t dlsr, const RTPTime &receivetime, const RTPAddress *senderaddress)
 
int ProcessSDESNormalItem (uint32_t ssrc, RTCPSDESPacket::ItemType t, std::size_t itemlength, const void *itemdata, const RTPTime &receivetime, const RTPAddress *senderaddress)
 
int ProcessSDESPrivateItem (uint32_t ssrc, std::size_t prefixlen, const void *prefixdata, std::size_t valuelen, const void *valuedata, const RTPTime &receivetime, const RTPAddress *senderaddress)
 
int ProcessBYE (uint32_t ssrc, std::size_t reasonlength, const void *reasondata, const RTPTime &receivetime, const RTPAddress *senderaddress)
 
int UpdateReceiveTime (uint32_t ssrc, const RTPTime &receivetime, const RTPAddress *senderaddress)
 
bool GotoFirstSource ()
 
bool GotoNextSource ()
 
bool GotoPreviousSource ()
 
bool GotoFirstSourceWithData ()
 
bool GotoNextSourceWithData ()
 
bool GotoPreviousSourceWithData ()
 
RTPSourceDataGetCurrentSourceInfo ()
 
RTPSourceDataGetSourceInfo (uint32_t ssrc)
 
RTPPacketGetNextPacket ()
 
bool GotEntry (uint32_t ssrc)
 
RTPSourceDataGetOwnSourceInfo ()
 
void Timeout (const RTPTime &curtime, const RTPTime &timeoutdelay)
 
void SenderTimeout (const RTPTime &curtime, const RTPTime &timeoutdelay)
 
void BYETimeout (const RTPTime &curtime, const RTPTime &timeoutdelay)
 
void NoteTimeout (const RTPTime &curtime, const RTPTime &timeoutdelay)
 
void MultipleTimeouts (const RTPTime &curtime, const RTPTime &sendertimeout, const RTPTime &byetimeout, const RTPTime &generaltimeout, const RTPTime &notetimeout)
 
int GetSenderCount () const
 
int GetTotalCount () const
 
int GetActiveMemberCount () const
 

Protected Member Functions

virtual void OnRTPPacket (RTPPacket *pack, const RTPTime &receivetime, const RTPAddress *senderaddress)
 
virtual void OnRTCPCompoundPacket (RTCPCompoundPacket *pack, const RTPTime &receivetime, const RTPAddress *senderaddress)
 
virtual void OnSSRCCollision (RTPSourceData *srcdat, const RTPAddress *senderaddress, bool isrtp)
 
virtual void OnCNAMECollision (RTPSourceData *srcdat, const RTPAddress *senderaddress, const uint8_t *cname, std::size_t cnamelength)
 
virtual void OnNewSource (RTPSourceData *srcdat)
 
virtual void OnRemoveSource (RTPSourceData *srcdat)
 
virtual void OnTimeout (RTPSourceData *srcdat)
 
virtual void OnBYETimeout (RTPSourceData *srcdat)
 
virtual void OnBYEPacket (RTPSourceData *srcdat)
 
virtual void OnRTCPSenderReport (RTPSourceData *srcdat)
 
virtual void OnRTCPReceiverReport (RTPSourceData *srcdat)
 
virtual void OnRTCPSDESItem (RTPSourceData *srcdat, RTCPSDESPacket::ItemType t, const void *itemdata, std::size_t itemlength)
 
virtual void OnRTCPSDESPrivateItem (RTPSourceData *srcdat, const void *prefixdata, std::size_t prefixlen, const void *valuedata, std::size_t valuelen)
 
virtual void OnAPPPacket (RTCPAPPPacket *apppacket, const RTPTime &receivetime, const RTPAddress *senderaddress)
 
virtual void OnUnknownPacketType (RTCPPacket *rtcppack, const RTPTime &receivetime, const RTPAddress *senderaddress)
 
virtual void OnUnknownPacketFormat (RTCPPacket *rtcppack, const RTPTime &receivetime, const RTPAddress *senderaddress)
 
virtual void OnNoteTimeout (RTPSourceData *srcdat)
 
virtual void OnValidatedRTPPacket (RTPSourceData *srcdat, RTPPacket *rtppack, bool isonprobation, bool *ispackethandled)
 

Private Member Functions

void ClearSourceList ()
 
int ObtainSourceDataInstance (uint32_t ssrc, RTPInternalSourceData **srcdat, bool *created)
 
int GetRTCPSourceData (uint32_t ssrc, const RTPAddress *senderaddress, RTPInternalSourceData **srcdat, bool *newsource)
 
bool CheckCollision (RTPInternalSourceData *srcdat, const RTPAddress *senderaddress, bool isrtp)
 

Private Attributes

RTPKeyHashTable< const uint32_t, RTPInternalSourceData *, RTPSources_GetHashIndex, RTPSOURCES_HASHSIZEsourcelist
 
int sendercount
 
int totalcount
 
int activecount
 
RTPInternalSourceDataowndata
 

Friends

class RTPInternalSourceData
 

Detailed Description

Represents a table in which information about the participating sources is kept. Represents a table in which information about the participating sources is kept. The class has member functions to process RTP and RTCP data and to iterate over the participants. Note that a NULL address is used to identify packets from our own session. The class also provides some overridable functions which can be used to catch certain events (new SSRC, SSRC collision, ...).

Definition at line 78 of file rtpsources.h.

Member Enumeration Documentation

◆ ProbationType

Type of probation to use for new sources.

Enumerator
NoProbation 

Don't use the probation algorithm; accept RTP packets immediately.

ProbationDiscard 

Discard incoming RTP packets originating from a source that's on probation.

ProbationStore 

Store incoming RTP packet from a source that's on probation for later retrieval.

Definition at line 82 of file rtpsources.h.

Constructor & Destructor Documentation

◆ RTPSources()

qrtplib::RTPSources::RTPSources ( )

In the constructor you can select the probation type you'd like to use and also a memory manager.

Definition at line 51 of file rtpsources.cpp.

References activecount, owndata, sendercount, and totalcount.

52 {
53  totalcount = 0;
54  sendercount = 0;
55  activecount = 0;
56  owndata = 0;
57 }
RTPInternalSourceData * owndata
Definition: rtpsources.h:368

◆ ~RTPSources()

qrtplib::RTPSources::~RTPSources ( )
virtual

Definition at line 59 of file rtpsources.cpp.

References Clear().

60 {
61  Clear();
62 }
+ Here is the call graph for this function:

Member Function Documentation

◆ BYETimeout()

void qrtplib::RTPSources::BYETimeout ( const RTPTime curtime,
const RTPTime timeoutdelay 
)

Assuming that the current time is curtime, remove the members who sent a BYE packet more than the time interval timeoutdelay ago.

Definition at line 960 of file rtpsources.cpp.

References activecount, qrtplib::RTPSourceData::GetBYETime(), qrtplib::RTPSourceData::IsActive(), qrtplib::RTPSourceData::IsSender(), OnBYETimeout(), OnRemoveSource(), owndata, qrtplib::RTPSourceData::ReceivedBYE(), sendercount, sourcelist, and totalcount.

961 {
962  int newtotalcount = 0;
963  int newsendercount = 0;
964  int newactivecount = 0;
965  RTPTime checktime = curtime;
966  checktime -= timeoutdelay;
967 
968  sourcelist.GotoFirstElement();
969  while (sourcelist.HasCurrentElement())
970  {
971  RTPInternalSourceData *srcdat = sourcelist.GetCurrentElement();
972 
973  if (srcdat->ReceivedBYE())
974  {
975  RTPTime byetime = srcdat->GetBYETime();
976 
977  if ((srcdat != owndata) && (checktime > byetime))
978  {
979  totalcount--;
980  if (srcdat->IsSender())
981  sendercount--;
982  if (srcdat->IsActive())
983  activecount--;
984  sourcelist.DeleteCurrentElement();
985  OnBYETimeout(srcdat);
986  OnRemoveSource(srcdat);
987  delete srcdat;
988  }
989  else
990  {
991  newtotalcount++;
992  if (srcdat->IsSender())
993  newsendercount++;
994  if (srcdat->IsActive())
995  newactivecount++;
996  sourcelist.GotoNextElement();
997  }
998  }
999  else
1000  {
1001  newtotalcount++;
1002  if (srcdat->IsSender())
1003  newsendercount++;
1004  if (srcdat->IsActive())
1005  newactivecount++;
1006  sourcelist.GotoNextElement();
1007  }
1008  }
1009 
1010  totalcount = newtotalcount; // just to play it safe
1011  sendercount = newsendercount;
1012  activecount = newactivecount;
1013 }
RTPInternalSourceData * owndata
Definition: rtpsources.h:368
RTPKeyHashTable< const uint32_t, RTPInternalSourceData *, RTPSources_GetHashIndex, RTPSOURCES_HASHSIZE > sourcelist
Definition: rtpsources.h:362
virtual void OnBYETimeout(RTPSourceData *srcdat)
Definition: rtpsources.h:395
friend class RTPInternalSourceData
Definition: rtpsources.h:370
virtual void OnRemoveSource(RTPSourceData *srcdat)
Definition: rtpsources.h:389
+ Here is the call graph for this function:

◆ CheckCollision()

bool qrtplib::RTPSources::CheckCollision ( RTPInternalSourceData srcdat,
const RTPAddress senderaddress,
bool  isrtp 
)
private

Definition at line 1168 of file rtpsources.cpp.

References qrtplib::RTPSourceData::GetRTCPDataAddress(), qrtplib::RTPSourceData::GetRTPDataAddress(), qrtplib::RTPAddress::IsFromSameHost(), qrtplib::RTPSourceData::IsRTCPAddressSet(), qrtplib::RTPSourceData::IsRTPAddressSet(), qrtplib::RTPAddress::IsSameAddress(), OnSSRCCollision(), qrtplib::RTPInternalSourceData::SetRTCPDataAddress(), and qrtplib::RTPInternalSourceData::SetRTPDataAddress().

Referenced by GetRTCPSourceData(), and ProcessRTPPacket().

1169 {
1170  bool isset, otherisset;
1171  const RTPAddress *addr, *otheraddr;
1172 
1173  if (isrtp)
1174  {
1175  isset = srcdat->IsRTPAddressSet();
1176  addr = srcdat->GetRTPDataAddress();
1177  otherisset = srcdat->IsRTCPAddressSet();
1178  otheraddr = srcdat->GetRTCPDataAddress();
1179  }
1180  else
1181  {
1182  isset = srcdat->IsRTCPAddressSet();
1183  addr = srcdat->GetRTCPDataAddress();
1184  otherisset = srcdat->IsRTPAddressSet();
1185  otheraddr = srcdat->GetRTPDataAddress();
1186  }
1187 
1188  if (!isset)
1189  {
1190  if (otherisset) // got other address, can check if it comes from same host
1191  {
1192  if (otheraddr == 0) // other came from our own session
1193  {
1194  if (senderaddress != 0)
1195  {
1196  OnSSRCCollision(srcdat, senderaddress, isrtp);
1197  return true;
1198  }
1199 
1200  // Ok, store it
1201 
1202  if (isrtp)
1203  srcdat->SetRTPDataAddress(senderaddress);
1204  else
1205  srcdat->SetRTCPDataAddress(senderaddress);
1206  }
1207  else
1208  {
1209  if (!otheraddr->IsFromSameHost(senderaddress))
1210  {
1211  OnSSRCCollision(srcdat, senderaddress, isrtp);
1212  return true;
1213  }
1214 
1215  // Ok, comes from same host, store the address
1216 
1217  if (isrtp)
1218  srcdat->SetRTPDataAddress(senderaddress);
1219  else
1220  srcdat->SetRTCPDataAddress(senderaddress);
1221  }
1222  }
1223  else // no other address, store this one
1224  {
1225  if (isrtp)
1226  srcdat->SetRTPDataAddress(senderaddress);
1227  else
1228  srcdat->SetRTCPDataAddress(senderaddress);
1229  }
1230  }
1231  else // already got an address
1232  {
1233  if (addr == 0)
1234  {
1235  if (senderaddress != 0)
1236  {
1237  OnSSRCCollision(srcdat, senderaddress, isrtp);
1238  return true;
1239  }
1240  }
1241  else
1242  {
1243  if (!addr->IsSameAddress(senderaddress))
1244  {
1245  OnSSRCCollision(srcdat, senderaddress, isrtp);
1246  return true;
1247  }
1248  }
1249  }
1250 
1251  return false;
1252 }
virtual void OnSSRCCollision(RTPSourceData *srcdat, const RTPAddress *senderaddress, bool isrtp)
Definition: rtpsources.h:380
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Clear()

void qrtplib::RTPSources::Clear ( )

Clears the source table.

Definition at line 64 of file rtpsources.cpp.

References ClearSourceList().

Referenced by qrtplib::RTPSession::BYEDestroy(), qrtplib::RTPSession::Destroy(), qrtplib::RTPSession::InternalCreate(), and ~RTPSources().

65 {
67 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ClearSourceList()

void qrtplib::RTPSources::ClearSourceList ( )
private

Definition at line 69 of file rtpsources.cpp.

References activecount, owndata, sendercount, sourcelist, and totalcount.

Referenced by Clear().

70 {
71  sourcelist.GotoFirstElement();
72  while (sourcelist.HasCurrentElement())
73  {
74  RTPInternalSourceData *sourcedata;
75 
76  sourcedata = sourcelist.GetCurrentElement();
77  delete sourcedata;
78  sourcelist.GotoNextElement();
79  }
80  sourcelist.Clear();
81  owndata = 0;
82  totalcount = 0;
83  sendercount = 0;
84  activecount = 0;
85 }
RTPInternalSourceData * owndata
Definition: rtpsources.h:368
RTPKeyHashTable< const uint32_t, RTPInternalSourceData *, RTPSources_GetHashIndex, RTPSOURCES_HASHSIZE > sourcelist
Definition: rtpsources.h:362
friend class RTPInternalSourceData
Definition: rtpsources.h:370
+ Here is the caller graph for this function:

◆ CreateOwnSSRC()

int qrtplib::RTPSources::CreateOwnSSRC ( uint32_t  ssrc)

Creates an entry for our own SSRC identifier.

Definition at line 87 of file rtpsources.cpp.

References activecount, ERR_RTP_SOURCES_ALREADYHAVEOWNSSRC, ERR_RTP_SOURCES_SSRCEXISTS, GotEntry(), ObtainSourceDataInstance(), OnNewSource(), owndata, qrtplib::RTPInternalSourceData::SetOwnSSRC(), qrtplib::RTPInternalSourceData::SetRTCPDataAddress(), and qrtplib::RTPInternalSourceData::SetRTPDataAddress().

Referenced by qrtplib::RTPSession::InternalCreate(), and qrtplib::RTPSession::ProcessPolledData().

88 {
89  if (owndata != 0)
91  if (GotEntry(ssrc))
93 
94  int status;
95  bool created;
96 
97  status = ObtainSourceDataInstance(ssrc, &owndata, &created);
98  if (status < 0)
99  {
100  owndata = 0; // just to make sure
101  return status;
102  }
103  owndata->SetOwnSSRC();
106 
107  // we've created a validated ssrc, so we should increase activecount
108  activecount++;
109 
111  return 0;
112 }
#define ERR_RTP_SOURCES_ALREADYHAVEOWNSSRC
Definition: rtperrors.h:117
int SetRTCPDataAddress(const RTPAddress *a)
RTPInternalSourceData * owndata
Definition: rtpsources.h:368
int ObtainSourceDataInstance(uint32_t ssrc, RTPInternalSourceData **srcdat, bool *created)
Definition: rtpsources.cpp:802
#define ERR_RTP_SOURCES_SSRCEXISTS
Definition: rtperrors.h:120
virtual void OnNewSource(RTPSourceData *srcdat)
Definition: rtpsources.h:386
bool GotEntry(uint32_t ssrc)
Definition: rtpsources.cpp:625
int SetRTPDataAddress(const RTPAddress *a)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DeleteOwnSSRC()

int qrtplib::RTPSources::DeleteOwnSSRC ( )

Deletes the entry for our own SSRC identifier.

Definition at line 114 of file rtpsources.cpp.

References activecount, ERR_RTP_SOURCES_DONTHAVEOWNSSRC, qrtplib::RTPSourceData::GetSSRC(), qrtplib::RTPSourceData::IsActive(), qrtplib::RTPSourceData::IsSender(), OnRemoveSource(), owndata, sendercount, sourcelist, and totalcount.

Referenced by qrtplib::RTPSession::ProcessPolledData().

115 {
116  if (owndata == 0)
118 
119  uint32_t ssrc = owndata->GetSSRC();
120 
121  sourcelist.GotoElement(ssrc);
122  sourcelist.DeleteCurrentElement();
123 
124  totalcount--;
125  if (owndata->IsSender())
126  sendercount--;
127  if (owndata->IsActive())
128  activecount--;
129 
131 
132  delete owndata;
133  owndata = 0;
134  return 0;
135 }
#define ERR_RTP_SOURCES_DONTHAVEOWNSSRC
Definition: rtperrors.h:118
RTPInternalSourceData * owndata
Definition: rtpsources.h:368
unsigned int uint32_t
Definition: rtptypes_win.h:46
RTPKeyHashTable< const uint32_t, RTPInternalSourceData *, RTPSources_GetHashIndex, RTPSOURCES_HASHSIZE > sourcelist
Definition: rtpsources.h:362
uint32_t GetSSRC() const
virtual void OnRemoveSource(RTPSourceData *srcdat)
Definition: rtpsources.h:389
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetActiveMemberCount()

int qrtplib::RTPSources::GetActiveMemberCount ( ) const
inline

Returns the number of members which have been validated and which haven't sent a BYE packet yet.

Definition at line 287 of file rtpsources.h.

Referenced by qrtplib::RTCPScheduler::ActiveMemberDecrease(), qrtplib::RTCPScheduler::CalculateDeterministicInterval(), qrtplib::RTCPScheduler::GetTransmissionDelay(), qrtplib::RTCPScheduler::IsTime(), qrtplib::RTCPScheduler::PerformReverseReconsideration(), and qrtplib::RTCPScheduler::ScheduleBYEPacket().

288  {
289  return activecount;
290  }
+ Here is the caller graph for this function:

◆ GetCurrentSourceInfo()

RTPSourceData * qrtplib::RTPSources::GetCurrentSourceInfo ( )

Returns the RTPSourceData instance for the currently selected participant.

Definition at line 609 of file rtpsources.cpp.

References sourcelist.

Referenced by qrtplib::RTCPPacketBuilder::ClearAllSourceFlags(), qrtplib::RTCPPacketBuilder::FillInReportBlocks(), and qrtplib::RTPSession::GetCurrentSourceInfo().

610 {
611  if (!sourcelist.HasCurrentElement())
612  return 0;
613  return sourcelist.GetCurrentElement();
614 }
RTPKeyHashTable< const uint32_t, RTPInternalSourceData *, RTPSources_GetHashIndex, RTPSOURCES_HASHSIZE > sourcelist
Definition: rtpsources.h:362
+ Here is the caller graph for this function:

◆ GetNextPacket()

RTPPacket * qrtplib::RTPSources::GetNextPacket ( )

Extracts the next packet from the received packets queue of the current participant.

Definition at line 630 of file rtpsources.cpp.

References qrtplib::RTPSourceData::GetNextPacket(), and sourcelist.

Referenced by qrtplib::RTPSession::GetNextPacket().

631 {
632  if (!sourcelist.HasCurrentElement())
633  return 0;
634 
635  RTPInternalSourceData *srcdat = sourcelist.GetCurrentElement();
636  RTPPacket *pack = srcdat->GetNextPacket();
637  return pack;
638 }
RTPKeyHashTable< const uint32_t, RTPInternalSourceData *, RTPSources_GetHashIndex, RTPSOURCES_HASHSIZE > sourcelist
Definition: rtpsources.h:362
friend class RTPInternalSourceData
Definition: rtpsources.h:370
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetOwnSourceInfo()

RTPSourceData* qrtplib::RTPSources::GetOwnSourceInfo ( )
inline

If present, it returns the RTPSourceData instance of the entry which was created by CreateOwnSSRC.

Definition at line 243 of file rtpsources.h.

Referenced by qrtplib::RTCPPacketBuilder::BuildBYEPacket(), qrtplib::RTCPPacketBuilder::BuildNextPacket(), qrtplib::RTCPScheduler::CalculateNextRTCPTime(), and qrtplib::RTCPScheduler::IsTime().

244  {
245  return (RTPSourceData *) owndata;
246  }
RTPInternalSourceData * owndata
Definition: rtpsources.h:368
+ Here is the caller graph for this function:

◆ GetRTCPSourceData()

int qrtplib::RTPSources::GetRTCPSourceData ( uint32_t  ssrc,
const RTPAddress senderaddress,
RTPInternalSourceData **  srcdat,
bool *  newsource 
)
private

Definition at line 827 of file rtpsources.cpp.

References CheckCollision(), ObtainSourceDataInstance(), and qrtplib::RTPInternalSourceData::SetRTCPDataAddress().

Referenced by ProcessBYE(), ProcessRTCPReportBlock(), ProcessRTCPSenderInfo(), ProcessSDESNormalItem(), ProcessSDESPrivateItem(), and UpdateReceiveTime().

828 {
829  int status;
830  bool created;
831  RTPInternalSourceData *srcdat;
832 
833  *srcdat2 = 0;
834 
835  if ((status = ObtainSourceDataInstance(ssrc, &srcdat, &created)) < 0)
836  return status;
837 
838  if (created)
839  {
840  if ((status = srcdat->SetRTCPDataAddress(senderaddress)) < 0)
841  return status;
842  }
843  else // got a previously existing source
844  {
845  if (CheckCollision(srcdat, senderaddress, false))
846  return 0; // ignore packet on collision
847  }
848 
849  *srcdat2 = srcdat;
850  *newsource = created;
851 
852  return 0;
853 }
bool CheckCollision(RTPInternalSourceData *srcdat, const RTPAddress *senderaddress, bool isrtp)
int ObtainSourceDataInstance(uint32_t ssrc, RTPInternalSourceData **srcdat, bool *created)
Definition: rtpsources.cpp:802
friend class RTPInternalSourceData
Definition: rtpsources.h:370
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetSenderCount()

int qrtplib::RTPSources::GetSenderCount ( ) const
inline

Returns the number of participants which are marked as a sender.

Definition at line 275 of file rtpsources.h.

Referenced by qrtplib::RTCPScheduler::CalculateDeterministicInterval().

276  {
277  return sendercount;
278  }
+ Here is the caller graph for this function:

◆ GetSourceInfo()

RTPSourceData * qrtplib::RTPSources::GetSourceInfo ( uint32_t  ssrc)

Returns the RTPSourceData instance for the participant identified by ssrc, or NULL if no such entry exists.

Definition at line 616 of file rtpsources.cpp.

References sourcelist.

Referenced by qrtplib::RTPSession::GetSourceInfo().

617 {
618  if (sourcelist.GotoElement(ssrc) < 0)
619  return 0;
620  if (!sourcelist.HasCurrentElement())
621  return 0;
622  return sourcelist.GetCurrentElement();
623 }
RTPKeyHashTable< const uint32_t, RTPInternalSourceData *, RTPSources_GetHashIndex, RTPSOURCES_HASHSIZE > sourcelist
Definition: rtpsources.h:362
+ Here is the caller graph for this function:

◆ GetTotalCount()

int qrtplib::RTPSources::GetTotalCount ( ) const
inline

Returns the total number of entries in the source table.

Definition at line 281 of file rtpsources.h.

Referenced by qrtplib::RTCPPacketBuilder::BuildNextPacket().

282  {
283  return totalcount;
284  }
+ Here is the caller graph for this function:

◆ GotEntry()

bool qrtplib::RTPSources::GotEntry ( uint32_t  ssrc)

Returns true if an entry for participant ssrc exists and false otherwise.

Definition at line 625 of file rtpsources.cpp.

References sourcelist.

Referenced by qrtplib::RTPPacketBuilder::CreateNewSSRC(), and CreateOwnSSRC().

626 {
627  return sourcelist.HasElement(ssrc);
628 }
RTPKeyHashTable< const uint32_t, RTPInternalSourceData *, RTPSources_GetHashIndex, RTPSOURCES_HASHSIZE > sourcelist
Definition: rtpsources.h:362
+ Here is the caller graph for this function:

◆ GotoFirstSource()

bool qrtplib::RTPSources::GotoFirstSource ( )

Starts the iteration over the participants by going to the first member in the table. Starts the iteration over the participants by going to the first member in the table. If a member was found, the function returns true, otherwise it returns false.

Definition at line 528 of file rtpsources.cpp.

References sourcelist.

Referenced by qrtplib::RTCPPacketBuilder::ClearAllSourceFlags(), qrtplib::RTCPPacketBuilder::FillInReportBlocks(), and qrtplib::RTPSession::GotoFirstSource().

529 {
530  sourcelist.GotoFirstElement();
531  if (sourcelist.HasCurrentElement())
532  return true;
533  return false;
534 }
RTPKeyHashTable< const uint32_t, RTPInternalSourceData *, RTPSources_GetHashIndex, RTPSOURCES_HASHSIZE > sourcelist
Definition: rtpsources.h:362
+ Here is the caller graph for this function:

◆ GotoFirstSourceWithData()

bool qrtplib::RTPSources::GotoFirstSourceWithData ( )

Sets the current source to be the first source in the table which has RTPPacket instances that we haven't extracted yet. Sets the current source to be the first source in the table which has RTPPacket instances that we haven't extracted yet. If no such member was found, the function returns false, otherwise it returns true.

Definition at line 552 of file rtpsources.cpp.

References qrtplib::RTPSourceData::HasData(), and sourcelist.

Referenced by qrtplib::RTPSession::GotoFirstSourceWithData().

553 {
554  bool found = false;
555 
556  sourcelist.GotoFirstElement();
557  while (!found && sourcelist.HasCurrentElement())
558  {
559  RTPInternalSourceData *srcdat;
560 
561  srcdat = sourcelist.GetCurrentElement();
562  if (srcdat->HasData())
563  found = true;
564  else
565  sourcelist.GotoNextElement();
566  }
567 
568  return found;
569 }
RTPKeyHashTable< const uint32_t, RTPInternalSourceData *, RTPSources_GetHashIndex, RTPSOURCES_HASHSIZE > sourcelist
Definition: rtpsources.h:362
friend class RTPInternalSourceData
Definition: rtpsources.h:370
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GotoNextSource()

bool qrtplib::RTPSources::GotoNextSource ( )

Sets the current source to be the next source in the table. Sets the current source to be the next source in the table. If we're already at the last source, the function returns false, otherwise it returns true.

Definition at line 536 of file rtpsources.cpp.

References sourcelist.

Referenced by qrtplib::RTCPPacketBuilder::ClearAllSourceFlags(), qrtplib::RTCPPacketBuilder::FillInReportBlocks(), and qrtplib::RTPSession::GotoNextSource().

537 {
538  sourcelist.GotoNextElement();
539  if (sourcelist.HasCurrentElement())
540  return true;
541  return false;
542 }
RTPKeyHashTable< const uint32_t, RTPInternalSourceData *, RTPSources_GetHashIndex, RTPSOURCES_HASHSIZE > sourcelist
Definition: rtpsources.h:362
+ Here is the caller graph for this function:

◆ GotoNextSourceWithData()

bool qrtplib::RTPSources::GotoNextSourceWithData ( )

Sets the current source to be the next source in the table which has RTPPacket instances that we haven't extracted yet. Sets the current source to be the next source in the table which has RTPPacket instances that we haven't extracted yet. If no such member was found, the function returns false, otherwise it returns true.

Definition at line 571 of file rtpsources.cpp.

References qrtplib::RTPSourceData::HasData(), and sourcelist.

Referenced by qrtplib::RTPSession::GotoNextSourceWithData().

572 {
573  bool found = false;
574 
575  sourcelist.GotoNextElement();
576  while (!found && sourcelist.HasCurrentElement())
577  {
578  RTPInternalSourceData *srcdat;
579 
580  srcdat = sourcelist.GetCurrentElement();
581  if (srcdat->HasData())
582  found = true;
583  else
584  sourcelist.GotoNextElement();
585  }
586 
587  return found;
588 }
RTPKeyHashTable< const uint32_t, RTPInternalSourceData *, RTPSources_GetHashIndex, RTPSOURCES_HASHSIZE > sourcelist
Definition: rtpsources.h:362
friend class RTPInternalSourceData
Definition: rtpsources.h:370
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GotoPreviousSource()

bool qrtplib::RTPSources::GotoPreviousSource ( )

Sets the current source to be the previous source in the table. Sets the current source to be the previous source in the table. If we're at the first source, the function returns false, otherwise it returns true.

Definition at line 544 of file rtpsources.cpp.

References sourcelist.

Referenced by qrtplib::RTPSession::GotoPreviousSource().

545 {
546  sourcelist.GotoPreviousElement();
547  if (sourcelist.HasCurrentElement())
548  return true;
549  return false;
550 }
RTPKeyHashTable< const uint32_t, RTPInternalSourceData *, RTPSources_GetHashIndex, RTPSOURCES_HASHSIZE > sourcelist
Definition: rtpsources.h:362
+ Here is the caller graph for this function:

◆ GotoPreviousSourceWithData()

bool qrtplib::RTPSources::GotoPreviousSourceWithData ( )

Sets the current source to be the previous source in the table which has RTPPacket instances that we haven't extracted yet. Sets the current source to be the previous source in the table which has RTPPacket instances that we haven't extracted yet. If no such member was found, the function returns false, otherwise it returns true.

Definition at line 590 of file rtpsources.cpp.

References qrtplib::RTPSourceData::HasData(), and sourcelist.

Referenced by qrtplib::RTPSession::GotoPreviousSourceWithData().

591 {
592  bool found = false;
593 
594  sourcelist.GotoPreviousElement();
595  while (!found && sourcelist.HasCurrentElement())
596  {
597  RTPInternalSourceData *srcdat;
598 
599  srcdat = sourcelist.GetCurrentElement();
600  if (srcdat->HasData())
601  found = true;
602  else
603  sourcelist.GotoPreviousElement();
604  }
605 
606  return found;
607 }
RTPKeyHashTable< const uint32_t, RTPInternalSourceData *, RTPSources_GetHashIndex, RTPSOURCES_HASHSIZE > sourcelist
Definition: rtpsources.h:362
friend class RTPInternalSourceData
Definition: rtpsources.h:370
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MultipleTimeouts()

void qrtplib::RTPSources::MultipleTimeouts ( const RTPTime curtime,
const RTPTime sendertimeout,
const RTPTime byetimeout,
const RTPTime generaltimeout,
const RTPTime notetimeout 
)

Combines the functions SenderTimeout, BYETimeout, Timeout and NoteTimeout. Combines the functions SenderTimeout, BYETimeout, Timeout and NoteTimeout. This is more efficient than calling all four functions since only one iteration is needed in this function.

Definition at line 1055 of file rtpsources.cpp.

References activecount, qrtplib::RTPInternalSourceData::ClearNote(), qrtplib::RTPInternalSourceData::ClearSenderFlag(), qrtplib::RTPSourceData::GetBYETime(), qrtplib::RTPSourceData::INF_GetLastMessageTime(), qrtplib::RTPSourceData::INF_GetLastRTPPacketTime(), qrtplib::RTPSourceData::INF_GetLastSDESNoteTime(), qrtplib::RTPSourceData::IsActive(), qrtplib::RTPSourceData::IsSender(), OnBYETimeout(), OnNoteTimeout(), OnRemoveSource(), OnTimeout(), owndata, qrtplib::RTPSourceData::ReceivedBYE(), qrtplib::RTPSourceData::SDES_GetNote(), sendercount, sourcelist, and totalcount.

Referenced by qrtplib::RTPSession::ProcessPolledData().

1056 {
1057  int newtotalcount = 0;
1058  int newsendercount = 0;
1059  int newactivecount = 0;
1060  RTPTime senderchecktime = curtime;
1061  RTPTime byechecktime = curtime;
1062  RTPTime generaltchecktime = curtime;
1063  RTPTime notechecktime = curtime;
1064  senderchecktime -= sendertimeout;
1065  byechecktime -= byetimeout;
1066  generaltchecktime -= generaltimeout;
1067  notechecktime -= notetimeout;
1068 
1069  sourcelist.GotoFirstElement();
1070  while (sourcelist.HasCurrentElement())
1071  {
1072  RTPInternalSourceData *srcdat = sourcelist.GetCurrentElement();
1073  bool deleted, issender, isactive;
1074  bool byetimeout, normaltimeout, notetimeout;
1075 
1076  std::size_t notelen;
1077 
1078  issender = srcdat->IsSender();
1079  isactive = srcdat->IsActive();
1080  deleted = false;
1081  byetimeout = false;
1082  normaltimeout = false;
1083  notetimeout = false;
1084 
1085  srcdat->SDES_GetNote(&notelen);
1086  if (notelen != 0) // Note has been set
1087  {
1088  RTPTime notetime = srcdat->INF_GetLastSDESNoteTime();
1089 
1090  if (notechecktime > notetime)
1091  {
1092  notetimeout = true;
1093  srcdat->ClearNote();
1094  }
1095  }
1096 
1097  if (srcdat->ReceivedBYE())
1098  {
1099  RTPTime byetime = srcdat->GetBYETime();
1100 
1101  if ((srcdat != owndata) && (byechecktime > byetime))
1102  {
1103  sourcelist.DeleteCurrentElement();
1104  deleted = true;
1105  byetimeout = true;
1106  }
1107  }
1108 
1109  if (!deleted)
1110  {
1111  RTPTime lastmsgtime = srcdat->INF_GetLastMessageTime();
1112 
1113  if ((srcdat != owndata) && (lastmsgtime < generaltchecktime))
1114  {
1115  sourcelist.DeleteCurrentElement();
1116  deleted = true;
1117  normaltimeout = true;
1118  }
1119  }
1120 
1121  if (!deleted)
1122  {
1123  newtotalcount++;
1124 
1125  if (issender)
1126  {
1127  RTPTime lastrtppacktime = srcdat->INF_GetLastRTPPacketTime();
1128 
1129  if (lastrtppacktime < senderchecktime)
1130  {
1131  srcdat->ClearSenderFlag();
1132  sendercount--;
1133  }
1134  else
1135  newsendercount++;
1136  }
1137 
1138  if (isactive)
1139  newactivecount++;
1140 
1141  if (notetimeout)
1142  OnNoteTimeout(srcdat);
1143 
1144  sourcelist.GotoNextElement();
1145  }
1146  else // deleted entry
1147  {
1148  if (issender)
1149  sendercount--;
1150  if (isactive)
1151  activecount--;
1152  totalcount--;
1153 
1154  if (byetimeout)
1155  OnBYETimeout(srcdat);
1156  if (normaltimeout)
1157  OnTimeout(srcdat);
1158  OnRemoveSource(srcdat);
1159  delete srcdat;
1160  }
1161  }
1162 
1163  totalcount = newtotalcount; // just to play it safe
1164  sendercount = newsendercount;
1165  activecount = newactivecount;
1166 }
virtual void OnNoteTimeout(RTPSourceData *srcdat)
Definition: rtpsources.h:424
RTPInternalSourceData * owndata
Definition: rtpsources.h:368
RTPKeyHashTable< const uint32_t, RTPInternalSourceData *, RTPSources_GetHashIndex, RTPSOURCES_HASHSIZE > sourcelist
Definition: rtpsources.h:362
virtual void OnBYETimeout(RTPSourceData *srcdat)
Definition: rtpsources.h:395
friend class RTPInternalSourceData
Definition: rtpsources.h:370
virtual void OnTimeout(RTPSourceData *srcdat)
Definition: rtpsources.h:392
virtual void OnRemoveSource(RTPSourceData *srcdat)
Definition: rtpsources.h:389
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ NoteTimeout()

void qrtplib::RTPSources::NoteTimeout ( const RTPTime curtime,
const RTPTime timeoutdelay 
)

Assuming that the current time is curtime, clear the SDES NOTE items which haven't been updated during the previous time interval timeoutdelay.

Definition at line 1015 of file rtpsources.cpp.

References activecount, qrtplib::RTPInternalSourceData::ClearNote(), qrtplib::RTPSourceData::INF_GetLastSDESNoteTime(), qrtplib::RTPSourceData::IsActive(), qrtplib::RTPSourceData::IsSender(), OnNoteTimeout(), qrtplib::RTPSourceData::SDES_GetNote(), sendercount, sourcelist, and totalcount.

1016 {
1017  int newtotalcount = 0;
1018  int newsendercount = 0;
1019  int newactivecount = 0;
1020  RTPTime checktime = curtime;
1021  checktime -= timeoutdelay;
1022 
1023  sourcelist.GotoFirstElement();
1024  while (sourcelist.HasCurrentElement())
1025  {
1026  RTPInternalSourceData *srcdat = sourcelist.GetCurrentElement();
1027  std::size_t notelen;
1028 
1029  srcdat->SDES_GetNote(&notelen);
1030  if (notelen != 0) // Note has been set
1031  {
1032  RTPTime notetime = srcdat->INF_GetLastSDESNoteTime();
1033 
1034  if (checktime > notetime)
1035  {
1036  srcdat->ClearNote();
1037  OnNoteTimeout(srcdat);
1038  }
1039  }
1040 
1041  newtotalcount++;
1042  if (srcdat->IsSender())
1043  newsendercount++;
1044  if (srcdat->IsActive())
1045  newactivecount++;
1046  sourcelist.GotoNextElement();
1047  }
1048 
1049  totalcount = newtotalcount; // just to play it safe
1050  sendercount = newsendercount;
1051  activecount = newactivecount;
1052 
1053 }
virtual void OnNoteTimeout(RTPSourceData *srcdat)
Definition: rtpsources.h:424
RTPKeyHashTable< const uint32_t, RTPInternalSourceData *, RTPSources_GetHashIndex, RTPSOURCES_HASHSIZE > sourcelist
Definition: rtpsources.h:362
friend class RTPInternalSourceData
Definition: rtpsources.h:370
+ Here is the call graph for this function:

◆ ObtainSourceDataInstance()

int qrtplib::RTPSources::ObtainSourceDataInstance ( uint32_t  ssrc,
RTPInternalSourceData **  srcdat,
bool *  created 
)
private

Definition at line 802 of file rtpsources.cpp.

References RTPInternalSourceData, sourcelist, and totalcount.

Referenced by CreateOwnSSRC(), GetRTCPSourceData(), and ProcessRTPPacket().

803 {
804  RTPInternalSourceData *srcdat2;
805  int status;
806 
807  if (sourcelist.GotoElement(ssrc) < 0) // No entry for this source
808  {
809  srcdat2 = new RTPInternalSourceData(ssrc);
810  if ((status = sourcelist.AddElement(ssrc, srcdat2)) < 0)
811  {
812  delete srcdat2;
813  return status;
814  }
815  *srcdat = srcdat2;
816  *created = true;
817  totalcount++;
818  }
819  else
820  {
821  *srcdat = sourcelist.GetCurrentElement();
822  *created = false;
823  }
824  return 0;
825 }
RTPKeyHashTable< const uint32_t, RTPInternalSourceData *, RTPSources_GetHashIndex, RTPSOURCES_HASHSIZE > sourcelist
Definition: rtpsources.h:362
friend class RTPInternalSourceData
Definition: rtpsources.h:370
+ Here is the caller graph for this function:

◆ OnAPPPacket()

void qrtplib::RTPSources::OnAPPPacket ( RTCPAPPPacket apppacket,
const RTPTime receivetime,
const RTPAddress senderaddress 
)
inlineprotectedvirtual

Is called when an RTCP APP packet apppacket has been received at time receivetime from address senderaddress.

Reimplemented in qrtplib::RTPSessionSources.

Definition at line 415 of file rtpsources.h.

Referenced by ProcessRTCPCompoundPacket().

416 {
417 }
+ Here is the caller graph for this function:

◆ OnBYEPacket()

void qrtplib::RTPSources::OnBYEPacket ( RTPSourceData srcdat)
inlineprotectedvirtual

Is called when a BYE packet has been processed for source srcdat.

Reimplemented in qrtplib::RTPSessionSources.

Definition at line 398 of file rtpsources.h.

Referenced by ProcessBYE().

399 {
400 }
+ Here is the caller graph for this function:

◆ OnBYETimeout()

void qrtplib::RTPSources::OnBYETimeout ( RTPSourceData srcdat)
inlineprotectedvirtual

Is called when participant srcdat is timed after having sent a BYE packet.

Reimplemented in qrtplib::RTPSessionSources.

Definition at line 395 of file rtpsources.h.

Referenced by BYETimeout(), and MultipleTimeouts().

396 {
397 }
+ Here is the caller graph for this function:

◆ OnCNAMECollision()

void qrtplib::RTPSources::OnCNAMECollision ( RTPSourceData srcdat,
const RTPAddress senderaddress,
const uint8_t cname,
std::size_t  cnamelength 
)
inlineprotectedvirtual

Is called when another CNAME was received than the one already present for source srcdat.

Reimplemented in qrtplib::RTPSessionSources.

Definition at line 383 of file rtpsources.h.

Referenced by ProcessSDESNormalItem().

384 {
385 }
+ Here is the caller graph for this function:

◆ OnNewSource()

void qrtplib::RTPSources::OnNewSource ( RTPSourceData srcdat)
inlineprotectedvirtual

Is called when a new entry srcdat is added to the source table.

Reimplemented in qrtplib::RTPSessionSources.

Definition at line 386 of file rtpsources.h.

Referenced by CreateOwnSSRC(), ProcessBYE(), ProcessRTCPReportBlock(), ProcessRTCPSenderInfo(), ProcessRTPPacket(), ProcessSDESNormalItem(), ProcessSDESPrivateItem(), and UpdateReceiveTime().

387 {
388 }
+ Here is the caller graph for this function:

◆ OnNoteTimeout()

void qrtplib::RTPSources::OnNoteTimeout ( RTPSourceData srcdat)
inlineprotectedvirtual

Is called when the SDES NOTE item for source srcdat has been timed out.

Reimplemented in qrtplib::RTPSessionSources.

Definition at line 424 of file rtpsources.h.

Referenced by MultipleTimeouts(), and NoteTimeout().

425 {
426 }
+ Here is the caller graph for this function:

◆ OnRemoveSource()

void qrtplib::RTPSources::OnRemoveSource ( RTPSourceData srcdat)
inlineprotectedvirtual

Is called when the entry srcdat is about to be deleted from the source table.

Reimplemented in qrtplib::RTPSessionSources.

Definition at line 389 of file rtpsources.h.

Referenced by BYETimeout(), DeleteOwnSSRC(), MultipleTimeouts(), and Timeout().

390 {
391 }
+ Here is the caller graph for this function:

◆ OnRTCPCompoundPacket()

void qrtplib::RTPSources::OnRTCPCompoundPacket ( RTCPCompoundPacket pack,
const RTPTime receivetime,
const RTPAddress senderaddress 
)
inlineprotectedvirtual

Is called when an RTCP compound packet is about to be processed.

Reimplemented in qrtplib::RTPSessionSources.

Definition at line 377 of file rtpsources.h.

Referenced by ProcessRTCPCompoundPacket().

378 {
379 }
+ Here is the caller graph for this function:

◆ OnRTCPReceiverReport()

void qrtplib::RTPSources::OnRTCPReceiverReport ( RTPSourceData srcdat)
inlineprotectedvirtual

Is called when an RTCP receiver report has been processed for this source.

Reimplemented in qrtplib::RTPSessionSources.

Definition at line 404 of file rtpsources.h.

Referenced by ProcessRTCPReportBlock().

405 {
406 }
+ Here is the caller graph for this function:

◆ OnRTCPSDESItem()

void qrtplib::RTPSources::OnRTCPSDESItem ( RTPSourceData srcdat,
RTCPSDESPacket::ItemType  t,
const void *  itemdata,
std::size_t  itemlength 
)
inlineprotectedvirtual

Is called when a specific SDES item was received for this source.

Reimplemented in qrtplib::RTPSessionSources.

Definition at line 407 of file rtpsources.h.

Referenced by ProcessSDESNormalItem().

408 {
409 }
+ Here is the caller graph for this function:

◆ OnRTCPSDESPrivateItem()

void qrtplib::RTPSources::OnRTCPSDESPrivateItem ( RTPSourceData srcdat,
const void *  prefixdata,
std::size_t  prefixlen,
const void *  valuedata,
std::size_t  valuelen 
)
inlineprotectedvirtual

Is called when a specific SDES item of 'private' type was received for this source.

Reimplemented in qrtplib::RTPSessionSources.

Definition at line 411 of file rtpsources.h.

Referenced by ProcessSDESPrivateItem().

412 {
413 }
+ Here is the caller graph for this function:

◆ OnRTCPSenderReport()

void qrtplib::RTPSources::OnRTCPSenderReport ( RTPSourceData srcdat)
inlineprotectedvirtual

Is called when an RTCP sender report has been processed for this source.

Reimplemented in qrtplib::RTPSessionSources.

Definition at line 401 of file rtpsources.h.

Referenced by ProcessRTCPSenderInfo().

402 {
403 }
+ Here is the caller graph for this function:

◆ OnRTPPacket()

void qrtplib::RTPSources::OnRTPPacket ( RTPPacket pack,
const RTPTime receivetime,
const RTPAddress senderaddress 
)
inlineprotectedvirtual

Is called when an RTP packet is about to be processed.

Reimplemented in qrtplib::RTPSessionSources.

Definition at line 374 of file rtpsources.h.

Referenced by ProcessRTPPacket().

375 {
376 }
+ Here is the caller graph for this function:

◆ OnSSRCCollision()

void qrtplib::RTPSources::OnSSRCCollision ( RTPSourceData srcdat,
const RTPAddress senderaddress,
bool  isrtp 
)
inlineprotectedvirtual

Is called when an SSRC collision was detected. Is called when an SSRC collision was detected. The instance srcdat is the one present in the table, the address senderaddress is the one that collided with one of the addresses and isrtp indicates against which address of srcdat the check failed.

Reimplemented in qrtplib::RTPSessionSources.

Definition at line 380 of file rtpsources.h.

Referenced by CheckCollision().

381 {
382 }
+ Here is the caller graph for this function:

◆ OnTimeout()

void qrtplib::RTPSources::OnTimeout ( RTPSourceData srcdat)
inlineprotectedvirtual

Is called when participant srcdat is timed out.

Reimplemented in qrtplib::RTPSessionSources.

Definition at line 392 of file rtpsources.h.

Referenced by MultipleTimeouts(), and Timeout().

393 {
394 }
+ Here is the caller graph for this function:

◆ OnUnknownPacketFormat()

void qrtplib::RTPSources::OnUnknownPacketFormat ( RTCPPacket rtcppack,
const RTPTime receivetime,
const RTPAddress senderaddress 
)
inlineprotectedvirtual

Is called when an unknown packet format for a known packet type was detected.

Reimplemented in qrtplib::RTPSessionSources.

Definition at line 421 of file rtpsources.h.

Referenced by ProcessRTCPCompoundPacket().

422 {
423 }
+ Here is the caller graph for this function:

◆ OnUnknownPacketType()

void qrtplib::RTPSources::OnUnknownPacketType ( RTCPPacket rtcppack,
const RTPTime receivetime,
const RTPAddress senderaddress 
)
inlineprotectedvirtual

Is called when an unknown RTCP packet type was detected.

Reimplemented in qrtplib::RTPSessionSources.

Definition at line 418 of file rtpsources.h.

Referenced by ProcessRTCPCompoundPacket().

419 {
420 }
+ Here is the caller graph for this function:

◆ OnValidatedRTPPacket()

void qrtplib::RTPSources::OnValidatedRTPPacket ( RTPSourceData srcdat,
RTPPacket rtppack,
bool  isonprobation,
bool *  ispackethandled 
)
inlineprotectedvirtual

Allows you to use an RTP packet from the specified source directly. Allows you to use an RTP packet from the specified source directly. If ispackethandled is set to true, the packet will no longer be stored in this source's packet list.

Reimplemented in qrtplib::RTPSessionSources.

Definition at line 427 of file rtpsources.h.

Referenced by qrtplib::RTPInternalSourceData::ProcessRTPPacket().

428 {
429 }
+ Here is the caller graph for this function:

◆ ProcessBYE()

int qrtplib::RTPSources::ProcessBYE ( uint32_t  ssrc,
std::size_t  reasonlength,
const void *  reasondata,
const RTPTime receivetime,
const RTPAddress senderaddress 
)

Processes the BYE message for SSRC ssrc. Processes the BYE message for SSRC ssrc. The information was received at time receivetime from address senderaddress. The senderaddress parameter must be NULL if the packet was sent by the local participant.

Definition at line 773 of file rtpsources.cpp.

References activecount, GetRTCPSourceData(), qrtplib::RTPSourceData::IsActive(), OnBYEPacket(), OnNewSource(), owndata, and qrtplib::RTPInternalSourceData::ProcessBYEPacket().

Referenced by ProcessRTCPCompoundPacket().

774 {
775  RTPInternalSourceData *srcdat;
776  bool created;
777  int status;
778  bool prevactive;
779 
780  status = GetRTCPSourceData(ssrc, senderaddress, &srcdat, &created);
781  if (status < 0)
782  return status;
783  if (srcdat == 0)
784  return 0;
785 
786  // we'll ignore BYE packets for our own ssrc
787  if (srcdat == owndata)
788  return 0;
789 
790  prevactive = srcdat->IsActive();
791  srcdat->ProcessBYEPacket((const uint8_t *) reasondata, reasonlength, receivetime);
792  if (prevactive && !srcdat->IsActive())
793  activecount--;
794 
795  // Call the callback
796  if (created)
797  OnNewSource(srcdat);
798  OnBYEPacket(srcdat);
799  return 0;
800 }
RTPInternalSourceData * owndata
Definition: rtpsources.h:368
virtual void OnBYEPacket(RTPSourceData *srcdat)
Definition: rtpsources.h:398
unsigned char uint8_t
Definition: rtptypes_win.h:42
friend class RTPInternalSourceData
Definition: rtpsources.h:370
int GetRTCPSourceData(uint32_t ssrc, const RTPAddress *senderaddress, RTPInternalSourceData **srcdat, bool *newsource)
Definition: rtpsources.cpp:827
virtual void OnNewSource(RTPSourceData *srcdat)
Definition: rtpsources.h:386
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ProcessRawPacket() [1/2]

int qrtplib::RTPSources::ProcessRawPacket ( RTPRawPacket rawpack,
RTPTransmitter trans,
bool  acceptownpackets 
)

Processes a raw packet rawpack. Processes a raw packet rawpack. The instance trans will be used to check if this packet is one of our own packets. The flag acceptownpackets indicates whether own packets should be accepted or ignored.

Definition at line 149 of file rtpsources.cpp.

Referenced by qrtplib::RTPSession::ProcessPolledData().

150 {
151  RTPTransmitter *transmitters[1];
152  int num;
153 
154  transmitters[0] = rtptrans;
155  if (rtptrans == 0)
156  num = 0;
157  else
158  num = 1;
159  return ProcessRawPacket(rawpack, transmitters, num, acceptownpackets);
160 }
int ProcessRawPacket(RTPRawPacket *rawpack, RTPTransmitter *trans, bool acceptownpackets)
Definition: rtpsources.cpp:149
+ Here is the caller graph for this function:

◆ ProcessRawPacket() [2/2]

int qrtplib::RTPSources::ProcessRawPacket ( RTPRawPacket rawpack,
RTPTransmitter trans[],
int  numtrans,
bool  acceptownpackets 
)

Processes a raw packet rawpack. Processes a raw packet rawpack. Every transmitter in the array trans of length numtrans is used to check if the packet is from our own session. The flag acceptownpackets indicates whether own packets should be accepted or ignored.

Definition at line 162 of file rtpsources.cpp.

References ERR_RTP_PACKET_INVALIDPACKET, ERR_RTP_RTCPCOMPOUND_INVALIDPACKET, qrtplib::RTCPCompoundPacket::GetCreationError(), qrtplib::RTPPacket::GetCreationError(), qrtplib::RTPRawPacket::GetReceiveTime(), qrtplib::RTPRawPacket::GetSenderAddress(), i, qrtplib::RTPRawPacket::IsRTP(), ProcessRTCPCompoundPacket(), and ProcessRTPPacket().

163 {
164  int status;
165 
166  if (rawpack->IsRTP()) // RTP packet
167  {
168  RTPPacket *rtppack;
169 
170  // First, we'll see if the packet can be parsed
171  rtppack = new RTPPacket(*rawpack);
172 
173  if ((status = rtppack->GetCreationError()) < 0)
174  {
175  if (status == ERR_RTP_PACKET_INVALIDPACKET)
176  {
177  delete rtppack;
178  rtppack = 0;
179  }
180  else
181  {
182  delete rtppack;
183  return status;
184  }
185  }
186 
187  // Check if the packet was valid
188  if (rtppack != 0)
189  {
190  bool stored = false;
191  bool ownpacket = false;
192  int i;
193  const RTPAddress& senderaddress = rawpack->GetSenderAddress();
194 
195  for (i = 0; !ownpacket && i < numtrans; i++)
196  {
197  if (rtptrans[i]->ComesFromThisTransmitter(senderaddress))
198  ownpacket = true;
199  }
200 
201  // Check if the packet is our own.
202  if (ownpacket)
203  {
204  // Now it depends on the user's preference
205  // what to do with this packet:
206  if (acceptownpackets)
207  {
208  // sender addres for own packets has to be NULL!
209  if ((status = ProcessRTPPacket(rtppack, rawpack->GetReceiveTime(), 0, &stored)) < 0)
210  {
211  if (!stored)
212  delete rtppack;
213  return status;
214  }
215  }
216  }
217  else
218  {
219  if ((status = ProcessRTPPacket(rtppack, rawpack->GetReceiveTime(), &senderaddress, &stored)) < 0)
220  {
221  if (!stored)
222  delete rtppack;
223  return status;
224  }
225  }
226  if (!stored)
227  delete rtppack;
228  }
229  }
230  else // RTCP packet
231  {
232  RTCPCompoundPacket rtcpcomppack(*rawpack);
233  bool valid = false;
234 
235  if ((status = rtcpcomppack.GetCreationError()) < 0)
236  {
238  return status;
239  }
240  else
241  valid = true;
242 
243  if (valid)
244  {
245  bool ownpacket = false;
246  int i;
247  const RTPAddress& senderaddress = rawpack->GetSenderAddress();
248 
249  for (i = 0; !ownpacket && i < numtrans; i++)
250  {
251  if (rtptrans[i]->ComesFromThisTransmitter(senderaddress))
252  ownpacket = true;
253  }
254 
255  // First check if it's a packet of this session.
256  if (ownpacket)
257  {
258  if (acceptownpackets)
259  {
260  // sender address for own packets has to be NULL
261  status = ProcessRTCPCompoundPacket(&rtcpcomppack, rawpack->GetReceiveTime(), 0);
262  if (status < 0)
263  return status;
264  }
265  }
266  else // not our own packet
267  {
268  status = ProcessRTCPCompoundPacket(&rtcpcomppack, rawpack->GetReceiveTime(), &rawpack->GetSenderAddress());
269  if (status < 0)
270  return status;
271  }
272  }
273  }
274 
275  return 0;
276 }
int ProcessRTPPacket(RTPPacket *rtppack, const RTPTime &receivetime, const RTPAddress *senderaddress, bool *stored)
Definition: rtpsources.cpp:278
int ProcessRTCPCompoundPacket(RTCPCompoundPacket *rtcpcomppack, const RTPTime &receivetime, const RTPAddress *senderaddress)
Definition: rtpsources.cpp:362
#define ERR_RTP_PACKET_INVALIDPACKET
Definition: rtperrors.h:77
int32_t i
Definition: decimators.h:244
#define ERR_RTP_RTCPCOMPOUND_INVALIDPACKET
Definition: rtperrors.h:82
+ Here is the call graph for this function:

◆ ProcessRTCPCompoundPacket()

int qrtplib::RTPSources::ProcessRTCPCompoundPacket ( RTCPCompoundPacket rtcpcomppack,
const RTPTime receivetime,
const RTPAddress senderaddress 
)

Processes the RTCP compound packet rtcpcomppack which was received at time receivetime from senderaddress. Processes the RTCP compound packet rtcpcomppack which was received at time receivetime from senderaddress. The senderaddress parameter must be NULL if the packet was sent by the local participant.

Definition at line 362 of file rtpsources.cpp.

References qrtplib::RTCPPacket::APP, qrtplib::RTCPPacket::BYE, qrtplib::RTCPSDESPacket::GetChunkSSRC(), qrtplib::RTCPRRPacket::GetDLSR(), qrtplib::RTCPSRPacket::GetDLSR(), qrtplib::RTCPRRPacket::GetExtendedHighestSequenceNumber(), qrtplib::RTCPSRPacket::GetExtendedHighestSequenceNumber(), qrtplib::RTCPRRPacket::GetFractionLost(), qrtplib::RTCPSRPacket::GetFractionLost(), qrtplib::RTCPSDESPacket::GetItemData(), qrtplib::RTCPSDESPacket::GetItemLength(), qrtplib::RTCPSDESPacket::GetItemType(), qrtplib::RTCPRRPacket::GetJitter(), qrtplib::RTCPSRPacket::GetJitter(), qrtplib::RTCPRRPacket::GetLostPacketCount(), qrtplib::RTCPSRPacket::GetLostPacketCount(), qrtplib::RTCPRRPacket::GetLSR(), qrtplib::RTCPSRPacket::GetLSR(), qrtplib::RTCPCompoundPacket::GetNextPacket(), qrtplib::RTCPSRPacket::GetNTPTimestamp(), qrtplib::RTCPPacket::GetPacketType(), qrtplib::RTCPSDESPacket::GetPRIVPrefixData(), qrtplib::RTCPSDESPacket::GetPRIVPrefixLength(), qrtplib::RTCPSDESPacket::GetPRIVValueData(), qrtplib::RTCPSDESPacket::GetPRIVValueLength(), qrtplib::RTCPBYEPacket::GetReasonData(), qrtplib::RTCPBYEPacket::GetReasonLength(), qrtplib::RTCPRRPacket::GetReceptionReportCount(), qrtplib::RTCPSRPacket::GetReceptionReportCount(), qrtplib::RTCPSRPacket::GetRTPTimestamp(), qrtplib::RTCPSRPacket::GetSenderOctetCount(), qrtplib::RTCPSRPacket::GetSenderPacketCount(), qrtplib::RTCPRRPacket::GetSenderSSRC(), qrtplib::RTCPSRPacket::GetSenderSSRC(), qrtplib::RTCPBYEPacket::GetSSRC(), qrtplib::RTCPRRPacket::GetSSRC(), qrtplib::RTCPSRPacket::GetSSRC(), qrtplib::RTPSourceData::GetSSRC(), qrtplib::RTCPBYEPacket::GetSSRCCount(), qrtplib::RTCPSDESPacket::GotoFirstChunk(), qrtplib::RTCPSDESPacket::GotoFirstItem(), qrtplib::RTCPCompoundPacket::GotoFirstPacket(), qrtplib::RTCPSDESPacket::GotoNextChunk(), qrtplib::RTCPSDESPacket::GotoNextItem(), i, qrtplib::RTCPPacket::IsKnownFormat(), OnAPPPacket(), OnRTCPCompoundPacket(), OnUnknownPacketFormat(), OnUnknownPacketType(), owndata, qrtplib::RTCPSDESPacket::PRIV, ProcessBYE(), ProcessRTCPReportBlock(), ProcessRTCPSenderInfo(), ProcessSDESNormalItem(), ProcessSDESPrivateItem(), qrtplib::RTCPPacket::RR, qrtplib::RTCPPacket::SDES, qrtplib::RTCPPacket::SR, qrtplib::RTCPPacket::Unknown, and UpdateReceiveTime().

Referenced by ProcessRawPacket().

363 {
364  RTCPPacket *rtcppack;
365  int status;
366  bool gotownssrc = ((owndata == 0) ? false : true);
367  uint32_t ownssrc = ((owndata != 0) ? owndata->GetSSRC() : 0);
368 
369  OnRTCPCompoundPacket(rtcpcomppack, receivetime, senderaddress);
370 
371  rtcpcomppack->GotoFirstPacket();
372  while ((rtcppack = rtcpcomppack->GetNextPacket()) != 0)
373  {
374  if (rtcppack->IsKnownFormat())
375  {
376  switch (rtcppack->GetPacketType())
377  {
378  case RTCPPacket::SR:
379  {
380  RTCPSRPacket *p = (RTCPSRPacket *) rtcppack;
381  uint32_t senderssrc = p->GetSenderSSRC();
382 
383  status = ProcessRTCPSenderInfo(senderssrc, p->GetNTPTimestamp(), p->GetRTPTimestamp(), p->GetSenderPacketCount(), p->GetSenderOctetCount(), receivetime,
384  senderaddress);
385  if (status < 0)
386  return status;
387 
388  bool gotinfo = false;
389  if (gotownssrc)
390  {
391  int i;
392  int num = p->GetReceptionReportCount();
393  for (i = 0; i < num; i++)
394  {
395  if (p->GetSSRC(i) == ownssrc) // data is meant for us
396  {
397  gotinfo = true;
398  status = ProcessRTCPReportBlock(senderssrc, p->GetFractionLost(i), p->GetLostPacketCount(i), p->GetExtendedHighestSequenceNumber(i), p->GetJitter(i),
399  p->GetLSR(i), p->GetDLSR(i), receivetime, senderaddress);
400  if (status < 0)
401  return status;
402  }
403  }
404  }
405  if (!gotinfo)
406  {
407  status = UpdateReceiveTime(senderssrc, receivetime, senderaddress);
408  if (status < 0)
409  return status;
410  }
411  }
412  break;
413  case RTCPPacket::RR:
414  {
415  RTCPRRPacket *p = (RTCPRRPacket *) rtcppack;
416  uint32_t senderssrc = p->GetSenderSSRC();
417 
418  bool gotinfo = false;
419 
420  if (gotownssrc)
421  {
422  int i;
423  int num = p->GetReceptionReportCount();
424  for (i = 0; i < num; i++)
425  {
426  if (p->GetSSRC(i) == ownssrc)
427  {
428  gotinfo = true;
429  status = ProcessRTCPReportBlock(senderssrc, p->GetFractionLost(i), p->GetLostPacketCount(i), p->GetExtendedHighestSequenceNumber(i), p->GetJitter(i),
430  p->GetLSR(i), p->GetDLSR(i), receivetime, senderaddress);
431  if (status < 0)
432  return status;
433  }
434  }
435  }
436  if (!gotinfo)
437  {
438  status = UpdateReceiveTime(senderssrc, receivetime, senderaddress);
439  if (status < 0)
440  return status;
441  }
442  }
443  break;
444  case RTCPPacket::SDES:
445  {
446  RTCPSDESPacket *p = (RTCPSDESPacket *) rtcppack;
447 
448  if (p->GotoFirstChunk())
449  {
450  do
451  {
452  uint32_t sdesssrc = p->GetChunkSSRC();
453  bool updated = false;
454  if (p->GotoFirstItem())
455  {
456  do
457  {
459 
460  if ((t = p->GetItemType()) != RTCPSDESPacket::PRIV)
461  {
462  updated = true;
463  status = ProcessSDESNormalItem(sdesssrc, t, p->GetItemLength(), p->GetItemData(), receivetime, senderaddress);
464  if (status < 0)
465  return status;
466  }
467 #ifdef RTP_SUPPORT_SDESPRIV
468  else
469  {
470  updated = true;
471  status = ProcessSDESPrivateItem(sdesssrc, p->GetPRIVPrefixLength(), p->GetPRIVPrefixData(), p->GetPRIVValueLength(), p->GetPRIVValueData(),
472  receivetime, senderaddress);
473  if (status < 0)
474  return status;
475  }
476 #endif // RTP_SUPPORT_SDESPRIV
477  } while (p->GotoNextItem());
478  }
479  if (!updated)
480  {
481  status = UpdateReceiveTime(sdesssrc, receivetime, senderaddress);
482  if (status < 0)
483  return status;
484  }
485  } while (p->GotoNextChunk());
486  }
487  }
488  break;
489  case RTCPPacket::BYE:
490  {
491  RTCPBYEPacket *p = (RTCPBYEPacket *) rtcppack;
492  int i;
493  int num = p->GetSSRCCount();
494 
495  for (i = 0; i < num; i++)
496  {
497  uint32_t byessrc = p->GetSSRC(i);
498  status = ProcessBYE(byessrc, p->GetReasonLength(), p->GetReasonData(), receivetime, senderaddress);
499  if (status < 0)
500  return status;
501  }
502  }
503  break;
504  case RTCPPacket::APP:
505  {
506  RTCPAPPPacket *p = (RTCPAPPPacket *) rtcppack;
507 
508  OnAPPPacket(p, receivetime, senderaddress);
509  }
510  break;
511  case RTCPPacket::Unknown:
512  default:
513  {
514  OnUnknownPacketType(rtcppack, receivetime, senderaddress);
515  }
516  break;
517  }
518  }
519  else
520  {
521  OnUnknownPacketFormat(rtcppack, receivetime, senderaddress);
522  }
523  }
524 
525  return 0;
526 }
int ProcessBYE(uint32_t ssrc, std::size_t reasonlength, const void *reasondata, const RTPTime &receivetime, const RTPAddress *senderaddress)
Definition: rtpsources.cpp:773
virtual void OnAPPPacket(RTCPAPPPacket *apppacket, const RTPTime &receivetime, const RTPAddress *senderaddress)
Definition: rtpsources.h:415
virtual void OnRTCPCompoundPacket(RTCPCompoundPacket *pack, const RTPTime &receivetime, const RTPAddress *senderaddress)
Definition: rtpsources.h:377
RTPInternalSourceData * owndata
Definition: rtpsources.h:368
int ProcessRTCPReportBlock(uint32_t ssrc, uint8_t fractionlost, int32_t lostpackets, uint32_t exthighseqnr, uint32_t jitter, uint32_t lsr, uint32_t dlsr, const RTPTime &receivetime, const RTPAddress *senderaddress)
Definition: rtpsources.cpp:664
unsigned int uint32_t
Definition: rtptypes_win.h:46
int ProcessSDESPrivateItem(uint32_t ssrc, std::size_t prefixlen, const void *prefixdata, std::size_t valuelen, const void *valuedata, const RTPTime &receivetime, const RTPAddress *senderaddress)
Definition: rtpsources.cpp:748
int32_t i
Definition: decimators.h:244
uint32_t GetSSRC() const
int ProcessSDESNormalItem(uint32_t ssrc, RTCPSDESPacket::ItemType t, std::size_t itemlength, const void *itemdata, const RTPTime &receivetime, const RTPAddress *senderaddress)
Definition: rtpsources.cpp:688
virtual void OnUnknownPacketType(RTCPPacket *rtcppack, const RTPTime &receivetime, const RTPAddress *senderaddress)
Definition: rtpsources.h:418
virtual void OnUnknownPacketFormat(RTCPPacket *rtcppack, const RTPTime &receivetime, const RTPAddress *senderaddress)
Definition: rtpsources.h:421
int ProcessRTCPSenderInfo(uint32_t ssrc, const RTPNTPTime &ntptime, uint32_t rtptime, uint32_t packetcount, uint32_t octetcount, const RTPTime &receivetime, const RTPAddress *senderaddress)
Definition: rtpsources.cpp:640
int UpdateReceiveTime(uint32_t ssrc, const RTPTime &receivetime, const RTPAddress *senderaddress)
Definition: rtpsources.cpp:855
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ProcessRTCPReportBlock()

int qrtplib::RTPSources::ProcessRTCPReportBlock ( uint32_t  ssrc,
uint8_t  fractionlost,
int32_t  lostpackets,
uint32_t  exthighseqnr,
uint32_t  jitter,
uint32_t  lsr,
uint32_t  dlsr,
const RTPTime receivetime,
const RTPAddress senderaddress 
)

Processes the report block information which was sent by participant ssrc into the source table. Processes the report block information which was sent by participant ssrc into the source table. The information was received at time receivetime from address senderaddress The senderaddress parameter must be NULL if the packet was sent by the local participant.

Definition at line 664 of file rtpsources.cpp.

References GetRTCPSourceData(), OnNewSource(), OnRTCPReceiverReport(), and qrtplib::RTPInternalSourceData::ProcessReportBlock().

Referenced by ProcessRTCPCompoundPacket().

666 {
667  RTPInternalSourceData *srcdat;
668  bool created;
669  int status;
670 
671  status = GetRTCPSourceData(ssrc, senderaddress, &srcdat, &created);
672  if (status < 0)
673  return status;
674  if (srcdat == 0)
675  return 0;
676 
677  srcdat->ProcessReportBlock(fractionlost, lostpackets, exthighseqnr, jitter, lsr, dlsr, receivetime);
678 
679  // Call the callback
680  if (created)
681  OnNewSource(srcdat);
682 
683  OnRTCPReceiverReport(srcdat);
684 
685  return 0;
686 }
friend class RTPInternalSourceData
Definition: rtpsources.h:370
virtual void OnRTCPReceiverReport(RTPSourceData *srcdat)
Definition: rtpsources.h:404
int GetRTCPSourceData(uint32_t ssrc, const RTPAddress *senderaddress, RTPInternalSourceData **srcdat, bool *newsource)
Definition: rtpsources.cpp:827
virtual void OnNewSource(RTPSourceData *srcdat)
Definition: rtpsources.h:386
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ProcessRTCPSenderInfo()

int qrtplib::RTPSources::ProcessRTCPSenderInfo ( uint32_t  ssrc,
const RTPNTPTime ntptime,
uint32_t  rtptime,
uint32_t  packetcount,
uint32_t  octetcount,
const RTPTime receivetime,
const RTPAddress senderaddress 
)

Process the sender information of SSRC ssrc into the source table. Process the sender information of SSRC ssrc into the source table. The information was received at time receivetime from address senderaddress. The senderaddress} parameter must be NULL if the packet was sent by the local participant.

Definition at line 640 of file rtpsources.cpp.

References GetRTCPSourceData(), OnNewSource(), OnRTCPSenderReport(), and qrtplib::RTPInternalSourceData::ProcessSenderInfo().

Referenced by ProcessRTCPCompoundPacket().

642 {
643  RTPInternalSourceData *srcdat;
644  bool created;
645  int status;
646 
647  status = GetRTCPSourceData(ssrc, senderaddress, &srcdat, &created);
648  if (status < 0)
649  return status;
650  if (srcdat == 0)
651  return 0;
652 
653  srcdat->ProcessSenderInfo(ntptime, rtptime, packetcount, octetcount, receivetime);
654 
655  // Call the callback
656  if (created)
657  OnNewSource(srcdat);
658 
659  OnRTCPSenderReport(srcdat);
660 
661  return 0;
662 }
virtual void OnRTCPSenderReport(RTPSourceData *srcdat)
Definition: rtpsources.h:401
friend class RTPInternalSourceData
Definition: rtpsources.h:370
int GetRTCPSourceData(uint32_t ssrc, const RTPAddress *senderaddress, RTPInternalSourceData **srcdat, bool *newsource)
Definition: rtpsources.cpp:827
virtual void OnNewSource(RTPSourceData *srcdat)
Definition: rtpsources.h:386
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ProcessRTPPacket()

int qrtplib::RTPSources::ProcessRTPPacket ( RTPPacket rtppack,
const RTPTime receivetime,
const RTPAddress senderaddress,
bool *  stored 
)

Processes an RTPPacket instance rtppack which was received at time receivetime and which originated from senderaddres. Processes an RTPPacket instance rtppack which was received at time receivetime and which originated from senderaddres. The senderaddress parameter must be NULL if the packet was sent by the local participant. The flag stored indicates whether the packet was stored in the table or not. If so, the rtppack instance may not be deleted.

Definition at line 278 of file rtpsources.cpp.

References activecount, CheckCollision(), qrtplib::RTPPacket::GetCSRC(), qrtplib::RTPPacket::GetCSRCCount(), qrtplib::RTPPacket::GetSSRC(), i, qrtplib::RTPSourceData::IsActive(), qrtplib::RTPSourceData::IsSender(), qrtplib::RTPSourceData::IsValidated(), ObtainSourceDataInstance(), OnNewSource(), OnRTPPacket(), qrtplib::RTPInternalSourceData::ProcessRTPPacket(), RTP_MAXCSRCS, sendercount, qrtplib::RTPInternalSourceData::SetCSRC(), and qrtplib::RTPInternalSourceData::SetRTPDataAddress().

Referenced by ProcessRawPacket().

279 {
280  uint32_t ssrc;
281  RTPInternalSourceData *srcdat;
282  int status;
283  bool created;
284 
285  OnRTPPacket(rtppack, receivetime, senderaddress);
286 
287  *stored = false;
288 
289  ssrc = rtppack->GetSSRC();
290  if ((status = ObtainSourceDataInstance(ssrc, &srcdat, &created)) < 0)
291  return status;
292 
293  if (created)
294  {
295  if ((status = srcdat->SetRTPDataAddress(senderaddress)) < 0)
296  return status;
297  }
298  else // got a previously existing source
299  {
300  if (CheckCollision(srcdat, senderaddress, true))
301  return 0; // ignore packet on collision
302  }
303 
304  bool prevsender = srcdat->IsSender();
305  bool prevactive = srcdat->IsActive();
306 
307  uint32_t CSRCs[RTP_MAXCSRCS];
308  int numCSRCs = rtppack->GetCSRCCount();
309  if (numCSRCs > RTP_MAXCSRCS) // shouldn't happen, but better to check than go out of bounds
310  numCSRCs = RTP_MAXCSRCS;
311 
312  for (int i = 0; i < numCSRCs; i++)
313  CSRCs[i] = rtppack->GetCSRC(i);
314 
315  // The packet comes from a valid source, we can process it further now
316  // The following function should delete rtppack itself if something goes
317  // wrong
318  if ((status = srcdat->ProcessRTPPacket(rtppack, receivetime, stored, this)) < 0)
319  return status;
320 
321  // NOTE: we cannot use 'rtppack' anymore since it may have been deleted in
322  // OnValidatedRTPPacket
323 
324  if (!prevsender && srcdat->IsSender())
325  sendercount++;
326  if (!prevactive && srcdat->IsActive())
327  activecount++;
328 
329  if (created)
330  OnNewSource(srcdat);
331 
332  if (srcdat->IsValidated()) // process the CSRCs
333  {
334  RTPInternalSourceData *csrcdat;
335  bool createdcsrc;
336 
337  int num = numCSRCs;
338  int i;
339 
340  for (i = 0; i < num; i++)
341  {
342  if ((status = ObtainSourceDataInstance(CSRCs[i], &csrcdat, &createdcsrc)) < 0)
343  return status;
344  if (createdcsrc)
345  {
346  csrcdat->SetCSRC();
347  if (csrcdat->IsActive())
348  activecount++;
349  OnNewSource(csrcdat);
350  }
351  else // already found an entry, possibly because of RTCP data
352  {
353  if (!CheckCollision(csrcdat, senderaddress, true))
354  csrcdat->SetCSRC();
355  }
356  }
357  }
358 
359  return 0;
360 }
unsigned int uint32_t
Definition: rtptypes_win.h:46
bool CheckCollision(RTPInternalSourceData *srcdat, const RTPAddress *senderaddress, bool isrtp)
virtual void OnRTPPacket(RTPPacket *pack, const RTPTime &receivetime, const RTPAddress *senderaddress)
Definition: rtpsources.h:374
int32_t i
Definition: decimators.h:244
#define RTP_MAXCSRCS
Definition: rtpdefines.h:38
int ObtainSourceDataInstance(uint32_t ssrc, RTPInternalSourceData **srcdat, bool *created)
Definition: rtpsources.cpp:802
friend class RTPInternalSourceData
Definition: rtpsources.h:370
virtual void OnNewSource(RTPSourceData *srcdat)
Definition: rtpsources.h:386
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ProcessSDESNormalItem()

int qrtplib::RTPSources::ProcessSDESNormalItem ( uint32_t  ssrc,
RTCPSDESPacket::ItemType  t,
std::size_t  itemlength,
const void *  itemdata,
const RTPTime receivetime,
const RTPAddress senderaddress 
)

Processes the non-private SDES item from source ssrc into the source table. Processes the non-private SDES item from source ssrc into the source table. The information was received at time receivetime from address senderaddress. The senderaddress parameter must be NULL if the packet was sent by the local participant.

Definition at line 688 of file rtpsources.cpp.

References activecount, qrtplib::RTCPSDESPacket::CNAME, qrtplib::RTCPSDESPacket::EMAIL, ERR_RTP_SOURCES_ILLEGALSDESTYPE, GetRTCPSourceData(), qrtplib::RTPSourceData::IsActive(), qrtplib::RTCPSDESPacket::LOC, qrtplib::RTCPSDESPacket::NAME, qrtplib::RTCPSDESPacket::NOTE, OnCNAMECollision(), OnNewSource(), OnRTCPSDESItem(), qrtplib::RTCPSDESPacket::PHONE, qrtplib::RTPInternalSourceData::ProcessSDESItem(), RTCP_SDES_ID_CNAME, RTCP_SDES_ID_EMAIL, RTCP_SDES_ID_LOCATION, RTCP_SDES_ID_NAME, RTCP_SDES_ID_NOTE, RTCP_SDES_ID_PHONE, RTCP_SDES_ID_TOOL, and qrtplib::RTCPSDESPacket::TOOL.

Referenced by ProcessRTCPCompoundPacket().

690 {
691  RTPInternalSourceData *srcdat;
692  bool created, cnamecollis;
693  int status;
694  uint8_t sdesid;
695  bool prevactive;
696 
697  switch (t)
698  {
700  sdesid = RTCP_SDES_ID_CNAME;
701  break;
703  sdesid = RTCP_SDES_ID_NAME;
704  break;
706  sdesid = RTCP_SDES_ID_EMAIL;
707  break;
709  sdesid = RTCP_SDES_ID_PHONE;
710  break;
711  case RTCPSDESPacket::LOC:
712  sdesid = RTCP_SDES_ID_LOCATION;
713  break;
715  sdesid = RTCP_SDES_ID_TOOL;
716  break;
718  sdesid = RTCP_SDES_ID_NOTE;
719  break;
720  default:
722  }
723 
724  status = GetRTCPSourceData(ssrc, senderaddress, &srcdat, &created);
725  if (status < 0)
726  return status;
727  if (srcdat == 0)
728  return 0;
729 
730  prevactive = srcdat->IsActive();
731  status = srcdat->ProcessSDESItem(sdesid, (const uint8_t *) itemdata, itemlength, receivetime, &cnamecollis);
732  if (!prevactive && srcdat->IsActive())
733  activecount++;
734 
735  // Call the callback
736  if (created)
737  OnNewSource(srcdat);
738  if (cnamecollis)
739  OnCNAMECollision(srcdat, senderaddress, (const uint8_t *) itemdata, itemlength);
740 
741  if (status >= 0)
742  OnRTCPSDESItem(srcdat, t, itemdata, itemlength);
743 
744  return status;
745 }
#define RTCP_SDES_ID_EMAIL
Definition: rtpdefines.h:58
#define RTCP_SDES_ID_LOCATION
Definition: rtpdefines.h:60
virtual void OnRTCPSDESItem(RTPSourceData *srcdat, RTCPSDESPacket::ItemType t, const void *itemdata, std::size_t itemlength)
Definition: rtpsources.h:407
#define ERR_RTP_SOURCES_ILLEGALSDESTYPE
Definition: rtperrors.h:119
#define RTCP_SDES_ID_NOTE
Definition: rtpdefines.h:62
unsigned char uint8_t
Definition: rtptypes_win.h:42
virtual void OnCNAMECollision(RTPSourceData *srcdat, const RTPAddress *senderaddress, const uint8_t *cname, std::size_t cnamelength)
Definition: rtpsources.h:383
#define RTCP_SDES_ID_TOOL
Definition: rtpdefines.h:61
#define RTCP_SDES_ID_CNAME
Definition: rtpdefines.h:56
friend class RTPInternalSourceData
Definition: rtpsources.h:370
int GetRTCPSourceData(uint32_t ssrc, const RTPAddress *senderaddress, RTPInternalSourceData **srcdat, bool *newsource)
Definition: rtpsources.cpp:827
#define RTCP_SDES_ID_NAME
Definition: rtpdefines.h:57
virtual void OnNewSource(RTPSourceData *srcdat)
Definition: rtpsources.h:386
#define RTCP_SDES_ID_PHONE
Definition: rtpdefines.h:59
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ProcessSDESPrivateItem()

int qrtplib::RTPSources::ProcessSDESPrivateItem ( uint32_t  ssrc,
std::size_t  prefixlen,
const void *  prefixdata,
std::size_t  valuelen,
const void *  valuedata,
const RTPTime receivetime,
const RTPAddress senderaddress 
)

Processes the SDES private item from source ssrc into the source table. Processes the SDES private item from source ssrc into the source table. The information was received at time receivetime from address senderaddress. The senderaddress parameter must be NULL if the packet was sent by the local participant.

Definition at line 748 of file rtpsources.cpp.

References GetRTCPSourceData(), OnNewSource(), OnRTCPSDESPrivateItem(), and qrtplib::RTPInternalSourceData::ProcessPrivateSDESItem().

Referenced by ProcessRTCPCompoundPacket().

750 {
751  RTPInternalSourceData *srcdat;
752  bool created;
753  int status;
754 
755  status = GetRTCPSourceData(ssrc, senderaddress, &srcdat, &created);
756  if (status < 0)
757  return status;
758  if (srcdat == 0)
759  return 0;
760 
761  status = srcdat->ProcessPrivateSDESItem((const uint8_t *) prefixdata, prefixlen, (const uint8_t *) valuedata, valuelen, receivetime);
762  // Call the callback
763  if (created)
764  OnNewSource(srcdat);
765 
766  if (status >= 0)
767  OnRTCPSDESPrivateItem(srcdat, prefixdata, prefixlen, valuedata, valuelen);
768 
769  return status;
770 }
unsigned char uint8_t
Definition: rtptypes_win.h:42
friend class RTPInternalSourceData
Definition: rtpsources.h:370
int GetRTCPSourceData(uint32_t ssrc, const RTPAddress *senderaddress, RTPInternalSourceData **srcdat, bool *newsource)
Definition: rtpsources.cpp:827
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
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SenderTimeout()

void qrtplib::RTPSources::SenderTimeout ( const RTPTime curtime,
const RTPTime timeoutdelay 
)

Assuming that the current time is curtime, remove the sender flag for senders from whom we haven't received any RTP packets during the previous time interval timeoutdelay.

Definition at line 923 of file rtpsources.cpp.

References activecount, qrtplib::RTPInternalSourceData::ClearSenderFlag(), qrtplib::RTPSourceData::INF_GetLastRTPPacketTime(), qrtplib::RTPSourceData::IsActive(), qrtplib::RTPSourceData::IsSender(), sendercount, sourcelist, and totalcount.

924 {
925  int newtotalcount = 0;
926  int newsendercount = 0;
927  int newactivecount = 0;
928  RTPTime checktime = curtime;
929  checktime -= timeoutdelay;
930 
931  sourcelist.GotoFirstElement();
932  while (sourcelist.HasCurrentElement())
933  {
934  RTPInternalSourceData *srcdat = sourcelist.GetCurrentElement();
935 
936  newtotalcount++;
937  if (srcdat->IsActive())
938  newactivecount++;
939 
940  if (srcdat->IsSender())
941  {
942  RTPTime lastrtppacktime = srcdat->INF_GetLastRTPPacketTime();
943 
944  if (lastrtppacktime < checktime) // timeout
945  {
946  srcdat->ClearSenderFlag();
947  sendercount--;
948  }
949  else
950  newsendercount++;
951  }
952  sourcelist.GotoNextElement();
953  }
954 
955  totalcount = newtotalcount; // just to play it safe
956  sendercount = newsendercount;
957  activecount = newactivecount;
958 }
RTPKeyHashTable< const uint32_t, RTPInternalSourceData *, RTPSources_GetHashIndex, RTPSOURCES_HASHSIZE > sourcelist
Definition: rtpsources.h:362
friend class RTPInternalSourceData
Definition: rtpsources.h:370
+ Here is the call graph for this function:

◆ SentRTPPacket()

void qrtplib::RTPSources::SentRTPPacket ( )

This function should be called if our own session has sent an RTP packet. This function should be called if our own session has sent an RTP packet. For our own SSRC entry, the sender flag is updated based upon outgoing packets instead of incoming packets.

Definition at line 137 of file rtpsources.cpp.

References qrtplib::RTPSourceData::IsSender(), owndata, sendercount, and qrtplib::RTPInternalSourceData::SentRTPPacket().

Referenced by qrtplib::RTPSession::SendPacket(), and qrtplib::RTPSession::SendPacketEx().

138 {
139  if (owndata == 0)
140  return;
141 
142  bool prevsender = owndata->IsSender();
143 
145  if (!prevsender && owndata->IsSender())
146  sendercount++;
147 }
RTPInternalSourceData * owndata
Definition: rtpsources.h:368
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Timeout()

void qrtplib::RTPSources::Timeout ( const RTPTime curtime,
const RTPTime timeoutdelay 
)

Assuming that the current time is curtime, time out the members from whom we haven't heard during the previous time interval timeoutdelay.

Definition at line 877 of file rtpsources.cpp.

References activecount, qrtplib::RTPSourceData::INF_GetLastMessageTime(), qrtplib::RTPSourceData::IsActive(), qrtplib::RTPSourceData::IsSender(), OnRemoveSource(), OnTimeout(), owndata, sendercount, sourcelist, and totalcount.

878 {
879  int newtotalcount = 0;
880  int newsendercount = 0;
881  int newactivecount = 0;
882  RTPTime checktime = curtime;
883  checktime -= timeoutdelay;
884 
885  sourcelist.GotoFirstElement();
886  while (sourcelist.HasCurrentElement())
887  {
888  RTPInternalSourceData *srcdat = sourcelist.GetCurrentElement();
889  RTPTime lastmsgtime = srcdat->INF_GetLastMessageTime();
890 
891  // we don't want to time out ourselves
892  if ((srcdat != owndata) && (lastmsgtime < checktime)) // timeout
893  {
894 
895  totalcount--;
896  if (srcdat->IsSender())
897  sendercount--;
898  if (srcdat->IsActive())
899  activecount--;
900 
901  sourcelist.DeleteCurrentElement();
902 
903  OnTimeout(srcdat);
904  OnRemoveSource(srcdat);
905  delete srcdat;
906  }
907  else
908  {
909  newtotalcount++;
910  if (srcdat->IsSender())
911  newsendercount++;
912  if (srcdat->IsActive())
913  newactivecount++;
914  sourcelist.GotoNextElement();
915  }
916  }
917 
918  totalcount = newtotalcount; // just to play it safe
919  sendercount = newsendercount;
920  activecount = newactivecount;
921 }
RTPInternalSourceData * owndata
Definition: rtpsources.h:368
RTPKeyHashTable< const uint32_t, RTPInternalSourceData *, RTPSources_GetHashIndex, RTPSOURCES_HASHSIZE > sourcelist
Definition: rtpsources.h:362
friend class RTPInternalSourceData
Definition: rtpsources.h:370
virtual void OnTimeout(RTPSourceData *srcdat)
Definition: rtpsources.h:392
virtual void OnRemoveSource(RTPSourceData *srcdat)
Definition: rtpsources.h:389
+ Here is the call graph for this function:

◆ UpdateReceiveTime()

int qrtplib::RTPSources::UpdateReceiveTime ( uint32_t  ssrc,
const RTPTime receivetime,
const RTPAddress senderaddress 
)

If we heard from source ssrc, but no actual data was added to the source table (for example, if no report block was meant for us), this function can e used to indicate that something was received from this source. If we heard from source ssrc, but no actual data was added to the source table (for example, if no report block was meant for us), this function can e used to indicate that something was received from this source. This will prevent a premature timeout for this participant. The message was received at time receivetime from address senderaddress. The senderaddress parameter must be NULL if the packet was sent by the local participant.

Definition at line 855 of file rtpsources.cpp.

References GetRTCPSourceData(), OnNewSource(), and qrtplib::RTPInternalSourceData::UpdateMessageTime().

Referenced by ProcessRTCPCompoundPacket().

856 {
857  RTPInternalSourceData *srcdat;
858  bool created;
859  int status;
860 
861  status = GetRTCPSourceData(ssrc, senderaddress, &srcdat, &created);
862  if (status < 0)
863  return status;
864  if (srcdat == 0)
865  return 0;
866 
867  // We got valid SSRC info
868  srcdat->UpdateMessageTime(receivetime);
869 
870  // Call the callback
871  if (created)
872  OnNewSource(srcdat);
873 
874  return 0;
875 }
friend class RTPInternalSourceData
Definition: rtpsources.h:370
int GetRTCPSourceData(uint32_t ssrc, const RTPAddress *senderaddress, RTPInternalSourceData **srcdat, bool *newsource)
Definition: rtpsources.cpp:827
virtual void OnNewSource(RTPSourceData *srcdat)
Definition: rtpsources.h:386
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Friends And Related Function Documentation

◆ RTPInternalSourceData

friend class RTPInternalSourceData
friend

Definition at line 370 of file rtpsources.h.

Referenced by ObtainSourceDataInstance().

Member Data Documentation

◆ activecount

int qrtplib::RTPSources::activecount
private

◆ owndata

RTPInternalSourceData* qrtplib::RTPSources::owndata
private

◆ sendercount

int qrtplib::RTPSources::sendercount
private

◆ sourcelist

◆ totalcount

int qrtplib::RTPSources::totalcount
private

The documentation for this class was generated from the following files: