📄 devicemgr.cpp
字号:
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;i<m_arPlayList.GetSize();i++)
{
CPlayList *pList=m_arPlayList.GetAt(i);
double fStartTime=StringToFloat(pList->m_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&&fEndTime<fFileEndTime)//选择的时间段中包含在一个文件
{
arFileName.Add(PlayFile.GetFilePath());
}
}
}
if(arFileName.GetSize()>0)
{
for(int i=1;i<arFileName.GetSize();i++)
{
CString sTmp1,sTmp2,sTmp3;
sTmp1=(arFileName.GetAt(i-1)).Right(21);
sTmp2=(arFileName.GetAt(i)).Right(21);
if(sTmp1>sTmp2)
{
sTmp3=arFileName.GetAt(i-1);
arFileName.SetAt(i-1,arFileName.GetAt(i));
arFileName.SetAt(i,sTmp3);
}
if(i<arFileName.GetSize()-1)
{
sTmp1=(arFileName.GetAt(i)).Right(21);
sTmp2=(arFileName.GetAt(i+1)).Right(21);
if(sTmp1>sTmp2)
{
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: 物理地址
*/
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -