Standard RTSP/RTP is not sufficient to reach users on private IP networks behind firewalls where HTTP proxy servers provide clients with indirect access to the Internet.
We refer to Apple's "Tunneling RTSP/RTP over HTTP" technique to overcome the firewall problem.
This protocol is based on HTTP Get and Post method.
The RTSP signaling was carried by the first HTTP session. The client send the HTTP request to the server to establish the the HTTP session. The x-sessioncookie is used for the second HTTP session for RTSP signaling session. As the server response the request, the client establishes the second HTTP session associated with the x-sessioncookie in the first HTTP session to uploads the RTSP signaling to the server. The RTSP signaling will be encoded by BASE64 coding scheme.As the RTSP signaling is completed, the server starts to send the media streams to the client through the first HTTP session. The second HTTP session keeps alive for the RTSP command handshaking.
The RTSP URI in HTTP tunneling applications is well-defined strings. It is /unicast/median.
The n is the streaming ID and started form 1. It represents the video source and audio media if AUDIO_IN function is enabled.
For example,
1. The URI /unicast/media1 requests the video source 1 (video channel ID=1) and audio media in the audio enabled camera (dual streaming mode).
2. The URI /unicast/media2 requests the video source 2 (video channel ID=2) only in the audio disabled camera (dual streaming mode).
In this example, it shows how the RTSP signaling was carried in the HTTP session. The HTTP message in red is the client's message. The HTTP message in blue is the server's message. The text in green are not the message between the client and server. It is the decoded message of the RTSP command in the HTTP session.
Client:
GET GET /unicast/media1 HTTP/1.1
x-sessioncookie: 413610d3d97250aabb9ffb2683e07922
Accept: application/x-rtsp-tunnelled
Connection: Keep-Alive
User-Agent: ARTSPHTTP
Host: 172.16.1.107
Cache-Control: no-cache
Pragma: no-cacheServer:
GET HTTP/1.0 200 OK
Server: ACTi RTP Server v1.0
Connection: Keep-Alive
Date: Thu, 19, Aug 1982 18:30:00 GMT
Cache-Control: no-cache
Pragma: no-cache
Content-Type: application/x-rtsp-tunnelledClient creates the other HTTP socket to sent the POST request to carry RTSP message to server then. The RTSP message was encoded by base64.
Client: (RTSP DESCRIBE Command)
POST POST unicast/media1 HTTP/1.1
x-sessioncookie: 413610d3d97250aabb9ffb2683e07922
Content-Type: application/x-rtsp-tunnelled
Connection: Keep-Alive
User-Agent: ARTSPHTTP
Host: 172.16.1.107
Content-Length: 32767
Cache-Control: no-cache
Pragma: no-cache
REVTQ1JJQkUgcnRzcDovLzE3Mi4xNi4zLjE0NC91bmljYXN0L21lZGlhMSBSVFNQLzEuMA0KQ1NlcTogMTg0DQpBY2NlcHQ6IGFwc
GxpY2F0aW9uL3NkcA0KQXV0aG9yaXphdGlvbjogRGlnZXN0IHVzZXJuYW1lPSJhZG1pbiIsIHJlYWxtPSJSVFNQIFNlcnZlciIsIG5vbmNl
PSI0NTk4NTRhNzY0MjQxMTllMDlkY2FhZDRhY2YyMWIxMDI3MWEzMzU3ODhiODM3MmJjNzdhM2Q4YTJiODhmOTE0IiwgdXJpPSJ
ydHNwOi8vMTcyLjE2LjMuMTQ0L3VuaWNhc3QvbWVkaWExIiwgcmVzcG9uc2U9IjA0M2UxMzU5NDBjZDdhNGYzODk5YmRjOTExZj
A0NWVjIg0KVXNlci1BZ2VudDogUlRTUE92ZXJIVFRQIFNhbXBsZSANCg0KRTSP CMD DESCRIBE rtsp://172.16.3.144/unicast/media1 RTSP/1.0
CSeq: 184
Accept: application/sdp
Authorization: Digest username="admin", realm="RTSP Server", nonce="459854a76424119e09dcaad4acf21b10271a335788b8372bc77a3d8a2b88f914", uri="rtsp://172.16.3.144/unicast/media1", response="043e135940cd7a4f3899bdc911f045ec"
User-Agent: RTSPOverHTTP SampleServer replies the POST request on the previous GET session. The Content-Length in POST request header should be ignored because it might not associated with the length of the RTSP message.
Server:
GET RTSP/1.0 200 OK
CSeq: 24697
Content-Base: rtsp://172.16.1.107:7070/mpeg4/1/media.amp/
Content-Type: application/sdp
Content-Length: 790
v=0
o=- 2875592057 2875592068 IN IP4 172.16.1.107
s=Media Presentation
e=NONE
c=IN IP4 0.0.0.0
b=AS:3064
t=0 0
a=control:*
a=range:npt=now-
a=mpeg4-iod: "data:application/mpeg4-iod;base64,AoEAAE8BAf70AQOAkwABQHRkYXRhOmFwcGxpY2F0aW9uL21wZWc0LW9k
LWF1O2Jhc2U2NCxBVGdCR3dVZkF4Y0F5U1FBWlFRTklCRUVrK0FBTGNiQUFDM0d3QVlCQkFFWkFwOERGUUJsQlFRTlFCVU
FDN2dBQVBvQUFBRDZBQVlCQXc9PQQNAQUABAAAAAAAAAAAAAYJAQAAAAAAAAAAA0IAAkA+ZGF0YTphcHBsaWNhdGlv
bi9tcGVnNC1iaWZzLWF1O2Jhc2U2NCx3QkFTZ1RBcUJYSmhCSWhRUlFVL0FBPT0EEgINAAACAAAAAAAAAAAFAwAAQAYJA
QAAAAAAAAAA"
m=video 0 RTP/AVP 96
b=AS:3000
a=framerate:8.0
a=control:trackID=1
a=rtpmap:96 MP4V-ES/90000
a=fmtp:96 profile-level-id=244; config=000001B0F4000001B5891300000100000001200086C40FA28A021E0A21
a=mpeg4-esid:201
m=audio 0 RTP/AVP 0
b=AS:64
a=control:trackID=2Client keeps sending its RTSP message on the POST session as server replied OK.
Client: (RTSP SETUP Command)
POST U0VUVVAgcnRzcDovLzE3Mi4xNi4zLjE0NC91bmljYXN0L21lZGlhMS90cmFjazEgUlRTUC8xLjANCkNTZXE6IDE4NQ0KVHJhbnNwb3J
0OiBSVFAvQVZQL1RDUDt1bmljYXN0O2ludGVybGVhdmVkPTAtMQ0KQXV0aG9yaXphdGlvbjogRGlnZXN0IHVzZXJuYW1lPSJhZG1p
biIsIHJlYWxtPSJSVFNQIFNlcnZlciIsIG5vbmNlPSI0NTk4NTRhNzY0MjQxMTllMDlkY2FhZDRhY2YyMWIxMDI3MWEzMzU3ODhiODM
3MmJjNzdhM2Q4YTJiODhmOTE0IiwgdXJpPSJydHNwOi8vMTcyLjE2LjMuMTQ0L3VuaWNhc3QvbWVkaWExIiwgcmVzcG9uc2U9IjA0
M2UxMzU5NDBjZDdhNGYzODk5YmRjOTExZjA0NWVjIg0KVXNlci1BZ2VudDogUlRTUE92ZXJIVFRQIFNhbXBsZQ0KDQo=
RTSP CMD SETUP rtsp://172.16.3.144/unicast/media1/track1 RTSP/1.0
CSeq: 185
Transport: RTP/AVP/TCP;unicast;interleaved=0-1
Authorization: Digest username="admin", realm="RTSP Server", nonce="459854a76424119e09dcaad4acf21b10271a335788b8372bc77a3d8a2b88f914", uri="rtsp://172.16.3.144/unicast/media1", response="043e135940cd7a4f3899bdc911f045ec"
User-Agent: RTSPOverHTTP SampleServer replies the POST request on the previous GET session.
Server:
GET RTSP/1.0 200 OK
CSeq: 185
Transport: RTP/AVP/TCP;unicast;interleaved=0-1
Session: BB6F2219BA9B7DF50BE11A1C7F23F8Client keeps sending its RTSP message on the POST session as server replied OK.
Client:(RTSP PLAY Command)
POST UExBWSBydHNwOi8vMTcyLjE2LjMuMTQ0L3VuaWNhc3QvbWVkaWExIFJUU1AvMS4wDQpDU2VxOiAxODYNClNlc3Npb246IEJCN
kYyMjE5QkE5QjdERjUwQkUxMUExQzdGMjNGOA0KUmFuZ2U6IG50cD0wLjAwMDAtDQpBdXRob3JpemF0aW9uOiBEaWdlc3QgdX
Nlcm5hbWU9ImFkbWluIiwgcmVhbG09IlJUU1AgU2VydmVyIiwgbm9uY2U9IjQ1OTg1NGE3NjQyNDExOWUwOWRjYWFkNGFjZjIxYjE
wMjcxYTMzNTc4OGI4MzcyYmM3N2EzZDhhMmI4OGY5MTQiLCB1cmk9InJ0c3A6Ly8xNzIuMTYuMy4xNDQvdW5pY2FzdC9tZWRpY
TEiLCByZXNwb25zZT0iMDQzZTEzNTk0MGNkN2E0ZjM4OTliZGM5MTFmMDQ1ZWMiDQpVc2VyLUFnZW50OiBSVFNQT3ZlckhUVFA
gU2FtcGxlIA0KDQo=RTSP CMD PLAY rtsp://172.16.3.144/unicast/media1 RTSP/1.0
CSeq: 186
Session: BB6F2219BA9B7DF50BE11A1C7F23F8
Range: ntp=0.0000-
Authorization: Digest username="admin", realm="RTSP Server", nonce="459854a76424119e09dcaad4acf21b10271a335788b8372bc77a3d8a2b88f914", uri="rtsp://172.16.3.144/unicast/media1", response="043e135940cd7a4f3899bdc911f045ec"
User-Agent: RTSPOverHTTP SampleServer replies the POST request on the previous GET session and streams the media data to client.
Server:
GET RTSP/1.0 200 OK
CSeq: 186
Session: BB6F2219BA9B7DF50BE11A1C7F23F8
RTP-Info: url=rtsp://172.16.3.144/unicast/media1/track1;seq=23573;rtptime=1195921635
.....................................................