|
NAMENet::SIP::SDP - Parsing and manipulation of SDP data for SIP SYNOPSISmy $sdp = Net::SIP::SDP->new( sdp_string ); my @media = $sdp->get_media; DESCRIPTIONNet::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::*. EXAMPLES # 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 );
CONSTRUCTOR
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). METHODS
WARNING! You should never manipulate the values you got from this function, because this might affect the objects internals.
|