adiInsertDigit

Inserts a digit at the end of the ADI service internal digit queue.

Supported board types

Prototype

DWORD adiInsertDigit ( CTAHD ctahd, char digit)

Argument

Description

ctahd

Context handle returned by ctaCreateContext or ctaAttachContext.

digit

Alphanumeric characters to store in the digit queue. Valid values are ASCII characters 0 through 9, # (number sign), and * (asterisk), as well as A, B, C, and D.

Return values

Return value

Description

SUCCESS

 

CTAERR_BAD_ARGUMENT

digit is not a valid character.

CTAERR_INVALID_CTAHD

Context handle is invalid.

CTAERR_INVALID_STATE

Protocol not started.

CTAERR_SVR_COMM

Server communication error.

Details

Use adiInsertDigit to insert a digit into the ADI digit queue. If digit collection is active, the digit is moved to the collection buffer and the interdigit timer is reset.

This function can be used when digits arrive from either DTMF detection or from an out-of-band indication such as RFC2833 packets. The DTMF digits are automatically added to the queue, whereas you must call this function to add the out-of-band digits.

The digit queue holds 62 characters. If the digit queue is full, the oldest character is discarded without an error indication.

If the digit is in the abort mask of an active play or record operation, the play or record operation terminates immediately. If any digit in the queue is in the abort mask, subsequent play or record operations terminate immediately after being started. Use adiFlushDigitQueue, adiGetDigit, or adiCollectDigits to remove digits from the queue.

For more information, refer to Collecting digits.

See also

adiPeekDigit

Example

//This example shows Fusion RFC 2833 events being converted to ADI digits

#include "mspunsol.h"
#include "mspdef.h"

example(CTAHD ctahd)
{
//main event loop
for(;;)
{
CTA_EVENT event;
myGetEvent( &event );   /* see ctaWaitEvent example */
switch( event.id )
{
//Assumes RTP endpoint is configured with
// dtmf_event_control = SEND_FIRST_EVENT | SEND_LAST_EVENT

case MSPEVN_RFC2833_REPORT:
{
DISASM_DTMF_EVENT_STRUCT *dtmfEvt=
(DISASM_DTMF_EVENT_STRUCT *)(event.buffer);
if ((dtmfEvt->EvtVol & LAST_DTMF_EVENT)==0)
{
char digit='\0';
switch (DtmfEvt->EvtID)
{
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9: digit='0'+DtmfEvt->EvtID; break;
case 10: digit='*'; break;
case 11: digit='#'; break;
case 12: digit='A'; break;
case 13: digit='B'; break;
case 14: digit='C'; break;
case 15: digit='D'; break;
}
if (digit !='\0')
{
adiInsertDigit
(ctahd, digit);
}
}
mspReleaseBuffer( event.objHd, event.buffer);
break;
}

// other events ...
}
}
}