Samples
This demo shows how to use IpServer
, IpClient
and
WaveCodec
components to build a simple voice chat application.
This sample also demonstrates conference communication in case a number of clients are connected to server.
You should create two chains of components.
The first chain implements server-side and the second one implements client-side.
Server-side chain is:
WaveIn => WaveCodec(1) => IpServer => WaveCodec(2) => WaveOut
Client-side chain is:
WaveIn => WaveCodec(1) => IpClient => WaveCodec(2) => WaveOut
IpServer and IpClient communicate through network, WaveCodec components encode and decode
audio stream data to decrease network traffic.
WaveIn component records audio stream from sound card and sends data to WaveCodec(1) component.
WaveCodec(1) encodes data and passes it to IpServer (IpClient) component.
IpServer and IpClient send data through network. Received data is passed to WaveCodec(2) component.
WaveCodec (2) decodes data and passes it to WaveOut component, which playbacks it using the sound card.
We are implementing both chains in the same application. You may implement only one of them depending on your needs.
Please follow these steps:
1. Place all components that are contained in both chains on form.
2. Set IsFormatProvider property to True for all components, so they will pass PCM format parameters to consumers.
3. Configure WaveIn components.
Set PcmNumChannels property to 1 (this is good enough for speech).
4. Configure WaveCodec(1) components.
Set FormatTag property to 49 to select the GSM codec. You can refer to mmreg.h file from Platform SDK documentation for
numbers assigned to other codecs.
Set RealTime property to True.
5. Configure IpServer and IpClient components.
Set Proto property to unapt_TCP or unapt_UDP depending on what protocol you wish to use. You can leave default socket
port number, or change it to appropriate value.
Set IpServer.MaxClients property to restrict the maximum number of client connections.
6. Configure WaveCodec(2) components.
Set RealTime property to True.
Set InputIsPcm property to False (input stream is encoded).
Set FormatTagImmunable property to False (value of FormatTag property is passed by server or client).
7. Set links between providers and consumers according to chain order. Refer to Providers & Consumers section for details.
8. Activate server by setting server WaveIn.Active property to True.
9. To activate client specify IP address or DNS name of server machine by setting IpClient.Host property; set client
WaveIn.Active property to True.
10. To stop server/client you should set WaveIn.Active property to False.