37 #ifndef RTPPACKETBUILDER_H
39 #define RTPPACKETBUILDER_H
41 #include "rtpconfig.h"
43 #include "rtpdefines.h"
62 int Init(
size_t maxpacksize);
98 uint8_t pt,
bool mark,uint32_t timestampinc);
108 uint16_t hdrextID,
const void *hdrextdata,
size_t numhdrextwords);
118 uint8_t pt,
bool mark,uint32_t timestampinc,
119 uint16_t hdrextID,
const void *hdrextdata,
size_t numhdrextwords);
122 uint8_t *
GetPacket() {
if (!init)
return 0;
return buffer; }
167 uint32_t
GetSSRC()
const {
if (!init)
return 0;
return ssrc; }
170 uint32_t
GetTimestamp()
const {
if (!init)
return 0;
return timestamp; }
184 int PrivateBuildPacket(
const void *data,
size_t len,
185 uint8_t pt,
bool mark,uint32_t timestampinc,
bool gotextension,
186 uint16_t hdrextID = 0,
const void *hdrextdata = 0,
size_t numhdrextwords = 0);
193 uint32_t numpayloadbytes;
201 uint32_t defaulttimestampinc;
202 uint8_t defaultpayloadtype;
205 bool deftsset,defptset,defmarkset;
207 uint32_t csrcs[RTP_MAXCSRCS];
211 uint32_t lastrtptimestamp;
212 uint32_t prevrtptimestamp;
218 return ERR_RTP_PACKBUILD_NOTINIT;
220 defaultpayloadtype = pt;
227 return ERR_RTP_PACKBUILD_NOTINIT;
236 return ERR_RTP_PACKBUILD_NOTINIT;
238 defaulttimestampinc = timestampinc;
245 return ERR_RTP_PACKBUILD_NOTINIT;
253 return ERR_RTP_PACKBUILD_NOTINIT;
255 return ERR_RTP_PACKBUILD_DEFAULTTSINCNOTSET;
256 timestamp += defaulttimestampinc;
260 #endif // RTPPACKETBUILDER_H
int SetDefaultTimestampIncrement(uint32_t timestampinc)
Sets the default timestamp increment to timestampinc.
Definition: rtppacketbuilder.h:233
int IncrementTimestamp(uint32_t inc)
This function increments the timestamp with the amount given by inc.
Definition: rtppacketbuilder.h:242
RTPTime GetPacketTime() const
Returns the time at which a packet was generated.
Definition: rtppacketbuilder.h:179
RTPPacketBuilder(RTPMemoryManager *mgr=0)
Constructs an instance, optionally installing a memory manager.
int AddCSRC(uint32_t csrc)
Adds a CSRC to the CSRC list which will be stored in the RTP packets.
A memory manager.
Definition: rtpmemorymanager.h:144
Represents a table in which information about the participating sources is kept.
Definition: rtpsources.h:71
This class is used to specify wallclock time, delay intervals etc.
Definition: rtptimeutilities.h:77
uint32_t GetPayloadOctetCount()
Returns the number of payload octets which have been generated with this SSRC identifier.
Definition: rtppacketbuilder.h:71
int IncrementTimestampDefault()
This function increments the timestamp with the amount given set by the SetDefaultTimestampIncrement ...
Definition: rtppacketbuilder.h:250
int SetDefaultPayloadType(uint8_t pt)
Sets the default payload type to pt.
Definition: rtppacketbuilder.h:215
int SetDefaultMark(bool m)
Sets the default marker bit to m.
Definition: rtppacketbuilder.h:224
int BuildPacketEx(const void *data, size_t len, uint16_t hdrextID, const void *hdrextdata, size_t numhdrextwords)
Builds a packet with payload data and payload length len.
int DeleteCSRC(uint32_t csrc)
Deletes a CSRC from the list which will be stored in the RTP packets.
uint32_t GetSSRC() const
Returns the current SSRC identifier.
Definition: rtppacketbuilder.h:167
uint32_t GetTimestamp() const
Returns the current RTP timestamp.
Definition: rtppacketbuilder.h:170
uint32_t CreateNewSSRC()
Creates a new SSRC to be used in generated packets.
uint16_t GetSequenceNumber() const
Returns the current sequence number.
Definition: rtppacketbuilder.h:173
This class can be used to build RTP packets and is a bit more high-level than the RTPPacket class: it...
Definition: rtppacketbuilder.h:54
int Init(size_t maxpacksize)
Initializes the builder to only allow packets with a size below maxpacksize.
size_t GetPacketLength()
Returns the size of the last built RTP packet.
Definition: rtppacketbuilder.h:125
uint32_t GetPacketCount()
Returns the number of packets which have been created with the current SSRC identifier.
Definition: rtppacketbuilder.h:68
int SetMaximumPacketSize(size_t maxpacksize)
Sets the maximum allowed packet size to maxpacksize.
The RTPRandom class can be used to generate random numbers.
Definition: rtprandom.h:46
void Destroy()
Cleans up the builder.
uint8_t * GetPacket()
Returns a pointer to the last built RTP packet data.
Definition: rtppacketbuilder.h:122
uint32_t GetPacketTimestamp() const
Returns the RTP timestamp which corresponds to the time returned by the previous function.
Definition: rtppacketbuilder.h:182
void ClearCSRCList()
Clears the CSRC list.
int BuildPacket(const void *data, size_t len)
Builds a packet with payload data and payload length len.