Voice Chat Using Client/Server Architecture

Environment: Visual C++ 6.0, Windows 98/XP

Application Details

This software is based on the client/server architecture. Communication between the clients is established through the server. Initially, the server is started. Clients connect to the server host. The server sends the new client list to all the existing clients. The client can select a destination user from the user combo box. The software also provides save and play (the user can save the sound and play it later). The client also has a volume control feature. When the client application is started, a microphone select option (recording) is enabled and the microphone mute option (playing) is checked automatically by the program. (The user doesn't have to worry about the external settings.)

Technical Details

In Display Class

When the client application starts recording and playing threads created in OnInitDialog() of the Display class.

// Create and Start Recorder Thread
record=new RecordSound(this);
record->CreateThread();

//Create and Start Player Thread
play=new PlaySound1(this);
play->CreateThread();

Thread functions are based on the code by the great person Paul Cheffers (from the CodeGuru site). I am grateful to him for making my dream project become a reality.

PreCreateHeader() of the Display class (from the constructor) creates some buffers for playing wavedata. (This prevents the creation of buffers during runtime...) When the client presses the connect button OnConnect() of the Display class, it connects client to server and displays the userlist and start button. On pressing the start button. recording and playing are started by sending a message to the recording and playing thread (OnStart function).

record->PostThreadMessage(WM_RECORDSOUND_STARTRECORDING,0,0);
play->PostThreadMessage(WM_PLAYSOUND_STARTPLAYING,0,0);

These messages will activate corresponding functions defined in the message map of the respective thread class.

On pressing the stop button, recording and playing are stopped by in the same way as above (OnStop Function). It also contains other functions that will be activated on pressing the buttons....and some functions are activated from other classes (mysocket and RecordSound classes).

In mysocket class

OnReceive: When data arrives at the client, it will call the Display class's receive function, which plays the sound by sending message to the PlaySound thread.

play->PostThreadMessage(WM_PLAYSOUND_PLAYBLOCK,0,(LPARAM)lpHdr);

Message Format:

Total length : 2020 bytes
15           :  header (destination username or special status)
5            :  Length of actual data
2000         :  Reserved for actual data.

RecordSound class

The PreCreateHeader() function creates buffers for recording data. These are added using the waveInPrepareHeader() and waveInAddBuffer() functions in the OnStartRecording function. (It is called when the start button is clicked, as explained earlier.)

Playsound1 class

Contains the functions for starting, playing, and stopping wavedata. Buffers are created initially in the Display class itself.

MicMute, MicPhone, and Mixer are the special classes to add several extra features to the Voice Chat function. Some of the concepts are collected from various developers at the CodeGuru site. I am grateful to those developers!!!

Running the Application

First, start the server application (with port number xxx). Then, start a minimum of two clients on any hosts (same or different). I should mention that the server hosts address and port xxx with username xyz. Then, click the connect button. The userlist will be displayed. Select the user and click the start button to start the chat...

Note: Any client can chat with any other client; hence, a client can receive data from any number of clients. Performance depends upon the situation. Developers are free to use their own ideas. (Please let me know if you see some new mechanism.)

I am eagerly waiting for your doubts and suggestions at nsry2002@yahoo.co.in.

I am grateful to the CodeGuru site for connecting developers....and helping us realise their dreams!!!

Downloads

Download demo project - 165 Kb


Comments

  • Doubt regarding Video conferencing

    Posted by gokulpalwe on 02/04/2010 07:48am

    I would like to know how to compress video for live video streaming??? 
    I am eagerly waiting for your reply.

    Reply
  • eBook for Voice Chat/Communication

    Posted by walim_2007 on 11/29/2006 09:49pm

    I respect and very thank for this demo project programming. Please let me know, Where I can get a free ebook for development this programming. Currently, I am developing project for voice switching communication. Thanks. Regards, Wali M.

    • nice

      Posted by saltana on 06/29/2008 05:51am

      very

      Reply
    • very nice

      Posted by kantipur on 10/31/2007 09:50am

      very goog

      Reply
    Reply
  • eBook for Voice Chat/Communication

    Posted by walim_2007 on 11/29/2006 09:48pm

    I respect and very thank for this demo project programming. Please let me know, Where I can get a free ebook for development this programming. Currently, I am developing project for voice switching communication. Thanks. Regards, Wali M.

    Reply
  • eBook for Voice Chat/Communication

    Posted by walim_2007 on 11/29/2006 09:47pm

    I respect and very thank for this demo project programming. Please let me know, Where I can get a free ebook for development this programming. Currently, I am developing project for voice switching communication. Thanks. Regards, Wali M.

    • Chat using Client/Server Architecture

      Posted by auanh on 07/25/2007 10:43pm

      I want use its. Thanks

      Reply
    Reply
  • eBook for Voice Chat/Communication

    Posted by walim_2007 on 11/29/2006 09:43pm

    I respect and very thank for this demo project programming. Please let me know, Where I can get a free ebook for development this programming. Currently, I am developing project for voice switching communication. Thanks. Regards, Wali M.

    Reply
  • Compile error?

    Posted by eAs on 10/25/2004 07:20am

    I cannot compile the client application, I get the following error WriteSound.cpp(13): error C2440: 'static_cast' : cannot convert from 'LRESULT (__thiscall WriteSound::* )(WPARAM,LPARAM)' to 'void (__thiscall CWinThread::* )(WPARAM,LPARAM)' Any suggestions?, I'm using Microsoft Development Environment 2003 under XPSP2 Thanks

    Reply
  • noise when used over internet

    Posted by eid on 10/20/2004 07:24am

    hi, thanks for this good program i tried it and it have some problems, the most one when i used it over the internet i hair a noise with sound and i can't now the source of it. can any one help me.

    • changing the audio format settings may help..

      Posted by nsry on 10/25/2004 01:17am

      If you change the waveformat settings and buffer size that will help..you may need to do some trial and error check to get right settings...because voice quality depends upon bandwidth and wave format parameters...

      Reply
    Reply
  • bandwidth

    Posted by Legacy on 01/26/2004 12:00am

    Originally posted by: kukuh

    Dear Mr,
    i want to know about the bandwidth that application use in Local Area network, or please give me clues for application that can be used for the performance test of voice chat application.
    thanks b-4

    Reply
  • Important api's

    Posted by Legacy on 12/23/2003 12:00am

    Originally posted by: Muthu

    sir,
    Thanx for answering me sir,i am happy &Another important question sir!! plzz What r the important api's used& for what purpose?? pls list out sir..it's ver y urgent.. .so kindly do me this favour....i will be very h appy sir!!!
    pls send me as soon as possible....its urgent..

    thanking you
    yours faithfuly
    Muthu

    Reply
  • Sending Pictures Over The Network

    Posted by Legacy on 12/15/2003 12:00am

    Originally posted by: Muhammad Kashif

    Dear Friend,
    I have developed a peer to peer version of your project.Your efforts are just incredible.The code written was very precise and no useless files were included.
    Now i am thinking about transfering pics taken by a pc camera over the network.Do you have any idea about that.Please help me in this regard as well.

    Video Over InterNet Protocol VidOIP.

    Reply
  • Loading, Please Wait ...

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: August 14, 2014 @ 2:00 p.m. ET / 11:00 a.m. PT Data protection has long been considered "overhead" by many organizations in the past, many chalking it up to an insurance policy or an extended warranty you may never use. The realities of today makes data protection a must-have, as we live in a data-driven society -- the digital assets we create, share, and collaborate with others on must be managed and protected for many purposes. Check out this upcoming eSeminar and join Seagate Cloud …

  • Hybrid cloud platforms need to think in terms of sweet spots when it comes to application platform interface (API) integration. Cloud Velocity has taken a unique approach to tight integration with the API sweet spot; enough to support the agility of physical and virtual apps, including multi-tier environments and databases, while reducing capital and operating costs. Read this case study to learn how a global-level Fortune 1000 company was able to deploy an entire 6+ TB Oracle eCommerce stack in Amazon Web …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds