// RemoteFilePlay.cpp : implementation file // #include "stdafx.h" #include "StoneU_HC_OCX.h" #include "RemoteFilePlay.h" #include "newclientDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CRemoteFilePlay dialog extern SERVER_INFO serverinfo[MAXIPNUMBER]; extern CLIENTPARAM ClientParam; BOOL g_bRmtCapPic = FALSE; CRemoteFilePlay * RFile; HANDLE hFile; int nTemp = 0; extern CNewclientDlg *g_NewClientDlg; void CALLBACK PlayDataCallBack(LONG lPlayHandle, DWORD dwDataType, BYTE *pBuffer,DWORD dwBufSize,DWORD dwUser) { //TRACE("lPlayHandle = %d dwUser = %d dwDataType = %d dwBufSize = %d", lPlayHandle, dwUser, dwDataType, dwBufSize); } ////////////////////////////////////////// UINT GetFileThread(LPVOID pParam) { LONG bRet = -1; NET_DVR_FIND_DATA strFileInfo; CString tempstring; //int ntemp,ntemp1; char tempfile[100]; while(1) { bRet = NET_DVR_FindNextFile(RFile->m_lFileHandle, &strFileInfo); if(bRet == NET_DVR_FILE_SUCCESS) { strcpy(tempfile,strFileInfo.sFileName); RFile->m_Filelist.InsertItem(RFile->m_iFileNum,tempfile,0); tempstring.Format("%d",strFileInfo.dwFileSize); RFile->m_Filelist.SetItemText(RFile->m_iFileNum,1,tempstring); tempstring.Format("%04d%02d%02d%02d%02d%02d",strFileInfo.struStartTime.dwYear, strFileInfo.struStartTime.dwMonth,strFileInfo.struStartTime.dwDay,strFileInfo.struStartTime.dwHour,strFileInfo.struStartTime.dwMinute,strFileInfo.struStartTime.dwSecond); RFile->m_Filelist.SetItemText(RFile->m_iFileNum,2,tempstring); tempstring.Format("%04d%02d%02d%02d%02d%02d",strFileInfo.struStopTime.dwYear, strFileInfo.struStopTime.dwMonth,strFileInfo.struStopTime.dwDay,strFileInfo.struStopTime.dwHour,strFileInfo.struStopTime.dwMinute,strFileInfo.struStopTime.dwSecond); RFile->m_Filelist.SetItemText(RFile->m_iFileNum,3,tempstring); RFile->m_iFileNum++; } else { if(bRet == NET_DVR_ISFINDING) { Sleep(5); continue; } if( (bRet == NET_DVR_NOMOREFILE) || (bRet == NET_DVR_FILE_NOFIND) ) { RFile->GetDlgItem(IDC_SEARCHLIST)->SetWindowText("查找"); // by zxy 2005/05/10 RFile->m_bSearchDown = FALSE; (RFile->GetDlgItem(IDC_STATICSTATE))->ShowWindow(SW_HIDE); RFile->m_iFileNum = 0; if(RFile->m_nPlayHandle == -1) RFile->F_SetStopState(); break; } else { RFile->GetDlgItem(IDC_SEARCHLIST)->SetWindowText("查找"); RFile->m_bSearchDown = FALSE; (RFile->GetDlgItem(IDC_STATICSTATE))->ShowWindow(SW_HIDE); MessageBox(g_NewClientDlg->GetSafeHwnd(),"由于服务器忙,或网络故障,获取文件列表异常终止!", "温馨提示", MB_ICONINFORMATION); RFile->m_iFileNum = 0; if(RFile->m_nPlayHandle == -1) RFile->F_SetStopState(); break; } } } CloseHandle(RFile->m_hFileThread); RFile->m_hFileThread = NULL; NET_DVR_FindClose(RFile->m_lFileHandle); return 0; } CRemoteFilePlay::CRemoteFilePlay(CWnd* pParent /*=NULL*/) : CDialog(CRemoteFilePlay::IDD, pParent) { //{{AFX_DATA_INIT(CRemoteFilePlay) m_ctDateStart = 0; m_ctDateStop = 0; m_ctTimeStart = 0; m_ctTimeStop = 0; m_sCardNum = _T(""); m_staticdownload = _T(""); m_bCard = FALSE; //}}AFX_DATA_INIT m_hPlayEnableIcon = AfxGetApp()->LoadIcon(IDI_PLAY_ENABLE); m_hPlayDisableIcon = AfxGetApp()->LoadIcon(IDI_PLAY_DISABLE); m_hPauseEnableIcon = AfxGetApp()->LoadIcon(IDI_PAUSE_ENABLE); m_hPauseDisableIcon = AfxGetApp()->LoadIcon(IDI_PAUSE_DISABLE); m_hStopEnableIcon = AfxGetApp()->LoadIcon(IDI_STOP_ENABLE); m_hStopDisableIcon = AfxGetApp()->LoadIcon(IDI_STOP_DISABLE); m_hSoundStartIcon= AfxGetApp()->LoadIcon(IDI_SOUND_ENABLE); m_hSoundStopIcon= AfxGetApp()->LoadIcon(IDI_SOUND_DISABLE); m_hGotoHeadDisableIcon = AfxGetApp()->LoadIcon(IDI_GOTOSTART_DISABLE); m_hGotoTailDisableIcon = AfxGetApp()->LoadIcon(IDI_GOTOEND_DISABLE); m_hFastDisableIcon = AfxGetApp()->LoadIcon(IDI_FASTFORWARD_DISABLE); m_hSlowDisableIcon= AfxGetApp()->LoadIcon(IDI_FASTBACKWARD_DISABLE); m_hGotoHeadEnableIcon = AfxGetApp()->LoadIcon(IDI_GOTOSTART_ENABLE); m_hGotoTailEnableIcon = AfxGetApp()->LoadIcon(IDI_GOTOEND_ENABLE); m_hFastEnableIcon = AfxGetApp()->LoadIcon(IDI_FASTFORWARD_ENABLE); m_hSlowEnableIcon = AfxGetApp()->LoadIcon(IDI_FASTBACKWARD_ENABLE); m_hStepEnableIcon= AfxGetApp()->LoadIcon(IDI_STEP_ENABLE); m_hStepDisableIcon = AfxGetApp()->LoadIcon(IDI_STEP_DISABLE); m_hStepBackEnableIcon = AfxGetApp()->LoadIcon(IDI_STEPBACK_ENABLE); m_hStepBackDisableIcon = AfxGetApp()->LoadIcon(IDI_STEPBACK_DISABLE); m_hCaptureIcon = AfxGetApp()->LoadIcon(IDI_PIC); } void CRemoteFilePlay::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CRemoteFilePlay) DDX_Control(pDX, IDC_REMOTEFILRLIST, m_Filelist); DDX_Control(pDX, IDC_COMBOPORT, m_ChannelCtrl); DDX_Control(pDX, IDC_PROGRESS_SLIDER, m_ctlProgress); DDX_Control(pDX, IDC_WND, m_PlayWnd); DDX_Control(pDX, IDC_DOWNPROGRESS, m_downProgress); DDX_Control(pDX, IDC_COMBOSERVER, m_ServerCtrl); DDX_Control(pDX, IDC_COMBOFILETYPE, m_FileType); DDX_Control(pDX, IDC_VOLUME_SLIDER, m_ctlVolume); DDX_DateTimeCtrl(pDX, IDC_DATESTART, m_ctDateStart); DDX_DateTimeCtrl(pDX, IDC_DATESTOP, m_ctDateStop); DDX_DateTimeCtrl(pDX, IDC_TIMESTART, m_ctTimeStart); DDX_DateTimeCtrl(pDX, IDC_TIMESTOP, m_ctTimeStop); DDX_Text(pDX, IDC_CARDNUM, m_sCardNum); DDX_Text(pDX, IDC_STATICSTATE2, m_staticdownload); DDX_Check(pDX, IDC_CHKCARD, m_bCard); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CRemoteFilePlay, CDialog) //{{AFX_MSG_MAP(CRemoteFilePlay) ON_NOTIFY(NM_DBLCLK, IDC_REMOTEFILRLIST, OnDblclkRemotefilrlist) ON_WM_HSCROLL() ON_WM_LBUTTONDBLCLK() ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_PROGRESS_SLIDER, OnReleasedcaptureProgressSlider) ON_WM_TIMER() ON_BN_CLICKED(IDC_SEARCHLIST, OnSearchlist) ON_BN_CLICKED(IDC_DOWNLOAD, OnDownload) ON_BN_CLICKED(IDC_PLAY_FILE, OnPlayFile) ON_BN_CLICKED(IDC_STOP, OnStop) ON_BN_CLICKED(IDC_SLOW, OnSlow) ON_BN_CLICKED(IDC_FAST, OnFast) ON_BN_CLICKED(IDC_CAPPIC, OnCappic) ON_BN_CLICKED(IDC_STEP, OnStep) ON_BN_CLICKED(IDC_SOUND, OnSound) ON_WM_DESTROY() ON_CBN_SELCHANGE(IDC_COMBOSERVER, OnSelchangeComboserver) ON_BN_CLICKED(IDC_BUTTONSAVE, OnButtonsave) ON_BN_CLICKED(IDC_BUTTONSTOPSAVE, OnButtonstopsave) ON_BN_CLICKED(IDC_GOTOSTART, OnGotostart) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CRemoteFilePlay message handlers void CRemoteFilePlay::SetParentWnd(HWND *hhWnd, int iParentNum) { VERIFY(iParentNum==2); m_hPareDlgWnd=hhWnd[0]; m_hPareTabWnd=hhWnd[1]; } BOOL CRemoteFilePlay::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here CRect rc(0, 0, 0, 0); GetParent()->GetClientRect(&rc); ((CTabCtrl*)GetParent())->AdjustRect(FALSE, &rc); MoveWindow(&rc); F_InitUI(); RFile=this; m_bDown=FALSE; m_bSearchDown = FALSE; m_nPlayHandle = -1; m_bSound=TRUE; g_bRmtCapPic=FALSE; m_bPause=FALSE; m_bSetFrame = FALSE; bGetMaxTime = FALSE; m_bFullScreen = FALSE; m_bSaveFile = FALSE; m_hPareDlgWnd = NULL; m_hPareTabWnd = NULL; m_hPlayWnd = GetDlgItem(IDC_WND)->m_hWnd; m_ctlVolume.SetRange(0,100); m_ctlProgress.SetRange(0,100); m_downProgress.SetRange(0,100); m_ctlProgress.SetPos(0); m_downProgress.SetPos(0); m_ctlVolume.SetPos(50); m_ServerCtrl.AddString("请选择DVR"); for(int i = 0; i < MAXIPNUMBER; i++) { if(serverinfo[i].m_csServerName != "") m_ServerCtrl.AddString(serverinfo[i].m_csServerName); } iFileType = 0; GetDlgItem(IDC_STATICCARDNUM)->ShowWindow(SW_SHOW); GetDlgItem(IDC_CARDNUM)->ShowWindow(SW_SHOW); m_ServerCtrl.SetCurSel(0); m_ChannelCtrl.SetCurSel(1); m_FileType.SetCurSel(iFileType); m_iChannel = 0; m_Filelist.InsertColumn(0,"文件名称",LVCFMT_LEFT,120,-1); m_Filelist.InsertColumn(1,"文件大小",LVCFMT_LEFT,70,-1); m_Filelist.InsertColumn(2,"开始时间",LVCFMT_LEFT,110,-1); m_Filelist.InsertColumn(3,"结束时间",LVCFMT_LEFT,110,-1); GetDlgItem(IDC_WND)->GetWindowRect(m_rcWnd); ScreenToClient(m_rcWnd); m_hFileThread = NULL; lFileHandle = -1; m_iFileNum = 0; m_nFileTime = 0; m_nTotalFrames = 0; m_nTotalSecond = 0; m_nTotalMinute = 0; m_nTotalHour = 0; CTime time1 = CTime::GetCurrentTime(); CTime time(time1.GetYear(),time1.GetMonth(),time1.GetDay(),0,0,0); CTime time0(time1.GetYear(),time1.GetMonth(),time1.GetDay(),23,59,59); m_ctDateStart = time; m_ctTimeStart = time; m_ctDateStop = time; m_ctTimeStop = time0; UpdateData(FALSE); m_bFindFile = FALSE; m_bFileDownload = FALSE; m_lStartChan = 0; return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CRemoteFilePlay::OnDestroy() { KillTimer(DOWNSTATE_TIMER); CDialog::OnDestroy(); // TODO: Add your message handler code here } void CRemoteFilePlay::OnDblclkRemotefilrlist(NMHDR* pNMHDR, LRESULT* pResult) { // TODO: Add your control notification handler code here OnStop(); OnPlayFile(); *pResult = 0; } void CRemoteFilePlay::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) { // TODO: Add your message handler code here and/or call default char volume = 0; WORD temp = (0xffff)/100; WORD volumevalue = 0; if (GetDlgItem(IDC_VOLUME_SLIDER) == pScrollBar) { volume =(char)m_ctlVolume.GetPos(); volumevalue =(WORD) (volume*temp); if(m_nPlayHandle >= 0) NET_DVR_PlayBackControl(m_nPlayHandle, NET_DVR_PLAYAUDIOVOLUME, volumevalue, NULL); } if (GetDlgItem(IDC_PROGRESS_SLIDER) == pScrollBar) { char cpos = (char)(m_ctlProgress.GetPos()); if(m_nPlayHandle >= 0) { if ((cpos >=0) && (cpos <=100)) { if(cpos == 100) { //F_StopPlay(); cpos = 99; } else { NET_DVR_PlayBackControl(m_nPlayHandle,NET_DVR_PLAYSETPOS, cpos, NULL); } } } } CDialog::OnHScroll(nSBCode, nPos, pScrollBar); } void CRemoteFilePlay::OnLButtonDblClk(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default if( (IsInWnd(point)) && (m_nPlayHandle>=0) ) { m_bFullScreen=!m_bFullScreen; if(m_bFullScreen) F_ShowFullScreen(); else F_ShowNormal(); } CDialog::OnLButtonDblClk(nFlags, point); } void CRemoteFilePlay::OnReleasedcaptureProgressSlider(NMHDR* pNMHDR, LRESULT* pResult) { // TODO: Add your control notification handler code here *pResult = 0; } void CRemoteFilePlay::OnTimer(UINT nIDEvent) { // TODO: Add your message handler code here and/or call default int nPos; DWORD nPos1; DWORD nCurrentTime = 0,nHour = 0,nMinute = 0,nSecond = 0,nCurrentFrame = 0; DWORD nPlayedFrames = 0; CString csText; NET_DVR_TIME OsdTime; switch(nIDEvent) { case DOWNSTATE_TIMER: if(m_bDown) { nPos = NET_DVR_GetDownloadPos(lFileHandle); if(nPos < 0) //失败 { NET_DVR_StopGetFile(lFileHandle); m_downProgress.ShowWindow(SW_HIDE); RFile->GetDlgItem(IDC_DOWNLOAD)->SetWindowText("下载"); RFile->m_bDown=FALSE; m_staticdownload.Format("停止下载文件%s", filenamedownload); GetDlgItem(IDC_STATICSTATE2)->ShowWindow(SW_HIDE); MessageBox("获取下载进度失败!", "温馨提示", MB_ICONINFORMATION); } if(nPos == 100) //下载结束 { NET_DVR_StopGetFile(lFileHandle); m_downProgress.ShowWindow(SW_HIDE); RFile->GetDlgItem(IDC_DOWNLOAD)->SetWindowText("下载"); RFile->m_bDown=FALSE; m_staticdownload.Format("下载文件结束%s", filenamedownload); GetDlgItem(IDC_STATICSTATE2)->ShowWindow(SW_HIDE); MessageBox("下载完毕!", "温馨提示", MB_ICONINFORMATION); } if(nPos > 100) //由于网络原因或DVR忙,下载异常终止 { NET_DVR_StopGetFile(lFileHandle); m_downProgress.ShowWindow(SW_HIDE); RFile->GetDlgItem(IDC_DOWNLOAD)->SetWindowText("下载"); RFile->m_bDown=FALSE; m_staticdownload.Format("停止下载文件%s", filenamedownload); GetDlgItem(IDC_STATICSTATE2)->ShowWindow(SW_HIDE); MessageBox("由于网络原因或DVR忙,下载异常终止!", "温馨提示", MB_ICONINFORMATION); } else { m_downProgress.SetPos(nPos); } } break; case RPSTATE_TIMER: // nTemp++; // if (nTemp == 5) // NET_DVR_PlayBackControl(m_nPlayHandle, NET_DVR_PLAYSETPOS, 80, NULL); if(!bGetMaxTime) { NET_DVR_PlayBackControl(m_nPlayHandle, NET_DVR_GETTOTALTIME, 0, &m_nFileTime); if(m_nFileTime == 0) return; NET_DVR_PlayBackControl(m_nPlayHandle, NET_DVR_GETTOTALFRAMES, 0, &m_nTotalFrames); if(m_nTotalFrames == 0) return; m_nTotalHour=m_nFileTime/3600; m_nTotalMinute=(m_nFileTime%3600)/60; m_nTotalSecond=m_nFileTime%60; bGetMaxTime = TRUE; } NET_DVR_PlayBackControl(m_nPlayHandle, NET_DVR_PLAYGETTIME, 0, &nCurrentTime); if(nCurrentTime >= m_nFileTime) { nCurrentTime = m_nFileTime; } nHour=(nCurrentTime/3600)%24; nMinute=(nCurrentTime%3600)/60; nSecond=nCurrentTime%60; NET_DVR_PlayBackControl(m_nPlayHandle, NET_DVR_PLAYGETFRAME, 0, &nCurrentFrame); if(nCurrentFrame>m_nTotalFrames) nCurrentFrame = m_nTotalFrames; csText.Format("%d/%d %02d:%02d:%02d/%02d:%02d:%02d %s",nCurrentFrame,m_nTotalFrames,nHour,nMinute,nSecond,m_nTotalHour,m_nTotalMinute,m_nTotalSecond,filename); GetDlgItem(IDC_PLAYSTATUS)->SetWindowText(csText); NET_DVR_PlayBackControl(m_nPlayHandle, NET_DVR_PLAYGETPOS, 0, &nPos1); if(nPos1 > 100) //由于网络原因或DVR忙,回放异常终止 { F_StopPlay(); MessageBox("由于网络原因或DVR忙,回放异常终止!", "温馨提示", MB_ICONINFORMATION); } else { m_ctlProgress.SetPos(nPos1); if(nPos1 == 100) { F_StopPlay(); TRACE("回放文件结束!"); } } 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) { MessageBox("请选择一个DVR!", "温馨提示", MB_ICONINFORMATION); 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) { MessageBox("获取文件列表失败!", "温馨提示", MB_ICONINFORMATION); 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) { MessageBox("打开线程失败!", "温馨提示", MB_ICONINFORMATION); return; } GetDlgItem(IDC_SEARCHLIST)->SetWindowText("停止查找"); 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("查找"); 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) { MessageBox("请选择要下载的文件!", "温馨提示", MB_ICONINFORMATION); 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("停止下载"); m_downProgress.SetPos(0); m_downProgress.ShowWindow(SW_SHOW); m_bDown=TRUE; m_staticdownload.Format("正在下载文件%s", filenamedownload); GetDlgItem(IDC_STATICSTATE2)->ShowWindow(SW_SHOW); SetTimer(DOWNSTATE_TIMER,200,NULL); } else { MessageBox("下载文件失败!", "温馨提示", MB_ICONINFORMATION); 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("下载"); KillTimer(DOWNSTATE_TIMER); Invalidate(TRUE); m_downProgress.SetPos(0); m_downProgress.ShowWindow(SW_HIDE); m_staticdownload.Format("停止下载文件%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)) { 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)) { m_bSetFrame=FALSE; F_SetPlayState(); } } else { if(NET_DVR_PlayBackControl(m_nPlayHandle, NET_DVR_PLAYPAUSE, 0, NULL)) { 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("抓图成功 %s!",cFilename); MessageBox(sTemp, "温馨提示", MB_ICONINFORMATION); return; } else { MessageBox("抓图失败!", "温馨提示", MB_ICONINFORMATION); } } 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() { // 初始化按钮 CButton *pButton; m_rcScreen=CRect(0,0,GetSystemMetrics(SM_CXSCREEN),GetSystemMetrics(SM_CYSCREEN)); //初始化滑动条 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); CloseHandle(m_hFileThread); m_hFileThread = NULL; NET_DVR_FindClose(m_lFileHandle); } //2008-02-25 这里要调用这个函数逐步停止,不能只调用停止解码 F_StopPlay(); Sleep(100); } void CRemoteFilePlay::F_Play() { UpdateData(TRUE); int m_nVerifyret = -1; CString csFileName; int fileselpos = 0; HWND PlayhWnd=m_PlayWnd.GetSafeHwnd(); POSITION pos = m_Filelist.GetFirstSelectedItemPosition(); if(pos == NULL) { MessageBox("请选择要播放的文件!", "温馨提示", MB_ICONINFORMATION); return; } fileselpos = m_Filelist.GetNextSelectedItem(pos); csFileName.Format("%s",m_Filelist.GetItemText(fileselpos,0)); if(csFileName.IsEmpty()) return; TRACE("远程回放文件:%s \n", csFileName); sprintf(filename,"%s",csFileName); // remoteplay_info.srcfilename=filename; if(m_nPlayHandle>=0) { NET_DVR_StopPlayBack(m_nPlayHandle); m_nPlayHandle = -1; Sleep(400); } m_nPlayHandle = NET_DVR_PlayBackByName(m_lServerID, filename, PlayhWnd); if(m_nPlayHandle == -1) { MessageBox("回放失败!", "温馨提示", MB_ICONINFORMATION); return; } NET_DVR_SetPlayDataCallBack(m_nPlayHandle, PlayDataCallBack, m_nPlayHandle); F_SetPlayState(); NET_DVR_PlayBackControl(m_nPlayHandle, NET_DVR_PLAYSTART, 0, NULL); if(NET_DVR_PlayBackControl(m_nPlayHandle, NET_DVR_PLAYSTARTAUDIO, 0, NULL)) { m_bSound=TRUE; NET_DVR_PlayBackControl(m_nPlayHandle, NET_DVR_PLAYAUDIOVOLUME, (0xffff)/2, NULL); m_ctlVolume.SetPos(50); ((CButton *)GetDlgItem(IDC_SOUND))->SetIcon(m_hSoundStartIcon); } else { m_bSound=FALSE; ((CButton *)GetDlgItem(IDC_SOUND))->SetIcon(m_hSoundStopIcon); } bGetMaxTime = FALSE; SetTimer(RPSTATE_TIMER, 1000, NULL); } void CRemoteFilePlay::F_SetPlayState() { m_ctlProgress.EnableWindow(TRUE); m_ctlVolume.EnableWindow(TRUE); CButton *pButton; pButton = (CButton *)GetDlgItem(IDC_PLAY_FILE); pButton->SetIcon(m_hPauseEnableIcon); pButton->EnableWindow(TRUE); pButton = (CButton *)GetDlgItem(IDC_STOP); pButton->SetIcon(m_hStopEnableIcon); pButton->EnableWindow(TRUE); pButton = (CButton *)GetDlgItem(IDC_FAST); pButton->SetIcon(m_hFastEnableIcon); pButton->EnableWindow(TRUE); pButton = (CButton *)GetDlgItem(IDC_SLOW); pButton->SetIcon(m_hSlowEnableIcon); pButton->EnableWindow(TRUE); pButton = (CButton *)GetDlgItem(IDC_CAPPIC); pButton->SetIcon(m_hCaptureIcon); pButton->EnableWindow(TRUE); pButton = (CButton *)GetDlgItem(IDC_SOUND); if(m_bSound) pButton->SetIcon(m_hSoundStartIcon); else pButton->SetIcon(m_hSoundStopIcon); pButton->EnableWindow(TRUE); pButton = (CButton *)GetDlgItem(IDC_STEP); pButton->SetIcon(m_hStepEnableIcon); pButton->EnableWindow(TRUE); pButton = (CButton *)GetDlgItem(IDC_GOTOSTART); pButton->SetIcon(m_hGotoHeadEnableIcon); pButton->EnableWindow(TRUE); } void CRemoteFilePlay::F_SetPauseState() { CButton *pButton; pButton = (CButton *)GetDlgItem(IDC_PLAY_FILE); pButton->SetIcon(m_hPlayEnableIcon); pButton->EnableWindow(TRUE); } void CRemoteFilePlay::F_StopPlay() { if(m_bFullScreen) { m_bFullScreen = FALSE; F_ShowNormal(); } if(m_nPlayHandle >= 0) { if(m_bSaveFile) { NET_DVR_StopPlayBackSave(m_nPlayHandle); m_bSaveFile = FALSE; } NET_DVR_StopPlayBack(m_nPlayHandle); m_nPlayHandle = -1; m_ctlProgress.SetPos(0); CString csText; KillTimer(RPSTATE_TIMER); csText.Format("%d/%d %02d:%02d:%02d/%02d:%02d:%02d",0,0,0,0,0,0,0,0); GetDlgItem(IDC_PLAYSTATUS)->SetWindowText(csText); //2008-02-25 停止回放时如果打开了声音就要关闭 if (m_bSound) { NET_DVR_PlayBackControl(m_nPlayHandle, NET_DVR_PLAYSTOPAUDIO, 0, NULL); m_ctlVolume.SetPos(0); ((CButton *)GetDlgItem(IDC_SOUND))->SetIcon(m_hSoundStopIcon); m_bSound = FALSE; } UpdateData(FALSE); Invalidate(TRUE); } m_bPause = FALSE; m_bSetFrame = FALSE; F_SetStopState(); } void CRemoteFilePlay::F_ShowNormal() { GetDlgItem(IDC_WND)->SetWindowPos(NULL,m_rcWnd.left,m_rcWnd.top,m_rcWnd.Width(),m_rcWnd.Height(),SWP_SHOWWINDOW); ::SetWindowPos(m_hWnd,NULL,m_rcParent.left,m_rcParent.top,m_rcParent.Width(),m_rcParent.Height(),SWP_SHOWWINDOW); ::SetWindowPos(m_hPareTabWnd,NULL,m_rcPareTab.left,m_rcPareTab.top,m_rcPareTab.Width(),m_rcPareTab.Height(),SWP_SHOWWINDOW); ::SetWindowPos(m_hPareDlgWnd,NULL,m_rcPareDlg.left,m_rcPareDlg.top,m_rcPareDlg.Width(),m_rcPareDlg.Height(),SWP_SHOWWINDOW); F_EnableFlashWnd(TRUE); Invalidate(FALSE); UpdateWindow(); } void CRemoteFilePlay::F_EnableFlashWnd(BOOL bEnable) { if(bEnable) { //THE same to multiplay GetDlgItem(IDC_PLAYSTATUS)->ModifyStyle(0,WS_VISIBLE,0); GetDlgItem(IDC_PLAY_FILE)->ModifyStyle(0,WS_VISIBLE,0); GetDlgItem(IDC_STOP)->ModifyStyle(0,WS_VISIBLE,0); GetDlgItem(IDC_SLOW)->ModifyStyle(0,WS_VISIBLE,0); GetDlgItem(IDC_FAST)->ModifyStyle(0,WS_VISIBLE,0); GetDlgItem(IDC_SOUND)->ModifyStyle(0,WS_VISIBLE,0); GetDlgItem(IDC_VOLUME_SLIDER)->ModifyStyle(0,WS_VISIBLE,0); GetDlgItem(IDC_PROGRESS_SLIDER)->ModifyStyle(0,WS_VISIBLE,0); GetDlgItem(IDC_DATESTART)->ModifyStyle(0,WS_VISIBLE,0); GetDlgItem(IDC_DATESTOP)->ModifyStyle(0,WS_VISIBLE,0); GetDlgItem(IDC_TIMESTOP)->ModifyStyle(0,WS_VISIBLE,0); GetDlgItem(IDC_TIMESTART)->ModifyStyle(0,WS_VISIBLE,0); GetDlgItem(IDC_COMBOFILETYPE)->ModifyStyle(0,WS_VISIBLE,0); GetDlgItem(IDC_SEARCHLIST)->ModifyStyle(0,WS_VISIBLE,0); GetDlgItem(IDC_CAPPIC)->ModifyStyle(0,WS_VISIBLE,0); //the only for single play GetDlgItem(IDC_DOWNLOAD)->ModifyStyle(0,WS_VISIBLE,0); GetDlgItem(IDC_REMOTEFILRLIST)->ModifyStyle(0,WS_VISIBLE,0); if(m_bDown) GetDlgItem(IDC_DOWNPROGRESS)->ModifyStyle(0,WS_VISIBLE,0); GetDlgItem(IDC_STEP)->ModifyStyle(0,WS_VISIBLE,0); GetDlgItem(IDC_GOTOSTART)->ModifyStyle(0,WS_VISIBLE,0); } else { //THE same to multiplay GetDlgItem(IDC_PLAYSTATUS)->ModifyStyle(WS_VISIBLE,0,0); GetDlgItem(IDC_PLAY_FILE)->ModifyStyle(WS_VISIBLE,0,0); GetDlgItem(IDC_STOP)->ModifyStyle(WS_VISIBLE,0,0); GetDlgItem(IDC_SLOW)->ModifyStyle(WS_VISIBLE,0,0); GetDlgItem(IDC_FAST)->ModifyStyle(WS_VISIBLE,0,0); GetDlgItem(IDC_SOUND)->ModifyStyle(WS_VISIBLE,0,0); GetDlgItem(IDC_VOLUME_SLIDER)->ModifyStyle(WS_VISIBLE,0,0); GetDlgItem(IDC_PROGRESS_SLIDER)->ModifyStyle(WS_VISIBLE,0,0); GetDlgItem(IDC_DATESTART)->ModifyStyle(WS_VISIBLE,0,0); GetDlgItem(IDC_DATESTOP)->ModifyStyle(WS_VISIBLE,0,0); GetDlgItem(IDC_TIMESTOP)->ModifyStyle(WS_VISIBLE,0,0); GetDlgItem(IDC_TIMESTART)->ModifyStyle(WS_VISIBLE,0,0); GetDlgItem(IDC_COMBOFILETYPE)->ModifyStyle(WS_VISIBLE,0,0); GetDlgItem(IDC_SEARCHLIST)->ModifyStyle(WS_VISIBLE,0,0); GetDlgItem(IDC_CAPPIC)->ModifyStyle(WS_VISIBLE,0,0); //the only for single play GetDlgItem(IDC_REMOTEFILRLIST)->ModifyStyle(WS_VISIBLE,0,0); GetDlgItem(IDC_STEP)->ModifyStyle(WS_VISIBLE,0,0); GetDlgItem(IDC_GOTOSTART)->ModifyStyle(WS_VISIBLE,0,0); GetDlgItem(IDC_DOWNLOAD)->ModifyStyle(WS_VISIBLE,0,0); GetDlgItem(IDC_DOWNPROGRESS)->ModifyStyle(WS_VISIBLE,0,0); } } BOOL CRemoteFilePlay::IsInWnd(CPoint point) { CRect rc; GetDlgItem(IDC_WND)->GetWindowRect(&rc); ScreenToClient(&rc); if(PtInRect(&rc,point)) return TRUE; else return FALSE; } void CRemoteFilePlay::F_ShowFullScreen() { F_EnableFlashWnd(FALSE); CRect rc,rcClient; ::GetWindowRect(m_hPareDlgWnd,m_rcPareDlg); ::GetWindowRect(m_hPareTabWnd,m_rcPareTab); ::ScreenToClient(m_hPareDlgWnd,(POINT*)(&m_rcPareTab)); ::ScreenToClient(m_hPareDlgWnd,(POINT*)(&m_rcPareTab)+1); ::GetWindowRect(m_hWnd,m_rcParent); ::ScreenToClient(m_hPareTabWnd,(POINT*)(&m_rcParent)); ::ScreenToClient(m_hPareTabWnd,(POINT*)(&m_rcParent)+1); ::SetWindowPos(m_hPareDlgWnd,NULL,m_rcScreen.left-SCREEN_EDGE,m_rcScreen.top-SCREEN_EDGE,m_rcScreen.Width()+2*SCREEN_EDGE,m_rcScreen.Height()+2*SCREEN_EDGE,SWP_SHOWWINDOW); ::GetClientRect(m_hPareDlgWnd,rc); ::SetWindowPos(m_hPareTabWnd,NULL,rc.left,rc.top,rc.Width(),rc.Height(),SWP_SHOWWINDOW); ::GetClientRect(m_hPareTabWnd,rc); ::SetWindowPos(m_hWnd,NULL,rc.left,rc.top,rc.Width(),rc.Height(),SWP_SHOWWINDOW); GetDlgItem(IDC_WND)->GetClientRect(rcClient); GetDlgItem(IDC_WND)->GetWindowRect(rc); int iEdge=(rc.Width()-rcClient.Width())/2; rc=m_rcScreen; rc.left-=iEdge; rc.right+=iEdge; rc.top-=iEdge; rc.bottom+=iEdge; this->ScreenToClient(rc); ::SetWindowPos(GetDlgItem(IDC_WND)->m_hWnd,NULL,rc.left,rc.top,rc.Width(),rc.Height(),SWP_SHOWWINDOW); Invalidate(FALSE); UpdateWindow(); } void CRemoteFilePlay::OnSelchangeComboserver() { // TODO: Add your control notification handler code here iSelServer = m_ServerCtrl.GetCurSel() - 1; if(iSelServer < 0) return; m_lServerID = serverinfo[iSelServer].m_lServerID; m_lServerType = serverinfo[iSelServer].m_wServerType; m_lStartChan = serverinfo[iSelServer].m_lStartChannel; int m_iChanNum = serverinfo[iSelServer].m_iServerChannelNumber; m_ChannelCtrl.ResetContent(); CString sTemp; for(int i=0; i= DVR_HC) //DVR { m_FileType.AddString("全部"); m_FileType.AddString("定时录像"); m_FileType.AddString("移动侦测"); m_FileType.AddString("报警触发"); m_FileType.AddString("报警|动测"); m_FileType.AddString("报警&动测"); m_FileType.AddString("命令触发"); m_FileType.AddString("手动触发"); } iFileType = 0; m_FileType.SetCurSel(iFileType); } void CRemoteFilePlay::OnCancel() { // TODO: Add extra cleanup here //CDialog::OnCancel(); } void CRemoteFilePlay::OnButtonsave() { // TODO: Add your control notification handler code here //zxy 2005-01-04 static char szFilter[]="All File(*.mp4)|*.*||"; char m_sFile[256] = "c:\\Savefile.mp4"; CString csFile; CFileDialog dlg(FALSE,"*.mp4","Savefile.mp4",OFN_OVERWRITEPROMPT|OFN_HIDEREADONLY, szFilter); if(dlg.DoModal()==IDOK) { csFile = dlg.GetPathName(); UpdateData(FALSE); sprintf(m_sFile, "%s", csFile); } if(NET_DVR_PlayBackSaveData(m_nPlayHandle, m_sFile)) { m_bSaveFile = TRUE; } else { MessageBox("文件保存失败!", "温馨提示", MB_ICONINFORMATION); } } void CRemoteFilePlay::OnButtonstopsave() { // TODO: Add your control notification handler code here if(m_bSaveFile) { NET_DVR_StopPlayBackSave(m_nPlayHandle); m_bSaveFile = FALSE; MessageBox("停止保存成功!", "温馨提示", MB_ICONINFORMATION); } } //zxy 2005-01-04 /* void CRemoteFilePlay::OnButplay() { // TODO: Add your control notification handler code here UpdateData(TRUE); int fileselpos = 0; CString csFileName; POSITION pos = m_Filelist.GetFirstSelectedItemPosition(); if(pos == NULL) { } fileselpos = m_Filelist.GetNextSelectedItem(pos); csFileName.Format("%s",m_Filelist.GetItemText(fileselpos,0)); if(csFileName.IsEmpty()) return; TRACE("远程回放文件:%s \n", csFileName); sprintf(filename,"%s",csFileName); // if(NET_DVR_PlayBackByNameLocDisplay(m_lServerID, filename)) { TRACE("远程控制本地回放成功!"); } } void CRemoteFilePlay::OnButstop() { // TODO: Add your control notification handler code here // if(NET_DVR_StopLocDisplayPlay(m_lServerID)) { TRACE("停止远程控制本地回放成功!"); } } */ void CRemoteFilePlay::OnGotostart() { // TODO: Add your control notification handler code here NET_DVR_PlayBackControl(m_nPlayHandle,NET_DVR_PLAYSETPOS, 0, NULL); }