You are on page 1of 10

1 s hm trong CTI 1.

Hm m thit b Dx_open(): Chc nng m 1 thit b m thanh v tr v 1 tn hiu iu khin thit b i thoi duy nht nhn dng thit b. Mt thit b c th c m nhiu hn mt ln bng bt k s lng cc quy trnh. #include <srllib.h> #include <dxxxlib.h> #include <windows.h> main() { int chdev; /* channel descriptor */ tham s nhn dng knh . . . /* Open Channel */ m knh if ((chdev = dx_open("dxxxB1C1",NULL)) == -1) { /* process error */ } . . } - cc tham s: +) *namep: con tr ti tn thit b m +) oflags: d tr cho tng lai 2. hm ng thit b chc nng ng cc thit b m thoi m c m trc do s dng hm dx_open(). N pht i cc tn hiu iu khin v ph v cc ng lien kt x l cuc gi vi cc thit b thng qua tn hiu iu khin ny. N s pht i cc tn hiu thng bo rng thit b trng thi ri hay bn. #include <srllib.h> #include <dxxxlib.h> #include <windows.h> main() { DX_CAP cap; // The DX_CAP structure is used to modify call analysis channel parameters when using dx_dial( ).) int chdev; /* continue processing */ if (dx_close (chdev) ==-1) +) cc tham s: - dev: knh m thoi hp l hoc thng bo thit b

3. dx_play(): chc nng thc hin vic ghi li d liu thoi hoc truyn ti d liu ca ADSI (giao din dch v hin th tng t) trn 1 knh c bit. D liu thoi c th n t mt vi s kt hp ca cc file data, b nh hoc cc thit b ngoi vi. +) Cc tham s: - chdev: thng bo thit b knh thoi hp l - *iottp: con tr tr ti cu trc bng truyn ti I/O - *tptp: con tr tr ti cu trc bng tham s u cui - Mode: ch thc hin ng b hay bt ng b Using dx_play( ) in synchronous mode. #include <fcntl.h> #include <srllib.h> #include <dxxxlib.h> #include <windows.h> main() { int chdev; DX_IOTT iott; DV_TPT tpt; DV_DIGIT dig; . . /* Open the device using dx_open( ). Get channel device descriptor in * chdev. */ if ((chdev = dx_open("dxxxB1C1",NULL)) == -1) { /* process error */ } /* set up DX_IOTT */ The DX_IOTT structure identifies a source or destination for voice data. It is used with the dx_play( ) and dx_rec( ) functions iott.io_type = IO_DEV|IO_EOT; iott.io_bufp = 0; iott.io_offset = 0; iott.io_length = -1; /* play till end of file */ if((iott.io_fhandle = dx_fileopen("prompt.vox", O_RDONLY| O_BINARY)) == -1) { /* process error */ } /* set up DV_TPT */ Termination Parameter Table dx_clrtpt(&tpt,1); tpt.tp_type = IO_EOT; tpt.tp_termno = DX_MAXDTMF; /* only entry in the table */ /* Maximum digits */
2

tpt.tp_length = 4; /* terminate on four digits */ tpt.tp_flags = TF_MAXDTMF; /* Use the default flags */ /* clear previously entered digits */ if (dx_clrdigbuf(chdev) == -1) { /* process error */ } /* Now play the file */ if (dx_play(chdev,&iott,&tpt,EV_SYNC) == -1) { /* process error */ } /* get digit using dx_getdig( ) and continue processing. */ . . } 4. dx_dial: Chc nng: Quay mt chui k t ASCII trn mt knh ang m v ri. V ty chn cho php Call Analysis cung cp thm thng tin v cuc gi. Nu knh ang trng thi ONHOOK, vic quay s s din ra khng c ty chn Call Analysis +) cc tham s: - chdev: ch ra thit b knh thoi hp l - *dialstrp: con tr tr ti chui quay s ASCIIZ - *cap: con tr tr ti cu trc tham s phn tch cuc gi - Mode: Call Analysis with default parameters (Synchronous Mode) /* Call Analysis with default parameters and synchronous mode. */ #include <srllib.h> #include <dxxxlib.h> #include <windows.h> main() { int cares, chdev; DX_CAP capp; /* open the channel using dx_open( ). Obtain channel device descriptor * in chdev */ if ((chdev = dx_open("dxxxB1C1",NULL)) == -1) { /* process error */ } /* take the phone off-hook */ if ((dx_sethook(chdev,DX_OFFHOOK,EV_SYNC)) == -1) { /* process error */ }
3

