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

#include <rtppacketbuilder.h>

+ Collaboration diagram for qrtplib::RTPPacketBuilder:

Public Member Functions

 RTPPacketBuilder (RTPRandom &rtprand)
 
 ~RTPPacketBuilder ()
 
int Init (unsigned int maxpacksize)
 
void Destroy ()
 
uint32_t GetPacketCount ()
 
uint32_t GetPayloadOctetCount ()
 
int SetMaximumPacketSize (unsigned int maxpacksize)
 
int AddCSRC (uint32_t csrc)
 
int DeleteCSRC (uint32_t csrc)
 
void ClearCSRCList ()
 
int BuildPacket (const void *data, unsigned int len)
 
int BuildPacket (const void *data, unsigned int len, uint8_t pt, bool mark, uint32_t timestampinc)
 
int BuildPacketEx (const void *data, unsigned int len, uint16_t hdrextID, const void *hdrextdata, unsigned int numhdrextwords)
 
int BuildPacketEx (const void *data, unsigned int len, uint8_t pt, bool mark, uint32_t timestampinc, uint16_t hdrextID, const void *hdrextdata, unsigned int numhdrextwords)
 
uint8_tGetPacket ()
 
unsigned int GetPacketLength ()
 
int SetDefaultPayloadType (uint8_t pt)
 
int SetDefaultMark (bool m)
 
int SetDefaultTimestampIncrement (uint32_t timestampinc)
 
int IncrementTimestamp (uint32_t inc)
 
int IncrementTimestampDefault ()
 
uint32_t CreateNewSSRC ()
 
uint32_t CreateNewSSRC (RTPSources &sources)
 
uint32_t GetSSRC () const
 
uint32_t GetTimestamp () const
 
uint16_t GetSequenceNumber () const
 
RTPTime GetPacketTime () const
 
uint32_t GetPacketTimestamp () const
 
void AdjustSSRC (uint32_t s)
 

Private Member Functions

int PrivateBuildPacket (const void *data, unsigned int len, uint8_t pt, bool mark, uint32_t timestampinc, bool gotextension, uint16_t hdrextID=0, const void *hdrextdata=0, unsigned int numhdrextwords=0)
 

Private Attributes

RTPRandomrtprnd
 
unsigned int maxpacksize
 
uint8_tbuffer
 
unsigned int packetlength
 
uint32_t numpayloadbytes
 
uint32_t numpackets
 
bool init
 
uint32_t ssrc
 
uint32_t timestamp
 
uint16_t seqnr
 
uint32_t defaulttimestampinc
 
uint8_t defaultpayloadtype
 
bool defaultmark
 
bool deftsset
 
bool defptset
 
bool defmarkset
 
uint32_t csrcs [RTP_MAXCSRCS]
 
int numcsrcs
 
RTPTime lastwallclocktime
 
uint32_t lastrtptimestamp
 
uint32_t prevrtptimestamp
 

Detailed Description

This class can be used to build RTP packets and is a bit more high-level than the RTPPacket class: it generates an SSRC identifier, keeps track of timestamp and sequence number etc.

Definition at line 58 of file rtppacketbuilder.h.

Constructor & Destructor Documentation

◆ RTPPacketBuilder()

qrtplib::RTPPacketBuilder::RTPPacketBuilder ( RTPRandom rtprand)

Constructs an instance which will use rtprand for generating random numbers (used to initialize the SSRC value and sequence number), optionally installing a memory manager.

Definition at line 43 of file rtppacketbuilder.cpp.

References csrcs, defaultmark, defaultpayloadtype, defaulttimestampinc, defmarkset, defptset, deftsset, qrtplib::RTPTimeInitializerObject::Dummy(), init, lastrtptimestamp, numcsrcs, numpackets, numpayloadbytes, prevrtptimestamp, RTP_MAXCSRCS, seqnr, ssrc, qrtplib::timeinit, and timestamp.

