38 #ifndef CCXX_RTP_RTPPKT_H_
39 #define CCXX_RTP_RTPPKT_H_
45 #ifdef CCXX_NAMESPACES
78 struct RTPFixedHeader;
94 RTPPacket(
const unsigned char*
const block,
size_t len,
95 bool duplicate =
false);
117 getHeaderSize()
const
123 inline const uint8*
const
125 {
return (uint8*)(buffer + getHeaderSize()); }
131 getPayloadSize()
const
132 {
return payloadSize; }
138 getPayloadType()
const
139 {
return static_cast<PayloadType>(getHeader()->payload); }
146 {
return cachedSeqNum; }
153 {
return cachedTimestamp; }
159 getProtocolVersion()
const
160 {
return getHeader()->version; }
168 {
return getHeader()->padding; }
177 getPaddingSize()
const
178 {
return buffer[total - 1]; }
188 {
return getHeader()->marker; }
197 {
return getHeader()->extension; }
204 getCSRCsCount()
const
205 {
return getHeader()->cc; }
216 {
return static_cast<const uint32*
>(&(getHeader()->sources[1])); }
231 getHdrExtUndefined()
const
232 {
return (isExtended()? getHeaderExt()->undefined : 0); }
246 getHdrExtSize()
const
247 {
return (isExtended()?
248 (static_cast<uint32>(ntohs(getHeaderExt()->length)) << 2) :
257 inline const unsigned char*
258 getHdrExtContent()
const
259 {
return (isExtended() ?
260 (reinterpret_cast<const unsigned char*>(getHeaderExt()) +
261 sizeof(RTPHeaderExt)) :
270 inline const unsigned char*
const
281 getRawPacketSize()
const
285 getRawPacketSizeSrtp()
const
286 {
return total + srtpLength; }
289 getSizeOfFixedHeader()
const
290 {
return sizeof(RTPFixedHeader); }
303 void reComputePayLength(
bool padding);
323 inline RTPFixedHeader*
325 {
return reinterpret_cast<RTPFixedHeader*
>(buffer); }
329 { getHeader()->extension = e; }
338 inline const RTPHeaderExt*
341 uint32 fixsize =
sizeof(RTPFixedHeader) + (getHeader()->cc << 2);
342 return (reinterpret_cast<RTPHeaderExt*>(buffer + fixsize));
351 getRawTimestamp()
const
352 {
return ntohl(getHeader()->timestamp); }
355 setbuffer(
const void* src,
size_t len,
size_t pos)
356 { memcpy(buffer + pos,src,len); }
386 unsigned char* buffer;
405 struct RTPFixedHeader
407 #if __BYTE_ORDER == __BIG_ENDIAN
409 unsigned char version:2;
410 unsigned char padding:1;
411 unsigned char extension:1;
413 unsigned char marker:1;
414 unsigned char payload:7;
418 unsigned char extension:1;
419 unsigned char padding:1;
420 unsigned char version:2;
421 unsigned char payload:7;
422 unsigned char marker:1;
440 #if __BYTE_ORDER == __BIG_ENDIAN
445 uint16 duration : 16;
451 uint16 duration : 16;
488 inline uint16 get2833Duration(
void)
489 {
return ntohs(getRaw2833Payload()->duration);}
496 inline void set2833Duration(uint16 timestamp)
497 {getRaw2833Payload()->duration = htons(timestamp);}
540 const unsigned char*
const hdrext, uint32 hdrextlen,
541 const unsigned char*
const data,
size_t datalen,
565 const unsigned char*
const data,
size_t datalen,
595 { getHeader()->payload = pt; }
603 setSeqNum(uint16 seq)
606 getHeader()->sequence = htons(seq);
613 setTimestamp(uint32 pts)
615 cachedTimestamp = pts;
616 getHeader()->timestamp = htonl(pts);
626 setSSRC(uint32 ssrc)
const
627 { getHeader()->sources[0] = htonl(ssrc); }
637 setSSRCNetwork(uint32 ssrc)
const
638 { getHeader()->sources[0] = ssrc; }
649 { getHeader()->marker = mark; }
664 {
return ( this->getSeqNum() == p.
getSeqNum() ); }
671 {
return ( this->getSeqNum() != p.
getSeqNum() ); }
691 void setCSRCArray(
const uint32*
const csrcs, uint16 numcsrc);
734 {
return headerValid; }
744 {
return cachedSSRC; }
765 {
return ( (this->getSeqNum() == p.
getSeqNum()) &&
766 (this->getSSRC() == p.
getSSRC()) ); }
774 {
return !( *
this == p ); }
797 static const uint16 RTP_INVALID_PT_MASK;
798 static const uint16 RTP_INVALID_PT_VALUE;
803 #ifdef CCXX_NAMESPACES
807 #endif // ndef CCXX_RTP_RTPPKT_H_