unit ds40xxsdk;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs;
const
ERR_WAIT_TIMEOUT =$c0000001;
ERR_INVALID_HANDLE =$c0000002;
ERR_INVALID_ARGUMENT =$c0000003;
ERR_DDRAW_CREATE_FAILED =$c0000004;
ERR_DDRAW_CAPS_FAULT =$c0000005;
ERR_SET_COOPERATIVELEVEL_FAILED =$c0000006;
ERR_PRIMARY_SURFACE_CREATE_FAILED =$c0000007;
ERR_GET_OVERLAY_ADDRESS_FAILED =$c0000008;
ERR_OVERLAY_SURFACE_CREATE_FAILED=$c0000009;
ERR_OVERLAY_UPDATE_FAILED =$c000000a;
ERR_TMMAN_FAILURE =$c000000b;
ERR_CHANNELMAGIC_MISMATCH=$c000000c;
ERR_CALLBACK_REGISTERED=$c000000d;
ERR_QUEUE_OVERFLOW =$c000000e;
ERR__STREAM_THREAD_FAILURE =$c000000f;
ERR_THREAD_STOP_ERROR =$c0000010;
ERR_NOT_SUPPORT =$c0000011;
ERR_OUTOF_MEMORY =$c0000012;
ERR_DSP_BUSY =$c0000013;
ERR_DATA_ERROR =$c0000014;
STREAM_TYPE_VIDEO=1;
STREAM_TYPE_AUDIO=2 ;
STREAM_TYPE_AVSYNC=3 ;
END_CODE=$00000002;
StandarNone=$80000000;
StandardNTSC=$1;
StandardPAL=$2;
StandardSECAM=$4;
vdfRGB8A_233 = $00000001;
vdfRGB8R_332 = $00000002;
vdfRGB15Alpha = $00000004;
vdfRGB16 = $00000008;
vdfRGB24 = $00000010;
vdfRGB24Alpha = $00000020;
vdfYUV420Planar = $00000040;
vdfYUV422Planar = $00000080;
vdfYUV411Planar = $00000100;
vdfYUV420Interspersed = $00000200;
vdfYUV422Interspersed = $00000400;
vdfYUV411Interspersed = $00000800;
vdfYUV422Sequence = $00001000;
vdfYUV422SequenceAlpha = $00002000;
vdfMono = $00004000;
vdfYUV444Planar = $00008000;
FRAME_HEAD_MAGIC=$03211546;
SYSTM_SYNC_ID=2;
FRAME_BUF_SIZE=512*1024;
FRAME_STACK_SIZE=400;
FRAME_INFO_HEADER_MAGIC=$20020620;
type
Framtype_t=( PktError=0,
PktIFrams=$0001,
PktPFrames=$0002,
PktBBPFrames=$0004,
PktAudioFrames=$0008,
PktMotionDetection=$00010,
PktDspStatus=$00020,
PktOrigImage=$00040,
PktSysHeader=$00080,
PktBPFrames=$00100,
PktSFrames=$00200
);
type
TPictureFormat_t=(ENC_CIF=0,ENC_QCIF=1,ENC_2CIF=2,ENC_4CIF=3,ENC_QQCIF=4,
ENC_CIFQCIF=5,ENC_CIFQQCIF=6);
type
TVideoStandard_t=packed record
StandarNone:integer;
StandarNTSC:integer;
StandarPAL:integer;
end;
VideoStandard_t=TVideoStandard_t;
pVideoStandard_t=^TVideoStandard_t;
type
Tbitratecontroltype_t=(brCBR=0,brvbr=1);
type
BOARD_TYPE_DS = (
DS400XM =0,
DS400XH =1,
DS4004HC =2,
DS4008HC =3,
DS4016HC =4,
DS4001HF =5,
DS4004HF =6,
DS4002MD =7,
DS4004MD =8,
DS4016HCS =9,
DS4002HT =10,
DS4004HT =11,
DS4008HT =12,
DS4004HC_PLUS =13,
DS4008HC_PLUS =14,
DS4016HC_PLUS =15,
INVALID_BOard_type=16);
type
Ttagframeinfo=packed record
syncid:cardinal;
frametype:integer;
leng:cardinal;
framenumber:cardinal;
breakable:byte;
PTS:cardinal;
end;
tagframeinfo=Ttagframeinfo;
pPFREAME_HEADER=^Ttagframeinfo;
type
TtagChannelCapability = packed record
bAudioPreview: pCHAR;
bAlarmIO: pCHAR;
bWatchDog: pCHAR;
end;
tagChannelCapability=TtagChannelCapability ;
pChannelCapability=^TtagChannelCapability;
type
DS_BOARD_DETAIL = packed record
ptype: BOARD_TYPE_DS;
sn: Array[0..16-1] of BYTE;
dspCount: Word;
firstDspIndex: Word;
encodeChannelCount: Word;
firstEncodeChannelIndex: Word;
decodeChannelCount: Word;
firstDecodeChannelIndex: Word;
displayChannelCount: Word;
firstDisplayChannelIndex: Word;
reserved1: Word;
reserved2: Word;
reserved3: Word;
reserved4: Word;
end ;
type
DSP_DETAIL = packed record
encodeChannelCount: Word;
firstEncodeChannelIndex: Word;
decodeChannelCount: Word;
firstDecodeChannelIndex: Word;
displayChannelCount: Word;
firstDisplayChannelIndex: Word;
reserved1: Word;
reserved2: Word;
reserved3: Word;
reserved4: Word;
end ;
type
TtagMotionData=packed record
PicFormat:integer;
HorizeBlocks:cardinal;
VerticalBlocks:cardinal;
BlockSize:cardinal;
end;
tagmotiondata=TTagmotiondata;
pTagmotiondata=^Ttagmotiondata;
type
TVersion_INFO=packed record
DspVersion:longword;
DspBuildNum:longword;
DriverVersion:longword;
DriverBuildNum:longword;
SDKVersion:longword;
SDKBuildNum:longword;
end;
Version_INFO=TVersion_INFO;
pVersion_INFO=^TVersion_INFO;
type
TtagFramsStatistics=packed record
VideoFrames:longword;
AudioFrames:longword;
FramesLost:longword;
CurBps:longword;
end;
tagFramsStatistics=TTagFramsStatistics;
pTagFramsStatistics=^TtagFramsStatistics;
type
rtt=TRECT;
prtt=^rtt;
type
TDrawFun = procedure(nport:integer;hDc:HDC;nUser:integer);stdcall;
function InitDSPs():integer;stdcall;
function DeInitDSPs():integer;stdcall;
function ChannelOpen(ChannelNum:integer):integer;stdcall;
function ChannelClose(hChannelHandle:integer ):integer;stdcall;
function GetTotalChannels():integer;stdcall;
function GetTotalDSPs():integer;stdcall;
function GetBoardCount():integer;stdcall;
function GetDspCount():integer;stdcall;
function GetBoardInfo(hChannelHandle:integer;BoardType
LongWord;SerialNo
char):integer;stdcall;
function GetBoardDetail(boardNum:integer;pBoardDetail
S_Board_Detail):integer;stdcall;
function GetDspDetail(dspNum:integer;pDspDetail
SP_DETAIL):integer;stdcall;
function GetEncodeChannelCount():integer;stdcall;
function GetDecodeChannelCount():integer;stdcall;
function GetDisplayChannelCount():integer;stdcall;
function GetVideoSignal(hChannelHandle:integer):integer;stdcall;
function GetCapability(hChannelHandle:integer;Capability: pChannelCapability):integer;stdcall;
function SetPreviewOverlayMode(bTrue:bool):integer;stdcall;
function GetVideoPara(hChannelHandle:integer;VideoStandard
VideoStandard_t;Brightness:integer;
Contrast:integer;Saturation:integer;Hue:integer):integer;stdcall;
function GetSDKVersion(VersionInfo
VERSION_INFO):longword;stdcall;
function GetFramesStatistics(hChannelHandle:integer;framesStatistics
TagFramsStatistics):integer;stdcall;
function SetEncoderPictureFormat(channelhandle:integer;PictureFormat:TPictureFormat_t):integer;stdcall;
function SetupNotifyThreshold(channelhandle:integer;iframesthreshold:integer):integer;stdcall;
function RegisterMessageNotifyHandle(hwnd:HWND;MessageId:integer):integer;stdcall;
function SetOverlayColorKey(destcolorkey:colorref):integer;stdcall;
function SetOsd(hChannelHandle:integer;Enable:bool):integer;stdcall;
//gy
function SetOsdDisplayMode(hChannelHandle:integer;Brightness:integer;Translucent:bool;param:integer;Format1,format2
ointer):integer;stdcall;
//function SetOsdDisplayMode(hChannelHandle:integer;Brightness:integer;Translucent:bool;param:integer;Format1
char):integer;stdcall;
function LoadYUVFromBMPFile(FileName
char;YUV
char;BufLen:integer;Width
integer;Height
integer):integer;stdcall;
function SetLogo(hChannelhandle:integer;x,y,w,h:integer;yuv
char):integer;stdcall;
function SetVideoDetectPrecision(hchannelhandle:integer;value:integer):integer;stdcall;
function SetInputVideoPosition(hChannelHandle:integer;X,Y:integer):integer;stdcall;
function SetBitrateControlMode(hChannelHandle:integer;brc:Tbitratecontroltype_t):integer;stdcall;
function SetupBitrateControl(hChannelHandle:integer;maxbps:cardinal):integer;stdcall;
function SetIBPMode(hChannelHandle:integer;keyframeintervals:integer;bframes:integer;
PFrames:integer;FrameRate:integer):integer;stdcall;
function SetStreamType(hChannel:integer;tpe:byte):integer;stdcall;
function StartVideoPreview(hchannelhandle:integer;wndhandle:HWND;rt
rtt;
boverlay:BOOLEAN;videoformat:integer;framerate:integer):integer;stdcall;
function StopVideoPreview(hChannelHandle:integer):integer;stdcall;
function StartVideoCapture(hChannelHandle:integer):integer;stdcall;
function StopVideoCapture(hChannelHandle:integer):integer;stdcall;
function StartSubVideoCapture(hChannelHandle:integer):integer;stdcall;
function StopSubVideoCapture(hChannelHandle:integer):integer;stdcall;
function SetImageStream(hChannelHandle:integer;bStart:bool;fps:integer;width:integer;height:integer;imageBuffer
char):integer;stdcall;
function ReadStreamData(hChannelHandle:integer;const DataBuf;Len
dword;FrameType
integer):integer;stdcall;
function GetSubChannelStreamType(const databuf;frametype:integer):integer;stdcall;
//function MotionAnalyzer(hChannelHandle:integer;MotionData
byte;iThreshold:integer;iResult
integer):integer;stdcall;
function RegisterDrawFun(nport:integer;drawfun:TDrawFun;nUser:integer):integer;stdcall;far;
function SetupSubChannel(hchannel:integer;ihchannel:integer):integer;stdcall;
function GetOriginalImage(hChannelHandle:integer;ImageBuf
Char;Size
LongWord):Integer;stdcall;
function SaveYUVToBmpFile(FileName
Char;yuv
Char;Width,Height:Integer):Integer;stdcall;
function SetAudioPreview(hChannelHandle:integer;bEnable:bool):Integer;stdcall;
function GetSoundLevel(hChannelHandle:integer):Integer;stdcall;
var
msgdataready,MsgUpdateCounters:integer;
savfile:string; //录像保存的文件名
implementation
// {$R *.dfm}
function InitDSPs;external 'ds40xxsdk.dll' name 'InitDSPs';
function DeInitDSPs;external 'ds40xxsdk.dll' name 'DeInitDSPs';
function ChannelOpen;external 'ds40xxsdk.dll' name 'ChannelOpen';
function ChannelClose;external 'ds40xxsdk.dll' name 'ChannelClose';
function GetTotalChannels;external 'ds40xxsdk.dll' name 'GetTotalChannels';
function GetTotalDSPs;external 'ds40xxsdk.dll' name 'GetTotalDSPs';
function GetBoardCount;external 'ds40xxsdk.dll' name 'GetBoardCount';
function GetDspCount;external 'ds40xxsdk.dll' name 'GetDspCount';
function GetBoardDetail;external 'ds40xxsdk.dll' name 'GetBoardDetail';
function GetDspDetail;external 'ds40xxsdk.dll' name 'GetDspDetail';
function GetBoardInfo;external 'ds40xxsdk.dll' name 'GetBoardInfo';
function GetEncodeChannelCount;external 'ds40xxsdk.dll' name 'GetEncodeChannelCount';
function GetDecodeChannelCount;external 'ds40xxsdk.dll' name 'GetDecodeChannelCount';
function GetDisplayChannelCount;external 'ds40xxsdk.dll' name 'GetDisplayChannelCount';
function GetVideoSignal;external 'ds40xxsdk.dll' name 'GetVideoSignal';
function GetCapability;external 'ds40xxsdk.dll' name 'GetCapability';
function GetVideoPara;external 'ds40xxsdk.dll' name 'GetVideoPara';
function GetSDKVersion;external 'ds40xxsdk.dll' name 'GetSDKVersion';
function GetFramesStatistics;external 'ds40xxsdk.dll' name 'GetFramesStatistics';
function SetPreviewOverlayMode;external 'ds40xxsdk.dll' name 'SetPreviewOverlayMode';
function SetEncoderPictureFormat;external 'ds40xxsdk.dll' name 'SetEncoderPictureFormat';
function SetupNotifyThreshold;external 'ds40xxsdk.dll' name 'SetupNotifyThreshold';
function RegisterMessageNotifyHandle;external 'ds40xxsdk.dll' name 'RegisterMessageNotifyHandle';
function SetOverlayColorKey;external 'ds40xxsdk.dll' name 'SetOverlayColorKey';
function SetOsd;external 'ds40xxsdk.dll' name 'SetOsd';
function SetOsdDisplayMode;external 'ds40xxsdk.dll' name 'SetOsdDisplayMode';
function LoadYUVFromBmpFile;external 'ds40xxsdk.dll' name 'LoadYUVFromBmpFile';
function SetLogo;external 'ds40xxsdk.dll' name 'SetLogo';
function SetVideoDetectPrecision;external 'ds40xxsdk.dll' name 'SetVideoDetectPrecision';
function SetInputVideoPosition;external 'ds40xxsdk.dll' name 'SetInputVideoPosition';
function SetBitrateControlMode;external 'ds40xxsdk.dll' name 'SetBitrateControlMode';
function SetupBitrateControl;external 'ds40xxsdk.dll' name 'SetupBitrateControl';
function SetIBPMode;external 'ds40xxsdk.dll' name 'SetIBPMode';
function SetStreamType;external 'ds40xxsdk.dll' name 'SetStreamType';
function StartVideoPreview;external 'ds40xxsdk.dll' name 'StartVideoPreview';
function StopVideoPreview;external 'ds40xxsdk.dll' name 'StopVideoPreview';
function StartVideoCapture;external 'ds40xxsdk.dll' name 'StartVideoCapture';
function StopVideoCapture;external 'ds40xxsdk.dll' name 'StopVideoCapture';
function StartSubVideoCapture;external 'ds40xxsdk.dll' name 'StartVideoCapture';
function StopSubVideoCapture;external 'ds40xxsdk.dll' name 'StopVideoCapture';
function SetImageStream;external 'ds40xxsdk.dll' name 'SetImageStream';
function ReadStreamData;external 'ds40xxsdk.dll' name 'ReadStreamData';
function GetSubChannelStreamType;external 'ds40xxsdk.dll' name 'GetSubChannelStreamType';
function RegisterDrawFun;external 'ds40xxsdk.dll' name 'RegisterDrawFun';
function SetupSubChannel;external 'ds40xxsdk.dll' name 'SetupSubChannel';
function GetOriginalImage;external 'ds40xxsdk.dll' name 'GetOriginalImage';
function SaveYUVToBmpFile;external 'ds40xxsdk.dll' name 'SaveYUVToBmpFile';
function SetAudioPreview;external 'ds40xxsdk.dll' name 'SetAudioPreview';
function GetSoundLevel;external 'ds40xxsdk.dll' name 'GetSoundLevel';
// function StartVideoCapture;external 'ds40xxsdk.dll' name 'StartVideoCapture';
end.