RTSP [3] is a multimedia playback control protocol used to control the playback of real-time data downloaded from the Internet. For example: pause/continue, backward, and forward. Therefore, RTSP is also called "Internet video recorder Remote Control Protocol ".
1.1. RTSP Protocol Introduction
To implement the RTSP control function, not only the protocol, but also the media player and Media Server ). The relationship between media servers and media players is the relationship between servers and customers.
The biggest difference between a media server and a common web server is that a Media Server supports stream audio and video transmission, therefore, the media player on the client can download and play the video (a short program needs to be cached first ). However, when downloading a multimedia program from a common web server, the entire file is downloaded and then played.
Figure 1 Relationship Between RTSP and RTP and RTCP
RTSP only enables the media player to control the transmission of Multimedia Streams. Therefore, RTSP is also called the out-of-band protocol, while Multimedia Streams are transmitted in the band using RTP.
1.2. RTSP message structure
RTSP has two types of packets: Request Message and Response Message. Request Message refers to the request message sent from the customer to the server, and the Response Message refers to the response from the server to the customer.
Because RTSP is text-oriented, every field in the message is an ASCII string, so the length of each field is uncertain.
The RTSP packet consists of the start line, first line, and entity. In the request message, the start line is the request line, as shown in structure 2 of the RTSP request message.
The client reminds the server to establish a session and determine the transmission mode.
Teardown
The client initiates a close request
Play
The client sends a playback request.
The starting line of the response packet is the status line, as shown in figure 3.
Figure 3 structure of RTSP Response Message
1.3. RTSP interaction process
C Indicates the RTSP client, and s indicates the RTSP server.
① C-> S: Option request // ask s which methods are available
S-> C: Option response // all available methods provided in the response information
② C-> S: DESCRIBE request // obtain the media initialization description provided by S.
S-> C: Describe response // s response media initialization description, mainly SDP
③ C-> S: SETUP Request // sets the session attributes and transmission mode to remind s to establish a session
S-> C: setup response // s creates a session and returns the session identifier and session-related information.
④ C-> S: Play request // C request playback
S-> C: Play response // s Response Request Information
Figure 2 Structure of the RTSP request message
Methods for RTSP request packets include options, describe, setup, teardown, play, pause, get_parameter, and set_parameter. Common methods and functions of RTSP request packets are shown in table 1.
Table 1 common methods and functions of RTSP request packets
Method
Function
Options
Obtain available methods provided by the server
Describe
Obtains the Session Description.
Setup
S-> C: Send streaming media data
⑤ C-> S: teardown request // C request to close the session
S-> C: teardown response // s response request
The above process is a standard RTSP process, of which steps 1 and 2 are required.