Introduction to RTSP interactive commands and description of Process Parameters

Source: Internet
Author: User

Real Time Streaming Protocol or RTSP (Real-Time Streaming Protocol) is an application layer protocol jointly proposed by real network and Netscape to effectively transmit streaming media data over an IP network. RTSP provides an extensible framework that enables controllable and on-demand transmission of real-time data, such as audio and video files. The source data can include on-site data feedback and stored files. RTSP provides control for streaming media such as pause and fast forward, but it does not transmit data itself. RTSP is equivalent to remote control of streaming media servers. Data transmission is acceptable.

The Transport Layer TCP, UDP, and RTSP also provide some effective methods based on the RTP transmission mechanism.


RTSP Message format:

There are two types of RTSP messages: request and response. The two types of messages have different formats.

Request Message:

Method uri rtsp version CR LF

Message Header CR LF

Message Body CR LF

The method includes all commands in the option response. The URI is the address of the receiver, for example

: Rtsp: // 192.168.20.136

RTSP versions are generally RTSP/1. 0. cr lf after each line indicates carriage return and line feed. The receiver must have corresponding solutions.

Analysis, the last message header requires two CR LF

Response Message:

RTSP version status code explanation CR LF

Message Header CR LF

Message Body CR LF

The RTSP version is generally RTSP/1.0, And the status code is a numerical value. The value 200 indicates success, which is interpreted as corresponding to the status code.

.

Simple RTSP interaction process:

C Indicates the RTSP client, and s indicates the RTSP server.

1. C-> S: Option request // ask s which methods are available

1. S-> C: Option response // s the response information includes all available methods provided


2. C-> S: DESCRIBE request // obtain the media initialization description provided by S.

2. S-> C: Describe response // s response media initialization description, mainly SDP


3. C-> S: SETUP Request // sets the session attributes and transmission mode to remind s to establish a session

Words

3. S-> C: setup response // s creates a session and returns the session identifier and session-related information.



4. C-> S: Play request // C request playback

4. S-> C: Play response // S: the requested information is returned.


S-> C: Send streaming media data

5. C-> S: teardown request // C request to close the session

5. S-> C: teardown response // s should request


The above process is a standard and friendly RTSP process, but the actual needs are not necessarily step by step.

Steps 3rd and 4 are required! Step 1: The option request is optional as long as the server client has agreed on which methods are available. Step 2: If we have other ways to obtain media initialization descriptions (such as HTTP requests), we do not need to use the DESCRIBE request in RTSP. Step 5: determine whether or not to use the system based on the system requirements.

Common RTSP methods:

1. Option

The purpose is to obtain available methods provided by the server:

Options rtsp: // 192.168.20.136: 5000/xxx666 RTSP/1.0

CSeq: 1 // each message is marked with a serial number. The first packet is usually an option request message.

User-Agent: VLC Media Player (live555 streaming media v2005.11.10)


Server Response Information includes the following methods:

RTSP/1.0 200 OK

Server: userver 0.9.7 _ RC1

CSeq: 1 // The CSeq value of each Response Message corresponds to the CSeq of the Request Message

Public: Options, describe, setup, teardown, play, pause, scale,

Get_parameter // available methods provided by the server

2. Describe

C initiates a DESCRIBE request to S to obtain the Session Description (SDP ):

Describe rtsp: // 192.168.20.136: 5000/xxx666 RTSP/1.0


CSeq: 2

Token:

Accept: Application/SDP

User-Agent: VLC Media Player (live555 streaming media v2005.11.10)


The server responds to some descriptions of this session (SDP ):

RTSP/1.0 200 OK

Server: userver 0.9.7 _ RC1

CSeq: 2

X-Prev-URL: rtsp: // 192.168.20.136: 5000

X-next-URL: rtsp: // 192.168.20.136: 5000

X-Accept-retransmit: Our-retransmit

X-Accept-dynamic-rate: 1

Cache-control: Must-revalidate

Last-modified: Fri, 10 Nov 2006 12:34:38 GMT

