RTSP and RTP for streaming
Real Time Streaming Protocol (RTSP) is the best choice for what it is designed for - streaming. To the contrary of what it may appear to be, RTSP plays only a small, nevertheless important role in streaming. The bulk of the work is done by the protocol responsible for the transmission of the data which usually is Real-time Transport Protocol (RTP) which includes a companion protocol - RTP Control Protocol(RTCP).
Microsoft has a very good document about RTSP. Though it is about their extension, but it covers RTSP with good explanation.
RTSP uses port 554 by default. This port, like many other ports, are often blocked by firewalls. Tunnelling RTSP and RTP through HTTP is used to overcome this. QuickTime supports this tunnelling. To test an RTSP stream over HTTP, one can set the transport protocol of QuickTime player to HTTP (Edit > Preferences > Quicktime Preferences ... > Advanced > Transport Setup > Custom... >), and use a URL indicates it is RTSP stream (e.g. rtsp://stream_source_ip/mystream.amp). Tunnelling RTSP and RTP through HTTP is essentially multiplexing RTP and its RTCP control packets, but it does not use the proposed standard for Multiplexing RTP Data and Control Packets on a Single Port.
Using RTSP with Firewalls, Proxies, and Other Intermediary Network Devices is a very good document for starters. Implementation has to rely on the RTSP protocol which also has a section (Appendix C) descrbing Session Description Protocol (SDP), which is all one needs to know about SDP for implementing the support for RTSP
A typical process for streaming using RTSP over HTTP is the following:
Client -> Server: GET request to establish the channel to receive responses and data from the server.
Client -> Server: POST request to open the channel for sending commands. This channel is bound to the GET channel by header "x-sessioncookie", so it can be closed and opened unlimited times.
The section of Real-time Transport Protocol dealing wth RSTP over HTTP is 10.12 Embedded (Interleaved) Binary Data that describes how RTP packet is packeged in TCP data stream.
TCP packet is relatively simple. It consits of a small header and a payload. The format of payload depends of its content. Different types of payloads correspond to different profiles that are usually defined by respective protocols. For example, H.264, the current most popular and very efficient video compression algorithm, has rfc3894 as its protocol for RTP packet payload.
The following is an example of typical exchanges between a client and a server to start a streaming session:
Client -> Server
DESCRIBE rtsp://192.168.0.95/axis-media/media.amp?videocodec=h264 RTSP/1.0
CSeq: 1
Accept: application/sdp
Bandwidth: 512000
Accept-Language: en-US
User-Agent: QuickTime/7.7 (qtver=7.7;os=Windows NT 6.1Service Pack 1)
Server -> Client
RTSP/1.0 200 OK
CSeq: 1
Content-Type: application/sdp
Content-Base: rtsp://192.168.0.95/axis-media/media.amp/
Date: Sun, 11 Sep 2011 13:09:56 GMT
Content-Length: 520
v=0
o=- 1315746596845071 1315746596845071 IN IP4 192.168.0.95
s=Media Presentation
e=NONE
c=IN IP4 0.0.0.0
b=AS:50000
t=0 0
a=control:rtsp://192.168.0.95/axis-media/media.amp?videocodec=h264
a=range:npt=0.000000-
m=video 0 RTP/AVP 96
b=AS:50000
a=framerate:30.0
a=transform:1,0,0;0,1,0;0,0,1
a=control:rtsp://192.168.0.95/axis-media/media.amp/trackID=1?videocodec=h264
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1; profile-level-id=420029; sprop-parameter-sets=Z0IAKeNQFAe2AtwEBAaQeJEV,aM48gA==
Client -> Server
SETUP rtsp://192.168.0.95/axis-media/media.amp/trackID=1?videocodec=h264 RTSP/1.0
CSeq: 2
Transport: RTP/AVP/TCP;unicast
x-dynamic-rate: 1
x-transport-options: late-tolerance=2.900000
User-Agent: QuickTime/7.7 (qtver=7.7;os=Windows NT 6.1Service Pack 1)
Accept-Language: en-US
Server -> Client
RTSP/1.0 200 OK
CSeq: 2
Session: 01AB7016; timeout=60
Transport: RTP/AVP/TCP;unicast;interleaved=0-1;ssrc=9E23359A;mode="PLAY"
Date: Sun, 11 Sep 2011 13:09:57 GMT
Client -> Server
PLAY rtsp://192.168.0.95/axis-media/media.amp?videocodec=h264 RTSP/1.0
CSeq: 3
Range: npt=0.000000-
x-prebuffer: maxtime=2.000000
Session: 01AB7016
User-Agent: QuickTime/7.7 (qtver=7.7;os=Windows NT 6.1Service Pack 1)
Server -> Client
RTSP/1.0 200 OK
CSeq: 3
Session: 01AB7016
Range: npt=0-
RTP-Info: url=rtsp://192.168.0.95/axis-media/media.amp/trackID=1?videocodec=h264;seq=14301;rtptime=2323204970
Date: Sun, 11 Sep 2011 13:09:57 GMT