adiPlayMMAsync

Initiates a multimedia play operation with asynchronous buffer submission.

Prototype

DWORD adiPlayMMAsync ( CTAHD ctahd, unsigned encoding, void *buffer1, unsigned bufsize, unsigned flags, DWORD ephd, ADI_PLAY_PARMS *parms);

Argument

Description

ctahd

Context handle returned by ctaCreateContext or ctaAttachContext.

encoding

Encoding type. See adidef.h header file for a complete list of ADI_ENCODING_xxx values. See Multimedia encoding types for the RTP compressed format encoding types.

buffer1

Pointer to the initial media data buffer.

bufsize

Number of bytes pointed to by buffer1.

flags

Indicates if the specified buffer is the only buffer to be played. Valid values are:

  • ADI_PLAY_LAST_BUFFER - Specified buffer is the only buffer to be played.

  • 0 - There are subsequent buffers to play.

ephd

Pointer to the CG board filter endpoint handle obtained with mspGetFilterHandle. This endpoint handle is required to connect the ADI channel on the board to the RTP endpoint.

parms

Specify a NULL pointer. Standard ADI play parameters are not applicable for multimedia pass-through play functions.

Return values

Return value

Description

SUCCESS

 

ADIERR_INVALID_CALL_STATE

Function not valid in the current call state.

CTAERR_BAD_ARGUMENT

Either invalid encoding or NULL buffer1.

CTAERR_FUNCTION_ACTIVE

Function already started.

CTAERR_INVALID_CTAHD

Context handle is invalid.

CTAERR_INVALID_STATE

Function not valid in the current port state.

CTAERR_OUTPUT_ACTIVE

Play failed because there is another active output function.

CTAERR_SVR_COMM

Server communication error.

Events

Event

Description

ADIEVN_PLAY_BUFFER_REQ

Generated when the ADI service needs a buffer containing multimedia data. The application responds by either submitting a full buffer (adiSubmitPlayBuffer) or a full or partial buffer (adiSubmitPlayBuffer with a flag indicating ADI_PLAY_LAST_BUFFER). If the ADI_PLAY_UNDERRUN bit is set, an underrun occurred, meaning that playing was temporarily suspended because there was no buffer to play.

ADIEVN_PLAY_DONE

Generated by the ADI service when the play operation terminates. The event size field contains the total number of bytes played during the function's instance. The event value field contains one of the following termination conditions, or an error code:

CTA_REASON_DIGIT
Aborted due to DTMF.

CTA_REASON_FINISHED
Buffer submitted with the ADI_PLAY_LAST_BUFFER flag set completed playing.

CTA_REASON_RELEASED
Call terminated.

CTA_REASON_STOPPED
Stopped by application request.

Details

Use adiPlayMMAsync to initiate a multimedia playback operation. The multimedia data is supplied in a sequence of buffers. The application has complete responsibility for allocating, filling, and submitting buffers to the ADI service.

The bufsize should be set to a value less than or equal to the board buffer size, which by default is 16,400 for CG boards. In this case, you can reuse the buffer as soon as this function returns.

After play initiates, the ADI service sends the ADIEVN_PLAY_BUFFER_REQ event to the application whenever it is ready to process more data. The application responds to this event by submitting a filled voice buffer with adiSubmitPlayBuffer. The application must submit buffers only in response to ADIEVN_PLAY_BUFFER_REQ.

For proper operation, each buffer must be submitted while the previous buffer is being played.

The application terminates play by submitting a buffer with the flags argument set to ADI_PLAY_LAST_BUFFER. After the ADI service has played the buffer that was submitted with the flag set, it generates an ADIEVN_PLAY_DONE event with the value set to CTA_REASON_FINISHED. To avoid unintentionally modifying data, the application must not modify the buffer until it receives the DONE event.

For more information about adiSubmitPlayBuffer, see the ADI Service Developer's Reference Manual.

See also

adiRecordMMAsync

Example

ret = adiPlayMMAsync(VideoCtx[i].ctahd,
      mmParm.ADIvidEncoder, // Encoding
      VideoCtx[i].data_buffer, // Buffer to play data from
      16400, // data size to play
      0, // flags – not last buffer
      videoEP_filterhd, // Video EndPoint Filter Handle
      NULL);
if (ret != SUCCESS)
{
    printf("Failed to Play Async, %x\n", ret);
    exit(1);
}