RFC2326 - Real Time Streaming Protocol (RTSP)(3)

时间:2005-02-15 来源: 作者: 点击:
acknowledged by the proxy to the client if not supported. Servers should treat this field identically to the Require field. See Section 12.32 for more details on the mechanics of this message and a u
  
acknowledged by the proxy to the client if not supported. Servers

should treat this field identically to the Require field.

See Section 12.32 for more details on the mechanics of this message
and a usage example.

12.28 Public

See [H14.35].

12.29 Range

This request and response header field specifies a range of time.
The range can be specified in a number of units. This specification
defines the smpte (Section 3.5), npt (Section 3.6), and clock
(Section 3.7) range units. Within RTSP, byte ranges [H14.36.1] are
not meaningful and MUST NOT be used. The header may also contain a
time parameter in UTC, specifying the time at which the operation is
to be made effective. Servers supporting the Range header MUST
understand the NPT range format and SHOULD understand the SMPTE range
format. The Range response header indicates what range of time is
actually being played or recorded. If the Range header is given in a
time format that is not understood, the recipient should return "501
Not Implemented".

Ranges are half-open intervals, including the lower point, but
excluding the upper point. In other words, a range of a-b starts
exactly at time a, but stops just before b. Only the start time of a
media unit such as a video or audio frame is relevant. As an example,
assume that video frames are generated every 40 ms. A range of 10.0-
10.1 would include a video frame starting at 10.0 or later time and
would include a video frame starting at 10.08, even though it lasted
beyond the interval. A range of 10.0-10.08, on the other hand, would
exclude the frame at 10.08.

Range = "Range" ":" 1\#ranges-specifier
[ ";" "time" "=" utc-time ]
ranges-specifier = npt-range | utc-range | smpte-range

Example:
Range: clock=19960213T143205Z-;time=19970123T143720Z

The notation is similar to that used for the HTTP/1.1 [2] byte-
range header. It allows clients to select an excerpt from the media
object, and to play from a given point to the end as well as from
the current location to a given point. The start of playback can be
scheduled for any time in the future, although a server may refuse
to keep server resources for extended idle periods.

12.30 Referer

See [H14.37]. The URL refers to that of the presentation description,
typically retrieved via HTTP.

12.31 Retry-After

See [H14.38].

12.32 Require

The Require header is used by clients to query the server about
options that it may or may not support. The server MUST respond to
this header by using the Unsupported header to negatively acknowledge
those options which are NOT supported.

This is to make sure that the client-server interaction will
proceed without delay when all options are understood by both
sides, and only slow down if options are not understood (as in the
case above). For a well-matched client-server pair, the interaction
proceeds quickly, saving a round-trip often required by negotiation
mechanisms. In addition, it also removes state ambiguity when the
client requires features that the server does not understand.

Require = "Require" ":" 1#option-tag

Example:
C->S: SETUP rtsp://server.com/foo/bar/baz.rm RTSP/1.0
CSeq: 302
Require: funky-feature
Funky-Parameter: funkystuff

S->C: RTSP/1.0 551 Option not supported
CSeq: 302
Unsupported: funky-feature

C->S: SETUP rtsp://server.com/foo/bar/baz.rm RTSP/1.0
CSeq: 303

S->C: RTSP/1.0 200 OK
CSeq: 303

In this example, "funky-feature" is the feature tag which indicates
to the client that the fictional Funky-Parameter field is required.
The relationship between "funky-feature" and Funky-Parameter is not
communicated via the RTSP exchange, since that relationship is an
immutable property of "funky-feature" and thus should not be
transmitted with every exchange.

Proxies and other intermediary devices SHOULD ignore features that
are not understood in this field. If a particular extension requires
that intermediate devices support it, the extension should be tagged
in the Proxy-Require field instead (see Section 12.27).

12.33 RTP-Info

This field is used to set RTP-specific parameters in the PLAY
response.

url:
Indicates the stream URL which for which the following RTP
parameters correspond.

seq:
Indicates the sequence number of the first packet of the
stream. This allows clients to gracefully deal with packets
when seeking. The client uses this value to differentiate
packets that originated before the seek from packets that
originated after the seek.

rtptime:
Indicates the RTP timestamp corresponding to the time value in
the Range response header. (Note: For aggregate control, a
particular stream may not actually generate a packet for the
Range time value returned or implied. Thus, there is no
guarantee that the packet with the sequence number indicated
by seq actually has the timestamp indicated by rtptime.) The
client uses this value to calculate the mapping of RTP time to
NPT.

A mapping from RTP timestamps to NTP timestamps (wall clock) is
available via RTCP. However, this information is not sufficient to
generate a mapping from RTP timestamps to NPT. Furthermore, in
order to ensure that this information is available at the necessary
time (immediately at startup or after a seek), and that it is
delivered reliably, this mapping is placed in the RTSP control
channel.

In order to compensate for drift for long, uninterrupted
presentations, RTSP clients should additionally map NPT to NTP,
using initial RTCP sender reports to do the mapping, and later
reports to check drift against the mapping.

Syntax:

RTP-Info = "RTP-Info" ":" 1#stream-url 1*parameter
stream-url = "url" "=" url
parameter = ";" "seq" "=" 1*DIGIT
| ";" "rtptime" "=" 1*DIGIT

Example:

RTP-Info: url=rtsp://foo.com/bar.avi/streamid=0;seq=45102,
url=rtsp://foo.com/bar.avi/streamid=1;seq=30211

12.34 Scale

A scale value of 1 indicates normal play or record at the normal
forward viewing rate. If not 1, the value corresponds to the rate
with respect to normal viewing rate. For example, a ratio of 2
indicates twice the normal viewing rate ("fast forward") and a ratio
of 0.5 indicates half the normal viewing rate. In other words, a
ratio of 2 has normal play time increase at twice the wallclock rate.
For every second of elapsed (wallclock) time, 2 seconds of content
will be delivered. A negative value indicates reverse direction.

Unless requested otherwise by the Speed parameter, the data rate
SHOULD not be changed. Implementation of scale changes depends on the
server and media type. For video, a server may, for example, deliver
only key frames or selected key frames. For audio, it may time-scale
the audio while preserving pitch or, less desirably, deliver
fragments of audio.

The server should try to approximate the viewing rate, but may
restrict the range of scale values that it supports. The response
MUST contain the actual scale value chosen by the server.

If the request contains a Range parameter, the new scale value will
take effect at that time.

Scale = "Scale" ":" [ "-" ] 1*DIGIT [ "." *DIGIT ]

Example of playing in reverse at 3.5 times normal rate:

Scale: -3.5

12.35 Speed

This request header fields parameter requests the server to deliver
data to the client at a particular speed, contingent on the server's
ability and desire to serve the media stream at the given speed.
Implementation by the server is OPTIONAL. The default is the bit rate
of the stream.

The parameter value is expressed as a decimal ratio, e.g., a value of
2.0 indicates that data is to be delivered twice as fast as normal. A
speed of zero is invalid. If the request contains a Range parameter,
the new speed value will take effect at that time.

Speed = "Speed" ":" 1*DIGIT [ "." *DIGIT ]

Example:
Speed: 2.5

Use of this field changes the bandwidth used for data delivery. It is
meant for use in specific circumstances where preview of the
presentation at a higher or lower rate is necessary. Implementors
should keep in mind that bandwidth for the session may be negotiated
beforehand (by means other than RTSP), and therefore re-negotiation
may be necessary. When data is delivered over UDP, it is highly
recommended that means such as RTCP be used to track packet loss
rates.

12.36 Server

See [H14.39]

12.37 Session

This request and response header field identifies an RTSP session
started by the media server in a SETUP response and concluded by
TEARDOWN on the presentation URL. The session identifier is chosen by
the media server (see Section 3.4). Once a client receives a Session
identifier, it MUST return it for any request related to that
session. A server does not have to set up a session identifier if it
has other means of identifying a session, such as dynamically
generated URLs.

Session = "Session" ":" session-id [ ";" "timeout" "=" delta-seconds ]

The timeout parameter is only allowed in a response header. The
server uses it to indicate to the client how long the server is
prepared to wait between RTSP commands before closing the session due
to lack of activity (see Section A). The timeout is measured in

seconds, with a default of 60 seconds (1 minute).

Note that a session identifier identifies a RTSP session across
transport sessions or connections. Control messages for more than one
RTSP URL may be sent within a single RTSP session. Hence, it is
possible that clients use the same session for controlling many
streams constituting a presentation, as long as all the streams come
from the same server. (See example in Section 14). However, multiple
"user" sessions for the same URL from the same client MUST use
different session identifiers.

The session identifier is needed to distinguish several delivery
requests for the same URL coming from the same client.

The response 454 (Session Not Found) is returned if the session
identifier is invalid.

12.38 Timestamp

The timestamp general header describes when the client sent the
request to the server. The value of the timestamp is of significance
only to the client and may use any timescale. The server MUST echo
the exact same value and MAY, if it has accurate information about
this, add a floating point number indicating the number of seconds
that has elapsed since it has received the request. The timestamp is
used by the client to compute the round-trip time to the server so
that it can adjust the timeout value for retransmissions.

Timestamp = "Timestamp" ":" *(DIGIT) [ "." *(DIGIT) ] [ delay ]
delay = *(DIGIT) [ "." *(DIGIT) ]

12.39 Transport

This request header indicates which transport protocol is to be used
and configures its parameters such as destination address,
compression, multicast time-to-live and destination port for a single
stream. It sets those values not already determined by a presentation
description.

Transports are comma separated, listed in order of preference.
Parameters may be added to each transport, separated by a semicolon.

The Transport header MAY also be used to change certain transport
parameters. A server MAY refuse to change parameters of an existing
stream.

The server MAY return a Transport response header in the response to
indicate the values actually chosen.

A Transport request header field may contain a list of transport
options acceptable to the client. In that case, the server MUST
return a single option which was actually chosen.

The syntax for the transport specifier is

transport/profile/lower-transport.

The default value for the "lower-transport" parameters is specific to
the profile. For RTP/AVP, the default is UDP.

Below are the configuration parameters associated with transport:

General parameters:

unicast | multicast:
mutually exclusive indication of whether unicast or multicast
delivery will be attempted. Default value is multicast.
Clients that are capable of handling both unicast and
multicast transmission MUST indicate such capability by
including two full transport-specs with separate parameters
for each.

destination:
The address to which a stream will be sent. The client may
specify the multicast address with the destination parameter.
To avoid becoming the unwitting perpetrator of a remote-
controlled denial-of-service attack, a server SHOULD
authenticate the client and SHOULD log such attempts before
allowing the client to direct a media stream to an address not
chosen by the server. This is particularly important if RTSP
commands are issued via UDP, but implementations cannot rely
on TCP as reliable means of client identification by itself. A
server SHOULD not allow a client to direct media streams to an
address that differs from the address commands are coming
from.

