Go to the documentation of this file.
37 #ifndef CCXX_RTP_RTPPKT_H_
38 #define CCXX_RTP_RTPPKT_H_
75 struct RTPFixedHeader;
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()) +
258 sizeof(RTPHeaderExt)) :
267 inline const unsigned char*
const
283 {
return total + srtpLength; }
287 {
return sizeof(RTPFixedHeader); }
300 void reComputePayLength(
bool padding);
320 inline RTPFixedHeader*
322 {
return reinterpret_cast<RTPFixedHeader*
>(buffer); }
326 { getHeader()->extension = e; }
335 inline const RTPHeaderExt*
338 uint32 fixsize =
sizeof(RTPFixedHeader) + (getHeader()->cc << 2);
339 return (
reinterpret_cast<RTPHeaderExt*
>(buffer + fixsize));
349 {
return ntohl(getHeader()->timestamp); }
353 { memcpy(buffer + pos,src,len); }
383 unsigned char* buffer;
402 struct RTPFixedHeader
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;
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;
624 {
getHeader()->sources[0] = htonl(ssrc); }
688 void setCSRCArray(
const uint32*
const csrcs, uint16 numcsrc);
731 {
return headerValid; }
741 {
return cachedSSRC; }
763 (this->getSSRC() == p.
getSSRC()) ); }
771 {
return !( *
this == p ); }
794 static const uint16 RTP_INVALID_PT_MASK;
795 static const uint16 RTP_INVALID_PT_VALUE;
802 #endif // ndef CCXX_RTP_RTPPKT_H_
void setSSRCNetwork(uint32 ssrc) const
Set synchronization source numeric identifier.
Definition: rtppkt.h:634
void setTimestamp(uint32 pts)
Definition: rtppkt.h:610
void setMarker(bool mark)
Specify the value of the marker bit.
Definition: rtppkt.h:645
uint16 duration
Definition: rtppkt.h:448
const unsigned char *const getRawPacket() const
Get the raw packet as it will be sent through the network.
Definition: rtppkt.h:268
uint8 vol
Definition: rtppkt.h:445
The implementation for a SRTP cryptographic context.
Definition: CryptoContext.h:82
uint32 getRawPacketSize() const
Get the raw packet length, including header, extension, payload and padding.
Definition: rtppkt.h:278
RTPFixedHeader * getHeader() const
Return low level structure for the header of the packet.
Definition: rtppkt.h:321
bool isPadded() const
Ask whether the packet contains padding bytes at the end.
Definition: rtppkt.h:164
bool operator!=(const IncomingRTPPkt &p) const
Two incoming packets are not equal if they come from different sources or have different sequence num...
Definition: rtppkt.h:770
PayloadType getPayloadType() const
Definition: rtppkt.h:135
uint16 cachedSeqNum
Packet sequence number in host order.
Definition: rtppkt.h:356
uint32 getTimestamp() const
Definition: rtppkt.h:149
~IncomingRTPPkt()
Definition: rtppkt.h:721
Base elements for RTP stacks: constants, types and global functions.
uint16 getCSRCsCount() const
Get the number of contributing sources specified in the packet header.
Definition: rtppkt.h:201
void setSeqNum(uint16 seq)
Definition: rtppkt.h:600
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...
Definition: rtppkt.h:761
int32 srtpLength
Lebgth of additional SRTP data.
Definition: rtppkt.h:373
size_t getSizeOfFixedHeader() const
Definition: rtppkt.h:286
uint8 getProtocolVersion() const
Definition: rtppkt.h:156
uint32 getSSRC() const
Get synchronization source numeric identifier.
Definition: rtppkt.h:740
void setPayloadType(PayloadType pt)
Definition: rtppkt.h:591
uint16 get2833Duration(void)
Fetch 2833 duration field.
Definition: rtppkt.h:485
const uint8 *const getPayload() const
Definition: rtppkt.h:121
uint8 PayloadType
RTP payload type numeric identifier.
Definition: formats.h:62
void setSSRC(uint32 ssrc) const
Set synchronization source numeric identifier.
Definition: rtppkt.h:623
~OutgoingRTPPkt()
Definition: rtppkt.h:584
uint32 srtpDataOffset
Offset into packet memory pointing to area for SRTP data.
Definition: rtppkt.h:366
bool isMarked() const
Ask whether the packet is marked (for isntance, is a new talk spurt in some audio profiles).
Definition: rtppkt.h:184
uint8 getPaddingSize() const
Get the number of octets padding the end of the payload section.
Definition: rtppkt.h:174
RTP packets being sent.
Definition: rtppkt.h:507
uint8 event
Definition: rtppkt.h:444
bool isExtended() const
Ask whether the packet contains header extensions.
Definition: rtppkt.h:193
bool isHeaderValid()
Get validity of this packet.
Definition: rtppkt.h:730
uint32 cachedTimestamp
Packet timestamp in host order (includes initial shift).
Definition: rtppkt.h:358
bool rbit
Definition: rtppkt.h:446
uint32 getPayloadSize() const
Definition: rtppkt.h:128
const RTPHeaderExt * getHeaderExt() const
Get a pointer to RTPHeaderExt pointing after the RTP header (fixed part plus contributing sources).
Definition: rtppkt.h:336
a structure defining RFC2833 Telephony events.
Definition: rtppkt.h:435
uint16 getHdrExtUndefined() const
Get the first 16 bits (in network order) of the header of the RTP header extension.
Definition: rtppkt.h:228
uint32 getRawPacketSizeSrtp() const
Definition: rtppkt.h:282
uint16 getSeqNum() const
Definition: rtppkt.h:142
bool operator==(const OutgoingRTPPkt &p) const
Outgoing packets are equal if their sequence numbers match.
Definition: rtppkt.h:660
RTP packets received from other participants.
Definition: rtppkt.h:704
uint32 getHdrExtSize() const
Get the length (in octets) of the data contained in the header extension.
Definition: rtppkt.h:243
bool operator!=(const OutgoingRTPPkt &p) const
Outgoing packets are not equal if their sequence numbers differ.
Definition: rtppkt.h:667
virtual ~RTPPacket()
Destructor, free the buffer provided in the constructor.
Definition: rtppkt.h:306
const uint32 * getCSRCs() const
Get the 32-bit identifiers of the contributing sources for the packet as an array,...
Definition: rtppkt.h:212
A base class for both IncomingRTPPkt and OutgoingRTPPkt.
Definition: rtppkt.h:72
void setbuffer(const void *src, size_t len, size_t pos)
Definition: rtppkt.h:352
uint32 getRawTimestamp() const
Obtain the absolute timestamp carried in the packet header.
Definition: rtppkt.h:348
uint32 total
total length, including header, payload and padding
Definition: rtppkt.h:376
void set2833Duration(uint16 timestamp)
Set 2833 duration field.
Definition: rtppkt.h:493
bool ebit
Definition: rtppkt.h:447
const unsigned char * getHdrExtContent() const
Get the content of the header extension.
Definition: rtppkt.h:255
struct RFC2833Payload * getRaw2833Payload(void)
Fetch a raw 2833 packet.
Definition: rtppkt.h:477
uint32 payloadSize
note: payload (not full packet) size.
Definition: rtppkt.h:379
uint32 getHeaderSize() const
Get the length of the header, including contributing sources identifiers and header extension,...
Definition: rtppkt.h:114
void setExtension(bool e)
Definition: rtppkt.h:325