// // Copyright @ 2014 Hangzhou Topzen Ltd. // Author: Tang (tang@hztopzen.com) @ 2014-12 // #ifndef __RTP_H #define __RTP_H #include "BaseTypes.h" #include "BytesOrder.h" namespace tzc { // Notice: in network bytes-order struct RTPHead { RTPHead(const TZ_BYTE * net) { Attribute = net[0]; TypeInfo = net[1]; memcpy(&Sequence, net + 2, sizeof(Sequence)); memcpy(&Timestamp, net + 4, sizeof(Timestamp)); memcpy(&SSRC, net + 8, sizeof(SSRC)); Sequence = ntoh_16(Sequence); Timestamp = ntoh_32(Timestamp); SSRC = ntoh_32(SSRC); } TZ_Uint8 IsMarked(); TZ_Uint8 PayloadType(); /* Attribute: 0 1 2 3 4 5 6 7 |--- --- --- --- --- --- --- ---| | V | Pad | E | CSRC count | */ TZ_Uint8 Attribute; /* TypeInfo: 0 1 2 3 4 5 6 7 |--- --- --- --- --- --- --- ---| | M | Payload Type | */ TZ_Uint8 TypeInfo; TZ_Uint16 Sequence; TZ_Uint32 Timestamp; TZ_Uint32 SSRC; }; // // inlines // inline TZ_Uint8 RTPHead::IsMarked() { return (this->TypeInfo & 0x80) != 0; } inline TZ_Uint8 RTPHead::PayloadType() { return this->TypeInfo & 0x7F; } } // namespace tzc #endif /* ----- #ifndef __RTP_H ----- */