In this article we are going to learn about RTSP

RTSP (Real Time Streaming Protocol) is a network control protocol designed to use in communication systems.

RTSP protocol provides a framework for real time streaming of audio and video

RTSP provides efficient management of audio and video streams with extreamly low latency, thus making it perfect for live streaming applications

What is RTSP

Real TIme Streaming Protocol. (RTSP) is a network control protocol to control streaming media servers.

It is perfect for streaming of real time data streams such as audio and video and other multimedia files over the internet

It is different from HTTP which is primarily designed for downloading content, RTSP is designed for live streaming

Historical context: How RTSP came to be

RTSP was developed by the Internet Engineering Task Force (IETF) in 1998. The RTSP protocol allows client devices (browsers or web apps) to control a media streaming server such as pause, play, stop the media stream

Thus it is the preferred protocol for applicagtions that require real time media delivery and interactivity

How RTSP works

Key features of RTSP

1. Session Control Capabilities

  • Play, Pause and Stop Commands: With RTSP the client devices cantrol the media streams similar to traditional cd / blu ray players. The interactivity is important for applications such as live broadcasts, movie rentals or any video streaming services
  • Seek Functionality: RTSP also allows for seek functionality which enables users to go to a specific point in a media stream

These features are dependent on the implementation of the RTSP protocol. The owner of the live broadcast or the on demand streaming service provider can control which features that want to give to the viewer watching the stream

2. Low latency

  • RTSP is designed from the ground up to provide low latency streaming, which is very important for live streams such as sporting events or other live events the users might want to stream

3. Efficient bandwidth utilization

  • RTSP is designed for efficient bandwidth utilization, that does not mean it provides bad quality. With RTSP you can stream 4k and even 8k video.
  • RTSP lets client request what data they want, if a client wants just the audio stream RTSP does not push the video to that client thus saving bandwidth.

4. Transport Agnostic

  • RTSP is transport agnostic meaning it can be used with TCP, UDP or any other protocol, although UDP is preferred.  
  • Thus RTSP has the flexibility to be used with different network conditions and requirements

5. Scalability

  • RTSP supports scalable streaming solutions. It does not matter if you are running small deplyments or large scale deplyments
  • RTSP can handle multiple media streams

6. Support for different media types

  • RTSP can handle different types of media including audio, video and text.

7. Interoperability

  • RTSP works with various codecs and media formats, ensuring broad compatibility across different browsers and devices.
  • This helps with reaching a wider audience which is important when you are broadcasting video.

8. Extensibility

  • The Protocol is designed to be extensiable, which means that it allows for the addition of new features and improvements over time
  • This means that the protocol is very much alive and in development and is able to cope with future streaming advancements and technologies

9. Control over Network elements

  • RTSP can interact with networking elements such as NAT and firewalls, which inadvertantly come in the ways to communicating with devices on the internet.

10. Security features

  • RTSP has security features built in, it has end to end encryption and auth mechanisms
  • Because of the security features the streams can only be accessed by authorized viewers and audiences

Metered.ca: The Global TURN Server solution

Metered TURN servers

Metered TURN servers

  1. API: TURN server management with powerful API. You can do things like Add/ Remove credentials via the API, Retrieve Per User / Credentials and User metrics via the API, Enable/ Disable credentials via the API, Retrive Usage data by date via the API.
  2. Global Geo-Location targeting: Automatically directs traffic to the nearest servers, for lowest possible latency and highest quality performance. less than 50 ms latency anywhere around the world
  3. Servers in 12 Regions of the world: Toronto, Miami, San Francisco, Amsterdam, London, Frankfurt, Bangalore, Singapore,Sydney, Seoul
  4. Low Latency: less than 50 ms latency, anywhere across the world.
  5. Cost-Effective: pay-as-you-go pricing with bandwidth and volume discounts available.
  6. Easy Administration: Get usage logs, emails when accounts reach threshold limits, billing records and email and phone support.
  7. Standards Compliant: Conforms to RFCs 5389, 5769, 5780, 5766, 6062, 6156, 5245, 5768, 6336, 6544, 5928 over UDP, TCP, TLS, and DTLS.
  8. Multi‑Tenancy: Create multiple credentials and separate the usage by customer, or different apps. Get Usage logs, billing records and threshold alerts.
  9. Enterprise Reliability: 99.999% Uptime with SLA.
  10. Enterprise Scale: With no limit on concurrent traffic or total traffic. Metered TURN Servers provide Enterprise Scalability
  11. 5 GB/mo Free: Get 5 GB every month free TURN server usage with the Free Plan
  12. Runs on port 80 and 443
  13. Support TURNS + SSL to allow connections through deep packet inspection firewalls.
  14. Support STUN
  15. Supports both TCP and UDP
  16. Free Unlimited STUN

Key Components of RTSP

Real Time Streaming Protocol (RTSP) is protocol designed for streaming media over the internet

Let us learn some of the important componenets and their roles in the streaming, here is a detailed explanation of the components of RTSP

1. RTSP Server

  • Session management: The RTSP server manages the streaming session, It establishes, maintains and terminates the session as required. It also keeps track of the state of on going session like playing, paused and stopped
  • Media Streaming: The server sends the media stream to the client devices.
  • Command Processing: The server processes RTSP commands requests like PLAY, PAUSE, STOP etc from client devices. This enable the client devices to control video streaming

2. RTSP Client

The RTSP client is any device or app that connects to the RTSP server and requests and controls the media streams

  • Session Control: The client initiates a media streaming session by sending a request to the RTSP server to initiate a streaming session. It can also pause and stop the session by sending appropriate commands
  • Media Playback: The client recieves the media stream and decodes media streams for playback on the device. The client device can by anything, a software application like VLC, a web browser like chrome, a hardware device such as a prime stick etc.
  • User Interface: The client has a built in user interface for the user to interact with the media including playing the media or stoppping the media playback

3. RTSP Commands

RTSP defines several commands to control the media streams on the server. The commands include

  • SETUP: Starts a session and allocates resources for the stream. It also decides of the transport mechanism to be used. For example RTP/UDP.
  • PLAY: Starts the playback of a media stream from a specified point in time.
  • PAUSE: Temprorily stop the playback of the media stream with releasing resources and remembers the point in time where the media stream is stoppped so that it can resume the playback from that point onwards.
  • TEARDOWN: Terminates the session and releases the resources that were associated with the session.
  • DESCRIBE: Requests a description of the media streams, this is typically in the SDP that is Session Description Protocol format. Detailing the available media streams and their formats
  • OPTIONS: This function quries the media server for available methods and features that can be availed
  • ANNOUNCE: This is used by the streaming server to notify the clients about changes in media streaming formats or session status.

4. Media Transport protocols

as we have already seen above the RTSP itself does not transport hte media streams but instead relies on other underlying protocols to transport the streams. These protocols include

  • RTP ( Real Time Transport Protocol):

The RTP is the primary protocol that is used to transport media streams over the internet in real time. It provides mechanisms that can be used for time stamping, sequence numbering and ensuring the proper synchronization of packet order

  • RTCP (RTP Control Protocol):

This protocol the RTCP protocol basically works alongside the RTP protocol in order to provide feedback on the quality of the media stream that is being delivered, with metrics such as packet loss and jitter. It helps in maintaining the quality of media streams.

5. Session Description Protocol (SDP)

SDP is used to describe the multimedia sessions in a standardized format. This is it provides detailed info on the media streams that are available for a streaming session, this includes information like

  • Media Types: The type of media that is available for streaming such as audio video etc
  • Codec Information: Codecs are used for media encoding, popular one include H.264, mp4 and others for video and mp3 or AAC for audio. This codec information is provided by the SDP protocol
  • Network Information: Network information including the IP addresses, domain names, port numbers and other such information
  • Timing Information: The start and end time for the media session

6. Transport layer

  • TCP (Transsmission Control Protocol): the TCP provides reliable, connection oriented delivery of RTSP messages. The TCP protocol ensures that the Commands from the devices and the responses from the server are delivered in order
  • UDP (User Datagram Protocol: UDP provides low overhead and low latency delivery. It is preferred for real time media but one drawback is that it does not gaurantee delivery and order of data
  • HTTP Tunneling:  RTSP can be tunnelled through HTTP to traverse firewalls and NAT devices ensuring compatibility and delivery in extremly restrictive networks

7. Control and Feedback Mechanism

RTSP has many security mechamisms built in place to ensure secure streaming is secure

  • Session Identifiers: There are unique identifies for each streaming session, allowing you to accurately measure and manage multiple sessions at once.
  • State Management: RTSP saves the information regarding the current state of the streaming session like playing, paused stopped etc.
  • RTCP Reports: Server and the client devices contineously exchange information regarding packet loss, jitter and other quality metrics to facilitate streaming and error correction

8. Security Components

RTSP has basic security mechanisms in place to secure the streams from un authorized access

  • Authentication: RTSP has built in mechanisms to identify and verify the indentity of the client that is asking for the media streams.
  • Encryption: RTSP uses protocols loke SRTP (Secure Real Time Transport Protocol) to encrypt media streams, thus preventing unauthorized access and download of media streams.
  • Access Control: With RTSP you can create access control policies to restrict who can access the media streams

RTSP Vs Other Streaming Protocols

Comparison with HTTP Live Streaming (HLS), Dynamic Adaptive Streaming over HTTP (DASH), and Real-Time Messaging Protocol (RTMP)

RTSP VS HLS VS DASH VS RTMP

1. RTSP (Real Time Streaming Protocol)

  • Latency: Low Latency, best suited for real time streaming applications
  • Control: Provides client devices control over the streaming media such as play, pause, stop etc
  • Transport: Can use a wide variety of protocols for transport but generally RTP/RTCP protocols are used
  • Interactivity: Highly interactive, this is due to ultra low latency and real time client control over streaming media

2. HLS  (HTTP Live Streaming)

  • Latency: Higher latency than RTSP, this is usually 10 to 30 seconds
  • Control: With HLS there is limited control, as this protocol is primarily designed with continuous playback in mind
  • Transport: Uses HTTP for transport, which is universally supported but it is heavy and can introduce latecy and performance bottlenecks
  • Interactivity:  Limited interactivity as the stream cannot be controlled by users. The stream can be controlled by the server and the admin

3. DASH (Dynamic Adaptive Streaming over HTTP)

  • Latency: It is similar to HLS but with higher latency as compared to HLS
  • Control: Does provide more control over the media streams but not as interactive as RTSP
  • Transport: Uses HTTP for transport, but with advanced adaptive bit rate technology that adapts to changes network conditions
  • Interactivity: There is moderate interactivity, but it is much suitable for both live and on demand streaming with automatic adaptability to changing network conditions

4. RTMP (Real Time Messaging Protocol)

  • Latency: Low latency, it is similar to RTSP
  • Control: This provides a good control over media streams.
  • Transport: RTMP typically uses TCP, which can be used for straming video and data over the internet
  • Interactivity: Highly interactive, can be used for live streaming applications

Here are some of our other articles you might be interested in