0x1949 Team - FAZEMRX - MANAGER
Edit File: Net::SIP::SDP.3pm
.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" 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" '' . ds C` . ds C' '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 >0, 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. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Net::SIP::SDP 3pm" .TH Net::SIP::SDP 3pm "2021-05-04" "perl v5.34.0" "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. \fBdie()\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 specify 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, INDEX\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.