/* Perform the outbound dial with call analysis enabled and capp set to * NULL */ if ((cares = dx_dial(chdev,"5551212",(DX_CAP *)NULL,DX_CALLP| EV_SYNC)) == -1) { /* perform error routine */ } /* Analyze the call analysis results as in Example 1 */ . . } 5. dx_clrdigbuf( ) Chc nng xa tt c cc s trong b m s firmware ca knh c quy nh bi chdev. +) cc tham s: - chdev: ch ra thit b knh m thoi hp l Example #include <srllib.h> #include <dxxxlib.h> #include <windows.h> main() { int chdev; /* channel descriptor */ . . . /* Open Channel */ if ((chdev = dx_open("dxxxB1C1",NULL)) == -1) { /* process error */ } /* Clear digit buffer */ if (dx_clrdigbuf(chdev) == -1) { /* process error*/ } . .

6. dx_getdig()
4

chc nng thu cc s t mt knh b m s. nh vo chc nng, thu cc s c vit di dng ASCIIZ trong b m m c sp xp nh 1 cu trc DV_DIGIT. Phng php thu cc s c lp vi ch d s thit lp bi hm dx_setdigtyp() (bng cc s thoi chun) hoc do hm dx_addtone() (cho cc s nh ngha ngi dung). Cc tham s: - chdev - *tptp: con tr tr ti cu trc bng tham s u cui - *digitp: con tr tr ti cu trc b m s ngi dng - Mode: thit lp ch ng b hoc bt ng b Example 1: Using dx_getdig( ) in synchronous mode #include <stdio.h> #include <srllib.h> #include <dxxxlib.h> #include <windows.h> main() { DV_TPT tpt[3]; DV_DIGIT digp; int chdev, numdigs, cnt; /* open the channel with dx_open( ). Obtain channel device descriptor * in chdev */ if ((chdev = dx_open("dxxxB1C1",NULL)) == -1) { /* process error */ } /* initiate the call */ . . /* Set up the DV_TPT and get the digits */ dx_clrtpt(tpt,3); tpt[0].tp_type = IO_CONT; tpt[0].tp_termno = DX_MAXDTMF; /* Maximum number of digits */ tpt[0].tp_length = 4; /* terminate on 4 digits */ tpt[0].tp_flags = TF_MAXDTMF; /* terminate if already in buf. */ tpt[1].tp_type = IO_CONT; tpt[1].tp_termno = DX_LCOFF; /* LC off termination */ tpt[1].tp_length = 3; /* Use 30 ms (10 ms resolution * timer) */ tpt[1].tp_flags = TF_LCOFF|TF_10MS; /* level triggered, clear history,
5

* timer) */ tpt[2].tp_flags = TF_MAXTIME; /* Edge-triggered */ /* clear previously entered digits */ if (dx_clrdigbuf(chdev) == -1) { /* process error */ } if ((numdigs = dx_getdig(chdev,tpt, &digp, EV_SYNC)) == -1) { /* process error */ } for (cnt=0; cnt < numdigs; cnt++) { printf("\nDigit received = %c, digit type = %d", digp.dg_value[cnt], digp.dg_type[cnt]); } /* go to next state */ . . } 7. dx_rec(): ghi li d liu thoi t 1 knh n. D liu c th c ghi ti mt s kt hp ca cc file d liu, b nh, hoc cc thit b ngoi vi. Sau khi dx_rec() c gi, vic ghi c tip tc cho n khi hm dx_stopch() c gi, d liu yu cu chi tit trong DX_IOTT th c p ng, hoc cho n khi 1 trong nhng iu kin cho u cui trong DV_TPT c p ng. Khi dx_rec() kt thc, thng tin trng thi ca knh c c th c truy cp s dng cc hm m rng. +) cc tham s: - chdev - *iottp - *tptp - Mode Example 1: Using dx_rec( ) in synchronous mode #include <fcntl.h> #include <srllib.h> #include <dxxxlib.h> #include <windows.h> #define MAXLEN 10000 main() { DV_TPT tpt; DX_IOTT iott[2]; int chdev; char basebufp[MAXLEN];
6

