adiPlayMMFromMemory

Initiates a multimedia play operation using data from a single memory-resident buffer.

Prototype

DWORD adiPlayMMFromMemory ( CTAHD ctahd, unsigned encoding, void *buffer, unsigned bufsize, MSPHD *ephd, ADI_PLAY_PARMS *parms)

Argument

Description

ctahd

Context handle returned by ctaCreateContext or ctaAttachContext.

encoding

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

buffer

Pointer to the media data buffer.

bufsize

Number of bytes stored at the address in buffer (bufsize can be arbitrarily large).

ephd

Pointer to the CG board filter endpoint handle from 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 buffer.

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

Play or record communication error.

Events

The ADIEVN_PLAY_DONE event is generated by the ADI service when playing terminates. The event size field contains the total number of bytes played during the function instance. The event value field contains one of the following termination reasons or an error code:

Event

Description

CTA_REASON_DIGIT

Aborted due to DTMF.

CTA_REASON_FINISHED

Complete buffer played.

CTA_REASON_RELEASED

Call terminated.

CTA_REASON_STOPPED

Stopped by application request.

Details

adiPlayMMFromMemory starts playing a single memory-resident buffer of bufsize bytes. The ADI service generates ADIEVN_PLAY_DONE when the function terminates. To avoid unintentionally modifying data, the application must not modify the buffer until it receives the DONE event.

See also

adiRecordMMToMemory

Example

if ((VideoCtx[i].video_fp = fopen(video_FileName, "r")) == NULL)
{
printf("Failed to open file: %s\n", video_FileName);
exit(1);
}
wrSize = fread(VideoCtx[i].data_buffer,
sizeof(BYTE),
mmParm.video_buffer_size,
VideoCtx[i].video_fp);

ret = adiPlayMMFromMemory(VideoCtx[i].ctahd,
mmParm.ADIvidEncoder, // Encoding
VideoCtx[i].data_buffer, // Buffer to play data from
wrSize, // data size to play
videoEP_filterhd, // Video EndPoint Filter Handle
NULL);
if (ret != SUCCESS)
{
printf("Failed to Play from memory, %x\n", ret);
exit(1);
}