Click here to Skip to main content
15,885,244 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

 
Questionplease tell me how to run the code Pin
Quang trần Aug202118-Aug-21 4:26
Quang trần Aug202118-Aug-21 4:26 
Questionnot working for me on visual studio 2008 and windows 7 Pin
reimo8-Sep-11 2:36
reimo8-Sep-11 2:36 
QuestionJust Downloaded VoiceChat plEASE EXPLAIN INSTALL Pin
DAZMeanZit21-Aug-11 1:23
DAZMeanZit21-Aug-11 1:23 
QuestionJust Downloaded VoiceChat Pin
DAZMeanZit21-Aug-11 1:22
DAZMeanZit21-Aug-11 1:22 
cAN I PLEASE HAVE A STEP BY STEP PROCES OF HOW TO INSTALL THIS ON MY COMPUTER I HAVE DOWNLOADED THE FILE BUT CAN ONLY OPEN WITH NOTEPAD ON WINDOWS 7 INTERNET EXPLORER 9 64BIT SYS :p

MANY THANKS
QuestionUrgent Pin
hinag2-Nov-08 23:31
hinag2-Nov-08 23:31 
GeneralCxImage Version 6.00 and Demo application Pin
Mustafa Alahwel23-Oct-08 6:30
Mustafa Alahwel23-Oct-08 6:30 
Generalneeded help Pin
hariharasudhan felix23-Jul-06 23:07
hariharasudhan felix23-Jul-06 23:07 
Generalis this example given file is a real time example or not Pin
manu90904-May-06 2:30
manu90904-May-06 2:30 
QuestionHow To check the CD Writter,Printer, Download Size Status such as How Copies writted and printed Pin
Member 23255383-Oct-05 1:31
Member 23255383-Oct-05 1:31 
AnswerRe: How To check the CD Writter,Printer, Download Size Status such as How Copies writted and printed Pin
Duncan Edwards Jones3-Oct-05 1:54
professionalDuncan Edwards Jones3-Oct-05 1:54 
Generalencryption Pin
valroft12-May-05 10:00
valroft12-May-05 10:00 
GeneralShaking Voice Pin
SohailB27-Apr-05 3:06
SohailB27-Apr-05 3:06 
Generalthank you georgi ! Pin
valroft30-Mar-05 19:19
valroft30-Mar-05 19:19 
GeneralErrors in Ole control Pin
Georgi Petrov5-Mar-05 0:21
Georgi Petrov5-Mar-05 0:21 
Generalerror in buliding the OVoiceChatt Control... Pin
ComVexd22-Jun-04 15:01
ComVexd22-Jun-04 15:01 
GeneralRe: error in buliding the OVoiceChatt Control... Pin
ComVexd22-Jun-04 15:11
ComVexd22-Jun-04 15:11 
Generalneed help Pin
saima11-Jun-04 4:24
saima11-Jun-04 4:24 
Generalneed help Pin
saima11-Jun-04 4:18
saima11-Jun-04 4:18 
QuestionHaving link error LNK2019? Pin
Danny J6-Feb-04 15:48
Danny J6-Feb-04 15:48 
Generalhelp me Pin
Anonymous11-Aug-03 15:01
Anonymous11-Aug-03 15:01 
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 

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.