43  :
44  rtprnd(r),
45  maxpacksize(0),
46  buffer(0),
47  packetlength(0),
48  lastwallclocktime(0, 0)
49 {
50  init = false;
51  deftsset = false;
52  defptset = false;
53  defmarkset = false;
54  defaultmark = false;
56  ssrc = 0;
57  timestamp = 0;
58  seqnr = 0;
59  prevrtptimestamp = 0;
60  lastrtptimestamp = 0;
62  numcsrcs = 0;
63  numpayloadbytes = 0;
64  numpackets = 0;
65  memset((char *) csrcs, 0, RTP_MAXCSRCS*sizeof(uint32_t));
66  timeinit.Dummy();
67 
68  //std::cout << (void *)(&rtprnd) << std::endl;
69 }
RTPTimeInitializerObject timeinit
unsigned int uint32_t
Definition: rtptypes_win.h:46
#define RTP_MAXCSRCS
Definition: rtpdefines.h:38
uint32_t csrcs[RTP_MAXCSRCS]
+ Here is the call graph for this function:

◆ ~RTPPacketBuilder()

qrtplib::RTPPacketBuilder::~RTPPacketBuilder ( )

Definition at line 71 of file rtppacketbuilder.cpp.

References Destroy().

72 {
73  Destroy();
74 }
+ Here is the call graph for this function:

Member Function Documentation

◆ AddCSRC()

int qrtplib::RTPPacketBuilder::AddCSRC ( uint32_t  csrc)

Adds a CSRC to the CSRC list which will be stored in the RTP packets.

Definition at line 122 of file rtppacketbuilder.cpp.

References csrcs, ERR_RTP_PACKBUILD_CSRCALREADYINLIST, ERR_RTP_PACKBUILD_CSRCLISTFULL, ERR_RTP_PACKBUILD_NOTINIT, i, init, numcsrcs, and RTP_MAXCSRCS.

123 {
124  if (!init)
126  if (numcsrcs >= RTP_MAXCSRCS)
128 
129  int i;
130 
131  for (i = 0; i < numcsrcs; i++)
132  {
133  if (csrcs[i] == csrc)
135  }
136  csrcs[numcsrcs] = csrc;
137  numcsrcs++;
138  return 0;
139 }
#define ERR_RTP_PACKBUILD_NOTINIT
Definition: rtperrors.h:72
#define ERR_RTP_PACKBUILD_CSRCLISTFULL
Definition: rtperrors.h:66
int32_t i
Definition: decimators.h:244
#define RTP_MAXCSRCS
Definition: rtpdefines.h:38
uint32_t csrcs[RTP_MAXCSRCS]
#define ERR_RTP_PACKBUILD_CSRCALREADYINLIST
Definition: rtperrors.h:65

◆ AdjustSSRC()

void qrtplib::RTPPacketBuilder::AdjustSSRC ( uint32_t  s)
inline

Sets a specific SSRC to be used. Sets a specific SSRC to be used. Does not create a new timestamp offset or sequence number offset. Does not reset the packet count or byte count. Think twice before using this!

Definition at line 235 of file rtppacketbuilder.h.

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

236  {
237  ssrc = s;
238  }
+ Here is the caller graph for this function:

◆ BuildPacket() [1/2]

int qrtplib::RTPPacketBuilder::BuildPacket ( const void *  data,
unsigned int  len 
)

Builds a packet with payload data and payload length len. Builds a packet with payload data and payload length len. The payload type, marker and timestamp increment used will be those that have been set using the SetDefault functions below.

Definition at line 207 of file rtppacketbuilder.cpp.

References defaultmark, defaultpayloadtype, defaulttimestampinc, defmarkset, defptset, deftsset, ERR_RTP_PACKBUILD_DEFAULTMARKNOTSET, ERR_RTP_PACKBUILD_DEFAULTPAYLOADTYPENOTSET, ERR_RTP_PACKBUILD_DEFAULTTSINCNOTSET, ERR_RTP_PACKBUILD_NOTINIT, init, and PrivateBuildPacket().

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

208 {
209  if (!init)
211  if (!defptset)
213  if (!defmarkset)
215  if (!deftsset)
218 }
#define ERR_RTP_PACKBUILD_DEFAULTPAYLOADTYPENOTSET
Definition: rtperrors.h:69
#define ERR_RTP_PACKBUILD_DEFAULTTSINCNOTSET
Definition: rtperrors.h:70
int PrivateBuildPacket(const void *data, unsigned int len, uint8_t pt, bool mark, uint32_t timestampinc, bool gotextension, uint16_t hdrextID=0, const void *hdrextdata=0, unsigned int numhdrextwords=0)
#define ERR_RTP_PACKBUILD_NOTINIT
Definition: rtperrors.h:72
#define ERR_RTP_PACKBUILD_DEFAULTMARKNOTSET
Definition: rtperrors.h:68
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ BuildPacket() [2/2]

