要做rtp/rtsp over http, 我对http也有点了解, 以前也做过rtp/rtsp over tcp/udp传输264视频流, 但刚开始还是没有一点思路,想着把http和rtp等联系到一起, 网上这方面的资料太少, 最后实在找不到想要的资料, 于是用开源的live555工程模拟了一个数据的交互过程, 相信对要做这方面的人有很大的帮助, 至少对于我, 呵呵。 下面是交互的过程: 客户端用openrtsp来模拟, 服务器用mediaserver来模拟(黄色字体表示接收到的, 红色表示发送出去的)。 openrtsp的打印信息如下: [root@www testProgs]# ./openRTSP -F first_ -T 80 rtsp://127.0.0.1/slamtv60.264 Opening connection to 127.0.0.1, port 80... ...remote connection opened Requesting RTSP-over-HTTP tunneling (on port 80) <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> Sending request:
GET /slamtv60.264 HTTP/1.0 CSeq: 1 User-Agent: ./openRTSP (LIVE555 Streaming Media v2011.03.14) x-sessioncookie: 754a0e506e8401d33572619 Accept: application/x-rtsp-tunnelled Pragma: no-cache Cache-Control: no-cache
Received 143 new bytes of response data. Received a complete GET response:
HTTP/1.0 200 OK Date: Thu, 19 Aug 1982 18:30:00 GMT Cache-Control: no-cache Pragma: no-cache Content-Type: application/x-rtsp-tunnelled
Opening connection to 127.0.0.1, port 80... ...remote connection opened Sending request:
POST /slamtv60.264 HTTP/1.0 CSeq: 1 User-Agent: ./openRTSP (LIVE555 Streaming Media v2011.03.14) x-sessioncookie: 754a0e506e8401d33572619 Content-Type: application/x-rtsp-tunnelled Pragma: no-cache Cache-Control: no-cache Content-Length: 32767 Expires: Sun, 9 Jan 1972 00:00:00 GMT
Sending request:
OPTIONS rtsp://127.0.0.1/slamtv60.264 RTSP/1.0 CSeq: 2 User-Agent: ./openRTSP (LIVE555 Streaming Media v2011.03.14)
The request was base-64 encoded to: T1BUSU9OUyBydHNwOi8vMTI3LjAuMC4xL3NsYW10djYwLjI2NCBSVFNQLzEuMA0KQ1NlcTog Mg0KVXNlci1BZ2VudDogLi9vcGVuUlRTUCAoTElWRTU1NSBTdHJlYW1pbmcgTWVkaWEgdjIw MTEuMDMuMTQpDQoNCg==
Received 152 new bytes of response data. Received a complete OPTIONS response:
RTSP/1.0 200 OK CSeq: 2 Date: Wed, Apr 13 2011 07:15:56 GMT Public: OPTIONS, DESCRIBE, SETUP, TEARDOWN, PLAY, PAUSE, GET_PARAMETER, SET_PARAMETER
Sending request:
DESCRIBE rtsp://127.0.0.1/slamtv60.264 RTSP/1.0 CSeq: 3 User-Agent: ./openRTSP (LIVE555 Streaming Media v2011.03.14) Accept: application/sdp
The request was base-64 encoded to:
REVTQ1JJQkUgcnRzcDovLzEyNy4wLjAuMS9zbGFtdHY2MC4yNjQgUlRTUC8xLjANCkNTZXE6ID MNClVzZXItQWdlbnQ6IC4vb3BlblJUU1AgKExJVkU1NTUgU3RyZWFtaW5nIE1lZGlhIHYyMDExLjA zLjE0KQ0KQWNjZXB0OiBhcHBsaWNhdGlvbi9zZHANCg0K
Received 689 new bytes of response data. Received a complete DESCRIBE response:
RTSP/1.0 200 OK CSeq: 3 Date: Wed, Apr 13 2011 07:15:56 GMT Content-Base: rtsp://127.0.0.1/slamtv60.264/ Content-Type: application/sdp Content-Length: 526
v=0 o=- 1302678956100984 1 IN IP4 192.168.77.111 s=H.264 Video, streamed by the LIVE555 Media Server i=slamtv60.264 t=0 0 a=tool:LIVE555 Streaming Media v2011.03.14 a=type:broadcast a=control:* a=range:npt=0- a=x-qt-text-nam:H.264 Video, streamed by the LIVE555 Media Server a=x-qt-text-inf:slamtv60.264 m=video 0 RTP/AVP 96 c=IN IP4 <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /> <?xml:namespace prefix = st1 /><?xml:namespace prefix = st1 />0.0.0.0 b=AS:500 a=rtpmap:96 H264/90000 a=fmtp:96 packetization-mode=1;profile-level-id=4D4033 ;sprop-parameter-sets=Z01AM5JUDAS0IAAAAwBAAAAM0eMGVA==,aO48gA== a=control:track1
Opened URL "rtsp://127.0.0.1/slamtv60.264", returning a SDP description: v=0 o=- 1302678956100984 1 IN IP4 192.168.77.111 s=H.264 Video, streamed by the LIVE555 Media Server i=slamtv60.264 t=0 0 a=tool:LIVE555 Streaming Media v2011.03.14 a=type:broadcast a=control:* a=range:npt=0- a=x-qt-text-nam:H.264 Video, streamed by the LIVE555 Media Server a=x-qt-text-inf:slamtv60.264 m=video 0 RTP/AVP 96 c=IN IP4 0.0.0.0 b=AS:500 a=rtpmap:96 H264/90000 a=fmtp:96 packetization-mode=1;profile-level-id=4D4033 ;sprop-parameter-sets=Z01AM5JUDAS0IAAAAwBAAAAM0eMGVA==,aO48gA== a=control:track1
Created receiver for "video/H264" subsession (client ports 50736-50737) Sending request:
SETUP rtsp://127.0.0.1/slamtv60.264/track1 RTSP/1.0 CSeq: 4 User-Agent: ./openRTSP (LIVE555 Streaming Media v2011.03.14) Transport: RTP/AVP/TCP;unicast;interleaved=0-1
The request was base-64 encoded to:
U0VUVVAgcnRzcDovLzEyNy4wLjAuMS9zbGFtdHY2MC4yNjQvdHJhY2sxIFJUU1AvMS4wDQp DU2VxOiA0DQpVc2VyLUFnZW50OiAuL29wZW5SVFNQIChMSVZFNTU1IFN0cmVhbWluZyBN ZWRpYSB2MjAxMS4wMy4xNCkNClRyYW5zcG9ydDogUlRQL0FWUC9UQ1A7dW5pY2FzdDtp bnRlcmxlYXZlZD0wLTENCg0K
Received 171 new bytes of response data. Received a complete SETUP response:
RTSP/1.0 200 OK CSeq: 4 Date: Wed, Apr 13 2011 07:15:56 GMT Transport: RTP/AVP/TCP;unicast;destination=127.0.0.1;source=127.0.0.1;interleaved=0-1 Session: 557663C7
Setup "video/H264" subsession (client ports 50736-50737) Created output file: "first_video-H264-1" Sending request:
PLAY rtsp://127.0.0.1/slamtv60.264/ RTSP/1.0 CSeq: 5 User-Agent: ./openRTSP (LIVE555 Streaming Media v2011.03.14) Session: 557663C7 Range: npt=0.000-
The request was base-64 encoded to:
UExBWSBydHNwOi8vMTI3LjAuMC4xL3NsYW10djYwLjI2NC8gUlRTUC8xLjANCkNTZXE6IDUNClVzZX ItQWdlbnQ6IC4vb3BlblJUU1AgKExJVkU1NTUgU3RyZWFtaW5nIE1lZGlhIHYyMDExLjAzLjE0KQ0KU2V zc2lvbjogNTU3NjYzQzcNClJhbmdlOiBucHQ9MC4wMDAtDQoNCg==
Received a complete PLAY response:
RTSP/1.0 200 OK CSeq: 5 Date: Wed, Apr 13 2011 07:15:56 GMT Range: npt=0.000- Session: 557663C7 RTP-Info: url=rtsp://127.0.0.1/slamtv60.264/track1;seq=8747;rtptime=3741659354
Started playing session Receiving streamed data (signal with "kill -HUP 6196" or "kill -USR1 6196" to terminate)... Received RTCP "BYE" on "video/H264" subsession (after 58 seconds) Sending request:
TEARDOWN rtsp://127.0.0.1/slamtv60.264/ RTSP/1.0 CSeq: 6 User-Agent: ./openRTSP (LIVE555 Streaming Media v2011.03.14) Session: 557663C7
The request was base-64 encoded to:
VEVBUkRPV04gcnRzcDovLzEyNy4wLjAuMS9zbGFtdHY2MC4yNjQvIFJUU1AvMS4wDQpDU2VxOiA2 DQpVc2VyLUFnZW50OiAuL29wZW5SVFNQIChMSVZFNTU1IFN0cmVhbWluZyBNZWRpYSB2MjAxM S4wMy4xNCkNClNlc3Npb246IDU1NzY2M0M3DQoNCg==
Received a complete TEARDOWN response:
RTSP/1.0 200 OK CSeq: 6 Date: Wed, Apr 13 2011 07:16:54 GMT
mediaserver的打印信息如下: rtRTSPClientSession[0x8f05890]::handleRequestBytes() read 224 new bytes:<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> GET /slamtv60.264 HTTP/1.0 CSeq: 1 User-Agent: ./openRTSP (LIVE555 Streaming Media v2011.03.14) x-sessioncookie: 754a0e506e8401d33572619 Accept: application/x-rtsp-tunnelled Pragma: no-cache Cache-Control: no-cache
RTSPClientSession[0x8f0a800]::handleRequestBytes() read 457 new bytes:
POST /slamtv60.264 HTTP/1.0 CSeq: 1 User-Agent: ./openRTSP (LIVE555 Streaming Media v2011.03.14) x-sessioncookie: 754a0e506e8401d33572619 Content-Type: application/x-rtsp-tunnelled Pragma: no-cache Cache-Control: no-cache Content-Length: 32767 Expires: Sun, 9 Jan 1972 00:00:00 GMT
T1BUSU9OUyBydHNwOi8vMTI3LjAuMC4xL3NsYW10djYwLjI2NCBSVFNQLzEuMA0KQ1N lcTogMg0KVXNlci1BZ2VudDogLi9vcGVuUlRTUCAoTElWRTU1NSBTdHJlYW1pbmcgTWVka WEgdjIwMTEuMDMuMTQpDQoNCg==
RTSPClientSession[0x8f05890]::handleRequestBytes() read 164 new bytes:
T1BUSU9OUyBydHNwOi8vMTI3LjAuMC4xL3NsYW10djYwLjI2NCBSVFNQLzEuMA0KQ1Nl cTogMg0KVXNlci1BZ2VudDogLi9vcGVuUlRTUCAoTElWRTU1NSBTdHJlYW1pbmcgTWVkaW EgdjIwMTEuMDMuMTQpDQoNCg==
RTSPClientSession[0x8f05890]::handleRequestBytes() read 196 new bytes:
REVTQ1JJQkUgcnRzcDovLzEyNy4wLjAuMS9zbGFtdHY2MC4yNjQgUlRTUC8xLjANCkNTZX E6IDMNClVzZXItQWdlbnQ6IC4vb3BlblJUU1AgKExJVkU1NTUgU3RyZWFtaW5nIE1lZGlhIHYy MDExLjAzLjE0KQ0KQWNjZXB0OiBhcHBsaWNhdGlvbi9zZHANCg0K
RTSPClientSession[0x8f05890]::handleRequestBytes() read 232 new bytes:
U0VUVVAgcnRzcDovLzEyNy4wLjAuMS9zbGFtdHY2MC4yNjQvdHJhY2sxIFJUU1AvMS4wDQp DU2VxOiA0DQpVc2VyLUFnZW50OiAuL29wZW5SVFNQIChMSVZFNTU1IFN0cmVhbWluZyBN ZWRpYSB2MjAxMS4wMy4xNCkNClRyYW5zcG9ydDogUlRQL0FWUC9UQ1A7dW5pY2FzdDtpb nRlcmxlYXZlZD0wLTENCg0K
RTSPClientSession[0x8f05890]::handleRequestBytes() read 212 new bytes:
UExBWSBydHNwOi8vMTI3LjAuMC4xL3NsYW10djYwLjI2NC8gUlRTUC8xLjANCkNTZXE6IDU NClVzZXItQWdlbnQ6IC4vb3BlblJUU1AgKExJVkU1NTUgU3RyZWFtaW5nIE1lZGlhIHYyMDExLjA zLjE0KQ0KU2Vzc2lvbjogNTU3NjYzQzcNClJhbmdlOiBucHQ9MC4wMDAtDQoNCg==
RTSPClientSession[0x8f05890]::handleRequestBytes() read 192 new bytes:
VEVBUkRPV04gcnRzcDovLzEyNy4wLjAuMS9zbGFtdHY2MC4yNjQvIFJUU1AvMS4wDQpDU2VxO iA2DQpVc2VyLUFnZW50OiAuL29wZW5SVFNQIChMSVZFNTU1IFN0cmVhbWluZyBNZWRpYSB2 MjAxMS4wMy4xNCkNClNlc3Npb246IDU1NzY2M0M3DQoNCg== (rongpmcu) |