Click here to Skip to main content
15,886,638 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.4K   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

 
QuestionHow OCX control into win32 aPP Pin
mmarmar2-Jul-03 22:01
mmarmar2-Jul-03 22:01 
GeneralPl Help to run this app Pin
dharani11-Jun-03 20:45
dharani11-Jun-03 20:45 
General[Q] error code... Pin
hss04217-Apr-03 4:56
hss04217-Apr-03 4:56 
GeneralRe: [Q] error code... Pin
haogege8-Mar-04 15:03
haogege8-Mar-04 15:03 
Generalresend the whole project Pin
anuvignesh4-Mar-03 1:02
anuvignesh4-Mar-03 1:02 
GeneralVB Pin
gsharf27-Dec-02 21:58
gsharf27-Dec-02 21:58 
GeneralCannot open output device in NT, works in 2000 Pin
Anonymous6-Aug-02 0:57
Anonymous6-Aug-02 0:57 
GeneralRe: Cannot open output device in NT, works in 2000 Pin
Anonymous22-Aug-02 21:07
Anonymous22-Aug-02 21:07 
i am also getting this problem on windows NT
GeneralProblem in running the voice chatt Pin
Anonymous5-Aug-02 20:06
Anonymous5-Aug-02 20:06 
QuestionHow to handle "Cannot Open Sound Input Device" Pin
13-Jun-02 23:48
suss13-Jun-02 23:48 
GeneralInstant Messanger Pin
29-May-02 23:29
suss29-May-02 23:29 
GeneralRe: Instant Messanger Pin
Member 443557825-Aug-08 2:40
Member 443557825-Aug-08 2:40 
Generalthanks,how to work with the Execute file?(yanbiao) Pin
29-May-02 19:16
suss29-May-02 19:16 
GeneralRe: thanks,how to work with the Execute file?(yanbiao) Pin
ComVexd22-Jun-04 15:28
ComVexd22-Jun-04 15:28 
GeneralNeed client TCP in C++ for windows Pin
20-Apr-02 8:07
suss20-Apr-02 8:07 
Generalcannot open file "mfc42u.lib" Pin
20-Apr-02 4:04
suss20-Apr-02 4:04 
GeneralRe: cannot open file "mfc42u.lib" Pin
Robert.H17-Nov-03 17:34
Robert.H17-Nov-03 17:34 
GeneralRe: cannot open file "mfc42u.lib" Pin
Anonymous13-Feb-04 3:51
Anonymous13-Feb-04 3:51 
GeneralRe: cannot open file "mfc42u.lib" Pin
haogege8-Mar-04 14:59
haogege8-Mar-04 14:59 
GeneralRe: cannot open file "mfc42u.lib" Pin
Anonymous20-Jul-04 17:12
Anonymous20-Jul-04 17:12 
GeneralRe: cannot open file "mfc42u.lib" Pin
Gloria Cheng20-Jul-04 17:59
Gloria Cheng20-Jul-04 17:59 
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 

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.