使用RTP over RTSP(TCP)

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.


Some issues with UDP are

1. RTSP/RTP over UDP requires many UDP ports to be opened (each media stream requires 2 UDP port for data and control).
2. Point 1 is a real problem as routers in the Internet may not open these ports.
3. It is normal for intermediate Internet router to filter and ignore UDP packets.
4. UDP is unreliable. Media packets may be lost when travelling along the Internet

RTSP/RTP over TCP may resolve this issue.

1. RTSP/RTP will communicate via 1 port for command and data. That is the RTSP port.
2. TCP provide reliable streaming
3. It is more likely that the intermediate Internet router allow these TCP packets to go through.

Using RTSP/RTP over TCP come with a price.

1. It complicated the packetization and depacketization process due to binary interleave.
2. TCP is reliable but have overhead. It may cause delay in real time media.

So, now I will talk about how to setup RTSP/RTP over TCP

RTSP/RTP over TCP

When you use RTSP/RTP over TCP, all command and media data will be sent through the RTSP port, normally, port 554. Also, when using RTSP/RTP over TCP, the data will be sent via binary interleave format.

Below will describe the essential for using RTSP/RTP over TCP

SETUP

To use TCP communication, you need to request TCP connection during RTSP SETUP. You have to sent SETUP command with

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 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.

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

| magic number | channel number | embedded data length | data |

magic number - 1 byte value of hex 0x24
channel number - 1 byte value to denote the channel
embedded data length - 2 bytes to denote the embedded data length
data - data packet, ie RTP packet, with the total length of the embedded data length

Below is a full example of the communication exchanged


Also, as RTSP is a application protocol, it has no way to control how TCP timeout the connection. Thus, during the RTSP SETUP, a Session is given to identify the connected stream

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 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 60 second to keep the TCP connection alive.

Read RFC 2326 Section 10.12 Embedded (Interleaved) Binary Data for more details

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值