tpt[2].tp_type = IO_EOT; tpt[2].tp_termno = DX_MAXTIME; tpt[2].tp_length = 100; resolution

* 10 ms resolution */ /* Function Time */ /* 10 seconds (100 ms

*/

/* * open the channel using dx_open( ) */ if ((chdev = dx_open("dxxxB1C1",NULL)) == -1) { /* process error */ } /* * Set up the DV_TPT structures for MAXDTMF */ dx_clrtpt(&tpt,1); tpt.tp_type = IO_EOT; /* last entry in the table

tpt.tp_termno = DX_MAXDTMF; /* Maximum digits */ tpt.tp_length = 1; /* terminate on the first digit */ tpt.tp_flags = TF_MAXDTMF; /* Use the default flags */ /* * Set up the DX_IOTT. The application records the voice data to memory * allocated by the user. */ iott[0].io_type = IO_MEM|IO_CONT; /* Record to memory */ iott[0].io_bufp = basebufp; /* Set up pointer to buffer */ iott[0].io_offset = 0; /* Start at beginning of buffer */ iott[0].io_length = MAXLEN; /* Record 10,000 bytes of voice data */ iott[1].io_type = IO_DEV|IO_EOT; /* Record to file, last DX_IOTT * entry */ iott[1].io_bufp = 0; /* Set up pointer to buffer */ iott[1].io_offset = 0; /* Start at beginning of buffer */ iott[1].io_length = MAXLEN; /* Record 10,000 bytes of voice * data */ if((iott[1].io_fhandle = dx_fileopen("file.vox", O_RDWR|O_CREAT|O_TRUNC|O_BINARY,0666)) == -1) { /* process error */ } /* clear previously entered digits */ if (dx_clrdigbuf(chdev) == -1) { /* process error */ } if (dx_rec(chdev,&iott[0],&tpt,RM_TONE|EV_SYNC) == -1) {
7

} /* Analyze the data recorded */ . .

/* process error */

8. dx_fileopen(): m 1 file chi tit chi tit bi filep, v chun b file cho vic c v ghi. cc tham s: - *filep: tn file - Flags: c cho php hot ng - Pmode: ch cho php Example /* Play a voice file. Terminate on receiving 4 digits or at end of file*/ #include <fcntl.h> #include <srllib.h> #include <dxxxlib.h> #include <windows.h> main() { int chdev; DX_IOTT iott; DV_TPT tpt; DV_DIGIT dig; . . /* Open the device using dx_open( ). Get channel device descriptor in * chdev. */ if ((chdev = dx_open("dxxxB1C1",NULL)) == -1) { /* process error */ } /* set up DX_IOTT */ iott.io_type = IO_DEV|IO_EOT; iott.io_bufp = 0; iott.io_offset = 0; iott.io_length = -1; /* play till end of file */ if((iott.io_handle = dx_fileopen("prompt.vox", O_RDONLY| O_BINARY)) == -1) { /* process error */ } /* set up DV_TPT */ dx_clrtpt(&tpt,1);
8

*/ */

tpt.tp_type

= IO_EOT;

