Creating an RTSP Server

Introduction

An RTSP server can deliver several media streams simultaneously and independently of each other. The RTSP server listens for connection requests on a TCP/IP port. An RTSP client (like the LEAD RTSP Source Filter) can connect and issue RTSP commands to the server. The most common commands are:

A server needs to respond to each of these commands.

The term "media stream" is used because the media being streamed can be a file or live stream. A live stream can be from a capture device, an MPEG-2 Transport Stream received over a UDP port, or an RTSP stream from another server. It can also be from a DVD image - anything that can be used to create an output file can also be used as a source media stream for an RTSP folder.

Typically, an RTSP server will stream all the files from a certain folder. However, not all compressions are supported by the RTSP streaming technology, so files with incompatible compressions need to be transcoded on the fly.

Currently, the LEAD RTSP Sink Filter supports both H264 and H265 video compressions, and AAC audio compression. Files with different video or audio compressions need to be transcoded to an RTSP-supported compression.

See the "RFC 2326 - Real Time Streaming Protocol (RTSP)" standard for more information on the RTSP specification.

Security

RTSP servers provide a way to restrict access to content from unauthorized users. RTSP servers can optionally use authentication to identify users and then allow access only to authorized users. There are two authentication modes: Basic and Digest. In either mode, users have to enter a username and password before they can gain access to a media stream. Administrators can use different authentication methods and give different access rights to each media stream or the same access rights can be applied to all media streams.

High-Level Implementation

The LEADTOOLS Multimedia SDK provides high-level objects that make it very easy to implement an RTSP server:

Examples

Suppose you want an RTSP server that streams all the files from "c:\MyFiles", and you want the server to listen on address 127.0.0.1 at port 554 (the default RTSP port). This RTSP server handles all RTSP URLs with the format, rtsp://127.0.0.1/RelativeURL, as requests to stream the file c:\MyFiles\RelativeURL. The C# code for a simple server would look like the following code:

C#
// Error checking is suppressed here for brevity  
RTSPServer _server;  
void SetupRTSPServer()  
{  
    // create the server instance  
    _server = new RTSPServer();  
 
    // specify c:\MyFiles as the source folder  
    _server.SetSourceFolder(0, @"c:\MyFiles");  
     
    // will listen on 127.0.0.1  
    _server.TargetAddress = "127.0.0.1";  
 
    // start listening on port 554  
    _server.StartServer(554);  
} 

Here are some examples of using that server to stream files, along with the corresponding URLs:

Connect with the LEAD RTSP Source and stream c:\MyFiles\file1.mpg using the following URL: rtsp://127.0.0.1/file1.mpg

When the LEAD RTSP server receives this URL, it will look for file1.mpg in all of the source folders. In this case, there is only one folder, so it will look for c:\MyFiles\file1.mpg

Streaming Live DVR

When high-level RTSP objects are streaming a growing DVR file, they will start streaming from the live position. This makes it possible to implement live streaming with the RTSP server. When streaming live DVR, all clients see the same video, regardless of how long ago they connected to the RTSP server.

If you are streaming a DVR file that is not growing anymore, the clients will start playing the video from the beginning of the DVR buffer.

Automatic Recompression in High-Level RTSP Objects

When re-streaming an MPEG-2 Transport UDP stream, it is best to stream it as a DVR file because the LEAD MPEG-2 Transport UDP Source filter uses DVR files to store the data.

Help Version 20.0.2020.5.8
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Multimedia