海康转码
来源:互联网 发布:linux重启ntp服务命令 编辑:程序博客网 时间:2024/06/11 01:09
//解码回调 视频为YUV数据(YV12),音频为PCM数据void CALLBACK DecCBFun(long nPort,char * pBuf,long nSize,FRAME_INFO * pFrameInfo, long nReserved1,long nReserved2){ long lFrameType = pFrameInfo->nType; if(lFrameType ==T_YV12) {Mat frame;frame.create(Size(pFrameInfo->nWidth, pFrameInfo->nHeight),CV_8UC1);memcpy(frame.data, pBuf, pFrameInfo->nWidth*pFrameInfo->nHeight);imshow("IP Camera", frame);waitKey(1); }}///实时流回调void CALLBACK fRealDataCallBack(LONG lRealHandle,DWORD dwDataType,BYTE *pBuffer,DWORD dwBufSize,void *pUser){ DWORD dRet; switch (dwDataType) { case NET_DVR_SYSHEAD: //系统头 if (!PlayM4_GetPort(&nPort)) //获取播放库未使用的通道号 { break; } if(dwBufSize > 0) { if (!PlayM4_OpenStream(nPort,pBuffer,dwBufSize,1024*1024)) { dRet=PlayM4_GetLastError(nPort); break; } //设置解码回调函数 只解码不显示 if (!PlayM4_SetDecCallBack(nPort,DecCBFun)) { dRet=PlayM4_GetLastError(nPort); break; } //设置解码回调函数 解码且显示 //if (!PlayM4_SetDecCallBackEx(nPort,DecCBFun,NULL,NULL)) //{ //dRet=PlayM4_GetLastError(nPort); //break; //} //打开视频解码 if (!PlayM4_Play(nPort,hWnd)) { dRet=PlayM4_GetLastError(nPort); break; } //打开音频解码, 需要码流是复合流 if (!PlayM4_PlaySound(nPort)) { dRet=PlayM4_GetLastError(nPort); break; } } break; case NET_DVR_STREAMDATA: //码流数据 if (dwBufSize > 0 && nPort != -1) { BOOL inData=PlayM4_InputData(nPort,pBuffer,dwBufSize); while (!inData) { Sleep(10); inData=PlayM4_InputData(nPort,pBuffer,dwBufSize); OutputDebugString(L"PlayM4_InputData failed \n"); } } break; }}
0 0