PREV TOC HOME INDEX NEXT


ec_reciottdata( )


Cautions | Example | Errors | See Also

Name: int ec_reciottdata(chDev, iottp, tptp, xpbp, mode)
Inputs: int chDev
  • valid channel device handle

DX_IOTT *iottp
  • pointer to I/O transfer table

DV_TPT *tptp
  • pointer to termination parameter table

DX_XPB *xpbp
  • pointer to I/O transfer parameter block table

unsigned short mode
  • record mode
Returns: 0 for success -1 for failure
Includes: srllib.h dxxxlib.h eclib.h
Category: I/O
Mode: synchronous/asynchronous

Description

The ec_reciottdata( ) function starts an echo-cancelled record to a file or memory buffer on a CSP-capable full-duplex channel.

You can perform a record at all times or a voice-activated record. To perform a voice-activated record, where recording begins only after speech energy has been detected, enable ECCH_VADINITIATED in ec_setparm( ).

Parameter
Description
chDev The channel device handle obtained when the CSP-capable device is opened using dx_open( ).
iottp Pointer to the DX_IOTT table that specifies the order and media on which the echo-cancelled data is recorded.
tptp Pointer to the DV_TPT table that sets the termination conditions for the device handle. Note: On SpringWare boards, the only supported DV_TPT terminating conditions are DX_MAXTIME, DX_MAXSIL, and DX_MAXNOSIL. The Voice Activity Detector (VAD) timeout period is set by the tp_length parameter in the DV_TPT structure. For more information on DV_TPT, see the Voice Software Reference: Programmer's Guide. Note: On DM3 boards, all DV_TPT terminating conditions are supported except for DX_MAXTIME, DX_LCOFF, DX_PMON and DX_PMOFF. For more information on DV_TPT limitations on DM3 boards, see the Compatibility Guide for the Dialogic R4 API on DM3 Products. Note: In CSP, DV_TPT terminating conditions are edge-sensitive.
xpbp Pointer to the DX_XPB table that specifies the file format, data format, sampling rate and sampling size.
mode A bit mask that specifies the record mode.
  • EV_SYNC - synchronous mode
  • EV_ASYNC - asynchronous mode
  • MD_GAIN - automatic gain control (AGC)
  • MD_NOGAIN - no automatic gain control
Note: For ASR applications, turn AGC off.

Cautions

Example

