📄 mp_apdlg.cpp
字号:
// MP_APDlg.cpp : implementation file
//
#include "stdafx.h"
#include "MP_AP.h"
#include "MP_APDlg.h"
#include "ServerUtl.h"
#include "PacketMaker.h"
#include <direct.h>
#include <process.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
//#ifdef STATICLIB
//#include "AVSynchronizer_Static.h"
//#include "DataBroker_Static.h"
//#endif
//#define CHECK_DI
//#define _SERVERUTL_ASYNC
#define EVENT_DRIVEN_RECORD_TIME 50
#define CONST_READUART_WAIT 5000
CRITICAL_SECTION g_CS[MAX_CHANNELS];
HANDLE g_hAvSync;
HANDLE g_hDataBroker;
HANDLE g_hDatabase;
HANDLE g_ExitWait[MAX_CHANNELS];
HANDLE g_hDisconnectOK=NULL;
TCHANNEL_INFO g_Channel_Info[MAX_CHANNELS];
int g_iFocus;
char g_chDBPath[64];
int g_nMaxChannel = 4;
int g_nImageSize = 0;
DWORD g_VideoCount=0;
DWORD g_AudioCount=0;
DWORD g_SynTime=0;
DWORD g_dwLayout = 0;
DWORD g_dwOrgPicCap = 0;
DWORD g_dwInitOpt = 0;
DWORD g_dwShowDZWnd = 0;
HBITMAP g_hBMP;
BOOL g_bSnapAllChannel = FALSE;
BOOL g_bDrawOnGraph = FALSE;
BOOL g_bDeblocking = FALSE;
int g_nAVRawCCB = 0;
int g_nAVRawDBAskType = PF_BMP24;
BOOL g_bAVRawCBOwnBuf = FALSE;
BOOL g_bAVRawCBWriteFile = FALSE;
char g_szAVCBExtName[MAX_PATH] = "bmp";
BOOL g_bAutoForceI = FALSE;
int g_nForcePeriod=1000;
char g_szProxy[256];
int g_nProxyPort = 3128;
// for decoder channel
int g_nMaxDecoderFileNum = 50;
char g_szExtName[MAX_PATH] = "bmp";
BOOL g_bDecoderChannel = FALSE;
int g_nDecoderAskType = PF_BMP24;
BOOL g_bShowQueueFull = FALSE;
int g_nDecoderMedia = 1;
BOOL g_bTestPacketMaker = FALSE;
char g_szPkgFile[MAX_PATH];
void ReadParameters();
void WriteParameters();
// debug funciton
void SaveVideoToFile(TMediaDataPacketInfo *pMediaDataPacket);
// call back function
SCODE __stdcall AvSynchronizerDecodeCallback(DWORD dwContext, EMEDIATYPE tFrameType, TFRAMEINFO * tframeinfo );
SCODE __stdcall AvSynchronizerAVCB(DWORD dwContext, EMEDIATYPE tFrameType, TFRAMEINFO * tframeinfo );
SCODE DataBrokerAVCallBack(DWORD dwContext,TMediaDataPacketInfo *pMediaDataPacket);
SCODE DataBrokerInputAVCallBack(DWORD dwContext,TMediaDataPacketInfo *pMediaDataPacket);
SCODE DataBrokerStatusCallBack(DWORD dwContext, TDataBrokerStatusType tStatusType, PVOID pvParam1, PVOID pvParam2);
SCODE DataBrokerInputStatusCallBack(DWORD dwContext, TDataBrokerStatusType tStatusType, PVOID pvParam1, PVOID pvParam2);
SCODE DataBrokerNetPacketCallback(DWORD dwContext, DWORD dwMediaType, DWORD dwLen, BYTE *pbyPacket);
SCODE AvSyhchronizerStatusCallBack(DWORD dwContext, DWORD dwStatusCode, DWORD dwParam1, DWORD dwParam2);
SCODE AvSyhchronizerDisplayCallBack(DWORD dwContext,TDISPLAYINFO* ptDisplayInfo );
SCODE __stdcall DataBrokerTxCallBack(DWORD dwContext, BYTE **ppbyData, DWORD *pdwLen, DWORD *pdwDataTimePeriod);
void ReadParameters()
{
// get mp_ap.ini path
char chINIPath[MAX_PATH];
DWORD dwRes=GetModuleFileName( NULL/*AfxGetInstanceHandle()*/,chINIPath,sizeof(chINIPath));
char *a,*b;
a = b = chINIPath;
while(b)
{
b=strchr(a+1,'.');
if(b) a=b;
}
strcpy((a+1),"ini");
// read parameters from mp_ap.ini
GetPrivateProfileString("System","DB_PATH","c:\\DB",g_chDBPath,200,chINIPath);
g_iFocus=GetPrivateProfileInt("System","Focus_Channel",0,chINIPath);
g_SynTime=GetPrivateProfileInt("System","Sync",0,chINIPath);
g_dwLayout=GetPrivateProfileInt("System","Layout",0,chINIPath);
g_dwOrgPicCap = GetPrivateProfileInt("System","OrgPicCap",0,chINIPath);
g_nMaxChannel = GetPrivateProfileInt("System","MaxChannels",4,chINIPath);
int nVal = GetPrivateProfileInt("System","OutputDevice", 0, chINIPath);
if (nVal == 1)
g_dwInitOpt = USE_GDI_ONLY;
else if (nVal == 2)
g_dwInitOpt = USE_DIRECTDRAW_ONLY;
else if (nVal == 3)
g_dwInitOpt = USE_GDI_ONLY | BETTER_GDI_STRETCH;
if (g_dwOrgPicCap != 0)
g_dwInitOpt |= ORG_SIZE_MODE;
nVal = GetPrivateProfileInt("System","CaptionOnGraph", 0, chINIPath);
g_bDrawOnGraph = (nVal != 0);
if (g_bDrawOnGraph)
g_dwInitOpt |= CAPTION_ON_GRAPH;
nVal = GetPrivateProfileInt("System","OnePass", 0, chINIPath);
if (nVal == 1)
g_dwInitOpt |= ONE_PASS_DDRAW;
nVal = GetPrivateProfileInt("System","IndividualYUV", 0, chINIPath);
if (nVal == 1)
g_dwInitOpt |= INDIVIDUAL_SURFACE;
nVal = GetPrivateProfileInt("System","Deblocking", 0, chINIPath);
g_bDeblocking = (nVal != 0);
nVal = GetPrivateProfileInt("System","AVNonSync", 0, chINIPath);
if (nVal == 1)
g_dwInitOpt |= AV_DONT_SYNC;
nVal = GetPrivateProfileInt("System","ImageSize", 0, chINIPath);
if (nVal == 1)
g_nImageSize = 1;
else if (nVal == 2)
g_nImageSize = 2;
nVal = GetPrivateProfileInt("System","SnapAll", 0, chINIPath);
if (nVal == 1)
g_bSnapAllChannel = TRUE;
if (g_dwLayout > 1)
g_dwLayout = 1;
char chSection[16];
nVal = GetPrivateProfileInt("System","MaxDecoderFileNum", 50, chINIPath);
if (nVal > 500)
g_nMaxDecoderFileNum = 500;
else if (nVal < 1)
g_nMaxDecoderFileNum = 1;
else
g_nMaxDecoderFileNum = nVal;
nVal = GetPrivateProfileInt("System","DecoderChannel", 0, chINIPath);
if (nVal)
g_bDecoderChannel = TRUE;
g_nDecoderMedia = GetPrivateProfileInt("System","DecoderMedia", 1, chINIPath);
if (g_nDecoderMedia < 1)
g_nDecoderMedia = 1;
if (g_nDecoderMedia > 3)
g_nDecoderMedia = 3;
nVal = GetPrivateProfileInt("System","AutoForceI", 0, chINIPath);
if (nVal)
g_bAutoForceI = TRUE;
g_nForcePeriod = GetPrivateProfileInt("System","ForcePeriod", 0, chINIPath);
nVal = GetPrivateProfileInt("System","ShowQueueFull", 0, chINIPath);
if (nVal)
g_bShowQueueFull = TRUE;
g_dwShowDZWnd = GetPrivateProfileInt("System","DigitalZoomWnd", 6, chINIPath);
nVal = GetPrivateProfileInt("System","DecoderVideoType", 6, chINIPath);
if (nVal == 1)
{
// YUY2
strcpy(g_szExtName, "yuv");
g_nDecoderAskType = PF_YUY2;
}
else if (nVal == 2)
{
// RGB16565
strcpy(g_szExtName, "rgb");
g_nDecoderAskType = PF_RGB16565;
}
else if (nVal == 3)
{
// PF_RGB24
strcpy(g_szExtName, "rgb");
g_nDecoderAskType = PF_RGB24;
}
else if (nVal == 4)
{
// PF_RGB32
strcpy(g_szExtName, "rgb");
g_nDecoderAskType = PF_RGB32;
}
else if (nVal == 5)
{
// PF_BMP16565
strcpy(g_szExtName, "bmp");
g_nDecoderAskType = PF_BMP16565;
}
else if (nVal == 7)
{
// PF_BMP32
strcpy(g_szExtName, "bmp");
g_nDecoderAskType = PF_BMP32;
}
else if (nVal == 8)
{
// PF_JPEG
strcpy(g_szExtName, "jpg");
g_nDecoderAskType = PF_JPEG;
}
else if (nVal == 9)
{
// PF_RGB16555
strcpy(g_szExtName, "rgb");
g_nDecoderAskType = PF_RGB16555;
}
else if (nVal == 10)
{
// PF_BMP16555
strcpy(g_szExtName, "bmp");
g_nDecoderAskType = PF_BMP16555;
}
else if (nVal == 11)
{
// PF_YUV
strcpy(g_szExtName, "yuv");
g_nDecoderAskType = PF_YUV;
}
else
{
// PF_BMP24
strcpy(g_szExtName, "bmp");
g_nDecoderAskType = PF_BMP24;
}
GetPrivateProfileString("System", "Proxy", "", g_szProxy, 256, chINIPath);
g_nProxyPort = GetPrivateProfileInt("System", "ProxyPort", 3128, chINIPath);
GetPrivateProfileString("System", "PackageFile", "", g_szPkgFile, sizeof(g_szPkgFile), chINIPath);
nVal = GetPrivateProfileInt("System","TestPacketMaker", 0, chINIPath);
g_bTestPacketMaker = (nVal != 0 && g_bDecoderChannel && (g_nDecoderMedia & 1) &&
(g_nDecoderAskType == PF_JPEG));
g_nAVRawCCB = GetPrivateProfileInt("System","AVCBRawCallback", 0, chINIPath);
g_nAVRawCCB &= 3;
nVal = GetPrivateProfileInt("System","AVCBVideoRawType", 6, chINIPath);
if (nVal == 1)
{
// YUY2
strcpy(g_szAVCBExtName, "yuv");
g_nAVRawDBAskType = PF_YUY2;
}
else if (nVal == 2)
{
// RGB16565
strcpy(g_szAVCBExtName, "rgb");
g_nAVRawDBAskType = PF_RGB16565;
}
else if (nVal == 3)
{
// PF_RGB24
strcpy(g_szAVCBExtName, "rgb");
g_nAVRawDBAskType = PF_RGB24;
}
else if (nVal == 4)
{
// PF_RGB32
strcpy(g_szAVCBExtName, "rgb");
g_nAVRawDBAskType = PF_RGB32;
}
else if (nVal == 5)
{
// PF_BMP16565
strcpy(g_szAVCBExtName, "bmp");
g_nAVRawDBAskType = PF_BMP16565;
}
else if (nVal == 7)
{
// PF_BMP32
strcpy(g_szAVCBExtName, "bmp");
g_nAVRawDBAskType = PF_BMP32;
}
else if (nVal == 8)
{
// PF_JPEG
strcpy(g_szAVCBExtName, "jpg");
g_nAVRawDBAskType = PF_JPEG;
}
else if (nVal == 9)
{
// PF_RGB16555
strcpy(g_szAVCBExtName, "rgb");
g_nAVRawDBAskType = PF_RGB16555;
}
else if (nVal == 10)
{
// PF_BMP16555
strcpy(g_szAVCBExtName, "bmp");
g_nAVRawDBAskType = PF_BMP16555;
}
else if (nVal == 11)
{
// PF_YUV
strcpy(g_szAVCBExtName, "yuv");
g_nAVRawDBAskType = PF_YUV;
}
else
{
// PF_BMP24
strcpy(g_szAVCBExtName, "bmp");
g_nAVRawDBAskType = PF_BMP24;
}
nVal = GetPrivateProfileInt("System","AVCBUseOwnBuffer", 0, chINIPath);
if (nVal)
g_bAVRawCBOwnBuf = TRUE;
nVal = GetPrivateProfileInt("System","AVCBWriteFile", 0, chINIPath);
if (nVal)
g_bAVRawCBWriteFile = TRUE;
if (g_nMaxChannel < 1)
g_nMaxChannel = 4;
else if (g_nMaxChannel > 16)
g_nMaxChannel = 16;
if (g_nMaxChannel != 1 && g_nMaxChannel != 2 && g_nMaxChannel != 4 && g_nMaxChannel != 6 &&
g_nMaxChannel != 9 && g_nMaxChannel != 16)
g_nMaxChannel = 4;
for ( int i=0; i < g_nMaxChannel ; i++ )
{
sprintf(chSection,"Channel_%d",i+1);
GetPrivateProfileString(chSection,"Host_IP",NULL,g_Channel_Info[i].chHostIP,sizeof(g_Channel_Info[i].chHostIP),chINIPath);
GetPrivateProfileString(chSection,"User_Name",NULL,g_Channel_Info[i].chUserName,sizeof(g_Channel_Info[i].chUserName),chINIPath);
GetPrivateProfileString(chSection,"Password",NULL,g_Channel_Info[i].chPassword,sizeof(g_Channel_Info[i].chPassword),chINIPath);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -