如何检测对方的挂机音(Dialogic) ( 积分: 200 )

  • 主题发起人 主题发起人 babysheep
  • 开始时间 开始时间
B

babysheep

Unregistered / Unconfirmed
GUEST, unregistred user!
小弟急啊,怎么都检测不到对方的挂机音。
void sysinit()
{
if ( dx_setevtmsk( dxinfo[channum].devhandle, DM_RINGS|DM_LCOFF ) == -1 )
{
sys_exit("error dx_setevtmsk",dxinfo[channum].devhandle);
}

if (dx_deltones(dxinfo[channum].devhandle) == -1)
{
sys_exit("error deltones",dxinfo[channum].devhandle);
}
// build tone template for disconnect supervision
if (dx_blddtcad(TID_1,350,60,440,60,30,10,30,10,1)==-1)
{
sys_exit("error buliding tone template",dxinfo[channum].devhandle);
}
if (dx_addtone(dxinfo[channum].devhandle,0,0) ==-1)
{
sys_exit("error dx_addtone",dxinfo[channum].devhandle);
}
if (dx_distone(dxinfo[channum].devhandle,TID_1,DM_TONEOFF) ==-1)
{
sys_exit("error dx_distone",dxinfo[channum].devhandle);
}
}

void play(int channel)
{
/* Clear and then
Set the DV_TPT structures */
//**--The termination parameter table (TPT) specifies termination conditions for Dialogic devices.
tpt[ 0 ].tp_type = IO_CONT;
tpt[ 1 ].tp_type = IO_CONT;
tpt[ 2 ].tp_type = IO_EOT;
dx_clrtpt( tpt, 3 );
/* Terminate Play on Receiving any DTMF tone */
tpt[ 0 ].tp_termno = DX_MAXDTMF;
tpt[ 0 ].tp_length = 1;
tpt[ 0 ].tp_flags = TF_MAXDTMF|TF_CLRBEG;

/* Terminate on tone */
tpt[ 1 ].tp_termno = DX_TONE;
tpt[ 1 ].tp_length = TID_1;
tpt[ 1 ].tp_data = DX_TONEON;
tpt[ 1 ].tp_flags = TF_TONE;
/* Terminate Play on Loop Current Drop */
tpt[ 2 ].tp_termno = DX_LCOFF;
tpt[ 2 ].tp_length = 1;
tpt[ 2 ].tp_flags = TF_LCOFF;
/* Play VOX File on D/4x Channel, Normal Play Back */
if (dx_play( dxinfo[channel].devhandle, &iott[channel],tpt, EV_ASYNC )==-1 )
{
sys_exit("error playing file", dxinfo[channel].devhandle);
}
}
int process_event(int channel)
{
int event;
long bitmask;
/* 2/1/00 coughenb fix for PT16280 */
int returnEvent = DX_ONHOOK;

DX_CST *cstp;

/* Process the Event and Save the Next Channel State */
//**--sr_getevttype(? - returns the event type for the current event
event = sr_getevttype();
switch(event)
{
case TDX_CST:
//**--sr_getevtdatap(? - returns the address of the variable data block
cstp = (DX_CST *) sr_getevtdatap();
switch ( cstp->cst_event )
{

case DE_RINGS:
if ( dxinfo[ channel ].state == ST_WTRING )
{ /* Rings Received (Incoming Call) */
returnEvent = DE_RINGS;
break;
}
break;
case DE_DIGITS:
returnEvent = DE_DIGITS;

break;
case DE_LCOFF:
returnEvent = DE_LCOFF;
break;
case DE_TONEON:
// parse a disconnect tone as if it were an lcoff
returnEvent = DE_LCOFF;
break;
default:
break;
} // end switch
break;
case TDX_SETHOOK:
cstp = (DX_CST *) sr_getevtdatap();
switch(cstp->cst_event )
{
case DX_OFFHOOK:
returnEvent = DX_OFFHOOK;
break;
case DX_ONHOOK:
returnEvent = DX_ONHOOK;
break;
} // end switch
break;
case TDX_PLAYTONE:
returnEvent = TDX_PLAYTONE;
break;
case TDX_PLAY: /* Play Completed */
case TDX_GETDIG: /* Get Digits Completed */
//**--The ATDX_TERMMSK(? function returns the reason for the last I/O function termination on the channel chdev.
bitmask = ATDX_TERMMSK( dxinfo[ channel ].devhandle);
if ( bitmask &
TM_LCOFF )
{
returnEvent = TM_LCOFF;
break;
}

// give TM_DIGIT priority over TM_MAXDTMF
if ( bitmask &
TM_DIGIT )
{
returnEvent = TM_DIGIT;
break;
}
if ( bitmask &
TM_MAXDTMF )
{
returnEvent = TM_MAXDTMF;
break;
}

if ( bitmask &
TM_EOD )
{
returnEvent = TM_EOD;
break;
}

if ( bitmask &
TM_MAXTIME)
{
returnEvent = TM_MAXTIME;
break;
}

if ( bitmask &
TM_USRSTOP)
{
returnEvent = TM_USRSTOP;
break;
}

if ( bitmask &
TM_TONE)
{
returnEvent = TM_LCOFF;
break;
}
break;
default:
returnEvent = DX_ONHOOK;
break;
} // end switch
/* 2/1/00 coughenb fix for PT16280
- If no other value has been set then
return an DX_ONHOOK
event as the default.
*/
return(returnEvent);
}
 
小弟急啊,怎么都检测不到对方的挂机音。
void sysinit()
{
if ( dx_setevtmsk( dxinfo[channum].devhandle, DM_RINGS|DM_LCOFF ) == -1 )
{
sys_exit("error dx_setevtmsk",dxinfo[channum].devhandle);
}

if (dx_deltones(dxinfo[channum].devhandle) == -1)
{
sys_exit("error deltones",dxinfo[channum].devhandle);
}
// build tone template for disconnect supervision
if (dx_blddtcad(TID_1,350,60,440,60,30,10,30,10,1)==-1)
{
sys_exit("error buliding tone template",dxinfo[channum].devhandle);
}
if (dx_addtone(dxinfo[channum].devhandle,0,0) ==-1)
{
sys_exit("error dx_addtone",dxinfo[channum].devhandle);
}
if (dx_distone(dxinfo[channum].devhandle,TID_1,DM_TONEOFF) ==-1)
{
sys_exit("error dx_distone",dxinfo[channum].devhandle);
}
}

void play(int channel)
{
/* Clear and then
Set the DV_TPT structures */
//**--The termination parameter table (TPT) specifies termination conditions for Dialogic devices.
tpt[ 0 ].tp_type = IO_CONT;
tpt[ 1 ].tp_type = IO_CONT;
tpt[ 2 ].tp_type = IO_EOT;
dx_clrtpt( tpt, 3 );
/* Terminate Play on Receiving any DTMF tone */
tpt[ 0 ].tp_termno = DX_MAXDTMF;
tpt[ 0 ].tp_length = 1;
tpt[ 0 ].tp_flags = TF_MAXDTMF|TF_CLRBEG;

/* Terminate on tone */
tpt[ 1 ].tp_termno = DX_TONE;
tpt[ 1 ].tp_length = TID_1;
tpt[ 1 ].tp_data = DX_TONEON;
tpt[ 1 ].tp_flags = TF_TONE;
/* Terminate Play on Loop Current Drop */
tpt[ 2 ].tp_termno = DX_LCOFF;
tpt[ 2 ].tp_length = 1;
tpt[ 2 ].tp_flags = TF_LCOFF;
/* Play VOX File on D/4x Channel, Normal Play Back */
if (dx_play( dxinfo[channel].devhandle, &iott[channel],tpt, EV_ASYNC )==-1 )
{
sys_exit("error playing file", dxinfo[channel].devhandle);
}
}
int process_event(int channel)
{
int event;
long bitmask;
/* 2/1/00 coughenb fix for PT16280 */
int returnEvent = DX_ONHOOK;

DX_CST *cstp;

/* Process the Event and Save the Next Channel State */
//**--sr_getevttype(? - returns the event type for the current event
event = sr_getevttype();
switch(event)
{
case TDX_CST:
//**--sr_getevtdatap(? - returns the address of the variable data block
cstp = (DX_CST *) sr_getevtdatap();
switch ( cstp->cst_event )
{

case DE_RINGS:
if ( dxinfo[ channel ].state == ST_WTRING )
{ /* Rings Received (Incoming Call) */
returnEvent = DE_RINGS;
break;
}
break;
case DE_DIGITS:
returnEvent = DE_DIGITS;

break;
case DE_LCOFF:
returnEvent = DE_LCOFF;
break;
case DE_TONEON:
// parse a disconnect tone as if it were an lcoff
returnEvent = DE_LCOFF;
break;
default:
break;
} // end switch
break;
case TDX_SETHOOK:
cstp = (DX_CST *) sr_getevtdatap();
switch(cstp->cst_event )
{
case DX_OFFHOOK:
returnEvent = DX_OFFHOOK;
break;
case DX_ONHOOK:
returnEvent = DX_ONHOOK;
break;
} // end switch
break;
case TDX_PLAYTONE:
returnEvent = TDX_PLAYTONE;
break;
case TDX_PLAY: /* Play Completed */
case TDX_GETDIG: /* Get Digits Completed */
//**--The ATDX_TERMMSK(? function returns the reason for the last I/O function termination on the channel chdev.
bitmask = ATDX_TERMMSK( dxinfo[ channel ].devhandle);
if ( bitmask &
TM_LCOFF )
{
returnEvent = TM_LCOFF;
break;
}

// give TM_DIGIT priority over TM_MAXDTMF
if ( bitmask &
TM_DIGIT )
{
returnEvent = TM_DIGIT;
break;
}
if ( bitmask &
TM_MAXDTMF )
{
returnEvent = TM_MAXDTMF;
break;
}

if ( bitmask &
TM_EOD )
{
returnEvent = TM_EOD;
break;
}

if ( bitmask &
TM_MAXTIME)
{
returnEvent = TM_MAXTIME;
break;
}

if ( bitmask &
TM_USRSTOP)
{
returnEvent = TM_USRSTOP;
break;
}

if ( bitmask &
TM_TONE)
{
returnEvent = TM_LCOFF;
break;
}
break;
default:
returnEvent = DX_ONHOOK;
break;
} // end switch
/* 2/1/00 coughenb fix for PT16280
- If no other value has been set then
return an DX_ONHOOK
event as the default.
*/
return(returnEvent);
}
 
以上是挂机的核心程序,但是一直都无法检测出挂机音,请各位帮帮忙,是不是
if (dx_blddtcad(TID_1,350,60,440,60,30,10,30,10,1)==-1)里的参数有问题呢?如何检测挂机音?
 
你自己写驱动??如果是,我不清楚
如果是用的话,我以前用的语音卡有一个OCX(厂家提供)是有一个挂机事件的.
 
自己设置全局音,然后检测到这个tone会触发事件
 
后退
顶部