<!-- Add the rest of your HTML here -->
This application uses multicasting technique for audio conference. Interested clients will join the multicast group address (184.108.40.206 - 220.127.116.11). On the LAN when any client sends the voice data to multicast address it will be delivered to all the clients joined to that group by the underlying network automatically. (Even the sending host also receive the copy if it has joined to that address and the application has to handle this situation). If the client only wants to send the data and doesn't want to receive the data then it does not have to join to that group.
On the Internet this feature is possible if routers support multicasting. Otherwise virtual multicasting has to be simulated using mtunneling.(refer details on MBONE-multicast BACKBONE).
The client can select a destination user from the user combo box. The software also provides save and play (user can save the sound and play it later). Client also has volume control feature. When client application is started microphone select option (recording) is enabled and microphone mute option is checked (playing) automatically by the program. (user don't have to worry about the external settings).
When the client application started recording and playing threads created in
OnInitDialog() of the Display class. <PRE lang=c++>// Create and Start Recorder Thread
record = new RecordSound(this);
// Create and Start Player Thread
play = new PlaySound1(this);
Thread functions are based on the code by great person Paul Cheffers (from codeguru site). I am grateful to him for making my dream project into reality.
PreCreateHeader() of the Display class (from constructor) creates some buffers for playing wavedata. (This prevents creation of buffers during runtime...) when the client presses the connect button
OnConnect() of the Display class connects client to server and displays the userlist and start button. On pressing the start button recording and playing is started by sending message to recording and playing thread. (
OnStart function) <PRE lang=c++>record->PostThreadMessage(WM_RECORDSOUND_STARTRECORDING, 0, 0);
play->PostThreadMessage(WM_PLAYSOUND_STARTPLAYING, 0, 0);
These messages will activate corresponding functions defined in message map of respective thread class.
On pressing the stop button recording and playing is stopped by in the same way as above (
OnStop Function). It also contains other functions which will be activated on pressing the buttons.... and some functions are activated from other classes. (
Before starting the application the client has to join multicast group using mulitcast group address and port.. this has been done in the
function.(called from the Display class).
To receive the messages the client has to join the multicast group. Steps are as follows.
- Create receiver socket <PRE lang=c++>Create(gport,SOCK_DGRAM, FD_READ)
- Allow other application to use the port (gport). <PRE lang=c++>SetSockOpt(SO_REUSEADDR, (void *) &bMultipleApps, sizeof(BOOL),
- Join to the multicast group <PRE lang=c++>ip_mreq mreq;
mreq.imr_multiaddr.s_addr = inet_addr(gaddr); //group address
mreq.imr_interface.s_addr = htons(INADDR_ANY);
setsockopt(m_hSocket,IPPROTO_IP, IP_ADD_MEMBERSHIP, (char FAR *) &mreq,
To send the data the steps are as follows:
- Create Sending socket <PRE lang=c++>SOCKADDR_IN hgroup;
memset(&hgroup, 0, sizeof(hgroup));
hgroup.sin_family = AF_INET;
hgroup.sin_addr.s_addr = inet_addr(gaddr);
hgroup.sin_port = htons((USHORT)gport);
send.Create(0, SOCK_DGRAM, 0);
- Set TTL value ...important <PRE lang=c++>ttl=8; //some value > 1
send.SetSockOpt(IP_MULTICAST_TTL, &ttl, sizeof(int), IPPROTO_IP)
- Set loopback option to false to prevent loopback (optional) <PRE lang=c++>//depends upon underlying protocol..
//application has to handle loopback(prefered...)
function creates buffers for recording data.These are added using
function. (Called when Start button is clicked as explained earlier)
Contains the functions for starting ,playing and stopping wavedata. Buffers are created initially in
are special classes to add several extra features to Voice - Chat function. Some of the concepts are collected from various developers at the codeguru and codeproject sites. I am grateful to those developers....!!!
Running the Application
- LAN : To start the application run the client program and specify the multicast group address (18.104.22.168 ... 22.214.171.124) and port (Specify even number 1024) and type username .Then press the Connect button to connect to the group. If successfully connected to the group the start button will be displayed. On clicking the start button recording will be started. Playing will be started automatically when new data arrives.
- On the Internet a virtual environment has to be provided using mtunneling (since most routers don't support multicasting..)
Note Any client can send data at any time. Performance depends upon the situation. Developers are free to use their own ideas to improve (please let me know if you see some new mechanism..)
I am eagerly awaiting your doubts and suggestions at firstname.lastname@example.org.
I am grateful to codeguru and codeproject sites for connecting developers and helping to realise their dreams..!!!