Date: Fri, 10 Nov 2006 12:34:38 GMT

Expires: Fri, 10 Nov 2006 12:34:38 GMT

Content-base: rtsp: // 192.168.20.136: 5000/xxx666/

Content-Length: 344

Content-Type: Application/SDP


V = 0 // The following information is SDP

O = onewaveuserverng 1451516402 1025358037 in ip4 192.168.20.136

S =/xxx666

U = http :///

E = admin @

C = in ip4 0.0.0.0

T = 0 0

A = Isma-compliance: 1, 1.0, 1


A = range: Treaty = 0-

M = video 0 RTP/AVP 96 // M indicates the media description. The following is the media description of the video channel in the session.

A = rtpmap: 96 MP4V-ES/90000

A = fmtp: 96

Profile-level-id = 245; Config = 000001b0f5000001b50900000000000012000c888b0e0e0fa62d089028307


A = control: trackID = 0 // trackID = 0 indicates that the video stream uses channel 0.


3. Setup

The client reminds the server to establish a session and determine the transmission mode:

Setup rtsp: // 192.168.20.136: 5000/xxx666/trackID = 0 RTSP/1.0

CSeq: 3

Transport: RTP/AVP/tcp; unicast; interleaved = 0-1

User-Agent: VLC Media Player (live555 streaming media v2005.11.10)

// The URI contains trackID = 0, indicating that the channel is set. The transport parameter sets the transmission mode.

. The second byte location of the next packet header is interleaved, and its value is

Different, the interleaved value of trackID = 0 has two 0 or 1, 0 indicates RTP packet, 1 indicates RTCP packet, and the receiver

The interleaved value is used to determine the data packet.


Server Response Information:

RTSP/1.0 200 OK

Server: userver 0.9.7 _ RC1

CSeq: 3

Session: 6310936469860791894 // The session identifier that the server responds

Cache-control: No-Cache

Transport: RTP/AVP/tcp; unicast; interleaved = 0-1; SSRC = 6b8b4567

4. Play

The client sends a playback request:

Play rtsp: // 192.168.20.136: 5000/xxx666 RTSP/1.0

CSeq: 4

Session: 6310936469860791894

Range: NLE = 0.000-// set the playing time range

User-Agent: VLC Media Player (live555 streaming media v2005.11.10)

Server Response Information:

RTSP/1.0 200 OK

Server: userver 0.9.7 _ RC1

CSeq: 4

Session: 6310936469860791894

Range: Treaty = 0.000000-

RTP-Info: url = trackID = 0; seq = 17040; rtptime = 1467265309

// Seq and rtptime are both information in the RTP package.

5. teardown

The client initiates a close request:

Teardown rtsp: // 192.168.20.136: 5000/xxx666 RTSP/1.0

CSeq: 5

Session: 6310936469860791894

User-Agent: VLC Media Player (live555 streaming media v2005.11.10)

Server Response:

RTSP/1.0 200 OK

Server: userver 0.9.7 _ RC1

CSeq: 5

Session: 6310936469860791894

Connection: Close


The above methods are the most commonly used in the interaction process. Other important methods are as follows:

GET/set_parameter, pause, redirect, etc.

PS:

SDP format

V = <version>

O = <username> <session ID> <version> <network type> <address>

S = <session Name>

I = <Session Description>

U = <URI>

E = <email address>

P = <phone number>

C = <network type> <address type> <connection address>

B = <modifier >:< bandwidth-value>

T = <start time> <stop time>

R = <repeat interval> <active duration> <list of offsets from start-time>

Z = <adjustment time> <OFFSET> ....

K = <method>

K = <method >:< encryption key>

A = <attribute>

A = <attribute >:< value>

M = <media> <port> <transport> <FMT list>

V = (Protocol Version)

O = (owner/creator and session identifier)

S = (Session name)

I = * (session information)

U = * (URI description)

E = * (email address)

P = * (phone number)

C = * (connection information)

B = * (bandwidth information)

