⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 check.cpp

📁 Dialogic D41/E语音卡 的一个应用源代码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
		break;
    case ST_PINNEWPASS:
        port[channel].msg_fh = dx_fileopen("c:\\yy\\inpassn.vox",O_RDONLY|O_BINARY);
        errcode = playfh(channel,port[channel].msg_fh);
		break;
    case ST_PINNEWPASSA:
        port[channel].msg_fh = dx_fileopen("c:\\yy\\inpassa.vox",O_RDONLY|O_BINARY);
        errcode = playfh(channel,port[channel].msg_fh);
		break;
    case ST_CHGPASSOK:
        port[channel].msg_fh = dx_fileopen("c:\\yy\\chgpass.vox",O_RDONLY|O_BINARY);
        errcode = playfh(channel,port[channel].msg_fh);
		break;
    case ST_PASSNOCHG:
        port[channel].msg_fh = dx_fileopen("c:\\yy\\pnochg.vox",O_RDONLY|O_BINARY);
        errcode = playfh(channel,port[channel].msg_fh);
		break;
    case ST_PINBANK:
        port[channel].msg_fh = dx_fileopen("c:\\yy\\inbank.vox",O_RDONLY|O_BINARY);
        errcode = playfh(channel,port[channel].msg_fh);
		break;
    case ST_BANKPLAY1:
        port[channel].msg_fh = dx_fileopen("c:\\yy\\bankplay.vox",O_RDONLY|O_BINARY);
        errcode = playfh(channel,port[channel].msg_fh);
		break;
    case ST_BANKPLAY2:
		//get_bankfile(channel);
        //port[channel].msg_fh = dx_fileopen("c:\\yy\\bankplay.vox",O_RDONLY|O_BINARY);
        errcode = play_num(channel,port[channel].bankno);
		break;
    case ST_PINCHECK:
        port[channel].msg_fh = dx_fileopen("c:\\yy\\incheck.vox",O_RDONLY|O_BINARY);
        errcode = playfh(channel,port[channel].msg_fh);
		break;
    case ST_CHECKPLAY1:
        port[channel].msg_fh = dx_fileopen("c:\\yy\\chkplay.vox",O_RDONLY|O_BINARY);
        errcode = playfh(channel,port[channel].msg_fh);
		break;
    case ST_CHECKPLAY2:
        //port[channel].msg_fh = dx_fileopen("c:\\yy\\NUM.vox",O_RDONLY|O_BINARY);
        //errcode = playfh(channel,port[channel].msg_fh);
        errcode = play_num(channel,port[channel].checkno);
        break;
    case ST_USEPLAY3:
    case ST_BANKPLAY3:
    case ST_CHECKPLAY3:
        port[channel].msg_fh = dx_fileopen("c:\\yy\\okorup.vox",O_RDONLY|O_BINARY);
		errcode = playfh(channel,port[channel].msg_fh);
		break;
	case ST_GETUSESEL:
	case ST_GETBANKSEL:
	case ST_GETCHECKSEL:
	case ST_GETRECORDSEL:
        errcode = get_digits(channel,1,50);
        break;
    case ST_INBANK:
        errcode = get_digits(channel,3,100);
        break;
    case ST_INCHECK:
        errcode = get_digits(channel,6,100);
		break;
    case ST_USEOUTTIME:
        port[channel].msg_fh = dx_fileopen("c:\\yy\\outtime.vox",O_RDONLY|O_BINARY);
        errcode = playfh(channel,port[channel].msg_fh);
		break;
    case ST_CHECKLASTOK:
        port[channel].msg_fh = dx_fileopen("c:\\yy\\chklast.vox",O_RDONLY|O_BINARY);
        errcode = playfh(channel,port[channel].msg_fh);
		break;
    case ST_NOLAST:
        port[channel].msg_fh = dx_fileopen("c:\\yy\\nolast.vox",O_RDONLY|O_BINARY);
        errcode = playfh(channel,port[channel].msg_fh);
		break;
    case ST_CHECKLAST:
        port[channel].msg_fh = dx_fileopen("c:\\yy\\lastdate.vox",O_RDONLY|O_BINARY);
        errcode = playfh(channel,port[channel].msg_fh);
		break;
    case ST_LASTTIME:
        //port[channel].msg_fh = dx_fileopen("c:\\yy\\chklast.vox",O_RDONLY|O_BINARY);
        errcode = play_num(channel,port[channel].lasttime);
		break;
    case ST_USETEL1:
 		strcpy(file_p,"c:\\usevox\\");
		strcat(file_p,port[channel].useno);
		strcat(file_p,".vox");
        if((port[channel].msg_fh = dx_fileopen(file_p,O_RDONLY|O_BINARY))==-1)
		{
			port[channel].msg_fh = dx_fileopen("c:\\yy\\usetele.vox",O_RDONLY|O_BINARY);
			errcode = playfh(channel,port[channel].msg_fh);
		}
		else 
		{
			errcode = playfh(channel,port[channel].msg_fh);
			port[channel].state=ST_USETEL2;
		}
		break;
    case ST_USETEL2:
        errcode = play_num(channel,port[channel].tele);
		break;
    case ST_CHECKOK:
        port[channel].msg_fh = dx_fileopen("c:\\yy\\checkok.vox",O_RDONLY|O_BINARY);
        errcode = playfh(channel,port[channel].msg_fh);
		break;
    case ST_PRECORD:
        port[channel].msg_fh = dx_fileopen("c:\\yy\\precord.vox",O_RDONLY|O_BINARY);
        errcode = playfh(channel,port[channel].msg_fh);
		break;
    case ST_RECORDSEL:
        port[channel].msg_fh = dx_fileopen("c:\\yy\\recsel.vox",O_RDONLY|O_BINARY);
        errcode = playfh(channel,port[channel].msg_fh);
		break;
    case ST_RECORD:
		strcpy(file_p,"c:\\usevox\\");
		strcat(file_p,port[channel].useno);
		strcat(file_p,".vox");
	    port[channel].msg_fh =dx_fileopen(file_p, _O_RDWR | _O_CREAT | _O_TRUNC | _O_BINARY, 0644);
        errcode = record(channel,port[channel].msg_fh);
		break;
    case ST_PLAYRECORD:
		strcpy(file_p,"c:\\usevox\\");
		strcat(file_p,port[channel].useno);
		strcat(file_p,".vox");
        port[channel].msg_fh = dx_fileopen(file_p,O_RDONLY|O_BINARY);
        errcode = playfh(channel,port[channel].msg_fh);
		break;

    case ST_USEERR:
        port[channel].msg_fh = dx_fileopen("c:\\yy\\useerr.vox",O_RDONLY|O_BINARY);
        errcode = playfh(channel,port[channel].msg_fh);
		break;
    case ST_PASSERR:
        port[channel].msg_fh = dx_fileopen("c:\\yy\\passerr.vox",O_RDONLY|O_BINARY);
        errcode = playfh(channel,port[channel].msg_fh);
		break;
    case ST_BANKERR:
        port[channel].msg_fh = dx_fileopen("c:\\yy\\bankerr.vox",O_RDONLY|O_BINARY);
        errcode = playfh(channel,port[channel].msg_fh);
		break;
    case ST_SYSERR:
        port[channel].msg_fh = dx_fileopen("c:\\yy\\syserr.vox",O_RDONLY|O_BINARY);
        errcode = playfh(channel,port[channel].msg_fh);
		break;

    case ST_GOODBY:
         port[channel].msg_fh =  dx_fileopen("c:\\yy\\goodby.vox", O_RDONLY|O_BINARY ); 
         //rcode = playfh(channel,port[channel].msg_fh);
         errcode = play_no_stop(channel,port[channel].msg_fh);
         break;
	case ST_ONHK:
			if(ATDX_STATE(port[channel].devhandle)==CS_IDLE)	
               	errcode = dx_sethook(port[channel].devhandle,DX_ONHOOK,EV_ASYNC);
			else
			{
				errcode = dx_stopch(port[channel].devhandle,EV_ASYNC);
            }

         if (errcode!=-1)
			 printf("\nonhook the call on channel %d",channel);
		 else 
		 {
			 printf("%s: \n",ATDV_ERRMSGP(port[channel].devhandle));
			 printf("\nonhook channel:%derror",channel);
		 }
         break;

    default:
		break;
    }

    return (errcode);
}

