Normally, RTSP provide streaming over UDP. By nature, UDP are a better choice as it provides robust streaming capability for media. However, it's unlikely to use UDP for streaming over the Internet.
Typically, RTSP provides a UDP way to send RTP streams. Of course, UDP is often a better choice when sending streaming media. However, it is not possible to send a stream using UDP on the Internet. Some issues with UDP is the following are some problems when using UDP: 1. RTSP/RTP over UDP requires many UDP ports to is opened (each media stream requires 2 UDP port for data and control). 1. The RTSP/RTP on the UDP protocol needs to open many UDP ports (2 UDP ports per streaming media, one for receiving data, one for receiving control information) and 2. Point 1 was a real problem as routers in the Internet might not open these ports.2. When the routers on the Internet do not have these ports on, the 1th above will be problematic; 3. It is the normal for intermediate Internet router to filter and ignore UDP packets.3. The intermediate network router can easily filter or ignore UDP packets; 4. UDP is unreliable. Media packets May is lost when travelling along the Internet
4. UDP is an unreliable transport protocol, and media packets are exposed to packet loss when they are transmitted over the Internet. RTSP/RTP over TCP could resolve this issue. But if we host RTSP/RTP on the TCP transport protocol, these issues will be resolved. 1. RTSP/RTP would communicate via 1 port for command and data. That's the RTSP Port.1. RTSP/RTP control commands and data are interacted with via a port, the port of RTSP (554 by default). 2. TCP provide reliable streaming2. The TCP protocol provides reliable stream transport. 3. It's more likely, the intermediate Internet router allow these TCP packets to go through.3. TCP packets are more likely to penetrate intermediate network routers. Using RTSP/RTP over TCP come with a price. However, it takes more effort to host the RTSP/RTP using the TCP transport protocol. 1. It complicated the packetization and depacketization process due to binary interleave.1. Because of the two-dollar interleaving, the process of RTP packets and packets is made more complex. 2. TCP is reliable but has overhead. It may cause delay in real time media.2. TCP is a reliable transport protocol, but it is because of this that it causes delays in live streaming media. So, now I'll talk about how to setup RTSP/RTP over TCP Next let's look at how TCP is used to host RTSP/RTP.
RTSP/RTP over TCP
TCP bearer RTSP/RTPWhen you use RTSP/RTP over TCP, all command and media data would be sent through the RTSP port, normally, port 554. Also, when using the TCP protocol to host RTSP/RTP, all command and media data will be sent via the RTSP port, usually 554. At the same time, the data will go through a two-yuan interleaving format before the RTSP/RTP over TCP can be sent, the sent via binary interleave format. Below will describe the essential for using RTSP/RTP over TCP Next we'll describe the main elements that use TCP to host RTSP/RTP:
SETUPTo the use of TCP communication, you need to request TCP connection during RTSP SETUP. The RTSP client needs to request a TCP connection in the setup phase for the sent Setup command with which you want to use a TCP connection. The Setup command should include transport in the following format:
transport:rtp/avp/tcp;interleaved=0-1
This is the server to send media data with TCP and interleave the data in channel 0 and 1. Given in the specification, data channel is even the above transport will tell the server to send media data using the TCP protocol, and use channel 0 and 1 convection data and control information for interleaving. In detail, an even channel is used as the data number and control channel is odd (Data_ch_num + 1). So, if you are data channel is 0, your control channel would be 0 + 1 = 1. Transmit channel, using odd channel as control channel (data channel + 1). So, if you set the data channel to 0, that control channel should be 0 + 1 = 1. Below is an example of TCP SETUP
RTP DataAfter the setup, RTP data would be sent through the TCP socket, which is used for RTSP commands. After the RTP data will is encapsulate in the following formatsetup, the RTP is sent via the TCP socket used to send the RTSP command. The RTP data will be encapsulated in the following format:
| magic number | channel number | Embedded data length | data |
Magic Number-1 byte value of hex 0X24RTP data identifier, "$" channel number-1 byte value to denote the channel number-1 bytes, used to indicate the channel EM Bedded data length-2 bytes to denote the embedded date length-2 bytes to indicate the length of the inserted data Data-data packet, IE RTP Packet, WI Th the total length of the embedded data-packets, such as RTP packets, have the same overall lengths as the above data below is a full example of the communication Exchanged the following is a complete example of an interactive process: Also, as RTSP is a application protocol, it has no means to control how TCP timeout the connection. Thus, during the RTSP SETUP, a Session is however, since RTSP is an application protocol, there is no way to control the timeout for TCP connections. Therefore, in the setup phase of RTSP, a new session is used to identify the connected stream. Given to identify the connected stream
Session = "Session" ":" Session-id [";"] "Timeout" "=" delta-seconds]
If session is given, each subsequence RTSP command must being sent with the Session so, the server can identify the Strea M. Also, please note once the session is created, each subsequent RTSP command must be prefixed with session_id, otherwise the server will not be able to identify the stream that the command corresponds to. In addition, the value of "timeout" is optional as that timeout is an optional value. The default value for a timeout is seconds. So, it's advisable to send a RTSP command to the server everythe. The default value for "Timeout" is 60 seconds. Therefore, it is recommended to send an RTSP command to the server every 60 seconds to keep the TCP connection alive.
Second to keep the TCP connection alive. Read RFC 2326 Section 10.12 Embedded (interleaved) binary data for more DETAILSRFC 2326 in section 10.12 describes the details of inserting binaries.
RTSP-RTP over TCP