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);
114 getHeaderSize()
const
120 inline const uint8*
const
122 {
return (uint8*)(buffer + getHeaderSize()); }
128 getPayloadSize()
const
129 {
return payloadSize; }
135 getPayloadType()
const
136 {
return static_cast<PayloadType>(getHeader()->payload); }
143 {
return cachedSeqNum; }
150 {
return cachedTimestamp; }
156 getProtocolVersion()
const
157 {
return getHeader()->version; }
165 {
return getHeader()->padding; }
174 getPaddingSize()
const
175 {
return buffer[total - 1]; }
185 {
return getHeader()->marker; }
194 {
return getHeader()->extension; }
201 getCSRCsCount()
const
202 {
return getHeader()->cc; }
213 {
return static_cast<const uint32*
>(&(getHeader()->sources[1])); }
228 getHdrExtUndefined()
const
229 {
return (isExtended()? getHeaderExt()->undefined : 0); }
243 getHdrExtSize()
const
244 {
return (isExtended()?
245 (static_cast<uint32>(ntohs(getHeaderExt()->length)) << 2) :
254 inline const unsigned char*
255 getHdrExtContent()
const
256 {
return (isExtended() ?
257 (reinterpret_cast<const unsigned char*>(getHeaderExt()) +
258 sizeof(RTPHeaderExt)) :
267 inline const unsigned char*
const
278 getRawPacketSize()
const
282 getRawPacketSizeSrtp()
const
283 {
return total + srtpLength; }
286 getSizeOfFixedHeader()
const
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));
348 getRawTimestamp()
const
349 {
return ntohl(getHeader()->timestamp); }
352 setbuffer(
const void* src,
size_t len,
size_t pos)
353 { memcpy(buffer + pos,src,len); }
383 unsigned char* buffer;
402 struct RTPFixedHeader
404 #if defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN
406 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;
485 inline uint16 get2833Duration(
void)
486 {
return ntohs(getRaw2833Payload()->duration);}
493 inline void set2833Duration(uint16 timestamp)
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,
600 setSeqNum(uint16 seq)
610 setTimestamp(uint32 pts)
612 cachedTimestamp = pts;
623 setSSRC(uint32 ssrc)
const
624 {
getHeader()->sources[0] = htonl(ssrc); }
634 setSSRCNetwork(uint32 ssrc)
const
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_