123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525 |
- // MatPlayBack.cpp : implementation file
- //
- #include "stdafx.h"
- #include "newclient.h"
- #include "MatPlayBack.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CMatPlayBack dialog
- #define GETSTATE_TIMER WM_USER+1
- CMatPlayBack::CMatPlayBack(CWnd* pParent /*=NULL*/)
- : CDialog(CMatPlayBack::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CMatPlayBack)
- m_PlayBackName = _T("");
- m_PlayBackIP = _T("");
- m_PlayBackPass = _T("");
- m_PlayBackChan = 0;
- m_PlayBackPort = 0;
- m_PlayBackUser = _T("");
- m_PlayStatus = _T("");
- //}}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_hFastDisableIcon = AfxGetApp()->LoadIcon(IDI_FASTFORWARD_DISABLE);
- m_hSlowDisableIcon= AfxGetApp()->LoadIcon(IDI_FASTBACKWARD_DISABLE);
- 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_bSound = FALSE;
- m_bPlay = FALSE;
- m_bPause = FALSE;
- // memset(&m_struState, 0, sizeof(m_struState));
- }
- void CMatPlayBack::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CMatPlayBack)
- DDX_Control(pDX, IDC_COMBODECCHAN, m_DecChanCombo);
- DDX_Control(pDX, IDC_PROGRESS_SLIDER, m_ctlProgress);
- DDX_Control(pDX, IDC_DATETIMEPICKER4, m_StopTime);
- DDX_Control(pDX, IDC_DATETIMEPICKER3, m_StopDate);
- DDX_Control(pDX, IDC_DATETIMEPICKER2, m_StartTime);
- DDX_Control(pDX, IDC_DATETIMEPICKER1, m_StartDate);
- DDX_Text(pDX, IDC_EDITBACKNAME, m_PlayBackName);
- DDX_Text(pDX, IDC_EDITIP, m_PlayBackIP);
- DDX_Text(pDX, IDC_EDITPASSWD, m_PlayBackPass);
- DDX_Text(pDX, IDC_EDITCHAN, m_PlayBackChan);
- DDX_Text(pDX, IDC_EDITPORT, m_PlayBackPort);
- DDX_Text(pDX, IDC_EDITUSER, m_PlayBackUser);
- DDX_Text(pDX, IDC_PLAYSTATUS, m_PlayStatus);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CMatPlayBack, CDialog)
- //{{AFX_MSG_MAP(CMatPlayBack)
- ON_WM_TIMER()
- ON_BN_CLICKED(IDC_FAST, OnFast)
- ON_BN_CLICKED(IDC_PLAY_FILE, OnPlayFile)
- ON_BN_CLICKED(IDC_SLOW, OnSlow)
- ON_BN_CLICKED(IDC_SOUND, OnSound)
- ON_BN_CLICKED(IDC_STEP, OnStep)
- ON_BN_CLICKED(IDC_STOP, OnStop)
- ON_WM_HSCROLL()
- ON_BN_CLICKED(IDC_RADIONAME, OnRadioname)
- ON_BN_CLICKED(IDC_RADIOTIME, OnRadiotime)
- ON_BN_CLICKED(IDC_SETUP, OnSetup)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CMatPlayBack message handlers
- void CMatPlayBack::F_InitUI()
- {
- // 初始化按钮
- CButton *pButton;
-
- 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_SOUND);
- pButton->SetIcon(m_hSoundStopIcon);
- pButton->EnableWindow(FALSE);
- }
- void CMatPlayBack::F_SetStopState()
- {
- CButton *pButton;
-
- m_ctlProgress.SetPos(0);
- m_ctlProgress.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_SOUND);
- pButton->SetIcon(m_hSoundStopIcon);
- pButton->EnableWindow(FALSE);
- }
- void CMatPlayBack::F_SetPlayState()
- {
- m_ctlProgress.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_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);
- }
- void CMatPlayBack::F_SetPauseState()
- {
- CButton *pButton;
- pButton = (CButton *)GetDlgItem(IDC_PLAY_FILE);
- pButton->SetIcon(m_hPlayEnableIcon);
- pButton->EnableWindow(TRUE);
- }
- void CMatPlayBack::EnableControl(BOOL bEnable)
- {
- GetDlgItem(IDC_EDITBACKNAME)->EnableWindow(bEnable);
- GetDlgItem(IDC_DATETIMEPICKER1)->EnableWindow(!bEnable);
- GetDlgItem(IDC_DATETIMEPICKER2)->EnableWindow(!bEnable);
- GetDlgItem(IDC_DATETIMEPICKER3)->EnableWindow(!bEnable);
- GetDlgItem(IDC_DATETIMEPICKER4)->EnableWindow(!bEnable);
- }
- BOOL CMatPlayBack::OnInitDialog()
- {
- CDialog::OnInitDialog();
- // TODO: Add extra initialization here
- F_InitUI();
-
- CString tmp;
- for (int i=0; i<m_iChannelNumber; i++)
- {
- tmp.Format("通道 %d", i+m_lStartChan);
- m_DecChanCombo.AddString(tmp);
- }
- m_DecChanCombo.SetCurSel(0);
- m_ctlProgress.SetRange(0, 100);
- m_ctlProgress.SetPos(0);
- SYSTEMTIME st;
- GetSystemTime(&st);
- m_StartDate.SetTime(&st);
- m_StartTime.SetTime(&st);
- m_StopDate.SetTime(&st);
- m_StopTime.SetTime(&st);
- CheckRadioButton(IDC_RADIONAME, IDC_RADIOTIME, IDC_RADIONAME);
- EnableControl(TRUE);
- F_SetStopState();
- UpdateData(FALSE);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void CMatPlayBack::OnTimer(UINT nIDEvent)
- {
- CDialog::OnTimer(nIDEvent);
- // NET_DVR_MATRIX_DEC_CHAN_STATUS MDStatus;
- CString tmp;
- // TODO: Add your message handler code here and/or call default
- if (nIDEvent == GETSTATE_TIMER)
- {
- if (m_bPlay)
- {
- // //播放时先去获取解码通道状态
- // memset(&MDStatus, 0, sizeof(MDStatus));
- // if (!NET_DVR_MatrixGetDecChanStatus(m_lServerID, m_DecChanCombo.GetCurSel()+m_lStartChan, &MDStatus))
- // {
- // tmp.Format("Error: NET_DVR_MatrixGetDecChanStatus = %d", NET_DVR_GetLastError());
- // AfxMessageBox(tmp);
- // }
- // else
- // {
- // //如果设备尚未连接,则不去获取播放参数
- // if (!MDStatus.dwIsLinked)
- // {
- // AfxMessageBox("设备尚未连接,请稍候!");
- // }
- // else
- // {
- // UpdateData(TRUE);
- // memset(&m_struState, 0, sizeof(m_struState));
- // if (!NET_DVR_MatrixGetRemotePlayStatus(m_lServerID, m_DecChanCombo.GetCurSel()+m_lStartChan, &m_struState))
- // {
- // tmp.Format("Error: NET_DVR_MatrixGetRemotePlayStatus = %d", NET_DVR_GetLastError());
- // AfxMessageBox(tmp);
- // }
- // else
- // {
- // m_PlayStatus.Format("位置: %ld/%ld 时间: %ld/%ld 帧数: %ld/%ld 命令: 0x%x 参数: 0x%x",
- // m_struState.dwCurMediaFilePosition, m_struState.dwCurMediaFileLen, m_struState.dwCurPlayTime,
- // m_struState.dwCurMediaFileDuration, m_struState.dwCurPlayFrame, m_struState.dwCurMediaFIleFrames,
- // m_struState.dwCurPlayCmd, m_struState.dwCurPlayCmdParam);
- //
- // if (m_struState.dwCurMediaFileLen)
- // {
- // m_ctlProgress.SetPos((m_struState.dwCurMediaFilePosition*100)/m_struState.dwCurMediaFileLen);
- // }
- // TRACE("\n### m_struState.dwCurMediaFileDuration = %ld, m_struState.dwCurPlayTime = %ld\n",
- // m_struState.dwCurMediaFileDuration, m_struState.dwCurPlayTime);
- //
- // //该结束了
- // if (m_struState.dwCurMediaFileDuration == m_struState.dwCurPlayTime)
- // {
- // m_ctlProgress.SetPos(0);
- // m_bPlay = FALSE;
- // m_bPause = FALSE;
- // F_SetStopState();
- // MessageBox("回放结束!");
- // }
- // }
- // UpdateData(FALSE);
- // }
- // }
- }
- }
- }
- void CMatPlayBack::OnFast()
- {
- // TODO: Add your control notification handler code here
- // if (!NET_DVR_MatrixSetRemotePlayControl(m_lServerID, m_DecChanCombo.GetCurSel()+m_lStartChan, NET_DVR_PLAYFAST, 2, NULL))
- // {
- // CString tmp;
- // tmp.Format("Error: NET_DVR_MatrixSetRemotePlayControl = %d", NET_DVR_GetLastError());
- // AfxMessageBox(tmp);
- // }
- }
- void CMatPlayBack::OnPlayFile()
- {
- UpdateData(TRUE);
- // TODO: Add your control notification handler code here
- // if (m_bPause && m_bPlay)
- // {
- // if (!NET_DVR_MatrixSetRemotePlayControl(m_lServerID, m_DecChanCombo.GetCurSel()+m_lStartChan, NET_DVR_PLAYRESTART, 0, NULL))
- // {
- // CString tmp;
- // tmp.Format("Error: NET_DVR_MatrixSetRemotePlayControl = %d", NET_DVR_GetLastError());
- // AfxMessageBox(tmp);
- // return;
- // }
- // m_bPause = FALSE;
- // F_SetPlayState();
- // }
- // else if (m_bPlay)
- // {
- // if (!NET_DVR_MatrixSetRemotePlayControl(m_lServerID, m_DecChanCombo.GetCurSel()+m_lStartChan, NET_DVR_PLAYPAUSE, 0, NULL))
- // {
- // CString tmp;
- // tmp.Format("Error: NET_DVR_MatrixSetRemotePlayControl = %d", NET_DVR_GetLastError());
- // AfxMessageBox(tmp);
- // return;
- // }
- // m_bPause = TRUE;
- // F_SetPauseState();
- // }
- // else
- // {
- // if (!NET_DVR_MatrixSetRemotePlayControl(m_lServerID, m_DecChanCombo.GetCurSel()+m_lStartChan, NET_DVR_PLAYSTART, 0, NULL))
- // {
- // CString tmp;
- // tmp.Format("Error: NET_DVR_MatrixSetRemotePlayControl = %d", NET_DVR_GetLastError());
- // AfxMessageBox(tmp);
- // return;
- // }
- // m_bPlay = TRUE;
- // m_bPause = FALSE;
- // F_SetPlayState();
- // SetTimer(GETSTATE_TIMER, 1000, NULL);
- // }
- //
- // UpdateData(FALSE);
- }
- void CMatPlayBack::OnSlow()
- {
- // TODO: Add your control notification handler code here
- // if (!NET_DVR_MatrixSetRemotePlayControl(m_lServerID, m_DecChanCombo.GetCurSel()+m_lStartChan, NET_DVR_PLAYSLOW, 2, NULL))
- // {
- // CString tmp;
- // tmp.Format("Error: NET_DVR_MatrixSetRemotePlayControl = %d", NET_DVR_GetLastError());
- // AfxMessageBox(tmp);
- // }
- }
- void CMatPlayBack::OnSound()
- {
- // TODO: Add your control notification handler code here
- // if (m_bSound)
- // {
- // if (!NET_DVR_MatrixSetRemotePlayControl(m_lServerID, m_DecChanCombo.GetCurSel()+m_lStartChan, NET_DVR_PLAYSTOPAUDIO, 0, NULL))
- // {
- // CString tmp;
- // tmp.Format("Error: NET_DVR_MatrixSetRemotePlayControl = %d", NET_DVR_GetLastError());
- // AfxMessageBox(tmp);
- // return;
- // }
- // m_bSound = FALSE;
- // }
- // else
- // {
- // if (!NET_DVR_MatrixSetRemotePlayControl(m_lServerID, m_DecChanCombo.GetCurSel()+m_lStartChan, NET_DVR_PLAYSTARTAUDIO, 0, NULL))
- // {
- // CString tmp;
- // tmp.Format("Error: NET_DVR_MatrixSetRemotePlayControl = %d", NET_DVR_GetLastError());
- // AfxMessageBox(tmp);
- // return;
- // }
- // m_bSound = TRUE;
- // }
- }
- //在这里做正常播放用
- void CMatPlayBack::OnStep()
- {
- // TODO: Add your control notification handler code here
- // if (!NET_DVR_MatrixSetRemotePlayControl(m_lServerID, m_DecChanCombo.GetCurSel()+m_lStartChan, NET_DVR_PLAYNORMAL, 0, NULL))
- // {
- // CString tmp;
- // tmp.Format("Error: NET_DVR_MatrixSetRemotePlayControl = %d", NET_DVR_GetLastError());
- // AfxMessageBox(tmp);
- // }
- }
- void CMatPlayBack::OnStop()
- {
- UpdateData(TRUE);
- // TODO: Add your control notification handler code here
- // if (!NET_DVR_MatrixSetRemotePlayControl(m_lServerID, m_DecChanCombo.GetCurSel()+m_lStartChan, NET_DVR_PLAYSTOP, 0, NULL))
- // {
- // CString tmp;
- // tmp.Format("Error: NET_DVR_MatrixSetRemotePlayControl = %d", NET_DVR_GetLastError());
- // AfxMessageBox(tmp);
- // return;
- // }
- // m_PlayStatus.Empty();
- // m_bPlay = FALSE;
- // m_bPause = FALSE;
- // F_SetStopState();
- // KillTimer(GETSTATE_TIMER);
- //
- // UpdateData(FALSE);
- }
- void CMatPlayBack::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
- {
- CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
- // TODO: Add your message handler code here and/or call default
- if (GetDlgItem(IDC_PROGRESS_SLIDER) == pScrollBar)
- {
- // if (m_bPlay)
- // {
- // int pos = m_ctlProgress.GetPos();
- // DWORD retVal = 0;
- // if (!NET_DVR_MatrixSetRemotePlayControl(m_lServerID, m_DecChanCombo.GetCurSel()+m_lStartChan, NET_DVR_PLAYSETPOS, pos, &retVal))
- // {
- // CString tmp;
- // tmp.Format("Error: NET_DVR_MatrixSetRemotePlayControl = %d", NET_DVR_GetLastError());
- // AfxMessageBox(tmp);
- // }
- // }
- }
- }
- void CMatPlayBack::OnRadioname()
- {
- // TODO: Add your control notification handler code here
- UpdateData(TRUE);
- CheckRadioButton(IDC_RADIONAME, IDC_RADIOTIME, IDC_RADIONAME);
- EnableControl(TRUE);
- UpdateData(FALSE);
- }
- void CMatPlayBack::OnRadiotime()
- {
- // TODO: Add your control notification handler code here
- UpdateData(TRUE);
-
- CheckRadioButton(IDC_RADIONAME, IDC_RADIOTIME, IDC_RADIOTIME);
- EnableControl(FALSE);
-
- UpdateData(FALSE);
- }
- void CMatPlayBack::OnSetup()
- {
- // TODO: Add your control notification handler code here
- UpdateData(TRUE);
- // NET_DVR_MATRIX_DEC_REMOTE_PLAY struPlay;
- // memset(&struPlay, 0, sizeof(struPlay));
- // struPlay.dwSize = sizeof(struPlay);
- //
- // sprintf(struPlay.sDVRIP, "%s", m_PlayBackIP);
- // struPlay.wDVRPort = m_PlayBackPort;
- // struPlay.byChannel = m_PlayBackChan;
- // sprintf((char *)struPlay.sUserName, "%s", m_PlayBackUser);
- // sprintf((char *)struPlay.sPassword, "%s", m_PlayBackPass);
- //
- // if (GetCheckedRadioButton(IDC_RADIONAME, IDC_RADIOTIME) == IDC_RADIOTIME)
- // {
- // SYSTEMTIME st;
- // m_StartDate.GetTime(&st);
- // struPlay.StartTime.dwYear = st.wYear;
- // struPlay.StartTime.dwMonth = st.wMonth;
- // struPlay.StartTime.dwDay = st.wDay;
- // m_StartTime.GetTime(&st);
- // struPlay.StartTime.dwHour = st.wHour;
- // struPlay.StartTime.dwMinute = st.wMinute;
- // struPlay.StartTime.dwSecond = st.wSecond;
- //
- // m_StopDate.GetTime(&st);
- // struPlay.StopTime.dwYear = st.wYear;
- // struPlay.StopTime.dwMonth = st.wMonth;
- // struPlay.StopTime.dwDay = st.wDay;
- // m_StopTime.GetTime(&st);
- // struPlay.StopTime.dwHour = st.wHour;
- // struPlay.StopTime.dwMinute = st.wMinute;
- // struPlay.StopTime.dwSecond = st.wSecond;
- //
- // struPlay.dwPlayMode = 1;
- // }
- // else
- // {
- // sprintf(struPlay.sFileName, "%s", m_PlayBackName);
- // struPlay.dwPlayMode = 0;
- // }
- //
- // if (!NET_DVR_MatrixSetRemotePlay(m_lServerID, m_DecChanCombo.GetCurSel()+m_lStartChan, &struPlay))
- // {
- // CString tmp;
- // tmp.Format("Error: NET_DVR_MatrixSetRemotePlay = %d", NET_DVR_GetLastError());
- // AfxMessageBox(tmp);
- // return;
- // }
- // OnPlayFile();
- // MessageBox("设置成功!");
- }
|