Intel 05-1832-002 IP Phone User Manual


 
Voice API for Windows Operating Systems Library Reference — November 2003 341
record voice data from a single channel — dx_rec( )
#include <stdio.h>
#include <fcntl.h>
#include <srllib.h>
#include <dxxxlib.h>
#include <windows.h>
#define MAXLEN 10000
#define MAXCHAN 24
int record_handler();
DV_TPT tpt;
DX_IOTT iott[MAXCHAN];
int chdev[MAXCHAN];
char basebufp[MAXCHAN][MAXLEN];
main()
{
int i, srlmode;
char *chname;
/* Set SRL to run in polled mode. */
srlmode = SR_POLLMODE;
if (sr_setparm(SRL_DEVICE, SR_MODEID, (void *)&srlmode) == -1) {
/* process error */
}
/* Start asynchronous dx_rec() on all the channels. */
for (i=0; i<MAXCHAN; i++) {
/* Set chname to the channel name, e.g., dxxxB1C1, dxxxB1C2,... */
/*
* open the channel using dx_open( )
*/
if ((chdev[i] = dx_open(chname,NULL)) == -1) {
/* process error */
}
/* Using sr_enbhdlr(), set up handler function to handle record
* completion events on this channel.
*/
if (sr_enbhdlr(chdev[i], TDX_RECORD, record_handler) == -1) {
/* process error */
}
/*
* Set up the DV_TPT structures for MAXDTMF
*/
dx_clrtpt(&tpt,1);
tpt.tp_type = IO_EOT; /* last entry in the table */
tpt.tp_termno = DX_MAXDTMF; /* Maximum digits */
tpt.tp_length = 1; /* terminate on the first digit */
tpt.tp_flags = TF_MAXDTMF; /* Use the default flags */
/*
* Set up the DX_IOTT. The application records the voice data to memory
* allocated by the user.
*/
iott[i].io_type = IO_MEM|IO_EOT; /* Record to memory, last DX_IOTT
* entry */
iott[i].io_bufp = basebufp[i]; /* Set up pointer to buffer */
iott[i].io_offset = 0; /* Start at beginning of buffer */
iott[i].io_length = MAXLEN; /* Record 10,000 bytes voice data */
/* clear previously entered digits */
if (dx_clrdigbuf(chdev) == -1) {
/* process error */
}