int record(int channel,int fh)
{
	//DV_TPT tpt[4];
	//DX_IOTT iott;
	if(fh==-1)
		return -1;
	dx_clrtpt(tpt,4);

	tpt[ 0 ].tp_type = IO_CONT;
	tpt[ 0 ].tp_termno = DX_MAXDTMF;
	tpt[ 0 ].tp_length = 1;
	tpt[ 0 ].tp_flags = TF_MAXDTMF;

	tpt[ 1 ].tp_type = IO_CONT;
	tpt[ 1 ].tp_termno = DX_TONE;
	tpt[ 1 ].tp_length = TID_1;
	tpt[ 1 ].tp_flags = TF_TONE;
	tpt[ 1 ].tp_data  =DX_TONEON;

   /* Terminate on 10s   of silence   */ 
	tpt[ 2 ].tp_type = IO_CONT;
	tpt[ 2 ].tp_termno = DX_MAXSIL;
	tpt[ 2 ].tp_length = 100;
	tpt[ 2 ].tp_flags = TF_MAXSIL;

   /* Terminate rec after 20 Seconds */
	tpt[ 3 ].tp_type = IO_EOT;
	tpt[ 3 ].tp_termno = DX_MAXTIME;
	tpt[ 3 ].tp_length = 200;
	tpt[ 3 ].tp_flags = TF_MAXTIME;

	iott.io_fhandle = fh;
	iott.io_type = IO_DEV|IO_EOT;
	iott.io_bufp = 0;
	iott.io_offset = 0;
	iott.io_length = -1;

	if (dx_rec(port[channel].devhandle, &iott, tpt, PM_TONE | EV_ASYNC | MD_ADPCM | PM_SR6) != 0) 
	{
		printf("error dx_rec");
		return(-1);
	}
	return 0;
}