source:
If the source address for the stream is different than can be
derived from the RTSP endpoint address (the server in playback
or the client in recording), the source MAY be specified.

This information may also be available through SDP. However, since
this is more a feature of transport than media initialization, the
authoritative source for this information should be in the SETUP
response.

layers:
The number of multicast layers to be used for this media
stream. The layers are sent to consecutive addresses starting
at the destination address.

mode:
The mode parameter indicates the methods to be supported for
this session. Valid values are PLAY and RECORD. If not
provided, the default is PLAY.

append:
If the mode parameter includes RECORD, the append parameter
indicates that the media data should append to the existing
resource rather than overwrite it. If appending is requested
and the server does not support this, it MUST refuse the
request rather than overwrite the resource identified by the
URI. The append parameter is ignored if the mode parameter
does not contain RECORD.

interleaved:
The interleaved parameter implies mixing the media stream with
the control stream in whatever protocol is being used by the
control stream, using the mechanism defined in Section 10.12.
The argument provides the channel number to be used in the $
statement. This parameter may be specified as a range, e.g.,
interleaved=4-5 in cases where the transport choice for the
media stream requires it.

This allows RTP/RTCP to be handled similarly to the way that it is
done with UDP, i.e., one channel for RTP and the other for RTCP.

Multicast specific:

ttl:
multicast time-to-live

RTP Specific:

port:
This parameter provides the RTP/RTCP port pair for a multicast
session. It is specified as a range, e.g., port=3456-3457.

client_port:
This parameter provides the unicast RTP/RTCP port pair on
which the client has chosen to receive media data and control
information. It is specified as a range, e.g.,
client_port=3456-3457.

server_port:
This parameter provides the unicast RTP/RTCP port pair on
which the server has chosen to receive media data and control
information. It is specified as a range, e.g.,
server_port=3456-3457.

ssrc:
The ssrc parameter indicates the RTP SSRC [24, Sec. 3] value
that should be (request) or will be (response) used by the
media server. This parameter is only valid for unicast
transmission. It identifies the synchronization source to be
associated with the media stream.

Transport = "Transport" ":"
1\#transport-spec
transport-spec = transport-protocol/profile[/lower-transport]
*parameter
transport-protocol = "RTP"
profile = "AVP"
lower-transport = "TCP" | "UDP"
parameter = ( "unicast" | "multicast" )
| ";" "destination" [ "=" address ]
| ";" "interleaved" "=" channel [ "-" channel ]
| ";" "append"
| ";" "ttl" "=" ttl
| ";" "layers" "=" 1*DIGIT
| ";" "port" "=" port [ "-" port ]
| ";" "client_port" "=" port [ "-" port ]
| ";" "server_port" "=" port [ "-" port ]
| ";" "ssrc" "=" ssrc
| ";" "mode" = <"> 1\#mode <">
ttl = 1*3(DIGIT)
port = 1*5(DIGIT)
ssrc = 8*8(HEX)
channel = 1*3(DIGIT)
address = host
mode = <"> *Method <"> | Method

Example:
Transport: RTP/AVP;multicast;ttl=127;mode="PLAY",
RTP/AVP;unicast;client_port=3456-3457;mode="PLAY"

The Transport header is restricted to describing a single RTP
stream. (RTSP can also control multiple streams as a single
entity.) Making it part of RTSP rather than relying on a multitude
of session description formats greatly simplifies designs of
firewalls.

12.40 Unsupported

The Unsupported response header lists the features not supported by
the server. In the case where the feature was specified via the
Proxy-Require field (Section 12.32), if there is a proxy on the path
between the client and the server, the proxy MUST insert a message
reply with an error message "551 Option Not Supported".

See Section 12.32 for a usage example.

12.41 User-Agent

See [H14.42]

12.42 Vary

See [H14.43]

12.43 Via

See [H14.44].

12.44 WWW-Authentica

See [H14.46].

13 Caching

In HTTP, response-request pairs are cached. RTSP differs
significantly in that respect. Responses are not cacheable, with the
exception of the presentation description returned by DESCRIBE or
included with ANNOUNCE. (Since the responses for anything but
DESCRIBE and GET_PARAMETER do not return any data, caching is not
really an issue for these requests.) However, it is desirable for the
continuous media data, typically delivered out-of-band with respect
to RTSP, to be cached, as well as the session description.

On receiving a SETUP or PLAY request, a proxy ascertains whether it
has an up-to-date copy of the continuous media content and its
description. It can determine whether the copy is up-to-date by
issuing a SETUP or DESCRIBE request, respectively, and comparing the
Last-Modified header with that of the cached copy. If the copy is not
up-to-date, it modifies the SETUP transport parameters as appropriate
and forwards the request to the origin server. Subsequent control
commands such as PLAY or PAUSE then pass the proxy unmodified. The
proxy delivers the continuous media data to the client, while
possibly making a local copy for later reuse. The exact behavior
allowed to the cache is given by the cache-response directives

described in Section 12.8. A cache MUST answer any DESCRIBE requests
if it is currently serving the stream to the requestor, as it is
possible that low-level details of the stream description may have
changed on the origin-server.

Note that an RTSP cache, unlike the HTTP cache, is of the "cut-
through" variety. Rather than retrieving the whole resource from the
origin server, the cache simply copies the streaming data as it
passes by on its way to the client. Thus, it does not introduce
additional latency.

