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 | Private Attributes | List of all members
qrtplib::RTCPBYEPacket Class Reference

#include <rtcpbyepacket.h>

+ Inheritance diagram for qrtplib::RTCPBYEPacket:
+ Collaboration diagram for qrtplib::RTCPBYEPacket:

Public Member Functions

 RTCPBYEPacket (uint8_t *data, std::size_t datalen)
 
 ~RTCPBYEPacket ()
 
int GetSSRCCount () const
 
uint32_t GetSSRC (int index) const
 
bool HasReasonForLeaving () const
 
std::size_t GetReasonLength () const
 
uint8_tGetReasonData ()
 
- Public Member Functions inherited from qrtplib::RTCPPacket
virtual ~RTCPPacket ()
 
bool IsKnownFormat () const
 
PacketType GetPacketType () const
 
uint8_tGetPacketData ()
 
std::size_t GetPacketLength () const
 

Private Attributes

RTPEndian m_endian
 
std::size_t reasonoffset
 

Additional Inherited Members

- Public Types inherited from qrtplib::RTCPPacket
enum  PacketType {
  SR, RR, SDES, BYE,
  APP, Unknown
}
 
- Protected Member Functions inherited from qrtplib::RTCPPacket
 RTCPPacket (PacketType t, uint8_t *d, std::size_t dlen)
 
- Protected Attributes inherited from qrtplib::RTCPPacket
uint8_tdata
 
std::size_t datalen
 
bool knownformat
 

Detailed Description

Describes an RTCP BYE packet.

Definition at line 54 of file rtcpbyepacket.h.

Constructor & Destructor Documentation

◆ RTCPBYEPacket()

qrtplib::RTCPBYEPacket::RTCPBYEPacket ( uint8_t data,
std::size_t  datalen 
)

Creates an instance based on the data in data with length datalen. Creates an instance based on the data in data with length datalen. Since the data pointer is referenced inside the class (no copy of the data is made) one must make sure that the memory it points to is valid as long as the class instance exists.

Definition at line 38 of file rtcpbyepacket.cpp.

References qrtplib::RTCPCommonHeader::count, qrtplib::RTCPPacket::knownformat, qrtplib::RTCPCommonHeader::padding, and reasonoffset.

38  :
39  RTCPPacket(BYE, data, datalength)
40 {
41  knownformat = false;
42  reasonoffset = 0;
43 
44  RTCPCommonHeader *hdr;
45  std::size_t len = datalength;
46 
47  hdr = (RTCPCommonHeader *) data;
48  if (hdr->padding)
49  {
50  uint8_t padcount = data[datalength - 1];
51  if ((padcount & 0x03) != 0) // not a multiple of four! (see rfc 3550 p 37)
52  return;
53  if (((std::size_t) padcount) >= len)
54  return;
55  len -= (std::size_t) padcount;
56  }
57 
58  std::size_t ssrclen = ((std::size_t)(hdr->count)) * sizeof(uint32_t) + sizeof(RTCPCommonHeader);
59  if (ssrclen > len)
60  return;
61  if (ssrclen < len) // there's probably a reason for leaving
62  {
63  uint8_t *reasonlength = (data + ssrclen);
64  std::size_t reaslen = (std::size_t)(*reasonlength);
65  if (reaslen > (len - ssrclen - 1))
66  return;
67  reasonoffset = ssrclen;
68  }
69  knownformat = true;
70 }
std::size_t reasonoffset
Definition: rtcpbyepacket.h:86
unsigned int uint32_t
Definition: rtptypes_win.h:46
unsigned char uint8_t
Definition: rtptypes_win.h:42
RTCPPacket(PacketType t, uint8_t *d, std::size_t dlen)
Definition: rtcppacket.h:65

◆ ~RTCPBYEPacket()

qrtplib::RTCPBYEPacket::~RTCPBYEPacket ( )
inline

Definition at line 63 of file rtcpbyepacket.h.

64  {
65  }

Member Function Documentation

◆ GetReasonData()

uint8_t * qrtplib::RTCPBYEPacket::GetReasonData ( )
inline

Returns the actual reason for leaving data.

Definition at line 125 of file rtcpbyepacket.h.

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

126 {
127  if (!knownformat)
128  return 0;
129  if (reasonoffset == 0)
130  return 0;
131  uint8_t *reasonlen = (data + reasonoffset);
132  if ((*reasonlen) == 0)
133  return 0;
134  return (data + reasonoffset + 1);
135 }
std::size_t reasonoffset
Definition: rtcpbyepacket.h:86
unsigned char uint8_t
Definition: rtptypes_win.h:42
+ Here is the caller graph for this function:

◆ GetReasonLength()

std::size_t qrtplib::RTCPBYEPacket::GetReasonLength ( ) const
inline

Returns the length of the string which describes why the source(s) left.

Definition at line 115 of file rtcpbyepacket.h.

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

116 {
117  if (!knownformat)
118  return 0;
119  if (reasonoffset == 0)
120  return 0;
121  uint8_t *reasonlen = (data + reasonoffset);
122  return (std::size_t)(*reasonlen);
123 }
std::size_t reasonoffset
Definition: rtcpbyepacket.h:86
unsigned char uint8_t
Definition: rtptypes_win.h:42
+ Here is the caller graph for this function:

◆ GetSSRC()

uint32_t qrtplib::RTCPBYEPacket::GetSSRC ( int  index) const
inline

Returns the SSRC described by index which may have a value from 0 to GetSSRCCount()-1 (note that no check is performed to see if index is valid).

Definition at line 98 of file rtcpbyepacket.h.

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

99 {
100  if (!knownformat)
101  return 0;
102  uint32_t *ssrc = (uint32_t *) (data + sizeof(RTCPCommonHeader) + sizeof(uint32_t) * index);
103  return m_endian.qToHost(*ssrc);
104 }
T qToHost(const T &x) const
Definition: rtpendian.h:27
unsigned int uint32_t
Definition: rtptypes_win.h:46
+ Here is the caller graph for this function:

◆ GetSSRCCount()

int qrtplib::RTCPBYEPacket::GetSSRCCount ( ) const
inline

Returns the number of SSRC identifiers present in this BYE packet.

Definition at line 89 of file rtcpbyepacket.h.

References qrtplib::RTCPCommonHeader::count.

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

90 {
91  if (!knownformat)
92  return 0;
93 
94  RTCPCommonHeader *hdr = (RTCPCommonHeader *) data;
95  return (int) (hdr->count);
96 }
+ Here is the caller graph for this function:

◆ HasReasonForLeaving()

bool qrtplib::RTCPBYEPacket::HasReasonForLeaving ( ) const
inline

Returns true if the BYE packet contains a reason for leaving.

Definition at line 106 of file rtcpbyepacket.h.

107 {
108  if (!knownformat)
109  return false;
110  if (reasonoffset == 0)
111  return false;
112  return true;
113 }
std::size_t reasonoffset
Definition: rtcpbyepacket.h:86

Member Data Documentation

◆ m_endian

RTPEndian qrtplib::RTCPBYEPacket::m_endian
private

Definition at line 85 of file rtcpbyepacket.h.

◆ reasonoffset

std::size_t qrtplib::RTCPBYEPacket::reasonoffset
private

Definition at line 86 of file rtcpbyepacket.h.

Referenced by RTCPBYEPacket().


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