问题描述
SeeAlso网络SDK开发手册CLIENT_PlayBackByTimeEx带数据回调的按时间回放扩展接口。LLONGCLIENT_PlayBackByTimeEx(LLONGlLoginID,intnChannelID,LPNET_TIMElpStartTime,LPNET_TIMElpStopTime,HWNDhWnd,fDownLoadPosCallBackcbDownLoadPos,LDWORDdwPosUser,fDataCallBackfDownLoadDataCallBack,LDWORDdwDataUser);Parameters[in]lLoginIDCLIENT_Login的返回值[in]nChannelID图像通道号,必须指定[in]lpStartTime开始时间[in]lpStopTime结束时间[in]hWnd回放窗口cbDownLoadPos进度回调用户参数,说明参见:CLIENT_PlayBackByRecordFiledwPosUser用户自定义数据,cbDownLoadPos中使用fDownLoadDataCallBack数据回调函数,说明参见:CLIENT_PlayBackByRecordFileExdwDataUser用户自定义数据,fDownLoadDataCallBack中使用ReturnValues成功返回网络回放ID,失败返回0。Remarks参数hWnd和fDownLoadDataCallBack不能同时为NULL,否则接口调用会返回失败SeeAlsoCLIENT_Login,CLIENT_PausePlayBack,CLIENT_SeekPlayBack,CLIENT_StopPlayBack,CLIENT_GetPlayBackOsdTime,CLIENT_StepPlayBack,CLIENT_GetFramePlayBack,CLIENT_SetFramePlayBack,CLIENT_SlowPlayBack,CLIENT_FastPlayBack。SeeAlsoCLIENT_Login,CLIENT_PausePlayBack,CLIENT_SeekPlayBack,CLIENT_StopPlayBack,CLIENT_GetPlayBackOsdTime,CLIENT_StepPlayBack,CLIENT_GetFramePlayBack,CLIENT_SetFramePlayBack,CLIENT_SlowPlayBack,CLIENT_FastPlayBack。#define_WIN32_WINNT0x500#include<stdio.h>#include<iostream>#include<Windows.h>#include"dhnetsdk.h"usingnamespacestd;#include<winCon.h>#pragmacomment(lib,"dhnetsdk.lib")//////////////////////////////////////////////////////////////////////////void__stdcallDisConnectFunc(LONGlLoginID,char*pchDVRIP,LONGnDVRPort,DWORDdwUser){printf("Devicedisconn,IP=%s+++++++++++++++++++++++n",pchDVRIP);}void__stdcallDownLoadPosCallBackFunc(LONGlPlayHandle,DWORDdwTotalSize,DWORDdwDownLoadSize,DWORDdwUser){if(dwDownLoadSize==-1){printf("PlayBackPosCallBack:100n");}elseif(dwTotalSize!=0){//printf("PlayBackPosCallBack:%d%n",dwDownLoadSize*100/dwTotalSize);}}int__stdcallDataCallBackFunc(LONGlRealHandle,DWORDdwDataType,BYTE*pBuffer,DWORDdwBufSize,DWORDdwUser){FILE*file=(FILE*)dwUser;if(file){fwrite(pBuffer,1,dwBufSize,file);}printf("PlayBack:data++++,len=%d+++++++++++++++n",dwBufSize);return1;}//////////////////////////////////////////////////////////////////////////intmain(intargc,char*argv[]){CLIENT_Init(DisConnectFunc,0);cout<<"InitializeclientSDKdone;"<<endl;charszDevIp[64]={0};NET_DEVICEINFOstDevInfo={0};intnError=0;LLONGlLoginHandle=0;intnPort=37777;intnChannelID=0;//通道号LLONGhPlayBack=0;//HWNDhWnd=GetConsoleWindow();//获取窗口句柄cout<<endl<<"IP:";cin>>szDevIp;cout<<endl<<"Port:";cin>>nPort;lLoginHandle=CLIENT_Login(szDevIp,nPort,"admin","admin",&stDevInfo,&nError);if(lLoginHandle!=0){NET_TIMEtartTime={0};NET_TIMEStopTime={0};StartTime.dwYear=2012;StartTime.dwMonth=9;StartTime.dwDay=20;StartTime.dwHour=0;StartTime.dwMinute=0;StopTime.dwYear=2012;StopTime.dwMonth=9;StopTime.dwDay=21;StopTime.dwHour=15;FILE*file=fopen("./PlayBack.dav","wb");hPlayBack=CLIENT_PlayBackByTimeEx(lLoginHandle,0,&StartTime,&StopTime,NULL/*hWnd*/,DownLoadPosCallBackFunc,0,DataCallBackFunc,(DWORD)file);printf("CLIENT_PlayBackByTimeEx:%dn",hPlayBack);}else{printf("CLIENT_LoginEx:%sfailed!error=%dn",szDevIp,nError);}//停止回放if(hPlayBack!=0){CLIENT_StopPlayBack(hPlayBack);}//注销用户CLIENT_Logout(lLoginHandle);//释放SDK资源CLIENT_Cleanup();return0;}谁用VB.NET开发过给个实例,我对回调函数不熟尤其是这句FILE*file=fopen("./PlayBack.dav","wb");