37 #ifndef CCXX_RTP_RTPPKT_H_
38 #define CCXX_RTP_RTPPKT_H_
91 RTPPacket(
const unsigned char*
const block,
size_t len,
92 bool duplicate =
false);
120 inline const uint8*
const
122 {
return (uint8*)(buffer + getHeaderSize()); }
129 {
return payloadSize; }
136 {
return static_cast<PayloadType>(getHeader()->payload); }
143 {
return cachedSeqNum; }
150 {
return cachedTimestamp; }
157 {
return getHeader()->version; }
165 {
return getHeader()->padding; }
175 {
return buffer[total - 1]; }
185 {
return getHeader()->marker; }
194 {
return getHeader()->extension; }
202 {
return getHeader()->cc; }
213 {
return static_cast<const uint32*
>(&(getHeader()->sources[1])); }
229 {
return (isExtended()? getHeaderExt()->undefined : 0); }
244 {
return (isExtended()?
245 (static_cast<uint32>(ntohs(getHeaderExt()->length)) << 2) :
254 inline const unsigned char*
256 {
return (isExtended() ?
257 (reinterpret_cast<const unsigned char*>(getHeaderExt()) +
267 inline const unsigned char*
const
283 {
return total + srtpLength; }
300 void reComputePayLength(
bool padding);
320 inline RTPFixedHeader*
326 { getHeader()->extension = e; }
335 inline const RTPHeaderExt*
339 return (reinterpret_cast<RTPHeaderExt*>(buffer + fixsize));
349 {
return ntohl(getHeader()->timestamp); }
353 { memcpy(buffer + pos,src,len); }
404 #if defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN
405 unsigned char version:2;
407 unsigned char padding:1;
408 unsigned char extension:1;
410 unsigned char marker:1;
411 unsigned char payload:7;
415 unsigned char extension:1;
416 unsigned char padding:1;
417 unsigned char version:2;
418 unsigned char payload:7;
419 unsigned char marker:1;
437 #if defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN
442 uint16 duration : 16;
448 uint16 duration : 16;
486 {
return ntohs(getRaw2833Payload()->duration);}
494 {getRaw2833Payload()->duration = htons(timestamp);}
537 const unsigned char*
const hdrext, uint32 hdrextlen,
538 const unsigned char*
const data,
size_t datalen,
562 const unsigned char*
const data,
size_t datalen,
612 cachedTimestamp = pts;
688 void setCSRCArray(
const uint32*
const csrcs, uint16 numcsrc);
731 {
return headerValid; }
741 {
return cachedSSRC; }
763 (this->getSSRC() == p.
getSSRC()) ); }
771 {
return !( *
this == p ); }
802 #endif // ndef CCXX_RTP_RTPPKT_H_
uint32 total
total length, including header, payload and padding
bool isPadded() const
Ask whether the packet contains padding bytes at the end.
void setMarker(bool mark)
Specify the value of the marker bit.
size_t getSizeOfFixedHeader() const
A base class for both IncomingRTPPkt and OutgoingRTPPkt.
The implementation for a SRTP cryptographic context.
PayloadType getPayloadType() const
RTP packets received from other participants.
uint32 getRawTimestamp() const
Obtain the absolute timestamp carried in the packet header.
const uint32 * getCSRCs() const
Get the 32-bit identifiers of the contributing sources for the packet as an array, of length getCSRCsCount().
uint32 getSSRC() const
Get synchronization source numeric identifier.
void setSeqNum(uint16 seq)
Sets the sequence number in the header.
unsigned char * buffer
packet in memory
void setSSRCNetwork(uint32 ssrc) const
Set synchronization source numeric identifier.
static const uint16 RTP_INVALID_PT_VALUE
uint32 getTimestamp() const
uint32 getHdrExtSize() const
Get the length (in octets) of the data contained in the header extension.
const RTPHeaderExt * getHeaderExt() const
Get a pointer to RTPHeaderExt pointing after the RTP header (fixed part plus contributing sources)...
bool isHeaderValid()
Get validity of this packet.
const uint8 *const getPayload() const
bool duplicated
whether the object was contructed with duplicated = true
bool operator!=(const OutgoingRTPPkt &p) const
Outgoing packets are not equal if their sequence numbers differ.
const unsigned char * getHdrExtContent() const
Get the content of the header extension.
uint16 getHdrExtUndefined() const
Get the first 16 bits (in network order) of the header of the RTP header extension.
uint32 srtpDataOffset
Offset into packet memory pointing to area for SRTP data.
RTPFixedHeader * getHeader() const
Return low level structure for the header of the packet.
bool operator==(const OutgoingRTPPkt &p) const
Outgoing packets are equal if their sequence numbers match.
uint8 getProtocolVersion() const
void setSSRC(uint32 ssrc) const
Set synchronization source numeric identifier.
uint32 cachedTimestamp
Packet timestamp in host order (includes initial shift).
virtual ~RTPPacket()
Destructor, free the buffer provided in the constructor.
uint32 getRawPacketSize() const
Get the raw packet length, including header, extension, payload and padding.
bool isExtended() const
Ask whether the packet contains header extensions.
bool operator==(const IncomingRTPPkt &p) const
Two incoming packets are equal if they come from sources with the same SSRC and have the same sequenc...
static const uint16 RTP_INVALID_PT_MASK
void set2833Duration(uint16 timestamp)
Set 2833 duration field.
const unsigned char *const getRawPacket() const
Get the raw packet as it will be sent through the network.
uint16 get2833Duration(void)
Fetch 2833 duration field.
uint32 cachedSSRC
SSRC 32-bit identifier in host order.
uint8 getPaddingSize() const
Get the number of octets padding the end of the payload section.
struct RFC2833Payload * getRaw2833Payload(void)
Fetch a raw 2833 packet.
uint32 getPayloadSize() const
bool headerValid
Header validity, checked at construction time.
Base elements for RTP stacks: constants, types and global functions.
uint16 getCSRCsCount() const
Get the number of contributing sources specified in the packet header.
void setTimestamp(uint32 pts)
void setPayloadType(PayloadType pt)
void setbuffer(const void *src, size_t len, size_t pos)
bool isMarked() const
Ask whether the packet is marked (for isntance, is a new talk spurt in some audio profiles)...
bool operator!=(const IncomingRTPPkt &p) const
Two incoming packets are not equal if they come from different sources or have different sequence num...
uint32 getRawPacketSizeSrtp() const
a structure defining RFC2833 Telephony events.
void setExtension(bool e)
uint32 hdrSize
size of the header, including contributing sources and extensions
int32 srtpLength
Lebgth of additional SRTP data.
uint16 cachedSeqNum
Packet sequence number in host order.
uint32 getHeaderSize() const
Get the length of the header, including contributing sources identifiers and header extension...
uint32 payloadSize
note: payload (not full packet) size.
uint8 PayloadType
RTP payload type numeric identifier.