int qrtplib::RTPPacketBuilder::BuildPacket ( const void *  data,
unsigned int  len,
uint8_t  pt,
bool  mark,
uint32_t  timestampinc 
)

Builds a packet with payload data and payload length len. Builds a packet with payload data and payload length len. The payload type will be set to pt, the marker bit to mark and after building this packet, the timestamp will be incremented with timestamp.

Definition at line 220 of file rtppacketbuilder.cpp.

References ERR_RTP_PACKBUILD_NOTINIT, init, and PrivateBuildPacket().

221 {
222  if (!init)
224  return PrivateBuildPacket(data, len, pt, mark, timestampinc, false);
225 }
int PrivateBuildPacket(const void *data, unsigned int len, uint8_t pt, bool mark, uint32_t timestampinc, bool gotextension, uint16_t hdrextID=0, const void *hdrextdata=0, unsigned int numhdrextwords=0)
#define ERR_RTP_PACKBUILD_NOTINIT
Definition: rtperrors.h:72
+ Here is the call graph for this function:

◆ BuildPacketEx() [1/2]

int qrtplib::RTPPacketBuilder::BuildPacketEx ( const void *  data,
unsigned int  len,
uint16_t  hdrextID,
const void *  hdrextdata,
unsigned int  numhdrextwords 
)

Builds a packet with payload data and payload length len. Builds a packet with payload data and payload length len. The payload type, marker and timestamp increment used will be those that have been set using the SetDefault functions below. This packet will also contain an RTP header extension with identifier hdrextID and data hdrextdata. The length of the header extension data is given by numhdrextwords which expresses the length in a number of 32-bit words.

Definition at line 227 of file rtppacketbuilder.cpp.

References defaultmark, defaultpayloadtype, defaulttimestampinc, defmarkset, defptset, deftsset, ERR_RTP_PACKBUILD_DEFAULTMARKNOTSET, ERR_RTP_PACKBUILD_DEFAULTPAYLOADTYPENOTSET, ERR_RTP_PACKBUILD_DEFAULTTSINCNOTSET, ERR_RTP_PACKBUILD_NOTINIT, init, and PrivateBuildPacket().

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

228 {
229  if (!init)
231  if (!defptset)
233  if (!defmarkset)
235  if (!deftsset)
237  return PrivateBuildPacket(data, len, defaultpayloadtype, defaultmark, defaulttimestampinc, true, hdrextID, hdrextdata, numhdrextwords);
238 }
#define ERR_RTP_PACKBUILD_DEFAULTPAYLOADTYPENOTSET
Definition: rtperrors.h:69
#define ERR_RTP_PACKBUILD_DEFAULTTSINCNOTSET
Definition: rtperrors.h:70
int PrivateBuildPacket(const void *data, unsigned int len, uint8_t pt, bool mark, uint32_t timestampinc, bool gotextension, uint16_t hdrextID=0, const void *hdrextdata=0, unsigned int numhdrextwords=0)
#define ERR_RTP_PACKBUILD_NOTINIT
Definition: rtperrors.h:72
#define ERR_RTP_PACKBUILD_DEFAULTMARKNOTSET
Definition: rtperrors.h:68
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ BuildPacketEx() [2/2]

int qrtplib::RTPPacketBuilder::BuildPacketEx ( const void *  data,
unsigned int  len,
uint8_t  pt,
bool  mark,
uint32_t  timestampinc,
uint16_t  hdrextID,
const void *  hdrextdata,
unsigned int  numhdrextwords 
)

Builds a packet with payload data and payload length len. Builds a packet with payload data and payload length len. The payload type will be set to pt, the marker bit to mark and after building this packet, the timestamp will be incremented with timestamp. This packet will also contain an RTP header extension with identifier hdrextID and data hdrextdata. The length of the header extension data is given by numhdrextwords which expresses the length in a number of 32-bit words.

Definition at line 240 of file rtppacketbuilder.cpp.

References ERR_RTP_PACKBUILD_NOTINIT, init, and PrivateBuildPacket().

241 {
242  if (!init)
244  return PrivateBuildPacket(data, len, pt, mark, timestampinc, true, hdrextID, hdrextdata, numhdrextwords);
245 
246 }
int PrivateBuildPacket(const void *data, unsigned int len, uint8_t pt, bool mark, uint32_t timestampinc, bool gotextension, uint16_t hdrextID=0, const void *hdrextdata=0, unsigned int numhdrextwords=0)
#define ERR_RTP_PACKBUILD_NOTINIT
Definition: rtperrors.h:72
+ Here is the call graph for this function:

◆ ClearCSRCList()

void qrtplib::RTPPacketBuilder::ClearCSRCList ( )

Clears the CSRC list.

Definition at line 167 of file rtppacketbuilder.cpp.

References init, and numcsrcs.

168 {
169  if (!init)
170  return;
171  numcsrcs = 0;
172 }

◆ CreateNewSSRC() [1/2]

uint32_t qrtplib::RTPPacketBuilder::CreateNewSSRC ( )

Creates a new SSRC to be used in generated packets. Creates a new SSRC to be used in generated packets. This will also generate new timestamp and sequence number offsets.

Definition at line 174 of file rtppacketbuilder.cpp.

References qrtplib::RTPRandom::GetRandom16(), qrtplib::RTPRandom::GetRandom32(), numpackets, numpayloadbytes, rtprnd, seqnr, ssrc, and timestamp.

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

175 {
176  ssrc = rtprnd.GetRandom32();
179 
180  qDebug("RTPPacketBuilder::CreateNewSSRC: timestamp: %u", timestamp);
181 
182  // p 38: the count SHOULD be reset if the sender changes its SSRC identifier
183  numpayloadbytes = 0;
184  numpackets = 0;
185  return ssrc;
186 }
virtual uint32_t GetRandom32()=0
virtual uint16_t GetRandom16()=0
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CreateNewSSRC() [2/2]

uint32_t qrtplib::RTPPacketBuilder::CreateNewSSRC ( RTPSources sources)

Creates a new SSRC to be used in generated packets. Creates a new SSRC to be used in generated packets. This will also generate new timestamp and sequence number offsets. The source table sources is used to make sure that the chosen SSRC isn't used by another participant yet.

Definition at line 188 of file rtppacketbuilder.cpp.

References qrtplib::RTPRandom::GetRandom16(), qrtplib::RTPRandom::GetRandom32(), qrtplib::RTPSources::GotEntry(), numpackets, numpayloadbytes, rtprnd, seqnr, ssrc, and timestamp.

189 {
190  bool found;
191 
192  do
193  {
194  ssrc = rtprnd.GetRandom32();
195  found = sources.GotEntry(ssrc);
196  } while (found);
197 
200 
201  // p 38: the count SHOULD be reset if the sender changes its SSRC identifier
202  numpayloadbytes = 0;
203  numpackets = 0;
204  return ssrc;
205 }
virtual uint32_t GetRandom32()=0
virtual uint16_t GetRandom16()=0
+ Here is the call graph for this function:

◆ DeleteCSRC()

int qrtplib::RTPPacketBuilder::DeleteCSRC ( uint32_t  csrc)

Deletes a CSRC from the list which will be stored in the RTP packets.

Definition at line 141 of file rtppacketbuilder.cpp.

References csrcs, ERR_RTP_PACKBUILD_CSRCNOTINLIST, ERR_RTP_PACKBUILD_NOTINIT, i, init, and numcsrcs.

142 {
143  if (!init)
145 
146  int i = 0;
147  bool found = false;
148 
149  while (!found && i < numcsrcs)
150  {
151  if (csrcs[i] == csrc)
152  found = true;
153  else
154  i++;
155  }
156 
157  if (!found)
159 
160  // move the last csrc in the place of the deleted one
161  numcsrcs--;
162  if (numcsrcs > 0 && numcsrcs != i)
163  csrcs[i] = csrcs[numcsrcs];
164  return 0;
165 }
#define ERR_RTP_PACKBUILD_CSRCNOTINLIST
Definition: rtperrors.h:67
#define ERR_RTP_PACKBUILD_NOTINIT
Definition: rtperrors.h:72
int32_t i
Definition: decimators.h:244
uint32_t csrcs[RTP_MAXCSRCS]

◆ Destroy()

void qrtplib::RTPPacketBuilder::Destroy ( )

Cleans up the builder.

Definition at line 100 of file rtppacketbuilder.cpp.

References buffer, and init.

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

101 {
102  if (!init)
103  return;
104  delete[] buffer;
105  init = false;
106 }
+ Here is the caller graph for this function:

◆ GetPacket()

uint8_t* qrtplib::RTPPacketBuilder::GetPacket ( )
inline

Returns a pointer to the last built RTP packet data.

Definition at line 134 of file rtppacketbuilder.h.

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

135  {
136  if (!init)
137  return 0;
138  return buffer;
139  }
+ Here is the caller graph for this function:

◆ GetPacketCount()

uint32_t qrtplib::RTPPacketBuilder::GetPacketCount ( )
inline

Returns the number of packets which have been created with the current SSRC identifier.

Definition at line 74 of file rtppacketbuilder.h.

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

75  {
76  if (!init)
77  return 0;
78  return numpackets;
79  }
+ Here is the caller graph for this function:

◆ GetPacketLength()

unsigned int qrtplib::RTPPacketBuilder::GetPacketLength ( )
inline

Returns the size of the last built RTP packet.

Definition at line 142 of file rtppacketbuilder.h.

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

143  {
144  if (!init)
145  return 0;
146  return packetlength;
147  }
+ Here is the caller graph for this function:

◆ GetPacketTime()

RTPTime qrtplib::RTPPacketBuilder::GetPacketTime ( ) const
inline

Returns the time at which a packet was generated. Returns the time at which a packet was generated. This is not necessarily the time at which the last RTP packet was generated: if the timestamp increment was zero, the time is not updated.

Definition at line 216 of file rtppacketbuilder.h.

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

217  {
218  if (!init)
219  return RTPTime(0, 0);
220  return lastwallclocktime;
221  }
+ Here is the caller graph for this function:

◆ GetPacketTimestamp()

uint32_t qrtplib::RTPPacketBuilder::GetPacketTimestamp ( ) const
inline

Returns the RTP timestamp which corresponds to the time returned by the previous function.

Definition at line 224 of file rtppacketbuilder.h.

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

225  {
226  if (!init)
227  return 0;
228  return lastrtptimestamp;
229  }
+ Here is the caller graph for this function:

◆ GetPayloadOctetCount()

uint32_t qrtplib::RTPPacketBuilder::GetPayloadOctetCount ( )
inline

Returns the number of payload octets which have been generated with this SSRC identifier.

Definition at line 82 of file rtppacketbuilder.h.

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

83  {
84  if (!init)
85  return 0;
86  return numpayloadbytes;
87  }
+ Here is the caller graph for this function:

◆ GetSequenceNumber()

uint16_t qrtplib::RTPPacketBuilder::GetSequenceNumber ( ) const
inline

Returns the current sequence number.

Definition at line 205 of file rtppacketbuilder.h.

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

206  {
207  if (!init)
208  return 0;
209  return seqnr;
210  }
+ Here is the caller graph for this function:

◆ GetSSRC()

uint32_t qrtplib::RTPPacketBuilder::GetSSRC ( ) const
inline

Returns the current SSRC identifier.

Definition at line 189 of file rtppacketbuilder.h.

Referenced by qrtplib::RTCPPacketBuilder::BuildBYEPacket(), qrtplib::RTCPPacketBuilder::BuildNextPacket(), qrtplib::RTPSession::GetLocalSSRC(), qrtplib::RTPSession::InternalCreate(), and qrtplib::RTPSession::SendRTCPAPPPacket().

190  {
191  if (!init)
192  return 0;
193  return ssrc;
194  }
+ Here is the caller graph for this function:

◆ GetTimestamp()

uint32_t qrtplib::RTPPacketBuilder::GetTimestamp ( ) const
inline

Returns the current RTP timestamp.

Definition at line 197 of file rtppacketbuilder.h.

198  {
199  if (!init)
200  return 0;
201  return timestamp;
202  }

◆ IncrementTimestamp()

