您的位置:首页 > 其它

RTSP协议介绍举例

2014-08-15 15:45 281 查看

Real Time Streaming Protocol

The Real Time Streaming Protocol (RTSP) is a network controlprotocol designed for use in entertainment and communications systems to controlstreaming mediaservers. The protocol is used for establishing and controlling media sessions between end points. Clients of media servers issueVCR-like commands, such asplay and pause, to facilitate real-time control of playback of media files from the server.
The transmission of streaming data itself is not a task of the RTSP protocol. Most RTSP servers use theReal-time Transport Protocol (RTP) in conjunction with Real-time Control Protocol (RTCP) for media stream delivery, however some vendors implement proprietary transport protocols. The RTSP server fromRealNetworks, for example, also featuresRealNetworks' proprietaryReal Data Transport (RDT).
RTSP was developed by the Multiparty Multimedia Session Control Working Group (MMUSIC WG) of theInternet Engineering Task Force (IETF) and published as RFC 2326 in 1998.[1]
RTSP using RTP and RTCP allows for the implementation of rate adaption.[further explanation needed]

Protocol directives

While similar in some ways to HTTP, RTSP defines control sequences useful in controlling multimedia playback. While HTTP isstateless, RTSP has state; an identifier is used when needed to track concurrent sessions. Like HTTP, RTSP uses TCP to maintain an end-to-end connection and, while most RTSP control messages are sent by the client to the server, some commands travel in the other direction (i.e. from server to client).
Presented here are the basic RTSP requests. Some typical HTTP requests, like the OPTIONS request, are also available. The default transport layerport number is 554.
OPTIONS

An OPTIONS request returns the request types the server will accept.

DESCRIBE

A DESCRIBE request includes an RTSP URL (rtsp://...), and the type of reply data that can be handled. The default port for the RTSP protocol is 554 for bothUDP (deprecated and very rarely used) and TCP transports. This reply includes the presentation description, typically inSession Description Protocol (SDP) format. Among other things, the presentation description lists the media streams controlled with the aggregate URL. In the typical case, there is one media stream each for audio and video.

C->S: DESCRIBE rtsp://example.com/media.mp4 RTSP/1.0
CSeq: 1

S->C: RTSP/1.0 200 OK
CSeq: 1
Content-Base: rtsp://example.com/media.mp4
Content-Type: application/sdp
m=video 0 RTP/AVP 96
a=control:streamid=0
a=range:npt=0-7.741000
a=length:npt=7.741000
a=rtpmap:96 MP4V-ES/5544
a=mimetype:string;"video/MP4V-ES"
a=AvgBitRate:integer;304018
a=StreamName:string;"hinted video track"
m=audio 0 RTP/AVP 97
a=control:streamid=1
a=range:npt=0-7.712000
a=length:npt=7.712000
a=rtpmap:97 mpeg4-generic/32000/2
a=mimetype:string;"audio/mpeg4-generic"
a=AvgBitRate:integer;65790
a=StreamName:string;"hinted audio track"
SETUP

A SETUP request specifies how a single media stream must be transported. This must be done before a PLAY request is sent. The request contains the media stream URL and a transport specifier. This specifier typically includes a local port for receivingRTP data (audio or video), and another for RTCP data (meta information). The server reply usually confirms the chosen parameters, and fills in the missing parts, such as the server's chosen ports. Each media stream must be configured using SETUP before an aggregate play request may be sent.

C->S: SETUP rtsp://example.com/media.mp4/streamid=0 RTSP/1.0
CSeq: 2
Transport: RTP/AVP;unicast;client_port=8000-8001

S->C: RTSP/1.0 200 OK
CSeq: 2
Transport: RTP/AVP;unicast;client_port=8000-8001;server_port=9000-9001
Session: 12345678
PLAY

A PLAY request will cause one or all media streams to be played. Play requests can be stacked by sending multiple PLAY requests. The URL may be the aggregate URL (to play all media streams), or a single media stream URL (to play only that stream). A range can be specified. If no range is specified, the stream is played from the beginning and plays to the end, or, if the stream is paused, it is resumed at the point it was paused.

C->S: PLAY rtsp://example.com/media.mp4 RTSP/1.0
CSeq: 4
Range: npt=5-20
Session: 12345678

S->C: RTSP/1.0 200 OK
CSeq: 4
Session: 12345678
RTP-Info: url=rtsp://example.com/media.mp4/streamid=0;seq=9810092;rtptime=3450012
PAUSE

A PAUSE request temporarily halts one or all media streams, so it can later be resumed with a PLAY request. The request contains an aggregate or media stream URL. A range parameter on a PAUSE request specifies when to pause. When the range parameter is omitted, the pause occurs immediately and indefinitely.

C->S: PAUSE rtsp://example.com/media.mp4 RTSP/1.0
CSeq: 5
Session: 12345678

S->C: RTSP/1.0 200 OK
CSeq: 5
Session: 12345678
RECORD

The RECORD request can be used to send a stream to the server for storage.

TEARDOWN

A TEARDOWN request is used to terminate the session. It stops all media streams and frees all session related data on the server.

C->S: TEARDOWN rtsp://example.com/media.mp4 RTSP/1.0
CSeq: 6
Session: 12345678

S->C: RTSP/1.0 200 OK
CSeq: 6
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  network protocol between