Microsoft DirectX 8.1 (C++)

VoiceConnect

The VoiceConnect sample shows how to network with other players to start a Microsoft® DirectPlay® Voice chat session. After joining or creating a session, the players can use a microphone to talk to one other. Other players can join the session at any time.

Path

Source: (SDK root)\Samples\Multimedia\DirectPlay\VoiceConnect

Executable: (SDK root)\Samples\Multimedia\DirectPlay\Bin

User's Guide

For information about how to connect, refer to the User's Guide section of the SimplePeer sample. After connecting, the host is presented with a dialog box asking which voice codec to use. Typical voice applications automatically select a voice codec, or present this to the user in some other fashion. Once the chat session begins, any client can alter the playback or capture settings by clicking Setup.

Programming Notes

The VoiceConnect sample is very similar in form to the SimplePeer sample. The VoiceConnect differs by letting clients use DirectPlay Voice to talk to each other using a computer microphone. For detailed programming notes see the Programming Notes section of the SimplePeer sample.

To create the voice functionality, the application must first initialize DirectPlay voice. This sample does this by calling CNetVoice::Init when the main dialog is initialized. CNetVoice::Init performs the following tasks:

DirectPlayVoiceClientMessageHandler handles different DirectPlay messages such as:

When Exit is clicked, the application needs to clean up DirectPlay Voice by calling CNetVoice::Free which does the following:

  1. Disconnects the player from the voice session. The VoiceSessionDisconnect function calls IDirectPlayVoiceClient::Disconnect and releases the IDirectPlayVoiceClient object.
  2. Destroys the voice session if this player is the host. The VoiceSessionDestroy function calls IDirectPlayVoiceServer::StopSession and releases the IDirectPlayVoiceServer object