using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace VideoCard.Hic
{
public class CardSDK
{
public const UInt32 ERR_WAIT_TIMEOUT = 0xc0000001;
public const UInt32 ERR_INVALID_HANDLE = 0xc0000002;
public const UInt32 ERR_INVALID_ARGUMENT = 0xc0000003;
public const UInt32 ERR_DDRAW_CREATE_FAILED = 0xc0000004;
public const UInt32 ERR_DDRAW_CAPS_FAULT = 0xc0000005;
public const UInt32 ERR_SET_COOPERATIVELEVEL_FAILED = 0xc0000006;
public const UInt32 ERR_PRIMARY_SURFACE_CREATE_FAILED = 0xc0000007;
public const UInt32 ERR_GET_OVERLAY_ADDRESS_FAILED = 0xc0000008;
public const UInt32 ERR_OVERLAY_SURFACE_CREATE_FAILED = 0xc0000009;
public const UInt32 ERR_OVERLAY_UPDATE_FAILED = 0xc000000a;
public const UInt32 ERR_TMMAN_FAILURE = 0xc000000b;
public const UInt32 ERR_CHANNELMAGIC_MISMATCH = 0xc000000c;
public const UInt32 ERR_CALLBACK_REGISTERED = 0xc000000d;
public const UInt32 ERR_QUEUE_OVERFLOW = 0xc000000e;
public const UInt32 ERR_STREAM_THREAD_FAILURE = 0xc000000f;
public const UInt32 ERR_THREAD_STOP_ERROR = 0xc0000010;
public const UInt32 ERR_NOT_SUPPORT = 0xc0000011;
public const UInt32 ERR_OUTOF_MEMORY = 0xc0000012;
public const UInt32 ERR_DSP_BUSY = 0xc0000013;
public const UInt32 ERR_DATA_ERROR = 0xc0000014;
public const UInt32 ERR_KERNEL = 0xc0000016;
public const UInt32 ERR_OFFSCREEN_CREATE_FAILED = 0xc0000017;
public const UInt32 ERR_MULTICLOCK_FAILURE = 0xc0000018;
public const UInt32 ERR_INVALID_DEVICE = 0xc0000019;
public const UInt32 ERR_INVALID_DRIVER = 0xc000001a;
//error code for MD card
public const UInt32 HWERR_SUCCESS = 0;
public const UInt32 HWERR_ALLOCATE_MEMORY = 0xc1000001;
public const UInt32 HWERR_INVALID_HANDLE = 0xc1000002;
public const UInt32 HWERR_DDRAW_CREATE_FAILED = 0xc1000003;
public const UInt32 HWERR_DDRAW_CAPS_FAULT = 0xc1000004;
public const UInt32 HWERR_SET_COOPERATIVELEVEL_FAILED = 0xc1000005;
public const UInt32 HWERR_PRIMARY_SURFACE_CREATE_FAILED = 0xc1000006;
public const UInt32 HWERR_OVERLAY_CREATE_FAILED = 0xc1000007;
public const UInt32 HWERR_GET_OVERLAY_ADDRESS_FAILED = 0xc1000008;
public const UInt32 HWERR_OVERLAY_UPDATE_FAILED = 0xc1000009;
public const UInt32 HWERR_SURFACE_NULL = 0xc100000a;
public const UInt32 HWERR_FILEHEADER_UNKNOWN = 0xc100000b;
public const UInt32 HWERR_CREATE_FILE_FAILED = 0xc100000c;
public const UInt32 HWERR_FILE_SIZE_ZERO = 0xc100000d;
public const UInt32 HWERR_FILE_SIZE_INVALID = 0xc100000d;
public const UInt32 HWERR_CREATE_OBJ_FAILED = 0xc100000e;
public const UInt32 HWERR_CHANNELMAGIC_MISMATCH = 0xc100000f;
public const UInt32 HWERR_PARA_OVER = 0xc1000010;
public const UInt32 HWERR_ORDER = 0xc1000011;
public const UInt32 HWERR_COMMAND = 0xc1000012;
public const UInt32 HWERR_UNSUPPORTED = 0xc1000013;
public const UInt32 HWERR_DSPOPEN = 0xc1000014;
public const UInt32 HWERR_DSPLOAD = 0xc1000015;
public const UInt32 HWERR_ALLOCATE_DSPMEMORY = 0xc1000016;
public const UInt32 HWERR_DSPCHECHER = 0xc1000017;
public const UInt32 HWERR_IMGFILE_UNKNOWN = 0xc1000018;
public const UInt32 HWERR_INVALID_FILE = 0xc1000019;
//standart;
public const UInt32 HW_PAL = 2;
public const UInt32 HW_NTSC = 1;
//jump direction
public const UInt32 HW_JUMP_FORWARD = 309;
public const UInt32 HW_JUMP_BACKWARD = 310;
public enum TypeVideoFormat
{
vdfRGB8A_233 = 0x00000001,
vdfRGB8R_332 = 0x00000002,
vdfRGB15Alpha = 0x00000004,
vdfRGB16 = 0x00000008,
vdfRGB24 = 0x00000010,
vdfRGB24Alpha = 0x00000020,
vdfYUV420Planar = 0x00000040,
vdfYUV422Planar = 0x00000080,
vdfYUV411Planar = 0x00000100,
vdfYUV420Interspersed = 0x00000200,
vdfYUV422Interspersed = 0x00000400,
vdfYUV411Interspersed = 0x00000800,
vdfYUV422Sequence = 0x00001000, /* U0, Y0, V0, Y1: For VO overlay */
vdfYUV422SequenceAlpha = 0x00002000,
/* U0, Y0, V0, Y1: For VO overlay, with low bit for alpha blending */
vdfMono = 0x00004000, /* 8 bit monochrome */
vdfYUV444Planar = 0x00008000,
};
public enum BitrateControlType_t
{
brCBR = 0,
brVBR = 1,
};
public enum BOARD_TYPE_DS : uint
{
DS400xM = 0, //M卡
DS400XH = 1, //H卡
DS4004HC = 2, //4004HC
DS4008HC = 3, //4008HC
DS4016HC = 4, //4016HC
DS4001HF = 5, //4001HF
DS4004HF = 6, //4004HF
DS4002MD = 7, //4002MD
DS4004MD = 8, //4004MD
DS4016HCS = 9, //4016HCS
DS4002HT = 10, //4002HT
DS4004HT = 11, //4004HT
DS4008HT = 12, //4008HT
DS4004HC_PLUS = 13, //4004HC+
DS4008HC_PLUS = 14, //4008HC+
DS4016HC_PLUS = 15, //4016HC+
DS4008HF = 16, //4008HF
DS4008MD = 17, //4008MD
DS4008HS = 18, //4008HS
DS4016HS = 19, //4016HS
INVALID_BOARD_TYPE = 0xffffffff,
};
public const UInt32 STREAM_TYPE_VIDEO = 1;
public const UInt32 STREAM_TYPE_AUDIO = 2;
public const UInt32 STREAM_TYPE_AVSYNC = 3;
//public const UInt32 DRAWFUN(x) void (CALLBACK* x)(long nPort,HDC hDc,LONG nUser)
public delegate void LOGRECORD_CALLBACK(string str, IntPtr context);
public delegate int STREAM_READ_CALLBACK(UInt32 channelNumber, IntPtr context);
public delegate int STREAM_DIRECT_READ_CALLBACK(UInt32 channelNumber, IntPtr DataBuf, UInt32 Length, int FrameType, IntPtr context);
public struct CHANNEL_CAPABILITY
{
public byte bAudioPreview;
public byte bAlarmIO;
public byte bWatchDog;
}//CHANNEL_CAPABILITY, *PCHANNEL_CAPABILITY;
public struct FRAMES_STATISTICS
{
public UInt32 VideoFrames;
public UInt32 AudioFrames;
public UInt32 FramesLost;
public UInt32 QueueOverflow;
public UInt32 CurBps;
}//FRAMES_STATISTICS, *PFRAMES_STATISTICS;
[DllImport("DS40xxSDK.dll")]
public static extern int InitDSPs();
[DllImport("DS40xxSDK.dll")]
public static extern int DeInitDSPs();
[DllImport("DS40xxSDK.dll")]
public static extern IntPtr ChannelOpen(int ChannelNum);
[DllImport("DS40xxSDK.dll")]
public static extern int ChannelClose(IntPtr hChannelHandle);
[DllImport("DS40xxSDK.dll")]
public static extern int GetTotalChannels();
[DllImport("DS40xxSDK.dll")]
public static extern int GetTotalDSPs();
[DllImport("DS40xxSDK.dll")]
public static extern int StartVideoPreview(IntPtr hChannelHandle, IntPtr WndHandle, ref Rect rect, bool bOverlay, int VideoFormat, int FrameRate);
[DllImport("DS40xxSDK.dll")]
public static extern int StopVideoPreview(IntPtr hChannelHandle);
[DllImport("DS40xxSDK.dll")]
public static extern int SetVideoPara(IntPtr hChannelHandle, int Brightness, int Contrast, int Saturation, int Hue);
[DllImport("DS40xxSDK.dll")]
public static extern int GetVideoPara(IntPtr hChannelHandle, ref VideoStandard_t VideoStandard, ref int Brightness, ref int Contrast, ref int Saturation, ref int Hue);
[DllImport("DS40xxSDK.dll")]
public static extern int GetVideoSignal(IntPtr hChannelHandle);
[DllImport("DS40xxSDK.dll")]
public static extern int GetSDKVersion(ref VERSION_INFO VersionInfo);
[DllImport("DS40xxSDK.dll")]
public static extern int GetCapability(IntPtr hChannelHandle, ref CHANNEL_CAPABILITY Capability);
[DllImport("DS40xxSDK.dll")]
public static extern int GetLastErrorNum(IntPtr hChannelHandle, IntPtr DspError, IntPtr SdkError);
[DllImport("DS40xxSDK.dll")]
public static extern int SetStreamType(IntPtr hChannelHandle, UInt16 Type);
[DllImport("DS40xxSDK.dll")]
public static extern int GetStreamType(IntPtr hChannelHandle, IntPtr StreamType);
[DllImport("DS40xxSDK.dll")]
public static extern int GetFramesStatistics(IntPtr hChannelHandle, ref FRAMES_STATISTICS framesStatistics);
[DllImport("DS40xxSDK.dll")]
public static extern int StartMotionDetection(IntPtr hChannelHandle);
[DllImport("DS40xxSDK.dll")]
public static extern int GetBoardInfo(IntPtr hChannelHandle, ref uint BoardType, ref string SerialNo);
[DllImport("DS40xxSDK.dll")]
public static extern int StopMotionDetection(IntPtr hChannelHandle);
[DllImport("DS40xxSDK.dll")]
public static extern int GetOriginalImage(IntPtr hChannelHandle, byte[] ImageBuf, ref int Size);
[DllImport("DS40xxSDK.dll")]
public static extern int RegisterLogRecordCallback(LOGRECORD_CALLBACK LogRecordFunc, IntPtr Context);
[DllImport("DS40xxSDK.dll")]
public static extern int SetAudioPreview(IntPtr hChannelHandle, bool bEnable);
[DllImport("DS40xxSDK.dll")]
public static extern int ReadStreamData(IntPtr hChannelHandle, byte[] DataBuf, ref int Length, ref int FrameType);
[DllImport("DS40xxSDK.dll")]
public static extern int RegisterMessageNotifyHandle(IntPtr hWnd, UInt32 MessageId);
[DllImport("DS40xxSDK.dll")]
public static extern int StartVideoCapture(IntPtr hChannelHandle);
[DllImport("DS40xxSDK.dll")]
public static extern int StopVideoCapture(IntPtr hChannelHandle);
[DllImport("DS40xxSDK.dll")]
public static extern int SetIBPMode(IntPtr hChannelHandle, int KeyFrameIntervals, int BFrames, int PFrames, int FrameRate);
[DllImport("DS40xxSDK.dll")]
public static extern int SetDefaultQuant(IntPtr hChannelHandle, int IQuantVal, int PQuantVal, int BQuantVal);
[DllImport("DS40xxSDK.dll")]
public static extern int SetOsd(IntPtr hChannelHandle, bool Enable);
[DllImport("DS40xxSDK.dll")]
public static extern int SetLogo(IntPtr hChannelHandle, int x, int y, int w, int h, string yuv);
[DllImport("DS40xxSDK.dll")]
public static extern int StopLogo(IntPtr hChannelHandle);
[DllImport("DS40xxSDK.dll")]
public static extern int SetupMotionDetection(IntPtr hChannelHandle, Rect[] RectList, int iAreas);
[DllImport("DS40xxSDK.dll")]
public static extern int MotionAnalyzer(IntPtr hChannelHandle, byte[] MotionData, int iThreshold, int[] iResult);
[DllImport("DS40xxSDK.dll")]
public static extern int LoadYUVFromBmpFile(string FileName, string yuv, int BufLen, int Width, int Height);
[DllImport("DS40xxSDK.dll")]
public static extern int SaveYUVToBmpFile(string FileName, byte[] yuv, int Width, int Height);
[DllImport("DS40xxSDK.dll")]
public static extern int CaptureIFrame(IntPtr hChannelHandle);
[DllImport("DS40xxSDK.dll")]
public static extern int RegisterStreamReadCallback(STREAM_READ_CALLBACK StreamReadCallback, IntPtr Context);
[DllImport("DS40xxSDK.dll")]
public static extern int AdjustMotionDetectPrecision(IntPtr hChannelHandle,
int iGrade, int iFastMotionDetectFps,
int iSlowMotionDetectFps);
[DllImport("DS40xxSDK.dll")]
public static extern int SetupBitrateControl(IntPtr hChannelHandle, UInt32 MaxBps);
[DllImport("DS40xxSDK.dll")]
public static extern int SetOverlayColorKey(UInt32 DestColorKey);
[DllImport("DS40xxSDK.dll")]
public static extern int SetOsdDisplayMode(IntPtr hChannelHandle, int Brightness, bool Translucent, int parameter, ushort[] Format1, ushort[] Format2);
[DllImport("DS40xxSDK.dll")]
public static extern int SetLogoDisplayMode(IntPtr hChannelHandle, UInt32 ColorKey, bool Translucent, int TwinkleInterval);
[DllImport("DS40xxSDK.dll")]
public static extern int SetEncoderPictureFormat(IntPtr hChannelHandle, PictureFormat_t PictureFormat);
[DllImport("DS40xxSDK.dll")]
public static extern int SetVideoStandard(IntPtr hChannelHandle, VideoStandard_t VideoStandard);
[DllImport("DS40xxSDK.dll")]
public static extern int RestoreOverlay();
[DllImport("DS40xxSDK.dll")]
public static extern int ResetDSP(int DspNumber);
[DllImport("DS40xxSDK.dll")]
public static extern int GetSoundLevel(IntPtr hChannelHandle);
[DllImport("DS40xxSDK.dll")]
public static extern int SetBitrateControlMode(IntPtr hChannelHandle, BitrateControlType_t brc);
[DllImport("DS40xxSDK.dll")]
public static extern int SetupNotifyThreshold(IntPtr hChannelHandle, int iFramesThreshold);
[DllImport("DS40xxSDK.dll")]
public static extern int SetupSubChannel(IntPtr hChannelHandle, int iSubChannel);
[DllImport("DS40xxSDK.dll")]
public static extern int GetSubChannelStreamType(IntPtr DataBuf, int FrameType);
//add for HC/HF
[DllImport("DS40xxSDK.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern int RegisterStreamDirectReadCallback(STREAM_DIRECT_READ_CALLBACK StreamDirectReadCallback, IntPtr Context);
//[DllImport("DS40xxSDK.dll")]
//public static extern int RegisterDrawFun(UInt32 nport, DRAWFUN(DrawFun),LONG nUser);
[DllImport("DS40xxSDK.dll")]
public static extern int SetupMask(IntPtr hChannelHandle, Rect[] RectList, int iAreas);
[DllImport("DS40xxSDK.dll")]
public static extern int StopMask(IntPtr hChannelHandle);
[DllImport("DS40xxSDK.dll")]
public static extern int SetSubEncoderPictureFormat(IntPtr hChannelHandle, PictureFormat_t PictureFormat);
[DllImport("DS40xxSDK.dll")]
public static extern int StartSubVideoCapture(IntPtr hChannelHandle);
[DllImport("DS40xxSDK.dll")]
public static extern int StopSubVideoCapture(IntPtr hChannelHandle);
[DllImport("DS40xxSDK.dll")]
public static extern int SetupDateTime(IntPtr hChannelHandle, ref SystemTime now);
//原始图像流设置
public delegate void IMAGE_STREAM_CALLBACK(UInt32 channelNumber, IntPtr context);
[DllImport("DS40xxSDK.dll")]
public static extern int SetImageStream(IntPtr hChannel, bool bStart, UInt32 fps, UInt32 width, UInt32 height, string imageBuffer);
[DllImport("DS40xxSDK.dll")]
public static extern int RegisterImageStreamCallback(IMAGE_STREAM_CALLBACK ImageStreamCallback, IntPtr context);
/*
设置视频输入位置:
(x,y)为系统所处理图像的左上角在摄像机输入的原始图像中的坐标。
x必须为2的整数倍。
(x,y)坐标的参数范围和摄像机的型号有关,如果指定的值和摄像机的输入不匹配,
可能会导致图像静止或水平、垂直方向滚动。
*/
[DllImport("DS40xxSDK.dll")]
public static extern int SetInputVideoPosition(IntPtr hChannel, UInt32 x, UInt32 y);
[DllImport("DS40xxSDK.dll")]
public static extern int StopRegisterDrawFun(UInt32 nport);
/*
3.0
*/
public const UInt32 SERIAL_NUMBER_LENGTH = 12; //板卡序列号长度
public struct DS_BOARD_DETAIL
{
public BOARD_TYPE_DS type; //板卡类型
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public byte[] sn; //序列号
public UInt32 dspCount; //板卡包含的DSP个数
public UInt32 firstDspIndex; //板卡上第一个DSP的索引
public UInt32 encodeChannelCount; //板卡包含的编码通道个数
public UInt32 firstEncodeChannelIndex; //板卡上第一个编码通道的索引
public UInt32 decodeChannelCount; //板卡包含的解码通道个数
public UInt32 firstDecodeChannelIndex; //板卡上第一个解码通道的索引
public UInt32 displayChannelCount; //板卡包含的视频输出通道个数
public UInt32 firstDisplayChannelIndex; //板卡上第一个视频输出通道的索引
public UInt32 reserved1;
public UInt32 reserved2;
public UInt32 reserved3;
public UInt32 version; //硬件版本,format:major.minor.build,major:bit 16-19,minor: bit 8-15,build: bit 0-7
};
public struct DSP_DETAIL
{
public UInt32 encodeChannelCount; //板卡包含的编码通道个数
public UInt32 firstEncodeChannelIndex; //板卡上第一个编码通道的索引
public UInt32 decodeChannelCount; //板卡包含的解码通道个数
public UInt32 firstDecodeChannelIndex; //板卡上第一个解码通道的索引
public UInt32 displayChannelCount; //板卡包含的视频输出通道个数
public UInt32 firstDisplayChannelIndex; //板卡上第一个视频输出通道的索引
public UInt32 reserved1;
public UInt32 reserved2;
public UInt32 reserved3;
public UInt32 reserved4;
};
[DllImport("DS40xxSDK.dll")]
public static extern UInt32 GetBoardCount();
[DllImport("DS40xxSDK.dll")]
public static extern int GetBoardDetail(UInt32 boardNum, ref DS_BOARD_DETAIL pBoardDetail);
[DllImport("DS40xxSDK.dll")]
public static extern UInt32 GetDspCount();
[DllImport("DS40xxSDK.dll")]
public static extern int GetDspDetail(UInt32 dspNum, ref DSP_DETAIL pDspDetail);
[DllImport("DS40xxSDK.dll")]
public static extern UInt32 GetEncodeChannelCount();
[DllImport("DS40xxSDK.dll")]
public static extern UInt32 GetDecodeChannelCount();
[DllImport("DS40xxSDK.dll")]
public static extern UInt32 GetDisplayChannelCount();
[DllImport("DS40xxSDK.dll")]
public static extern int SetDefaultVideoStandard(VideoStandard_t VideoStandard);
[DllImport("DS40xxSDK.dll")]
public static extern int SetVideoDetectPrecision(IntPtr hChannel, UInt32 value);
[DllImport("DS40xxSDK.dll")]
public static extern int SetSubStreamType(IntPtr hChannelHandle, UInt16 Type);
[DllImport("DS40xxSDK.dll")]
public static extern int GetSubStreamType(IntPtr hChannelHandle, IntPtr StreamType);
public const UInt32 MAX_DISPLAY_REGION = 16;
public struct REGION_PARAM
{
public UInt32 left;
public UInt32 top;
public UInt32 width;
public UInt32 height;
public UInt32 color;
public UInt32 param;
};
[DllImport("DS40xxSDK.dll")]
public static extern int SetDisplayStandard(UInt32 nDisplayChannel, VideoStandard_t VideoStandard);
[DllImport("DS40xxSDK.dll")]
public static extern int SetDisplayRegion(UInt32 nDisplayChannel, UInt32 nRegionCount, REGION_PARAM[] pParam, UInt32 nReserved);
[DllImport("DS40xxSDK.dll")]
public static extern int ClearDisplayRegion(UInt32 nDisplayChannel, UInt32 nRegionFlag);
[DllImport("DS40xxSDK.dll")]
public static extern int SetDisplayRegionPosition(UInt32 nDisplayChannel, UInt32 nRegion, UInt32 nLeft, UInt32 nTop);
[DllImport("DS40xxSDK.dll")]
public static extern int FillDisplayRegion(UInt32 nDisplayChannel, UInt32 nRegion, string pImage);
[DllImport("DS40xxSDK.dll")]
public static extern int SetEncoderVideoExtOutput(UInt32 nEncodeChannel, UInt32 nPort, bool bOpen, UInt32 nDisplayChannel, UInt32 nDisplayRegion, UInt32 nReserved);
[DllImport("DS40xxSDK.dll")]
public static extern int SetDecoderVideoExtOutput(UInt32 nDecodeChannel, UInt32 nPort, bool bOpen, UInt32 nDisplayChannel, UInt32 nDisplayRegion, UInt32 nReserved);
[DllImport("DS40xxSDK.dll")]
public static extern int SetDecoderVideoOutput(UInt32 nDecodeChannel, UInt32 nPort, bool bOpen, UInt32 nDisplayChannel, UInt32 nDisplayRegion, UInt32 nReserved);
[DllImport("DS40xxSDK.dll")]
public static extern int SetDecoderAudioOutput(UInt32 nDecodeChannel, bool bOpen, UInt32 nOutputChannel);
//3.1
[DllImport("DS40xxSDK.dll")]
public static extern int SetDeInterlace(IntPtr hChannelHandle, UInt32 mode, UInt32 level);
[DllImport("DS40xxSDK.dll")]
public static extern int SetPreviewOverlayMode(bool bTrue);
//DECODE functions for MD card
public struct DISPLAY_PARA
{
public long bToScreen;
public long bToVideoOut;
public long nLeft;
public long nTop;
public long nWidth;
public long nHeight;
public long nReserved;
}//DISPLAY_PARA,*PDISPLAY_PARA;
//Version info
public struct HW_VERSION
{
public UInt32 DspVersion, DspBuildNum;
public UInt32 DriverVersion, DriverBuildNum;
public UInt32 SDKVersion, SDKBuildNum;
}//HW_VERSION, *PHW_VERSION;
//init part
[DllImport("DS40xxSDK.dll")]
public static extern int HW_InitDirectDraw(IntPtr hParent, UInt32 colorKey);
[DllImport("DS40xxSDK.dll")]
public static extern int HW_ReleaseDirectDraw();
[DllImport("DS40xxSDK.dll")]
public static extern int HW_InitDecDevice(ref int pDeviceTotal);
[DllImport("DS40xxSDK.dll")]
public static extern int HW_ReleaseDecDevice();
[DllImport("DS40xxSDK.dll")]
public static extern int HW_ChannelOpen(uint nChannelNum, ref IntPtr phChannel);
[DllImport("DS40xxSDK.dll")]
public static extern int HW_ChannelClose(IntPtr hChannel);
//open part
[DllImport("DS40xxSDK.dll")]
public static extern int HW_OpenStream(IntPtr hChannel, byte[] pFileHeadBuf, int nSize);
[DllImport("DS40xxSDK.dll")]
public static extern int HW_ResetStream(IntPtr hChannel);
[DllImport("DS40xxSDK.dll")]
public static extern int HW_CloseStream(IntPtr hChannel);
[DllImport("DS40xxSDK.dll")]
public static extern int HW_InputData(IntPtr hChannel, byte[] pBuf, int nSize);
[DllImport("DS40xxSDK.dll")]
public static extern int HW_InputData(IntPtr hChannel, System.IntPtr bufferAddress , int nSize);
[DllImport("DS40xxSDK.dll")]
public static extern int HW_OpenFile(IntPtr hChannel, string sFileName);
[DllImport("DS40xxSDK.dll")]
public static extern int HW_CloseFile(IntPtr hChannel);
//play part
[DllImport("DS40xxSDK.dll")]
public static extern int HW_SetDisplayPara(IntPtr hChannel, ref DISPLAY_PARA pPara);
[DllImport("DS40xxSDK.dll")]
public static extern int HW_Play(IntPtr hChannel);
[DllImport("DS40xxSDK.dll")]
public static extern int HW_Stop(IntPtr hChannel);
[DllImport("DS40xxSDK.dll")]
public static extern int HW_Pause(IntPtr hChannel, UInt32 bPause);
//sound part
[DllImport("DS40xxSDK.dll")]
public static extern int HW_PlaySound(IntPtr hChannel);
[DllImport("DS40xxSDK.dll")]
public static extern int HW_StopSound(IntPtr hChannel);
[DllImport("DS40xxSDK.dll")]
public static extern int HW_SetVolume(IntPtr hChannel, UInt32 nVolume);
//overlay part
[DllImport("DS40xxSDK.dll")]
public static extern int HW_RefreshSurface();
[DllImport("DS40xxSDK.dll")]
public static extern int HW_RestoreSurface();
[DllImport("DS40xxSDK.dll")]
public static extern int HW_ClearSurface();
[DllImport("DS40xxSDK.dll")]
public static extern int HW_ZoomOverlay(Rect[] pSrcClientRect, Rect[] pDecScreenRect);
//cut file
[DllImport("DS40xxSDK.dll")]
public static extern int HW_StartCapFile(IntPtr hChannel, string sFileName);
[DllImport("DS40xxSDK.dll")]
public static extern int HW_StopCapFile(IntPtr hChannel);
//capture picture
[DllImport("DS40xxSDK.dll")]
public static extern int HW_GetYV12Image(IntPtr hChannel, UInt16[] pBuffer, UInt32 nSize);
[DllImport("DS40xxSDK.dll")]
public static extern int HW_GetPictureSize(IntPtr hChannel, IntPtr pWidth, IntPtr pHeight);
[DllImport("DS40xxSDK.dll")]
public static extern int HW_ConvertToBmpFile(string pBuf, UInt32 nSize, UInt32 nWidth, UInt32 nHeight, string sFileName, UInt32 nReserved);
//setting and getting part
[DllImport("DS40xxSDK.dll")]
public static extern int HW_Jump(IntPtr hChannel, UInt32 nDirection);
[DllImport("DS40xxSDK.dll")]
public static extern int HW_SetJumpInterval(IntPtr hChannel, UInt32 nSecond);
[DllImport("DS40xxSDK.dll")]
public static extern int HW_GetSpeed(IntPtr hChannel, IntPtr pSpeed);
[DllImport("DS40xxSDK.dll")]
public static extern int HW_SetSpeed(IntPtr hChannel, long nSpeed);
[DllImport("DS40xxSDK.dll")]
public static extern int HW_SetPlayPos(IntPtr hChannel, UInt32 nPos);
[DllImport("DS40xxSDK.dll")]
public static extern int HW_GetPlayPos(IntPtr hChannel, IntPtr pPos);
//[DllImport("DS40xxSDK.dll")]
//public static extern int HW_GetVersion(PHW_VERSION pVersion);
[DllImport("DS40xxSDK.dll")]
public static extern int HW_GetCurrentFrameRate(IntPtr hChannel, IntPtr pFrameRate);
[DllImport("DS40xxSDK.dll")]
public static extern int HW_GetCurrentFrameNum(IntPtr hChannel, IntPtr pFrameNum);
[DllImport("DS40xxSDK.dll")]
public static extern int HW_GetFileTotalFrames(IntPtr hChannel, IntPtr pTotalFrames);
[DllImport("DS40xxSDK.dll")]
public static extern int HW_GetFileTime(IntPtr hChannel, IntPtr pFileTime);
[DllImport("DS40xxSDK.dll")]
public static extern int HW_GetCurrentFrameTime(IntPtr hChannel, IntPtr pFrameTime);
[DllImport("DS40xxSDK.dll")]
public static extern int HW_GetPlayedFrames(IntPtr hChannel, IntPtr pDecVFrames);
[DllImport("DS40xxSDK.dll")]
public static extern int HW_GetDeviceSerialNo(IntPtr hChannel, IntPtr pDeviceSerialNo);
[DllImport("DS40xxSDK.dll")]
public static extern int HW_SetFileEndMsg(IntPtr hChannel, IntPtr hWnd, UInt32 nMsg);
[DllImport("DS40xxSDK.dll")]
public static extern int HW_SetStreamOpenMode(IntPtr hChannel, UInt32 nMode);
[DllImport("DS40xxSDK.dll")]
public static extern int HW_GetStreamOpenMode(IntPtr hChannel, IntPtr pMode);
[DllImport("DS40xxSDK.dll")]
public static extern int HW_SetVideoOutStandard(IntPtr hChannel, UInt32 nStandard);
[DllImport("DS40xxSDK.dll")]
public static extern int HW_SetDspDeadlockMsg(IntPtr hWnd, UInt32 nMsg);
[DllImport("DS40xxSDK.dll")]
public static extern int HW_GetChannelNum(long nDspNum, IntPtr pChannelNum, UInt32 nNumsToGet, IntPtr pNumsGotten);
[DllImport("DS40xxSDK.dll")]
public static extern int HW_ResetDsp(long nDspNum);
[DllImport("DS40xxSDK.dll")]
public static extern int HW_SetAudioPreview(IntPtr hChannel, bool bEnable);
//////////////////////////////////////////////
[DllImport("DS40xxSDK.dll")]
public static extern int HW_OpenStreamEx(IntPtr hChannel, UInt16[] pFileHeadBuf, UInt32 nSize);
[DllImport("DS40xxSDK.dll")]
public static extern int HW_CloseStreamEx(IntPtr hChannel);
[DllImport("DS40xxSDK.dll")]
public static extern int HW_InputVideoData(IntPtr hChannel, UInt16[] pBuf, UInt32 nSize);
[DllImport("DS40xxSDK.dll")]
public static extern int HW_InputAudioData(IntPtr hChannel, UInt16[] pBuf, UInt32 nSize);
//4.0
[DllImport("DS40xxSDK.dll")]
public static extern int SetOsdDisplayModeEx(IntPtr hChannelHandle, int color, bool Translucent, int param, int nLineCount, IntPtr Format);
public delegate void MOTION_DETECTION_CALLBACK(UInt32 channelNumber, bool bMotionDetected, IntPtr context);
[DllImport("DS40xxSDK.dll")]
public static extern int SetupMotionDetectionEx(IntPtr hChannelHandle, int iGrade, int iFastMotionDetectFps,
int iSlowMotionDetectFps, UInt32 delay, Rect[] RectList, int iAreas,
MOTION_DETECTION_CALLBACK MotionDetectionCallback, int reserved);
[DllImport("DS40xxSDK.dll")]
public static extern int GetJpegImage(IntPtr hChannelHandle, byte[] ImageBuf, ref int Size, UInt32 nQuality);
//WatchDog
[DllImport("DS40xxSDK.dll")]
public static extern int SetWatchDog(UInt32 boardNumber, bool bEnable);
//4.1
public delegate void FILE_REF_DONE_CALLBACK(UInt32 nChannel, UInt32 nSize);
[DllImport("DS40xxSDK.dll")]
public static extern int HW_SetFileRef(IntPtr hChannel, bool bEnable, FILE_REF_DONE_CALLBACK FileRefDoneCallback);
[DllImport("DS40xxSDK.dll")]
public static extern int HW_LocateByAbsoluteTime(IntPtr hChannel, SystemTime time);
[DllImport("DS40xxSDK.dll")]
public static extern int HW_LocateByFrameNumber(IntPtr hChannel, UInt32 frmNum);
[DllImport("DS40xxSDK.dll")]
public static extern int HW_GetCurrentAbsoluteTime(IntPtr hChannel, ref SystemTime pTime);
[DllImport("DS40xxSDK.dll")]
public static extern int HW_GetFileAbsoluteTime(IntPtr hChannel, ref SystemTime pStartTime, ref SystemTime pEndTime);
//4.2
[DllImport("DS40xxSDK.dll")]
public static extern int HW_ImportFileRef(IntPtr hChannel, string pBuffer, UInt32 nSize);
[DllImport("DS40xxSDK.dll")]
public static extern int HW_ExportFileRef(IntPtr hChannel, string pBuffer, UInt32 nSize);
[DllImport("DS40xxSDK.dll")]
public static extern int SetDisplayVideoCapture(UInt32 nDisplayChannel, bool bStart, UInt32 fps, UInt32 width, UInt32 height, string imageBuffer);
[DllImport("DS40xxSDK.dll")]
public static extern int RegisterDisplayVideoCaptureCallback(IMAGE_STREAM_CALLBACK DisplayVideoCaptureCallback, IntPtr context);
[DllImport("DS40xxSDK.dll")]
public static extern int SetDisplayVideoBrightness(UInt32 chan, int Brightness);
[DllImport("DS40xxSDK.dll")]
public static extern int SetChannelStreamCRC(IntPtr hChannel, bool bEnable);
[DllImport("DS40xxSDK.dll")]
public static extern int SetSubChannelStreamCRC(IntPtr hChannel, bool bEnable);
[DllImport("DS40xxSDK.dll")]
public static extern int HW_SetDecoderPostProcess(IntPtr hChannel, UInt32 param);
//
public delegate void DECODER_VIDEO_CAPTURE_CALLBACK(UInt32 nChannelNumber, IntPtr DataBuf, UInt32 width, UInt32 height, UInt32 nFrameNum, UInt32 nFrameTime, ref SystemTime pFrameAbsoluteTime, IntPtr context);
[DllImport("DS40xxSDK.dll")]
public static extern int RegisterDecoderVideoCaptureCallback(DECODER_VIDEO_CAPTURE_CALLBACK DecoderVideoCaptureCallback, IntPtr context);
[DllImport("DS40xxSDK.dll")]
public static extern int HW_SetDecoderVideoCapture(IntPtr hChannel, bool bStart, UInt32 param);
[DllImport("DS40xxSDK.dll")]
public static extern int HW_InputDataByFrame(IntPtr hChannel, UInt16[] pBuf, UInt32 nSize);
/*
人脸检测接口:仅供测试、评估,以后可能会做修改。
*/
public struct FACE_AREA_DEMO
{
public short x, y, width, height;
};
public struct FACE_INFO_DEMO
{
public FACE_AREA_DEMO faceArea;
public FACE_AREA_DEMO leftEyeArea;
public FACE_AREA_DEMO rightEyeArea;
public FACE_AREA_DEMO leftPupilArea;
public FACE_AREA_DEMO rightPupilArea;
public FACE_AREA_DEMO noseArea;
public FACE_AREA_DEMO mouthArea;
};
public delegate void FACE_DETECTION_DEMO_CALLBACK(UInt32 nChannel, UInt32 nFaceCount, ref FACE_INFO_DEMO pFaceInfo,
string pData, UInt32 nDataSize, UInt32 nImageWidth, UInt32 nImageHeight);
[DllImport("DS40xxSDK.dll")]
public static extern int SetFaceDetectionDemo(IntPtr hChannelHandle, bool bEnable,
UInt32 nFrameInterval, FACE_DETECTION_DEMO_CALLBACK pFunc,
bool bCompress, UInt32 nCompressQuality, bool bLocateEyePos);
public struct SystemTime
{
public short wYear;
public short wMonth;
public short wDayOfWeek;
public short wDay;
public short wHour;
public short wMinute;
public short wSecond;
public short wMilliseconds;
}
[StructLayout(LayoutKind.Sequential)]
public struct Point
{
public int x;
public int y;
}
[StructLayout(LayoutKind.Explicit)]
public struct Rect
{
[FieldOffset(0)]
public int left;
[FieldOffset(4)]
public int top;
[FieldOffset(8)]
public int right;
[FieldOffset(12)]
public int bottom;
}
public struct TMFRAME_HEADER
{
/// <summary>
/// 00000000000000000000000000010b
/// </summary>
public uint SyncId;
public uint Magic;
/// <summary>
/// I frames , P frames or BBP frames Audio frames or dsp status etc
/// </summary>
public ushort FrameType;
/// <summary>
/// lenth include this header
/// </summary>
public uint Length;
/// <summary>
/// serial number of this frame
/// </summary>
public uint FrameNumber;
/// <summary>
/// indicate if stream breakable, you could restart new file(with PktSysHeader) if true
/// </summary>
public sbyte Breakable;
/// <summary>
/// system clock when this frames is processed
/// </summary>
public uint PTS;
}
public struct VERSION_INFO
{
public uint DspVersion;
public int DspBuildNum;
public uint DriverVersion;
public uint driverBuildNum;
public uint SDKVersion;
public uint SDKBuildNum;
}
public struct MOTION_DATA_HEADER
{
public PictureFormat_t PicFormat;
public uint HorizeBlocks;
public uint VerticalBlocks;
public uint BlockSize;
}
public enum VideoStandard_t : uint
{
StandardNone = 0x80000000,
StandardNTSC = 0x00000001,
StandardPAL = 0x00000002,
StandardSECAM = 0x00000004,
};
public enum FrameType_t
{
PktError = 0,
PktIFrames = 0x0001,
PktPFrames = 0x0002,
PktBBPFrames = 0x0004,
PktAudioFrames = 0x0008,
PktMotionDetection = 0x00010,
PktDspStatus = 0x00020,
PktOrigImage = 0x00040,
PktSysHeader = 0x00080,
PktBPFrames = 0x00100,
PktSFrames = 0x00200,
PktSubIFrames = 0x00400,
PktSubPFrames = 0x00800,
PktSubBBPFrames = 0x01000,
PktSubSysHeader = 0x02000
};
public enum PictureFormat_t
{
ENC_CIF_FORMAT = 0,
ENC_QCIF_FORMAT = 1,
ENC_2CIF_FORMAT = 2,
ENC_4CIF_FORMAT = 3,
ENC_QQCIF_FORMAT = 4,
ENC_CIFQCIF_FORMAT = 5,
ENC_CIFQQCIF_FORMAT = 6,
ENC_DCIF_FORMAT = 7
};
public const int FRAME_HEAD_MAGIC = 0x03211546;
public const int _OSD_BASE = 0x9000;
public const int _OSD_YEAR4 = _OSD_BASE + 0;
public const int _OSD_YEAR2 = _OSD_BASE + 1;
public const int _OSD_MONTH3 = _OSD_BASE + 2;
public const int _OSD_MONTH2 = _OSD_BASE + 3;
public const int _OSD_DAY = _OSD_BASE + 4;
public const int _OSD_WEEK3 = _OSD_BASE + 5;
public const int _OSD_CWEEK1 = _OSD_BASE + 6;
public const int _OSD_HOUR24 = _OSD_BASE + 7;
public const int _OSD_HOUR12 = _OSD_BASE + 8;
public const int _OSD_MINUTE = _OSD_BASE + 9;
public const int _OSD_SECOND = _OSD_BASE + 10;
public enum StreamType
{
VIDEO = 1,//视频流
AUDIO = 2, //音频流
AVSYNC = 3 //音视频同步流
}
}
}