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.
196 lines
2.5 KiB
C++
196 lines
2.5 KiB
C++
|
1 year ago
|
#include "HVDLL.h"
|
||
|
|
#include "HvdllStr.h"
|
||
|
|
#include <string.h>
|
||
|
|
//#include <stdio.h>
|
||
|
|
|
||
|
|
static list<HvdllStr *> gHvList;
|
||
|
|
|
||
|
|
HvdllStr * getHvdllptr(HV_HANDLE phandle, bool isRemove = false)
|
||
|
|
{
|
||
|
|
HvdllStr * ptr = (HvdllStr *)phandle;
|
||
|
|
if (!ptr)
|
||
|
|
{
|
||
|
|
return NULL;
|
||
|
|
}
|
||
|
|
|
||
|
|
list<HvdllStr *>::iterator it;
|
||
|
|
for (it = gHvList.begin(); it != gHvList.end(); it++)
|
||
|
|
{
|
||
|
|
if (ptr == (*it))
|
||
|
|
{
|
||
|
|
if (isRemove)
|
||
|
|
{
|
||
|
|
gHvList.erase(it);
|
||
|
|
}
|
||
|
|
return ptr;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
return NULL;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
extern "C" HV_HANDLE OpenHv(const PSTR pcIP)
|
||
|
|
{
|
||
|
|
int iRet;
|
||
|
|
HvdllStr * p;
|
||
|
|
char buf[32];
|
||
|
|
size_t iLen;
|
||
|
|
|
||
|
|
iRet = isIpAddrAndPort(pcIP);
|
||
|
|
if (iRet < 0)
|
||
|
|
{
|
||
|
|
return E_HV_INVALID_HANDLE;
|
||
|
|
}
|
||
|
|
|
||
|
|
strcpy(buf, pcIP);
|
||
|
|
iLen = strlen(buf);
|
||
|
|
for (size_t i = 0; i < iLen; i++)
|
||
|
|
{
|
||
|
|
if (':' == buf[i])
|
||
|
|
{
|
||
|
|
buf[i] = 0;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
iRet = isIpAddr(buf);
|
||
|
|
if (iRet < 0)
|
||
|
|
{
|
||
|
|
return E_HV_INVALID_HANDLE;
|
||
|
|
}
|
||
|
|
p = new HvdllStr();
|
||
|
|
if (!p)
|
||
|
|
{
|
||
|
|
return E_HV_INVALID_HANDLE;
|
||
|
|
}
|
||
|
|
|
||
|
|
iRet = p->OpenHv(buf);
|
||
|
|
if (iRet < 0)
|
||
|
|
{
|
||
|
|
delete p;
|
||
|
|
return E_HV_INVALID_HANDLE;
|
||
|
|
}
|
||
|
|
|
||
|
|
gHvList.push_back(p);
|
||
|
|
|
||
|
|
//printf("this is openhv\n");
|
||
|
|
return (HV_HANDLE)p;
|
||
|
|
|
||
|
|
|
||
|
|
// return NULL;
|
||
|
|
}
|
||
|
|
|
||
|
|
extern "C" HRESULT CloseHv(HV_HANDLE hHandle)
|
||
|
|
{
|
||
|
|
HvdllStr *p = getHvdllptr(hHandle, true);
|
||
|
|
|
||
|
|
if (!p)
|
||
|
|
{
|
||
|
|
return -1;
|
||
|
|
}
|
||
|
|
|
||
|
|
p->CloseHv();
|
||
|
|
delete p;
|
||
|
|
|
||
|
|
return 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
extern "C" HRESULT HvIsConnected(HV_HANDLE hHandle, INT32 *piStatus)
|
||
|
|
{
|
||
|
|
|
||
|
|
HRESULT hRet;
|
||
|
|
HvdllStr *p = getHvdllptr(hHandle);
|
||
|
|
|
||
|
|
if (!p)
|
||
|
|
{
|
||
|
|
return -1;
|
||
|
|
}
|
||
|
|
|
||
|
|
hRet = p->HvIsConnected(piStatus);
|
||
|
|
return hRet;
|
||
|
|
}
|
||
|
|
|
||
|
|
extern "C" HRESULT SetHvCallBack(
|
||
|
|
HV_HANDLE hHandle,
|
||
|
|
void *pFunction,
|
||
|
|
void *pFirstParameter,
|
||
|
|
WORD wVideoID,
|
||
|
|
WORD wStream
|
||
|
|
)
|
||
|
|
{
|
||
|
|
HRESULT hRet;
|
||
|
|
HvdllStr *p = getHvdllptr(hHandle);
|
||
|
|
|
||
|
|
if (!p)
|
||
|
|
{
|
||
|
|
return -1;
|
||
|
|
}
|
||
|
|
|
||
|
|
//printf("start set fun\n");
|
||
|
|
hRet = p->SetHvCallBack(
|
||
|
|
pFunction,
|
||
|
|
pFirstParameter,
|
||
|
|
wVideoID,
|
||
|
|
wStream);
|
||
|
|
|
||
|
|
return hRet;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
extern "C" HRESULT Yuv2Rgb(
|
||
|
|
BYTE *pbDest,
|
||
|
|
BYTE *pbSrc,
|
||
|
|
int iSrcWidth,
|
||
|
|
int iSrcHeight,
|
||
|
|
int iBGRStride
|
||
|
|
)
|
||
|
|
{
|
||
|
|
return 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
extern "C" HRESULT Yuv2BMP(
|
||
|
|
BYTE *pbDest,
|
||
|
|
int iDestBufLen,
|
||
|
|
int *piDestLen,
|
||
|
|
BYTE *pbSrc,
|
||
|
|
int iSrcWidth,
|
||
|
|
int iSrcHeight
|
||
|
|
)
|
||
|
|
{
|
||
|
|
return 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
extern "C" HRESULT Yuv2Jpg(
|
||
|
|
BYTE *pbDest,
|
||
|
|
int iDestBufLen,
|
||
|
|
int *piDestLen,
|
||
|
|
BYTE *pbSrc,
|
||
|
|
int iSrcWidth,
|
||
|
|
int iSrcHeight
|
||
|
|
)
|
||
|
|
{
|
||
|
|
return 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
extern "C" HRESULT HV_ForceSend(HV_HANDLE hHandle)
|
||
|
|
{
|
||
|
|
return 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
extern "C" HRESULT SetHvTime(HV_HANDLE hHandle, DWORD64 dw64TimeMs)
|
||
|
|
{
|
||
|
|
return 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
extern "C" HRESULT GetHvTime(
|
||
|
|
HV_HANDLE hHandle,
|
||
|
|
DWORD64 *pdw64TimeMs
|
||
|
|
)
|
||
|
|
{
|
||
|
|
return 0;
|
||
|
|
}
|
||
|
|
|