37 #ifndef RTPPACKETBUILDER_H
39 #define RTPPACKETBUILDER_H
41 #include "rtpconfig.h"
43 #include "rtpdefines.h"
68 int Init(
size_t maxpacksize);
104 uint8_t pt,
bool mark,uint32_t timestampinc);
114 uint16_t hdrextID,
const void *hdrextdata,
size_t numhdrextwords);
124 uint8_t pt,
bool mark,uint32_t timestampinc,
125 uint16_t hdrextID,
const void *hdrextdata,
size_t numhdrextwords);
128 uint8_t *
GetPacket() {
if (!init)
return 0;
return buffer; }
134 int SetDefaultPayloadType(uint8_t pt);
137 int SetDefaultMark(
bool m);
140 int SetDefaultTimestampIncrement(uint32_t timestampinc);
148 int IncrementTimestamp(uint32_t inc);
157 int IncrementTimestampDefault();
173 uint32_t
GetSSRC()
const {
if (!init)
return 0;
return ssrc; }
176 uint32_t
GetTimestamp()
const {
if (!init)
return 0;
return timestamp; }
196 int PrivateBuildPacket(
const void *data,
size_t len,
197 uint8_t pt,
bool mark,uint32_t timestampinc,
bool gotextension,
198 uint16_t hdrextID = 0,
const void *hdrextdata = 0,
size_t numhdrextwords = 0);
205 uint32_t numpayloadbytes;
213 uint32_t defaulttimestampinc;
214 uint8_t defaultpayloadtype;
217 bool deftsset,defptset,defmarkset;
219 uint32_t csrcs[RTP_MAXCSRCS];
223 uint32_t lastrtptimestamp;
224 uint32_t prevrtptimestamp;
230 return ERR_RTP_PACKBUILD_NOTINIT;
232 defaultpayloadtype = pt;
239 return ERR_RTP_PACKBUILD_NOTINIT;
248 return ERR_RTP_PACKBUILD_NOTINIT;
250 defaulttimestampinc = timestampinc;
257 return ERR_RTP_PACKBUILD_NOTINIT;
265 return ERR_RTP_PACKBUILD_NOTINIT;
267 return ERR_RTP_PACKBUILD_DEFAULTTSINCNOTSET;
268 timestamp += defaulttimestampinc;
A memory manager.
Definition: rtpmemorymanager.h:151
This class can be used to build RTP packets and is a bit more high-level than the RTPPacket class: it...
Definition: rtppacketbuilder.h:58
int IncrementTimestamp(uint32_t inc)
This function increments the timestamp with the amount given by inc.
Definition: rtppacketbuilder.h:254
int SetMaximumPacketSize(size_t maxpacksize)
Sets the maximum allowed packet size to maxpacksize.
uint32_t GetPacketCount()
Returns the number of packets which have been created with the current SSRC identifier.
Definition: rtppacketbuilder.h:74
uint32_t CreateNewSSRC(RTPSources &sources)
Creates a new SSRC to be used in generated packets.
uint32_t GetTimestamp() const
Returns the current RTP timestamp.
Definition: rtppacketbuilder.h:176
int AddCSRC(uint32_t csrc)
Adds a CSRC to the CSRC list which will be stored in the RTP packets.
uint16_t GetSequenceNumber() const
Returns the current sequence number.
Definition: rtppacketbuilder.h:179
void AdjustSSRC(uint32_t s)
Sets a specific SSRC to be used.
Definition: rtppacketbuilder.h:194
uint8_t * GetPacket()
Returns a pointer to the last built RTP packet data.
Definition: rtppacketbuilder.h:128
int BuildPacketEx(const void *data, size_t len, uint8_t pt, bool mark, uint32_t timestampinc, uint16_t hdrextID, const void *hdrextdata, size_t numhdrextwords)
Builds a packet with payload data and payload length len.
int BuildPacket(const void *data, size_t len)
Builds a packet with payload data and payload length len.
int IncrementTimestampDefault()
This function increments the timestamp with the amount given set by the SetDefaultTimestampIncrement ...
Definition: rtppacketbuilder.h:262
void Destroy()
Cleans up the builder.
uint32_t CreateNewSSRC()
Creates a new SSRC to be used in generated packets.
uint32_t GetPacketTimestamp() const
Returns the RTP timestamp which corresponds to the time returned by the previous function.
Definition: rtppacketbuilder.h:188
uint32_t GetPayloadOctetCount()
Returns the number of payload octets which have been generated with this SSRC identifier.
Definition: rtppacketbuilder.h:77
RTPTime GetPacketTime() const
Returns the time at which a packet was generated.
Definition: rtppacketbuilder.h:185
int SetDefaultTimestampIncrement(uint32_t timestampinc)
Sets the default timestamp increment to timestampinc.
Definition: rtppacketbuilder.h:245
int DeleteCSRC(uint32_t csrc)
Deletes a CSRC from the list which will be stored in the RTP packets.
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.
void ClearCSRCList()
Clears the CSRC list.
RTPPacketBuilder(RTPRandom &rtprand, RTPMemoryManager *mgr=0)
Constructs an instance which will use rtprand for generating random numbers (used to initialize the S...
int SetDefaultPayloadType(uint8_t pt)
Sets the default payload type to pt.
Definition: rtppacketbuilder.h:227
int BuildPacket(const void *data, size_t len, uint8_t pt, bool mark, uint32_t timestampinc)
Builds a packet with payload data and payload length len.
int Init(size_t maxpacksize)
Initializes the builder to only allow packets with a size below maxpacksize.
int SetDefaultMark(bool m)
Sets the default marker bit to m.
Definition: rtppacketbuilder.h:236
uint32_t GetSSRC() const
Returns the current SSRC identifier.
Definition: rtppacketbuilder.h:173
size_t GetPacketLength()
Returns the size of the last built RTP packet.
Definition: rtppacketbuilder.h:131
Interface for generating random numbers.
Definition: rtprandom.h:52
Represents a table in which information about the participating sources is kept.
Definition: rtpsources.h:75
This class is used to specify wallclock time, delay intervals etc.
Definition: rtptimeutilities.h:86