TheReal-Time Streaming Protocol (RTSP) is anapplication-level networkprotocol designed formultiplexing andpacketizingmultimedia transport streams (such asinteractive media,video andaudio) over a suitabletransport protocol. RTSP is used in entertainment and communications systems to controlstreaming mediaservers. The protocol is used for establishing and controlling media sessions between endpoints. Clients of media servers issue commands such asplay,record andpause, to facilitate real-time control of the media streaming from the server to a client (video on demand) or from a client to the server (voice recording).
RTSP was developed byRealNetworks,Netscape[1] andColumbia University.[2] The first draft was submitted to IETF in October 1996 byNetscape andProgressive Networks, after whichHenning Schulzrinne fromColumbia University submitted "RTSP՚" ("RTSP prime") in December 1996.[3][4] The two drafts were merged for standardization by the Multiparty Multimedia Session Control Working Group (MMUSIC WG) of theInternet Engineering Task Force (IETF) and further drafts were published by the working group.[5][6] TheProposed Standard for RTSP was published as RFC 2326 in 1998.[7] RTSP 2.0 published as RFC 7826 in 2016 as a replacement of RTSP 1.0. RTSP 2.0 is based on RTSP 1.0 but is not backwards compatible other than in the basic version negotiation mechanism, and remains a Proposed Standard.[8]
The transmission of streaming data itself is not a task of RTSP. Most RTSP servers use theReal-time Transport Protocol (RTP) in conjunction withReal-time Control Protocol (RTCP) for media stream delivery. However, some vendors implement proprietary transport protocols. The RTSP server software fromRealNetworks, for example, also used RealNetworks' proprietaryReal Data Transport (RDT).
While similar in some ways toHTTP, RTSP defines control sequences useful in controlling multimedia playback. While HTTP isstateless, RTSP has a state; an identifier is used when needed to track concurrent sessions. Like HTTP, RTSP uses TCP to maintain an end-to-end connection and, while most RTSP control messages are sent by the client to the server, some commands travel in the other direction (i.e. from server to client).
Presented here are the basic RTSP requests. Some typicalHTTP requests, like the OPTIONS request, are also available. The default transport layerport number is 554[7] for bothTCP andUDP, the latter being rarely used for the control requests.
A DESCRIBE request includes an RTSPURL (rtsp://...), and the type of reply data that can be handled. This reply includes the presentation description, typically inSession Description Protocol (SDP) format. Among other things, the presentation description lists the media streams controlled with the aggregate URL. In the typical case, there is one media stream each for audio and video streams. The media stream URLs are either obtained directly from the SDP control fields or they are obtained by appending the SDP control field to the aggregate URL.
A SETUP request specifies how a single media stream must be transported. This must be done before a PLAY request is sent. The request contains the media stream URL and a transport specifier. This specifier typically includes a local port for receivingRTP data (audio or video), and another forRTCP data (meta information). The server reply usually confirms the chosen parameters, and fills in the missing parts, such as the server's chosen ports. Each media stream must be configured using SETUP before an aggregate play request may be sent.
A PLAY request will cause one or all media streams to be played. Play requests can be stacked by sending multiple PLAY requests. The URL may be the aggregate URL (to play all media streams), or a single media stream URL (to play only that stream). A range can be specified. If no range is specified, the stream is played from the beginning and plays to the end, or, if the stream is paused, it is resumed at the point it was paused.
C->S: PLAY rtsp://example.com/media.mp4 RTSP/1.0 CSeq: 4 Range: npt=5-20 Session: 12345678S->C: RTSP/1.0 200 OK CSeq: 4 Session: 12345678 RTP-Info: url=rtsp://example.com/media.mp4/streamid=0;seq=9810092;rtptime=3450012
A PAUSE request temporarily halts one or all media streams, so it can later be resumed with a PLAY request. The request contains an aggregate or media stream URL. A range parameter on a PAUSE request specifies when to pause. When the range parameter is omitted, the pause occurs immediately and indefinitely.
This method initiates recording a range of media data according to the presentation description. The timestamp reflects the start and end time(UTC). If no time range is given, use the start or end time provided in the presentation description. If the session has already started, commence recording immediately. The server decides whether to store the recorded data under the request URI or another URI. If the server does not use the request URI, the response should be 201 and contain an entity which describes the states of the request and refers to the new resource, and a Location header.
C->S: RECORD rtsp://example.com/media.mp4 RTSP/1.0 CSeq: 6 Session: 12345678S->C: RTSP/1.0 200 OK CSeq: 6 Session: 12345678
When sent from client to server, ANNOUNCE posts the description of a presentation or media object identified by the request URL to a server. When sent from server to client, ANNOUNCE updates the session description in real time. If a new media stream is added to a presentation (e.g., during a live presentation), the whole presentation description should be sent again, rather than just the additional components, so that components can be deleted.
The GET_PARAMETER request retrieves the value of a parameter of a presentation or stream specified in the URI. The content of the reply and response is left to the implementation. GET_PARAMETER with no entity body may be used to test client or server liveness ("ping").
A REDIRECT request informs the client that it must connect to another server location. It contains the mandatory header Location, which indicates that the client should issue requests for that URL. It may contain the parameter Range, which indicates when the redirection takes effect. If the client wants to continue to send or receive media for this URI, the client MUST issue a TEARDOWN request for the current session and a SETUP for the new session at the designated host.
Certain firewall designs and other circumstances may force a server to interleave RTSP methods and stream data. This interleaving should generally be avoided unless necessary since it complicates client and server operation and imposes additional overhead. Interleaved binary data SHOULD only be used if RTSP is carried over TCP. Stream data such as RTP packets is encapsulated by an ASCII dollar sign (24 hexadecimal), followed by a one-byte channel identifier, followed by the length of the encapsulated binary data as a binary, two-byte integer in network byte order. The stream data follows immediately afterwards, without a CRLF, but including the upper-layer protocol headers. Each $ block contains exactly one upper-layer protocol data unit, e.g., one RTP packet.
RTSP over HTTP was defined by Apple in 1999[9] and[1]. It interleaves the RTP Video and Audio data into the RTSP Command Connection (as defined in RFC2326), and then sends the RTSP Command Connection via a pair of HTTP connections, one is a long running GET connection and the other is a long running POST connection.
This method is also used in theONVIF IP Camera standard and can be combined with HTTPS for secure and encrypted video and audio.
There are several different methods for encrypting RTSP command messages and the RTP Video and Audio data.
RTSP 2.0 (RFC7826) defines several methods for encryption and introduces a new rtsps:// URL and many of these have been incorporated into RFC2326 RTSP 1.0 Clients and Servers.
RTSPS URL (using the rtsps:// URL) - This method uses aTLS Socket (default of Port 322) to establish an encrypted connection between the RTSP client and the RTSP Server. Video and Audio can then sent in one of two ways
TCP Video/Audio - The RTP Video and Audio is sent interleaved with the RTSP Commands over the already encryptedTLS Connection
UDP and Multicast-UDP Video/Audio - the RTP Video and Audio is encrypted using theSecure RTP (SRTP) protocol and sent in parallel to the RTSPSTLS connection
RTSP over HTTPS - this method interleaves the RTP Video and Audio data into the RTSP Command Connection (as defined in RFC2326) and then sends the RTSP Command Connection via a pair of encrypted HTTPS connections. It uses Port 443 by default.
IANA have reserved the rtsps:// URL prefix and Port 322 for RTSPS.[10] As of September 2024, RTSP over HTTPS has been implemented in several ONVIF IP Cameras and RTSPS (using the rtsps:// URL) has been implemented by Axis and Bosch CCTV Cameras,[11]FFmpeg,GStreamer, MediaMTX,[12] Ant Media Server[13] and SharpRTSP.[14]
Ant Media Server: The Community version[16] version supports pulling from RTSP/S sources and can live stream using HLS or record in MP4.The Enterprise version can convert RTSP to WebRTC with approximately 200-500ms end-to-end latency.
Darwin Streaming Server: Open-sourced version of QuickTime Streaming Server maintained by Apple.
^Santos, Hugo; Cruz, Rui Santos; Nunes, Mário Serafim (2010), "Rate Adaptation Techniques for WebTV",User Centric Media, Lecture Notes of the Institute for Computer Sciences, Social Informatics and Telecommunications Engineering, vol. 40, pp. 161–168,doi:10.1007/978-3-642-12630-7_19,ISBN978-3-642-12629-1