www.pudn.com > DVR-MPEG4编码播放器 .rar > Search.cpp


// Search.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "Mp4Player.h" 
#include "Search.h" 
#include "Decode.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CSearch dialog 
 
 
CSearch::CSearch(CWnd* pParent /*=NULL*/) 
	: CDialog(CSearch::IDD, pParent) 
{ 
	//{{AFX_DATA_INIT(CSearch) 
	m_Local = TRUE; 
	m_Remote = FALSE; 
	//}}AFX_DATA_INIT 
} 
 
 
void CSearch::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CSearch) 
	DDX_Control(pDX, IDC_SearchDATE, m_SearDate); 
	DDX_Control(pDX, IDC_LIST1, m_ListBox); 
	DDX_Check(pDX, IDC_LOCAL, m_Local); 
	DDX_Check(pDX, IDC_REMOTE, m_Remote); 
	//}}AFX_DATA_MAP 
} 
 
 
BEGIN_MESSAGE_MAP(CSearch, CDialog) 
	//{{AFX_MSG_MAP(CSearch) 
	ON_BN_CLICKED(IDC_LISTTODAY, OnListtoday) 
	ON_BN_CLICKED(IDC_SEARCH, OnSearch) 
	ON_BN_CLICKED(IDC_PLAY, OnPlay) 
	ON_LBN_DBLCLK(IDC_LIST1, OnDblclkList1) 
	ON_BN_CLICKED(IDC_BUTTON10, OnDeleteFile) 
	ON_BN_CLICKED(IDC_LOCAL, OnLocal) 
	ON_BN_CLICKED(IDC_REMOTE, OnRemote) 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CSearch message handlers 
 
