这是录音函数: /************************************************************************* * NAME : trans_record(int, int, int) * DESCRIPTION : Performs a transaction record on two devices using a 3rd * device * INPUTS : int vox1, vox2 - devices to record * int recchan - voice device handle to do recording * OUTPUT : none. * RETURNS : Channel number or -1 if no match found * CAUTIONS : none. *************************************************************************/ void trans_record(int vox1, int vox2, int recchan) { /* This function will route LSI 1 and LSI 2 together and begin a transaction record on the two timeslots using a 3rd voice resource */
int rc; SC_TSINFO scinfo; long sctsa[2]; long scts; DV_TPT tpt; int fd; scinfo.sc_numts = 1; scinfo.sc_tsarrayp = &scts; rc = ag_getxmitslot(vox1, &scinfo); if (rc == -1) { printf("error getting scinfo on %s\n", ATDV_NAMEP(vox1)); exit(1); } printf("%s is on ts %d\n", ATDV_NAMEP(vox1), scts); sctsa[0] = scts; rc = ag_listen(vox2, &scinfo); if (rc == -1) { printf("error ch 2 listening to ch 1\n"); exit(1); } rc = ag_getxmitslot(vox2, &scinfo); if (rc == -1) { printf("error getting scinfo on %s\n", ATDV_NAMEP(vox2)); exit(1); } printf("%s is on ts %d\n", ATDV_NAMEP(vox2), scts); rc = ag_listen(vox1, &scinfo); if (rc == -1) { printf("error ch 1 listening to ch 2\n"); exit(1); } sctsa[1] = scts; scinfo.sc_numts = 2; scinfo.sc_tsarrayp = sctsa; if ((fd = dx_fileopen("chxfile.vox", O_CREAT | O_RDWR | O_BINARY, 0666)) == -1) { printf("File open error\n"); exit (1); } /* Set up DX_XPB structure Note: XPB structure must remain in scope during the entire record */
chaninfo[recchan].xpb.wFileFormat = FILE_FORMAT_VOX; chaninfo[recchan].xpb.wDataFormat = DATA_FORMAT_PCM; chaninfo[recchan].xpb.nSamplesPerSec = DRT_8KHZ; chaninfo[recchan].xpb.wBitsPerSample = 8; /*Set up DV_TPT structure */ dx_clrtpt (&tpt,1); tpt.tp_type = IO_EOT; tpt.tp_termno = DX_MAXDTMF; tpt.tp_length = 1; tpt.tp_flags = TF_MAXDTMF; /* Set up DX_IOTT structure Note: IOTT structure must remain in scope during the entire record */ chaninfo[recchan].iott.io_fhandle = fd; chaninfo[recchan].iott.io_type = IO_DEV | IO_EOT; chaninfo[recchan].iott.io_offset = 0; chaninfo[recchan].iott.io_length = -1; chaninfo[recchan].iott.io_bufp = 0;
printf("recording with mreciottdata\n"); dx_clrdigbuf(chaninfo[recchan].voxh); /* And record from both voice channels */ if (dx_mreciottdata(chaninfo[recchan].voxh, &chaninfo[recchan].iott, &tpt, &chaninfo[recchan].xpb, PM_TONE | EV_ASYNC,&scinfo) == -1) { printf("Error recording from dxxxB1C1 and dxxxB1C2\n"); printf("error = %s\n", ATDV_ERRMSGP(chaninfo[recchan].voxh)); exit(2); }
/*************************************************************************
* NAME : trans_record(int, int, int)
* DESCRIPTION : Performs a transaction record on two devices using a 3rd
* device
* INPUTS : int vox1, vox2 - devices to record
* int recchan - voice device handle to do recording
* OUTPUT : none.
* RETURNS : Channel number or -1 if no match found
* CAUTIONS : none.
*************************************************************************/
void trans_record(int vox1, int vox2, int recchan)
{
/* This function will route LSI 1 and LSI 2 together
and begin a transaction record on the two timeslots
using a 3rd voice resource */
int rc; SC_TSINFO scinfo;
long sctsa[2];
long scts;
DV_TPT tpt;
int fd; scinfo.sc_numts = 1;
scinfo.sc_tsarrayp = &scts; rc = ag_getxmitslot(vox1, &scinfo);
if (rc == -1)
{
printf("error getting scinfo on %s\n", ATDV_NAMEP(vox1));
exit(1);
} printf("%s is on ts %d\n", ATDV_NAMEP(vox1), scts); sctsa[0] = scts; rc = ag_listen(vox2, &scinfo);
if (rc == -1)
{
printf("error ch 2 listening to ch 1\n");
exit(1);
} rc = ag_getxmitslot(vox2, &scinfo);
if (rc == -1)
{
printf("error getting scinfo on %s\n", ATDV_NAMEP(vox2));
exit(1);
} printf("%s is on ts %d\n", ATDV_NAMEP(vox2), scts); rc = ag_listen(vox1, &scinfo);
if (rc == -1)
{
printf("error ch 1 listening to ch 2\n");
exit(1);
} sctsa[1] = scts; scinfo.sc_numts = 2;
scinfo.sc_tsarrayp = sctsa; if ((fd = dx_fileopen("chxfile.vox", O_CREAT | O_RDWR | O_BINARY, 0666)) == -1)
{
printf("File open error\n");
exit (1);
} /* Set up DX_XPB structure
Note: XPB structure must remain in scope during the entire
record
*/
chaninfo[recchan].xpb.wFileFormat = FILE_FORMAT_VOX;
chaninfo[recchan].xpb.wDataFormat = DATA_FORMAT_PCM;
chaninfo[recchan].xpb.nSamplesPerSec = DRT_8KHZ;
chaninfo[recchan].xpb.wBitsPerSample = 8; /*Set up DV_TPT structure */
dx_clrtpt (&tpt,1);
tpt.tp_type = IO_EOT;
tpt.tp_termno = DX_MAXDTMF;
tpt.tp_length = 1;
tpt.tp_flags = TF_MAXDTMF;
/* Set up DX_IOTT structure
Note: IOTT structure must remain in scope during the entire
record
*/
chaninfo[recchan].iott.io_fhandle = fd;
chaninfo[recchan].iott.io_type = IO_DEV | IO_EOT;
chaninfo[recchan].iott.io_offset = 0;
chaninfo[recchan].iott.io_length = -1;
chaninfo[recchan].iott.io_bufp = 0;
printf("recording with mreciottdata\n"); dx_clrdigbuf(chaninfo[recchan].voxh); /* And record from both voice channels */
if (dx_mreciottdata(chaninfo[recchan].voxh, &chaninfo[recchan].iott, &tpt, &chaninfo[recchan].xpb,
PM_TONE | EV_ASYNC,&scinfo) == -1)
{
printf("Error recording from dxxxB1C1 and dxxxB1C2\n");
printf("error = %s\n", ATDV_ERRMSGP(chaninfo[recchan].voxh));
exit(2);
}
}