37 #ifndef RTPPACKETBUILDER_H
39 #define RTPPACKETBUILDER_H
41 #include "rtpconfig.h"
43 #include "rtpdefines.h"
64 int Init(
size_t maxpacksize);
100 uint8_t pt,
bool mark,uint32_t timestampinc);
110 uint16_t hdrextID,
const void *hdrextdata,
size_t numhdrextwords);
120 uint8_t pt,
bool mark,uint32_t timestampinc,
121 uint16_t hdrextID,
const void *hdrextdata,
size_t numhdrextwords);
124 uint8_t *
GetPacket() {
if (!init)
return 0;
return buffer; }
169 uint32_t
GetSSRC()
const {
if (!init)
return 0;
return ssrc; }
172 uint32_t
GetTimestamp()
const {
if (!init)
return 0;
return timestamp; }
192 int PrivateBuildPacket(
const void *data,
size_t len,
193 uint8_t pt,
bool mark,uint32_t timestampinc,
bool gotextension,
194 uint16_t hdrextID = 0,
const void *hdrextdata = 0,
size_t numhdrextwords = 0);
201 uint32_t numpayloadbytes;
209 uint32_t defaulttimestampinc;
210 uint8_t defaultpayloadtype;
213 bool deftsset,defptset,defmarkset;
215 uint32_t csrcs[RTP_MAXCSRCS];
219 uint32_t lastrtptimestamp;
220 uint32_t prevrtptimestamp;
226 return ERR_RTP_PACKBUILD_NOTINIT;
228 defaultpayloadtype = pt;
235 return ERR_RTP_PACKBUILD_NOTINIT;
244 return ERR_RTP_PACKBUILD_NOTINIT;
246 defaulttimestampinc = timestampinc;
253 return ERR_RTP_PACKBUILD_NOTINIT;
261 return ERR_RTP_PACKBUILD_NOTINIT;
263 return ERR_RTP_PACKBUILD_DEFAULTTSINCNOTSET;
264 timestamp += defaulttimestampinc;
268 #endif // RTPPACKETBUILDER_H
int SetDefaultTimestampIncrement(uint32_t timestampinc)
Sets the default timestamp increment to timestampinc.
Definition: rtppacketbuilder.h:241
int IncrementTimestamp(uint32_t inc)
This function increments the timestamp with the amount given by inc.
Definition: rtppacketbuilder.h:250
RTPTime GetPacketTime() const
Returns the time at which a packet was generated.
Definition: rtppacketbuilder.h:181
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:73
int IncrementTimestampDefault()
This function increments the timestamp with the amount given set by the SetDefaultTimestampIncrement ...
Definition: rtppacketbuilder.h:258
int SetDefaultPayloadType(uint8_t pt)
Sets the default payload type to pt.
Definition: rtppacketbuilder.h:223
RTPPacketBuilder(RTPRandom &rtprand, RTPMemoryManager *mgr=0)
Constructs an instance which will use rtprand for generating random numbers (used to initialize the S...
int SetDefaultMark(bool m)
Sets the default marker bit to m.
Definition: rtppacketbuilder.h:232
void AdjustSSRC(uint32_t s)
Sets a specific SSRC to be used.
Definition: rtppacketbuilder.h:190
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:169
uint32_t GetTimestamp() const
Returns the current RTP timestamp.
Definition: rtppacketbuilder.h:172
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:175
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:127
uint32_t GetPacketCount()
Returns the number of packets which have been created with the current SSRC identifier.
Definition: rtppacketbuilder.h:70
int SetMaximumPacketSize(size_t maxpacksize)
Sets the maximum allowed packet size to maxpacksize.
Interface for generating random numbers.
Definition: rtprandom.h:48
void Destroy()
Cleans up the builder.
uint8_t * GetPacket()
Returns a pointer to the last built RTP packet data.
Definition: rtppacketbuilder.h:124
uint32_t GetPacketTimestamp() const
Returns the RTP timestamp which corresponds to the time returned by the previous function.
Definition: rtppacketbuilder.h:184
void ClearCSRCList()
Clears the CSRC list.
int BuildPacket(const void *data, size_t len)
Builds a packet with payload data and payload length len.