目前视频监控中网络访问很多还是C/S结构,不过B/S将更方便,通过对一款DVR的分析,添加一个web server,流程如下,记录一下,免得以后用时忘记;
1.移植boa、goahead等开源web服务器软件一个;
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. 上面代码中有一句最关键,即
<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有如下属性:
当Web页上OBJECT元素的CODEBASE特性引用包含.INF文件的. CAB文件时,Internet Explorer将自动把.CAB文件作为软件分发单位下载并安装,每次访问时还会自动检测版本并进行更新;
4.
所以,当第一次在IE浏览器输入DVR IP,如192.168.1.100时,index.htm中的object属性首先找本电脑中是否已经安装ID号为3FB84210-0311-49BA-AFF7-A2C50E2D20B6的OCX插件,如果安装,直接运行,否则,下载codebase后面的URL,这里是同目录下的webrec.cab,同时检测到此cab文件中有.inf文件web.inf,所以执行web.inf安装到相应目录;
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的开发与客户端exe开发基本类似,无非是登录DVR-获取码流-本地解码显示;
|