百分悬赏新人求助--海康SDK二次开发预览问题
我用MFC写的一个小程序,对海康SDK进行二次开发,但在预览的时候不到10秒钟就会卡屏,不知道是什么原因,悬赏100分求助,只给解决了问题的人,分不够可以在加,重要的是要能解决问题。以下是我添加的源代码,求各位大神帮忙啊。
BOOL CPTZTestDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
NET_DVR_Init();
NET_DVR_DEVICEINFO_V30 struDeviceInfo;
m_lUserID = NET_DVR_Login_V30("192.168.0.250",8000,"admin","12345",&struDeviceInfo);
if(m_lUserID < 0)
{
printf("Login error, %d\n",NET_DVR_GetLastError());
NET_DVR_Cleanup();
return FALSE;
}
return TRUE; // return TRUE unless you set the focus to a control
}
void CPTZTestDlg::OnBtnPreview()
{
// TODO: Add your control notification handler code here
NET_DVR_CLIENTINFO ClientInfo = {0};
ClientInfo.hPlayWnd = GetDlgItem(IDC_STATIC_OUTPUT)->m_hWnd;
ClientInfo.lChannel = 1;
ClientInfo.lLinkMode = 0;
ClientInfo.sMultiCastIP = NULL;
BOOL bPreviewBlock = false;
m_lRealPlayHandle = NET_DVR_RealPlay_V30(m_lUserID, &ClientInfo, NULL, NULL, 0);
if(m_lRealPlayHandle < 0)
{
MessageBox("Play Error!", NULL, MB_OK);
}
}
void CPTZTestDlg::OnBtnStop()
{
// TODO: Add your control notification handler code here
BOOL bRet = NET_DVR_StopRealPlay(m_lRealPlayHandle);
if (!bRet)
{
CString strErr;
strErr.Format("NET_DVR_StopRealPlay ErrorCode = %d\n", NET_DVR_GetLastError());
MessageBox(strErr,NULL,MB_OK);
}
}
void CPTZTestDlg::OnClose()
{
// TODO: Add your message handler code here and/or call default
NET_DVR_Logout(m_lUserID);
NET_DVR_Cleanup();
CDialog::OnClose();
}
注1:IDC_STATIC_OUTPUT为我在主窗口上添加的静态文本框ID,用来显示预览的图像。
注2:我的程序并不是不能预览,只是预览的时候隔10秒左右就会卡,有时会卡好多秒的时间。所以我要解决的是卡的问题,请看清楚。