Z = * (Time Zone adjustment)

K = * (encryption key)

A = * (0 or multiple session attribute rows)

Time description:

T = (Session Activity time)

R = * (0 or repeated times)

Media description:

M = (media name and transfer address)

I = * (media title)

C = * (connection information-this field is optional if it is included in the Session Layer)

B = * (bandwidth information)

K = * (encryption key)

A = * (0 or multiple media attribute rows)

Reference: rfc2326 (RTSP); rfc2327 (SDP)

RTSP On-Demand message process instance (Client: VLC, RTSP server: live555 Media Server)


1) C (client)-> M (Media Server)

Options rtsp: // 192.168.1.109/1.mpg RTSP/1.0

CSeq: 1

User-Agent: VLC Media Player (live555 streaming media v2007.02.20)


1) m-> C

RTSP/1.0 200 OK

CSeq: 1

Date: Wed, Feb 20 2008 07:13:24 GMT

Public: Options, describe, setup, teardown, play, pause


2) c-> m

Describe rtsp: // 192.168.1.109/1.mpg RTSP/1.0.

CSeq: 2

Accept: Application/SDP

User-Agent: VLC Media Player (live555 streaming media v2007.02.20)


2) m-> C

RTSP/1.0 200 OK

CSeq: 2

Date: Wed, Feb 20 2008 07:13:25 GMT

Content-base: rtsp: // 192.168.1.109/1.mpg/

Content-Type: Application/SDP

Content-Length: 447

V = 0

O =-2284269756 1 in ip4 192.168.1.109

S = MPEG-1 or 2 Program Stream, streamed by the live555 Media Server

I = 1.mpg

T = 0 0

A = tool: live555 streaming media v2008.02.08

A = type: Broadcast

A = control :*

A = range: Treaty = 0-66.181

A = x-QT-text-nam: MPEG-1 or Program Stream, streamed by the live555 Media Server

A = x-QT-text-inf: 1.mpg

M = video 0 RTP/AVP 32

C = in ip4 0.0.0.0

A = control: track1

M = audio 0 RTP/AVP 14

C = in ip4 0.0.0.0

A = control: track2


3) c-> m

Setup rtsp: // 192.168.1.109/1.mpg/ track1 RTSP/1.0

CSeq: 3

Transport: RTP/AVP; unicast; client_port = 1112-1113

User-Agent: VLC Media Player (live555 streaming media v2007.02.20)


3) m-> C

RTSP/1.0 200 OK

CSeq: 3

Date: Wed, Feb 20 2008 07:13:25 GMT

Transport: RTP/AVP; unicast; Destination = 192.168.1.222; Source = 192.168.1.109; client_port = 1112-1113; server_port = 6970-6971

Session: 3


4) C-> m

Setup rtsp: // 192.168.1.109/1.mpg/ track2 RTSP/1.0

CSeq: 4

Transport: RTP/AVP; unicast; client_port = 1114-1115

Session: 3

User-Agent: VLC Media Player (live555 streaming media v2007.02.20)


4) m-> C

RTSP/1.0 200 OK

CSeq: 4

Date: Wed, Feb 20 2008 07:13:25 GMT

Transport: RTP/AVP; unicast; Destination = 192.168.1.222; Source = 192.168.1.109; client_port = 1114-1115; server_port = 6972-6973

Session: 3


5) C-> m

Play rtsp: // 192.168.1.109/1.mpg/ RTSP/1.0

CSeq: 5

Session: 3

Range: Treaty = 0.000-

User-Agent: VLC Media Player (live555 streaming media v2007.02.20)


5) m-> C

RTSP/1.0 200 OK

CSeq: 5

Range: Treaty = 0.000-

Session: 3

RTP-Info: url = rtsp: // 192.168.1.109/1.mpg/ track1; seq = 9200; rtptime = 214793785, url = rtsp: // 192.168.1.109/1.mpg/ track2; seq = 12770; rtptime = 1, 31721


(Start to transfer streaming media ...)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.