38 #ifndef CCXX_RTP_RTPPKT_H_ 39 #define CCXX_RTP_RTPPKT_H_ 76 struct RTPFixedHeader;
92 RTPPacket(
const unsigned char*
const block,
size_t len,
93 bool duplicate =
false);
121 inline const uint8*
const 123 {
return (uint8*)(buffer + getHeaderSize()); }
130 {
return payloadSize; }
137 {
return static_cast<PayloadType>(getHeader()->payload); }
144 {
return cachedSeqNum; }
151 {
return cachedTimestamp; }
158 {
return getHeader()->version; }
166 {
return getHeader()->padding; }
176 {
return buffer[total - 1]; }
186 {
return getHeader()->marker; }
195 {
return getHeader()->extension; }
203 {
return getHeader()->cc; }
214 {
return static_cast<const uint32*
>(&(getHeader()->sources[1])); }
230 {
return (isExtended()? getHeaderExt()->undefined : 0); }
245 {
return (isExtended()?
246 (static_cast<uint32>(ntohs(getHeaderExt()->length)) << 2) :
255 inline const unsigned char*
257 {
return (isExtended() ?
258 (reinterpret_cast<const unsigned char*>(getHeaderExt()) +
259 sizeof(RTPHeaderExt)) :
268 inline const unsigned char*
const 284 {
return total + srtpLength; }
288 {
return sizeof(RTPFixedHeader); }
301 void reComputePayLength(
bool padding);
321 inline RTPFixedHeader*
323 {
return reinterpret_cast<RTPFixedHeader*
>(buffer); }
327 { getHeader()->extension = e; }
336 inline const RTPHeaderExt*
339 uint32 fixsize =
sizeof(RTPFixedHeader) + (getHeader()->cc << 2);
340 return (reinterpret_cast<RTPHeaderExt*>(buffer + fixsize));
350 {
return ntohl(getHeader()->timestamp); }
354 { memcpy(buffer + pos,src,len); }
384 unsigned char* buffer;
403 struct RTPFixedHeader
405 #if __BYTE_ORDER == __BIG_ENDIAN 406 unsigned char version:2;
408 unsigned char padding:1;
409 unsigned char extension:1;
411 unsigned char marker:1;
412 unsigned char payload:7;
416 unsigned char extension:1;
417 unsigned char padding:1;
418 unsigned char version:2;
419 unsigned char payload:7;
420 unsigned char marker:1;
438 #if __BYTE_ORDER == __BIG_ENDIAN 449 uint16 duration : 16;
487 {
return ntohs(getRaw2833Payload()->duration);}
495 {getRaw2833Payload()->duration = htons(timestamp);}
538 const unsigned char*
const hdrext, uint32 hdrextlen,
539 const unsigned char*
const data,
size_t datalen,
563 const unsigned char*
const data,
size_t datalen,
613 cachedTimestamp = pts;
625 {
getHeader()->sources[0] = htonl(ssrc); }
689 void setCSRCArray(
const uint32*
const csrcs, uint16 numcsrc);
732 {
return headerValid; }
742 {
return cachedSSRC; }
764 (this->getSSRC() == p.
getSSRC()) ); }
772 {
return !( *
this == p ); }
795 static const uint16 RTP_INVALID_PT_MASK;
796 static const uint16 RTP_INVALID_PT_VALUE;
803 #endif // ndef CCXX_RTP_RTPPKT_H_ uint32 getRawPacketSize() const
Get the raw packet length, including header, extension, payload and padding.
Definition: rtppkt.h:279
uint32 getHdrExtSize() const
Get the length (in octets) of the data contained in the header extension.
Definition: rtppkt.h:244
uint16 getHdrExtUndefined() const
Get the first 16 bits (in network order) of the header of the RTP header extension.
Definition: rtppkt.h:229
The implementation for a SRTP cryptographic context.
Definition: CryptoContext.h:83
uint32 payloadSize
note: payload (not full packet) size.
Definition: rtppkt.h:380
uint16 getSeqNum() const
Definition: rtppkt.h:143
void set2833Duration(uint16 timestamp)
Set 2833 duration field.
Definition: rtppkt.h:494
int32 srtpLength
Lebgth of additional SRTP data.
Definition: rtppkt.h:374
uint32 getHeaderSize() const
Get the length of the header, including contributing sources identifiers and header extension...
Definition: rtppkt.h:115
bool operator!=(const OutgoingRTPPkt &p) const
Outgoing packets are not equal if their sequence numbers differ.
Definition: rtppkt.h:668
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:762
bool isMarked() const
Ask whether the packet is marked (for isntance, is a new talk spurt in some audio profiles)...
Definition: rtppkt.h:185
const unsigned char *const getRawPacket() const
Get the raw packet as it will be sent through the network.
Definition: rtppkt.h:269
uint16 cachedSeqNum
Packet sequence number in host order.
Definition: rtppkt.h:357
uint16 duration
Definition: rtppkt.h:443
bool isExtended() const
Ask whether the packet contains header extensions.
Definition: rtppkt.h:194
void setTimestamp(uint32 pts)
Definition: rtppkt.h:611
A base class for both IncomingRTPPkt and OutgoingRTPPkt.
Definition: rtppkt.h:73
uint32 total
total length, including header, payload and padding
Definition: rtppkt.h:377
void setPayloadType(PayloadType pt)
Definition: rtppkt.h:592
virtual ~RTPPacket()
Destructor, free the buffer provided in the constructor.
Definition: rtppkt.h:307
uint16 get2833Duration(void)
Fetch 2833 duration field.
Definition: rtppkt.h:486
const uint8 *const getPayload() const
Definition: rtppkt.h:122
uint32 cachedTimestamp
Packet timestamp in host order (includes initial shift).
Definition: rtppkt.h:359
void setSSRCNetwork(uint32 ssrc) const
Set synchronization source numeric identifier.
Definition: rtppkt.h:635
bool rbit
Definition: rtppkt.h:441
bool operator==(const OutgoingRTPPkt &p) const
Outgoing packets are equal if their sequence numbers match.
Definition: rtppkt.h:661
void setSSRC(uint32 ssrc) const
Set synchronization source numeric identifier.
Definition: rtppkt.h:624
void setSeqNum(uint16 seq)
Sets the sequence number in the header.
Definition: rtppkt.h:601
~OutgoingRTPPkt()
Definition: rtppkt.h:585
RTP packets being sent.
Definition: rtppkt.h:508
uint16 getCSRCsCount() const
Get the number of contributing sources specified in the packet header.
Definition: rtppkt.h:202
uint32 getRawPacketSizeSrtp() const
Definition: rtppkt.h:283
uint8 vol
Definition: rtppkt.h:442
bool isPadded() const
Ask whether the packet contains padding bytes at the end.
Definition: rtppkt.h:165
size_t getSizeOfFixedHeader() const
Definition: rtppkt.h:287
uint8 getPaddingSize() const
Get the number of octets padding the end of the payload section.
Definition: rtppkt.h:175
a structure defining RFC2833 Telephony events.
Definition: rtppkt.h:436
uint32 getPayloadSize() const
Definition: rtppkt.h:129
struct RFC2833Payload * getRaw2833Payload(void)
Fetch a raw 2833 packet.
Definition: rtppkt.h:478
uint32 srtpDataOffset
Offset into packet memory pointing to area for SRTP data.
Definition: rtppkt.h:367
uint8 getProtocolVersion() const
Definition: rtppkt.h:157
RTP packets received from other participants.
Definition: rtppkt.h:705
Base elements for RTP stacks: constants, types and global functions.
PayloadType getPayloadType() const
Definition: rtppkt.h:136
const unsigned char * getHdrExtContent() const
Get the content of the header extension.
Definition: rtppkt.h:256
bool isHeaderValid()
Get validity of this packet.
Definition: rtppkt.h:731
uint8 event
Definition: rtppkt.h:439
void setExtension(bool e)
Definition: rtppkt.h:326
const RTPHeaderExt * getHeaderExt() const
Get a pointer to RTPHeaderExt pointing after the RTP header (fixed part plus contributing sources)...
Definition: rtppkt.h:337
uint32 getTimestamp() const
Definition: rtppkt.h:150
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:771
RTPFixedHeader * getHeader() const
Return low level structure for the header of the packet.
Definition: rtppkt.h:322
uint32 getSSRC() const
Get synchronization source numeric identifier.
Definition: rtppkt.h:741
uint32 getRawTimestamp() const
Obtain the absolute timestamp carried in the packet header.
Definition: rtppkt.h:349
~IncomingRTPPkt()
Definition: rtppkt.h:722
bool ebit
Definition: rtppkt.h:440
void setMarker(bool mark)
Specify the value of the marker bit.
Definition: rtppkt.h:646
const uint32 * getCSRCs() const
Get the 32-bit identifiers of the contributing sources for the packet as an array, of length getCSRCsCount().
Definition: rtppkt.h:213
void setbuffer(const void *src, size_t len, size_t pos)
Definition: rtppkt.h:353
uint8 PayloadType
RTP payload type numeric identifier.
Definition: formats.h:63