RTSP::Lite - Lightweight RTSP implementation


RTSP-Lite documentation  | view source Contained in the RTSP-Lite distribution.

Index


NAME

Top

RTSP::Lite - Lightweight RTSP implementation

SYNOPSIS

Top

  use RTSP::Lite;
  $rtsp = new RTSP::Lite;
  $rtsp->open("192.168.0.1",554);
  $rtsp->method("DESCRIBE");
  $rtsp->request("rtsp://192.168.0.1/realqt.mov");
  $status_code = $rtsp->status();
  $status_message = $rtsp->status_message();
  print "$status_code $status_message\n";
  print $rtsp->body();

DESCRIPTION

Top

RTSP::Lite is a stand-alone lightweight RTSP/1.0 module for Perl. It is based on Roy Hooper's HTTP::Lite (RTSP protocol is very similar to HTTP protocol. I simply modified it to support RTSP).

The main focus of the module is to help you write simple RTSP clients for monitoring and debugging streaming server. So far, full streaming clients that need RTP handling are out of my scope.

The main modifications from the HTTP::Lite 2.1.4 are: + Supports continuous requests. Therefore explicit open operation is now required. + Supports multiple debug level. + Callback function is not supported. + Deletes http style proxy support. Because RTSP requests to proxy are the same style of requests to server.

METHODS

Top

Set the debug level. 0: no debug message (default), 1: display all network write and read 2: display all debug message

Open a connection to $host:$port. $port can be left out.

Set the method name (OPTIONS, DESCRIBE, PLAY, ...).

Add, Delete, or get RTSP header(s) for the request.

Set the agent name (Default is "RTSP::Lite 0.1").

Send a request to the connected host. If an I/O error is encountered, it returns undef, otherwise RTSP status code is returned.

Note: user-agent and cseq headers are automatically added. If user agent header is specified by add_req_header (), it overwrites the user_agent () variable;

Returns the body of the response.

Returns the status code received from the RTSP server

Returns the textual description of the status code received from the RTSP server.

Returns an array of the RTSP headers received from the RTSP server.

Returns a string representation of the RTSP headers received from the RTSP server.

Returns an array of values for the received response.

You must call this prior to re-using an RTSP::Lite file handle, otherwise the results are undefined.

Explicitly select the local IP address (default 0.0.0.0) and the local port (default 0: automatic selected by system).

EXAMPLES

Top

rtsp-request: command line RTSP request tool (http://www.kosho.org/tools/rtsp-request/).

sample scripts that included in the distribution file describe.pl play.pl

SETUP & PLAY sample #!/usr/bin/perl use RTSP::Lite; $url = "rtsp://192.168.0.1/realqt.mov"; $rtsp = new RTSP::Lite; ## open the connection $req = $rtsp->open("192.168.0.1",554) or die "Unable to open: $!";

  ## SETUP
  $rtsp->method("SETUP");
  $rtsp->add_req_header("Transport","RTP/AVP;unicast;client_port=6970-6971");
  $req = $rtsp->request($url."/streamid=0");

  my $se = $rtsp->get_header("Session");
  $session = @$se[0];
  print $rtsp->status_message();
  print_headers();
  ## Play
  $rtsp->reset();
  $rtsp->method("PLAY");
  $rtsp->add_req_header("Session","$session");
  $rtsp->add_req_header("Range","npt=0.000000-5.200000");
  $req = $rtsp->request($url);
  print $rtsp->status_message();
  print_headers();
  ## You will get RTP/RTCP packets, you need to have codes for them.
  exit;
  sub print_headers {
    my @headers = $rtsp->headers_array();
    my $body = $rtsp->body();
    foreach $header (@headers) {
      print "$header\n";
    }
  }

AUTHOR

Top

Masaaki NABESHIMA <http://www.kosho.org/>

SEE ALSO

Top

 RFC 2326 - Real Time Streaming Protocol (RTSP)
 HTTP::Lite module (http://www.thetoybox.org/http-lite/)

ACKNOWLEDGEMENTS

Top

This module is a deviation of HTTP::Lite, maintained by Roy Hooper. Without it this module never exist.

COPYRIGHT

Top

AVAILABILITY

Top

The latest version of this module is available at: http://www.kosho.org/tools/rtsp-lite/


RTSP-Lite documentation  | view source Contained in the RTSP-Lite distribution.