void CSearch::OnListtoday()  
{ 
	// TODO: Add your control notification handler code here 
	char cmd[1]; 
 
	TRANSDATE	   TransDate; 
	TRANS_SEARCH2  Trans_MarkedFile; 
 
	m_ListBox.ResetContent(); 
	 
	SYSTEMTIME systime; 
	::GetLocalTime(&systime); 
	 
	::memset(&TransDate,0,sizeof(TRANSDATE)); 
	TransDate.Camera=0; 
	TransDate.StartDate.m_day=systime.wDay; 
	TransDate.StartDate.m_hour=0; 
	TransDate.StartDate.m_min=0; 
	TransDate.StartDate.m_month=systime.wMonth; 
	TransDate.StartDate.m_year=systime.wYear; 
     
	TransDate.EndDate.m_day=systime.wDay; 
	TransDate.EndDate.m_hour=23; 
	TransDate.EndDate.m_min=59; 
	TransDate.EndDate.m_month=systime.wMonth; 
	TransDate.EndDate.m_year=systime.wYear; 
	TransDate.SearchTypeorSet=4; 
		 
	::memset(&Trans_MarkedFile,0,sizeof(TRANS_SEARCH2)); 
	 
	InitVRTLink(ConnectIP,ConnectPort); 
	cmd[0]=VRTSearch; 
	SendVRTData(cmd,1); 
	Sleep(1); 
	SendVRTData((char *)&TransDate,sizeof(TRANSDATE)); 
	RecvVRTData((char *)&Trans_MarkedFile,sizeof(TRANS_SEARCH2)); 
	CloseVRTLink(); 
 
	if(Trans_MarkedFile.Total==0) 
	{ 
		m_ListBox.AddString(" 没有视频!"); 
		return; 
	} 
	char buf[200]; 
    char sz_marked[200]; 
	int m_year; 
	int m_month; 
	int m_day; 
	int m_hour; 
	int m_min; 
	int m_sec; 
	int m_Duration; 
	 
	int m_type; 
    int m_Camera; 
    m_ListBox.ResetContent(); 
	for(int i=0;iGetTime(timeTime); 
 
     
	TRANSDATE TransDate; 
	TRANS_SEARCH2 Trans_MarkedFile; 
	 
	SYSTEMTIME systime; 
	::GetLocalTime(&systime); 
     
	 
	::memset(&TransDate,0,sizeof(TRANSDATE)); 
	TransDate.Camera=0; 
	TransDate.StartDate.m_day=timeTime.GetDay(); 
	TransDate.StartDate.m_hour=atoi((const char*)m_Houre); 
	TransDate.StartDate.m_min=atoi((const char*)m_Min); 
    TransDate.StartDate.m_sec=atoi((const char*)m_Sec); 
	TransDate.StartDate.m_month=timeTime.GetMonth(); 
	TransDate.StartDate.m_year=timeTime.GetYear(); 
   
	TransDate.EndDate.m_day=timeTime.GetDay(); 
	TransDate.EndDate.m_hour=23; 
	TransDate.EndDate.m_min=59; 
    TransDate.EndDate.m_sec=59; 
	TransDate.EndDate.m_month=timeTime.GetMonth(); 
	TransDate.EndDate.m_year=timeTime.GetYear(); 
	TransDate.SearchTypeorSet=4; 
 
    m_ListBox.ResetContent(); 
	::memset(&Trans_MarkedFile,0,sizeof(TRANS_SEARCH2)); 
   
	InitVRTLink(ConnectIP,ConnectPort); 
 
	cmd[0]=VRTSearch; 
	SendVRTData(cmd,1); 
	Sleep(1); 
	SendVRTData((char *)&TransDate,sizeof(TRANSDATE)); 
	RecvVRTData((char *)&Trans_MarkedFile,sizeof(TRANS_SEARCH2)); 
	CloseVRTLink(); 
 
	if(Trans_MarkedFile.Total==0) 
	{ 
		m_ListBox.AddString(" 没有视频!"); 
		return; 
	} 
	char buf[200]; 
    char sz_marked[200]; 
	int m_year; 
	int m_month; 
	int m_day; 
	int m_hour; 
	int m_min; 
	int m_sec; 
	int m_Duration; 
	 
	int m_type; 
    int m_Camera; 
    m_ListBox.ResetContent(); 
	for(int i=0;iGetConnectIPAddress(ConnectIP,&ConnectPort); 
	 
	return TRUE;  // return TRUE unless you set the focus to a control 
	              // EXCEPTION: OCX Property Pages should return FALSE 
} 
 
void CSearch::OnPlay()  
{ 
 
	CString getstr; 
	char cmd[1]; 
	TRANS_FILE m_PlaySelectFileName; 
	int rtn = 0; 
    ::memset(&m_PlaySelectFileName,0,sizeof(m_PlaySelectFileName)); 
	if(m_ListBox.GetSelCount()<=0) 
	{ 
		::AfxMessageBox("Error!"); 
		return; 
	} 
    m_PlaySelectFileName.FileCounter=m_ListBox.GetSelCount(); 
 
	int delindex=0; 
	int arry_del[256]; 
    for(int i=0;i< m_ListBox.GetCount();i++) 
	{ 
		if(m_ListBox.GetSel(i)>0) 
		{ 
			strcpy(m_PlaySelectFileName.Buf_File[delindex].FileName,Trans_MarkedFile2.T_Search[i].T_File.FileName); 
			arry_del[delindex]=i; 
			delindex++; 
		} 
	} 
 
	if(m_Remote) 
	{ 
 
		InitVRTLink(ConnectIP,ConnectPort); 
		cmd[0]=VRTPlay; 
		SendVRTData(cmd,1); 
		Sleep(1); 
		SendVRTData((char *)&m_PlaySelectFileName,sizeof(TRANS_FILE)); 
		CloseVRTLink(); 
	} 
	if(m_Local) 
	{ 
		RECT rc; 
		HWND hWnd =::GetDlgItem(::AfxGetMainWnd()->m_hWnd,IDC_WIN); 
		::GetClientRect(hWnd,&rc);  
 
 
		CMp4PlayerApp *play = (CMp4PlayerApp *)::AfxGetApp(); 
		SearchPlay = play->GetPlayStatus();  
	 
		if(SearchPlay == true) 
		{ 
			StopPlay(); 
			SearchPlay = false; 
			play->SetPlayStatus(SearchPlay); 
 
		} 
 
		if(!SearchPlay)	 
			InitPlay(); 
	 
		IfDeInterlace(TRUE); 
		memset(&Trans_File3,0,sizeof(TRANS_FILE3)); 
	 
		Trans_File3.FileCounter =m_PlaySelectFileName.FileCounter; 
		for(int n=0;nSetPlayStatus(SearchPlay); 
	} 
} 
 
void CSearch::OnDblclkList1()  
{ 
 
	CString getstr; 
	TRANS_FILE m_PlaySelectFileName; 
	char  cmd[1]; 
    // HWND hWnd; 
    // RECT rc ; 
	int Play_index; 
	int count; 
	int rtn = 0; 
    bool status = 0;  
			 
	count=Trans_MarkedFile2.Total; 
	Play_index=m_ListBox.GetCurSel(); 
	if(Play_index<0) 
	{ 
		m_ListBox.ResetContent(); 
		m_ListBox.AddString("Error!"); 
		return; 
	} 
	::memset(&m_PlaySelectFileName,0,sizeof(TRANS_FILE)); 
 
	m_PlaySelectFileName.FileCounter=1; 
	strcpy(m_PlaySelectFileName.Buf_File[0].FileName,Trans_MarkedFile2.T_Search[Play_index].T_File.FileName); 
     
	//InitVRTLink("192.168.0.20",2003); 
	if(m_Remote) 
	{ 
		InitVRTLink(ConnectIP,ConnectPort); 
		cmd[0]=VRTPlay; 
		SendVRTData(cmd,1); 
		Sleep(1); 
		SendVRTData((char *)&m_PlaySelectFileName,sizeof(TRANS_FILE)); 
		CloseVRTLink(); 
	} 
	if(m_Local) 
	{ 
		RECT rc; 
		HWND hWnd =::GetDlgItem(::AfxGetMainWnd()->m_hWnd,IDC_WIN); 
		::GetClientRect(hWnd,&rc);  
	 
		CMp4PlayerApp *play = (CMp4PlayerApp *)::AfxGetApp(); 
		SearchPlay = play->GetPlayStatus();  
	 
		if(SearchPlay == true) 
		{ 
			StopPlay(); 
			SearchPlay = false; 
			play->SetPlayStatus(SearchPlay); 
 
		} 
 
		if(!SearchPlay)	 
			InitPlay(); 
 
		IfDeInterlace(TRUE); 
		memset(&Trans_File3,0,sizeof(TRANS_FILE3)); 
	 
		Trans_File3.FileCounter =m_PlaySelectFileName.FileCounter; 
		for(int n=0;nSetPlayStatus(SearchPlay); 
	} 
} 
 
void CSearch::OnDeleteFile()  
{ 
	// TODO: Add your control notification handler code here 
	CString getstr; 
	char cmd[1]; 
	TRANS_FILE m_PlaySelectFileName; 
	 
	memset(&m_PlaySelectFileName,0,sizeof(m_PlaySelectFileName)); 
    m_PlaySelectFileName.FileCounter=m_ListBox.GetSelCount(); 
	 
	if(m_PlaySelectFileName.FileCounter<=0) 
	{ 
		return; 
	} 
	int delindex=0; 
	int arry_del[256]; 
    for(int i=0;i< m_ListBox.GetCount();i++) 
	{ 
		if(m_ListBox.GetSel(i)>0) 
		{ 
		 
			strcpy(m_PlaySelectFileName.Buf_File[delindex].FileName,Trans_MarkedFile2.T_Search[i].T_File.FileName); 
			arry_del[delindex]=i; 
			delindex++; 
			 
		} 
	} 
    for(i=0;i3) 
			{ 
				Path[n] = '\\'; 
				n++; 
			} 
		} 
		if((m>3) && (p[i] !='/')) 
		{ 
			Path[n] = p[i];   
			n++; 
		} 
		i++; 
	} 
	 
	sprintf(buf,"\\\\%s\\KaiFaTech",ConnectIP); 
	//strcpy(buf,"\\\\192.168.0.20\\mpg");KaiFaTech 
	strcat(buf,Path); 
	strcpy(DestPath,buf); 
} 
 
void CSearch::OnLocal()  
{ 
	m_Local = !m_Local; 
} 
 
void CSearch::OnRemote()  
{ 
	m_Remote = !m_Remote; 
}