Summary in a simple sentence:
RTSP initiates/terminates streaming media, RTP transmits streaming media data, and RTCP controls and synchronizes RTP.
The reason for this is that the CTC standard does not require RTCP.
In the standard RTSPCodeDoes not see the relevant part. In the code of the private RTSP, the control and synchronization functions are extended and defined in the RTP Header. .
In addition, rfc3550 can be seen as an rfc1889 upgrade document. You can only view rfc3550.
- RTP: Real-Time Transport Protocol)
- RTP/RTCP is the actual data transmission protocol.
- RTP transmits audio/video data. If it is play, the server sends the data to the client. If it is record, the client can send the data to the server.
- The whole RTP protocol is composed of two closely related parts: RTP data protocol and RTP Control Protocol (RTCP)
- RTSP: Real Time Streaming Protocol (RTSP)
- RTSP requests mainly include describe, setup, play, pause, teardown, options, etc. As the name suggests, you can understand the role of dialog and control.
- During the RTSP conversation, setup can determine the port used by RTP/RTCP, and play/pause/teardown can start or stop sending RTP, etc.
- RTCP:
- RTP/RTCP is the actual data transmission protocol.
- RTCP includes Sender report and javaser report for audio/video synchronization and other purposes. It is a control protocol.
The following is an overview of each protocol:
I. RTP data protocol
The RTP data protocol is used to package streaming media data and implement real-time transmission of media streams. Each RTP data packet consists of header and payload, the first 12 bytes in the header are fixed, while the load can be audio or video data. The Header Format of the RTP datagram is 1:
The important domains and their meanings are as follows:
CSRC notation (CC): indicates the number of CSRC identifiers. The CSRC Mark follows the fixed RTP Header to indicate the source of the RTP datagram. the RTP protocol allows multiple data sources in the same session, which can be combined into a data source through the RTP mixer. For example, a CSRC list can be generated to represent a teleconference, which combines the voice data of all speakers into a RTP data source through an RTP mixer.
Load type (PT): indicates the RTP load format, including the encoding usedAlgorithmSampling frequency and bearer channel. For example, type 2 indicates that the RTP data packet carries voice data encoded using the ITU g.721 algorithm. The sampling frequency is 8000Hz and the single channel is used.
Serial number: used to provide a method for the receiver to detect data loss, but how to handle the lost data is the applicationProgramThe RTP protocol is not responsible for data retransmission.
Timestamp: records the sampling time of the first byte in the load. the receiver can timestamp to determine whether data arrival is affected by latency jitter, but how to compensate for latency jitter is the application's own business.
It is not difficult to see from the RTP datagram format that it contains the type, format, serial number, timestamp, and whether there is additional data, these provide a foundation for Real-Time Streaming Media transmission. The RTP protocol is designed to provide end-to-end transmission services for real-time data (such as interactive audio and video ).No connection concept in RTPIt can be built on the underlying connection-oriented or non-connection-oriented transmission protocol. RTP does not depend on the special network address format, but only needs the underlying transmission protocol to support frame (framing) and segment (segmentation ).RTP itself does not provide any reliability mechanismThese must be ensured by the transmission protocol or application itself. In typical application scenarios, RTP is generally implemented as part of an application over the transport protocol, as shown in Figure 2:
Ii. RTCP Control Protocol
The RTCP control protocol must be used together with the RTP data protocol. When an application starts an RTP session, both ports are used for RTP and RTCP respectively.RTP itself does not provide a reliable guarantee for data packets transmitted in sequence, nor does it provide traffic control and congestion control, which are completed by RTCP.. Generally, RTCP uses the same distribution mechanism as RTP to periodically send control information to all session members. The application receives the data and obtains relevant information of the session participants, and network conditions, packet loss probability and other feedback information, so as to control service quality or diagnose network conditions.
The functions of the RTCP protocol are implemented through different RTCP datagram, mainly including the following types:
SR: The sending end report. The so-called sending end refers to the application or terminal that sends the RTP datagram, And the sending end can also be the receiving end.
Rr: the receiving end report. The so-called receiving end refers to an application or terminal that only receives but does not send RTP datagram.
Sdes: source description. It serves as a carrier of the identity information of a session Member, such as the user name, email address, and phone number. It also provides the ability to send session control information to session members.
Bye: indicates that one or more sources are no longer valid, that is, other members in the notification session will quit the session.
APP: defined by the application itself, solves the problem of RTCP scalability, and provides great flexibility for Protocol Implementers.
RTCP datagram carries the necessary information of service quality monitoring, which can dynamically adjust service quality and effectively control network congestion. Because RTCP datagram adopts the multicast mode, all members in the session can use the control information returned by the RTCP datagram to understand the current situation of other participants.
In a typical application, the application that sends a media stream periodically generates the sender Report SR. The RTCP datagram contains synchronization information between different media streams, as well as the sent datagram and byte count, the receiving end can estimate the actual data transmission rate based on the information. On the other hand, the receiving end sends the RR report to all known senders. The RTCP datagram contains the maximum serial number of the received datagram, the number of lost datagram, latency jitter, timestamp, and other important information, based on this information, the sender application can estimate the round-trip latency and dynamically adjust the transmission rate based on the datagram loss probability and latency Jitter to improve network congestion, or, you can smoothly adjust the service quality of your application based on the network conditions.
Iii. RTSP real-time stream Protocol
As an application layer protocol, RTSP provides a scalable framework, which makes real-time streaming media data controlled and On-Demand Streaming possible. In general, RTSP is a Streaming Media Protocol mainly used to control data transmission with real-time characteristics. However, RTSP does not transmit data, but must rely on some services provided by the lower-layer transmission protocol.RTSP can provide streaming media operations such as playing, pausing, and fast forward. It defines specific control messages, operation methods, status codes, and so on, the interaction with RTP is also described (rfc2326).
RTSP has made many references to the HTTP/1.1 protocol during the preparation, and even many descriptions are exactly the same as HTTP/1.1.. RTSP uses similar syntaxes and operations as HTTP/1.1 to be compatible with the existing web infrastructure, most HTTP/1.1 extensions can be directly introduced into RTSP.
A media stream set controlled by RTSP can be defined by the presentation description. The so-called representation refers to the set of one or more media streams provided by the Streaming Media Server to the client, the description contains information about each media stream, such as the data encoding/decoding algorithm, network address, and media stream content.
Although the RTSP server also uses identifiers to differentiate each session, the RTSP connection is not bound to a transport layer connection (such as TCP ), that is to say, during the entire RTSP connection, the RTSP user can open or close multiple reliable transmission connections to the RTSP server to send an RTSP request. In addition, RTSP connections can also be based on connectionless transmission protocols (such as UDP ).
The RTSP protocol currently supports the following operations:
Media retrieval: allows users to submit a description to the Media Server through HTTP or other methods. For example, if the description is multicast, the description includes the multicast address and port number used for the media stream. If the description is unicast, to ensure security, only the target address is provided in the description.
Invite to join: The Media Server can be invited to an ongoing meeting, play back the media in the presentation, or record all media or its subsets in the presentation, which is very suitable for distributed teaching.
Add media: notifies users of the available media streams they have joined. This is especially useful for on-site lectures. Similar to HTTP/1.1, RTSP requests can also be handled by proxy, channel, or cache.