
Description | Cautions | Example | Errors | See Also
Name: |
short dx_playiottdata(chdev, iottp, tptp, xpbp, mode) | |
Inputs: |
int chdev |
|
DX_IOTT *iottp |
| |
DV_TPT *tptp |
| |
DX_XPB *xpbp |
| |
unsigned short mode |
| |
Returns: |
0 if success | |
|
-1 if failure | ||
Includes: |
srllib.h | |
dxxxlib.h | ||
Category: |
I/O function | |
Mode: |
synchronous or asynchronous | |
The dx_playiottdata( ) function plays back recorded voice data from multiple sources on a channel. The file format for the files to be played is specified in the wFileFormat field of the DX_XPB. Other fields in the DX_XPB describe the data format. For files that include data format information (for example, WAVE files), these other fields are ignored.
Parameter |
Description | |
chdev |
channel device descriptor. | |
iottp |
the voice data may come from any combination of data files, memory, or custom devices. The order of playback and the location of the voice data is specified in an array of DX_IOTT structures pointed to by iottp | |
tptp |
pointer to Termination parameter table | |
xpbp |
pointer to I/O transfer parameter block | |
specifies the record mode: | ||
mode |
PM_TONE |
play 200 ms audible tone |
#include "srllib.h"
#include "dxxxlib.h"
int chdev; /* channel descriptor */
int fd; /* file descriptor for file to be played */
DX_IOTT iott; /* I/O transfer table */
DV_TPT tpt; /* termination parameter table */
DX_XPB xpb; /* I/O transfer parameter block */
.
.
.
/* Open channel */
if ((chdev = dx_open("dxxxB1C1",0)) == -1) {
printf("Cannot open channel\n");
/* Perform system error processing */
exit(1);
}
/* Set to terminate play on 1 digit */
tpt.tp_type = IO_EOT;
tpt.tp_termno = DX_MAXDTMF;
tpt.tp_length = 1;
tpt.tp_flags = TF_MAXDTMF;
/* Open VOX file to play */
if ((fd = dx_fileopen("HELLO.VOX",O_RDONLY|O_BINARY)) == -1) {
printf("File open error\n");
exit(2);
}
/* Set up DX_IOTT */
iott.io_fhandle = fd;
iott.io_bufp = 0;
iott.io_offset = 0;
iott.io_length = -1;
iott.io_type = IO_DEV | IO_EOT;
/*
* Specify VOX file format for ADPCM at 8KHz
*/
xpb.wFileFormat = FILE_FORMAT_VOX;
xpb.wDataFormat = DATA_FORMAT_DIALOGIC_ADPCM;
xpb.nSamplesPerSec = DRT_8KHZ;
xpb.wBitsPerSample = 4;
/* Wait forever for phone to ring and go offhook */
if (dx_wtring(chdev,1,DX_OFFHOOK,-1) == -1) {
printf("Error waiting for ring - %s\n", ATDV_LASTERR(chdev));
exit(3);
}
/* Start playback */
if (dx_playiottdata(chdev,&iott,&tpt,&xpb,EV_SYNC)==-1) {
printf("Error playing file - %s\n", ATDV_ERRMSGP(chdev));
exit(4);
}
In asynchronous mode, function returns immediately and a TDX_PLAY event is queued upon completion. Check ATDX_TERMMSK( ) for the termination reason. If a failure occurs, then a TDX_ERROR event will be queued. Use ATDV_LASTERR( ) to determine the reason for error.
In synchronous mode, if this function returns -1 to indicate failure, one of the following reasons will be contained by ATDV_LASTERR( ):
Equate |
Returned When |
EDX_BUSY |
Channel is busy |
EDX_XPBPARM |
Invalid DX_XPB setting |
EDX_BADIOTT |
Invalid DX_IOTT setting |
EDX_SYSTEM |
Error from operating system; use dx_fileerrno( ) to obtain error value. System I/O errors |
EDX_BADWAVFILE |
Invalid WAV file |
EDX_SH_BADCMD |
Unsupported command or WAV file format |
Click here to contact Dialogic Customer Engineering
Copyright 2002, Dialogic Corporation