NAME

RTSP::Client - High-level client for the Real-Time Streaming Protocol

SYNOPSIS

use RTSP::Client;
my $client = new RTSP::Client(
    port               => 554,
    client_port_range  => '6970-6971',
    transport_protocol => 'RTP/AVP;unicast',
    address            => '10.0.1.105',
    media_path         => '/mpeg4/media.amp',
);

# OR
my $client = RTSP::Client->new_from_uri(uri => 'rtsp://10.0.1.105:554/mpeg4/media.amp');

$client->open or die $!;

my $sdp = $client->describe;
my @allowed_public_methods = $client->options_public;

$client->setup;
$client->reset;

$client->play;
$client->pause;


$client->teardown;

DESCRIPTION

This module provides a high-level interface for communicating with an RTSP server. RTSP is a protocol for controlling streaming applications, it is not a media transport or a codec. It supports describing media streams and controlling playback, and that's about it.

In typical usage, you will open a connection to an RTSP server and send it the PLAY method. The server will then stream the media at you on the client port range using the specified transport protocol. You are responsible for listening on the client port range and handling the actual media data yourself, actually receiving a media stream or decoding it is beyond the scope of RTSP and this module.

EXPORT

No namespace pollution here!

ATTRIBUTES

session_id

RTSP session id. It will be set on a successful OPEN request and added to each subsequent request

client_port_range

Ports the client receives data on. Listening and receiving data is not handled by RTSP::Client

media_path

Path to the requested media stream

e.g. /mpeg4/media.amp

transport_protocol

Requested transport protocol, RTP by default

address

RTSP server address. This is required.

port

RTSP server port. Defaults to 554

connected

Is the client connected?

Print out debug headers

debug

Print debugging information (request status)

METHODS

open

This method opens a connection to the RTSP server. Returns true on success, false with $! possibly set on failure.

setup

A SETUP request specifies how a single media stream must be transported. This must be done before a PLAY request is sent. The request contains the media stream URL and a transport specifier. This specifier typically includes a local port for receiving RTP data (audio or video), and another for RTCP data (meta information). The server reply usually confirms the chosen parameters, and fills in the missing parts, such as the server's chosen ports. Each media stream must be configured using SETUP before an aggregate play request may be sent.

new_from_uri(%opts)

Takes same opts as new() and adds additional param: uri

e.g. my $rtsp_client = RTSP::Client->new_from_uri(uri => 'rtsp://10.0.1.105:554/mpeg4/media.amp', debug => 1);

play

A PLAY request will cause one or all media streams to be played. Play requests can be stacked by sending multiple PLAY requests. The URL may be the aggregate URL (to play all media streams), or a single media stream URL (to play only that stream). A range can be specified. If no range is specified, the stream is played from the beginning and plays to the end, or, if the stream is paused, it is resumed at the point it was paused.

pause

A PAUSE request temporarily halts one or all media streams, so it can later be resumed with a PLAY request. The request contains an aggregate or media stream URL.

record

The RECORD request can be used to send a stream to the server for storage.

teardown

A TEARDOWN request is used to terminate the session. It stops all media streams and frees all session related data on the server.

options_public

An OPTIONS request returns the request types the server will accept.

This returns an array of allowed public methods.

describe

The reply to a DESCRIBE request includes the presentation description, typically in Session Description Protocol (SDP) format. Among other things, the presentation description lists the media streams controlled with the aggregate URL. In the typical case, there is one media stream each for audio and video.

This method returns the actual DESCRIBE content, as SDP data

request($method)

Sends a $method request, returns true on success, false with $! possibly set on failure

reset

If you wish to reuse the client for multiple requests, you should call reset after each request unless you want to keep the socket open.

status_message

Get the status message of the last request (e.g. "Bad Request")

status

Get the status code of the last request (e.g. 200, 405)

get_header ($header)

returns response header

add_req_header ($header, $value)
get_req_header ($header)
delete_req_header ($header)

SEE ALSO

RTSP::Lite, http://en.wikipedia.org/wiki/Real_Time_Streaming_Protocol

AUTHOR

Mischa Spiegelmock <revmischa@cpan.org>

ACKNOWLEDGEMENTS

This is based entirely on RTSP::Lite by Masaaki Nabeshima.

COPYRIGHT AND LICENSE

Copyright (C) 2010 by Mischa Spiegelmock

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available.