To the client, an RTSP proxy cache appears like a regular media
server, to the media origin server like a client. Just as an HTTP
cache has to store the content type, content language, and so on for
the objects it caches, a media cache has to store the presentation
description. Typically, a cache eliminates all transport-references
(that is, multicast information) from the presentation description,
since these are independent of the data delivery from the cache to
the client. Information on the encodings remains the same. If the
cache is able to translate the cached media data, it would create a
new presentation description with all the encoding possibilities it
can offer.

14 Examples

The following examples refer to stream description formats that are
not standards, such as RTSL. The following examples are not to be
used as a reference for those formats.

14.1 Media on Demand (Unicast)

Client C requests a movie from media servers A ( audio.example.com)
and V (video.example.com). The media description is stored on a web
server W . The media description contains descriptions of the
presentation and all its streams, including the codecs that are
available, dynamic RTP payload types, the protocol stack, and content
information such as language or copyright restrictions. It may also
give an indication about the timeline of the movie.

In this example, the client is only interested in the last part of
the movie.

C->W: GET /twister.sdp HTTP/1.1
Host: www.example.com
Accept: application/sdp

W->C: HTTP/1.0 200 OK
Content-Type: application/sdp

v=0
o=- 2890844526 2890842807 IN IP4 192.16.24.202
s=RTSP Session
m=audio 0 RTP/AVP 0
a=control:rtsp://audio.example.com/twister/audio.en
m=video 0 RTP/AVP 31
a=control:rtsp://video.example.com/twister/video

C->A: SETUP rtsp://audio.example.com/twister/audio.en RTSP/1.0
CSeq: 1
Transport: RTP/AVP/UDP;unicast;client_port=3056-3057

A->C: RTSP/1.0 200 OK
CSeq: 1
Session: 12345678
Transport: RTP/AVP/UDP;unicast;client_port=3056-3057;
server_port=5000-5001

C->V: SETUP rtsp://video.example.com/twister/video RTSP/1.0
CSeq: 1
Transport: RTP/AVP/UDP;unicast;client_port=3058-3059

V->C: RTSP/1.0 200 OK
CSeq: 1
Session: 23456789
Transport: RTP/AVP/UDP;unicast;client_port=3058-3059;
server_port=5002-5003

C->V: PLAY rtsp://video.example.com/twister/video RTSP/1.0
CSeq: 2
Session: 23456789
Range: smpte=0:10:00-

V->C: RTSP/1.0 200 OK
CSeq: 2
Session: 23456789
Range: smpte=0:10:00-0:20:00
RTP-Info: url=rtsp://video.example.com/twister/video;
seq=12312232;rtptime=78712811

C->A: PLAY rtsp://audio.example.com/twister/audio.en RTSP/1.0
CSeq: 2
Session: 12345678
Range: smpte=0:10:00-

A->C: RTSP/1.0 200 OK
CSeq: 2
Session: 12345678

Range: smpte=0:10:00-0:20:00
RTP-Info: url=rtsp://audio.example.com/twister/audio.en;
seq=876655;rtptime=1032181

C->A: TEARDOWN rtsp://audio.example.com/twister/audio.en RTSP/1.0
CSeq: 3
Session: 12345678

A->C: RTSP/1.0 200 OK
CSeq: 3

C->V: TEARDOWN rtsp://video.example.com/twister/video RTSP/1.0
CSeq: 3
Session: 23456789

V->C: RTSP/1.0 200 OK
CSeq: 3

Even though the audio and video track are on two different servers,
and may start at slightly different times and may drift with respect
to each other, the client can synchronize the two using standard RTP
methods, in particular the time scale contained in the RTCP sender
reports.

14.2 Streaming of a Container file

For purposes of this example, a container file is a storage entity in
which multiple continuous media types pertaining to the same end-user
presentation are present. In effect, the container file represents an
RTSP presentation, with each of its components being RTSP streams.
Container files are a widely used means to store such presentations.
While the components are transported as independent streams, it is
desirable to maintain a common context for those streams at the
server end.

This enables the server to keep a single storage handle open
easily. It also allows treating all the streams equally in case of
any prioritization of streams by the server.

It is also possible that the presentation author may wish to prevent
selective retrieval of the streams by the client in order to preserve
the artistic effect of the combined media presentation. Similarly, in
such a tightly bound presentation, it is desirable to be able to
control all the streams via a single control message using an
aggregate URL.

The following is an example of using a single RTSP session to control
multiple streams. It also illustrates the use of aggregate URLs.

Client C requests a presentation from media server M . The movie is
stored in a container file. The client has obtained an RTSP URL to
the container file.

C->M: DESCRIBE rtsp://foo/twister RTSP/1.0
CSeq: 1

M->C: RTSP/1.0 200 OK
CSeq: 1
Content-Type: application/sdp
Content-Length: 164

v=0
o=- 2890844256 2890842807 IN IP4 172.16.2.93
s=RTSP Session
i=An Example of RTSP Session Usage
a=control:rtsp://foo/twister
t=0 0
m=audio 0 RTP/AVP 0
a=control:rtsp://foo/twister/audio
m=video 0 RTP/AVP 26
a=control:rtsp://foo/twister/video

C->M: SETUP rtsp://foo/twister/audio RTSP/1.0
CSeq: 2
Transport: RTP/AVP;unicast;client_port=8000-8001

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

C->M: SETUP rtsp://foo/twister/video RTSP/1.0
CSeq: 3
Transport: RTP/AVP;unicast;client_port=8002-8003
Session: 12345678

M->C: RTSP/1.0 200 OK
CSeq: 3
Transport: RTP/AVP;unicast;client_port=8002-8003;
server_port=9004-9005
Session: 12345678

