in reply to Re: Binary conversion, RTP header (unpack)
in thread Binary conversion, RTP header

You have no idea how much this has helped me. Thank you so much for spreading your wisdom to a perl newbie. One more thing, the $header variable in this case is a reference to a hash?? I believe that it contians references to packet recv time, len, etc. How can I view that information??
sub process_rtp_packets { my ($user_data, $header, $packet) = @_; for my $key ( keys %header ) { my $value = $header{$key}; print "$key => $value\n"; } my $eth_obj = NetPacket::Ethernet->decode($packet); my $ether_data = NetPacket::Ethernet::strip($packet); my $ip_obj = NetPacket::IP->decode($ether_data); my $ip_data = NetPacket::IP::strip($ether_data); my $udp_obj = NetPacket::UDP->decode($ip_data); my $RTP_data = $udp_obj->{data}; my( $bits, $type, $seq, $time )= unpack "C C n N", $RTP_data; print "$bits\n"; print "$type\n"; print "$seq\n"; print "$time\n"; }

Replies are listed 'Best First'.
Re^3: Binary conversion, RTP header (refs)
by tye (Sage) on Dec 22, 2005 at 04:56 UTC

    Add 'use strict;' and change %header to %$header and change $header{...} to $header->{...}. You might find References quick reference helpful. For more in-depth information on references, start with "perldoc perlreftut"

    - tye