📄 remotefileplay.cpp
字号:
// RemoteFilePlay.cpp : implementation file
//
#include "stdafx.h"
#include "newclient.h"
#include "RemoteFilePlay.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;
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("Search"); // by zxy 2005/05/10
RFile->m_bSearchDown = FALSE;
(RFile->GetDlgItem(IDC_STATICSTATE))->ShowWindow(SW_HIDE);
AfxMessageBox("Search completed!");
RFile->m_iFileNum = 0;
if(RFile->m_nPlayHandle == -1)
RFile->F_SetStopState();
break;
}
else
{
RFile->GetDlgItem(IDC_SEARCHLIST)->SetWindowText("Search");
RFile->m_bSearchDown = FALSE;
(RFile->GetDlgItem(IDC_STATICSTATE))->ShowWindow(SW_HIDE);
AfxMessageBox("Search exception!");
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)
ON_WM_LBUTTONDOWN()
//}}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("Please select 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,"File Name",LVCFMT_LEFT,120,-1);
m_Filelist.InsertColumn(1,"File Size",LVCFMT_LEFT,70,-1);
m_Filelist.InsertColumn(2,"Start Time",LVCFMT_LEFT,110,-1);
m_Filelist.InsertColumn(3,"End Time",LVCFMT_LEFT,110,-1);
GetDlgItem(IDC_WND)->GetWindowRect(m_rcWnd);
ScreenToClient(m_rcWnd);
m_hFileThread = NULL;
m_iFileNum = 0;
lFileHandle = -1;
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();
NET_DVR_RefreshPlay(m_nPlayHandle);
}
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) //fail
{
NET_DVR_StopGetFile(lFileHandle);
m_downProgress.ShowWindow(SW_HIDE);
RFile->GetDlgItem(IDC_DOWNLOAD)->SetWindowText("Download");
RFile->m_bDown=FALSE;
m_staticdownload.Format("Stop download file:%s", filenamedownload);
GetDlgItem(IDC_STATICSTATE2)->ShowWindow(SW_HIDE);
AfxMessageBox("Get download process failed!");
}
if(nPos == 100) //download completed
{
NET_DVR_StopGetFile(lFileHandle);
m_downProgress.ShowWindow(SW_HIDE);
RFile->GetDlgItem(IDC_DOWNLOAD)->SetWindowText("Download");
RFile->m_bDown=FALSE;
m_staticdownload.Format("Complete download file:%s", filenamedownload);
GetDlgItem(IDC_STATICSTATE2)->ShowWindow(SW_HIDE);
AfxMessageBox("Download completed!");
}
if(nPos > 100) //Download exception due to network or DVR busy
{
NET_DVR_StopGetFile(lFileHandle);
m_downProgress.ShowWindow(SW_HIDE);
RFile->GetDlgItem(IDC_DOWNLOAD)->SetWindowText("Download");
RFile->m_bDown=FALSE;
m_staticdownload.Format("Stop download file:%s", filenamedownload);
GetDlgItem(IDC_STATICSTATE2)->ShowWindow(SW_HIDE);
AfxMessageBox("Download exception!");
}
else
{
m_downProgress.SetPos(nPos);
}
}
break;
case RPSTATE_TIMER:
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);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -