SetCodec Method

Description

Sets the codec (compression-decompression) of an audio control player.

Syntax
object.SetCodec FormatTag Channels SamplesPerSec BitsPerSample

ParameterDescription
FormatTag Sets the format of the codec. If you want to use compression, GSM is recommended for the Internet and IMA ADPCM is recommended for corporate intranets.
Value Description
1 PCM (no compression)
2 Microsoft ADPCM
6 CCITT A-law
7 CCITT µ-law
17 IMA ADPCM (corporate intranets)
49 GSM610 (Internet)
Channels Specifies the number of discrete channels in the format.
Value Description
1 Monaural data (recommended)
2 Stereo data
SamplesPerSec Sets the samples-per-second rate in the format.
Value Description
8000 8 KHz (recommended)
11025 11.025 KHz
22050 22.050 KHz
44100 44.100 KHz
BitsPerSample Sets the bits per sample in the codec format. The recommended value for compression is 0 for GSM, 4 for ADPCM, and 8 for PCM.
Value Description
0 Block-based codecs such as GSM (recommended for the Internet)
4 Sample-based codecs such as Microsoft ADPCM and IMA ADPCM (recommended for corporate intranets)
8 PCM (non-compressed)

Return Value

This method does not return a value.

Remarks

The SetCodec method is used to set the codec (compression-decompression) of the player. Using SetCodec overrides the value of AutoDetectCodec. Do not use SetCodec if you want to autodetect a codec.

Parameter values are not checked when SetCodec is called. If an invalid parameter is entered for SetCodec, an ERROR_TRANSFORM_NOT_SUPPORTED error will be generated.

GSM codecs are block-based, so a null value is entered, since "bits per sample" does not apply.

When a .wav file is sent using the NetShow Administrator application, the codec can be determined by the properties of the .wav file. Make sure that the player codec matches the .wav file codec.

Use the following settings for VAT (Visual Audio Tool) if you are using CCITT µ-law:
Setting Value
Format Tag 7
Channels 1
Samples Per Second 8000
Bits Per Sample 8

Example

The following code example shows how to use SetCodec to play compressed IMA ADPCM audio (suggested for corporate intranets). The audio control object is called rtpaudio and a button has been created called BtnPlay. When the button is clicked, the codec specified in SetCodec will be set.


Sub BtnPlay_OnClick
 call rtpaudio.Stop()
 call rtpaudio.SetCodec(17,1,8000,4)
 call rtpaudio.SetSocket("239.240.100.2", 29102)
 call rtpaudio.Play()
End Sub

See Also

Play

Return to the RTP Audio Control Reference.

© 1997 Microsoft Corporation. All rights reserved. Terms of Use.