2016-09 点击次数:
Normally, RTSP provide streaming over UDP. By nature, UDP is a better choice as it provides robust streaming capability for media. However, it is unlikely to use UDP for streaming over the Internet.
通常来说,RTSP提供UDP方式发送RTP流。当然,发送流媒体时,UDP往往是更好的选择。但是,在互联网上使用UDP方式发送流是不可能的。 Some issues with UDP are 下面是使用UDP时的一些问题: 1. RTSP/RTP over UDP requires many UDP ports to be opened (each media stream requires 2 UDP port for data and control). 1. UDP协议上的RTSP/RTP需要打开许多UDP端口(每一路流媒体都需要2个UDP端口,一个用于接收数据,一个用于接收控制信息); 2. Point 1 is a real problem as routers in the Internet may not open these ports. 2.当因特网上的路由器没有打开这些端口的时候,上述第一点将会存在问题; 3. It is normal for intermediate Internet router to filter and ignore UDP packets. 3. 中间网络路由器很容易就过滤或者忽略掉UDP数据包; 4. UDP is unreliable. Media packets may be lost when travelling along the InternetTransport: RTP/AVP/TCP;interleaved=0-1This 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
| 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包,总长度与上面的数据长度相同 Below is a full example of the communication exchanged 下面是交互过程的一个完整示例:
Session = "Session" ":" session-id [ ";" "timeout" "=" delta-seconds ]If Session is given, each subsequence RTSP command must be sent with the session so that the server can identify the stream. Also, please note 一旦会话(SESSION)被创建,接下来的每一个RTSP命令都必须加上session_id,否则服务端无法识别命令对应的流。另外,"timeout"的值是可选 that timeout is an optional value. The default value for timeout is 60 seconds. So, it is advisable to send a RTSP command to the server every 的。"timeout"的默认值是60秒。所以,建议每隔60秒向服务端发送一个RTSP命令以保持TCP连接的存活。