2019-01-05 20:21:43 +08:00
|
|
|
|
// VideoDlg.cpp : ʵ<><CAB5><EFBFBD>ļ<EFBFBD>
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
|
|
#include "2015Remote.h"
|
|
|
|
|
|
#include "VideoDlg.h"
|
|
|
|
|
|
#include "afxdialogex.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum
|
|
|
|
|
|
{
|
2019-01-26 10:35:10 +08:00
|
|
|
|
IDM_ENABLECOMPRESS = 0x0010, // <20><>Ƶѹ<C6B5><D1B9>
|
2019-01-05 20:21:43 +08:00
|
|
|
|
IDM_SAVEAVI, // <20><><EFBFBD><EFBFBD>¼<EFBFBD><C2BC>
|
|
|
|
|
|
};
|
|
|
|
|
|
// CVideoDlg <20>Ի<EFBFBD><D4BB><EFBFBD>
|
|
|
|
|
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC(CVideoDlg, CDialog)
|
|
|
|
|
|
|
2019-01-26 10:35:10 +08:00
|
|
|
|
AVISTREAMINFO CBmpToAvi::m_si;
|
|
|
|
|
|
|
|
|
|
|
|
CBmpToAvi::CBmpToAvi()
|
|
|
|
|
|
{
|
|
|
|
|
|
m_pfile = NULL;
|
|
|
|
|
|
m_pavi = NULL;
|
|
|
|
|
|
AVIFileInit();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CBmpToAvi::~CBmpToAvi()
|
|
|
|
|
|
{
|
|
|
|
|
|
AVIFileExit();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CBmpToAvi::Open( LPCTSTR szFile, LPBITMAPINFO lpbmi )
|
|
|
|
|
|
{
|
|
|
|
|
|
if (szFile == NULL)
|
|
|
|
|
|
return false;
|
|
|
|
|
|
m_nFrames = 0;
|
|
|
|
|
|
|
|
|
|
|
|
if (AVIFileOpen(&m_pfile, szFile, OF_WRITE | OF_CREATE, NULL))
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
m_si.fccType = streamtypeVIDEO;
|
|
|
|
|
|
m_si.fccHandler = BI_RGB;
|
|
|
|
|
|
m_si.dwScale = 1;
|
|
|
|
|
|
m_si.dwRate = 8; // ֡<><D6A1>
|
|
|
|
|
|
SetRect(&m_si.rcFrame, 0, 0, lpbmi->bmiHeader.biWidth, lpbmi->bmiHeader.biHeight);
|
|
|
|
|
|
m_si.dwSuggestedBufferSize = lpbmi->bmiHeader.biSizeImage;
|
|
|
|
|
|
|
|
|
|
|
|
if (AVIFileCreateStream(m_pfile, &m_pavi, &m_si))
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (AVIStreamSetFormat(m_pavi, 0, lpbmi, sizeof(BITMAPINFO)) != AVIERR_OK)
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CBmpToAvi::Write(LPVOID lpBuffer)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (m_pfile == NULL || m_pavi == NULL)
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
return AVIStreamWrite(m_pavi, m_nFrames++, 1, lpBuffer, m_si.dwSuggestedBufferSize, AVIIF_KEYFRAME, NULL, NULL) == AVIERR_OK;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CBmpToAvi::Close()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (m_pavi)
|
|
|
|
|
|
{
|
|
|
|
|
|
AVIStreamRelease(m_pavi);
|
|
|
|
|
|
m_pavi = NULL;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (m_pfile)
|
|
|
|
|
|
{
|
|
|
|
|
|
AVIFileRelease(m_pfile);
|
|
|
|
|
|
m_pfile = NULL;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CVideoDlg::SaveAvi(void)
|
|
|
|
|
|
{
|
|
|
|
|
|
CMenu *pSysMenu = GetSystemMenu(FALSE);
|
|
|
|
|
|
if (pSysMenu->GetMenuState(IDM_SAVEAVI, MF_BYCOMMAND) & MF_CHECKED)
|
|
|
|
|
|
{
|
|
|
|
|
|
pSysMenu->CheckMenuItem(IDM_SAVEAVI, MF_UNCHECKED);
|
|
|
|
|
|
m_aviFile.Empty();
|
|
|
|
|
|
m_aviStream.Close();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CString strFileName = m_strIPAddress + CTime::GetCurrentTime().Format("_%Y-%m-%d_%H-%M-%S.avi");
|
|
|
|
|
|
CFileDialog dlg(FALSE, "avi", strFileName, OFN_OVERWRITEPROMPT, "<EFBFBD><EFBFBD>Ƶ<EFBFBD>ļ<EFBFBD>(*.avi)|*.avi|", this);
|
|
|
|
|
|
if(dlg.DoModal () != IDOK)
|
|
|
|
|
|
return;
|
|
|
|
|
|
m_aviFile = dlg.GetPathName();
|
|
|
|
|
|
if (!m_aviStream.Open(m_aviFile, m_BitmapInfor_Full))
|
|
|
|
|
|
{
|
|
|
|
|
|
m_aviFile.Empty();
|
|
|
|
|
|
MessageBox("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ʧ<EFBFBD><EFBFBD>!");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
pSysMenu->CheckMenuItem(IDM_SAVEAVI, MF_CHECKED);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-01-05 20:21:43 +08:00
|
|
|
|
CVideoDlg::CVideoDlg(CWnd* pParent, IOCPServer* IOCPServer, CONTEXT_OBJECT *ContextObject)
|
|
|
|
|
|
: CDialog(CVideoDlg::IDD, pParent)
|
|
|
|
|
|
{
|
2019-01-26 10:35:10 +08:00
|
|
|
|
m_nCount = 0;
|
|
|
|
|
|
m_aviFile.Empty();
|
2019-01-05 20:21:43 +08:00
|
|
|
|
m_ContextObject = ContextObject;
|
|
|
|
|
|
m_iocpServer = IOCPServer;
|
|
|
|
|
|
m_BitmapInfor_Full = NULL;
|
2019-02-04 14:49:11 +08:00
|
|
|
|
m_pVideoCodec = NULL;
|
2019-01-05 20:21:43 +08:00
|
|
|
|
sockaddr_in ClientAddress;
|
|
|
|
|
|
memset(&ClientAddress, 0, sizeof(ClientAddress));
|
|
|
|
|
|
int iClientAddressLength = sizeof(ClientAddress);
|
|
|
|
|
|
BOOL bResult = getpeername(m_ContextObject->sClientSocket, (SOCKADDR*)&ClientAddress, &iClientAddressLength);
|
|
|
|
|
|
m_strIPAddress = bResult != INVALID_SOCKET ? inet_ntoa(ClientAddress.sin_addr) : "";
|
|
|
|
|
|
|
|
|
|
|
|
m_BitmapData_Full = NULL;
|
|
|
|
|
|
m_BitmapCompressedData_Full = NULL;
|
|
|
|
|
|
ResetScreen();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CVideoDlg::ResetScreen(void)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (m_BitmapInfor_Full)
|
|
|
|
|
|
{
|
|
|
|
|
|
delete m_BitmapInfor_Full;
|
|
|
|
|
|
m_BitmapInfor_Full = NULL;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int iBitMapInforSize = m_ContextObject->InDeCompressedBuffer.GetBufferLength() - 1;
|
|
|
|
|
|
m_BitmapInfor_Full = (LPBITMAPINFO) new BYTE[iBitMapInforSize];
|
2024-12-26 17:07:43 +08:00
|
|
|
|
m_ContextObject->InDeCompressedBuffer.CopyBuffer(m_BitmapInfor_Full, iBitMapInforSize, 1);
|
2019-01-05 20:21:43 +08:00
|
|
|
|
m_BitmapData_Full = new BYTE[m_BitmapInfor_Full->bmiHeader.biSizeImage];
|
|
|
|
|
|
m_BitmapCompressedData_Full = new BYTE[m_BitmapInfor_Full->bmiHeader.biSizeImage];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CVideoDlg::~CVideoDlg()
|
|
|
|
|
|
{
|
2019-01-26 10:35:10 +08:00
|
|
|
|
if (!m_aviFile.IsEmpty())
|
|
|
|
|
|
{
|
|
|
|
|
|
SaveAvi();
|
|
|
|
|
|
m_aviFile.Empty();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-01-05 20:21:43 +08:00
|
|
|
|
if (m_pVideoCodec)
|
|
|
|
|
|
{
|
|
|
|
|
|
delete m_pVideoCodec;
|
|
|
|
|
|
m_pVideoCodec = NULL;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (m_BitmapData_Full)
|
|
|
|
|
|
{
|
|
|
|
|
|
delete m_BitmapData_Full;
|
|
|
|
|
|
m_BitmapData_Full = NULL;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (m_BitmapInfor_Full)
|
|
|
|
|
|
{
|
|
|
|
|
|
delete m_BitmapInfor_Full;
|
|
|
|
|
|
m_BitmapInfor_Full = NULL;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (m_BitmapCompressedData_Full)
|
|
|
|
|
|
{
|
|
|
|
|
|
delete m_BitmapCompressedData_Full;
|
|
|
|
|
|
m_BitmapCompressedData_Full = NULL;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CVideoDlg::DoDataExchange(CDataExchange* pDX)
|
|
|
|
|
|
{
|
|
|
|
|
|
CDialog::DoDataExchange(pDX);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CVideoDlg, CDialog)
|
|
|
|
|
|
ON_WM_CLOSE()
|
|
|
|
|
|
ON_WM_SYSCOMMAND()
|
|
|
|
|
|
ON_WM_PAINT()
|
|
|
|
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// CVideoDlg <20><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BOOL CVideoDlg::OnInitDialog()
|
|
|
|
|
|
{
|
|
|
|
|
|
CDialog::OnInitDialog();
|
|
|
|
|
|
|
|
|
|
|
|
CMenu* SysMenu = GetSystemMenu(FALSE);
|
|
|
|
|
|
if (SysMenu != NULL)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_hDD = DrawDibOpen();
|
|
|
|
|
|
|
|
|
|
|
|
m_hDC = ::GetDC(m_hWnd);
|
2019-01-26 10:35:10 +08:00
|
|
|
|
SysMenu->AppendMenu(MF_STRING, IDM_ENABLECOMPRESS, "<EFBFBD><EFBFBD>Ƶѹ<EFBFBD><EFBFBD>(&C)");
|
2019-01-05 20:21:43 +08:00
|
|
|
|
SysMenu->AppendMenu(MF_STRING, IDM_SAVEAVI, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD>(&V)");
|
2019-01-26 10:35:10 +08:00
|
|
|
|
SysMenu->AppendMenu(MF_SEPARATOR);
|
2019-01-05 20:21:43 +08:00
|
|
|
|
|
|
|
|
|
|
CString strString;
|
|
|
|
|
|
|
|
|
|
|
|
strString.Format("%s - <20><>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD> %d<><64>%d", m_strIPAddress, m_BitmapInfor_Full->bmiHeader.biWidth, m_BitmapInfor_Full->bmiHeader.biHeight);
|
|
|
|
|
|
|
|
|
|
|
|
SetWindowText(strString);
|
|
|
|
|
|
|
|
|
|
|
|
BYTE bToken = COMMAND_NEXT;
|
|
|
|
|
|
|
|
|
|
|
|
m_iocpServer->OnClientPreSending(m_ContextObject, &bToken, sizeof(BYTE));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-01-26 14:05:37 +08:00
|
|
|
|
m_hIcon = LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_ICON_CAMERA));
|
|
|
|
|
|
SetIcon(m_hIcon, TRUE);
|
|
|
|
|
|
SetIcon(m_hIcon, FALSE);
|
|
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
2019-01-05 20:21:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CVideoDlg::OnClose()
|
|
|
|
|
|
{
|
2019-01-26 10:35:10 +08:00
|
|
|
|
if (!m_aviFile.IsEmpty())
|
|
|
|
|
|
{
|
|
|
|
|
|
SaveAvi();
|
|
|
|
|
|
m_aviFile.Empty();
|
|
|
|
|
|
}
|
2019-01-13 13:13:59 +08:00
|
|
|
|
#if CLOSE_DELETE_DLG
|
2019-01-05 20:21:43 +08:00
|
|
|
|
m_ContextObject->v1 = 0;
|
2019-01-13 13:13:59 +08:00
|
|
|
|
#endif
|
2019-01-05 20:21:43 +08:00
|
|
|
|
CancelIo((HANDLE)m_ContextObject->sClientSocket);
|
|
|
|
|
|
closesocket(m_ContextObject->sClientSocket);
|
|
|
|
|
|
|
|
|
|
|
|
CDialog::OnClose();
|
2019-01-13 13:13:59 +08:00
|
|
|
|
#if CLOSE_DELETE_DLG
|
2019-01-05 20:21:43 +08:00
|
|
|
|
delete this;
|
2019-01-13 13:13:59 +08:00
|
|
|
|
#endif
|
2019-01-05 20:21:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CVideoDlg::OnReceiveComplete(void)
|
|
|
|
|
|
{
|
2019-01-26 10:35:10 +08:00
|
|
|
|
++m_nCount;
|
|
|
|
|
|
|
2024-12-26 17:07:43 +08:00
|
|
|
|
switch (m_ContextObject->InDeCompressedBuffer.GetBYTE(0))
|
2019-01-05 20:21:43 +08:00
|
|
|
|
{
|
|
|
|
|
|
case TOKEN_WEBCAM_DIB:
|
|
|
|
|
|
{
|
|
|
|
|
|
DrawDIB();//<2F><><EFBFBD><EFBFBD><EFBFBD>ǻ<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4>뿴һ<EBBFB4><D2BB>
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
default:
|
|
|
|
|
|
// <20><><EFBFBD>䷢<EFBFBD><E4B7A2><EFBFBD>쳣<EFBFBD><ECB3A3><EFBFBD><EFBFBD>
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CVideoDlg::DrawDIB(void)
|
|
|
|
|
|
{
|
|
|
|
|
|
CMenu* SysMenu = GetSystemMenu(FALSE);
|
|
|
|
|
|
if (SysMenu == NULL)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
2019-01-26 10:35:10 +08:00
|
|
|
|
const int nHeadLen = 1 + 1 + 4;
|
2019-01-05 20:21:43 +08:00
|
|
|
|
|
2024-12-26 17:07:43 +08:00
|
|
|
|
Buffer tmp = m_ContextObject->InDeCompressedBuffer.GetMyBuffer(0);
|
|
|
|
|
|
LPBYTE szBuffer = tmp.Buf();
|
2019-01-05 20:21:43 +08:00
|
|
|
|
UINT ulBufferLen = m_ContextObject->InDeCompressedBuffer.GetBufferLength();
|
|
|
|
|
|
if (szBuffer[1] == 0) // û<>о<EFBFBD><D0BE><EFBFBD>H263ѹ<33><D1B9><EFBFBD><EFBFBD>ԭʼ<D4AD><CABC><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>
|
|
|
|
|
|
{
|
|
|
|
|
|
// <20><>һ<EFBFBD>Σ<EFBFBD>û<EFBFBD><C3BB>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˲<EFBFBD>֧<EFBFBD><D6A7>ָ<EFBFBD><D6B8><EFBFBD>Ľ<EFBFBD><C4BD><EFBFBD><EFBFBD><EFBFBD>
|
2019-01-26 10:35:10 +08:00
|
|
|
|
if (m_nCount == 1)
|
2019-01-05 20:21:43 +08:00
|
|
|
|
{
|
2019-01-26 10:35:10 +08:00
|
|
|
|
SysMenu->EnableMenuItem(IDM_ENABLECOMPRESS, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
|
2019-01-05 20:21:43 +08:00
|
|
|
|
}
|
2019-01-26 10:35:10 +08:00
|
|
|
|
SysMenu->CheckMenuItem(IDM_ENABLECOMPRESS, MF_UNCHECKED);
|
|
|
|
|
|
memcpy(m_BitmapData_Full, szBuffer + nHeadLen, ulBufferLen - nHeadLen);
|
2019-01-05 20:21:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
else // <20><><EFBFBD><EFBFBD>
|
|
|
|
|
|
{
|
|
|
|
|
|
////<2F><><EFBFBD>ﻺ<EFBFBD><EFBBBA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵĵڶ<C4B5><DAB6><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD>
|
2019-01-26 10:35:10 +08:00
|
|
|
|
InitCodec(*(LPDWORD)(szBuffer + 2)); //<2F>ж<EFBFBD>
|
2019-01-05 20:21:43 +08:00
|
|
|
|
if (m_pVideoCodec != NULL)
|
|
|
|
|
|
{
|
2019-01-26 10:35:10 +08:00
|
|
|
|
SysMenu->CheckMenuItem(IDM_ENABLECOMPRESS, MF_CHECKED);
|
|
|
|
|
|
memcpy(m_BitmapCompressedData_Full, szBuffer + nHeadLen, ulBufferLen - nHeadLen); //<2F><>Ƶû<C6B5>н<EFBFBD>ѹ
|
2019-01-05 20:21:43 +08:00
|
|
|
|
//<2F><><EFBFBD>↑ʼ<EFBFAA><CABC><EFBFBD>룬<EFBFBD><EBA3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬδѹ<CEB4><D1B9><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD> <20><>ʾ<EFBFBD><CABE><EFBFBD>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD>ϡ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>avi<76><69>ʽ
|
|
|
|
|
|
m_pVideoCodec->DecodeVideoData(m_BitmapCompressedData_Full, ulBufferLen - nHeadLen,
|
2019-01-26 10:35:10 +08:00
|
|
|
|
(LPBYTE)m_BitmapData_Full, NULL, NULL); //<2F><><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD>ݽ<EFBFBD>ѹ
|
2019-01-05 20:21:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PostMessage(WM_PAINT);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CVideoDlg::InitCodec(DWORD fccHandler)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (m_pVideoCodec != NULL)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
m_pVideoCodec = new CVideoCodec;
|
2019-01-26 10:35:10 +08:00
|
|
|
|
if (!m_pVideoCodec->InitCompressor(m_BitmapInfor_Full, fccHandler))
|
2019-01-05 20:21:43 +08:00
|
|
|
|
{
|
|
|
|
|
|
OutputDebugStringA("======> InitCompressor failed \n");
|
2019-01-26 10:35:10 +08:00
|
|
|
|
delete m_pVideoCodec;
|
|
|
|
|
|
// <20><>NULL, <20><><EFBFBD><EFBFBD>ʱ<EFBFBD>ж<EFBFBD><D0B6>Ƿ<EFBFBD>ΪNULL<4C><4C><EFBFBD>ж<EFBFBD><D0B6>Ƿ<EFBFBD>ѹ<EFBFBD><D1B9>
|
|
|
|
|
|
m_pVideoCodec = NULL;
|
|
|
|
|
|
// ֪ͨ<CDA8><D6AA><EFBFBD><EFBFBD><EFBFBD>˲<EFBFBD><CBB2><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><D1B9>
|
|
|
|
|
|
BYTE bToken = COMMAND_WEBCAM_DISABLECOMPRESS;
|
|
|
|
|
|
m_iocpServer->OnClientPreSending(m_ContextObject, &bToken, sizeof(BYTE));
|
|
|
|
|
|
GetSystemMenu(FALSE)->EnableMenuItem(IDM_ENABLECOMPRESS, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
|
2019-01-05 20:21:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CVideoDlg::OnSysCommand(UINT nID, LPARAM lParam)
|
|
|
|
|
|
{
|
|
|
|
|
|
// TODO: <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĭ<EFBFBD><C4AC>ֵ
|
|
|
|
|
|
switch (nID)
|
|
|
|
|
|
{
|
|
|
|
|
|
case IDM_SAVEAVI:
|
|
|
|
|
|
{
|
2019-01-26 10:35:10 +08:00
|
|
|
|
SaveAvi();
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
case IDM_ENABLECOMPRESS:
|
|
|
|
|
|
{
|
|
|
|
|
|
CMenu *pSysMenu = GetSystemMenu(FALSE);
|
|
|
|
|
|
bool bIsChecked = pSysMenu->GetMenuState(IDM_ENABLECOMPRESS, MF_BYCOMMAND) & MF_CHECKED;
|
|
|
|
|
|
pSysMenu->CheckMenuItem(IDM_ENABLECOMPRESS, bIsChecked ? MF_UNCHECKED : MF_CHECKED);
|
|
|
|
|
|
bIsChecked = !bIsChecked;
|
|
|
|
|
|
BYTE bToken = COMMAND_WEBCAM_ENABLECOMPRESS;
|
|
|
|
|
|
if (!bIsChecked)
|
|
|
|
|
|
bToken = COMMAND_WEBCAM_DISABLECOMPRESS;
|
|
|
|
|
|
m_iocpServer->OnClientPreSending(m_ContextObject, &bToken, sizeof(BYTE));
|
2019-01-05 20:21:43 +08:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CDialog::OnSysCommand(nID, lParam);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CVideoDlg::OnPaint()
|
|
|
|
|
|
{
|
|
|
|
|
|
CPaintDC dc(this); // device context for painting
|
|
|
|
|
|
|
|
|
|
|
|
if (m_BitmapData_Full==NULL)
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
RECT rect;
|
|
|
|
|
|
GetClientRect(&rect);
|
|
|
|
|
|
|
|
|
|
|
|
DrawDibDraw
|
|
|
|
|
|
(
|
|
|
|
|
|
m_hDD,
|
|
|
|
|
|
m_hDC,
|
|
|
|
|
|
0, 0,
|
|
|
|
|
|
rect.right, rect.bottom,
|
|
|
|
|
|
(LPBITMAPINFOHEADER)m_BitmapInfor_Full,
|
|
|
|
|
|
m_BitmapData_Full,
|
|
|
|
|
|
0, 0,
|
|
|
|
|
|
m_BitmapInfor_Full->bmiHeader.biWidth, m_BitmapInfor_Full->bmiHeader.biHeight,
|
|
|
|
|
|
DDF_SAME_HDC
|
|
|
|
|
|
);
|
2019-01-26 10:35:10 +08:00
|
|
|
|
|
|
|
|
|
|
if (!m_aviFile.IsEmpty())
|
|
|
|
|
|
{
|
|
|
|
|
|
m_aviStream.Write(m_BitmapData_Full);
|
|
|
|
|
|
// <20><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>¼<EFBFBD><C2BC>
|
|
|
|
|
|
SetBkMode(m_hDC, TRANSPARENT);
|
|
|
|
|
|
SetTextColor(m_hDC, RGB(0xff,0x00,0x00));
|
|
|
|
|
|
const LPCTSTR lpTipsString = "Recording";
|
|
|
|
|
|
TextOut(m_hDC, 0, 0, lpTipsString, lstrlen(lpTipsString));
|
|
|
|
|
|
}
|
2019-01-05 20:21:43 +08:00
|
|
|
|
}
|