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.
|
#include <rtppacketbuilder.h>
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_t * | GetPacket () |
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 | |
RTPRandom & | rtprnd |
unsigned int | maxpacksize |
uint8_t * | buffer |
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 |
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.
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.
qrtplib::RTPPacketBuilder::~RTPPacketBuilder | ( | ) |
Definition at line 71 of file rtppacketbuilder.cpp.
References Destroy().
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.
|
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().
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().
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().
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().
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().
void qrtplib::RTPPacketBuilder::ClearCSRCList | ( | ) |
Clears the CSRC list.
Definition at line 167 of file rtppacketbuilder.cpp.
References init, and numcsrcs.
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().
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.
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.
void qrtplib::RTPPacketBuilder::Destroy | ( | ) |
Cleans up the builder.
Definition at line 100 of file rtppacketbuilder.cpp.
Referenced by qrtplib::RTPSession::BYEDestroy(), qrtplib::RTPSession::Destroy(), qrtplib::RTPSession::InternalCreate(), and ~RTPPacketBuilder().
|
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().
|
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().
|
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().
|
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().
|
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().
|
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().
|
inline |
Returns the current sequence number.
Definition at line 205 of file rtppacketbuilder.h.
Referenced by qrtplib::RTPSession::GetNextSequenceNumber().
|
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().
|
inline |
|
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().
|
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().
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().
|
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().
|
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().
|
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().
|
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().
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().
|
private |
Definition at line 251 of file rtppacketbuilder.h.
Referenced by Destroy(), Init(), PrivateBuildPacket(), and SetMaximumPacketSize().
|
private |
Definition at line 268 of file rtppacketbuilder.h.
Referenced by AddCSRC(), DeleteCSRC(), PrivateBuildPacket(), and RTPPacketBuilder().
|
private |
Definition at line 264 of file rtppacketbuilder.h.
Referenced by BuildPacket(), BuildPacketEx(), and RTPPacketBuilder().
|
private |
Definition at line 263 of file rtppacketbuilder.h.
Referenced by BuildPacket(), BuildPacketEx(), and RTPPacketBuilder().
|
private |
Definition at line 262 of file rtppacketbuilder.h.
Referenced by BuildPacket(), BuildPacketEx(), and RTPPacketBuilder().
|
private |
Definition at line 266 of file rtppacketbuilder.h.
Referenced by BuildPacket(), BuildPacketEx(), Init(), and RTPPacketBuilder().
|
private |
Definition at line 266 of file rtppacketbuilder.h.
Referenced by BuildPacket(), BuildPacketEx(), Init(), and RTPPacketBuilder().
|
private |
Definition at line 266 of file rtppacketbuilder.h.
Referenced by BuildPacket(), BuildPacketEx(), Init(), and RTPPacketBuilder().
|
private |
Definition at line 256 of file rtppacketbuilder.h.
Referenced by AddCSRC(), BuildPacket(), BuildPacketEx(), ClearCSRCList(), DeleteCSRC(), Destroy(), Init(), and RTPPacketBuilder().
|
private |
Definition at line 272 of file rtppacketbuilder.h.
Referenced by PrivateBuildPacket(), and RTPPacketBuilder().
|
private |
Definition at line 271 of file rtppacketbuilder.h.
Referenced by PrivateBuildPacket().
|
private |
Definition at line 250 of file rtppacketbuilder.h.
Referenced by Init(), PrivateBuildPacket(), and SetMaximumPacketSize().
|
private |
Definition at line 269 of file rtppacketbuilder.h.
Referenced by AddCSRC(), ClearCSRCList(), DeleteCSRC(), Init(), PrivateBuildPacket(), and RTPPacketBuilder().
|
private |
Definition at line 255 of file rtppacketbuilder.h.
Referenced by CreateNewSSRC(), Init(), PrivateBuildPacket(), and RTPPacketBuilder().
|
private |
Definition at line 254 of file rtppacketbuilder.h.
Referenced by CreateNewSSRC(), PrivateBuildPacket(), and RTPPacketBuilder().
|
private |
Definition at line 252 of file rtppacketbuilder.h.
Referenced by Init(), and PrivateBuildPacket().
|
private |
Definition at line 273 of file rtppacketbuilder.h.
Referenced by PrivateBuildPacket(), and RTPPacketBuilder().
|
private |
Definition at line 249 of file rtppacketbuilder.h.
Referenced by CreateNewSSRC().
|
private |
Definition at line 260 of file rtppacketbuilder.h.
Referenced by CreateNewSSRC(), PrivateBuildPacket(), and RTPPacketBuilder().
|
private |
Definition at line 258 of file rtppacketbuilder.h.
Referenced by CreateNewSSRC(), PrivateBuildPacket(), and RTPPacketBuilder().
|
private |
Definition at line 259 of file rtppacketbuilder.h.
Referenced by CreateNewSSRC(), PrivateBuildPacket(), and RTPPacketBuilder().