www.pudn.com > 2007112823521925.rar > Devicemgr.cpp


#include "stdafx.h" 
#include "Gtmpeg.h" 
#include "lib\ViewCtl.h" 
#include "GtMpegWnd.h" 
// Added by CSC 
#include "lib\RecCtl.h" 
int            g_RGBColorBits; 
/////////////////////////////////////// 
// 
/////////////////////////////////////// 
CDeviceObject::CDeviceObject(CGtMpegWnd*  pParentWnd,DWORD dwSlotNumber) 
{ 
	m_bRePlay=FALSE; 
	m_bRecord=FALSE; 
	m_dwCurMode=0; 
	m_pParentWnd=pParentWnd; 
	m_dwSlotNumber=dwSlotNumber; 
	m_sSection.Format("Video_%d",dwSlotNumber+1); 
	m_arPlayList.SetSize(0); 
	m_arFileName.SetSize(0); 
	GetINIParameters(); 
	InitVideoDecoder(); 
	m_sRecordRootPath=""; 
	m_bCheck=FALSE; 
	CWnd* pDispWnd=m_pParentWnd->GetDlgItem(IDC_VIDEO_POS+m_dwSlotNumber); 
	m_pVideoPlay=new CVideo(pDispWnd); 
	m_nStartTicks=-1; 
	m_nStartTicks1=-1; 
	m_nStartTicks2=-1; 
	int nVideoWay=AfxGetApp()->GetProfileInt("系统参数","采集方式",0); 
	m_hcg200 = BeginCG200(m_dwSlotNumber+1); 
	CG200SetDispMode(m_hcg200,nVideoWay); 
} 
/////////////////////////////////////////// 
// 
/////////////////////////////////////////// 
CDeviceObject::~CDeviceObject() 
{ 
  RECCTL_EnableSoundCard(FALSE); 
  m_bRePlay=FALSE; 
  m_bRecord=FALSE; 
  m_dwCurMode=0; 
  EndCG200(m_hcg200); 
  if(m_arPlayList.GetSize()!=0) 
  { 
     for(int i=0;iIsPlaying()) 
		{ 
			  if(!PlaySection()) 
			  { 
				  m_bRePlay=FALSE; 
				  m_pVideoPlay->Close(); 
				  m_pParentWnd->m_nPlays--; 
				  StartDisplay(); 
				  return; 
			  } 
		} 
		if ((nCurTicks - m_nStartTicks1) >=60000) 
		{ 
		  sTxt.Format("回放-%d分 ",(nCurTicks - m_nStartTicks2)/60000); 
		  if(m_bRecord) 
		  { 
		     CString sTmp=""; 
		     m_pParentWnd->GetDlgItem(IDC_CHANNEL_STATES0+m_dwSlotNumber)->GetWindowText(sTmp); 
		     int nFind=sTmp.Find(" ",0); 
		     if(nFind!=-1) 
			 { 
		        sTmp=sTmp.Right(sTmp.GetLength()-nFind+1); 
				sTmp.TrimLeft(); 
			 } 
			 sTxt+=sTmp; 
		  } 
		  m_pParentWnd->GetDlgItem(IDC_CHANNEL_STATES0+m_dwSlotNumber)->SetWindowText(sTxt); 
		  m_nStartTicks1 = nCurTicks; 
		} 
   } 
}  
/////////////////////////////////////////// 
// 
/////////////////////////////////////////// 
void CDeviceObject::RecordSubsection() 
{ 
    int nCurTicks=0; 
	CString sTxt=""; 
	if(m_bRecord) 
	{ 
		nCurTicks = GetTickCount(); 
		if ((nCurTicks - m_nStartTicks) >=300000)//1分=60000毫秒 
		{ 
		  RECCTL_StopCapture(m_dwSlotNumber); 
		  if(m_bSound) 
		  { 
		  } 
		  StartLVE(); 
		  m_nStartTicks = nCurTicks; 
		} 
		if ((nCurTicks - m_nStartTicks1) >=60000) 
		{ 
		  sTxt.Format("录像-%d分",(nCurTicks - m_nStartTicks2)/60000); 
		  if(m_bRePlay) 
		  { 
		     CString sTmp; 
		     m_pParentWnd->GetDlgItem(IDC_CHANNEL_STATES0+m_dwSlotNumber)->GetWindowText(sTmp); 
			 sTxt=sTmp+sTxt; 
		  } 
		  m_pParentWnd->GetDlgItem(IDC_CHANNEL_STATES0+m_dwSlotNumber)->SetWindowText(sTxt); 
		  m_nStartTicks1=nCurTicks; 
		} 
	} 
} 
/////////////////////////////////////// 
// 
/////////////////////////////////////// 
void CDeviceObject::PauseDisplay() 
{ 
    if(m_dwCurMode==0) 
	{ 
	   m_dwCurMode=2; 
	   CG200Capture(m_hcg200, FALSE); 
       if(!m_bRePlay&&!m_bRecord) 
		   m_pParentWnd->GetDlgItem(IDC_CHANNEL_STATES0+m_dwSlotNumber)->SetWindowText("暂停"); 
	} 
} 
/////////////////////////////////////// 
// 
/////////////////////////////////////// 
void CDeviceObject::RestoryDisplay(int nFrame) 
{ 
    if(m_dwCurMode==2) 
	{ 
	   if(nFrame!=-1) 
	   { 
 	     CWnd *hOutputArea; 
	     CRect rect; 
		 hOutputArea = AfxGetMainWnd()->GetDlgItem(IDC_VIDEO_POS+m_dwSlotNumber); 
	     hOutputArea->GetWindowRect(rect); 
		 int nVideoWay=AfxGetApp()->GetProfileInt("系统参数","采集方式",0);  
		 if(nVideoWay==0) 
            CG200SetDispWindow(m_hcg200, (int)rect.left, (int)rect.top, rect.Width(), rect.Height()); 
	     else 
 	        CG200SetDispWindow(m_hcg200, (int)rect.left, (int)rect.top, rect.Width(), 2*rect.Height()); 
         CG200SetDispMode(m_hcg200,nVideoWay); 
	   } 
	   CG200Capture(m_hcg200, TRUE); 
	   m_dwCurMode=0; 
       if(!m_bRePlay&&!m_bRecord) 
		   m_pParentWnd->GetDlgItem(IDC_CHANNEL_STATES0+m_dwSlotNumber)->SetWindowText("监视"); 
	} 
} 
/////////////////////////////////////// 
// 
/////////////////////////////////////// 
void CDeviceObject::ChangeDisplayColor() 
{ 
    m_ConfigInfo.iVideoBri = AfxGetApp()->GetProfileInt(m_sSection,"亮度",12);  
	m_ConfigInfo.iVideoCta = AfxGetApp()->GetProfileInt(m_sSection,"对比度",75);  
	m_ConfigInfo.iVideoSta = AfxGetApp()->GetProfileInt(m_sSection,"饱和度",64);  
	m_ConfigInfo.iVideoHue = AfxGetApp()->GetProfileInt(m_sSection,"色调",0);  
	CG200SetADParam(m_hcg200,AD_BRIGHTNESS,m_ConfigInfo.iVideoBri+128); 
	CG200SetADParam(m_hcg200,AD_CONTRAST,m_ConfigInfo.iVideoCta); 
	CG200SetADParam(m_hcg200,AD_HUE,m_ConfigInfo.iVideoHue); 
	CG200SetADParam(m_hcg200,AD_SATURATION,m_ConfigInfo.iVideoSta); 
	RECCTL_SetVideoDecoder(m_dwSlotNumber,RECTL_BRIGHTNESS,m_ConfigInfo.iVideoBri+128); 
	RECCTL_SetVideoDecoder(m_dwSlotNumber,RECTL_CONTRAST,m_ConfigInfo.iVideoCta); 
	RECCTL_SetVideoDecoder(m_dwSlotNumber,RECTL_HUE,m_ConfigInfo.iVideoHue); 
	RECCTL_SetVideoDecoder(m_dwSlotNumber,RECTL_SATURATION,m_ConfigInfo.iVideoSta); 
} 
/////////////////////////////////////// 
// 
/////////////////////////////////////// 
void CDeviceObject::Snap() 
{ 
   CG200Snap(m_hcg200); 
} 
/////////////////////////////////////// 
// 
/////////////////////////////////////// 
void CDeviceObject::StartDisplay() 
{ 
	CWnd *hOutputArea; 
	CRect rect; 
	if(m_bRePlay) 
	   StopPlayback(); 
	m_dwCurMode=0; 
	int nVideoWay=AfxGetApp()->GetProfileInt("系统参数","采集方式",0); 
	hOutputArea = AfxGetMainWnd()->GetDlgItem(IDC_VIDEO_POS+m_dwSlotNumber); 
	hOutputArea->GetWindowRect(rect); 
	CG200SetColorSpace(m_hcg200,g_RGBColorBits); 
	ChangeDisplayColor(); 
	if(nVideoWay==0) 
       CG200SetDispWindow(m_hcg200, (int)rect.left, (int)rect.top, rect.Width(), rect.Height()); 
	else 
 	   CG200SetDispWindow(m_hcg200, (int)rect.left, (int)rect.top, rect.Width(), 2*rect.Height()); 
	CG200Capture(m_hcg200, TRUE); 
    if(!m_bRePlay&&!m_bRecord) 
	    m_pParentWnd->GetDlgItem(IDC_CHANNEL_STATES0+m_dwSlotNumber)->SetWindowText("监视"); 
	return; 
} 
/////////////////////////////////////// 
// 
/////////////////////////////////////// 
BOOL CDeviceObject::StartRecord() 
{ 
	if(m_bCheck) 
		return FALSE; 
	if(!theApp.m_bRecord) 
		return TRUE; 
	if(!StartLVE()) 
		return FALSE; 
	m_bRecord =TRUE; 
	m_nStartTicks=GetTickCount(); 
	m_nStartTicks1=m_nStartTicks; 
	m_nStartTicks2=m_nStartTicks; 
	CString sTxt="录像-0分"; 
	if(m_bRePlay) 
	{ 
	   CString sTmp; 
	   m_pParentWnd->GetDlgItem(IDC_CHANNEL_STATES0+m_dwSlotNumber)->GetWindowText(sTmp); 
	   sTxt=sTmp+sTxt; 
	} 
	m_pParentWnd->GetDlgItem(IDC_CHANNEL_STATES0+m_dwSlotNumber)->SetWindowText(sTxt); 
    return TRUE; 
} 
/////////////////////////////////////// 
// 
/////////////////////////////////////// 
BOOL CDeviceObject::StartPlayback() 
{ 
	m_pParentWnd->GetDlgItem(IDC_VIDEO_POS+m_dwSlotNumber)->Invalidate(); 
	if(!Playback()) 
		return FALSE; 
	m_nStartTicks=GetTickCount(); 
	m_nStartTicks1=m_nStartTicks; 
	m_nStartTicks2=m_nStartTicks; 
	CString sTxt="回放-0分 "; 
	if(m_bRecord) 
	{ 
	    CString sTmp=""; 
	    m_pParentWnd->GetDlgItem(IDC_CHANNEL_STATES0+m_dwSlotNumber)->GetWindowText(sTmp); 
	    int nFind=sTmp.Find(" ",0); 
	    if(nFind!=-1) 
		{ 
		  sTmp=sTmp.Right(sTmp.GetLength()-nFind-1); 
		} 
		sTmp.TrimLeft(); 
		sTxt+=sTmp; 
	} 
	m_pParentWnd->GetDlgItem(IDC_CHANNEL_STATES0+m_dwSlotNumber)->SetWindowText(sTxt); 
	return TRUE; 
} 
///////////////////////////////////////// 
// 
///////////////////////////////////////// 
void CDeviceObject::StopDisplay() 
{ 
  if(m_dwCurMode==0||m_dwCurMode==2) 
  { 
	  if(m_dwCurMode==0) 
		  CG200Capture(m_hcg200, FALSE); 
	  m_dwCurMode=1; 
	  if(!m_bRePlay&&!m_bRecord) 
	      m_pParentWnd->GetDlgItem(IDC_CHANNEL_STATES0+m_dwSlotNumber)->SetWindowText("停止"); 
  } 
  return; 
} 
//////////////////////////////////////////////////////////// 
// 
//////////////////////////////////////////////////////////// 
BOOL CDeviceObject::StopRecord() 
{ 
	if(!theApp.m_bRecord) 
		return TRUE; 
	RECCTL_StopCapture( m_dwSlotNumber ); 
	VIEWCTL_CloseDisplay(m_dwSlotNumber, TRUE); 
	m_bRecord=FALSE; 
	m_nStartTicks=-1; 
	m_nStartTicks1=-1; 
	m_nStartTicks2=-1; 
	if(!m_bRecord&&!m_bRePlay) 
	{ 
	    if(m_dwCurMode==0) 
		  m_pParentWnd->GetDlgItem(IDC_CHANNEL_STATES0+m_dwSlotNumber)->SetWindowText("监视"); 
	} 
	return TRUE; 
} 
//////////////////////////////////////////////////////////// 
// 
//////////////////////////////////////////////////////////// 
BOOL  CDeviceObject::StopCheck() 
{ 
	if(!m_bCheck) 
		return TRUE; 
	RECCTL_StopCapture( m_dwSlotNumber ); 
	VIEWCTL_CloseDisplay(m_dwSlotNumber, TRUE); 
	m_bCheck=FALSE; 
	return TRUE; 
} 
//////////////////////////////////////////////////////////// 
// 
//////////////////////////////////////////////////////////// 
BOOL  CDeviceObject::StopPlayback() 
{ 
	m_bRePlay=FALSE; 
	Sleep(1000); 
    m_pVideoPlay->Close(); 
	m_arFileName.SetSize(0); 
	if(m_arPlayList.GetSize()!=0) 
	{ 
       for(int i=0;iGetDlgItem(IDC_CHANNEL_STATES0+m_dwSlotNumber)->GetWindowText(sTmp); 
	    int nFind=sTmp.Find(" ",0); 
	    if(nFind!=-1) 
		{ 
		  sTmp=sTmp.Right(sTmp.GetLength()-nFind-1); 
		} 
	    m_pParentWnd->GetDlgItem(IDC_CHANNEL_STATES0+m_dwSlotNumber)->SetWindowText(sTmp); 
	} 
	return TRUE; 
} 
//////////////////////////////////////////////////////////// 
// 
//////////////////////////////////////////////////////////// 
BOOL CDeviceObject::Close() 
{ 
	if(m_bRePlay) 
        StopPlayback(); 
	if(m_bRecord) 
		StopRecord(); 
    if(m_dwCurMode==0) 
        StopDisplay(); 
	return TRUE; 
} 
/////////////////////////////////////////////////////////////////////////////// 
// 
//////////////////////////////////////////////////////////////////////////////// 
void CDeviceObject::ChangeVideo() 
{ 
	m_ConfigInfo.iRecordMode = AfxGetApp()->GetProfileInt(m_sSection,"录制模式",0); 
	m_ConfigInfo.iVideoStandard = AfxGetApp()->GetProfileInt(m_sSection,"视频信号源制式",1); 
	m_ConfigInfo.iPictureSize = AfxGetApp()->GetProfileInt(m_sSection,"图像尺寸",0); 
} 
/////////////////////////////////////////////////////////////////////////////// 
// 
//////////////////////////////////////////////////////////////////////////////// 
void CDeviceObject::GetINIParameters() 
{ 
	m_ConfigInfo.iInputSource = AfxGetApp()->GetProfileInt(m_sSection,"源路",0); 
	m_ConfigInfo.iVideoStandard = AfxGetApp()->GetProfileInt(m_sSection,"视频信号源制式",1); 
	m_ConfigInfo.iVCD = AfxGetApp()->GetProfileInt(m_sSection,"VCD标准",0); 
	m_ConfigInfo.iRecordMode = AfxGetApp()->GetProfileInt(m_sSection,"录制模式",0); 
	m_ConfigInfo.iVideoCons = AfxGetApp()->GetProfileInt(m_sSection,"常量位速率",1);  
	m_ConfigInfo.iVideoConsVal = AfxGetApp()->GetProfileInt(m_sSection,"常量位速率值",500);//1150,500  
	m_ConfigInfo.iPictureSize = AfxGetApp()->GetProfileInt(m_sSection,"图像尺寸",0); 
	m_ConfigInfo.iAudioBitrate = AfxGetApp()->GetProfileInt(m_sSection,"音频速率",224); 
	m_ConfigInfo.iAudioSampleRate = AfxGetApp()->GetProfileInt(m_sSection,"音频采样速率",44100);  
	m_ConfigInfo.iAudioDelay=AfxGetApp()->GetProfileInt(m_sSection,"音频延迟",0); 
	m_ConfigInfo.iVideoBri = AfxGetApp()->GetProfileInt(m_sSection,"亮度",45);  
	m_ConfigInfo.iVideoCta = AfxGetApp()->GetProfileInt(m_sSection,"对比度",75);  
	m_ConfigInfo.iVideoSta = AfxGetApp()->GetProfileInt(m_sSection,"饱和度",64);  
	m_ConfigInfo.iVideoHue = AfxGetApp()->GetProfileInt(m_sSection,"色调",0);  
	m_ConfigInfo.iXLogo = 0; 
	m_ConfigInfo.iYLogo = 0; 
	m_ConfigInfo.iDuration=0; 
	m_ConfigInfo.iDurationH=0; 
	m_ConfigInfo.iDurationM=0; 
	m_ConfigInfo.iDurationS=0; 
	m_ConfigInfo.iCheckLogo = 0; 
	m_ConfigInfo.iCheckLogo = 0; 
    m_ConfigInfo.csLogoFile[0]=0; 
	strcpy(m_ConfigInfo.csWorkDir, GetAppPath()); 
} 
/////////////////////////////////////////////////////////////////////// 
// 
/////////////////////////////////////////////////////////////////////// 
BOOL CDeviceObject::InitVideoDecoder() 
{ 
	if(!theApp.m_bRecord) 
		return TRUE; 
	RECCTL_VIDEO_DECODER_CONFIG		VideoDecoderConfig; 
	VideoDecoderConfig.dwSlotNumber = m_dwSlotNumber; 
	VideoDecoderConfig.iVideoStandard =(m_ConfigInfo.iVideoStandard == 0) ? MPJ_NTSC : MPJ_PAL; 
	VideoDecoderConfig.iVideoSource = m_ConfigInfo.iInputSource; 
	VideoDecoderConfig.iBrightness = m_ConfigInfo.iVideoBri+ 128; 
	VideoDecoderConfig.iContrast = m_ConfigInfo.iVideoCta; 
	VideoDecoderConfig.iHue = m_ConfigInfo.iVideoHue; 
	VideoDecoderConfig.iSaturation = m_ConfigInfo.iVideoSta; 
	int nError=RECCTL_InitVideoDecoder( &VideoDecoderConfig ); 
	if(  nError!= ERR_OK ) 
	{ 
		CString sError; 
		sError.Format("%02d路初始视频解码器失败-%d",m_dwSlotNumber+1,nError); 
		m_pParentWnd->m_cMsgListBox.AddString(sError); 
		return FALSE; 
	} 
	return TRUE; 
} 
///////////////////////////////////// 
// 
///////////////////////////////////// 
BOOL CDeviceObject::StartLVPT() 
{ 
	if(!theApp.m_bRecord) 
		return TRUE; 
	if(m_bRecord) 
		return FALSE; 
	CWnd *hOutputArea; 
    hOutputArea = AfxGetMainWnd()->GetDlgItem(IDC_LOGO); 
	VIEWCTL_DISPLAYINFO nDisplayInfo; 
	nDisplayInfo.dwDataType = DATATYPE_YUV420_DATA; 
	nDisplayInfo.dwImageHeight = 144; 
	nDisplayInfo.dwImageWidth = 176; 
	nDisplayInfo.dwSlotNumber = m_dwSlotNumber; 
	nDisplayInfo.hWnd = hOutputArea->m_hWnd; 
	CRect rect, rect1, rect2; 
	hOutputArea->GetClientRect(rect); 
	hOutputArea->ShowWindow(SW_SHOW); 
	nDisplayInfo.rOutputArea = rect; 
	nDisplayInfo.bColorKeyRed = 0; 
	nDisplayInfo.bColorKeyGreen = 0; 
	nDisplayInfo.bColorKeyBlue = 0; 
	VIEWCTL_CreateDisplay(nDisplayInfo); 
	 
	RECCTL_LVPT_CONFIG	LVPTConfig; 
	LVPTConfig.dwSlotNumber = m_dwSlotNumber; 
	LVPTConfig.fLogoEnable = m_ConfigInfo.iCheckLogo; 
	LVPTConfig.dwAudioBitRate = 224; 
	LVPTConfig.dwAudioSampleRate = 44100;	//0; 
	LVPTConfig.iDelayTicks = 0; 
	LVPTConfig.iLogoX = m_ConfigInfo.iXLogo; 
	LVPTConfig.iLogoY = m_ConfigInfo.iYLogo; 
	LVPTConfig.lpLogoBuffer = NULL; 
	LVPTConfig.Resolution =MPJ_QSIF;//(m_ConfigInfo.iPictureSize == 0) ? MPJ_SIF : MPJ_QSIF; 
	LVPTConfig.StreamType = MPJ_VIDEO_STREAM; 
	LVPTConfig.VideoStandard =MPJ_PAL ;//(m_ConfigInfo.iVideoStandard == 0) ? MPJ_NTSC : MPJ_PAL; 
	LVPTConfig.iAdjustAudioSamplesPeriodically=0; 
	int nErr = RECCTL_LiveVideoPassThrough( &LVPTConfig ); 
	if( nErr != ERR_OK ) 
	{ 
		return FALSE; 
	} 
	m_bCheck=TRUE; 
	return TRUE; 
} 
///////////////////////////////////// 
// Added by CSC, doing LVE 
//////////////////////////////////// 
BOOL CDeviceObject::StartLVE() 
{ 
	if(m_bCheck) 
		return FALSE; 
	if(!theApp.m_bRecord) 
		return TRUE; 
	RECCTL_LVE_CONFIG	LVEConfig; 
	LVEConfig.dwSlotNumber = m_dwSlotNumber; 
	LVEConfig.CaptureType = MPJ_LIVE_VIDEO; 
	LVEConfig.Resolution = (m_ConfigInfo.iPictureSize == 0) ? MPJ_SIF : MPJ_QSIF; 
	LVEConfig.VideoStandard = (m_ConfigInfo.iVideoStandard == 0) ? MPJ_NTSC : MPJ_PAL; 
	if(m_ConfigInfo.iRecordMode == 2) 
		LVEConfig.fNeedMux = TRUE;	 
	else 
		LVEConfig.fNeedMux = FALSE;		// Dump video MPEG elementary stream. 
	if( m_ConfigInfo.iVideoCons == 1 )		// Constant bit rate 
	{ 
		LVEConfig.RateControl = MPJ_CONST_BIT_RATE; 
		LVEConfig.iVideoBitRate =AfxGetApp()->GetProfileInt(m_sSection,"常量位速率值",500) * 1000; 
		LVEConfig.Quality = 1;//30;		// Assign a valid value for passing driver test. 
	} 
	else		// Variable bit rate 
	{ 
		LVEConfig.RateControl = MPJ_VARIABLE_BIT_RATE; 
		LVEConfig.Quality = m_ConfigInfo.iVideoConsVal; 
		LVEConfig.iVideoBitRate = 1150000;	// Assign a valid value for passing driver test. 
	} 
	LVEConfig.CompressMethod = MPJ_MPEG1; 
	LVEConfig.fLogoEnable = m_ConfigInfo.iCheckLogo; 
	LVEConfig.lpLogoBuffer = (LPBYTE) (m_ConfigInfo.csLogoBuffer); 
	LVEConfig.iLogoX = m_ConfigInfo.iXLogo; 
	LVEConfig.iLogoY = m_ConfigInfo.iYLogo; 
	LVEConfig.dwAudioSampleRate = m_ConfigInfo.iAudioSampleRate;	//0; 
	LVEConfig.iDelayTicks = m_ConfigInfo.iAudioDelay;		//0; 
	LVEConfig.fVCDFormat = m_ConfigInfo.iVCD;	// TRUE;	//FALSE; 
	LVEConfig.fOutOfSyncStop =FALSE; 
	LVEConfig.fPassThroughUsingLVE = TRUE; 
	// 
	CString	  sMPEGDataFile,sTmp; 
	CString sPath; 
	sPath=GetAppPath(); 
	sPath+="Mpeg\\"; 
	m_sRecordRootPath=GetRootPath(sPath); 
	COleDateTime CurTime; 
    CurTime=COleDateTime::GetCurrentTime(); 
	sTmp=CurTime.Format("%Y%m%d%H%M%S"); 
	sMPEGDataFile.Format("%02d-",m_dwSlotNumber+1); 
	CString sSoundFile=sPath+sMPEGDataFile+sTmp+".Wav"; 
    sMPEGDataFile+=sTmp+".mpg"; 
	sMPEGDataFile = sPath + sMPEGDataFile; 
	// 
	strcpy( LVEConfig.csOutputFilename, sMPEGDataFile ); 
	LVEConfig.StreamType = MPJ_VIDEO_STREAM; 
	switch(m_ConfigInfo.iRecordMode) 
	{ 
		case 0: 
			//LVEConfig.StreamType = MPJ_VIDEO_STREAM; 
			m_bSound=FALSE; 
			break; 
		case 1: 
			//LVEConfig.StreamType = MPJ_AUDIO_STREAM; 
			m_bSound=TRUE; 
			break; 
		case 2: 
			//LVEConfig.StreamType = MPJ_BOTH_STREAMS; 
			m_bSound=TRUE; 
			break; 
	} 
	if(m_bSound) 
	{ 
	} 
	LVEConfig.dwAudioBitRate = m_ConfigInfo.iAudioBitrate; 
	LVEConfig.iAdjustAudioSamplesPeriodically = 0; 
	if( RECCTL_LiveVideoEncoding(&LVEConfig) != ERR_OK ) 
	{ 
		m_pParentWnd->GetDlgItem(IDC_CHANNEL_STATES0+m_dwSlotNumber)->SetWindowText("录像失败!"); 
		return FALSE; 
	} 
	return TRUE; 
} 
/////////////////////////////////////////////////// 
// 
/////////////////////////////////////////////////// 
void CDeviceObject::PlaybackAdjust() 
{ 
  m_pVideoPlay->Pause(); 
  m_pVideoPlay->AdjustDispWndRect(); 
  m_pVideoPlay->Play(); 
} 
/////////////////////////////////////////////////// 
// 
/////////////////////////////////////////////////// 
BOOL CDeviceObject::PlaySection() 
{ 
	BOOL bPlayBack=FALSE,bStart=FALSE; 
	CString sFile=""; 
	while(m_arFileName.GetSize()>0) 
	{ 
	   sFile=m_arFileName.GetAt(0);  
       m_arFileName.RemoveAt(0); 
	   bStart=TRUE; 
	   if(m_pVideoPlay->Open(sFile)) 
	   { 
	      bPlayBack=TRUE; 
		  break; 
	   } 
	} 
	if(!bPlayBack) 
	{ 
	   if(bStart) 
	      m_pParentWnd->m_cMsgListBox.AddString("回放失败"); 
	   return FALSE; 
	} 
	m_pVideoPlay->Play();  
#ifdef _DEBUG 
	m_pParentWnd->m_cMsgListBox.AddString((sFile.Right(21)).Left(17)); 
#endif 
	return TRUE; 
} 
/////////////////////////////////////////////////// 
// 
/////////////////////////////////////////////////// 
BOOL CDeviceObject::Playback() 
{ 
	BOOL bPlayBack=FALSE; 
	CString sFile=""; 
	while(m_arFileName.GetSize()>0) 
	{ 
	   sFile=m_arFileName.GetAt(0);  
       m_arFileName.RemoveAt(0); 
	   if(m_pVideoPlay->Open(sFile)) 
	   { 
	      bPlayBack=TRUE; 
		  break; 
	   } 
	} 
	if(!bPlayBack) 
	{ 
	   m_pParentWnd->m_cMsgListBox.AddString("回放失败"); 
	   return FALSE; 
	} 
	m_pVideoPlay->Play(); 
    m_bRePlay=TRUE; 
#ifdef _DEBUG 
	m_pParentWnd->m_cMsgListBox.AddString((sFile.Right(21)).Left(17)); 
#endif 
	return TRUE; 
} 
/////////////////////////////////////////////////// 
// 
/////////////////////////////////////////////////// 
BOOL CDeviceObject::CheckPlayFile() 
{ 
   if(m_arFileName.GetSize()==0) 
	   return FALSE; 
   return TRUE; 
} 
///////////////////////////////// 
// 
///////////////////////////////// 
BOOL CDeviceObject::EnablePlayFile(CString sDate,CString sPath,CStringArray &arFileName) 
{ 
   	CFileFind PlayFile; 
	CString sFind; 
	sFind.Format("%02d-%s",m_dwSlotNumber+1,sDate); 
	sFind+="*.mpg"; 
	sFind=sPath+"\\"+sFind; 
	for(int i=0;im_sStartTime.Left(2)+"."+pList->m_sStartTime.Right(2)); 
	   double fEndTime=StringToFloat(pList->m_sEndTime.Left(2)+"."+pList->m_sEndTime.Right(2)); 
	   BOOL bFind=PlayFile.FindFile(sFind); 
	   while(bFind) 
	   { 
		   bFind=PlayFile.FindNextFile(); 
		   CString sTmp=PlayFile.GetFileTitle(); 
		   CTime   Time; 
		   PlayFile.GetLastWriteTime(Time); 
		   double fFileEndTime=StringToFloat(Time.Format("%H.%M")); 
		   double fFileStartTime=StringToFloat(sTmp.Mid(11,2)+"."+sTmp.Mid(13,2)); 
		   if(fFileStartTime>=fStartTime&&fFileStartTime<=fEndTime)//选择的时间段中包含一个文件 
		      arFileName.Add(PlayFile.GetFilePath()); 
		   else if(fStartTime>fFileStartTime&&fEndTime0) 
	{ 
	  for(int i=1;isTmp2) 
		 { 
			 sTmp3=arFileName.GetAt(i-1); 
			 arFileName.SetAt(i-1,arFileName.GetAt(i)); 
             arFileName.SetAt(i,sTmp3); 
		 } 
		 if(isTmp2) 
			 { 
			   sTmp3=arFileName.GetAt(i); 
			   arFileName.SetAt(i,arFileName.GetAt(i+1)); 
               arFileName.SetAt(i+1,sTmp3); 
			 } 
		 } 
	  } 
	} 
	return TRUE; 
} 
/////////////////////////////////////////////// 
// 
/////////////////////////////////////////////// 
void  CDeviceObject::SetMaskMap(CRect rMaskRect) 
{ 
/*	DWORD size; 
	DWORD handle; 
	DWORD ddd; 
	StaticMemAlloc(&size,&m_dwPhyTopMask,&handle,&ddd); 
	StaticMemAlloc(&size,&m_dwPhyBotMask,&handle,&ddd); 
	 
	CRect rScreenRect; 
	AfxGetMainWnd()->GetDlgItem(IDC_VIDEO_POS+m_dwSlotNumber)->GetWindowRect(rScreenRect); 
	//int nScreenWid=rScreenRect.Width(); 
	//int nScreenHei=rScreenRect.Height(); 
	int nScreenWid=::GetSystemMetrics(SM_CXSCREEN); 
	int nScreenHei=::GetSystemMetrics(SM_CYSCREEN); 
	//奇、偶场分别屏蔽==>	nPageNeeded*2 
	nScreenWid *= 2;	//存放屏蔽码内存区宽度为屏幕宽度*2 
	int nPageNeeded=(nScreenWid*nScreenHei/8+4095)/4096; 
	if( DWORD(2*nPageNeeded) > size)		//保证分配了足够的空间,奇、偶场分别屏蔽==>	nPageNeeded*2 
		return; 
	int nLineWid=nScreenWid/8;		//屏蔽一行 
    m_dwPhyBotMask=m_dwPhyTopMask+nPageNeeded*4096; 
	m_pbyMask1=(BYTE *)handle; 
	m_pbyMask2=(BYTE *)(handle+nPageNeeded*4096); 
 
	FillMemory(m_pbyMask1,nPageNeeded*4096L,0xff); 
	FillMemory(m_pbyMask2,nPageNeeded*4096L,0xff); 
	long pos; 
 
	//屏蔽一方块 
	for(int i=0;i<20;i++) 
	{ 
		//从第10行屏蔽起 
		pos=(10+i)*nLineWid; 
		for(int j=0;j<5;j++) 
		{ 
			*(m_pbyMask1+pos)=0; 
			*(m_pbyMask2+pos)=0; 
			pos++; 
		} 
	} 
 
	//屏蔽一横线,屏蔽第100行的80~160的像素点 
	//如果奇、偶场使用的屏蔽图像一样,则屏蔽的是两行 
	pos=100*nLineWid; 
	pos+=10; 
	for(i=0;i<10;i++) 
	{ 
		*(m_pbyMask2+pos)=0; 
		*(m_pbyMask1+pos)=0; 
		pos++; 
	} 
 
	//屏蔽一列,高度为80个像素 
	pos=120*nLineWid; 
	pos+=10;			//该列离左边界80个像素 
	for(i=0;i<80;i++) 
	{ 
		*(m_pbyMask1+pos)=0xfe;		//屏蔽8个像素的最左像素 
		*(m_pbyMask2+pos)=0xfe;		//屏蔽8个像素的最左像素 
	//	*(pMask+pos)=0x7f;		  屏蔽8个像素的最右像素 
		pos+=nLineWid; 
	} 
	CG200EnableOverlay(m_hcg200,TRUE); 
	CG200SetMask(m_hcg200,TopField,m_dwPhyTopMask);		//pPhyMask1:	物理地址 
	CG200SetMask(m_hcg200,BottomField,m_dwPhyBotMask);		//pPhyMask2:	物理地址 
*/ 
}