C->M: PLAY rtsp://foo/twister RTSP/1.0
CSeq: 4
Range: npt=0-
Session: 12345678

M->C: RTSP/1.0 200 OK
CSeq: 4
Session: 12345678
RTP-Info: url=rtsp://foo/twister/video;
seq=9810092;rtptime=3450012

C->M: PAUSE rtsp://foo/twister/video RTSP/1.0
CSeq: 5
Session: 12345678

M->C: RTSP/1.0 460 Only aggregate operation allowed
CSeq: 5

C->M: PAUSE rtsp://foo/twister RTSP/1.0
CSeq: 6
Session: 12345678

M->C: RTSP/1.0 200 OK
CSeq: 6
Session: 12345678

C->M: SETUP rtsp://foo/twister RTSP/1.0
CSeq: 7
Transport: RTP/AVP;unicast;client_port=10000

M->C: RTSP/1.0 459 Aggregate operation not allowed
CSeq: 7

In the first instance of failure, the client tries to pause one
stream (in this case video) of the presentation. This is disallowed
for that presentation by the server. In the second instance, the
aggregate URL may not be used for SETUP and one control message is
required per stream to set up transport parameters.

This keeps the syntax of the Transport header simple and allows
easy parsing of transport information by firewalls.

14.3 Single Stream Container Files

Some RTSP servers may treat all files as though they are "container
files", yet other servers may not support such a concept. Because of
this, clients SHOULD use the rules set forth in the session
description for request URLs, rather than assuming that a consistent
URL may always be used throughout. Here's an example of how a multi-
stream server might expect a single-stream file to be served:

Accept: application/x-rtsp-mh, application/sdp

CSeq: 1

S->C RTSP/1.0 200 OK
CSeq: 1
Content-base: rtsp://foo.com/test.wav/
Content-type: application/sdp
Content-length: 48

v=0
o=- 872653257 872653257 IN IP4 172.16.2.187
s=mu-law wave file
i=audio test
t=0 0
m=audio 0 RTP/AVP 0
a=control:streamid=0

C->S SETUP rtsp://foo.com/test.wav/streamid=0 RTSP/1.0
Transport: RTP/AVP/UDP;unicast;
client_port=6970-6971;mode=play
CSeq: 2

S->C RTSP/1.0 200 OK
Transport: RTP/AVP/UDP;unicast;client_port=6970-6971;
server_port=6970-6971;mode=play
CSeq: 2
Session: 2034820394

C->S PLAY rtsp://foo.com/test.wav RTSP/1.0
CSeq: 3
Session: 2034820394

S->C RTSP/1.0 200 OK
CSeq: 3
Session: 2034820394
RTP-Info: url=rtsp://foo.com/test.wav/streamid=0;
seq=981888;rtptime=3781123

Note the different URL in the SETUP command, and then the switch back
to the aggregate URL in the PLAY command. This makes complete sense
when there are multiple streams with aggregate control, but is less
than intuitive in the special case where the number of streams is
one.

In this special case, it is recommended that servers be forgiving of
implementations that send:

C->S PLAY rtsp://foo.com/test.wav/streamid=0 RTSP/1.0
CSeq: 3

In the worst case, servers should send back:

S->C RTSP/1.0 460 Only aggregate operation allowed
CSeq: 3

One would also hope that server implementations are also forgiving of
the following:

C->S SETUP rtsp://foo.com/test.wav RTSP/1.0
Transport: rtp/avp/udp;client_port=6970-6971;mode=play
CSeq: 2

Since there is only a single stream in this file, it's not ambiguous
what this means.

14.4 Live Media Presentation Using Multicast

The media server M chooses the multicast address and port. Here, we
assume that the web server only contains a pointer to the full
description, while the media server M maintains the full description.

C->W: GET /concert.sdp HTTP/1.1
Host: www.example.com

W->C: HTTP/1.1 200 OK
Content-Type: application/x-rtsl

<session>
<track src="rtsp://live.example.com/concert/audio">
</session>

C->M: DESCRIBE rtsp://live.example.com/concert/audio RTSP/1.0
CSeq: 1

M->C: RTSP/1.0 200 OK
CSeq: 1
Content-Type: application/sdp
Content-Length: 44

v=0
o=- 2890844526 2890842807 IN IP4 192.16.24.202
s=RTSP Session
m=audio 3456 RTP/AVP 0
a=control:rtsp://live.example.com/concert/audio
c=IN IP4 224.2.0.1/16

C->M: SETUP rtsp://live.example.com/concert/audio RTSP/1.0
CSeq: 2

Transport: RTP/AVP;multicast

M->C: RTSP/1.0 200 OK
CSeq: 2
Transport: RTP/AVP;multicast;destination=224.2.0.1;
port=3456-3457;ttl=16
Session: 0456804596

C->M: PLAY rtsp://live.example.com/concert/audio RTSP/1.0
CSeq: 3
Session: 0456804596

M->C: RTSP/1.0 200 OK
CSeq: 3
Session: 0456804596

14.5 Playing media into an existing session

A conference participant C wants to have the media server M play back
a demo tape into an existing conference. C indicates to the media
server that the network addresses and encryption keys are already
given by the conference, so they should not be chosen by the server.
The example omits the simple ACK responses.

C->M: DESCRIBE rtsp://server.example.com/demo/548/sound RTSP/1.0
CSeq: 1
Accept: application/sdp

M->C: RTSP/1.0 200 1 OK
Content-type: application/sdp
Content-Length: 44

v=0
o=- 2890844526 2890842807 IN IP4 192.16.24.202
s=RTSP Session
i=See above
t=0 0
m=audio 0 RTP/AVP 0

C->M: SETUP rtsp://server.example.com/demo/548/sound RTSP/1.0
CSeq: 2
Transport: RTP/AVP;multicast;destination=225.219.201.15;
port=7000-7001;ttl=127
Conference: 199702170042.SAA08642@obiwan.arl.wustl.edu%20Starr

M->C: RTSP/1.0 200 OK
CSeq: 2
Transport: RTP/AVP;multicast;destination=225.219.201.15;

port=7000-7001;ttl=127
Session: 91389234234
Conference: 199702170042.SAA08642@obiwan.arl.wustl.edu%20Starr

C->M: PLAY rtsp://server.example.com/demo/548/sound RTSP/1.0
CSeq: 3
Session: 91389234234

M->C: RTSP/1.0 200 OK
CSeq: 3

14.6 Recording

The conference participant client C asks the media server M to record
the audio and video portions of a meeting. The client uses the
ANNOUNCE method to provide meta-information about the recorded
session to the server.

C->M: ANNOUNCE rtsp://server.example.com/meeting RTSP/1.0
CSeq: 90
Content-Type: application/sdp
Content-Length: 121

v=0
o=camera1 3080117314 3080118787 IN IP4 195.27.192.36
s=IETF Meeting, Munich - 1
i=The thirty-ninth IETF meeting will be held in Munich, Germany
u=http://www.ietf.org/meetings/Munich.html
e=IETF Channel 1 <ietf39-mbone@uni-koeln.de>
p=IETF Channel 1 +49-172-2312 451
c=IN IP4 224.0.1.11/127
t=3080271600 3080703600
a=tool:sdr v2.4a6
a=type:test
m=audio 21010 RTP/AVP 5
c=IN IP4 224.0.1.11/127
a=ptime:40
m=video 61010 RTP/AVP 31
c=IN IP4 224.0.1.12/127

M->C: RTSP/1.0 200 OK
CSeq: 90

C->M: SETUP rtsp://server.example.com/meeting/audiotrack RTSP/1.0
CSeq: 91
Transport: RTP/AVP;multicast;destination=224.0.1.11;
port=21010-21011;mode=record;ttl=127

M->C: RTSP/1.0 200 OK
CSeq: 91
Session: 50887676
Transport: RTP/AVP;multicast;destination=224.0.1.11;
port=21010-21011;mode=record;ttl=127

C->M: SETUP rtsp://server.example.com/meeting/videotrack RTSP/1.0
CSeq: 92
Session: 50887676
Transport: RTP/AVP;multicast;destination=224.0.1.12;
port=61010-61011;mode=record;ttl=127

M->C: RTSP/1.0 200 OK
CSeq: 92
Transport: RTP/AVP;multicast;destination=224.0.1.12;
port=61010-61011;mode=record;ttl=127

C->M: RECORD rtsp://server.example.com/meeting RTSP/1.0
CSeq: 93
Session: 50887676
Range: clock=19961110T1925-19961110T2015

M->C: RTSP/1.0 200 OK
CSeq: 93

15 Syntax

The RTSP syntax is described in an augmented Backus-Naur form (BNF)
as used in RFC2068 [2].

15.1 Base Syntax

OCTET = <any 8-bit sequence of data>
CHAR = <any US-ASCII character (octets 0 - 127)>
UPALPHA = <any US-ASCII uppercase letter "A".."Z">
LOALPHA = <any US-ASCII lowercase letter "a".."z">
ALPHA = UPALPHA | LOALPHA

DIGIT = <any US-ASCII digit "0".."9">
CTL = <any US-ASCII control character
(octets 0 - 31) and DEL (127)>
CR = <US-ASCII CR, carriage return (13)>
LF = <US-ASCII LF, linefeed (10)>

SP = <US-ASCII SP, space (32)>
HT = <US-ASCII HT, horizontal-tab (9)>
<"> = <US-ASCII double-quote mark (34)>
CRLF = CR LF

LWS = [CRLF] 1*( SP | HT )
TEXT = <any OCTET except CTLs>
tspecials = "(" | ")" | "<" | ">" | "@"
| "," | ";" | ":" | "\" | <">
| "/" | "[" | "]" | "?" | "="
| "{" | "}" | SP | HT

token = 1*<any CHAR except CTLs or tspecials>
quoted-string = ( <"> *(qdtext) <"> )
qdtext = <any TEXT except <">>
quoted-pair = "\" CHAR

message-header = field-name ":" [ field-value ] CRLF
field-name = token
field-value = *( field-content | LWS )
field-content = <the OCTETs making up the field-value and
consisting of either *TEXT or
combinations of token, tspecials, and
quoted-string>

safe = "\$" | "-" | "_" | "." | "+"
extra = "!" | "*" | "$'$" | "(" | ")" | ","

hex = DIGIT | "A" | "B" | "C" | "D" | "E" | "F" |
"a" | "b" | "c" | "d" | "e" | "f"
escape = "\%" hex hex
reserved = ";" | "/" | "?" | ":" | "@" | "&" | "="

unreserved = alpha | digit | safe | extra
xchar = unreserved | reserved | escape

16 Security Considerations

Because of the similarity in syntax and usage between RTSP servers
and HTTP servers, the security considerations outlined in [H15]
apply. Specifically, please note the following:

Authentication Mechanisms:
RTSP and HTTP share common authentication schemes, and thus
should follow the same prescriptions with regards to
authentication. See [H15.1] for client authentication issues,
and [H15.2] for issues regarding support for multiple
authentication mechanisms.

