RTP over RTSP(TCP)(一)
https://blog.youkuaiyun.com/onelight1997/article/details/7325345
RTSP - RTP over TCP
http://www.cnblogs.com/lidabo/p/4483497.html
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包,总长度与上面的数据长度相同
所以一般以RTP_over_TCP传输方式下的RTP H264码流数据包应该是
24 00 XX XX 80 e0 X1 X1 X2 X2 X2 X2 X3 X3 X3 X3 X4….
24 00 XX XX很好解释,是TCP交织头,XX XX表示数据长度;
80 e0 是二进制 1000 0000 1110 0000,具体需要查看这篇文章中关于RTP头的解释https://blog.youkuaiyun.com/chen495810242/article/details/39207305
110 0000是payload类型,是H264的类型,96.
X1是Sequence number,X2是Timestamp,X3是Synchronization Source identifier,即SSRC,X4及以后都是Payload了