RTSP Blog
RTSP Blog
1. Understanding RTSP
The RTSP architecture follows a client-server model, where the client initiates
requests to the server for various operations, such as opening a media session,
pausing playback, seeking, or closing the session. The server responds to these
requests, and together they coordinate the media streaming process.
RTSP defines a set of methods that clients can use to communicate with the server.
Some common RTSP methods include:
DESCRIBE: Retrieves the description of the media content, such as its format,
encoding, and presentation details.
SETUP: Sets up the delivery parameters for the media session, like the transport
protocol and port numbers.
PLAY: Initiates the playback of the media stream.
PAUSE: Temporarily halts the playback.
TEARDOWN: Terminates the media session.
For each RTSP request, the server provides a corresponding response with a status
code indicating the success or failure of the operation.
RTSP uses URLs (Uniform Resource Locators) to identify and locate media resources.
The RTSP URL format typically follows the scheme: rtsp://hostname[:port]/location,
where "hostname" is the domain or IP address of the server, "port" is the optional
port number (default is 554 for RTSP), and "location" is the path to the media
content.
Session control is a crucial aspect of RTSP. Clients can use the PLAY, PAUSE, and
TEARDOWN methods to manage sessions, enabling them to control the timing and
synchronization of media playback.
While RTSP handles session control and media resource identification, the actual
delivery of multimedia data is achieved through Real-Time Transport Protocol (RTP).
RTP is responsible for packetizing the media content, adding timestamps, and
ensuring timely delivery. RTSP and RTP work in tandem to offer a complete real-time
streaming solution.
8. RTSP Applications
IP Camera Surveillance: RTSP is commonly used to access live video feeds from IP
cameras and control their movements remotely.
Video Conferencing: RTSP allows real-time transmission of audio and video streams
in video conferencing systems.
Streaming Services: Many media streaming services, especially those using RTSP and
RTP in combination, benefit from the low latency and synchronized playback
features.
IPTV (Internet Protocol Television): RTSP facilitates the delivery of IPTV content
to set-top boxes and connected devices.
Virtual Reality (VR) and Augmented Reality (AR): RTSP can be employed to stream
immersive content in VR and AR applications.
9. Advantages of RTSP
Low Latency: RTSP is designed to offer low latency streaming, making it suitable
for real-time applications.
Synchronization: The protocol supports synchronized playback across multiple
clients, crucial for scenarios like live events and video conferencing.
Efficient Control: RTSP's explicit control model allows clients to have precise
control over media session management.
Scalability: RTSP enables the creation of multiple media sessions, making it
scalable for different applications.
Protocol Interoperability: RTSP can work with various transport protocols,
providing flexibility and compatibility.
Firewall and NAT Traversal: RTSP can encounter issues with firewalls and Network
Address Translation (NAT), affecting connectivity between clients and servers.
Security Concerns: Like any other streaming protocol, RTSP raises security concerns
regarding unauthorized access, eavesdropping, and denial-of-service attacks.
Media Format Support: RTSP itself does not specify media formats, and codec
compatibility could be a challenge in certain implementations.
Mobile and Wireless Networks: RTSP's low-latency advantage can be affected in
unstable or bandwidth-constrained mobile and wireless networks.
7. RTSP Headers
RTSP defines a set of headers that provide additional information about requests
and responses. Some common headers include:
CSeq: Sequence number of the RTSP request or response. Used to manage message
ordering.
Session: Identifies the media session to which the request or response belongs.
Transport: Specifies the transport protocol and parameters for the media stream.
Range: Defines the range of time over which the client requests playback.
Headers play a crucial role in facilitating various RTSP operations.
9. Security Considerations
RTSP introduces security challenges due to its exposure to the public internet. RFC
2326 outlines several security considerations, including:
Real-Time Protocol (RTP) is the preferred transport protocol for media content
delivery in conjunction with RTSP. RTP handles packetization, sequencing, and
timestamping of media data, while RTSP handles session control. Session Description
Protocol (SDP) is used to describe the format and characteristics of media streams
in RTSP requests and responses.
3. RTSP Components
The RTSP architecture comprises several key components that play specific roles in
the streaming process:
Client: The client is the application or device that sends RTSP requests to the
server to control media sessions, initiate playback, pause, seek, and terminate
sessions.
Server: The server stores and serves the multimedia content to clients. It responds
to RTSP requests, establishes and manages media sessions, and delivers media data
using RTP.
Media Content: The media content includes audio, video, or other multimedia data
that is stored on the server and made available to clients for streaming.
RTP Protocol: RTSP works in conjunction with RTP, which is responsible for
packetizing, sequencing, and timestamping the media data. RTP operates on a
separate transport layer and delivers the actual multimedia content to the clients.
Options. An options request is sent to the server to determine the request types
that the media server supports.
Describe. A describe request includes a URL and describes the replay data.
Setup. A setup request describes how to transport the bitstream.
Teardown. A teardown request ends the streaming media session.
Redirect. A redirect request tells the client to connect to a different media
server.
Play. The play request starts the specified media.
Pause. The pause request freezes the specified media until the user presses play.
Record. The record request starts a recording of the media.
Set_Parameter. Set_Parameter can test whether the client or server is active. It
also reveals the values of the presentation or stream guidelines that the Uniform
Resource Identifier (URI), which contains the characters that identify the
resource, provides.
Note:-
RTSP was published as rfc 2326 in 1998. Transmission of streaming data itself is
not a task of rtsp.it uses the real time transport protocol for media stream
delivery.But as a protocol we call it Rtsp.
Options: This request determines what other types of requests the media server will
accept.
Describe: A describe request identifies the URL and type of data.
Announce: The announce method describes the presentation when sent from the client
to the server and updates the description when sent from server to client.
Setup: Setup requests specify how a media stream must be transported before a play
request is sent.
Play: A play request starts the media transmission by telling the server to start
sending the data.
Pause: Pause requests temporarily halt the stream delivery.
Record: A record request initiates a media recording.
Teardown: This request terminates the session entirely and stops all media streams.
Redirect: Redirect requests inform the client that it must connect to another
server by providing a new URL for the client to issue requests to.
The first request must also inform the client about the available options through
the Options command. After that, a user can watch or turn off the stream. In
addition to the Options request, RTSP supports several control commands like play,
pause, and setup. RTSP leverages TCP to maintain an end-to-end and stable
connection without requiring local download or caching.
However, the protocol does not support content encryption or retransmission of lost
media packets and cannot stream directly to a browser over HTTP. This is because
RTSP is connected to a dedicated server for streaming and relies on RTP to transmit
real media. To circumvent this, you must use FFMPEG to convert the RTSP to an HLS
stream. This major limitation and its inability to scale led to a drop in RTSP
usage.
Audio Codecs: AAC, AAC-LC, HE-AAC+ v1 & v2, MP3, Speex, Opus, Vorbis
Video Codecs: H.265, H.264, VP9, VP8
Playback Compatibility: Not widely supported and rarely used for playback
Benefits: Low-latency
Drawbacks: Low quality of experience, low compatibility, and limited scalability
Latency: 2-second average
Variant Formats: The entire stack of real-time protocol (RTP) includes Real-Time
Control Protocol (RTCP) and RTSP, and it is often referred to as RTSP
The principles established in RTSP can be observed in the modern WebRTC standard.
RTSP can be compared to a TV remote control. It can be used to start, pause, stop,
etc. the video on the TV, the media server. The control is not via infrared but via
the Internet. Humanity has not yet learned to transmit the content itself through
the TV remote control (even if it is our years), but it is more than enough to
control it.
Wait, so RTSP only manages the content, but how does the content itself get
streamed?
In the transport layer, RTP (Real-Time Protocol) is used to transmit the stream in
real-time. The RTSP function is equivalent to the remote control of a streaming
media server. IP cameras can use both TCP and UDP to transmit streaming content.
However, it should be noted that UDP does not make any practical sense for this
task.
Both use plain text to send messages, and the RTSP protocol syntax is similar to
HTTP.
RTSP was originally designed to be compatible with previously written HTTP protocol
parsing code.
Differences:
RTSP save state. RTSP commands need to know what state they are currently in. In
other words, RTSP commands are always sent in order, with each next command coming
after the previous one. RTSP will not drop the connection, no matter what state it
is in. HTTP, on the other hand, does not save the state. After how the protocol
sends a command, the connection is broken and there is no dependency between the
commands.
Compared to RTSP, HTTP requests are sent by the client and the server responds.
With RTSP, both the client and the server can send requests, which means that RTSP
can be bidirectional.
As noted above, RTSP is conceptually similar to HTTP in function and was easily
compatible with existing HTTP networks when it was first developed.
We noted before that its authors described RTSP as a “network remote control” for
media servers. It was designed to control the streams without any need for local
download. When a video stream is started, a device using the protocol sends an RTSP
request to the media server that initiates the setup process.
RTSP also supports several control request operations (also known as “commands”)
such as play, pause, setup, etc. The initial request should also report back to the
client what options are available through the “OPTIONS” command. From there on out
a user can watch, cue up, or shut down the stream based on what parameters are
allowed. RTSP maintains an end-to-end connection with TCP and achieves high
transmission speed by turning on the proverbial data spigot through this stable
connection without requiring any local download or caching.
Because RTSP depends on a dedicated server for streaming and relies on RTP to
transmit actual media, the protocol does not support content encryption or the
retransmission of lost packets. And while RTSP is similar in syntax and operation
to HTTP, it also has differences and incompatibilities, and there was no way to
stream it in an easy, straightforward way from a web browser without adding
additional software. Due to these factors and the previously mentioned issue of
scaling to large broadcasts, it was gradually eclipsed by newer streaming
technology.
On today’s internet, a video streaming workflow that includes RTSP would most
likely use a media server to ingest streams transmitted through RTSP/RTP (per its
designation as a “contribution protocol” or “first-mile” technology) and then
utilize another means of delivery to repackage and send the content to be watched
on a wide range of devices.
WHAT IS REAL TIME STREAMING PROTOCOL(RTSP) AND HOW DOES IT RELATE TO SECURITY
CAMERAS?
The Real Time Streaming Protocol (RTSP) is a network control protocol designed for
use in entertainment and communications systems to control streaming media servers.
The protocol is used for establishing and controlling media sessions between end
points.
In short, RTSP is one way the cameras and recorders transfer information back and
forth. RTSP allows you to see the stream of the recorder or camera through an
application like VLC.
RTSP://UserName:Password@IPAddress:RtspPort/Streaming/channels/XXYY
I am going to briefly explain each part of the RTSP URL so we can better understand
the required items.
RTSP://admin:[email protected]:554/Streaming/channels/101
RTSP://admin:[email protected]:554/Streaming/channels/102
RTSP also supports several control request operations (also known as “commands”)
such as play, pause, setup, etc. (I will give you some example requests in the
following section.) The first request must also inform the client about the
available options via the “OPTIONS” command. After that, a user can watch, or turn
off the stream. RTSP maintains an end-to-end connection with TCP and achieves a
high throughput over this stable connection without requiring any local download or
caching.
The protocol does not support content encryption or retransmission of lost packets,
as RTSP is connected to a dedicated server for streaming and relies on RTP to
transmit real media. These limitations along with scaling problems led to a drop in
overall RTSP usage.
RTSP: A Snapshot
Audio Codecs: AAC, AAC-LC, HE-AAC+ v1 & v2, MP3, Speex, Opus, Vorbis
Video Codecs: H.265 (preview), H.264, VP9, VP8
Playback Compatibility: Not widely supported and rarely used for playback
(Quicktime Player and other RTSP/RTP-compliant players, VideoLAN VLC media player,
3Gpp-compatible mobile devices)
Benefits: Low-latency and ubiquitous in IP cameras
Drawbacks: Not optimized for quality of experience and scalability
Latency: 2 seconds
Variant Formats: RTSP as an umbrella term describes the entire stack of RTP, RTCP
(Real-Time Control Protocol), RTSPS (RTSP over SSL / Secure RTSP), and good-old
RTSP