Introduction
This is a simple voice chat program implemented in an ActiveX control (OVoiceChatt
Control) using windows sockets in non compressed PCM format. You just need to
give your name and the IP address of the computer on which you want to establish
a voice chat session.
There is a simple test application (OVoiceChattClient) which has implemented
the control.
Run the OVoiceChatClient.exe and enter you name and the ip address of the
computer same application should be running on that computer as well. .A request
for the voice chat goes to that computer and if that person accepts it then the
voice chat starts.
To use in a program.
Below is some sample code that demonstrates using the control in your code.
In the header:
COVoiceChatt m_ctlVoice;
In the implementation:
BEGIN_EVENTSINK_MAP(COVoiceChattClientDlg, CDialog)
ON_EVENT(COVoiceChattClientDlg, IDC_OVOICECHATTCTRL1, 1 , \
OnGetVoiceInvitation, VTS_BSTR VTS_BSTR)
ON_EVENT(COVoiceChattClientDlg, IDC_OVOICECHATTCTRL1, 2 , \
OnGetReqStatus, VTS_I4)
ON_EVENT(COVoiceChattClientDlg, IDC_OVOICECHATTCTRL1, 3 , \
OnGetVoiceEndNoticeOvoicechattctrl1, VTS_NONE)
END_EVENTSINK_MAP()
void COVoiceChattClientDlg::OnGetVoiceInvitation(LPCTSTR ip, LPCTSTR nick)
{
m_ip=ip;
CString str=nick;
str+=" wants to have voice chat with you";
if(AfxMessageBox(str,MB_YESNO)==IDYES)
{
m_ctlVoice.OVoiceInvStatus(1,ip);
}
else
m_ctlVoice.OVoiceInvStatus(0,ip);
}
void COVoiceChattClientDlg::OnGetReqStatus(long status)
{
if(status==0)
AfxMessageBox("request rejected");
else
{
m_strStatus="Connecting";
UpdateData(FALSE);
}
}
void COVoiceChattClientDlg::OnButton1()
{
m_ctlVoice.OVoiceInit();
}
void COVoiceChattClientDlg::OnButtonEnd()
{
m_ctlVoice.OVoiceEnd();
}
void COVoiceChattClientDlg::OnGetVoiceEndNoticeOvoicechattctrl1()
{
AfxMessageBox("Voice Conversation Has Been Ended");
}