void CALLBACK g_RealDataCallBack_V30(LONG lRealHandle, DWORD dwDataType, BYTE *pBuffer, DWORD dwBufSize, void* dwUser) { if (lRealHandle == lRealHandle1) { switch (dwDataType) { case NET_DVR_SYSHEAD: //系统头 if (!PlayM4_GetPort(&nPort1)) //获取播放库未使用的通道号 { break; } //m_iPort = lPort; //第一次回调的是系统头,将获取的播放库port号赋值给全局port,下次回调数据时即使用此port号播放 if (dwBufSize > 0) { if (!PlayM4_SetStreamOpenMode(nPort1, STREAME_REALTIME)) //设置实时流播放模式 { break; } if (!PlayM4_OpenStream(nPort1, pBuffer, dwBufSize, 1024 * 1024)) //打开流接口 { break; } //设置解码回调函数 只解码不显示 //if (!PlayM4_SetDecCallBack(lPort,DecCBFun)) //{ // //dRet=PlayM4_GetLastError(nPort1); // break; //} //设置解码回调函数 解码且显示在窗口句柄中 if (!PlayM4_SetDecCallBackEx(nPort1, DecCBFun, NULL, NULL)) { break; } if (!PlayM4_SetDisplayBuf(nPort1, 4))//设置缓冲区大小,2-5 { break; } if (!PlayM4_Play(nPort1, hPlayWnd1)) //播放开始 { break; } } case NET_DVR_STREAMDATA: //码流数据 if (dwBufSize > 0 && nPort1 != -1) if (!PlayM4_InputData(nPort1, pBuffer, dwBufSize)) break; } } else { switch (dwDataType) { case NET_DVR_SYSHEAD: //系统头 if (!PlayM4_GetPort(&nPort2)) //获取播放库未使用的通道号 { break; } //m_iPort = lPort; //第一次回调的是系统头,将获取的播放库port号赋值给全局port,下次回调数据时即使用此port号播放 if (dwBufSize > 0) { if (!PlayM4_SetStreamOpenMode(nPort2, STREAME_REALTIME)) //设置实时流播放模式 { break; } if (!PlayM4_OpenStream(nPort2, pBuffer, dwBufSize, 1024 * 1024)) //打开流接口 { break; } //设置解码回调函数 只解码不显示 //if (!PlayM4_SetDecCallBack(lPort,DecCBFun)) //{ // //dRet=PlayM4_GetLastError(nPort1); // break; //} //设置解码回调函数 解码且显示在窗口句柄中 if (!PlayM4_SetDecCallBackEx(nPort2, DecCBFun, NULL, NULL)) { break; } if (!PlayM4_SetDisplayBuf(nPort2, 4))//设置缓冲区大小,2-5 { break; } if (!PlayM4_Play(nPort2, hPlayWnd2)) //播放开始 { break; } } case NET_DVR_STREAMDATA: //码流数据 if (dwBufSize > 0 && nPort2 != -1) if (!PlayM4_InputData(nPort2, pBuffer, dwBufSize)) break; } } }
void DevChannelHK::onPreview(DWORD dwDataType, BYTE* pBuffer, DWORD dwBufSize) { //TimeTicker1(-1); switch (dwDataType) { case NET_DVR_SYSHEAD: { //系统头数据 if (!PlayM4_GetPort(&m_iPlayHandle)) { //获取播放库未使用的通道号 WarnL << "PlayM4_GetPort:" << NET_DVR_GetLastError(); break; } if (dwBufSize > 0) { if (!PlayM4_SetStreamOpenMode(m_iPlayHandle, STREAME_REALTIME)) { //设置实时流播放模式 WarnL << "PlayM4_SetStreamOpenMode:" << NET_DVR_GetLastError(); break; } if (!PlayM4_OpenStream(m_iPlayHandle, pBuffer, dwBufSize, 1024 * 1024)) { //打开流接口 WarnL << "PlayM4_OpenStream:" << NET_DVR_GetLastError(); break; } PlayM4_SetDecCallBackMend(m_iPlayHandle, [](int nPort,char * pBuf,int nSize,FRAME_INFO * pFrameInfo, void* nUser,int nReserved2) { DevChannelHK *chn=reinterpret_cast<DevChannelHK *>(nUser); if(chn->m_iPlayHandle!=nPort) { return; } chn->onGetDecData(pBuf,nSize,pFrameInfo); }, this); if (!PlayM4_Play(m_iPlayHandle, 0)) { //播放开始 WarnL << "PlayM4_Play:" << NET_DVR_GetLastError(); break; } InfoL << "设置解码器成功!" << endl; //打开音频解码, 需要码流是复合流 if (!PlayM4_PlaySoundShare(m_iPlayHandle)) { WarnL << "PlayM4_PlaySound:" << NET_DVR_GetLastError(); break; } } } break; case NET_DVR_STREAMDATA: { //流数据(包括复合流或音视频分开的视频流数据) if (dwBufSize > 0 && m_iPlayHandle != -1) { if (!PlayM4_InputData(m_iPlayHandle, pBuffer, dwBufSize)) { WarnL << "PlayM4_InputData:" << NET_DVR_GetLastError(); break; } } } break; case NET_DVR_AUDIOSTREAMDATA: { //音频数据 } break; case NET_DVR_PRIVATE_DATA: { //私有数据,包括智能信息 } break; default: break; } }
BOOL CPlayerHik::OpenFile(char *PFile,HWND hwnd) { m_hwnd = hwnd; if (PlayM4_GetPort(&m_nPort)) { return PlayM4_OpenFile(m_nPort, PFile); } return false; }
void MainWindow::PsDataCallBack(LONG lRealHandle, DWORD dwDataType,BYTE *pBuffer,DWORD dwBufSize, void* pUser) { HWND hWnd=((Movie*)pUser)->hWnd; //qDebug("hWnd(pUser):%d", *(HWND*)pUser); switch (dwDataType) { case NET_DVR_SYSHEAD: //系统头 if (!PlayM4_GetPort(&lPort)) //获取播放库未使用的通道号 { qDebug("PlayM4_GetPort"); break; } //m_iPort = lPort; //第一次回调的是系统头,将获取的播放库port号赋值给全局port,下次回调数据时即使用此port号播放 if (dwBufSize > 0) { if (!PlayM4_SetStreamOpenMode(lPort, STREAME_REALTIME)) //设置实时流播放模式 { qDebug("PlayM4_SetStreamOpenMode"); break; } if (!PlayM4_OpenStream(lPort, pBuffer, dwBufSize, 1024*1024)) //打开流接口 { qDebug("PlayM4_OpenStream"); break; } qDebug("hWnd(pUser):%d", hWnd); if (!PlayM4_Play(lPort, hWnd)) //播放开始 { qDebug("PlayM4_Play"); break; } } break; case NET_DVR_STREAMDATA: //码流数据 if (dwBufSize > 0 && lPort != -1) { if (!PlayM4_InputData(lPort, pBuffer, dwBufSize)) { qDebug("PlayM4_InputData"); break; } } } }
void CALLBACK g_RealDataCallBack_V30(LONG lRealHandle, DWORD dwDataType, BYTE *pBuffer,DWORD dwBufSize,DWORD dwUser) { switch(dwDataType) { case NET_DVR_SYSHEAD: //系统头 if(!PlayM4_GetPort(&lPort)) break; //获取播放库未使用的通道号 if(dwBufSize > 0) { if(!PlayM4_SetStreamOpenMode(lPort,STREAME_REALTIME)) break; //设置实时流播放模式 if(!PlayM4_OpenStream(lPort,pBuffer,dwBufSize,1024*1024)) break; //打开流接口,1024 * 1024的数据何来? PlayM4_SetDecCallBack(lPort,DecCBFun); if(!PlayM4_SetDecCBStream(lPort,1)) break; if(!PlayM4_Play(lPort,NULL)) break;//播放开始 }//T_YV12 case NET_DVR_STREAMDATA: //码流数据 if (dwBufSize > 0 && lPort != -1) { if(!PlayM4_InputData(lPort,pBuffer,dwBufSize)) break; } } }
void CALLBACK g_RealDataCallBack_V30(LONG lRealHandle, DWORD dwDataType, BYTE *pBuffer,DWORD dwBufSize,void* dwUser) { CHaikangSDK *HaikangSDK = (CHaikangSDK *)dwUser; int screenNo = DlgMain->DlgScreen.m_video.m_haikang.GetHandleWindID(lRealHandle); LONG lPort = HaikangSDK->m_lPort[screenNo]; CWnd* pWnd=NULL; switch (dwDataType) { case NET_DVR_SYSHEAD: //系统头 if (PlayM4_GetPort(&lPort)) //获取播放库未使用的通道号 { DlgMain->DlgScreen.m_video.m_haikang.m_lPort[screenNo] = lPort; } //m_iPort = lPort; //第一次回调的是系统头,将获取的播放库port号赋值给全局port,下次回调数据时即使用此port号播放 if (dwBufSize > 0) { if (!PlayM4_SetStreamOpenMode(lPort, STREAME_REALTIME)) //设置实时流播放模式 { PlayM4_FreePort(lPort); break; } if (!PlayM4_OpenStream(lPort, pBuffer, dwBufSize, 1920*1080*3)) //打开流接口 { PlayM4_FreePort(lPort); break; } if (!PlayM4_SetDisplayCallBack(lPort, RemoteDisplayCBFun)) { PlayM4_CloseStream(lPort); PlayM4_FreePort(lPort); break; } if(DlgSetSystem.m_display_preview) { pWnd= DlgMain->DlgScreen.m_screenPannel.GetPage(screenNo); if (!pWnd) { PlayM4_CloseStream(lPort); PlayM4_FreePort(lPort); return; } if (!PlayM4_Play(lPort, pWnd->m_hWnd)) //播放开始 { PlayM4_CloseStream(lPort); PlayM4_FreePort(lPort); break; } } else { if (!PlayM4_Play(lPort,NULL)) //播放开始 { PlayM4_CloseStream(lPort); PlayM4_FreePort(lPort); break; } } } break; case NET_DVR_STREAMDATA: //码流数据 if (dwBufSize > 0 && lPort != -1) { if (!PlayM4_InputData(lPort, pBuffer, dwBufSize)) { break; } } break; } }