RTSP - RTP over TCP
To use TCP communication, you need to request TCP connection during RTSP SETUP. You have to sent SETUP command with
要使用TCP连接,RTSP客户端需要在SETUP阶段请求TCP连接。SETUP命令中应该包括如下格式的Transport:
Transport: RTP/AVP/TCP;interleaved=0-1
This will tell 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
上述Transport将告诉服务端使用TCP协议发送媒体数据,并且使用信道 0 和 1 对流数据以及控制信息进行交织。详细说来,使用偶数信道作为数据
number and control channel is odd (data_ch_num + 1). So, if you data channel is 0, your control channel will be 0 + 1 = 1.
传输信道,使用奇数信道作为控制信道(数据信道 + 1)。所以,如果你设定数据信道为 0 ,那控制信道应该是 0 + 1 = 1。
Below is an example of TCP SETUP
RTP Data
After the setup, RTP data will be sent through the TCP socket that is used for RTSP commands. The RTP data will be encapsulate in the following format
SETUP之后,RTP数据将通过用来发送RTSP命令的TCP Socket进行发送。RTP数据将以如下格式进行封装:
| magic number | channel number | embedded data length | data |
magic number - 1 byte value of hex 0x24
RTP数据标识符,"$"
channel number - 1 byte value to denote the channel
信道数字 - 1个字节,用来指示信道
embedded data length - 2 bytes to denote the embedded data length
数据长度 - 2个字节,用来指示插入数据长度
data - data packet, ie RTP packet, with the total length of the embedded data length
数据 - 数据包,比如说RTP包,总长度与上面的数据长度相同
一个奔跑的程序员