int qrtplib::RTPPacketBuilder::IncrementTimestamp ( uint32_t  inc)
inline

This function increments the timestamp with the amount given by inc. This function increments the timestamp with the amount given by inc. This can be useful if, for example, a packet was not sent because it contained only silence. Then, this function should be called to increment the timestamp with the appropriate amount so that the next packets will still be played at the correct time at other hosts.

Definition at line 303 of file rtppacketbuilder.h.

References ERR_RTP_PACKBUILD_NOTINIT.

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

304 {
305  if (!init)
307  timestamp += inc;
308  return 0;
309 }
#define ERR_RTP_PACKBUILD_NOTINIT
Definition: rtperrors.h:72
+ Here is the caller graph for this function:

◆ IncrementTimestampDefault()

int qrtplib::RTPPacketBuilder::IncrementTimestampDefault ( )
inline

This function increments the timestamp with the amount given set by the SetDefaultTimestampIncrement member function. This function increments the timestamp with the amount given set by the SetDefaultTimestampIncrement member function. This can be useful if, for example, a packet was not sent because it contained only silence. Then, this function should be called to increment the timestamp with the appropriate amount so that the next packets will still be played at the correct time at other hosts.

Definition at line 311 of file rtppacketbuilder.h.

References ERR_RTP_PACKBUILD_DEFAULTTSINCNOTSET, and ERR_RTP_PACKBUILD_NOTINIT.

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

312 {
313  if (!init)
315  if (!deftsset)
318  return 0;
319 }
#define ERR_RTP_PACKBUILD_DEFAULTTSINCNOTSET
Definition: rtperrors.h:70
#define ERR_RTP_PACKBUILD_NOTINIT
Definition: rtperrors.h:72
+ Here is the caller graph for this function:

◆ Init()

int qrtplib::RTPPacketBuilder::Init ( unsigned int  maxpacksize)

Initializes the builder to only allow packets with a size below maxpacksize.

Definition at line 76 of file rtppacketbuilder.cpp.

References buffer, CreateNewSSRC(), defmarkset, defptset, deftsset, ERR_RTP_PACKBUILD_ALREADYINIT, ERR_RTP_PACKBUILD_INVALIDMAXPACKETSIZE, init, leansdr::max(), maxpacksize, numcsrcs, numpackets, and packetlength.

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

77 {
78  if (init)
80  if (max <= 0)
82 
83  maxpacksize = max;
84  buffer = new uint8_t[max];
85  packetlength = 0;
86  numpackets = 0;
87 
88  CreateNewSSRC();
89 
90  deftsset = false;
91  defptset = false;
92  defmarkset = false;
93 
94  numcsrcs = 0;
95 
96  init = true;
97  return 0;
98 }
unsigned char uint8_t
Definition: rtptypes_win.h:42
#define ERR_RTP_PACKBUILD_ALREADYINIT
Definition: rtperrors.h:64
#define ERR_RTP_PACKBUILD_INVALIDMAXPACKETSIZE
Definition: rtperrors.h:71
T max(const T &x, const T &y)
Definition: framework.h:446
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ PrivateBuildPacket()

int qrtplib::RTPPacketBuilder::PrivateBuildPacket ( const void *  data,
unsigned int  len,
uint8_t  pt,
bool  mark,
uint32_t  timestampinc,
bool  gotextension,
uint16_t  hdrextID = 0,
const void *  hdrextdata = 0,
unsigned int  numhdrextwords = 0 
)
private

Definition at line 248 of file rtppacketbuilder.cpp.

References buffer, csrcs, qrtplib::RTPTime::CurrentTime(), qrtplib::RTPPacket::GetCreationError(), qrtplib::RTPPacket::GetPacketLength(), qrtplib::RTPPacket::GetPayloadLength(), lastrtptimestamp, lastwallclocktime, maxpacksize, numcsrcs, numpackets, numpayloadbytes, packetlength, prevrtptimestamp, seqnr, ssrc, and timestamp.

Referenced by BuildPacket(), and BuildPacketEx().

