gvSetCustomCodec
Tells GV to use an application-provided codec instead of a built-in codec.
- void gvSetCustomCodec(
- GVCustomCodecInfo * info );
Routine | Required Header | Distribution |
---|---|---|
gvSetCustomCodec | <gv.h> | SDKZIP |
Parameters
- info
- [in] The application fills in this structure with the information that the SDK needs to use the custom codec.
Remarks
The first thing to do after initializing the SDK is to set the codec you would like to use. The codec cannot be changed while any devices are initialized, so an application will typically just set the codec once, when it starts using voice.
Before calling this function, the application must fill in the GVCustomCodecInfo structure with information about the codec to be used.
m_samplesPerFrame is the number of samples that this codec expects in a raw (unencoded) frame of audio. This can be whatever value is used by the codec, however it is typically about 160 samples.
m_encodedFrameSize is the number of bytes in an encoded frame of audio produced by this codec. The ratio of the samples per frame and encoded frame size is directly related to the codec’s output stream bit rate.
m_newDecoderCallback is used to allocate a new decoder instance for each incoming source. Some codecs do not require this, and they should set the m_newDecoderCallback member to NULL. For codecs that do require per-source data, they should allocate a new decoder data state and set the data parameter to point to it, then return TRUE. If they cannot allocate a new decoder data, then they should return GVFalse.
The m_freeDecoderCallback is used to free decoder data allocated through m_newDecoderCallback. If a codec set m_newDecoderCallback to NULL, it should set m_freeDecoderCallback to NULL as well. Otherwise it should provide a function that frees the decoder data.
m_encodeCallback is used to encode data. The in parameter points to the input data, with is a single raw frame of samples. The number of samples passed to this function will always be m_samplesPerFrame. The out parameter points to the memory into which the callback should decode the input data. The memory will always be large enough to hold one frame of compressed audio, which will always be m_encodedFrameSize bytes long.
m_decodeCallback is used to decode data. The in parameter will point to an encoded frame of audio, which will be m_encodedFrameSize bytes long. The out parameter which will be large enough to hold m_samplesPerFrame samples of audio. The decoder data is provided for codecs that need it. The important thing to know with the decode callback is that it should not decode directly into the out buffer, but it should add to it. This allows GV to decode and mix at the same time, without having to decode into a temporary buffer which would then be mixed into the output stream.
Section Reference: Gamespy Voice SDK
See Also: gvSetCodec