#include <windows.h>  /* include in Windows applications only; exclude in Linux */
#include <stdio.h>
#include <srllib.h>
#include <dxxxlib.h>
#include <eclib.h> 
#include <errno.h>  /* include in Linux applications only; exclude in Windows */ 
main ()
{ 
int chdev;             /* channel descriptor */
int fd;                /* file descriptor for file to be played */
DX_IOTT iott, iott1;   /* I/O transfer table */
DV_TPT tpt, tpt1;      /* termination parameter table */
DX_XPB xpb;            /* I/O transfer parameter block */
int parmval = 1;
int srlmode;           /* Standard Runtime Library mode */ 
/* Set SRL to run in polled mode. */
srlmode = SR_POLLMODE;
if (sr_setparm(SRL_DEVICE, SR_MODEID, (void *)&srlmode) == -1) {
   /* process error */
}
.
.
. 
/* Open channel */
if ((chdev = dx_open("dxxxB1C1",0)) == -1) {
      /* process error */ 
} 
/* Set event mask to send the VAD events to the application */
dx_setevtmsk(chdev, DM_VADEVTS); 
/* To use barge-in and voice-activated recording, you must enable 
 * ECCH_VADINITIATED (enabled by default) and DXCH_BARGEIN using
 * ec_setparm( )
 */
ec_setparm (chdev, DXCH_BARGEIN, &parmval);
ec_setparm (chdev, ECCH_VADINITIATED, &parmval);
.
.
. 
/* Set up DV_TPT for record */
tpt.tp_type   = IO_EOT;
tpt.tp_termno = DX_MAXTIME;
tpt.tp_length = 60;  /* max time for record is 6 secs */
tpt.tp_flags  = TF_MAXTIME; 
/* Open file */
#ifdef WIN32 
if (( iott.io_fhandle = dx_fileopen("MESSAGE.VOX",O_RDWR| O_BINARY| O_CREAT| O_TRUNC,
                              0666)) == -1) {
      printf("File open error\n");
      exit(2);
}
#else
if (( iott.io_fhandle = open("MESSAGE.VOX",O_RDWR| O_CREAT| O_TRUNC, 0666)) == -1) {
      printf("File open error\n");
      exit(2);
}
#endif 
/* Set up DX_IOTT */
iott.io_bufp    = 0;
iott.io_offset  = 0;
iott.io_length  = -1;
iott.io_type = IO_DEV | IO_EOT; 
/*
 * Specify VOX file format for PCM at 8KHz.
 */
xpb.wFileFormat = FILE_FORMAT_VOX;
xpb.wDataFormat = DATA_FORMAT_PCM;
xpb.nSamplesPerSec = DRT_8KHZ;
xpb.wBitsPerSample = 8; 
/* Start recording. */ 
if (ec_reciottdata(chdev, &iott, &tpt, &xpb, EV_ASYNC | MD_NOGAIN) == -1) {
      printf("Error recording file - %s\n",    ATDV_ERRMSGP(chdev));
      exit(4);
} 
/* Open file to be played */
#ifdef WIN32 
if ((iott1.io_fhandle = dx_fileopen("SAMPLE.VOX",O_RDONLY|O_BINARY)) == -1) {
      printf("Error opening SAMPLE.VOX\n");
      exit(1);
}
#else
if (( iott1.io_fhandle = open("SAMPLE.VOX",O_RDONLY)) == -1) {
      printf("File open error\n");
      exit(2);
}
#endif 
iott1.io_bufp    = 0;
iott1.io_offset  = 0;
iott1.io_length  = -1;
iott1.io_type = IO_DEV | IO_EOT; 
/* Set up DV_TPT for play */
tpt1.tp_type   = IO_EOT;
tpt1.tp_termno = DX_MAXDTMF;
tpt1.tp_length = 1;
tpt1.tp_flags  = TF_MAXDTMF; 
/* Play intro message; use same file format as record */
if (dx_playiottdata(chdev,&iott1,&tpt1,&xpb,EV_ASYNC) == -1) {
      printf("Error playing file - %s\n",      ATDV_ERRMSGP(chdev));
      exit(4);
} 
/* Wait for barge-in and echo-cancelled record to complete */
while (1) {
     sr_waitevt(-1);
     ret = sr_getevttype();
     if (ret == TDX_BARGEIN) {
             printf("TDX_BARGEIN event received\n"); 
    }
     else if (ret == TDX_PLAY) {
             printf("Play Completed event received\n");
             break;
     }
     else if (ret == TEC_STREAM) {
             printf("TEC_STREAM - termination event");
             printf("for ec_stream and ec_reciottdata received\n");
             break;
     } 
    else if (ret == TDX_ERROR) {
             printf("ERROR event received\n");
     } else  {
             printf("Event 0x%x received.\n", ret);
     } 
} /* end while */ 
/* Close record file */
#ifdef WIN32 
if (dx_fileclose(iott.io_fhandle) == -1) {
     printf("Error closing MESSAGE.VOX \n");
     exit(1);
}
#else
if (close(iott.io_fhandle) == -1) {
     printf("Error closing MESSAGE.VOX \n");
     exit(1);
}
#endif 
/* Close play file */
#ifdef WIN32 
if (dx_fileclose(iott1.io_fhandle) == -1 {
     printf("Error closing SAMPLE.VOX \n");
     exit(1);
}
#else
if (close(iott1.io_fhandle) == -1) {
     printf("Error closing SAMPLE.VOX \n");
     exit(1);
}
#endif 
/* Close channel */
dx_close(chdev); 

Errors

If the function returns -1, use ATDV_LASTERR( ) to return the error code and ATDV_ERRMSGP( ) to return a descriptive error message.

One of the following error codes may be returned:

Error code
Reason
EDX_BADDEV Device handle is NULL or invalid.
EDX_BADPARM Parameter is invalid or not supported.
EDX_BUSY Channel is busy.
EDX_XPBPARM DX_XPB setting is invalid.
EDX_BADIOTT DX_IOTT setting is invalid.
EDX_SYSTEM Operating system error occurred.
EDX_BADWAVFILE WAVE file is invalid.
EDX_SH_BADCMD Command or WAVE file format is not supported.
EEC_UNSUPPORTED Device handle is valid but device does not support CSP.

See Also


PREV TOC HOME INDEX NEXT

Click here to contact Dialogic Customer Engineering

Copyright 2001, Intel Corporation
All rights reserved
This page generated December, 2001