Abuse of Server Log Information:
RTSP and HTTP servers will presumably have similar logging
mechanisms, and thus should be equally guarded in protecting
the contents of those logs, thus protecting the privacy of the

users of the servers. See [H15.3] for HTTP server
recommendations regarding server logs.

Transfer of Sensitive Information:
There is no reason to believe that information transferred via
RTSP may be any less sensitive than that normally transmitted
via HTTP. Therefore, all of the precautions regarding the
protection of data privacy and user privacy apply to
implementors of RTSP clients, servers, and proxies. See
[H15.4] for further details.

Attacks Based On File and Path Names:
Though RTSP URLs are opaque handles that do not necessarily
have file system semantics, it is anticipated that many
implementations will translate portions of the request URLs
directly to file system calls. In such cases, file systems
SHOULD follow the precautions outlined in [H15.5], such as
checking for ".." in path components.

Personal Information:
RTSP clients are often privy to the same information that HTTP
clients are (user name, location, etc.) and thus should be
equally. See [H15.6] for further recommendations.

Privacy Issues Connected to Accept Headers:
Since may of the same "Accept" headers exist in RTSP as in
HTTP, the same caveats outlined in [H15.7] with regards to
their use should be followed.

DNS Spoofing:
Presumably, given the longer connection times typically
associated to RTSP sessions relative to HTTP sessions, RTSP
client DNS optimizations should be less prevalent.
Nonetheless, the recommendations provided in [H15.8] are still
relevant to any implementation which attempts to rely on a
DNS-to-IP mapping to hold beyond a single use of the mapping.

Location Headers and Spoofing:
If a single server supports multiple organizations that do not
trust one another, then it must check the values of Location
and Content-Location headers in responses that are generated
under control of said organizations to make sure that they do
not attempt to invalidate resources over which they have no
authority. ([H15.9])

In addition to the recommendations in the current HTTP specification
(RFC2068 [2], as of this writing), future HTTP specifications may
provide additional guidance on security issues.

The following are added considerations for RTSP implementations.

Concentrated denial-of-service attack:
The protocol offers the opportunity for a remote-controlled
denial-of-service attack. The attacker may initiate traffic
flows to one or more IP addresses by specifying them as the
destination in SETUP requests. While the attacker's IP address
may be known in this case, this is not always useful in
prevention of more attacks or ascertaining the attackers
identity. Thus, an RTSP server SHOULD only allow client-
specified destinations for RTSP-initiated traffic flows if the
server has verified the client's identity, either against a
database of known users using RTSP authentication mechanisms
(preferably digest authentication or stronger), or other
secure means.

Session hijacking:
Since there is no relation between a transport layer
connection and an RTSP session, it is possible for a malicious
client to issue requests with random session identifiers which
would affect unsuspecting clients. The server SHOULD use a
large, random and non-sequential session identifier to
minimize the possibility of this kind of attack.

Authentication:
Servers SHOULD implement both basic and digest [8]
authentication. In environments requiring tighter security for
the control messages, the RTSP control stream may be
encrypted.

Stream issues:
RTSP only provides for stream control. Stream delivery issues
are not covered in this section, nor in the rest of this memo.
RTSP implementations will most likely rely on other protocols
such as RTP, IP multicast, RSVP and IGMP, and should address
security considerations brought up in those and other
applicable specifications.

Persistently suspicious behavior:
RTSP servers SHOULD return error code 403 (Forbidden) upon
receiving a single instance of behavior which is deemed a
security risk. RTSP servers SHOULD also be aware of attempts
to probe the server for weaknesses and entry points and MAY
arbitrarily disconnect and ignore further requests clients
which are deemed to be in violation of local security policy.

Appendix A: RTSP Protocol State Machines

The RTSP client and server state machines describe the behavior of
the protocol from RTSP session initialization through RTSP session
termination.

State is defined on a per object basis. An object is uniquely
identified by the stream URL and the RTSP session identifier. Any
request/reply using aggregate URLs denoting RTSP presentations
composed of multiple streams will have an effect on the individual
states of all the streams. For example, if the presentation /movie
contains two streams, /movie/audio and /movie/video, then the
following command:

PLAY rtsp://foo.com/movie RTSP/1.0
CSeq: 559
Session: 12345678

will have an effect on the states of movie/audio and movie/video.

This example does not imply a standard way to represent streams in
URLs or a relation to the filesystem. See Section 3.2.

The requests OPTIONS, ANNOUNCE, DESCRIBE, GET_PARAMETER,
SET_PARAMETER do not have any effect on client or server state and
are therefore not listed in the state tables.

A.1 Client State Machine

The client can assume the following states:

Init:
SETUP has been sent, waiting for reply.

Ready:
SETUP reply received or PAUSE reply received while in Playing
state.

Playing:
PLAY reply received

Recording:
RECORD reply received

In general, the client changes state on receipt of replies to
requests. Note that some requests are effective at a future time or
position (such as a PAUSE), and state also changes accordingly. If no
explicit SETUP is required for the object (for example, it is

available via a multicast group), state begins at Ready. In this
case, there are only two states, Ready and Playing. The client also
changes state from Playing/Recording to Ready when the end of the
requested range is reached.

The "next state" column indicates the state assumed after receiving a
success response (2xx). If a request yields a status code of 3xx, the
state becomes Init, and a status code of 4xx yields no change in
state. Messages not listed for each state MUST NOT be issued by the
client in that state, with the exception of messages not affecting
state, as listed above. Receiving a REDIRECT from the server is
equivalent to receiving a 3xx redirect status from the server.

