目前視頻監(jiān)控中網(wǎng)絡(luò)訪問很多還是C/S結(jié)構(gòu),不過B/S將更方便,通過對一款DVR的分析,添加一個web server,流程如下,記錄一下,免得以后用時忘記;
1.移植boa、goahead等開源web服務(wù)器軟件一個;
2.寫index.htm,如:
<html> <head> <title>NetServeillance WEB</title> </head> <body topmargin="0" leftmargin="0"> <div align="center"> <table border="0" cellspacing="0" cellpadding="0" width="100%" height="100%"> <tr> <td> <object classid="CLSID:3FB84210-0311-49BA-AFF7-A2C50E2D20B6" codebase="webrec.cab#version=1,0,0,9" width="100%" height="100%" id="Surveil"> <param name="usertype" value="0"> <param name="clienttype" value="0"> <param name="hostport" value="34567"> <param name="ipaddress" value="127.0.0.1"> </object> </td> </tr> <center> </table> </center> </div> </body> </html>
3. 上面代碼中有一句最關(guān)鍵,即
<object classid="CLSID:3FB84210-0311-49BA-AFF7-A2C50E2D20B6" codebase="webrec.cab#version=1,0,0,9" width="100%" height="100%" id="Surveil">,
而webrec.cab包括如下文件:
|-- AmrDll.dll |-- hi_h264dec_w.dll |-- ptz_down.bmp |-- replayer_config.ini .
.
. |-- theme.ini |-- users.xml |-- web.inf
又由于html有如下屬性:
當(dāng)Web頁上OBJECT元素的CODEBASE特性引用包含.INF文件的. CAB文件時,Internet Explorer將自動把.CAB文件作為軟件分發(fā)單位下載并安裝,每次訪問時還會自動檢測版本并進(jìn)行更新;
4.
所以,當(dāng)?shù)谝淮卧贗E瀏覽器輸入DVR IP,如192.168.1.100時,index.htm中的object屬性首先找本電腦中是否已經(jīng)安裝ID號為3FB84210-0311-49BA-AFF7-A2C50E2D20B6的OCX插件,如果安裝,直接運行,否則,下載codebase后面的URL,這里是同目錄下的webrec.cab,同時檢測到此cab文件中有.inf文件web.inf,所以執(zhí)行web.inf安裝到相應(yīng)目錄;
web.inf如下:
[version] signature="$CHICAGO$" NetSurveillanceActiveX=1.00
[DestinationDirs] install.files=30,WINDOWS\NetSurveillance
[SourceDisksNames] 1=%DiskName%,web.cab,1
[install.files] NetSurveillance.ocx=NetSurveillance.ocx WndManager.ocx=WndManager.ocx Config.ocx=Config.ocx hi_h264dec_w.dll=hi_h264dec_w.dll
[btn_PTZ.bmp] file-win32-x86=thiscab RegisterServer=no DestDir=30,WINDOWS\NetSurveillance
.
.
.
[hi_h264dec_w.dll] file-win32-x86=thiscab RegisterServer=no DestDir=30,WINDOWS\NetSurveillance [PlayBack.dll] file-win32-x86=thiscab RegisterServer=no DestDir=30,WINDOWS\NetSurveillance
[WndManager.ocx] file-win32-x86=thiscab RegisterServer=yes clsid={56405723-8E20-404C-B2DA-3CFE65D9D1A3} DestDir=30,WINDOWS\NetSurveillance
[Config.ocx] file-win32-x86=thiscab RegisterServer=yes clsid={5E4D8475-3953-4008-B08F-D07687269EE7} DestDir=30,WINDOWS\NetSurveillance
[NetSurveillance.ocx] file-win32-x86=thiscab RegisterServer=yes clsid={3FB84210-0311-49BA-AFF7-A2C50E2D20B6} DestDir=30,WINDOWS\NetSurveillance
[RegisterFiles] %30%\WINDOWS\NetSurveillance\Config.ocx %30%\WINDOWS\NetSurveillance\WndManager.ocx %30%\WINDOWS\NetSurveillance\NetSurveillance.ocx
可以看到cab中的所有文件都被安裝到了C:\WINDOWS\NetSurveillance下,并把NetSurveillance.ocx注冊為ID 3FB84210-0311-49BA-AFF7-A2C50E2D20B6,因此<object classid="CLSID:3FB84210-0311-49BA-AFF7-A2C50E2D20B6" codebase="webrec.cab#version=1,0,0,9" width="100%" height="100%" id="Surveil">開始運行NetSurveillance.ocx;
5.
NetSurveillance.ocx的開發(fā)與客戶端exe開發(fā)基本類似,無非是登錄DVR-獲取碼流-本地解碼顯示;
|