上一篇文章,理解了离线的 H.264流媒体的播放 http://blog.csdn.net/span76/article/details/12905515
离线媒体只是用 Http协议去读取服务器端文件而已,而对于实时直播如何实现, 这里就要用到 RTP/RTCP协议了
RTP/RTCP
RTP是基于 UDP协议的, UDP不用建立连接,效率更高;但允许丢包, 这就要求在重新组装媒体的时候多做些工作
RTP只是包裹内容信息,而RTCP是交换控制信息的,Qos是通过RTCP实现的
RTP中一个重要的概念是 session, 对于一个 audio stream 可以是一个session 但可以有多个 contributor, 也可以有多个监听者, 比如网络电话
做实时视频流,先用采集设备,直接把视频做成 H.264 的 NALu,而后通过 RTP打包,传输给客户端
有一篇文就是介绍如何把 NALu 用RTP打包的
http://www.rosoo.net/a/201108/14896.html
RTSP
但还缺少一个环节, 应用程序对应的是 play, seek, pause, stop, 如何把应用指令和 RTP的传输结合起来.
RTSP正是为了解决这个问题产生的
RTSP是应用层的协议和 HTTP协议很相似,客户端和服务器通过传递文本,通知如何进行 RTP/RTCP信息的交互
从图中,我们可以看到 RTSP也可以不用 RTP, 而用TCP来实现流媒体传递
RTSP的 client 连接 server 多通过 SDP(会话描述协议)传递信息
C -> S :
DESCRIBE rtsp://server.example.com/fizzle/foo RTSP/1.0 312
Accept: application/sdp, application/rtsl, application/mheg
S -> C :
RTSP/1.0 200 312 OK
Date: 23 Jan 1997 15:35:06 GMT
Content-Type: application/sdp
Content-Length: 376
v=0
o=mhandley 2890844526 2890842807 IN IP4 126.16.64.4
s=SDP Seminar
i=A Seminar on the session description protocol
u=http://www.cs.ucl.ac.uk/staff/M.Handley/sdp.03.ps
e=mjh@isi.edu (Mark Handley)
c=IN IP4 224.2.17.12/127
t=2873397496 28973404696
a=recvonly
m=audio 3456 RTP/AVP 0
m=video 2232 RTP/AVP 31
m=whiteboard 32416 UDP WB
a=orient:portrait
Session description
v= (protocol version)
o= (owner/creator and session identifier)
s= (session name)
i=* (session information)
u=* (URI of description)
e=* (email address)
p=* (phone number)
c=* (connection information - not required if included in all media)
b=* (zero or more bandwidth information lines)
One or more time descriptions ("t=" and "r=" lines, see below)
z=* (time zone adjustments)
k=* (encryption key)
a=* (zero or more session attribute lines)
Zero or more media descriptions
通过这些信息,client 就可以连接正确的 RTP session
关于RTMP和RTSP的区别
RTMP: RTM(Messaging)P 是 Adobe公司自己的规范,为Flash播放器和服务器之间音频、视频和数据传输开发的私有协议。
看下面评论
They are both protocols for Streaming Media and on a high level achieve the same thing - Specify a standard to stream media. Although RTMP was developed and owned by Adobe before being made public , whereas RTSP was a public standard from the beginning. Since RTMP is mostly used by Flash player。
对于 Android这个开源项目,其 media player 一定是使用 public 的 RTSP
本文介绍了实时媒体播放中的RTP/RTCP协议,阐述了RTP基于UDP的特性以及与RTCP在QoS中的作用。RTSP作为控制协议,允许应用程序进行播放、暂停等操作。同时,文章对比了RTMP和RTSP的区别,并提到Android开源项目通常使用公共标准RTSP。
4713

被折叠的 条评论
为什么被折叠?



