I want to extract vía SDK a video in format .hik (Hikvision) to MP4. My code is the next:
#include <stdio.h>
#include <stdlib.h>
#include "../SDK/incEn/HCNetSDK.h"
#include "Windows.h"
using namespace std;
int saveRecordFile(int userId, char * srcfile, char * destfile) {
HINSTANCE hGetProcIDDLL = LoadLibrary("D:\\ExtraccionYConversionArchivos\\c++\\Fuente\\SDK\\HCNetSDK.dll");
int bRes = 1;
int hPlayBack = 0;
if ( (hPlayBack = NET_DVR_GetFileByName(userId, srcfile, destfile)) < 0)
{
printf("Error en GetFileByName. Error[$d]\n",NET_DVR_GetLastError());
bRes = -1;
return bRes;
}
if (!NET_DVR_PlayBackControl(hPlayBack, NET_DVR_PLAYSTART,0,NULL))
{
printf("Control de play back fallido [%d]\n", NET_DVR_GetLastError());
bRes = -1;
return bRes;
}
int nPos = 0;
for (nPos = 0; nPos < 100 && nPos >= 0; nPos = NET_DVR_GetDownloadPos(hPlayBack))
{
Sleep(5000);
}
printf("Se obtuvo %d\n", nPos);
if (!NET_DVR_StopGetFile(hPlayBack))
{
printf("Error al detener descarga de archivo [%d]\n",NET_DVR_GetLastError());
bRes = -1;
return bRes;
}
printf("%s\n",srcfile);
if (nPos < 0 || nPos > 100)
{
printf("Error de descarga [%d]\n", NET_DVR_GetLastError());
bRes = -1;
return bRes;
}
else
{
return 0;
}
}
int main()
{
printf("Hello world!\n");
return 0;
}
It uses the HCNetSDK.h header, which throw me an error in multiple lines: syntax error before string constant. This header file have more than 41K lines, and most of the error are after typedef:
typedef void (CALLBACK *MSGCallBack)(LONG lCommand, NET_DVR_ALARMER *pAlarmer, char *pAlarmInfo, DWORD dwBufLen, void* pUser);
NET_DVR_API BOOL __stdcall NET_DVR_SetDVRMessageCallBack_V30(MSGCallBack fMessageCallBack, void* pUser);
What could be the problem? Before this lines, there are more than 6K typedef struct like this:
typedef struct tagNET_DVR_MATRIX_STATUS_V50
{
DWORD dwSize;
BYTE byMainFrameType;
BYTE bySoltNum;
BYTE byBoardNum;
BYTE byLCDPanelStatus;
NET_DVR_MATRIX_SUBBOARD_V50 struMatrixSubboard[MAX_MATRIX_SUBBOARD_NUM];
DWORD dwFanSequence;
DWORD dwFanConnectStatus;
DWORD dwFanOperationStatus;
BYTE byDeviceModel[32];
BYTE byRes[32];
}NET_DVR_MATRIX_STATUS_V50, *LPNET_DVR_MATRIX_STATUS_V50;
And even that I make comments over each typedef struct to catch the mistake, I couldn't figure out how.