jrtplib
3.8.0
|
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.
#include <rtppacketbuilder.h>
Inherits RTPMemoryObject.
Public Member Functions | |
RTPPacketBuilder (RTPRandom &rtprand, RTPMemoryManager *mgr=0) | |
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. | |
int | Init (size_t maxpacksize) |
Initializes the builder to only allow packets with a size below maxpacksize . More... | |
void | Destroy () |
Cleans up the builder. More... | |
uint32_t | GetPacketCount () |
Returns the number of packets which have been created with the current SSRC identifier. More... | |
uint32_t | GetPayloadOctetCount () |
Returns the number of payload octets which have been generated with this SSRC identifier. More... | |
int | SetMaximumPacketSize (size_t maxpacksize) |
Sets the maximum allowed packet size to maxpacksize . More... | |
int | AddCSRC (uint32_t csrc) |
Adds a CSRC to the CSRC list which will be stored in the RTP packets. More... | |
int | DeleteCSRC (uint32_t csrc) |
Deletes a CSRC from the list which will be stored in the RTP packets. More... | |
void | ClearCSRCList () |
Clears the CSRC list. More... | |
int | BuildPacket (const void *data, size_t len) |
Builds a packet with payload data and payload length len . More... | |
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 . More... | |
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 . More... | |
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 . More... | |
uint8_t * | GetPacket () |
Returns a pointer to the last built RTP packet data. More... | |
size_t | GetPacketLength () |
Returns the size of the last built RTP packet. More... | |
int | SetDefaultPayloadType (uint8_t pt) |
Sets the default payload type to pt . More... | |
int | SetDefaultMark (bool m) |
Sets the default marker bit to m . More... | |
int | SetDefaultTimestampIncrement (uint32_t timestampinc) |
Sets the default timestamp increment to timestampinc . More... | |
int | IncrementTimestamp (uint32_t inc) |
This function increments the timestamp with the amount given by inc . More... | |
int | IncrementTimestampDefault () |
This function increments the timestamp with the amount given set by the SetDefaultTimestampIncrement member function. More... | |
uint32_t | CreateNewSSRC () |
Creates a new SSRC to be used in generated packets. More... | |
uint32_t | CreateNewSSRC (RTPSources &sources) |
Creates a new SSRC to be used in generated packets. More... | |
uint32_t | GetSSRC () const |
Returns the current SSRC identifier. More... | |
uint32_t | GetTimestamp () const |
Returns the current RTP timestamp. More... | |
uint16_t | GetSequenceNumber () const |
Returns the current sequence number. More... | |
RTPTime | GetPacketTime () const |
Returns the time at which a packet was generated. More... | |
uint32_t | GetPacketTimestamp () const |
Returns the RTP timestamp which corresponds to the time returned by the previous function. More... | |
void | AdjustSSRC (uint32_t s) |
Sets a specific SSRC to be used. More... | |
int RTPPacketBuilder::AddCSRC | ( | uint32_t | csrc | ) |
|
inline |
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!
int RTPPacketBuilder::BuildPacket | ( | const void * | data, |
size_t | 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.
int RTPPacketBuilder::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
. 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
.
int RTPPacketBuilder::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
. 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.
int RTPPacketBuilder::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
. 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.
void RTPPacketBuilder::ClearCSRCList | ( | ) |
uint32_t RTPPacketBuilder::CreateNewSSRC | ( | ) |
Creates a new SSRC to be used in generated packets. This will also generate new timestamp and sequence number offsets.
uint32_t RTPPacketBuilder::CreateNewSSRC | ( | RTPSources & | sources | ) |
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.
int RTPPacketBuilder::DeleteCSRC | ( | uint32_t | csrc | ) |
void RTPPacketBuilder::Destroy | ( | ) |
|
inline |
|
inline |
|
inline |
|
inline |
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.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
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.
|
inline |
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.
int RTPPacketBuilder::Init | ( | size_t | maxpacksize | ) |
|
inline |
|
inline |
|
inline |
int RTPPacketBuilder::SetMaximumPacketSize | ( | size_t | maxpacksize | ) |