分类: C/C++
2017-07-28 17:14:36
ONVIF2.0协议如下:
原理说明:
1、
客户端和服务器之间建立一个双向的连接。使用RTSP协议[ RFC 2326]对反向通道连接进行处理。这里将存在一种机制用于表明客户端想建立一个往回通道连接。 RTSP提供了功能标签来处理这样的附加的功能。
支持双向连接的设备(如音频或元数据连接)应该支持已经介绍RTSP扩展。
2、
[ RFC 2326]的RTSP标准,可以用附加对象头进行扩展。为了这个目的,将引进一个请求的标签来处理专门的附加功能(见RFC2326] ,1.5扩展RTSP和12.32需求)
请求标签是用来判断是否支持此功能。这头应包含任何请求并且要求服务器理解这些特性并能够正确对这些请求进行应答。
支持反向通道的一种装置,应当理解的反向通道的标签:
希望建立具有数据反向通道的RTSP连接的客户应该在请求信息中包括请求的Require头
3、
客户端应当在它的描述请求中包括特性标签,用以表明应该建立双向数据连接。
理解这一要求标签的服务器应在SDP协议中包含一个正如在媒体类别的配置一样的额外流媒体。
根据的RTSP标准,一个不理解的反向通道的特性标签或不支持双向数据连接RTSP服务器会响应错误代码551 Option not supported。然后,客户端可以尝试建立一个没有反向通道RTSP连接。
一个SDP的文件被用来描述会话。服务器应在每一个媒体选项中包括一个a= sendonly或b= recvonly属性来表明将要发送数据的方向。
服务器应该列举出所有支持的解码规则作为自己媒介选项以及客户应该选择哪一种。
我的RTSP信令如下:
time:1495797881.558125; send request [OPTIONS rtsp://192.168.8.9:8554/1 RTSP/1.0
CSeq: 1
User-Agent: Lavf57.56.100
]
time:1495797881.558452;set pRequestMst finish
time:1495797881.570014;OnOptionsResponse 1
time:1495797881.570432;send buff len = 153,buf = [[0RTSP/1.0 200 OK
CSeq: 1
Date: Fri, May 26 2017 11:24:40 GMT
Public: OPTIONS, DESCRIBE, SETUP, TEARDOWN, PLAY, PAUSE, GET_PARAMETER, SET_PARAMETER
]]
time:1495797881.576634; send request [DESCRIBE rtsp://192.168.8.9:8554/1 RTSP/1.0
Accept: application/sdp
CSeq: 2
User-Agent: Lavf57.56.100
Require:
] time:1495797884.851540;send buff len = 978,buf = [[0RTSP/1.0 200 OK
CSeq: 2
Date: Fri, May 26 2017 11:24:44 GMT
Content-Base: rtsp://127.0.0.1:50164/camera/0/01020304050607080900
Content-Type: application/sdp
Content-Length: 792
v=0
o=- 1495797858134194 1 IN IP4 192.168.8.9
s=Session streamed by "RTSPServer"
i=1
t=0 0
a=tool:LIVE555 Streaming Media v2014.07.18
a=type:broadcast
a=control:rtsp://192.168.8.9:8554/1
a=range:npt=0-
a=x-qt-text-nam:Session streamed by "RTSPServer"
a=x-qt-text-inf:1
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=42C01F;sprop-parameter-sets=Z0LAH7kQCgC3QgAAAwACAAADAFEeMGVA,aM48gA==
a=recvonly;
a=control:rtsp://192.168.8.9:8554/1/trackID=1
m=audio 0 RTP/AVP 8
c=IN IP4 0.0.0.0
b=AS:96
a=rtpmap:8 PCMA/8000
a=recvonly;
a=control:rtsp://192.168.8.9:8554/1/trackID=2
m=audio 0 RTP/AVP 8
c=IN IP4 0.0.0.0
b=AS:8
a=rtpmap:8 PCMA/8000
a=sendonly;
a=control:rtsp://192.168.8.9:8554/1/trackID=3
]]
time:1495797884.879539; send request [SETUP rtsp://192.168.8.9:8554/1/trackID=1 RTSP/1.0
Transport: RTP/AVP/UDP;unicast;client_port=15550-15551
CSeq: 3
User-Agent: Lavf57.56.100
]
time:1495797884.921316;send buff len = 207,buf = [[0RTSP/1.0 200 OK
CSeq: 3
Date: Fri, May 26 2017 11:24:44 GMT
Transport: RTP/AVP;unicast;destination=192.168.8.1;source=192.168.8.9;client_port=20006-20007;server_port=0-1
Session: 1AC69105;timeout=65
]]
time:1495797884.921602;SendResponse ok
time:1495797884.961160; send request [SETUP rtsp://192.168.8.9:8554/1/trackID=2 RTSP/1.0
Transport: RTP/AVP/UDP;unicast;client_port=15550-15551
CSeq: 4
User-Agent: Lavf57.56.100
Session: 1AC69105
]time:1495797884.971279;send buff len = 196,buf = [[0RTSP/1.0 200 OK
CSeq: 4
Date: Fri, May 26 2017 11:24:44 GMT
Transport: RTP/AVP;unicast;destination=192.168.8.1;source=192.168.8.9;client_port=20008-20009;server_port=0-1
Session: 1AC69105
]]
time:1495797884.993622; send request [SETUP rtsp://192.168.8.9:8554/1/trackID=3 RTSP/1.0
Transport: RTP/AVP/UDP;unicast;client_port=15554-15555
CSeq: 4
User-Agent: Lavf57.56.100
Session: 1AC69105
Require:
]
time:1495797885.6728;OnSetupResponse 4
time:1495797885.6856;strTransPort
RTP/AVP;unicast;destination=192.168.8.1;source=192.168.8.9;client_port=15554-15555;server_port=6974-6975
time:1495797885.6925;receive backChannel ,transport =
RTP/AVP;unicast;destination=192.168.8.1;source=192.168.8.9;client_port=15554-15555;server_port=6974-6975
time:1495797885.7004;m_iBackChannelServerPort := 6974,6975
time:1495797885.7075;delete pMsgLst finish
time:1495797885.197751;receive play 11
time:1495797885.197859;send request info
time:1495797885.197917;OnPlayRequest 5
time:1495797885.197968;m_cSeqNo = 3
time:1495797885.198013;m_bHasReceiveBackChannelInfo = 1
time:1495797885.198059;send play msg
time:1495797885.198129;sendRequest 5
time:1495797885.198354; send request [PLAY rtsp://192.168.8.9:8554/1 RTSP/1.0
Range: npt=0.000-
CSeq: 5
User-Agent: Lavf57.56.100
Session: 1AC69105
Require:
]
time:1495797885.198474;set pRequestMst finish
time:1495797885.212947;OnPlayResponse 5
time:1495797885.213324;strRTP
url=rtsp://192.168.8.9:8554/1/trackID=1;seq=50197;rtptime=675344710,url=rtsp://192.168.8.9:8554/1/trackID=2;seq=27630;rtptime=2250740295,url=rtsp://192.168.8.9:8554/1/trackID=3;seq=0;rtptime=0
time:1495797885.213823;send buff len = 352,buf = [[0RTSP/1.0 200 OK
CSeq: 5
Date: Fri, May 26 2017 11:24:44 GMT
Range: npt=0.000-
Session: 1AC69105
RTP-Info:
url=rtsp://127.0.0.1:50164/camera/0/0102030405060708090092.168.8.9:8554/1/trackID=1;seq=50197;rtptime=675344710,url=rtsp://192.168.8.9:8554/1/trackID=2;seq=27630;rtptime=2250740295,url=rtsp://192.168.8.9:8554/1/trackID=3;seq=23230;rtptime=2153740195
]]