📄 visconfdlg.cpp
字号:
//For general setup
m_pep->SetUserName(config.GetString(KEY_USER_NAME,""),config.GetString(KEY_ALIAS,""));
m_pep->SetMaxConnection(config.GetInteger(KEY_MAX_CONN,10000));
m_pep->SetNoAnswerTimeout(config.GetInteger(KEY_NO_ANSWER_TIMEOUT,60));
//For audio setup
m_pep->SetMaxAudioDelayJitter(0,config.GetInteger(KEY_JITTER_BUFFER,60));
m_pep->SetPreferredAudioCodec(config.GetInteger(KEY_PREFERRED_CODEC,0));
m_pep->SetSilenceDetectionMode(0,(enum SilenceDetectionMode)config.GetInteger(KEY_SILENCE_DETECTION,NoSilenceDetection),
config.GetInteger(KEY_THRESHOLD,0));
//For video setup
m_pep->AutoSendVideo(config.GetBoolean(KEY_AUTO_SEND_VIDEO,FALSE));
m_pep->SetVideoSize(0,(enum VideoFormat)config.GetInteger(KEY_TRANSMIT_FORMAT,VS_QCIF));
m_pep->SetVideoQuality(0,config.GetInteger(KEY_VIDEO_QUALITY,50));
//For network setup
m_pep->SetInitialBandwidth(config.GetInteger(KEY_BANDWIDTH,10000000));
Output("Initial bandwidth set to %d kbps",config.GetInteger(KEY_BANDWIDTH,10000000)/1000);
m_pep->EnableFastStart(config.GetBoolean(KEY_FASTSTART,TRUE));
Output("Fast-start %s",config.GetBoolean(KEY_FASTSTART,TRUE)?"Enabled":"Disabled");
m_pep->EnableH245Tunnel(config.GetBoolean(KEY_H245TUNNEL,TRUE));
Output("H245 tunnel %s",config.GetBoolean(KEY_H245TUNNEL,TRUE)?"Enabled":"Disabled");
m_pep->EnableH245inSetup(config.GetBoolean(KEY_H245INSETUP,TRUE));
Output("H245 in setup %s",config.GetBoolean(KEY_H245INSETUP,TRUE)?"Enabled":"Disabled");
//Leave first parameter NULL to listen on all IP interface available
if(!m_pep->StartListen(NULL,config.GetInteger(KEY_LISTEN_PORT,1720)))
goto RET;
Output("Endpoint listened on port:%d",config.GetInteger(KEY_LISTEN_PORT,1720));
if(config.GetBoolean(KEY_REGISTER_GK,FALSE))
{
CString GKAddr;
CString Password;
config.GetString(KEY_H235PASSWORD,"");
if(!config.GetBoolean(KEY_AUTO_SEARCH_GK,TRUE))
{
GKAddr=config.GetString(KEY_ADDRESS_GK,"");
}
if(m_pep->UseGatekeeper(GKAddr,Password))
{
Output("Try registering with Gatekeeper");
m_StatusBar.SetText("Try registering with gatekeeper",2,0);
}
}
else
{
m_StatusBar.SetText("No gatekeeper",2,0);
}
bRet=TRUE;
RET:
if(!bRet)
{
//Fatal error occured, quit
AfxMessageBox("Failed to initialise H.323 endpoint!",MB_OK|MB_ICONSTOP);
PostQuitMessage(0);
}
return bRet;
}
//Network setup
void CVISConfDlg::OnNetwork()
{
CSetupNetworkDlg dlg;
CConfig config;
//
dlg.m_Bandwidth=m_pep->GetInitialBandwidth()/1000;
dlg.m_Port=config.GetInteger(KEY_LISTEN_PORT,1720);
dlg.m_Faststart=config.GetBoolean(KEY_FASTSTART,TRUE);
dlg.m_H245tunnel=config.GetBoolean(KEY_H245TUNNEL,TRUE);
dlg.m_h245inSetup=config.GetBoolean(KEY_H245INSETUP,TRUE);
dlg.m_RegisterGK=config.GetBoolean(KEY_REGISTER_GK,FALSE);
dlg.m_AutoSearch=config.GetBoolean(KEY_AUTO_SEARCH_GK,TRUE);
dlg.m_Locate=!dlg.m_AutoSearch;
dlg.m_Address=config.GetString(KEY_ADDRESS_GK,"");
dlg.m_Password=config.GetString(KEY_H235PASSWORD,"");
if(dlg.DoModal()==IDOK)
{
m_pep->SetInitialBandwidth(dlg.m_Bandwidth*1000);
//Try to listen on new port.
if(m_pep->StartListen(NULL,dlg.m_Port))
{
Output("Endpoint listened on port:%d",dlg.m_Port);
}
m_pep->EnableFastStart(dlg.m_Faststart);
Output("Fast-start %s",dlg.m_Faststart?"Enabled":"Disabled");
m_pep->EnableH245Tunnel(dlg.m_H245tunnel);
Output("H245 tunnel %s",dlg.m_H245tunnel?"Enabled":"Disabled");
m_pep->EnableH245inSetup(dlg.m_h245inSetup);
Output("H245 in setup %s",dlg.m_h245inSetup?"Enabled":"Disabled");
if(dlg.m_RegisterGK)
{
//Try to find GK
CString GKAddr;
if(!dlg.m_AutoSearch)
{
GKAddr=dlg.m_Address;
}
//If the function succeeds, CH323EndPoint::OnUserGatekeeper will be fired
//when GK found or failed.
if(m_pep->UseGatekeeper(GKAddr,dlg.m_Password))
{
Output("Try registering with Gatekeeper");
m_StatusBar.SetText("Try registering with gatekeeper",2,0);
}
}
else
{
//Try to unuse GK
char name[256]="";
m_pep->GetGateKeeperName(name,256);
if(m_pep->UnuseGatekeeper())
{
Output("Unregistered with gatekeeper \"%s\"",name);
m_StatusBar.SetText("No gatekeeper",2,0);
}
}
config.SetInteger(KEY_BANDWIDTH,m_pep->GetInitialBandwidth());
Output("Initial bandwidth set to %d kbps",m_pep->GetInitialBandwidth()/1000);
config.SetInteger(KEY_LISTEN_PORT,dlg.m_Port);
config.SetBoolean(KEY_FASTSTART,dlg.m_Faststart);
config.SetBoolean(KEY_H245TUNNEL,dlg.m_H245tunnel);
config.SetBoolean(KEY_H245INSETUP,dlg.m_h245inSetup);
config.SetBoolean(KEY_REGISTER_GK,dlg.m_RegisterGK);
config.SetBoolean(KEY_AUTO_SEARCH_GK,dlg.m_AutoSearch);
config.SetString(KEY_ADDRESS_GK,dlg.m_Address);
config.SetString(KEY_H235PASSWORD,dlg.m_Password);
}
}
//Audio setup
void CVISConfDlg::OnAudio()
{
CSetupAudioDlg dlg;
CConfig config;
dlg.m_inputDevice=config.GetInteger(KEY_AUDIO_INPUT_DEVICE,0);
dlg.m_outputDevice=config.GetInteger(KEY_AUDIO_OUTPUT_DEVICE,0);
m_pep->GetMaxAudioDelayJitter(0,(DWORD&)dlg.m_jitter);
dlg.m_sendLocalVoice=config.GetBoolean(KEY_SEND_LOCAL_VOICE,TRUE);
dlg.m_playReceivedVoice=config.GetBoolean(KEY_PLAY_RECEIVED_VOICE,TRUE);
dlg.m_preferredCodec=m_pep->GetPreferredAudioCodec();
m_pep->GetSilenceDetectionMode(0,(enum SilenceDetectionMode&)dlg.m_silenceDtct,(DWORD&)dlg.m_threshold);
if(dlg.DoModal()==IDOK)
{
config.SetInteger(KEY_AUDIO_INPUT_DEVICE,dlg.m_inputDevice);
config.SetInteger(KEY_AUDIO_OUTPUT_DEVICE,dlg.m_outputDevice);
m_pep->SetMaxAudioDelayJitter(0,dlg.m_jitter);
config.SetInteger(KEY_JITTER_BUFFER,dlg.m_jitter);
config.SetBoolean(KEY_SEND_LOCAL_VOICE,dlg.m_sendLocalVoice);
config.SetBoolean(KEY_PLAY_RECEIVED_VOICE,dlg.m_playReceivedVoice);
//
if(m_pep->m_AudioMixer.GetChannelCount(TRUE)>0)
{
if(dlg.m_sendLocalVoice)
m_pep->StartLocalAudio();
else
m_pep->StopLocalAudio();
}
if(m_pep->m_AudioMixer.GetChannelCount(FALSE)>0)
{
if(dlg.m_playReceivedVoice)
m_pep->StartRemoteAudio();
else
m_pep->StopRemoteAudio();
}
m_pep->SetPreferredAudioCodec(dlg.m_preferredCodec);
config.SetInteger(KEY_PREFERRED_CODEC,dlg.m_preferredCodec);
config.SetInteger(KEY_SILENCE_DETECTION,dlg.m_silenceDtct);
config.SetInteger(KEY_THRESHOLD,dlg.m_threshold);
m_pep->SetSilenceDetectionMode(0,(enum SilenceDetectionMode)dlg.m_silenceDtct,dlg.m_threshold);
}
}
//Video setup
void CVISConfDlg::OnVideo()
{
CSetupVideoDlg dlg;
CConfig config;
dlg.m_device=config.GetInteger(KEY_VIDEO_INPUT_DEVICE,0);
dlg.m_useDirectshow=config.GetBoolean(KEY_USE_DIRECTSHOW,FALSE);
dlg.m_autoSendVideo=config.GetBoolean(KEY_AUTO_SEND_VIDEO,FALSE);
dlg.m_sendLocalVideo=config.GetBoolean(KEY_SEND_LOCAL_VIDEO,TRUE);
dlg.m_captureFormat=config.GetInteger(KEY_CAPTURE_FORMAT,VS_QCIF)==VS_QCIF?0:1;
dlg.m_captureFPS=config.GetInteger(KEY_CAPTURE_FPS,10);
m_pep->GetVideoSize(0,(enum VideoFormat&)dlg.m_transmitFormat);
dlg.m_transmitFormat=(dlg.m_transmitFormat==VS_QCIF)?0:1;
dlg.m_transmitFPS=config.GetInteger(KEY_TRANSMIT_FPS,10);
m_pep->GetVideoQuality(0,(DWORD&)dlg.m_quality);
if(dlg.DoModal()==IDOK)
{
config.SetInteger(KEY_VIDEO_INPUT_DEVICE,dlg.m_device);
config.SetInteger(KEY_USE_DIRECTSHOW,dlg.m_useDirectshow);
m_pep->m_VideoGrabber.SetGrabberMode(dlg.m_useDirectshow?VG_DS:VG_VFW);
config.SetBoolean(KEY_AUTO_SEND_VIDEO,dlg.m_autoSendVideo);
m_pep->AutoSendVideo(dlg.m_autoSendVideo);
config.SetBoolean(KEY_SEND_LOCAL_VIDEO,dlg.m_sendLocalVideo);
if(dlg.m_sendLocalVideo)
{
if(m_pep->m_VideoGrabber.IsOpened())
{
m_pep->m_VideoMixer.AddChannel(0,FALSE);
}
}
else
m_pep->m_VideoMixer.RemoveChannel(0,FALSE);
config.SetInteger(KEY_CAPTURE_FORMAT,dlg.m_captureFormat==0?VS_QCIF:VS_CIF);
if(m_pep->m_VideoGrabber.IsOpened())
{
int w=176,h=144;
if(dlg.m_captureFormat==1)
{
w=352;
h=288;
}
m_pep->m_VideoGrabber.StartStream(w,h);
}
config.SetInteger(KEY_CAPTURE_FPS,dlg.m_captureFPS);
config.SetInteger(KEY_TRANSMIT_FORMAT,dlg.m_transmitFormat==0?VS_QCIF:VS_CIF);
m_pep->SetVideoSize(0,dlg.m_transmitFormat==0?VS_QCIF:VS_CIF);
config.SetInteger(KEY_TRANSMIT_FPS,dlg.m_transmitFPS);
config.SetInteger(KEY_VIDEO_QUALITY,dlg.m_quality);
m_pep->SetVideoQuality(0,dlg.m_quality);
}
}
void CVISConfDlg::OnLogOutput()
{
if(m_LogOutputDlg.IsWindowVisible())
m_LogOutputDlg.ShowWindow(SW_HIDE);
else
m_LogOutputDlg.ShowWindow(SW_SHOW);
CMenu *menu =GetMenu();
if(menu)
{
menu->CheckMenuItem(ID_LOG_OUTPUT,MF_BYCOMMAND|(m_LogOutputDlg.IsWindowVisible()?MF_CHECKED:MF_UNCHECKED));
}
}
//Output to log window
void CVISConfDlg::Output(const char *output,...)
{
CString out;
va_list argList;
va_start(argList, output);
out.FormatV(output,argList);
m_LogOutputDlg.Output(out);
}
void CVISConfDlg::OnProperties()
{
int index=m_MemberList.GetNextItem(-1,LVNI_SELECTED);
if(index>=0)
{
DWORD connID=m_MemberList.GetItemData(index);
m_PropertiesDlg.m_connID=connID;
if(m_PropertiesDlg.DoModal()==IDOK)
{
//do nothing here
}
}
}
//Double click on member list
void CVISConfDlg::OnDblclkMemberlist(NMHDR* pNMHDR, LRESULT* pResult)
{
OnProperties();
*pResult = 0;
}
//Pop-up menu command
void CVISConfDlg::OnStartSendAudio()
{
int index=m_MemberList.GetNextItem(-1,LVNI_SELECTED);
if(index>=0)
{
DWORD connID=m_MemberList.GetItemData(index);
if(m_pep->m_AudioMixer.ChannelExist(connID,TRUE))
m_pep->StopSendAudio(connID);
else
m_pep->StartSendAudio(connID);
}
}
//Pop-up menu command
void CVISConfDlg::OnHoldSendAudio()
{
int index=m_MemberList.GetNextItem(-1,LVNI_SELECTED);
if(index>=0)
{
DWORD connID=m_MemberList.GetItemData(index);
m_pep->HoldAudio(connID,TRUE,!m_pep->IsAudioHold(connID,TRUE));
}
}
//Pop-up menu command
void CVISConfDlg::OnHoldReceiveAudio()
{
int index=m_MemberList.GetNextItem(-1,LVNI_SELECTED);
if(index>=0)
{
DWORD connID=m_MemberList.GetItemData(index);
m_pep->HoldAudio(connID,FALSE,!m_pep->IsAudioHold(connID,FALSE));
}
}
//Pop-up menu command
void CVISConfDlg::OnStartSendVideo()
{
int index=m_MemberList.GetNextItem(-1,LVNI_SELECTED);
if(index>=0)
{
DWORD connID=m_MemberList.GetItemData(index);
if(m_pep->m_VideoMixer.ChannelExist(connID,TRUE))
m_pep->StopSendVideo(connID);
else
m_pep->StartSendVideo(connID);
}
}
//Pop-up menu command
void CVISConfDlg::OnHoldReceiveVideo()
{
int index=m_MemberList.GetNextItem(-1,LVNI_SELECTED);
if(index>=0)
{
DWORD connID=m_MemberList.GetItemData(index);
m_pep->HoldVideo(connID,FALSE,!m_pep->IsVideoHold(connID,FALSE));
}
}
//Pop-up menu command
void CVISConfDlg::OnHoldSendVideo()
{
int index=m_MemberList.GetNextItem(-1,LVNI_SELECTED);
if(index>=0)
{
DWORD connID=m_MemberList.GetItemData(index);
m_pep->HoldVideo(connID,TRUE,!m_pep->IsVideoHold(connID,TRUE));
}
}
//Pop-up menu command
void CVISConfDlg::OnFlipxReceiveVideo()
{
int index=m_MemberList.GetNextItem(-1,LVNI_SELECTED);
if(index>=0)
{
DWORD connID=m_MemberList.GetItemData(index);
BOOL x,y;
m_pep->m_VideoMixer.GetVideoFlip(connID,FALSE,x,y);
m_pep->m_VideoMixer.SetVideoFlip(connID,FALSE,!x,y);
}
}
//Pop-up menu command
void CVISConfDlg::OnFlipxSendVideo()
{
int index=m_MemberList.GetNextItem(-1,LVNI_SELECTED);
if(index>=0)
{
DWORD connID=m_MemberList.GetItemData(index);
BOOL x,y;
m_pep->m_VideoMixer.GetVideoFlip(connID,TRUE,x,y);
m_pep->m_VideoMixer.SetVideoFlip(connID,TRUE,!x,y);
}
}
//Pop-up menu command
void CVISConfDlg::OnFlipyReceiveVideo()
{
int index=m_MemberList.GetNextItem(-1,LVNI_SELECTED);
if(index>=0)
{
DWORD connID=m_MemberList.GetItemData(index);
BOOL x,y;
m_pep->m_VideoMixer.GetVideoFlip(connID,FALSE,x,y);
m_pep->m_VideoMixer.SetVideoFlip(connID,FALSE,x,!y);
}
}
//Pop-up menu command
void CVISConfDlg::OnFlipySendVideo()
{
int index=m_MemberList.GetNextItem(-1,LVNI_SELECTED);
if(index>=0)
{
DWORD connID=m_MemberList.GetItemData(index);
BOOL x,y;
m_pep->m_VideoMixer.GetVideoFlip(connID,TRUE,x,y);
m_pep->m_VideoMixer.SetVideoFlip(connID,TRUE,x,!y);
}
}
void CVISConfDlg::OnItemclickMemberlist(NMHDR* pNMHDR, LRESULT* pResult)
{
HD_NOTIFY *phdn = (HD_NOTIFY *) pNMHDR;
// TODO: Add your control notification handler code here
//It doesn't work here,maybe MFC bug
*pResult = 0;
}
int CALLBACK CVISConfDlg::CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParam)
{
DWORD *param=(DWORD*)lParam;
CVISConfDlg *dlg=(CVISConfDlg*)param[0];
int item=param[1];
BOOL sort=param[2];
int index1,index2;
LVFINDINFO lfi;
lfi.flags=LVFI_PARAM;
lfi.lParam=lParam1;
index1=dlg->m_MemberList.FindItem(&lfi);
lfi.lParam=lParam2;
index2=dlg->m_MemberList.FindItem(&lfi);
if(index1>=0&&index2>=0)
{
CString txt1,txt2;
txt1=dlg->m_MemberList.GetItemText(index1,item);
txt2=dlg->m_MemberList.GetItemText(index2,item);
return sort?txt1.Compare(txt2):-txt1.Compare(txt2);
}
return 0;
}
BOOL CVISConfDlg::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
// TODO: Add your specialized code here and/or call the base class
LPNMHDR hdr=(LPNMHDR)lParam;
if(hdr->hwndFrom==m_MemberList.GetHeaderCtrl()->GetSafeHwnd()&&
hdr->code==HDN_ITEMCLICK)
{
int item=((LPNMHEADER) lParam)->iItem;
BOOL sort=m_sort[item];
m_sort[0]=FALSE;
m_sort[1]=FALSE;
m_sort[2]=FALSE;
m_sort[item]=!sort;
DWORD param[3];
param[0]=(DWORD)this;
param[1]=item;
param[2]=sort;
m_MemberList.SortItems(CompareFunc,(DWORD)param);
}
return CDialog::OnNotify(wParam, lParam, pResult);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -