Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Simple Voice Chat

0.00/5 (No votes)
19 Jan 2002 1  
A simple peer to peer voice chat application using sockets

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)
    //{{AFX_EVENTSINK_MAP(COVoiceChattClientDlg)

    ON_EVENT(COVoiceChattClientDlg, IDC_OVOICECHATTCTRL1, 1 /* GetVoiceInvitation */, \
                 OnGetVoiceInvitation, VTS_BSTR VTS_BSTR)
    ON_EVENT(COVoiceChattClientDlg, IDC_OVOICECHATTCTRL1, 2 /* GetReqStatus */, \
                 OnGetReqStatus, VTS_I4)
    ON_EVENT(COVoiceChattClientDlg, IDC_OVOICECHATTCTRL1, 3 /* GetVoiceEndNotice */, \
                 OnGetVoiceEndNoticeOvoicechattctrl1, VTS_NONE)
    //}}AFX_EVENTSINK_MAP

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");       
}

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here