The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Net::oRTP - Perl interface to the oRTP C library

SYNOPSIS

  use Net::oRTP;

  my $rtp = Net::oRTP->new( 'SENDONLY' );
  $rtp->set_remote_addr( '237.70.58.86', 5004 );
  $rtp->set_send_payload_type( 8 );
  
  while(1)
  {
     $payload = read_alaw_audio( 160 );
     $rtp->send_with_ts( $payload, $timestamp);
     $timestamp+=160;
  }

DESCRIPTION

Net::oRTP is a perl interface to the oRTP C library - a RTP (Real-time Transport Protocol) stack.

$rtp = new Net::oRTP( $mode )

The new() method is the constructor for the Net::oRTP class.

The $mode parameter can be one of the following values:

        RECVONLY
        SENDONLY
        SENDRECV
        

Which sets the RTP session to Receive Only Mode, Send Only Mode and Send Receive modes respectively.

$rtp->set_blocking_mode( $yesno )

If $yesno is true, recv_with_ts() will block until it is time for the packet to be received, according to the timestamp passed to the function. After this time, the function returns. For send_with_ts(), it will block until it is time for the packet to be sent. If $yesno is false, then the two functions will return immediately.

$rtp->set_local_addr( $address, $port )

Specify the local addr to be use to listen for RTP packets or to send RTP packet from. In case where the RTP session is send-only, then it is not required to call this function: when calling set_remote_addr(), if no local address has been set, then the default INADRR_ANY (0.0.0.0) IP address with a random port will be used. Calling set_local_addr() is mandatory when the session is recv-only or duplex.

$rtp->get_local_port()

Returns the local port that the socket is bound to.

$rtp->set_remote_addr( $address, $port )

Sets the remote address of the RTP session, ie the destination address where RTP packet are sent. If the session is recv-only or duplex, it also sets the origin of incoming RTP packets. RTP packets that don't come from addr:port are discarded.

$rtp->get_jitter_compensation()

Gets the time interval for which packet are buffered instead of being delivered to the application.

$rtp->set_jitter_compensation( $milisec )

Sets the time interval for which packet are buffered instead of being delivered to the application.

$rtp->set_adaptive_jitter_compensation( $yesno )

Enable or disable adaptive jitter compensation.

$rtp->get_adaptive_jitter_compensation()

Gets the current state of adaptive jitter compensation.

$rtp->set_send_ssrc( $ssrc )

Sets the SSRC for the outgoing stream. If not done, a random ssrc is used.

$rtp->get_send_ssrc( $ssrc )

Gets the SSRC for the outgoing stream.

$rtp->set_send_seq_number( $seqnum )

Sets the initial sequence number of a freshly created session.

$rtp->get_send_seq_number( )

Returns the current sequence number of a session.

$rtp->set_send_payload_type( $payload_type )

Sets the payload type for outgoing packets in the session.

$rtp->get_send_payload_type( $payload_type )

Gets the payload type for outgoing packets in the session.

$rtp->set_recv_payload_type( $payload_type )

Sets the expected payload type for incoming packets.

$rtp->recv_with_ts( $bytes, $timestamp )

Tries to read $bytes bytes from the incoming RTP stream related to timestamp $timestamp. When blocking mode is on (see set_blocking_mode() ), then the calling thread is suspended until the timestamp given as argument expires, whatever a received packet fits the query or not.

Important note: it is clear that the application cannot know the timestamp of the first packet of the incoming stream, because it can be random. The time timestamp given to the function is used relatively to first timestamp of the stream. In simple words, 0 is a good value to start calling this function.

$rtp->send_with_ts( $data, $timestamp )

Send a RTP datagram to the destination set by set_remote_addr() containing $data with timestamp $timestamp. Refer to RFC3550 to know what it is.

$rtp->flush_sockets()

Flushes the sockets for all pending incoming packets. This can be usefull if you did not listen to the stream for a while and wishes to start to receive again. During the time no receive is made packets get bufferised into the internal kernel socket structure.

$rtp->reset()

Reset the session: local and remote addresses are kept unchanged but the internal queue for ordering and buffering packets is flushed, the session is ready to be re-synchronised to another incoming stream.

SEE ALSO

http://www.ietf.org/rfc/rfc3550.txt

http://www.linphone.org/ortp/

BUGS

Please report any bugs or feature requests to bug-net-ortp@rt.cpan.org, or through the web interface at http://rt.cpan.org. I will be notified, and then you will automatically be notified of progress on your bug as I make changes.

AUTHOR

Nicholas Humfrey, njh@ecs.soton.ac.uk

COPYRIGHT AND LICENSE

Copyright (C) 2006 University of Southampton

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.