/****************************************************************
*        NAME : get_digits(channel,bufp,num)
* DESCRIPTION : set up RWB and call getdtmfs()
*       INPUT : channel = channel number
*             : bufp = pointer to dtmf buffer
*             : num = get digit number
*      OUTPUT : none
*     RETURNS : error code from getdtmfs()
*    CAUTIONS : none
****************************************************************/
int get_digits(int channel,int num,int timeout)
{
	dx_clrtpt(tpt,4);
	/* Terminate GetDigits on Receiving MAXDTMF Digits */
	tpt[ 0 ].tp_type = IO_CONT;
	tpt[ 0 ].tp_termno = DX_MAXDTMF;
	tpt[ 0 ].tp_length = num;
	tpt[ 0 ].tp_flags = TF_MAXDTMF;

   /* Terminate GetDigits on "#"          */
	tpt[ 1 ].tp_type = IO_CONT;
	tpt[ 1 ].tp_termno = DX_DIGMASK;
	tpt[ 1 ].tp_length = DM_P;       
	tpt[ 1 ].tp_flags = TF_DIGMASK;

   /* Terminate GetDigits on "C"          */
	tpt[ 2 ].tp_type = IO_CONT;
	tpt[ 2 ].tp_termno = DX_DIGMASK;
	tpt[ 2 ].tp_length = DM_C;       
	tpt[ 2 ].tp_flags = TF_DIGMASK;

   /* Terminate GetDigits after 15 Seconds */
	tpt[ 3 ].tp_type = IO_EOT;
	tpt[ 3 ].tp_termno = DX_MAXTIME;
	tpt[ 3 ].tp_length = timeout;
	tpt[ 3 ].tp_flags = TF_MAXTIME;
   //dev=port[channel].devhandle;
   return (dx_getdig(port[channel].devhandle,tpt,&(port[channel].buffer),EV_ASYNC));
   }

int playfh(int i,int fh)
{
	//static DV_TPT tpt[4];
	//static DX_IOTT iott[10];
	
	dx_clrtpt(tpt,3);
   // Terminate Play on Receiving any DTMF tone 
	tpt[0].tp_type = IO_CONT;
	tpt[0].tp_termno = DX_MAXDTMF;
	tpt[0].tp_length = 1;
	tpt[0].tp_flags = TF_MAXDTMF;

	tpt[1].tp_type = IO_CONT;
	tpt[1].tp_termno = DX_TONE;
	tpt[1].tp_length = TID_1;
	tpt[1].tp_flags = TF_TONE;
	tpt[1].tp_data  =DX_TONEON;

	tpt[2].tp_type = IO_EOT;
	tpt[2].tp_termno = DX_LCOFF;
	tpt[2].tp_length = 1;
	tpt[2].tp_flags = TF_LCOFF;

	iott.io_type=IO_DEV|IO_EOT;
	iott.io_bufp=0;
	iott.io_offset=0;
	iott.io_length=-1;
	iott.io_fhandle= fh;
	
	dx_clrdigbuf(port[i].devhandle);
	/* Play VOX File on D/4x Channel, Normal Play Back */
	if (dx_play(port[i].devhandle,&iott,tpt,EV_ASYNC)==-1 )
	{
		printf("%s: \n",ATDV_ERRMSGP(port[i].devhandle));
		return -1;
	}
	return 0;
}
int play_num(int chan,char *num)
{
	//static DV_TPT tpt[4];
	static DX_IOTT iott[10];
	int len,i;
	len=strlen(num);
	printf("len:%d",len);
	if(len>10)
		return(-1);
	dx_clrtpt(tpt,3);
   // Terminate Play on Receiving any DTMF tone 
	tpt[0].tp_type = IO_CONT;
	tpt[0].tp_termno = DX_MAXDTMF;
	tpt[0].tp_length = 1;
	tpt[0].tp_flags = TF_MAXDTMF;

	tpt[1].tp_type = IO_CONT;
	tpt[1].tp_termno = DX_TONE;
	tpt[1].tp_length = TID_1;
	tpt[1].tp_flags = TF_TONE;
	tpt[1].tp_data  =DX_TONEON;

	tpt[2].tp_type = IO_EOT;
	tpt[2].tp_termno = DX_LCOFF;
	tpt[2].tp_length = 1;
	tpt[2].tp_flags = TF_LCOFF;
	for (i=0;i<len-1;i++)
	{

		iott[i].io_type=IO_DEV;
		iott[i].io_offset=(num[i]-48)*1800;
		iott[i].io_length=1800;
		iott[i].io_fhandle=numfh;
	}
	iott[len-1].io_type=IO_DEV|IO_EOT;
	iott[len-1].io_offset=(num[i]-48)*1800;
	iott[len-1].io_length=1800;
	iott[len-1].io_fhandle=numfh;
	
	dx_clrdigbuf(port[chan].devhandle);
	/* Play VOX File on D/4x Channel, Normal Play Back */
	if (dx_play(port[chan].devhandle,iott,tpt,EV_ASYNC)==-1 )
	{
		printf("%s: \n",ATDV_ERRMSGP(port[chan].devhandle));
		return -1;
	}
	return 0;
}

int play_no_stop(int i,int fh)
{
	
	dx_clrtpt(tpt,2);

	tpt[0].tp_type = IO_CONT;
	tpt[0].tp_termno = DX_TONE;
	tpt[0].tp_length = TID_1;
	tpt[0].tp_flags = TF_TONE;
	tpt[0].tp_data  =DX_TONEON;

	tpt[1].tp_type = IO_EOT;
	tpt[1].tp_termno = DX_LCOFF;
	tpt[1].tp_length = 1;
	tpt[1].tp_flags = TF_LCOFF;

	iott.io_type=IO_DEV|IO_EOT;
	iott.io_bufp=0;
	iott.io_offset=0;
	iott.io_length=-1;
	iott.io_fhandle= fh;
	
	dx_clrdigbuf(port[i].devhandle);
	/* Play VOX File on D/4x Channel, Normal Play Back */
	if (dx_play(port[i].devhandle,&iott,tpt,EV_ASYNC)==-1 )
	{
		printf("%s: \n",ATDV_ERRMSGP(port[i].devhandle));
		return -1;
	}
	return 0;
}

/*void get_path(char *path_f,int channel)
{
	char c1[20],cc,ccase_no[8];
	int i;
	//long case_no;
	//printf("ldate:%ld",ldate);
    c1[0]=0;
	cc=(port[channel].case_no[3]-'0')%2+'0';
    strcpy(path_f,"c:\\");
    path_f[3]=cc;
    path_f[4]=0;
    strcat(path_f,"\\");
	path_f[5]=port[channel].case_no[4];
	path_f[6]=port[channel].case_no[5];
    path_f[7]=0;
    strcat(path_f,"\\");
	path_f[8]=port[channel].case_no[6];
	path_f[9]=port[channel].case_no[7];
    path_f[10]=0;
    strcat(path_f,"\\");
    strcat(path_f,ccase_no);
    strcat(path_f,".vox");
	printf("\n file name:%s",path_f);
}
*/
void print_state()
{
	int i;
	//printf("\n");
	for (i=1;i<=4;i++)
		printf("\n通道[%d]状态:%d|%s",i,port[i].state,(ATDX_HOOKST(port[i].devhandle))?("摘机"):("挂机"));
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -