📄 remotefileplay.cpp
字号:
if(nPos1 > 100) //Playback exception due to network or DVR busy
{
F_StopPlay();
AfxMessageBox("Playback exception!");
}
else
{
m_ctlProgress.SetPos(nPos1);
if(nPos1 == 100)
{
F_StopPlay();
TRACE("Playback completed!");
}
}
if(NET_DVR_GetPlayBackOsdTime(m_nPlayHandle, &OsdTime))
{
//TRACE("OSDTime: %04d%02d%02d%02d%02d%02d", OsdTime.dwYear, OsdTime.dwMonth,OsdTime.dwDay,OsdTime.dwHour,OsdTime.dwMinute,OsdTime.dwSecond);
}
break;
default:
break;
}
CDialog::OnTimer(nIDEvent);
}
void CRemoteFilePlay::OnSearchlist()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
m_Filelist.DeleteAllItems();
iSelServer = m_ServerCtrl.GetCurSel()-1;
if (iSelServer < 0)
{
AfxMessageBox("please select a DVR!");
return;
}
if(!m_bSearchDown)
{
NET_DVR_TIME StartTime;
NET_DVR_TIME StopTime;
m_iChannel = m_ChannelCtrl.GetCurSel()+m_lStartChan;
iFileType = m_FileType.GetCurSel();
StartTime.dwYear = (WORD)m_ctDateStart.GetYear();
StartTime.dwMonth = (WORD)m_ctDateStart.GetMonth();
StartTime.dwDay = (WORD)m_ctDateStart.GetDay();
StartTime.dwHour = (char)m_ctTimeStart.GetHour();
StartTime.dwMinute = (char)m_ctTimeStart.GetMinute();
StartTime.dwSecond = (char)m_ctTimeStart.GetSecond();
StopTime.dwYear = (WORD)m_ctDateStop.GetYear();
StopTime.dwMonth = (WORD)m_ctDateStop.GetMonth();
StopTime.dwDay = (WORD)m_ctDateStop.GetDay();
StopTime.dwHour = (char)m_ctTimeStop.GetHour();
StopTime.dwMinute = (char)m_ctTimeStop.GetMinute();
StopTime.dwSecond = (char)m_ctTimeStop.GetSecond();
m_lServerType = serverinfo[iSelServer].m_wServerType;
if(m_bCard) //ATM DVR
{
BYTE cTemp[CARDNUM_LEN];
memcpy(cTemp, m_sCardNum, CARDNUM_LEN);
if(iFileType == 0)
{
iFileType = 0xFF;
}
else
{
iFileType -= 1;
}
m_lFileHandle = NET_DVR_FindFileByCard(m_lServerID,m_iChannel,iFileType, TRUE, cTemp, &StartTime, &StopTime);
}
else
{
if(iFileType == 0)
{
iFileType = 0xFF;
}
else
{
iFileType -= 1;
}
m_lFileHandle = NET_DVR_FindFile(m_lServerID,m_iChannel,iFileType, &StartTime, &StopTime);
}
if(m_lFileHandle < 0)
{
AfxMessageBox("Get file list failed!");
CString sTemp;
sTemp.Format("ERROR: NET_DVR_FindFile = %d",NET_DVR_GetLastError());
TRACE(sTemp);
return;
}
m_Filelist.DeleteAllItems();
m_bFindFile = TRUE;
DWORD dwThreadId;
if(m_hFileThread == NULL)
m_hFileThread = CreateThread(NULL,0,LPTHREAD_START_ROUTINE(GetFileThread),this,0,&dwThreadId);
if(m_hFileThread == NULL)
{
AfxMessageBox("Create thread failed!");
return;
}
GetDlgItem(IDC_SEARCHLIST)->SetWindowText("Stop Search");
m_bSearchDown = TRUE;
GetDlgItem(IDC_STATICSTATE)->ShowWindow(SW_SHOW);
}
else
{
if(m_hFileThread)
{
TerminateThread(m_hFileThread, 0);
}
CloseHandle(m_hFileThread);
m_hFileThread = NULL;
NET_DVR_FindClose(m_lFileHandle);
GetDlgItem(IDC_SEARCHLIST)->SetWindowText("Search");
m_bSearchDown = FALSE;
GetDlgItem(IDC_STATICSTATE)->ShowWindow(SW_HIDE);
m_iFileNum = 0;
}
}
void CRemoteFilePlay::OnDownload()
{
// TODO: Add your control notification handler code here
CString csFileName;
CString csStartTime, csStopTime;
CString csTemp,csDir;
char nFileName[256];
POSITION pos;
int fileselpos = 0;
// VERIFYINFO strVerifyInfo;
int m_nVerifyret = -1;
UpdateData(TRUE);
if(!m_bDown)
{
pos = m_Filelist.GetFirstSelectedItemPosition();
if(pos == NULL)
{
AfxMessageBox("Please select file to download!");
return;
}
fileselpos = m_Filelist.GetNextSelectedItem(pos);
csFileName.Format("%s",m_Filelist.GetItemText(fileselpos,0));
if(csFileName.IsEmpty())
return;
csStartTime.Format("%s",m_Filelist.GetItemText(fileselpos,2));
csStopTime.Format("%s",m_Filelist.GetItemText(fileselpos,3));
sprintf(filenamedownload,"%s",csFileName);
csDir.Format("%s\\",ClientParam.m_csDownLoadPath);
sprintf(nFileName,"%s%s_%02d_D%s_%s.mp4",csDir,serverinfo[iSelServer].m_csServerIP, m_iChannel,csStartTime,csStopTime);
TRACE("Download file name: %s \n", nFileName);
lFileHandle = NET_DVR_GetFileByName(m_lServerID,filenamedownload,nFileName);
if(lFileHandle >= 0)
{
NET_DVR_PlayBackControl(lFileHandle, NET_DVR_PLAYSTART, 0, NULL);
GetDlgItem(IDC_DOWNLOAD)->SetWindowText("Stop Download");
m_downProgress.SetPos(0);
m_downProgress.ShowWindow(SW_SHOW);
m_bDown=TRUE;
m_staticdownload.Format("Downloading file:%s", filenamedownload);
GetDlgItem(IDC_STATICSTATE2)->ShowWindow(SW_SHOW);
SetTimer(DOWNSTATE_TIMER,200,NULL);
}
else
{
AfxMessageBox("Download failed!");
CString sTemp;
sTemp.Format("ERROR: NET_DVR_GetFileByName = %d",NET_DVR_GetLastError());
TRACE(sTemp);
return;
}
}
else
{
NET_DVR_StopGetFile(lFileHandle);
m_bDown=FALSE;
GetDlgItem(IDC_DOWNLOAD)->SetWindowText("Download");
KillTimer(DOWNSTATE_TIMER);
Invalidate(TRUE);
m_downProgress.SetPos(0);
m_downProgress.ShowWindow(SW_HIDE);
m_staticdownload.Format("Stop download file:%s", filenamedownload);
GetDlgItem(IDC_STATICSTATE2)->ShowWindow(SW_HIDE);
}
UpdateData(FALSE);
}
void CRemoteFilePlay::OnPlayFile()
{
// TODO: Add your control notification handler code here
if(m_nPlayHandle == -1)
{
F_Play();
}
else
{
if(m_bPause)
{
if(m_bSetFrame)
{
if(NET_DVR_PlayBackControl(m_nPlayHandle, NET_DVR_PLAYNORMAL, 0, NULL))
{
TRACE("handle:%d \n",m_nPlayHandle);
m_bSetFrame=FALSE;
F_SetPlayState();
}
}
if(NET_DVR_PlayBackControl(m_nPlayHandle, NET_DVR_PLAYRESTART, 0, NULL))
{
m_bPause=FALSE;
F_SetPlayState();
}
}
else
{
if(m_bSetFrame)
{
if(NET_DVR_PlayBackControl(m_nPlayHandle, NET_DVR_PLAYNORMAL, 0, NULL))
{
TRACE("handle:%d \n",m_nPlayHandle);
m_bSetFrame=FALSE;
F_SetPlayState();
}
}
else
{
if(NET_DVR_PlayBackControl(m_nPlayHandle, NET_DVR_PLAYPAUSE, 0, NULL))
{
TRACE("handle:%d \n",m_nPlayHandle);
m_bPause=TRUE;
F_SetPauseState();
}
}
}
}
}
void CRemoteFilePlay::OnStop()
{
// TODO: Add your control notification handler code here
F_StopPlay();
}
void CRemoteFilePlay::OnSlow()
{
// TODO: Add your control notification handler code here
NET_DVR_PlayBackControl(m_nPlayHandle, NET_DVR_PLAYSLOW, 0, NULL);
}
void CRemoteFilePlay::OnFast()
{
// TODO: Add your control notification handler code here
NET_DVR_PlayBackControl(m_nPlayHandle, NET_DVR_PLAYFAST, 0, NULL);
}
void CRemoteFilePlay::OnCappic()
{
// TODO: Add your control notification handler code here
char cFilename[256];
sprintf(cFilename, "%s\\%d_%d.bmp",ClientParam.m_csPictureSavePath,m_iChannel, GetTickCount());
if(NET_DVR_PlayBackCaptureFile(m_nPlayHandle,cFilename))
{
CString sTemp;
sTemp.Format("Capture picture succeed %s!",cFilename);
AfxMessageBox(sTemp);
return;
}
else
{
AfxMessageBox("Capture failed!");
}
}
void CRemoteFilePlay::OnStep()
{
// TODO: Add your control notification handler code here
if(NET_DVR_PlayBackControl(m_nPlayHandle, NET_DVR_PLAYFRAME, 0, NULL))
{
CButton *pButton;
pButton = (CButton *)GetDlgItem(IDC_PLAY_FILE);
pButton->SetIcon(m_hPlayEnableIcon);
pButton->EnableWindow(TRUE);
m_bSetFrame = TRUE;
}
}
void CRemoteFilePlay::OnSound()
{
// TODO: Add your control notification handler code here
CButton *pButton;
if(m_bSound)
{
if(NET_DVR_PlayBackControl(m_nPlayHandle, NET_DVR_PLAYSTOPAUDIO, 0, NULL))
{
m_bSound=FALSE;
pButton = (CButton *)GetDlgItem(IDC_SOUND);
pButton->SetIcon(m_hSoundStopIcon);
}
}
else
{
if(NET_DVR_PlayBackControl(m_nPlayHandle, NET_DVR_PLAYSTARTAUDIO, 0, NULL))
{
pButton = (CButton *)GetDlgItem(IDC_SOUND);
pButton->SetIcon(m_hSoundStartIcon);
m_bSound=TRUE;
}
}
}
void CRemoteFilePlay::F_InitUI()
{
// Initialize button
CButton *pButton;
m_rcScreen=CRect(0,0,GetSystemMetrics(SM_CXSCREEN),GetSystemMetrics(SM_CYSCREEN));
//initialize slider
pButton = (CButton *)GetDlgItem(IDC_PLAY_FILE);
pButton->SetIcon(m_hPlayDisableIcon);
pButton->EnableWindow(FALSE);
pButton = (CButton *)GetDlgItem(IDC_STOP);
pButton->SetIcon(m_hStopDisableIcon);
pButton->EnableWindow(FALSE);
pButton = (CButton *)GetDlgItem(IDC_FAST);
pButton->SetIcon(m_hFastDisableIcon);
pButton->EnableWindow(FALSE);
pButton = (CButton *)GetDlgItem(IDC_SLOW);
pButton->SetIcon(m_hSlowDisableIcon);
pButton->EnableWindow(FALSE);
pButton = (CButton *)GetDlgItem(IDC_STEP);
pButton->SetIcon(m_hStepDisableIcon);
pButton->EnableWindow(FALSE);
pButton = (CButton *)GetDlgItem(IDC_GOTOSTART);
pButton->SetIcon(m_hGotoHeadDisableIcon);
pButton->EnableWindow(FALSE);
pButton = (CButton *)GetDlgItem(IDC_CAPPIC);
pButton->SetIcon(m_hCaptureIcon);
pButton->EnableWindow(FALSE);
pButton = (CButton *)GetDlgItem(IDC_SOUND);
pButton->SetIcon(m_hSoundStopIcon);
pButton->EnableWindow(FALSE);
}
void CRemoteFilePlay::F_SetStopState()
{
CButton *pButton;
m_ctlProgress.SetPos(0);
m_ctlProgress.EnableWindow(FALSE);
m_ctlVolume.EnableWindow(FALSE);
pButton = (CButton *)GetDlgItem(IDC_PLAY_FILE);
pButton->SetIcon(m_hPlayEnableIcon);
pButton->EnableWindow(TRUE);
pButton = (CButton *)GetDlgItem(IDC_STOP);
pButton->SetIcon(m_hStopDisableIcon);
pButton->EnableWindow(FALSE);
pButton = (CButton *)GetDlgItem(IDC_FAST);
pButton->SetIcon(m_hFastDisableIcon);
pButton->EnableWindow(FALSE);
pButton = (CButton *)GetDlgItem(IDC_SLOW);
pButton->SetIcon(m_hSlowDisableIcon);
pButton->EnableWindow(FALSE);
pButton = (CButton *)GetDlgItem(IDC_STEP);
pButton->SetIcon(m_hStepDisableIcon);
pButton->EnableWindow(FALSE);
pButton = (CButton *)GetDlgItem(IDC_GOTOSTART);
pButton->SetIcon(m_hGotoHeadDisableIcon);
pButton->EnableWindow(FALSE);
pButton = (CButton *)GetDlgItem(IDC_CAPPIC);
pButton->SetIcon(m_hCaptureIcon);
pButton->EnableWindow(FALSE);
pButton = (CButton *)GetDlgItem(IDC_SOUND);
pButton->SetIcon(m_hSoundStopIcon);
pButton->EnableWindow(FALSE);
pButton = (CButton *)GetDlgItem(IDC_STEP);
pButton->SetIcon(m_hStepDisableIcon);
pButton->EnableWindow(FALSE);
}
void CRemoteFilePlay::F_Exit()
{
if(m_hFileThread)
{
TerminateThread(m_hFileThread, 0);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -