📄 voiceexchange.cpp
字号:
// VoiceExchange.cpp : implementation file
//
#include "stdafx.h"
#include "newclient.h"
#include "VoiceExchange.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CVoiceExchange dialog
extern SERVER_INFO serverinfo[MAXIPNUMBER];
LONG lVoiceIndex = -1;
HANDLE hSendFile = NULL;
HANDLE hRevFile = NULL;
DWORD dwReturn = 0;
CONST BYTE FileHeader[40] = {0x34,0x48,0x4B,0x48,0xFE,0xB3,0xD0,0xD6,0x08,0x03,0x04,0x20,0x00,0x00,0x00,0x00,
0x02,0x10,0x01,0x10,0x01,0x10,0x10,0x00,0x80,0x3E,0x00,0x00,0x60,0x01,0x20,0x01,
0x11,0x10,0x00,0x00,0x00,0x00,0x00,0x00};
//byAudioFlag = 0 means voice data from sound card
//byAudioFlag = 1 means voice data from DVRDVS
void CALLBACK fVoiceDataCallBack(LONG lVoiceComHandle,char *pRecvDataBuffer,DWORD dwBufSize,BYTE byAudioFlag,DWORD dwUser)
{
if(byAudioFlag == 0)
{
if(hSendFile)
{
WriteFile(hSendFile, pRecvDataBuffer, dwBufSize, &dwReturn, NULL);
}
}
else if(byAudioFlag == 1)
{
if(hRevFile)
{
WriteFile(hRevFile, pRecvDataBuffer, dwBufSize, &dwReturn, NULL);
}
}
}
CVoiceExchange::CVoiceExchange(CWnd* pParent /*=NULL*/)
: CDialog(CVoiceExchange::IDD, pParent)
{
//{{AFX_DATA_INIT(CVoiceExchange)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CVoiceExchange::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CVoiceExchange)
DDX_Control(pDX, IDC_COMBOAUDEXCH, m_ServerCtrl);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CVoiceExchange, CDialog)
//{{AFX_MSG_MAP(CVoiceExchange)
ON_BN_CLICKED(IDC_AUDSTART, OnAudstart)
ON_CBN_SELCHANGE(IDC_COMBOAUDEXCH, OnSelchangeComboaudexch)
ON_BN_CLICKED(IDEXIT, OnExit)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CVoiceExchange message handlers
BOOL CVoiceExchange::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
int i, iNum;
m_ServerCtrl.InsertString(0,"Please select DVR");
for(i = 0; i < MAXIPNUMBER; i++)
{
if(serverinfo[i].m_iServerChannelNumber >= 0)
{
iNum = m_ServerCtrl.AddString(serverinfo[i].m_csServerName);
m_ServerCtrl.SetItemData(iNum, i);
}
}
m_ServerCtrl.SetCurSel(0);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CVoiceExchange::OnAudstart()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if(m_ServerCtrl.GetCurSel()==0)
{
AfxMessageBox("Please select DVR!");
return;
}
/*
if(NET_DVR_ClientAudioStart())
{
AfxMessageBox("Voice broadcast succeed!");
}
else
{
AfxMessageBox("Voice broadcast failed!");
}
*/ if(lVoiceIndex >= 0)
{
if(NET_DVR_StopVoiceCom(lVoiceIndex))
{
lVoiceIndex = -1;
}
else
{
AfxMessageBox("Please close voice dialogue!");
return;
}
}
lVoiceIndex = NET_DVR_StartVoiceCom(m_lServerID, NULL, 0);
if(lVoiceIndex == -1)
{
CString sTemp;
sTemp.Format("ERROR: NET_DVR_StartVoiceCom = %d \n", NET_DVR_GetLastError());
TRACE(sTemp);
AfxMessageBox("Voice dialogue failed!");
return ;
}
else
{
AfxMessageBox("Voice dialogue succeed!");
}
}
void CVoiceExchange::OnSelchangeComboaudexch()
{
// TODO: Add your control notification handler code here
int i,ipnum;
i = m_ServerCtrl.GetCurSel();
if(i >= 1)
{
ipnum = m_ServerCtrl.GetItemData(i);
m_lServerID = serverinfo[ipnum].m_lServerID;
}
UpdateData(FALSE);
}
void CVoiceExchange::OnExit()
{
// TODO: Add your control notification handler code here
/* if(NET_DVR_ClientAudioStop())
{
AfxMessageBox("Stop voice broadcast succeed!");
}
else
{
AfxMessageBox("Stop voice broadcast failed!");
}
*/ CDialog::OnCancel();
}
void CVoiceExchange::OnCancel()
{
// TODO: Add extra cleanup here
// CDialog::OnCancel();
}
void CVoiceExchange::OnButton1()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if(m_ServerCtrl.GetCurSel()==0)
{
AfxMessageBox("Please select DVR!");
return;
}
NET_DVR_AddDVR(m_lServerID);
}
void CVoiceExchange::OnButton2()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if(m_ServerCtrl.GetCurSel()==0)
{
AfxMessageBox("Please select DVR!");
return;
}
NET_DVR_DelDVR(m_lServerID);
}
void CVoiceExchange::OnOK()
{
// TODO: Add extra cleanup here
// CDialog::OnOK();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -