程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> C# >> 關於C# >> C#封裝的海康DVR客戶端SDK

C#封裝的海康DVR客戶端SDK

編輯:關於C#

using System;
using System.Collections.Generic;
using System.Text;

using System.Runtime.InteropServices;
using System.Drawing;

namespace HIK
{

    public delegate void fVoiceDataCallBack(int lVoiceComHandle, [MarshalAs (UnmanagedType.LPArray)]  byte[] pRecvDataBuffer, uint dwBufSize, byte byAudioFlag, uint dwUser);

    public delegate void SerialDataCallBack(int lSerialHandle, [MarshalAs (UnmanagedType.LPArray)]  byte[] pRecvDataBuffer, uint dwBufSize, uint dwUser);

    public delegate void DrawFun(int  lRealHandle,System.Drawing.Graphics hDc,uint  dwUser);

    public delegate void RealDataCallBack(int lRealHandle, uint dwDataType, [MarshalAs (UnmanagedType.LPArray, SizeConst = 11520)] byte[] pBuffer, uint dwBufSize, uint dwUser);

    public delegate void PlayDataCallBack(int lPlayHandle, uint dwDataType, [MarshalAs (UnmanagedType.LPArray)]  byte[] pBuffer, uint dwBufSize, uint dwUser);

    public struct NET_DVR_DEVICEINFO
    {
        // [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] 

        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 48)]
        public byte[] sSerialNumber;//[SERIALNO_LEN];  //序列號
        public byte byAlarmInPortNum;  //DVR報警輸入個數
        public byte byAlarmOutPortNum;  //DVR報警輸出個數
        public byte byDiskNum;    //DVR 硬盤個數
        public byte byDVRType;    //DVR類型,
        public byte byChanNum;    //DVR 通道個數
        public byte byStartChan;   //起始通道號,例如DVS-1,DVR - 1
    }


    public struct NET_DVR_DISKSTATE
    {
        public uint dwVolume;//硬盤的容量
        public uint dwFreeSpace;//硬盤的剩余空間
        public uint dwHardDiskStatic; //硬盤的狀態,休眠,活動,不正常等
    }


    public struct NET_DVR_TIME
    {
        public uint dwYear;  //年
        public uint dwMonth;  //月
        public uint dwDay;  //日
        public uint dwHour;  //時
        public uint dwMinute;  //分
        public uint dwSecond;  //秒
    }

    public struct NET_DVR_FIND_DATA
    {
        public string sFileName;//文件名
        public NET_DVR_TIME struStartTime;//文件的開始時間
        public NET_DVR_TIME struStopTime;//文件的結束時間
        public uint dwFileSize;//文件的大小
    }


    public struct NET_DVR_CHANNELSTATE
    {
        public byte byRecordStatic; //通道是否在錄像,0-不錄像,1-錄像
        public byte bySignalStatic; //連接的信號狀態,0-正常,1-信號丟失
        public byte byHardwareStatic;//通道硬件狀態,0-正常,1-異常,例如DSP死掉
        public char reservedData;
        public uint dwBitRate;//實際碼率
        public uint dwLinkNum;//客戶端連接的個數
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]  //MAX_LINK
        public uint[] dwClientIP;//客戶端的IP地址
    }

    public struct NET_DVR_WORKSTATE
    {

        public uint dwDeviceStatic;  //設備的狀態,0-正常,1-CPU占用率太高,超過 85%,2-硬件錯誤,例如串口死掉

        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
        public NET_DVR_DISKSTATE[] struHardDiskStatic; //MAX_DISKNUM

        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
        public NET_DVR_CHANNELSTATE[] struChanStatic;//通道的狀態 MAX_CHANNUM

        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
        public byte[] byAlarmInStatic; //報警端口的狀態,0-沒有報警,1-有報警 MAX_ALARMIN

        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
        public byte[] byAlarmOutStatic; //報警輸出端口的狀態,0-沒有輸出,1-有報警輸 出MAX_ALARMOUT
        public uint dwLocalDisplay;//本地顯示狀態,0-正常,1-不正常
    }

    public struct NET_DVR_ETHERNET
    {
        public string sDVRIP;          //DVR IP地址
        public string sDVRIPMask;      // DVR IP地址掩碼
        public uint dwNetInterface;   //網絡接口 1-10MBase-T 2-10MBase-T全雙工 3 -100MBase-TX 4-100M全雙工 5-10M/100M自適應
        public ushort wDVRPort;  //端口號
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]
        public byte[] byMACAddr;  //服務器的物理地址MACADDR_LEN
    }


    public struct NET_DVR_NETCFG
    {
        public uint dwSize;

        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
        public NET_DVR_ETHERNET[] struEtherNet;  /* 以太網口 */
        public string sManageHostIP;  //遠程管理主機地址
        public short wManageHostPort; //遠程管理主機端口號
        public string sDNSIP;            //DNS服務器地址 
        public string sMultiCastIP;     //多播組地址
        public string sGatewayIP;        //網關地址
        public string sNFSIP;   //NAS主機IP地址 
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)]
        public byte[] sNFSDirectory;//NAS目錄PATHNAME_LEN
        public uint dwPPPOE;    //0-不啟用,1-啟用
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
        public byte[] sPPPoEUser; //PPPoE用戶名NAME_LEN
        //  [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
        public string sPPPoEPassword;// PPPoE密碼
        public string sPPPoEIP;   //PPPoE IP地址(只讀)
        public ushort wHttpPort;    //HTTP端口號
    }

    public struct NET_DVR_ALARMOUTSTATUS
    {
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
        public byte[] Output;//MAX_ALARMOUT
    }

    public struct NET_DVR_CLIENTINFO{
  public int  lChannel;//通道號
  public int  lLinkMode;//最高位(31)為0表示主碼流,為1表示子碼流,0-30位表示碼流連接方 式: 0:TCP方式,1:UDP方式,2:多播方式,3 - RTP方式,4-音視頻分開(TCP)
  public  System.IntPtr hPlayWnd;//播放窗口的句柄,為NULL表示不播放圖象
  public  string  sMultiCastIP;//多播組地址
}

    /// <summary>
    /// 海康嵌入式
    /// </summary>
    public sealed class Hik_HCNetSDK
    {
        #region 常量定義
        public const int NET_DVR_NOERROR = 0; //沒有錯誤
        public const int NET_DVR_PASSWORD_ERROR = 1;  //用戶名密碼錯誤
        public const int NET_DVR_NOENOUGHPRI = 2;  //權限不足
        public const int NET_DVR_NOINIT = 3; //沒有初始化
        public const int NET_DVR_CHANNEL_ERROR = 4;  //通道號錯誤
        public const int NET_DVR_OVER_MAXLINK = 5; //連接到DVR的客戶端個數超過最大
        public const int NET_DVR_VERSIONNOMATCH = 6; //版本不匹配
        public const int NET_DVR_NETWORK_FAIL_CONNECT = 7;//連接服務器失敗
        public const int NET_DVR_NETWORK_SEND_ERROR = 8; //向服務器發送失敗
        public const int NET_DVR_NETWORK_RECV_ERROR = 9;//從服務器接收數據失敗
        public const int NET_DVR_NETWORK_RECV_TIMEOUT = 10; //從服務器接收數據超時
        public const int NET_DVR_NETWORK_ERRORDATA = 11; //傳送的數據有誤
        public const int NET_DVR_ORDER_ERROR = 12;//調用次序錯誤
        public const int NET_DVR_OPERNOPERMIT = 13; //無此權限
        public const int NET_DVR_COMMANDTIMEOUT = 14;//DVR命令執行超時
        public const int NET_DVR_ERRORSERIALPORT = 15;//串口號錯誤
        public const int NET_DVR_ERRORALARMPORT = 16; //報警端口錯誤
        public const int NET_DVR_PARAMETER_ERROR = 17; //參數錯誤
        public const int NET_DVR_CHAN_EXCEPTION = 18;//服務器通道處於錯誤狀態
        public const int NET_DVR_NODISK = 19;//沒有硬盤
        public const int NET_DVR_ERRORDISKNUM = 20;//硬盤號錯誤
        public const int NET_DVR_DISK_FULL = 21; //服務器硬盤滿
        public const int NET_DVR_DISK_ERROR = 22;//服務器硬盤出錯
        public const int NET_DVR_NOSUPPORT = 23; //服務器不支持
        public const int NET_DVR_BUSY = 24;//服務器忙
        public const int NET_DVR_MODIFY_FAIL = 25; //服務器修改不成功
        public const int NET_DVR_PASSWORD_FORMAT_ERROR = 26; //密碼輸入格式不正確
        public const int NET_DVR_DISK_FORMATING = 27; //硬盤正在格式化,不能啟動操 作
        public const int NET_DVR_DVRNORESOURCE = 28; //DVR資源不足
        public const int NET_DVR_DVROPRATEFAILED = 29; //DVR操作失敗
        public const int NET_DVR_OPENHOSTSOUND_FAIL = 30; //打開PC聲音失敗
        public const int NET_DVR_DVRVOICEOPENED = 31; //服務器語音對講被占用
        public const int NET_DVR_TIMEINPUTERROR = 32; //時間輸入不正確
        public const int NET_DVR_NOSPECFILE = 33; //回放時服務器沒有指定的文件
        public const int NET_DVR_CREATEFILE_ERROR = 34;//創建文件出錯
        public const int NET_DVR_FILEOPENFAIL = 35; //打開文件出錯
        public const int NET_DVR_OPERNOTFINISH = 36; //上次的操作還沒有完成
        public const int NET_DVR_GETPLAYTIMEFAIL = 37; //獲取當前播放的時間出錯
        public const int NET_DVR_PLAYFAIL = 38; //播放出錯
        public const int NET_DVR_FILEFORMAT_ERROR = 39; //文件格式不正確
        public const int NET_DVR_DIR_ERROR = 40; //路徑錯誤
        public const int NET_DVR_ALLOC_RESOUCE_ERROR = 41; //資源分配錯誤
        public const int NET_DVR_AUDIO_MODE_ERROR = 42; //聲卡模式錯誤
        public const int NET_DVR_NOENOUGH_BUF = 43;//緩沖區太小
        public const int NET_DVR_CREATESOCKET_ERROR = 44; //創建SOCKET出錯
        public const int NET_DVR_SETSOCKET_ERROR = 45; //設置SOCKET出錯
        public const int NET_DVR_MAX_NUM = 46;//個數達到最大
        public const int NET_DVR_USERNOTEXIST = 47; //用戶不存在
        public const int NET_DVR_WRITEFLASHERROR = 48;  //寫FLASH出錯
        public const int NET_DVR_UPGRADEFAIL = 49; //DVR升級失敗
        public const int NET_DVR_CARDHAVEINIT = 50; //解碼卡已經初始化過
        public const int NET_DVR_PLAYERFAILED = 51; //播放器中錯誤
        public const int NET_DVR_MAX_USERNUM = 52; //用戶數達到最大
        public const int NET_DVR_GETLOCALIPANDMACFAIL = 53; //獲得客戶端的IP地址或 物理地址失敗
        public const int NET_DVR_NOENCODEING = 54;//該通道沒有編碼
        public const int NET_DVR_IPMISMATCH = 55; //IP地址不匹配
        public const int NET_DVR_MACMISMATCH = 56;//MAC地址不匹配
        public const int NET_DVR_UPGRADELANGMISMATCH = 57;//升級文件語言不匹配
        public const int NET_DVR_DDRAWDEVICENOSUPPORT = 58;//本地顯卡不支持


        //查找文件和日志函數返回值
        public const int NET_DVR_FILE_SUCCESS = 1000; //獲得文件信息
        public const int NET_DVR_FILE_NOFIND = 1001;//沒有文件
        public const int NET_DVR_ISFINDING = 1002;//正在查找文件
        public const int NET_DVR_NOMOREFILE = 1003; //查找文件時沒有更多的文件
        public const int NET_DVR_FILE_EXCEPTION = 1004; //查找文件時異常

        //NET_DVR_IsSupport()返回值
        //1-9位分別表示以下信息(位與是TRUE)表示支持;
        public const int NET_DVR_SUPPORT_DDRAW = 0x01;//支持DIRECTDRAW,如果不支持 ,則播放器不能工作;
        public const int NET_DVR_SUPPORT_BLT = 0x02;//顯卡支持BLT操作,如果不支持, 則播放器不能工作;
        public const int NET_DVR_SUPPORT_BLTFOURCC = 0x04;//顯卡BLT支持顏色轉換,如 果不支持,播放器會用軟件方法作RGB轉換;
        public const int NET_DVR_SUPPORT_BLTSHRINKX = 0x08;//顯卡BLT支持X軸縮小;如 果不支持,系統會用軟件方法轉換;
        public const int NET_DVR_SUPPORT_BLTSHRINKY = 0x10;//顯卡BLT支持Y軸縮小;如 果不支持,系統會用軟件方法轉換;
        public const int NET_DVR_SUPPORT_BLTSTRETCHX = 0x20;//顯卡BLT支持X軸放大; 如果不支持,系統會用軟件方法轉換;
        public const int NET_DVR_SUPPORT_BLTSTRETCHY = 0x40;//顯卡BLT支持Y軸放大; 如果不支持,系統會用軟件方法轉換;
        public const int NET_DVR_SUPPORT_SSE = 0x80;//CPU支持SSE指令,Intel Pentium3以上支持SSE指令;
        public const int NET_DVR_SUPPORT_MMX = 0x100;//CPU支持MMX指令集,Intel Pentium3以上支持SSE指令;

        public const int SET_PRESET = 8;// 設置預置點
        public const int CLE_PRESET = 9; // 清除預置點
        public const int GOTO_PRESET = 39;// 轉到預置點

        public const int LIGHT_PWRON = 2; /* 接通燈光電源 */
        public const int WIPER_PWRON = 3; /* 接通雨刷開關 */
        public const int FAN_PWRON = 4;/* 接通風扇開關 */
        public const int HEATER_PWRON = 5;/* 接通加熱器開關 */
        public const int AUX_PWRON = 6;/* 接通輔助設備開關 */

        public const int ZOOM_IN = 11; /* 焦距以速度SS變大(倍率變大) */
        public const int ZOOM_OUT = 12;/* 焦距以速度SS變小(倍率變小) */
        public const int FOCUS_NEAR = 13; /* 焦點以速度SS前調 */
        public const int FOCUS_FAR = 14;/* 焦點以速度SS後調 */
        public const int IRIS_OPEN = 15; /* 光圈以速度SS擴大 */
        public const int IRIS_CLOSE = 16; /* 光圈以速度SS縮小 */
        public const int TILT_UP = 21;/* 雲台以SS的速度上仰 */
        public const int TILT_DOWN = 22;/* 雲台以SS的速度下俯 */
        public const int PAN_LEFT = 23;/* 雲台以SS的速度左轉 */
        public const int PAN_RIGHT = 24; /* 雲台以SS的速度右轉 */
        public const int PAN_AUTO = 29; /* 雲台以SS的速度左右自動掃描 */

        public const int RUN_CRUISE = 36; /* 開始軌跡 */
        public const int RUN_SEQ = 37; /* 開始巡航 */
        public const int STOP_SEQ = 38;/* 停止巡航 */

        //顯示模式
        public enum DispMode { NORMALMODE = 0, OVERLAYMODE };
        //發送模式
        public enum TransMode { PTOPTCPMODE, PTOPUDPMODE, MULTIMODE, RTPMODE, AUDIODETACH, NOUSEMODE };

        public const int NET_DVR_SYSHEAD = 1;//系統頭數據
        public const int NET_DVR_STREAMDATA = 2; //流數據

        //播放控制命令宏定義 NET_DVR_PlayBackControl,NET_DVR_PlayControlLocDisplay,NET_DVR_DecPlayBackCtrl的宏定義
        public const int NET_DVR_PLAYSTART = 1;//開始播放
        public const int NET_DVR_PLAYSTOP = 2;//停止播放
        public const int NET_DVR_PLAYPAUSE = 3;//暫停播放
        public const int NET_DVR_PLAYRESTART = 4;//恢復播放
        public const int NET_DVR_PLAYFAST = 5;//快放
        public const int NET_DVR_PLAYSLOW = 6;//慢放
        public const int NET_DVR_PLAYNORMAL = 7;//正常速度
        public const int NET_DVR_PLAYFRAME = 8;//單幀放
        public const int NET_DVR_PLAYSTARTAUDIO = 9;//打開聲音
        public const int NET_DVR_PLAYSTOPAUDIO = 10;//關閉聲音
        public const int NET_DVR_PLAYAUDIOVOLUME = 11;//調節音量
        public const int NET_DVR_PLAYSETPOS = 12;//改變文件回放的進度
        public const int NET_DVR_PLAYGETPOS = 13;//獲取文件回放的進度
        public const int NET_DVR_PLAYGETTIME = 14;//獲取當前已經播放的時間
        public const int NET_DVR_PLAYGETFRAME = 15;//獲取當前已經播放的幀數
        public const int NET_DVR_GETTOTALFRAMES = 16;//獲取當前播放文件總的幀數
        public const int NET_DVR_GETTOTALTIME = 17;//獲取當前播放文件總的時間
        public const int NET_DVR_THROWBFRAME = 20;//丟B幀

        //NET_DVR_GetDVRConfig,NET_DVR_GetDVRConfig的命令定義
        public const int NET_DVR_GET_DEVICECFG = 100;  //獲取設備參數
        public const int NET_DVR_SET_DEVICECFG = 101; //設置設備參數
        public const int NET_DVR_GET_NETCFG = 102; //獲取網絡參數
        public const int NET_DVR_SET_NETCFG = 103; //設置網絡參數
        public const int NET_DVR_GET_PICCFG = 104; //獲取圖象參數
        public const int NET_DVR_SET_PICCFG = 105; //設置圖象參數
        public const int NET_DVR_GET_COMPRESSCFG = 106; //獲取壓縮參數
        public const int NET_DVR_SET_COMPRESSCFG = 107; //設置壓縮參數
        public const int NET_DVR_GET_COMPRESSCFG_EX = 204; //獲取壓縮參數(擴展)
        public const int NET_DVR_SET_COMPRESSCFG_EX = 205; //設置壓縮參數(擴展)
        public const int NET_DVR_GET_RECORDCFG = 108;//獲取錄像時間參數
        public const int NET_DVR_SET_RECORDCFG = 109; //設置錄像時間參數
        public const int NET_DVR_GET_DECODERCFG = 110; //獲取解碼器參數
        public const int NET_DVR_SET_DECODERCFG = 111; //設置解碼器參數
        public const int NET_DVR_GET_RS232CFG = 112; //獲取232串口參數
        public const int NET_DVR_SET_RS232CFG = 113;//設置232串口參數
        public const int NET_DVR_GET_ALARMINCFG = 114; //獲取報警輸入參數
        public const int NET_DVR_SET_ALARMINCFG = 115; //設置報警輸入參數
        public const int NET_DVR_GET_ALARMOUTCFG = 116; //獲取報警輸出參數
        public const int NET_DVR_SET_ALARMOUTCFG = 117; //設置報警輸出參數
        public const int NET_DVR_GET_TIMECFG = 118; //獲取DVR時間
        public const int NET_DVR_SET_TIMECFG = 119; //設置DVR時間
        public const int NET_DVR_GET_PREVIEWCFG = 120; //獲取預覽參數
        public const int NET_DVR_SET_PREVIEWCFG = 121; //設置預覽參數
        public const int NET_DVR_GET_VIDEOOUTCFG = 122; //獲取視頻輸出參數
        public const int NET_DVR_SET_VIDEOOUTCFG = 123; //設置視頻輸出參數
        public const int NET_DVR_GET_USERCFG = 124; //獲取用戶參數
        public const int NET_DVR_SET_USERCFG = 125; //設置用戶參數
        public const int NET_DVR_GET_EXCEPTIONCFG = 126; //獲取異常參數
        public const int NET_DVR_SET_EXCEPTIONCFG = 127;  //設置異常參數
        public const int NET_DVR_GET_SHOWSTRING = 130; //獲取疊加字符參數
        public const int NET_DVR_SET_SHOWSTRING = 131; //設置疊加字符參數
        public const int NET_DVR_GET_AUXOUTCFG = 140; //獲取輔助輸出設置
        public const int NET_DVR_SET_AUXOUTCFG = 141;  //設置輔助輸出設置
        //2006-04-13 -s系列雙輸出
        public const int NET_DVR_GET_PREVIEWCFG_AUX = 142; //獲取預覽參數
        public const int NET_DVR_SET_PREVIEWCFG_AUX = 143; //設置預覽參數
        public const int NET_DVR_GET_PICCFG_EX = 200; //獲取圖象參數(擴展)
        public const int NET_DVR_SET_PICCFG_EX = 201; //設置圖象參數(擴展)
        public const int NET_DVR_GET_USERCFG_EX = 202; //獲取用戶參數
        public const int NET_DVR_SET_USERCFG_EX = 203; //設置用戶參數

        //回調函數類型
        public const int COMM_ALARM = 0x1100;//報警信息
        public const int COMM_TRADEINFO = 0x1500;//ATMDVR主動上傳交易信息

        //消息方式
        //異常類型
        public const int EXCEPTION_AUDIOEXCHANGE = 0x8001;//語音對講異常
        public const int EXCEPTION_ALARM = 0x8002;//報警異常
        public const int EXCEPTION_PREVIEW = 0x8003; //網絡預覽異常
        public const int EXCEPTION_SERIAL = 0x8004;//透明通道異常
        public const int EXCEPTION_RECONNECT = 0x8005;//預覽時重連

        public const int NAME_LEN = 32;
        public const int SERIALNO_LEN = 48;
        public const int MACADDR_LEN = 6;
        public const int MAX_ETHERNET = 2;
        public const int PATHNAME_LEN = 128;
        public const int PASSWD_LEN = 16;
        public const int MAX_CHANNUM = 16;
        public const int MAX_ALARMOUT = 4;
        public const int MAX_TIMESEGMENT = 4;
        public const int MAX_PRESET = 128;
        public const int MAX_DAYS = 7;
        public const int PHONENUMBER_LEN = 32;
        public const int MAX_DISKNUM = 16;
        public const int MAX_WINDOW = 16;
        public const int MAX_VGA = 1;
        public const int MAX_USERNUM = 16;
        public const int MAX_EXCEPTIONNUM = 16;
        public const int MAX_LINK = 6;
        public const int MAX_ALARMIN = 16;
        public const int MAX_VIDEOOUT = 2;
        public const int MAX_NAMELEN = 16; //DVR本地登陸名
        public const int MAX_RIGHT = 32;//權限
        public const int CARDNUM_LEN = 20;
        public const int MAX_SHELTERNUM = 4;//遮擋區域數
        public const int MAX_DECPOOLNUM = 4;
        public const int MAX_DECNUM = 4;
        public const int MAX_TRANSPARENTNUM = 2;
        public const int MAX_STRINGNUM = 4;
        public const int MAX_AUXOUT = 4;

        /* 網絡接口定義 */
        public const int NET_IF_10M_HALF = 1;    /* 10M ethernet */
        public const int NET_IF_10M_FULL = 2;
        public const int NET_IF_100M_HALF = 3;    /* 100M ethernet */
        public const int NET_IF_100M_FULL = 4;
        public const int NET_IF_AUTO = 5;

        //設備型號(DVR類型)
        public const int DVR = 1;
        public const int ATMDVR = 2;
        public const int DVS = 3;
        public const int DEC = 4; /* 6001D */
        public const int ENC_DEC = 5; /* 6001F */
        public const int DVR_HC = 6;
        public const int DVR_HT = 7;
        public const int DVR_HF = 8;
        public const int DVR_HS = 9;
        public const int DVR_HTS = 10;
        public const int DVR_HB = 11;
        public const int DVR_HCS = 12;
        public const int DVS_A = 13;
        public const int DVR_HC_S = 14;
        public const int DVR_HT_S = 15;
        public const int DVR_HF_S = 16;
        public const int DVR_HS_S = 17;
        public const int ATMDVR_S = 18;
        public const int LOWCOST_DVR = 19;
        #endregion

        //  public static readonly  int  SERIALNO_LEN = 48;


        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_Init();

        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_Cleanup();

        [DllImport("HCNetSDK.dll")]
        public static extern int NET_DVR_Login(string sDVRIP, ushort wDVRPort, string sUserName, string sPassword, ref  NET_DVR_DEVICEINFO lpDeviceInfo);

        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_Logout(int lUserID);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_SetDVRMessage(uint nMessage, System.IntPtr hWnd);
        //public static extern bool NET_DVR_SetDVRMessCallBack(BOOL (CALLBACK *fMessCallBack)(int  lCommand,char *sDVRIP,char *pBuf,uint  dwBufLen));
        //public static extern bool NET_DVR_SetDVRMessCallBack_EX(BOOL (CALLBACK *fMessCallBack_EX)(int  lCommand,int  lUserID,char *pBuf,uint  dwBufLen));
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_SetConnectTime(uint dwWaitTime, uint dwTryTimes);
        [DllImport("HCNetSDK.dll")]
        public static extern uint NET_DVR_GetSDKVersion();
        [DllImport("HCNetSDK.dll")]
        public static extern int NET_DVR_IsSupport();
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_StartListen(string sLocalIP, ushort wLocalPort);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_StopListen();

        [DllImport("HCNetSDK.dll")]
        public static extern uint NET_DVR_GetLastError();
         [DllImport("HCNetSDK.dll")]
       public static extern bool NET_DVR_SetShowMode(uint  dwShowType,System.Drawing.Color colorKey);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_GetDVRIPByResolveSvr(string sServerIP, ushort wServerPort, string sDVRName, ushort wDVRNameLen, string sDVRSerialNumber, ushort wDVRSerialLen, string sGetIP);
        //圖像預覽
        [DllImport("HCNetSDK.dll")]
        public static extern int  NET_DVR_RealPlay(int  lUserID, ref NET_DVR_CLIENTINFO lpClientInfo);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_StopRealPlay(int lRealHandle);
        //視頻參數是索引值 1-10
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_ClientSetVideoEffect(int lRealHandle, uint dwBrightValue, uint dwContrastValue, uint dwSaturationValue, uint dwHueValue);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_ClientGetVideoEffect(int lRealHandle, uint pBrightValue, uint pContrastValue, uint pSaturationValue, uint pHueValue);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_RigisterDrawFun(int  lRealHandle,DrawFun x,uint  dwUser);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_SetPlayerBufNumber(int lRealHandle, uint dwBufNum);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_ThrowBFrame(int lRealHandle, uint dwNum);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_SetAudioMode(uint dwMode);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_OpenSound(int lRealHandle);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_CloseSound();
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_OpenSoundShare(int lRealHandle);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_CloseSoundShare(int lRealHandle);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_Volume(int lRealHandle, ushort wVolume);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_SaveRealData(int lRealHandle, string  sFileName);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_StopSaveRealData(int lRealHandle);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_SetRealDataCallBack(int  lRealHandle,RealDataCallBack x,uint  dwUser);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_CapturePicture(int lRealHandle, string sPicFileName);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_MakeKeyFrame(int lUserID, int lChannel);
        //雲台控制
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_PTZControl(int lRealHandle, uint dwPTZCommand, uint dwStop);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_PTZControl_Other(int lUserID, int lChannel, uint dwPTZCommand, uint dwStop);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_TransPTZ(int lRealHandle, byte[] pPTZCodeBuf, uint dwBufSize);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_TransPTZ_Other(int lUserID, int lChannel, byte[] pPTZCodeBuf, uint dwBufSize);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_PTZPreset(int lRealHandle, uint dwPTZPresetCmd, uint dwPresetIndex);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_PTZPreset_Other(int lUserID, int lChannel, uint dwPTZPresetCmd, uint dwPresetIndex);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_TransPTZ_EX(int lRealHandle, byte[] pPTZCodeBuf, uint dwBufSize);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_PTZControl_EX(int lRealHandle, uint dwPTZCommand, uint dwStop);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_PTZPreset_EX(int lRealHandle, uint dwPTZPresetCmd, uint dwPresetIndex);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_PTZCruise(int lRealHandle, uint dwPTZCruiseCmd, byte byCruiseRoute, byte byCruisePoint, ushort wInput);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_PTZCruise_Other(int lUserID, int lChannel, uint dwPTZCruiseCmd, byte byCruiseRoute, byte byCruisePoint, ushort wInput);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_PTZCruise_EX(int lRealHandle, uint dwPTZCruiseCmd, byte byCruiseRoute, byte byCruisePoint, ushort wInput);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_PTZTrack(int lRealHandle, uint dwPTZTrackCmd);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_PTZTrack_Other(int lUserID, int lChannel, uint dwPTZTrackCmd);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_PTZTrack_EX(int lRealHandle, uint dwPTZTrackCmd);
        //帶速度的雲台控制
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_PTZControlWithSpeed(int lRealHandle, uint dwPTZCommand, uint dwStop, uint dwSpeed);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_PTZControlWithSpeed_Other(int lUserID, int lChannel, uint dwPTZCommand, uint dwStop, uint dwSpeed);

        //文件回放
        [DllImport("HCNetSDK.dll")]
        public static extern int NET_DVR_FindFile(int lUserID, int lChannel, uint dwFileType, ref NET_DVR_TIME lpStartTime, ref NET_DVR_TIME lpStopTime);
        [DllImport("HCNetSDK.dll")]
        public static extern int NET_DVR_FindNextFile(int lFindHandle, ref NET_DVR_FIND_DATA lpFindData);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_FindClose(int lFindHandle);
        [DllImport("HCNetSDK.dll")]
        public static extern int NET_DVR_PlayBackByName(int lUserID, string sPlayBackFileName, System.IntPtr hWnd);
        [DllImport("HCNetSDK.dll")]
        public static extern int NET_DVR_PlayBackByTime(int lUserID, int lChannel, ref NET_DVR_TIME lpStartTime, ref NET_DVR_TIME lpStopTime, System.IntPtr hWnd);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_PlayBackControl(int lPlayHandle, uint dwControlCode, uint dwInValue, uint lpOutValue);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_StopPlayBack(int lPlayHandle);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_SetPlayDataCallBack(int  lPlayHandle,PlayDataCallBack x,uint  dwUser);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_PlayBackSaveData(int lPlayHandle, string sFileName);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_StopPlayBackSave(int lPlayHandle);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_GetPlayBackOsdTime(int lPlayHandle, ref NET_DVR_TIME lpOsdTime);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_PlayBackCaptureFile(int lPlayHandle, string sFileName);
        [DllImport("HCNetSDK.dll")]
        public static extern int NET_DVR_GetFileByName(int lUserID, string sDVRFileName, string sSavedFileName);
        [DllImport("HCNetSDK.dll")]
        public static extern int NET_DVR_GetFileByTime(int lUserID, int lChannel, ref NET_DVR_TIME lpStartTime, ref NET_DVR_TIME lpStopTime, string sSavedFileName);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_StopGetFile(int lFileHandle);
        [DllImport("HCNetSDK.dll")]
        public static extern int NET_DVR_GetDownloadPos(int lFileHandle);

        //恢復默認值
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_RestoreConfig(int lUserID);
        //保存參數
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_SaveConfig(int lUserID);
        //重啟
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_RebootDVR(int lUserID);
        //關閉DVR
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_ShutDownDVR(int lUserID);
        //升級
        [DllImport("HCNetSDK.dll")]
        public static extern int NET_DVR_Upgrade(int lUserID, string sFileName);
        [DllImport("HCNetSDK.dll")]
        public static extern int NET_DVR_GetUpgradeState(int lUpgradeHandle);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_CloseUpgradeHandle(int lUpgradeHandle);
        //遠程格式化硬盤
        [DllImport("HCNetSDK.dll")]
        public static extern int NET_DVR_FormatDisk(int lUserID, int lDiskNumber);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_GetFormatProgress(int lFormatHandle, int pCurrentFormatDisk, int pCurrentDiskPos, int pFormatStatic);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_CloseFormatHandle(int lFormatHandle);
        //報警
        [DllImport("HCNetSDK.dll")]
        public static extern int NET_DVR_SetupAlarmChan(int lUserID);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_CloseAlarmChan(int lAlarmHandle);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_GetAlarmOut(int lUserID, ref NET_DVR_ALARMOUTSTATUS lpAlarmOutState);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_SetAlarmOut(int lUserID, int lAlarmOutPort, int lAlarmOutStatic);

        //語音對講
        [DllImport("HCNetSDK.dll")]
        public static extern int NET_DVR_StartVoiceCom(int lUserID, fVoiceDataCallBack x, uint dwUser);

        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_SetVoiceComClientVolume(int lVoiceComHandle, ushort wVolume);

        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_StopVoiceCom(int lVoiceComHandle);
        //語音廣播
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_ClientAudioStart();

        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_ClientAudioStop();

        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_AddDVR(int lUserID);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_DelDVR(int lUserID);
        //語音轉發
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_StartVoiceCom_MR(int lUserID, fVoiceDataCallBack x, uint dwUser);

        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_VoiceComSendData(int lVoiceComHandle, byte[] pSendBuf, uint dwBufSize);

        //透明通道設置
        [DllImport("HCNetSDK.dll")]
        public static extern int NET_DVR_SerialStart(int lUserID, int lSerialPort, SerialDataCallBack x, uint dwUser);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_SerialSend(int lSerialHandle, int lChannel, byte[] pSendBuf, uint dwBufSize);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_SerialStop(int lSerialHandle);
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_SendTo232Port(int lUserID, byte[] pSendBuf, uint dwBufSize);
        //遠程控制本地顯示
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_ClickKey(int lUserID, int lKeyIndex);

        //遠程控制手動錄像
        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_StartDVRRecord(int lUserID, int lChannel, int lRecordType);

        [DllImport("HCNetSDK.dll")]
        public static extern bool NET_DVR_StopDVRRecord(int lUserID, int lChannel);
    }
}

不用多久,DVR/IP 網絡錄像機廠家都將提供C#版SDK,有利於網絡開發!

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved