gho.st/6vQjRd8X6
#include <stdio.h>
#include <unistd.h>
#include <iostream>
using namespace std;
#include "netsdk.h"
FILE *g_File;
int callBackReal(long IReadHandle,const PACKET_INFO_EX *pFrame,unsigned int dwUser)
{
printf("time:%04d-%02d-%02d %02d:%02d:%02d\n",pFrame->nYear,pFrame->nMonth,pFrame->nDay,pFrame->nHour,pFrame->nMinute,pFrame->nSecond);
fwrite(pFrame->pPacketBuffer,1,pFrame->dwPacketSize,g_File);
return true;
}
int main(void)
{
H264_DVR_Init(NULL,NULL);
printf("SDK INIT");
H264_DVR_DEVICEINFO OutDev;
memset(&OutDev,0,sizeof(OutDev));
int nError = 0;
int g_LoginID = H264_DVR_Login((char*)"127.0.0.1", 34567, (char*)"admin",(char*)"admin",(LPH264_DVR_DEVICEINFO)(&OutDev),&nError);
printf("LoginID=%d,Ошибок:%d\n",g_LoginID,nError);
H264_DVR_CLIENTINFO playstru;
playstru.nChannel = 0;
playstru.nStream = 0;
playstru.nMode = 0;
long nPlayHandle = H264_DVR_RealPlay(g_LoginID,&playstru );
printf("nPlayHandle=%ld\n",nPlayHandle);
H264_DVR_MakeKeyFrame(g_LoginID,0,0);
//H264_DVR_CatchPic(g_LoginID,0,"/home/mrxakerrus/Desktop/fff/pic.jpg");
g_File = fopen("D:/realPlay/RealPlay.h264","wb+");
H264_DVR_SetRealDataCallBack_V2(nPlayHandle,callBackReal,0);
printf("Start real play");
sleep(60);
H264_DVR_StopRealPlay(nPlayHandle);
if(g_LoginID>0)
{
H264_DVR_Logout(g_LoginID);
printf("Logout\n");
}
H264_DVR_Cleanup();
printf("SDK CLOSE\n");
printf("**************OVER************\n");
return 0;
}