大华摄像头获取yuv数据

来源:互联网 发布:看摄像头监控软件 编辑:程序博客网 时间:2024/04/29 17:59

这里我把从大华公司获取的资料代码贴出来,希望对大家有所帮助。

// DecCallBack.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include <Windows.h>#include <conio.h>#include "dhnetsdk.h"#include <stdio.h>#include "dhplay.h"#define PLAYPORT 1void CALLBACK DisConnectFunc(LONG lLoginID, char *pchDVRIP, LONG nDVRPort, DWORD dwUser){printf("设备断线.\n");    return;}void CALLBACK AutoReConnectFunc(LONG lLoginID, char *pchDVRIP, LONG nDVRPort, DWORD dwUser){printf("自动重连成功.\n");    return;}void CALLBACK RealDataCallBackEx(LONG lRealHandle, DWORD dwDataType, BYTE *pBuffer,DWORD dwBufSize, LONG lParam, DWORD dwUser){if (dwDataType == 0)  //原始视频流送播放库  {PLAY_InputData(PLAYPORT,pBuffer,dwBufSize);       }}void CALLBACK DecCBFun(LONG nPort,char * pBuf,LONG nSize,FRAME_INFO * pFrameInfo, void* pUserData, LONG nReserved2){     //移走数据后,快速返回,即开始解码回调下一帧数据;不要在回调中运行长事务,否则阻塞解码下一帧数据     // pbuf里的数据是YUV I420格式的数据  if(pFrameInfo->nType == 3) //视频数据  {      printf("video CallBack\n"); } else if(pFrameInfo->nType == T_AUDIO16) { //cout<<"Audio CallBack"<<endl; } else { printf("nType = %d\n",pFrameInfo->nType); } return;}int main(void){//打开播放通道PLAY_OpenStream(PLAYPORT,0,0,1024*1024); PLAY_SetDecCallBackEx(PLAYPORT, DecCBFun,NULL);    PLAY_Play(PLAYPORT,NULL);CLIENT_LogClose();NET_DEVICEINFO deviceInfo ={0};unsigned long lLogin;CLIENT_Init(DisConnectFunc,0);//初始化sdk,设置断线回调函数CLIENT_SetAutoReconnect(AutoReConnectFunc,0);printf( " Login Device ... Please Input IP Address:\n");char ip[255] = {0};scanf("%s",ip);lLogin = CLIENT_Login(ip,37777,"admin","admin",&deviceInfo);//登陆设备,用户需另选设备。long lRealPlay;if(lLogin != 0){ printf( "Login Success ,Start Real Play\n");     lRealPlay = CLIENT_RealPlay(lLogin,0,0); if(lRealPlay != 0) {             //窗口句柄传空值,网络库只回调原始数据 CLIENT_SetRealDataCallBackEx(lRealPlay, RealDataCallBackEx, 0, 0x1f); }}else{printf(" Login Fail \n)");}_getch();//释放网络库CLIENT_StopRealPlay(lRealPlay);CLIENT_Logout(lLogin);CLIENT_Cleanup();//关闭播放通道,释放资源PLAY_Stop(PLAYPORT);PLAY_CloseStream(PLAYPORT);return 0;}


原创粉丝点击