250 {
251  RTPPacket p(pt, data, len, seqnr, timestamp, ssrc, mark, numcsrcs, csrcs, gotextension, hdrextID, (uint16_t) numhdrextwords, hdrextdata, buffer, maxpacksize);
252  int status = p.GetCreationError();
253 
254  if (status < 0)
255  return status;
256  packetlength = p.GetPacketLength();
257 
258  if (numpackets == 0) // first packet
259  {
263  }
264  else if (timestamp != prevrtptimestamp)
265  {
269  }
270 
271  numpayloadbytes += (uint32_t) p.GetPayloadLength();
272  numpackets++;
273  timestamp += timestampinc;
274  seqnr++;
275 
276  //qDebug("RTPPacketBuilder::PrivateBuildPacket: numpackets: %u timestamp: %u timestampinc: %u seqnr: %u", numpackets, timestamp, timestampinc, seqnr);
277 
278  return 0;
279 }
unsigned int uint32_t
Definition: rtptypes_win.h:46
unsigned short uint16_t
Definition: rtptypes_win.h:44
uint32_t csrcs[RTP_MAXCSRCS]
static RTPTime CurrentTime()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetDefaultMark()

int qrtplib::RTPPacketBuilder::SetDefaultMark ( bool  m)
inline

Sets the default marker bit to m.

Definition at line 285 of file rtppacketbuilder.h.

References ERR_RTP_PACKBUILD_NOTINIT.

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

286 {
287  if (!init)
289  defmarkset = true;
290  defaultmark = m;
291  return 0;
292 }
#define ERR_RTP_PACKBUILD_NOTINIT
Definition: rtperrors.h:72
+ Here is the caller graph for this function:

◆ SetDefaultPayloadType()

int qrtplib::RTPPacketBuilder::SetDefaultPayloadType ( uint8_t  pt)
inline

Sets the default payload type to pt.

Definition at line 276 of file rtppacketbuilder.h.

References ERR_RTP_PACKBUILD_NOTINIT.

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

277 {
278  if (!init)
280  defptset = true;
281  defaultpayloadtype = pt;
282  return 0;
283 }
#define ERR_RTP_PACKBUILD_NOTINIT
Definition: rtperrors.h:72
+ Here is the caller graph for this function:

◆ SetDefaultTimestampIncrement()

int qrtplib::RTPPacketBuilder::SetDefaultTimestampIncrement ( uint32_t  timestampinc)
inline

Sets the default timestamp increment to timestampinc.

Definition at line 294 of file rtppacketbuilder.h.

References ERR_RTP_PACKBUILD_NOTINIT.

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

295 {
296  if (!init)
298  deftsset = true;
299  defaulttimestampinc = timestampinc;
300  return 0;
301 }
#define ERR_RTP_PACKBUILD_NOTINIT
Definition: rtperrors.h:72
+ Here is the caller graph for this function:

◆ SetMaximumPacketSize()

int qrtplib::RTPPacketBuilder::SetMaximumPacketSize ( unsigned int  maxpacksize)

Sets the maximum allowed packet size to maxpacksize.

Definition at line 108 of file rtppacketbuilder.cpp.

References buffer, ERR_RTP_PACKBUILD_INVALIDMAXPACKETSIZE, leansdr::max(), and maxpacksize.

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

109 {
110  uint8_t *newbuf;
111 
112  if (max <= 0)
114  newbuf = new uint8_t[max];
115 
116  delete[] buffer;
117  buffer = newbuf;
118  maxpacksize = max;
119  return 0;
120 }
unsigned char uint8_t
Definition: rtptypes_win.h:42
#define ERR_RTP_PACKBUILD_INVALIDMAXPACKETSIZE
Definition: rtperrors.h:71
T max(const T &x, const T &y)
Definition: framework.h:446
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ buffer

uint8_t* qrtplib::RTPPacketBuilder::buffer
private

Definition at line 251 of file rtppacketbuilder.h.

Referenced by Destroy(), Init(), PrivateBuildPacket(), and SetMaximumPacketSize().

◆ csrcs

uint32_t qrtplib::RTPPacketBuilder::csrcs[RTP_MAXCSRCS]
private

Definition at line 268 of file rtppacketbuilder.h.

Referenced by AddCSRC(), DeleteCSRC(), PrivateBuildPacket(), and RTPPacketBuilder().

◆ defaultmark

bool qrtplib::RTPPacketBuilder::defaultmark
private

