2012-06-08 5 views
5

네트워크 IP 카메라 (Canon VB-M40)가 있습니다. 이 카메라는 ONVIF 프로토콜을 지원합니다. Windows에서 ONVIF 기능을 C 언어를 사용하여 구현하고 있습니다. 다음 요청을 사용하여 RTSP URI를 얻었습니다. 내가 스트림 URI를 일단 내가 장치에 요청을 보내 'DESCRIBE'한다, ONVIF 사양에 따라ONVIF 프로토콜을 지원하는 네트워크 IP 카메라에서 실시간 스트리밍을 받으시겠습니까?

<?xml version="1.0" encoding="UTF-8"?> 
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" 
        xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" 
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
        xmlns:wsa5="http://www.w3.org/2005/08/addressing" 
        xmlns:c14n="http://www.w3.org/2001/10/xml-exc-c14n#" 
        xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" 
        xmlns:ds="http://www.w3.org/2000/09/xmldsig#" 
        xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" 
        xmlns:MC2="http://www.onvif.org/ver10/schema" 
        xmlns:MC3="http://www.w3.org/2005/05/xmlmime" 
        xmlns:MC4="http://docs.oasis-open.org/wsn/b-2" 
        xmlns:MC10="http://www.w3.org/2004/08/xop/include" 
        xmlns:MC5="http://docs.oasis-open.org/wsrf/bf-2" 
        xmlns:MC6="http://docs.oasis-open.org/wsn/t-1" 
        xmlns:CC="http://www.canon.com/ns/networkcamera/onvif/va/schema" 
        xmlns:MC1="http://www.onvif.org/ver10/media/wsdl" 
        xmlns:MC8="http://www.onvif.org/ver20/analytics/wsdl/RuleEngineBinding" 
        xmlns:MC9="http://www.onvif.org/ver20/analytics/wsdl/AnalyticsEngineBinding" 
        xmlns:MC7="http://www.onvif.org/ver20/analytics/wsdl" 
        xmlns:ter="http://www.onvif.org/ver10/error" 
        xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" 
        xmlns:tns1="http://www.onvif.org/ver10/topics"> 
    <SOAP-ENV:Header></SOAP-ENV:Header> 
    <SOAP-ENV:Body> 
     <MC1:GetStreamUriResponse> 
      <MC1:MediaUri> 
       <MC2:Uri>rtsp://192.168.5.53:8090/profile1=r</MC2:Uri> 
       <MC2:InvalidAfterConnect>false</MC2:InvalidAfterConnect> 
       <MC2:InvalidAfterReboot>true</MC2:InvalidAfterReboot> 
       <MC2:Timeout>PT0M0S</MC2:Timeout> 
      </MC1:MediaUri> 
     </MC1:GetStreamUriResponse> 
    </SOAP-ENV:Body> 
</SOAP-ENV:Envelope> 

:

snprintf(postData, sizeof(postData), 
     "<?xml version=\"1.0\" encoding=\"utf-8\"?>" 
     "<soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" " 
     "xmlns:tds=\"http://www.onvif.org/ver10/media/wsdl\"" 
     "xmlns:tt=\"http://www.onvif.org/ver10/schema\">"    
     "<soap:Body>" 
     "<tds:GetStreamUri>" 
     "<tds:StreamSetup>" 
      "<tt:Stream>0</tt:Stream>" 
      "<tt:Transport>" 
      "<tt:Protocol>HTTP</tt:Protocol>" 
      "</tt:Transport>" 
     "</tds:StreamSetup>" 
     "<tds:ProfileToken>profile1</tds:ProfileToken>" 
     "</tds:GetStreamUri>" 
     "</soap:Body></soap:Envelope>", 
     username, digest_str, nonce_str, time_str); 

는하고 응답입니다. TCP에서 스트림이 필요하기 때문에이 절차를 사용하고 있습니다.

제 질문은 'DESCRIBE'요청을 장치 및 소켓에 보내는 방법입니다.

GetStreamURI 요청을 보낸 동일한 소켓에서이 요청을 보내야합니까? 아니면 다른 하나를 만들어야합니다. 그러면 요청 형식은 어떻게됩니까?

답변

3

포트 554 (또는 RTSP 용으로 장치에 구성된 다른 포트)에서 GetStreamUri 요청과 동일한 호스트로 보냅니다. 그런 다음 DESCRIBE 전에 OPTIONS 요청을 보내야합니다. 아마 401 Unauthorized status와 nonce + realm 값을 몸체에 반환 할 것입니다. 는 (내가. 당신이 당신의 GetStreamUri 응답에 받았다 개의 다른 주소를 사용하고 있습니다)

Request: 
OPTIONS http://192.168.128.99:80/profile1/media.smp RTSP/1.0\r\n 
CSeq: 1\r\n 
User-Agent: MyAgent\r\n\r\n 

Response: 
RTSP/1.0 401 Unauthorized 
CSeq: 1 
Date: Thu Jun 28 05:39:55 2012 GMT 
Expires: Thu Jun 28 05:39:55 2012 GMT 
Cache-Control: must-revalidate 
WWW-Authenticate: Digest realm="iPOLiS", nonce="00000000000000000000000048E02F14" 

는 autorization 위해 필요하기 때문에,이 영역 및 비표 값을 읽고 다른, 허가 OPTIONS 요청을 보냅니다. HTTP : //192.168

OPTIONS http://192.168.128.99:80/profile1/media.smp RTSP/1.0\r\n 
CSeq: 2\r\n 
Authorization: Digest username="admin", realm="iPOLiS", nonce="00000000000000000000000048E02F14", uri="http://192.168.128.99:80/profile1/media.smp", response="23a5a81fb98b6cb29368eba060ba31b9"\r\n 
User-Agent: MyAgent\r\n\r\n 

응답

this way 그럼 A = 컨트롤이 응답 주소 요청

DESCRIBE http://192.168.128.99:80/profile1/media.smp RTSP/1.0\r\n 
CSeq: 3\r\n 
User-Agent: MyAgent\r\n\r\n 

응답

RTSP/1.0 200 OK 
CSeq: 3 
Date: Thu Jun 28 05:46:20 2012 GMT 
Expires: Thu Jun 28 05:46:20 2012 GMT 
Content-Base: http://192.168.128.99:554/profile1/media.smp/ 
Content-Type: application/sdp 
Content-Length: 498 
x-Accept-Retransmit: our-retransmit 
x-Accept-Dynamic-Rate: 1 
Cache-Control: must-revalidate 

v=0 
o=- 0 0 IN IP4 192.168.128.9 
s=Media Presentation 
i=samsung 
c=IN IP4 0.0.0.0 
b=AS:384128 
t=0 0 
a=control:http://192.168.128.99:554/profile1/media.smp 
a=range:npt=now- 
m=video 40336 RTP/AVP 26 
b=AS:384000 
a=rtpmap:26 JPEG/90000 
a=control:http://192.168.128.99:554/profile1/media.smp/trackID=v 
a=cliprect:0,0,768,1024 
a=framesize:26 1024-768 
a=framerate:5.0 
m=audio 40338 RTP/AVP 0 
b=AS:64 
a=rtpmap:0 PCMU/8000 
a=control:http://192.168.128.99:554/profile1/media.smp/trackID=a 

에게 DESCRIBE 올 생성한다. 128.99 : 554/profile1/media.smp/trackID = v 미디어에 대해 구문 분석되어야 함 m = video (SDP pr otocol). 그게 내가 얼마나 멀리했는지. 다음 절차는 전송 정보로 SETUP 요청을 한 다음 PLAY 요청을 보내야합니다. 이미지 수신을 위해 SETUP 요청에서 지정한 포트에서 청취해야합니다.

+1

GetStreamUri가'rtsp : //192.168.5.53 : 8090/profile1 = r'을 반환하면 연결할 RTSP 서버가 포트 554에 없습니다. – mpromonet