.\" Automatically generated by Pod::Man 2.25 (Pod::Simple 3.16) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .ie \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .el \{\ . de IX .. .\} .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Net::SIP::SDP 3pm" .TH Net::SIP::SDP 3pm "2012-06-08" "perl v5.14.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Net::SIP::SDP \- Parsing and manipulation of SDP data for SIP .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& my $sdp = Net::SIP::SDP\->new( sdp_string ); \& my @media = $sdp\->get_media; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Net::SIP::SDP can parse and manipulate \s-1SDP\s0 data. .PP It's not a general purpose \s-1SDP\s0 class (like Net::SDP) but designed to work with \s-1SDP\s0 data contained in \s-1SIP\s0 packets and for easy extraction and manipulation (for \s-1NAT\s0 etc) of media information contained in the \s-1SDP\s0. .PP The class is also designed for easy creation of \s-1SDP\s0 bodies in the context of the rest of Net::SIP::*. .SH "EXAMPLES" .IX Header "EXAMPLES" .Vb 6 \& # creation based on media data \& my $sdp = Net::SIP::SDP\->new( \& { addr => \*(Aq192.168.0.1\*(Aq }, \& { port => 2012, proto => \*(AqRTP/AVP\*(Aq, media => \*(Aqaudio\*(Aq, fmt => 0 }, \& { port => 2014, proto => \*(AqRTP/AVP\*(Aq, media => \*(Aqvideo\*(Aq, 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( \*(Aq192.168.178.1\*(Aq, $_\->{range} ); \& push @new_media, [ \*(Aq192.168.178.1\*(Aq, $port ]; \& ... \& } \& $sdp\->replace_media_listen( @new_media ); .Ve .SH "CONSTRUCTOR" .IX Header "CONSTRUCTOR" .IP "new" 4 .IX Item "new" Default constructor. Depending on kind of arguments branches into \fBnew_from_string\fR or \fBnew_from_parts\fR. See there. .IP "new_from_string ( \s-1STRING\s0 )" 4 .IX Item "new_from_string ( STRING )" Creates object from \s-1STRING\s0 containing the \s-1SDP\s0 data. Raises an exception (e.g. \fIdie()\fR) if \s-1SDP\s0 is invalid. .ie n .IP "new_from_parts ( \e%GLOBAL, @MEDIA )" 4 .el .IP "new_from_parts ( \e%GLOBAL, \f(CW@MEDIA\fR )" 4 .IX Item "new_from_parts ( %GLOBAL, @MEDIA )" Creates object from specification. \&\f(CW%GLOBAL\fR describes the global keys, usually only a common \f(CW\*(C`addr\*(C'\fR for all media but any of the keys defined in \s-1RFC2327\s0 can be used. .Sp \&\f(CW@MEDIA\fR is a list of hash references, one hash for each media part. These hashes can contain as keys the one-letter keys specified in \s-1RFC2327\s0 and/or special keys for constructing the 'c' and 'm' line: .RS 4 .IP "addr \- The address, used in the 'c' line." 8 .IX Item "addr - The address, used in the 'c' line." .PD 0 .IP "port \- The port number" 8 .IX Item "port - The port number" .IP "range \- Range of ports, for \s-1RTP/AVP\s0 defaults to 2, else 1" 8 .IX Item "range - Range of ports, for RTP/AVP defaults to 2, else 1" .IP "media \- The media typ, e.g. 'audio','video',..." 8 .IX Item "media - The media typ, e.g. 'audio','video',..." .IP "proto \- Transport protocol, ususally '\s-1RTP/AVP\s0' or 'udp'" 8 .IX Item "proto - Transport protocol, ususally 'RTP/AVP' or 'udp'" .RE .RS 4 .PD .Sp If the \s-1SDP\s0 should contain multiple values for the same key in the same media section on can specifiy the value for the key as a \e@list instead of a string (this is often the case for 'a' lines). .RE .SH "METHODS" .IX Header "METHODS" .IP "as_string" 4 .IX Item "as_string" Returns string representation for object. .IP "content_type" 4 .IX Item "content_type" Returns 'application/sdp' .IP "get_media" 4 .IX Item "get_media" Returns list of all media described in the \s-1SDP\s0. If the caller expects an array the result will be a list, otherwise a reference to a list. .Sp Each element of the list is a hash with the following keys: .RS 4 .IP "addr \- \s-1IP4/IP6\s0 address for media" 8 .IX Item "addr - IP4/IP6 address for media" .PD 0 .IP "port \- Start port" 8 .IX Item "port - Start port" .IP "range \- Range for ports" 8 .IX Item "range - Range for ports" .IP "proto \- Media proto, usually '\s-1RTP/AVP\s0' or 'udp'" 8 .IX Item "proto - Media proto, usually 'RTP/AVP' or 'udp'" .IP "media \- Media typ, usually 'audio', 'video' or 'data'" 8 .IX Item "media - Media typ, usually 'audio', 'video' or 'data'" .ie n .IP "fmt \- Format info from media line as \e@list, e.g ""[ 0,10,5 ]""." 8 .el .IP "fmt \- Format info from media line as \e@list, e.g \f(CW[ 0,10,5 ]\fR." 8 .IX Item "fmt - Format info from media line as @list, e.g [ 0,10,5 ]." .IP "lines \- All lines from media description as \e@list of [ key,value ]." 8 .IX Item "lines - All lines from media description as @list of [ key,value ]." .RE .RS 4 .PD .Sp \&\fB\s-1WARNING\s0!\fR You should never manipulate the values you got from this function, because this might affect the objects internals. .RE .IP "replace_media_listen ( \s-1NEW_MEDIA\s0 )" 4 .IX Item "replace_media_listen ( NEW_MEDIA )" Replaces the exisisting media in the object with new media. Useful for \s-1NAT\s0. .Sp \&\s-1NEW_MEDIA\s0 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. .Sp The number of entries in the list should be the same as the number of media entries in the object ( see \fBget_media\fR ). If this is not the case it will \&\f(CW\*(C`die()\*(C'\fR. .IP "name2int ( \s-1NAME\s0, \s-1INDEX\s0 )" 4 .IX Item "name2int ( NAME, INDEX )" Returns the \s-1RTP\s0 payload id for \s-1NAME\s0 (e.g. \*(L"telephone\-event/8000\*(R"). \&\s-1INDEX\s0 is the index into the list of media information, matching the list returned from get_media. \s-1INDEX\s0 can also be 'audio','video'.., which will then lookup at the first matching entry in the media list.