You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
321 lines
5.5 KiB
C++
321 lines
5.5 KiB
C++
#include "hdll.h"
|
|
#include "hdllcls.h"
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include "globalfun.h"
|
|
|
|
#include "globaldef.h"
|
|
list<hdllcls *> ghList;
|
|
|
|
hdllcls * getdevptr(HV_HANDLE phandle, bool isremove = false)
|
|
{
|
|
hdllcls * ptr;
|
|
list<hdllcls *>::iterator it;
|
|
if(! phandle)
|
|
{
|
|
return nullptr;
|
|
}
|
|
|
|
ptr =(hdllcls *)phandle;
|
|
for (it = ghList.begin(); it != ghList.end(); it++)
|
|
{
|
|
if (ptr == (*it))
|
|
{
|
|
if (isremove)
|
|
{
|
|
ghList.erase(it);
|
|
}
|
|
return ptr;
|
|
break;
|
|
}
|
|
}
|
|
|
|
return nullptr;
|
|
}
|
|
|
|
extern "C" HV_HANDLE HDLL_EXPORT HV_Open(const char* pcIP)
|
|
{
|
|
|
|
int iret;
|
|
int icount;
|
|
char * portptr;
|
|
char * usrptr;
|
|
char * pwdptr;
|
|
unsigned short port;
|
|
int itemp;
|
|
|
|
hdllcls * pcls;
|
|
char buf[IPPARA_INPUT_MAXLEN];
|
|
|
|
if(! pcIP)
|
|
{
|
|
return nullptr;
|
|
}
|
|
|
|
iret =strlen(pcIP);
|
|
if((iret <=0) || (iret >= IPPARA_INPUT_MAXLEN))
|
|
{
|
|
return nullptr;
|
|
}
|
|
strcpy(buf,pcIP);
|
|
|
|
icount =0;
|
|
portptr =nullptr;
|
|
usrptr =nullptr;
|
|
pwdptr =nullptr;
|
|
for(int i =0;i <iret; i++)
|
|
{
|
|
if(':' == (buf[i]))
|
|
{
|
|
buf[i] =0;
|
|
if(':' == (buf[i+1]) || (0 == (buf[i+1])))
|
|
{
|
|
return nullptr;
|
|
}
|
|
|
|
if(0 == icount)
|
|
{
|
|
portptr = &(buf[i+1]);
|
|
}
|
|
else if (1 == icount)
|
|
{
|
|
usrptr = &(buf[i+1]);
|
|
}
|
|
else if (2 == icount)
|
|
{
|
|
pwdptr = &(buf[i+1]);
|
|
}
|
|
else
|
|
{
|
|
|
|
}
|
|
icount ++;
|
|
}
|
|
}
|
|
|
|
if(3 != icount)
|
|
{
|
|
return nullptr;
|
|
}
|
|
|
|
iret = isipaddr(buf,IP_ADDR_TYPE);
|
|
if(iret <0)
|
|
{
|
|
return nullptr;
|
|
}
|
|
|
|
iret = istcpportstr(portptr);
|
|
if(iret <0)
|
|
{
|
|
return nullptr;
|
|
}
|
|
|
|
itemp = atoi(portptr);
|
|
|
|
iret = istcpport(itemp);
|
|
if(iret <0)
|
|
{
|
|
return nullptr;
|
|
}
|
|
port = itemp;
|
|
|
|
pcls = new hdllcls();
|
|
if(! pcls)
|
|
{
|
|
return nullptr;
|
|
}
|
|
|
|
pcls->initstr();
|
|
iret = pcls->devopen(buf,port,usrptr,pwdptr);
|
|
if(iret <0)
|
|
{
|
|
delete pcls;
|
|
return nullptr;
|
|
}
|
|
|
|
ghList.push_back(pcls);
|
|
return (HV_HANDLE)pcls;
|
|
}
|
|
|
|
extern "C" HRESULT HDLL_EXPORT HV_Close(HV_HANDLE hHandle)
|
|
{
|
|
hdllcls * p = getdevptr(hHandle, true);
|
|
|
|
if (!p)
|
|
{
|
|
return -1;
|
|
}
|
|
|
|
p->closehv();
|
|
delete p;
|
|
return 0;
|
|
}
|
|
|
|
extern "C" HRESULT HDLL_EXPORT HV_IsConnected(HV_HANDLE hHandle, INT32 *piStatus)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
extern "C" HRESULT HDLL_EXPORT HV_Capture(HV_HANDLE hHandle,INT32 ImageFormat, BYTE *pbImageBuf,INT32* iBufLen)
|
|
{
|
|
HRESULT hret;
|
|
hdllcls * p = getdevptr(hHandle, false);
|
|
|
|
if (!p)
|
|
{
|
|
return -1;
|
|
}
|
|
|
|
hret = p->HV_Capture(ImageFormat, pbImageBuf,iBufLen);
|
|
if(hret <0)
|
|
{
|
|
|
|
}
|
|
|
|
return hret;
|
|
}
|
|
|
|
extern "C" HRESULT HDLL_EXPORT HV_Capture2(HV_HANDLE hHandle,INT32 ImageFormat, BYTE *pbImageBuf,INT32* iBufLen,INT32 iChannelType)
|
|
{
|
|
HRESULT hret;
|
|
hdllcls * p = getdevptr(hHandle, false);
|
|
|
|
if (!p)
|
|
{
|
|
return -1;
|
|
}
|
|
|
|
hret = p->HV_Capture2(ImageFormat, pbImageBuf,iBufLen,iChannelType);
|
|
if(hret <0)
|
|
{
|
|
|
|
}
|
|
|
|
return hret;
|
|
}
|
|
|
|
extern "C" HRESULT HDLL_EXPORT HV_StartPlay(HV_HANDLE hHandle, HWND hWnd, INT32 iChannelType)
|
|
{
|
|
HRESULT hret;
|
|
hdllcls * p = getdevptr(hHandle, false);
|
|
|
|
if (!p)
|
|
{
|
|
return -100;
|
|
}
|
|
|
|
|
|
if( (0 !=iChannelType) && (1 !=iChannelType))
|
|
{
|
|
return -101;
|
|
}
|
|
|
|
hret = p->HV_StartPlay(hWnd, iChannelType);
|
|
if(hret <0)
|
|
{
|
|
|
|
}
|
|
|
|
return hret;
|
|
}
|
|
|
|
extern "C" HRESULT HDLL_EXPORT HV_StopPlay(HV_HANDLE hHandle)
|
|
{
|
|
HRESULT hret;
|
|
hdllcls * p = getdevptr(hHandle, false);
|
|
|
|
if (!p)
|
|
{
|
|
return -1;
|
|
}
|
|
|
|
hret = p->HV_StopPlay();
|
|
if(hret <0)
|
|
{
|
|
}
|
|
|
|
return hret;
|
|
}
|
|
|
|
extern "C" HRESULT HDLL_EXPORT HV_SetTime(HV_HANDLE hHandle, UINT64 dw64TimeMs)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
extern "C" HRESULT HDLL_EXPORT HV_AddChar(HV_HANDLE hHandle,INT32 xPos,INT32 yPos, UINT32 iColor, INT32 iFontSize, char* pcValue)
|
|
{
|
|
HRESULT hret;
|
|
hdllcls * p = getdevptr(hHandle, false);
|
|
|
|
if (!p)
|
|
{
|
|
return -1;
|
|
}
|
|
|
|
hret = p->HV_AddChar(xPos,yPos,iColor,iFontSize, pcValue);
|
|
if(hret <0)
|
|
{
|
|
}
|
|
|
|
return hret;
|
|
}
|
|
|
|
extern "C" HRESULT HDLL_EXPORT HV_ClearChar(HV_HANDLE hHandle)
|
|
{
|
|
HRESULT hret;
|
|
hdllcls * p = getdevptr(hHandle, false);
|
|
|
|
if (!p)
|
|
{
|
|
return -1;
|
|
}
|
|
|
|
hret = p->HV_ClearChar();
|
|
if(hret <0)
|
|
{
|
|
}
|
|
|
|
return hret;
|
|
}
|
|
|
|
extern "C" HRESULT HDLL_EXPORT HV_StartRecord (HV_HANDLE hHandle, INT32 iChannel, char* pcFileName)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
extern "C" HRESULT HDLL_EXPORT HV_StopRecord(HV_HANDLE hHandle)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
extern "C" HRESULT HDLL_EXPORT HV_GetOption(HV_HANDLE hHandle, char* pcOption)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
extern "C" HRESULT HDLL_EXPORT HV_SetOption( HV_HANDLE hHandle, char* pcOption, char* pcValue)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
extern "C" HRESULT HDLL_EXPORT Yuv2Jpg(BYTE *pbDest,int iDestBufLen, int *piDestLen, BYTE *pbSrc, int iSrcWidth, int iSrcHeight)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
extern "C" HRESULT HDLL_EXPORT Yuv2BMP(BYTE *pbDest, int iDestBufLen, int *piDestLen, BYTE *pbSrc, int iSrcWidth, int iSrcHeight)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
extern "C" HRESULT HDLL_EXPORT Yuv2Rgb(BYTE *pbDest, BYTE *pbSrc, int iSrcWidth, int iSrcHeight, int iBGRStride)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
extern "C" char* HV_GetErrorStr(INT32 ErrorCode)
|
|
{
|
|
return nullptr;
|
|
}
|