Definition at line 264 of file rtppacketbuilder.h.

Referenced by BuildPacket(), BuildPacketEx(), and RTPPacketBuilder().

◆ defaultpayloadtype

uint8_t qrtplib::RTPPacketBuilder::defaultpayloadtype
private

Definition at line 263 of file rtppacketbuilder.h.

Referenced by BuildPacket(), BuildPacketEx(), and RTPPacketBuilder().

◆ defaulttimestampinc

uint32_t qrtplib::RTPPacketBuilder::defaulttimestampinc
private

Definition at line 262 of file rtppacketbuilder.h.

Referenced by BuildPacket(), BuildPacketEx(), and RTPPacketBuilder().

◆ defmarkset

bool qrtplib::RTPPacketBuilder::defmarkset
private

Definition at line 266 of file rtppacketbuilder.h.

Referenced by BuildPacket(), BuildPacketEx(), Init(), and RTPPacketBuilder().

◆ defptset

bool qrtplib::RTPPacketBuilder::defptset
private

Definition at line 266 of file rtppacketbuilder.h.

Referenced by BuildPacket(), BuildPacketEx(), Init(), and RTPPacketBuilder().

◆ deftsset

bool qrtplib::RTPPacketBuilder::deftsset
private

Definition at line 266 of file rtppacketbuilder.h.

Referenced by BuildPacket(), BuildPacketEx(), Init(), and RTPPacketBuilder().

◆ init

bool qrtplib::RTPPacketBuilder::init
private

◆ lastrtptimestamp

uint32_t qrtplib::RTPPacketBuilder::lastrtptimestamp
private

Definition at line 272 of file rtppacketbuilder.h.

Referenced by PrivateBuildPacket(), and RTPPacketBuilder().

◆ lastwallclocktime

RTPTime qrtplib::RTPPacketBuilder::lastwallclocktime
private

Definition at line 271 of file rtppacketbuilder.h.

Referenced by PrivateBuildPacket().

◆ maxpacksize

unsigned int qrtplib::RTPPacketBuilder::maxpacksize
private

Definition at line 250 of file rtppacketbuilder.h.

Referenced by Init(), PrivateBuildPacket(), and SetMaximumPacketSize().

◆ numcsrcs

int qrtplib::RTPPacketBuilder::numcsrcs
private

◆ numpackets

uint32_t qrtplib::RTPPacketBuilder::numpackets
private

Definition at line 255 of file rtppacketbuilder.h.

Referenced by CreateNewSSRC(), Init(), PrivateBuildPacket(), and RTPPacketBuilder().

◆ numpayloadbytes

uint32_t qrtplib::RTPPacketBuilder::numpayloadbytes
private

Definition at line 254 of file rtppacketbuilder.h.

Referenced by CreateNewSSRC(), PrivateBuildPacket(), and RTPPacketBuilder().

◆ packetlength

unsigned int qrtplib::RTPPacketBuilder::packetlength
private

Definition at line 252 of file rtppacketbuilder.h.

Referenced by Init(), and PrivateBuildPacket().

◆ prevrtptimestamp

uint32_t qrtplib::RTPPacketBuilder::prevrtptimestamp
private

Definition at line 273 of file rtppacketbuilder.h.

Referenced by PrivateBuildPacket(), and RTPPacketBuilder().

◆ rtprnd

RTPRandom& qrtplib::RTPPacketBuilder::rtprnd
private

Definition at line 249 of file rtppacketbuilder.h.

Referenced by CreateNewSSRC().

◆ seqnr

uint16_t qrtplib::RTPPacketBuilder::seqnr
private

Definition at line 260 of file rtppacketbuilder.h.

Referenced by CreateNewSSRC(), PrivateBuildPacket(), and RTPPacketBuilder().

◆ ssrc

uint32_t qrtplib::RTPPacketBuilder::ssrc
private

Definition at line 258 of file rtppacketbuilder.h.

Referenced by CreateNewSSRC(), PrivateBuildPacket(), and RTPPacketBuilder().

◆ timestamp

uint32_t qrtplib::RTPPacketBuilder::timestamp
private

Definition at line 259 of file rtppacketbuilder.h.

Referenced by CreateNewSSRC(), PrivateBuildPacket(), and RTPPacketBuilder().


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