|
RTSP::Lite - Lightweight RTSP implementation |
RTSP::Lite - Lightweight RTSP implementation
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();
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.
header(s) for the request.
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;
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";
}
}
Masaaki NABESHIMA <http://www.kosho.org/>
RFC 2326 - Real Time Streaming Protocol (RTSP) HTTP::Lite module (http://www.thetoybox.org/http-lite/)
This module is a deviation of HTTP::Lite, maintained by Roy Hooper. Without it this module never exist.
Copyright (c) 2003, Masaaki NABESHIMA. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The latest version of this module is available at: http://www.kosho.org/tools/rtsp-lite/
|
RTSP::Lite - Lightweight RTSP implementation |