state message sent next state after response
Init SETUP Ready
TEARDOWN Init
Ready PLAY Playing
RECORD Recording
TEARDOWN Init
SETUP Ready
Playing PAUSE Ready
TEARDOWN Init
PLAY Playing
SETUP Playing (changed transport)
Recording PAUSE Ready
TEARDOWN Init
RECORD Recording
SETUP Recording (changed transport)

A.2 Server State Machine

The server can assume the following states:

Init:
The initial state, no valid SETUP has been received yet.

Ready:
Last SETUP received was successful, reply sent or after
playing, last PAUSE received was successful, reply sent.

Playing:
Last PLAY received was successful, reply sent. Data is being
sent.

Recording:
The server is recording media data.

In general, the server changes state on receiving requests. If the
server is in state Playing or Recording and in unicast mode, it MAY
revert to Init and tear down the RTSP session if it has not received
"wellness" information, such as RTCP reports or RTSP commands, from
the client for a defined interval, with a default of one minute. The
server can declare another timeout value in the Session response
header (Section 12.37). If the server is in state Ready, it MAY
revert to Init if it does not receive an RTSP request for an interval
of more than one minute. Note that some requests (such as PAUSE) may
be effective at a future time or position, and server state changes
at the appropriate time. The server reverts from state Playing or
Recording to state Ready at the end of the range requested by the
client.

The REDIRECT message, when sent, is effective immediately unless it
has a Range header specifying when the redirect is effective. In such
a case, server state will also change at the appropriate time.

If no explicit SETUP is required for the object, the state starts at
Ready and there are only two states, Ready and Playing.

The "next state" column indicates the state assumed after sending a
success response (2xx). If a request results in a status code of 3xx,
the state becomes Init. A status code of 4xx results in no change.

state message received next state
Init SETUP Ready
TEARDOWN Init
Ready PLAY Playing
SETUP Ready
TEARDOWN Init
RECORD Recording
Playing PLAY Playing
PAUSE Ready
TEARDOWN Init
SETUP Playing
Recording RECORD Recording
PAUSE Ready
TEARDOWN Init
SETUP Recording

Appendix B: Interaction with RTP

RTSP allows media clients to control selected, non-contiguous
sections of media presentations, rendering those streams with an RTP
media layer[24]. The media layer rendering the RTP stream should not
be affected by jumps in NPT. Thus, both RTP sequence numbers and RTP
timestamps MUST be continuous and monotonic across jumps of NPT.

As an example, assume a clock frequency of 8000 Hz, a packetization
interval of 100 ms and an initial sequence number and timestamp of
zero. First we play NPT 10 through 15, then skip ahead and play NPT
18 through 20. The first segment is presented as RTP packets with
sequence numbers 0 through 49 and timestamp 0 through 39,200. The
second segment consists of RTP packets with sequence number 50
through 69, with timestamps 40,000 through 55,200.

We cannot assume that the RTSP client can communicate with the RTP
media agent, as the two may be independent processes. If the RTP
timestamp shows the same gap as the NPT, the media agent will
assume that there is a pause in the presentation. If the jump in
NPT is large enough, the RTP timestamp may roll over and the media
agent may believe later packets to be duplicates of packets just
played out.

For certain datatypes, tight integration between the RTSP layer and
the RTP layer will be necessary. This by no means precludes the
above restriction. Combined RTSP/RTP media clients should use the
RTP-Info field to determine whether incoming RTP packets were sent
before or after a seek.

For continuous audio, the server SHOULD set the RTP marker bit at the
beginning of serving a new PLAY request. This allows the client to
perform playout delay adaptation.

For scaling (see Section 12.34), RTP timestamps should correspond to
the playback timing. For example, when playing video recorded at 30
frames/second at a scale of two and speed (Section 12.35) of one, the
server would drop every second frame to maintain and deliver video
packets with the normal timestamp spacing of 3,000 per frame, but NPT
would increase by 1/15 second for each video frame.

The client can maintain a correct display of NPT by noting the RTP
timestamp value of the first packet arriving after repositioning. The
sequence parameter of the RTP-Info (Section 12.33) header provides
the first sequence number of the next segment.

Appendix C: Use of SDP for RTSP Session Descriptions

The Session Description Protocol (SDP, RFC2327 [6]) may be used to
describe streams or presentations in RTSP. Such usage is limited to
specifying means of access and encoding(s) for:

aggregate control:
A presentation composed of streams from one or more servers
that are not available for aggregate control. Such a
description is typically retrieved by HTTP or other non-RTSP
means. However, they may be received with ANNOUNCE methods.

non-aggregate control:
A presentation composed of multiple streams from a single
server that are available for aggregate control. Such a
description is typically returned in reply to a DESCRIBE
request on a URL, or received in an ANNOUNCE method.

This appendix describes how an SDP file, retrieved, for example,
through HTTP, determines the operation of an RTSP session. It also
describes how a client should interpret SDP content returned in reply
to a DESCRIBE request. SDP provides no mechanism by which a client
can distinguish, without human guidance, between several media
streams to be rendered simultaneously and a set of alternatives
(e.g., two audio streams spoken in different languages).

C.1 Definitions

The terms "session-level", "media-level" and other key/attribute
------分隔线----------------------------
顶一下
(4)
100%
踩一下
(0)
0%
------分隔线----------------------------
最新评论 查看所有评论
发表评论 查看所有评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 密码: 验证码:
推荐内容