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);
115 getHeaderSize()
const
121 inline const uint8*
const
123 {
return (uint8*)(buffer + getHeaderSize()); }
129 getPayloadSize()
const
130 {
return payloadSize; }
136 getPayloadType()
const
137 {
return static_cast<PayloadType>(getHeader()->payload); }
144 {
return cachedSeqNum; }
151 {
return cachedTimestamp; }
157 getProtocolVersion()
const
158 {
return getHeader()->version; }
166 {
return getHeader()->padding; }
175 getPaddingSize()
const
176 {
return buffer[total - 1]; }
186 {
return getHeader()->marker; }
195 {
return getHeader()->extension; }
202 getCSRCsCount()
const
203 {
return getHeader()->cc; }
214 {
return static_cast<const uint32*
>(&(getHeader()->sources[1])); }
229 getHdrExtUndefined()
const
230 {
return (isExtended()? getHeaderExt()->undefined : 0); }
244 getHdrExtSize()
const
245 {
return (isExtended()?
246 (static_cast<uint32>(ntohs(getHeaderExt()->length)) << 2) :
255 inline const unsigned char*
256 getHdrExtContent()
const
257 {
return (isExtended() ?
258 (reinterpret_cast<const unsigned char*>(getHeaderExt()) +
259 sizeof(RTPHeaderExt)) :
268 inline const unsigned char*
const
279 getRawPacketSize()
const
283 getRawPacketSizeSrtp()
const
284 {
return total + srtpLength; }
287 getSizeOfFixedHeader()
const
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));
349 getRawTimestamp()
const
350 {
return ntohl(getHeader()->timestamp); }
353 setbuffer(
const void* src,
size_t len,
size_t pos)
354 { memcpy(buffer + pos,src,len); }
384 unsigned char* buffer;
403 struct RTPFixedHeader
405 #if __BYTE_ORDER == __BIG_ENDIAN
407 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
443 uint16 duration : 16;
449 uint16 duration : 16;
486 inline uint16 get2833Duration(
void)
487 {
return ntohs(getRaw2833Payload()->duration);}
494 inline void set2833Duration(uint16 timestamp)
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,
601 setSeqNum(uint16 seq)
611 setTimestamp(uint32 pts)
613 cachedTimestamp = pts;
624 setSSRC(uint32 ssrc)
const
625 {
getHeader()->sources[0] = htonl(ssrc); }
635 setSSRCNetwork(uint32 ssrc)
const
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_