tags:

views:

308

answers:

2

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?

+2  A: 

Surely thats just "long lSeq = (unsigned char)(pszPacket[2] << 8) | (unsigned char)pszPacket[3];"?

Goz
Additionally pszPacket should also be unsigned char[] and not plain char[].
AProgrammer
Good point. I will edit my reply.
Goz
Thank you! may be a little bracket fix:long lSeq = ((unsigned char)pszPacket[2] << 8) | (unsigned char)pszPacket[3];
sea
it doesn't really matter which way round .. but yeah if you prefer do it that way :)
Goz
+3  A: 
unsigned short seq = (packet[2] << 8) | packet[3];
unwind
unsigned short is the correct type for 'seq', not (signed) long. 'char' vs 'unsigned char' doesn't matter for this set of operations (<< and |), though the RTP header should be an array of unsigned bytes.
jesup
+1 for correct and to the point answer
alam