videoshow.cpp
来自「用vb实现在线考试系统」· C++ 代码 · 共 980 行 · 第 1/2 页
CPP
980 行
GetDlgItem(IDC_STATIC1+i)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_STATIC1+i)->MoveWindow(&showRect[i]);
}
break;
default:
for(j=0; j<5; j++)
{
for(i=0; i<5; i++)
{
showRect[i+5*j].SetRect(i*rectWidth/5, j*rectHeight/5, (i+1)*rectWidth/5, (j+1)*rectHeight/5);
}
}
for(i=0; i<25; i++)
{
GetDlgItem(IDC_STATIC1+i)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_STATIC1+i)->MoveWindow(&showRect[i]);
}
break;
}
}
void CVideoShow::OnDestroy()
{
KillTimer(1);
// MP4_ClientReleaseDDraw_Card();
// MP4_ClientReleaseDevice_Card();
// MP4_ClientCleanup();
CDialog::OnDestroy();
}
/****************************************************************
* 以下做的是轮寻测试~ 在DLL中实现,但结果不太好~ 故取消之,使用另中方法
* 在EXE中实现了,但下面的代码还是保留~
*
****************************************************************/
void CVideoShow::SwitchShow()
{
UpdateData(FALSE);
int i, j;
//轮循参数赋值
for(i=0; i<MAX_CHANNELS; i++)
for(j=0; j<MAX_CHANNELS; j++)
m_SwitchShow[i][j] = SwitchParams->SwitchShow[i][j];
m_SwitchNum = SwitchParams->SwitchNum;
//CString strTmp;
//strTmp.Format("SwitchShow: %d %s %d %s %d", ShowParams->localChannel[2], ShowParams->remoteIP[1], m_SwitchNum, m_remoteIP[1], m_Values[1][1]);
//AfxMessageBox(strTmp);
/*
for(i=0; i<MAX_CHANNELS; i++)
{
MP4_ClientStopCapture(ShowParams->result[i]);
MP4_ClientStop(ShowParams->result[i]);
}*/
SetTimer(1, 10000, NULL);
}
/***********************************
* 停止轮循显示
*
**********************************/
void CVideoShow::StopSwitchShow()
{
int i;
for(i=0; i<m_SwitchNum; i++)
{
MP4_ClientStopCapture(m_Values[m_SwitchShow[i][m_Num[i]-1]][5]);
MP4_ClientStop(m_Values[m_SwitchShow[i][m_Num[i]-1]][5]);
}
KillTimer(1);
}
/***********************************
* 定时函数
* INPUT: nIDEvent:时间标志
* =1:轮循
*
**********************************/
void CVideoShow::OnTimer(UINT nIDEvent)
{
UpdateData(TRUE);
if(nIDEvent==1)
{
int i, j, nn1;
CString strTmp;
CRect rectVideo;
CLIENT_CARDINFO cliVideo;
for(i=0; i<m_SwitchNum; i++)
{
//思路:
// j:通道号
//
if(m_Num[i]==0)
m_Num[i] = 1;
else
{
Sleep(50);
j = m_SwitchShow[i][m_Num[i]-1];
MP4_ClientStopCapture(m_Values[j][5]); //m_Values[j][5]
MP4_ClientStop(m_Values[j][5]);
//MP4_ClientResetDSP_Card(j);
//MP4_ClientClearSurface_Card();
}
j = m_SwitchShow[i][m_Num[i]];
if(m_Num[i]==m_SwitchShow[i][0])
m_Num[i] = 1;
else
m_Num[i]++;
//if(m_Values[j][0]==2)
{
strTmp.Format("m_SwitchParams->SwitchShow[%d][%d]: %d == %s || %d", i, m_Num[i], j, m_remoteIP[1], m_Values[1][1]);
//AfxMessageBox(strTmp);
cliVideo.m_bRemoteChannel = m_Values[j][4];
switch(m_Values[j][3])
{
case 0:
cliVideo.m_bSendMode = TCPMODE;
break;
case 1:
cliVideo.m_bSendMode = UDPMODE;
break;
case 2:
cliVideo.m_bSendMode = MULTIMODE;
break;
case 3:
cliVideo.m_bSendMode = DIALING;
break;
default:
cliVideo.m_bSendMode = TCPMODE;
break;
}
GetDlgItem(IDC_STATIC1+m_Values[j][1])->GetWindowRect(&rectVideo);
ScreenToClient((LPPOINT)&rectVideo);
ScreenToClient((LPPOINT)&rectVideo+1);
cliVideo.m_sIPAddress = m_remoteIP[j];
cliVideo.m_sUserName = "123";
cliVideo.m_sUserPassword="w";
cliVideo.m_bUserCheck = TRUE;
cliVideo.displaypara.nLeft =rectVideo.left;
cliVideo.displaypara.nTop = rectVideo.top;
cliVideo.displaypara.nWidth =rectVideo.Width();
cliVideo.displaypara.nHeight =rectVideo.Height();
cliVideo.displaypara.bToScreen = 1;
cliVideo.displaypara.bToVideoOut = 1;
cliVideo.displaypara.format =vfYUV422Planar;
MP4_ClientSetTTL(64);
Sleep(10);
nn1 = MP4_ClientStart_Card(&cliVideo, m_Values[j][2], NULL);
Sleep(10);
//MP4_ClientGetState(nn1);
MP4_ClientStartCapture(nn1);
m_Values[j][5] = nn1; //ShowParams->result[j] =
}
}
}
CDialog::OnTimer(nIDEvent);
}
/****************
/* 日志记录
/***************/
int LogWrite(const char *Format, ...)
{
CHAR Buffer0[1024];
CHAR Buffer1[512];
DWORD ItemsWritten;
va_list ArgumentList;
if(logFile == -1)
return -1;
SYSTEMTIME sysTime;
GetLocalTime(&sysTime);
sprintf(Buffer0, "%d:%02d:%02d-%02d:%02d:%02d: ", sysTime.wYear, sysTime.wMonth, sysTime.wDay, sysTime.wHour,
sysTime.wMinute, sysTime.wSecond);
va_start( ArgumentList, Format );
ItemsWritten = vsprintf ((char *)Buffer1, Format, ArgumentList );
va_end ( ArgumentList );
strcat(Buffer0, Buffer1);
return _write( logFile, Buffer0, strlen((const char *)Buffer0 ));
}
void CVideoShow::DrawRect(int iSelectNum)
{
this->RedrawWindow();
CDC* pDC = GetDlgItem(IDC_STATIC1+iSelectNum)->GetDC();
CRect rect;
rect.left = 1;
rect.top = 1;
rect.right = 15;
rect.bottom = 15;
CBrush tempBrush(RGB(255, 200, 255));
CBrush *oldBrush = pDC->SelectObject(&tempBrush);
pDC->Rectangle(&rect);
pDC->SelectObject(oldBrush);
ReleaseDC(pDC);
}
void CVideoShow::OnStatic1()
{
DrawRect(0);
iCurrentWin = 0;
}
void CVideoShow::OnStatic2()
{
DrawRect(1);
iCurrentWin = 1;
}
void CVideoShow::OnStatic3()
{
DrawRect(2);
iCurrentWin = 2;
}
void CVideoShow::OnStatic4()
{
DrawRect(3);
iCurrentWin = 3;
}
void CVideoShow::OnStatic5()
{
DrawRect(4);
iCurrentWin = 4;
}
void CVideoShow::OnStatic6()
{
DrawRect(5);
iCurrentWin = 5;
}
void CVideoShow::OnStatic7()
{
DrawRect(6);
iCurrentWin = 6;
}
void CVideoShow::OnStatic8()
{
DrawRect(7);
iCurrentWin = 7;
}
void CVideoShow::OnStatic9()
{
DrawRect(8);
iCurrentWin = 8;
}
void CVideoShow::OnStatic10()
{
DrawRect(9);
iCurrentWin = 9;
}
void CVideoShow::OnStatic11()
{
DrawRect(10);
iCurrentWin = 10;
}
void CVideoShow::OnStatic12()
{
DrawRect(11);
iCurrentWin = 11;
}
void CVideoShow::OnStatic13()
{
DrawRect(12);
iCurrentWin = 12;
}
void CVideoShow::OnStatic14()
{
DrawRect(13);
iCurrentWin = 13;
}
void CVideoShow::OnStatic15()
{
DrawRect(14);
iCurrentWin = 14;
}
void CVideoShow::OnStatic16()
{
DrawRect(15);
iCurrentWin = 15;
}
void CVideoShow::OnStatic17()
{
DrawRect(16);
iCurrentWin = 16;
}
void CVideoShow::OnStatic18()
{
DrawRect(17);
iCurrentWin = 17;
}
void CVideoShow::OnStatic19()
{
DrawRect(18);
iCurrentWin = 18;
}
void CVideoShow::OnStatic20()
{
DrawRect(19);
iCurrentWin = 19;
}
void CVideoShow::OnStatic21()
{
DrawRect(20);
iCurrentWin = 20;
}
void CVideoShow::OnStatic22()
{
DrawRect(21);
iCurrentWin = 21;
}
void CVideoShow::OnStatic23()
{
DrawRect(22);
iCurrentWin = 22;
}
void CVideoShow::OnStatic24()
{
DrawRect(23);
iCurrentWin = 23;
}
void CVideoShow::OnStatic25()
{
DrawRect(24);
iCurrentWin = 24;
}
void CVideoShow::OnSingleMode(WPARAM wParam, LPARAM lParam)
{
m_oldShowNum = m_ShowNum;
splitRect(1);
/*
CString strTmp;
strTmp.Format("single:%d %d", m_oldShowNum, oldShowParams->localChannel[iCurrentWin]);
AfxMessageBox(strTmp);
for(int i=0; i<MAX_CHANNELS; i++)
{
if(oldShowParams->result[i]>=0)
{
MP4_ClientStopCapture(oldShowParams->result[i]);
MP4_ClientStop(oldShowParams->result[i]);
}
oldShowParams->bShow[i] = 0;
}
oldShowParams->bShow[iCurrentWin] = 1;
oldShowParams->ipos[iCurrentWin] = 0;
oldShowParams->localChannel[iCurrentWin] = m_Values[iCurrentWin][2];
oldShowParams->m_linktype[iCurrentWin] = m_Values[iCurrentWin][3];
oldShowParams->remoteChannel[iCurrentWin] = m_Values[iCurrentWin][4];
oldShowParams->remoteIP[iCurrentWin] = "192.168.10.39";
strTmp.Format("iCurrentWin:%d lCh:%d rCh:%d rIP:%s" , iCurrentWin, oldShowParams->localChannel[iCurrentWin],
oldShowParams->remoteChannel[iCurrentWin], oldShowParams->remoteIP[iCurrentWin]);
AfxMessageBox(strTmp);
int nn1;
int a;
CRect rectVideo;
CLIENT_CARDINFO cliVideo;
i = iCurrentWin;
cliVideo.m_bRemoteChannel = oldShowParams->remoteChannel[i];
switch(oldShowParams->m_linktype[i])
{
case 0:
cliVideo.m_bSendMode = TCPMODE;
break;
case 1:
cliVideo.m_bSendMode = UDPMODE;
break;
case 2:
cliVideo.m_bSendMode = MULTIMODE;
break;
case 3:
cliVideo.m_bSendMode = DIALING;
break;
default:
cliVideo.m_bSendMode = TCPMODE;
break;
}
GetDlgItem(IDC_STATIC1+oldShowParams->ipos[i])->GetWindowRect(&rectVideo);
ScreenToClient((LPPOINT)&rectVideo);
ScreenToClient((LPPOINT)&rectVideo+1);
cliVideo.m_sIPAddress = oldShowParams->remoteIP[i];
cliVideo.m_sUserName = "123";
cliVideo.m_sUserPassword="w";
cliVideo.m_bUserCheck = TRUE;
cliVideo.displaypara.nLeft =rectVideo.left;
cliVideo.displaypara.nTop = rectVideo.top;
cliVideo.displaypara.nWidth =rectVideo.Width();
cliVideo.displaypara.nHeight =rectVideo.Height();
cliVideo.displaypara.bToScreen = oldShowParams->bShow[i];
cliVideo.displaypara.bToVideoOut = 1;
cliVideo.displaypara.format =vfYUV422Planar;
MP4_ClientSetTTL(64);
nn1 = MP4_ClientStart_Card(&cliVideo, oldShowParams->localChannel[i] , NULL);
a = MP4_ClientGetState(nn1);
oldShowParams->result[i] = nn1;
*/
}
void CVideoShow::OnMultiMode(WPARAM wParam, LPARAM lParam)
{
/*CString strTmp;
strTmp.Format("multi:%d", m_oldShowNum);
AfxMessageBox(strTmp);*/
splitRect(m_oldShowNum);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?