Net::SIP::SDP(3pm) | User Contributed Perl Documentation | Net::SIP::SDP(3pm) |
Net::SIP::SDP - Parsing and manipulation of SDP data for SIP
my $sdp = Net::SIP::SDP->new( sdp_string ); my @media = $sdp->get_media;
Net::SIP::SDP can parse and manipulate SDP data.
It's not a general purpose SDP class (like Net::SDP) but designed to work with SDP data contained in SIP packets and for easy extraction and manipulation (for NAT etc) of media information contained in the SDP.
The class is also designed for easy creation of SDP bodies in the context of the rest of Net::SIP::*.
# creation based on media data my $sdp = Net::SIP::SDP->new( { addr => '192.168.0.1' }, { port => 2012, proto => 'RTP/AVP', media => 'audio', fmt => 0 }, { port => 2014, proto => 'RTP/AVP', media => 'video', fmt => 0 }, ); # parse from string my $sdp = Net::SIP::SDP->new( sdp_string ); # extract all media data my @media = $sdp->get_media; # and replace them with new addr + port (for NAT) my @new_media,; foreach (@media) { my ($port,@socks) = create_rtp_sockets( '192.168.178.1', $_->{range} ); push @new_media, [ '192.168.178.1', $port ]; ... } $sdp->replace_media_listen( @new_media );
@MEDIA is a list of hash references, one hash for each media part. These hashes can contain as keys the one-letter keys specified in RFC2327 and/or special keys for constructing the 'c' and 'm' line:
If the SDP should contain multiple values for the same key in the same media section on can specify the value for the key as a \@list instead of a string (this is often the case for 'a' lines).
Each element of the list is a hash with the following keys:
WARNING! You should never manipulate the values you got from this function, because this might affect the objects internals.
NEW_MEDIA is ether an array or a reference to an array. Each element in the list consists of the new [ addr,port ] mapping for the matching media entry.
The number of entries in the list should be the same as the number of media entries in the object ( see get_media ). If this is not the case it will "die()".
2023-02-04 | perl v5.36.0 |