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 Member Functions | Protected Member Functions | Protected Attributes | List of all members
qrtplib::RTCPCompoundPacket Class Reference

#include <rtcpcompoundpacket.h>

+ Inheritance diagram for qrtplib::RTCPCompoundPacket:
+ Collaboration diagram for qrtplib::RTCPCompoundPacket:

Public Member Functions

 RTCPCompoundPacket (RTPRawPacket &rawpack)
 
 RTCPCompoundPacket (uint8_t *packet, std::size_t len)
 
virtual ~RTCPCompoundPacket ()
 
int GetCreationError ()
 
uint8_tGetCompoundPacketData ()
 
std::size_t GetCompoundPacketLength ()
 
void GotoFirstPacket ()
 
RTCPPacketGetNextPacket ()
 

Protected Member Functions

 RTCPCompoundPacket ()
 
void ClearPacketList ()
 
int ParseData (uint8_t *packet, std::size_t len)
 

Protected Attributes

RTPEndian m_endian
 
int error
 
uint8_tcompoundpacket
 
std::size_t compoundpacketlength
 
std::list< RTCPPacket * > rtcppacklist
 
std::list< RTCPPacket * >::const_iterator rtcppackit
 

Detailed Description

Represents an RTCP compound packet.

Definition at line 55 of file rtcpcompoundpacket.h.

Constructor & Destructor Documentation

◆ RTCPCompoundPacket() [1/3]

qrtplib::RTCPCompoundPacket::RTCPCompoundPacket ( RTPRawPacket rawpack)

Creates an RTCPCompoundPacket instance from the data in rawpack, installing a memory manager if specified.

Definition at line 48 of file rtcpcompoundpacket.cpp.

References compoundpacket, compoundpacketlength, ERR_RTP_RTCPCOMPOUND_INVALIDPACKET, error, qrtplib::RTPRawPacket::GetData(), qrtplib::RTPRawPacket::GetDataLength(), qrtplib::RTPRawPacket::IsRTP(), ParseData(), rtcppackit, and rtcppacklist.

49 {
50  compoundpacket = 0;
52  error = 0;
53 
54  if (rawpack.IsRTP())
55  {
57  return;
58  }
59 
60  uint8_t *data = rawpack.GetData();
61  std::size_t datalen = rawpack.GetDataLength();
62 
63  error = ParseData(data, datalen);
64 
65  if (error < 0) {
66  return;
67  }
68 
69  compoundpacket = rawpack.GetData();
70  compoundpacketlength = rawpack.GetDataLength();
71 
72  rtcppackit = rtcppacklist.begin();
73 }
std::list< RTCPPacket * > rtcppacklist
unsigned char uint8_t
Definition: rtptypes_win.h:42
std::list< RTCPPacket * >::const_iterator rtcppackit
int ParseData(uint8_t *packet, std::size_t len)
#define ERR_RTP_RTCPCOMPOUND_INVALIDPACKET
Definition: rtperrors.h:82
+ Here is the call graph for this function:

◆ RTCPCompoundPacket() [2/3]

qrtplib::RTCPCompoundPacket::RTCPCompoundPacket ( uint8_t packet,
std::size_t  len 
)

Creates an RTCPCompoundPacket instance from the data in packet}, with size len.

Definition at line 75 of file rtcpcompoundpacket.cpp.

References compoundpacket, compoundpacketlength, error, ParseData(), rtcppackit, and rtcppacklist.

76 {
77  compoundpacket = 0;
79 
80  error = ParseData(packet, packetlen);
81 
82  if (error < 0) {
83  return;
84  }
85 
86  compoundpacket = packet;
87  compoundpacketlength = packetlen;
88 
89  rtcppackit = rtcppacklist.begin();
90 }
std::list< RTCPPacket * > rtcppacklist
std::list< RTCPPacket * >::const_iterator rtcppackit
int ParseData(uint8_t *packet, std::size_t len)
+ Here is the call graph for this function:

◆ RTCPCompoundPacket() [3/3]

qrtplib::RTCPCompoundPacket::RTCPCompoundPacket ( )
protected

Definition at line 92 of file rtcpcompoundpacket.cpp.

References compoundpacket, compoundpacketlength, and error.

◆ ~RTCPCompoundPacket()

qrtplib::RTCPCompoundPacket::~RTCPCompoundPacket ( )
virtual

Definition at line 188 of file rtcpcompoundpacket.cpp.

References ClearPacketList().

189 {
190  ClearPacketList();
191 }
+ Here is the call graph for this function:

Member Function Documentation

◆ ClearPacketList()

void qrtplib::RTCPCompoundPacket::ClearPacketList ( )
protected

Definition at line 193 of file rtcpcompoundpacket.cpp.

References rtcppackit, and rtcppacklist.

Referenced by ParseData(), and ~RTCPCompoundPacket().

194 {
195  std::list<RTCPPacket *>::const_iterator it;
196 
197  for (it = rtcppacklist.begin(); it != rtcppacklist.end(); it++) {
198  delete *it;
199  }
200 
201  rtcppacklist.clear();
202  rtcppackit = rtcppacklist.begin();
203 }
std::list< RTCPPacket * > rtcppacklist
std::list< RTCPPacket * >::const_iterator rtcppackit
+ Here is the caller graph for this function:

◆ GetCompoundPacketData()

uint8_t* qrtplib::RTCPCompoundPacket::GetCompoundPacketData ( )
inline

Returns a pointer to the data of the entire RTCP compound packet.

Definition at line 78 of file rtcpcompoundpacket.h.

Referenced by qrtplib::RTPSession::BYEDestroy(), qrtplib::RTPSession::ProcessPolledData(), and qrtplib::RTPSession::SendRTCPAPPPacket().

79  {
80  return compoundpacket;
81  }
+ Here is the caller graph for this function:

◆ GetCompoundPacketLength()

std::size_t qrtplib::RTCPCompoundPacket::GetCompoundPacketLength ( )
inline

Returns the size of the entire RTCP compound packet.

Definition at line 84 of file rtcpcompoundpacket.h.

Referenced by qrtplib::RTCPScheduler::AnalyseIncoming(), qrtplib::RTCPScheduler::AnalyseOutgoing(), qrtplib::RTPSession::BYEDestroy(), qrtplib::RTPSession::ProcessPolledData(), and qrtplib::RTPSession::SendRTCPAPPPacket().

85  {
86  return compoundpacketlength;
87  }
+ Here is the caller graph for this function:

◆ GetCreationError()

int qrtplib::RTCPCompoundPacket::GetCreationError ( )
inline

Checks if the RTCP compound packet was created successfully. If the raw packet data in the constructor could not be parsed, this function returns the error code of what went wrong. If the packet had an invalid format, the return value is ERR_RTP_RTCPCOMPOUND_INVALIDPACKET.

Definition at line 72 of file rtcpcompoundpacket.h.

Referenced by qrtplib::RTPSources::ProcessRawPacket().

73  {
74  return error;
75  }
+ Here is the caller graph for this function:

◆ GetNextPacket()

RTCPPacket* qrtplib::RTCPCompoundPacket::GetNextPacket ( )
inline

Returns a pointer to the next individual RTCP packet. Returns a pointer to the next individual RTCP packet. Note that no delete call may be done on the RTCPPacket instance which is returned.

Definition at line 99 of file rtcpcompoundpacket.h.

Referenced by qrtplib::RTCPScheduler::AnalyseIncoming(), qrtplib::RTCPScheduler::AnalyseOutgoing(), and qrtplib::RTPSources::ProcessRTCPCompoundPacket().

100  {
101  if (rtcppackit == rtcppacklist.end())
102  return 0;
103  RTCPPacket *p = *rtcppackit;
104  rtcppackit++;
105  return p;
106  }
std::list< RTCPPacket * > rtcppacklist
std::list< RTCPPacket * >::const_iterator rtcppackit
+ Here is the caller graph for this function:

◆ GotoFirstPacket()

void qrtplib::RTCPCompoundPacket::GotoFirstPacket ( )
inline

Starts the iteration over the individual RTCP packets in the RTCP compound packet.

Definition at line 90 of file rtcpcompoundpacket.h.

Referenced by qrtplib::RTCPScheduler::AnalyseIncoming(), qrtplib::RTCPScheduler::AnalyseOutgoing(), and qrtplib::RTPSources::ProcessRTCPCompoundPacket().

91  {
92  rtcppackit = rtcppacklist.begin();
93  }
std::list< RTCPPacket * > rtcppacklist
std::list< RTCPPacket * >::const_iterator rtcppackit
+ Here is the caller graph for this function:

◆ ParseData()

int qrtplib::RTCPCompoundPacket::ParseData ( uint8_t packet,
std::size_t  len 
)
protected

Definition at line 99 of file rtcpcompoundpacket.cpp.

References ClearPacketList(), ERR_RTP_RTCPCOMPOUND_INVALIDPACKET, qrtplib::RTCPCommonHeader::length, m_endian, qrtplib::RTCPCommonHeader::packettype, qrtplib::RTCPCommonHeader::padding, qrtplib::RTPEndian::qToHost(), rtcppacklist, RTP_RTCPTYPE_APP, RTP_RTCPTYPE_BYE, RTP_RTCPTYPE_RR, RTP_RTCPTYPE_SDES, RTP_RTCPTYPE_SR, RTP_VERSION, and qrtplib::RTCPCommonHeader::version.

Referenced by RTCPCompoundPacket().

100 {
101  bool first;
102 
103  if (datalen < sizeof(RTCPCommonHeader))
105 
106  first = true;
107 
108  do
109  {
110  RTCPCommonHeader *rtcphdr;
111  std::size_t length;
112 
113  rtcphdr = (RTCPCommonHeader *) data;
114  if (rtcphdr->version != RTP_VERSION) // check version
115  {
116  ClearPacketList();
118  }
119  if (first)
120  {
121  // Check if first packet is SR or RR
122 
123  first = false;
124  if (!(rtcphdr->packettype == RTP_RTCPTYPE_SR || rtcphdr->packettype == RTP_RTCPTYPE_RR))
125  {
126  ClearPacketList();
128  }
129  }
130 
131  length = (std::size_t) m_endian.qToHost(rtcphdr->length);
132  length++;
133  length *= sizeof(uint32_t);
134 
135  if (length > datalen) // invalid length field
136  {
137  ClearPacketList();
139  }
140 
141  if (rtcphdr->padding)
142  {
143  // check if it's the last packet
144  if (length != datalen)
145  {
146  ClearPacketList();
148  }
149  }
150 
151  RTCPPacket *p;
152 
153  switch (rtcphdr->packettype)
154  {
155  case RTP_RTCPTYPE_SR:
156  p = new RTCPSRPacket(data, length);
157  break;
158  case RTP_RTCPTYPE_RR:
159  p = new RTCPRRPacket(data, length);
160  break;
161  case RTP_RTCPTYPE_SDES:
162  p = new RTCPSDESPacket(data, length);
163  break;
164  case RTP_RTCPTYPE_BYE:
165  p = new RTCPBYEPacket(data, length);
166  break;
167  case RTP_RTCPTYPE_APP:
168  p = new RTCPAPPPacket(data, length);
169  break;
170  default:
171  p = new RTCPUnknownPacket(data, length);
172  }
173 
174  rtcppacklist.push_back(p);
175 
176  datalen -= length;
177  data += length;
178  } while (datalen >= (std::size_t) sizeof(RTCPCommonHeader));
179 
180  if (datalen != 0) // some remaining bytes
181  {
182  ClearPacketList();
184  }
185  return 0;
186 }
#define RTP_RTCPTYPE_BYE
Definition: rtpdefines.h:53
T qToHost(const T &x) const
Definition: rtpendian.h:27
unsigned int uint32_t
Definition: rtptypes_win.h:46
#define RTP_RTCPTYPE_RR
Definition: rtpdefines.h:51
std::list< RTCPPacket * > rtcppacklist
#define RTP_RTCPTYPE_SR
Definition: rtpdefines.h:50
#define RTP_VERSION
Definition: rtpdefines.h:37
#define RTP_RTCPTYPE_APP
Definition: rtpdefines.h:54
#define RTP_RTCPTYPE_SDES
Definition: rtpdefines.h:52
#define ERR_RTP_RTCPCOMPOUND_INVALIDPACKET
Definition: rtperrors.h:82
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ compoundpacket

uint8_t* qrtplib::RTCPCompoundPacket::compoundpacket
protected

◆ compoundpacketlength

std::size_t qrtplib::RTCPCompoundPacket::compoundpacketlength
protected

◆ error

int qrtplib::RTCPCompoundPacket::error
protected

Definition at line 113 of file rtcpcompoundpacket.h.

Referenced by RTCPCompoundPacket().

◆ m_endian

RTPEndian qrtplib::RTCPCompoundPacket::m_endian
protected

Definition at line 112 of file rtcpcompoundpacket.h.

Referenced by ParseData().

◆ rtcppackit

std::list<RTCPPacket *>::const_iterator qrtplib::RTCPCompoundPacket::rtcppackit
protected

Definition at line 119 of file rtcpcompoundpacket.h.

Referenced by ClearPacketList(), and RTCPCompoundPacket().

◆ rtcppacklist

std::list<RTCPPacket *> qrtplib::RTCPCompoundPacket::rtcppacklist
protected

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