|
Net::SDP - Session Description Protocol |
Net::SDP - Session Description Protocol (rfc2327)
use Net::SDP;
my $sdp = Net::SDP->new();
$sdp->parse_file( 'myfile.sdp' );
print "Session name: ".$sdp->session_name()."\n";
print "Session info: ".$sdp->session_info()."\n";
print "Session tool: ".$sdp->session_attribute('tool')."\n";
$sdp->session_info( "This is my session" );
print $sdp->generate();
Net::SDP is an SDP (Session Description Protocol) parser and generator.
Net::SDP is object oriented and a single instance of Net::SDP represents
a single SDP session description. There are methods to easily get, set and create
each of the fields in the session description.
The classes Net::SDP::Time and Net::SDP::Media are automatically instantiated
for each Time Description (t=) and Media Description (m=).
Net::SDP session description object with default values for
the required fields.
If the optional paramater source is specified, then it is passed to
parse(). If parsing fails, than new() will return undef.
Net::SAP::Packet object, SDP data itself or if undefined
will be read in on STDIN.
Returns 1 if successful, or 0 on failure.
NOTE: it is faster to pass SDP data straight into the new() method, as it does not
then initialise the object with default values, this involves doing DNS lookups to
find out the name of the local host.
Example:
$origin = $sdp->session_origin();
$sdp->session_origin( 'njh 3303643609 3303643669 IN IP4 152.78.104.83' );
Example:
$username = $sdp->session_origin_username();
$sdp->session_origin_username( 'njh' );
Example:
$id = $sdp->session_origin_id();
$sdp->session_origin_id( 3303643609 );
Example:
$version = $sdp->session_origin_version();
$sdp->session_origin_version( 3303643669 );
Example:
$net_type = $sdp->session_origin_net_type();
$sdp->session_origin_net_type( 'IN' );
Example:
$addr_type = $sdp->session_origin_addr_type();
$sdp->session_origin_addr_type( 'IP6' );
Example:
$address = $sdp->session_origin_address();
$sdp->session_origin_address( '152.78.104.83' );
Example:
$ident = $sdp->session_identifier();
Example:
$name = $sdp->session_name();
$sdp->session_name( 'My Cool Session' );
Example:
$name = $sdp->session_info();
$sdp->session_info( 'Broadcast live from Southampton' );
Example:
$name = $sdp->session_uri();
$sdp->session_uri( 'http://www.surgeradio.co.uk' );
Example:
$email = $sdp->session_email();
$sdp->session_email( 'njh@ecs.soton.ac.uk' );
$sdp->session_email( ['njh@ecs.soton.ac.uk', 'njh@surgeradio.co.uk'] );
Example:
$phone = $sdp->session_phone();
$sdp->session_phone( '+44 870 357 2287' );
$sdp->session_phone( ['0870 357 2287', '41287'] );
Example:
($method, $key) = $sdp->session_key();
$sdp->session_key( 'prompt' );
$sdp->session_key( 'base64', 'AoItAE8BAQ8DAQOBQwA' );
When setting an attribute, if you pass in a scalar, then all attributes with the same name will be replaced. Alternively an attribute may be set to multiple values by passing an ARRAYREF. If an attribute does not require it, then the value parameter is optional - eg for 'recvonly' attribute.
When getting an attribute that has no value, then '' is returned, or if the attribute does not exists then undef is returned. If the attribute has a single value, then that value is returned, or if it has more than one value then an ARRAYREF is returned.
Example:
$tool = $sdp->session_attribute( 'tool' );
$sdp->session_attribute( 'recvonly' );
Example:
$hashref = $sdp->session_attributes();
Example:
$audio->session_add_attribute( 'lang', 'en');
$audio->session_add_attribute( 'lang', 'fr');
=item B<session_del_attribute( name )>
Deletes all attributes of given name. Example:
$audio->session_del_attribute( 'lang' );
Net::SDP::Media) of the specified type.
Example:
$audio = $sdp->media_desc_of_type( 'audio' );
Net::SDP::Media objects.
$num.
Returns 0 if successful or 1 on failure.
Net::SDP::Time.
Net::SDP::Time objects.
$num.
Returns 0 if successful or 1 on failure.
Net::SDP::Time object.
Net::SDP::Media object.
The type parameter is optional, and will set the media type if specified.
Example:
$time = $sdp->new_media_desc( 'audio' );
perl(1), the Net::SAP manpage
http://www.ietf.org/rfc/rfc2327.txt
Please report any bugs or feature requests to
bug-net-sdp@rt.cpan.org, or through the web interface at
http://rt.cpan.org. I will be notified, and then you'll automatically
be notified of progress on your bug as I make changes.
Nicholas J Humfrey, njh@cpan.org
Copyright (C) 2004 University of Southampton
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.005 or, at your option, any later version of Perl 5 you may have available.
|
Net::SDP - Session Description Protocol |