/* only entry in the table /* Maximum digits */ /* terminate on four digits

tpt.tp_termno = DX_MAXDTMF; tpt.tp_length = 4;

tpt.tp_flags = TF_MAXDTMF; /* Use the default flags */ /* clear previously entered digits */ if (dx_clrdigbuf(chdev) == -1) { /* process error */ } /* Now play the file */ if (dx_play(chdev,&iott,&tpt,EV_SYNC) == -1) { /* process error */ } /* get digit using dx_getdig( ) and continue processing. */ . . if (dx_fileclose(iott.io_handle) == -1) { /* process error */ }

} 9. dx_fileread(): c d liu t 1 file lien kt vi file ch dn. hm s c s cc byte t file lien kt vi s ch dn ti b m. s cc byte c c th ln hn gi tr ca bin m count nu nh hn count byte trong file hoc nu file c m trong ch vn bn cc tham s: - handle: kt qu tr v t dx_fileopen() - *buffer: b nh lu tr cho d liu - Count: s lng ln nht ca byte 10. dx_sethook(): cung cp iu khin trng thi chuyn mch nhc t ca knh iu khin. 1 trng thi chuyn mch nhc t c th l bt hoc tt Cc tham s: - chdev - hookstate: trng thi nhc t(gc hay t) - mode: syn or asyn Example 1: Using dx_sethook( ) in synchronous mode
#include <srllib.h> #include <dxxxlib.h> #include <windows.h> main() { int chdev; /* open a channel with chdev as descriptor */ if ((chdev = dx_open("dxxxB1C1",NULL)) == -1) { 9

/* process error */ } /* put the channel on-hook */ if (dx_sethook(chdev,DX_ONHOOK,EV_SYNC) == -1) { /* error setting hook state */ } . . /* take the channel off-hook */ if (dx_sethook(chdev,DX_OFFHOOK,EV_SYNC) == -1) { /* error setting hook state */ } 11. Cc hm trong TAPI - phoneCallbackFunc: la 1 thay th cho tn ham ng dung c cung cp 12. phoneClose: ong thit bi in thoai c m theo quy inh 13. phoneConfigDialog: cho phep ngi dung cu hinh cac thng s lin quan n cac thit bi in thoai c chi inh bi cac tham s dwDeviceID. - phoneDevSpecific: Cho phep trin khai thc hin TAPI cung cp cac tinh nng makhng phai la m ta trong cac chc nng TAPI khac. 14. phoneGetDevCaps: Truy vn mt thit bi in thoai quy inh xac inh kha nng in thoai cua minh. 15. phoneGetGain: tra v s thit lp li microphone cua thit bi chuyn mach ong m cua in thoai quy inh 16. phoneGetHookSwitch: Tra v ch hookswitch cu cua thit bi in thoai c m theo quy inh 17. phoneGetIcon: cho phep mt ng dung ly mt biu tng dich vu thit bi in thoai cu th ma co th c hin thi cho ngi dung 18. phoneGetID: Tra v mt nhn dang thit bi cho cac lp thit bi quy inh o ma lin kt vi cac in thoai c chon 19. phoneGetMessage: tra v ban tin ng dung TAPI tip theo va tuy chon i 1 ban tin mi 20. phoneGetRing: cho phep mt ng dung truy vn ti thit bi in thoai c m theo quy inh cho ch chung hin tai cua no 21. phoneGetStatus: cho phep mt ng dung truy vn ti thit bi in thoai c m theo quy inh cho trang thai tng th cua no 22. phoneGetStatusMessages: chi thi trang thai ban tin mt ng dung se nhn 23. phoneGetVolume: tra v vic thit lp m lng cua thit bi hookswitch cua in thoai quy inh 24. phoneInitializeEx: khi tao vic s dung TAPI bi ng dung cho vic s dung tip theo cua in thoai - phoneNegotiateAPIVersion: Cho phep mt ng dung thng lng mt phin ban API s dung cho cac thit bi in thoai c chi inh. - phoneNegotiateExtVersion: Cho phep mt ng dung thng lng mt phin ban m rng s dung vi cac thit bi in thoai c chi inh. 25. phoneOpen: m thit bi in thoai c quy inh 26. phoneSetGain: thit lp li microphone cua thit bi hookswitch quy inh cho mc li quy inh 27. phoneSetHookSwitch: thit lp trang thai hook cua thit bi hookswitch cua in thoai m quy inh cho ch quy inh 28. phoneSetRing: thit lp ch va mc m lng cho chung thit bi in thoai theo quy inh 29. phoneSetStatusMessages: cho phep mt ng dung hin thi trn thit bi in thoai cho vic la chon trang thai s kin 30. phoneSetVolume: thit lp m lng cua thanh phn loa cua thit bi hookswitch ti mc quy inh 31. phoneShutdown: tt lu lng bi ng dung cua in thoai TAPI 10

You might also like