adiGetEncodingInfo

Returns data size parameters for a given voice encoding format on a specified context.

Supported board types

Prototype

DWORD adiGetEncodingInfo ( CTAHD ctahd, unsigned encoding, unsigned *framesize, unsigned *datarate, unsigned *maxbufsize)

Argument

Description

ctahd

Context handle returned by ctaCreateContext or ctaAttachContext.

encoding

Data encoding method. See Voice encoding formats for a complete list of valid encoding methods.

framesize

Pointer to returned size, in bytes, of a single voice frame for given encoding format.

datarate

Pointer to returned required throughput in bytes per second, for given encoding format.

maxbufsize

Pointer to returned board buffer size in bytes, for given encoding format on the specified context.

Return values

Return value

Description

SUCCESS

 

CTAERR_BAD_ARGUMENT

Invalid encoding format.

CTAERR_INVALID_CTAHD

Context handle is invalid.

CTAERR_INVALID_STATE

Function not valid in the current port state.

CTAERR_SVR_COMM

Server communication error.

Details

Use adiGetEncodingInfo to return data size information for the given encoding format on the specified context.

When submitting buffers of voice data for play or record, the buffers must be an integral multiple of the encoding frame size, and should be a multiple of the board's physical buffer (maxbufsize). All buffers of voice data submitted to the ADI service must be an integral number of framesize bytes. For example, if the frame size is 62 bytes, a submitted buffer must be sized as n x 62 bytes where n=1,2,3....

The datarate is provided for resource management optimization. The datarate defines the required throughput between the host CPU and AG board (in bytes/second). It can be used for positioning. For example, to skip ahead four seconds in a message, move your data pointer 4 x datarate bytes (modulo framesize).

The maxbufsize is the maximum physical buffer size for the board on the specified context for the given encoding format. The board's physical buffer size varies depending upon the board type and configured software. The size returned here is rounded to a multiple of the frame size.

You can pass NULL for any of the function arguments that are pointers to returned values.

See also

adiPlayAsync, adiPlayFromMemory, adiRecordAsync, adiRecordToMemory, adiStartPlaying, adiStartRecording

Example

void myShowEncodingInfo( CTAHD ctahd, unsigned encoding )
{
   unsigned framesize, datarate, maxbufsize;

   if( adiGetEncodingInfo( ctahd, encoding,
                           &framesize, &datarate, &maxbufsize ) == SUCCESS )
   {
       printf( "Frame size = %d bytes\n", framesize );
       printf( "Data rate = %d bytes/sec\n", datarate );
       printf( "Max buf size = %d bytes\n", maxbufsize );
   }
}