NATHAN242's Projects
Projects
Tools
Libraries
Web Tools
Project repo: LINK
This is a PHP class for interacting with the RTSP protocol. It is still a work in progress.
I started this whilst experimenting with the possibility of getting an RTSP stream from a device on the server side then transcoding it so it can be played in a webpage. This was for the IPCAM-CCTV project so that live camera streams could be shown in the browser but I never got around to finishing this.
This class only handles communication with the RTSP control protocol. You can activate streams on devices but you will need separate software to receive them.
Instantiate the class with the address, port and optional username and password.
$rtsp = new rtsp_client("10.10.9.110", 554, "admin", "123456");
You can then use the request() method to communicate with the protocol.
$url = "rtsp://10.10.9.110/media/video1"; $options = $rtsp->request("OPTIONS", $url); $desc = $rtsp->request("DESCRIBE", $url); $setup = $rtsp->request("SETUP", $url."/video", array('Transport'=>'RTP/AVP;unicast;client_port=52614-52615', 'User-Agent'=>'PHPrtsp_client/0.0.1')); $rtsp->request("PLAY", $url, array('Session'=>$setup['Session'], 'User-Agent'=>'PHPrtsp_client/0.0.1', 'Range'=>'npt=0.000-'));
The request() method will return an array containing the key/values of the rtsp response. The example above shows using the "session" variable returned from the RTSP "SETUP" call for the "PLAY" call.