BTW, anyone trying to extract information from RTP packets should note that nearly all of your code is going to great lengths to get 'raw' packets and then going to great lengths to strip off the nested headers to get to $user_data. Yes, I realize that you have reasons for doing it this way, but I wanted to note that people who just want what you asked for can just grab RTP packets in much simpler ways, where they come with the IP and UDP headers already stripped off. So forget all of the above code and just read the RTP packet into $user_data. (:
If you google for rtp rfc, then you'll quickly find this:
5.1 RTP Fixed Header Fields The RTP header has the following format: |0 | 1 | 2 | 3 | |0 1 2 3 4 5 6 7|8 9 0 1 2 3 4 5|6 7 8 9 0 1 2 3|4 5 6 7 8 9 0 1| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |V=2|P|X| CC |M| PT | sequence number | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | timestamp | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | synchronization source (SSRC) identifier | +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ | contributing source (CSRC) identifiers | | .... | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Then you read the pack documentation and then the unpack docs and extracting these fields is quite simple:
my( $bits, $type, $seq, $time )= unpack "C C n N", $user_data;
- tye
In reply to Re: Binary conversion, RTP header (unpack)
by tye
in thread Binary conversion, RTP header
by atistler
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |