Click here to Skip to main content
15,883,531 members
Articles / Desktop Programming / MFC
Article

Simple Voice Chat

Rate me:
Please Sign up or sign in to vote.
3.54/5 (12 votes)
19 Jan 2002 484.3K   16.5K   64   56
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


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralRe: cannot open file "mfc42u.lib" Pin
h02145783-Nov-04 5:31
h02145783-Nov-04 5:31 
GeneralQuestion abt executable file Pin
7-Mar-02 0:37
suss7-Mar-02 0:37 
GeneralThe same projects need Pin
21-Feb-02 2:38
suss21-Feb-02 2:38 
Generalthank imran lodhi Pin
sinomaverick2-Feb-02 13:48
sinomaverick2-Feb-02 13:48 
Generalthanx for the code Pin
24-Jan-02 2:44
suss24-Jan-02 2:44 
GeneralRe: thanx for the code Pin
28-Jan-02 5:20
suss28-Jan-02 5:20 
GeneralRe: thanx for the code Pin
sinomaverick2-Feb-02 15:39
sinomaverick2-Feb-02 15:39 
GeneralSame problem Please solutions... Pin
19-Mar-02 2:02
suss19-Mar-02 2:02 
How did you manage the error " cannot open voice input device" ?

I have the same problem?

Where do I make mistakes?

How did you deal with it? thank you!


GeneralRun Problems Pin
Ed Dixon21-Jan-02 12:24
Ed Dixon21-Jan-02 12:24 
GeneralRe: Run Problems Pin
17-Mar-02 21:47
suss17-Mar-02 21:47 
GeneralI also have link errors Pin
Selevercin21-Jan-02 9:18
Selevercin21-Jan-02 9:18 
GeneralRe: I also have link errors Pin
21-Jan-02 9:38
suss21-Jan-02 9:38 
GeneralIt's easy Pin
28-Jan-02 20:14
suss28-Jan-02 20:14 
Generallink errors Pin
20-Jan-02 22:43
suss20-Jan-02 22:43 
GeneralRe: link errors Pin
21-Jan-02 0:47
suss21-Jan-02 0:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.