Tuesday, May 7, 2013

dialogic api 로 녹음중 통화 끊김 감지. dialogic api detect disconnected using dual tone


dialogic global call api를 이용한 녹음.

녹음 중 전화를 끊어버린 상황을 감지하는 소스플그램임.


This source program presents how to detect disonnected while recording.

dual tone (480, 30, 620, 40) is korean standard. find your self what tone using in your country.




//CH_DEV는 LINE 번호임. 1채널인경우 1임.

#define CH_DEV 1


CString CDialogicLib::Record(CString savefilename, int timeout_sec )
{
 CString result="";
 DV_TPT tpt[10];            /* termination parameter table */
 DX_XPB xpb;

 xpb.nSamplesPerSec = DRT_11KHZ;
 xpb.wFileFormat = FILE_FORMAT_WAVE;
 xpb.wDataFormat = DATA_FORMAT_ALAW;
 xpb.wBitsPerSample = 8;

 #define TID_1    101

 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;

 // Terminate on Loop Current Drop (call disconnect)
 tpt[1].tp_type = IO_CONT;
 tpt[1].tp_termno = DX_LCOFF;    
 tpt[1].tp_length = 1;          //  I have also tried 3
 tpt[1].tp_flags = TF_LCOFF;

 tpt[2].tp_type = IO_CONT;
 tpt[2].tp_termno = DX_MAXTIME;        /* Function Time */
 tpt[2].tp_length = (timeout_sec * 10);    /* 10 seconds (100 msec resolution timer) */
 tpt[2].tp_flags = TF_MAXTIME;        /* Edge-triggered */

 tpt[3].tp_type = IO_EOT;
 tpt[3].tp_termno = DX_TONE;
 tpt[3].tp_length = TID_1;
 tpt[3].tp_flags = TF_TONE;
 tpt[3].tp_data = DX_TONEON;


 dx_deltones(CH_DEV);
 dx_blddt(TID_1, 480, 30, 620, 40,TN_LEADING );
 dx_addtone(CH_DEV,NULL,0);
 dx_enbtone( CH_DEV, TID_1, DM_TONEON | DM_TONEOFF );

 dx_clrdigbuf(CH_DEV);

 dx_setevtmsk(CH_DEV, GCEV_DISCONNECTED);

 /* Start 11KHz A-law recording */
 if (dx_recwav(CH_DEV, savefilename, tpt,   &xpb,PM_TONE|EV_SYNC) == -1)
 {
  return "ERROR";
 }
 else
 {
  dx_clrdigbuf(CH_DEV);


  switch(ATDX_TERMMSK(CH_DEV))
  {
  case TM_MAXDTMF:
   return "SUCCESS";
  case TM_LCOFF :
   result = "LCOFF";
   break;
  case TM_TONE:
   result ="TONE";
   break;
  case TM_MAXTIME:
   result = "MAXTIME";
   break;
  }
  return "UNKNOWN";
 }

}

No comments:

Post a Comment