Search code examples
c++rtp

RTP sequence extract


A RTP packet consists of a 12-byte RTP header and subsequent RTP payload The 3rd and 4th byte of the header contain the Most-Significant-Byte and Least-Significant-Byte of the sequence number of the RTP packet Seq Num= (MSB<<8)+LSB

char pszPacket[12];

...

long lSeq = ???? - How to get the sequence number from a packet?


Solution

  • unsigned short seq = (packet[2] << 8) | packet[3];
    

    Note that this assumes packet is an array of unsigned char.