Modular design of TAPI soft telephone communication system

1 Introduction

TAPI: Short for "Telephony Application Interface" (Te lephonyApplicaTIon Programm ing Interface). It is a set of functions developed by Microsoft and INTEL for direct control of telephony communication systems. It is the core of the Microsoft Computer Telephony Integration (CTI) program and is part of Microsoft's W indows Open Services (WOSA). It further integrates the functions of the telephone, telephone network and computer. Today's computer technology can not only handle low-level applications such as voice communication, but also handle advanced applications such as video.

Computer technology makes the phone have a software trend, and its advantage is that the phone can be flexible, and the basic functions and additional functions of the phone can be conveniently implemented according to specific requirements. Softphones need to interact with communication hardware devices. At present, there are two main implementation methods: one is to use the computer board and the DLL provided by the equipment company to achieve, but the function has certain limitations; the second is to use the standard programming interface exposed by the protocol. However, it is difficult and the parameters are complicated and difficult to implement. This design utilizes the standard programming interface TAPI. In order to facilitate the integration and development of the system, the TAPI modular design method for realizing the interaction between the application system and the communication device in the form of unified short message is emphasized. The modular components are highly integrated with the system and can easily implement a variety of telephony and control functions.

2 TAPI role and structure analysis

2. 1 The role of TAPI in softphone systems

Since the TAPI application is a telecommunications application, it is necessary to connect a PC computer and a communication hardware device. The TAPI runs on a PC and monitors the communication hardware device, so the first task is to establish a hardware environment. For the VOIP application communication system, the softswitch server is the control core of the IP telephone network, and the PSTN (public telephone network) is connected to the ground. The PC and the softswitch server are in the same network segment, and the TAPI and hardware interaction will also be used through the network. TCP/IP protocol connection. The development platform of this design is based on the following soft switching system, as shown in Figure 1.

Figure 1 Softswitch System

Similar to the installation of new hardware on a PC, the driver needs to be installed on the PC, but this driver is not the driver of the softswitch server, but the driver of the TAPI on the softswitch server. This driver is usually called the TAPI client. ", the purpose is to enable the TAPIDLL on the PC to "find" the TAPI of the softswitch and communicate with it.

2. 2 TAPI structural analysis

The TAPI is actually composed of three parts: TAPI, TSPI ( Telephony Serv Ice Protocol), and MSPI (Media Service Protocol Interface) media service providing interface. TAPI is a toolkit for programmers that, together with MSPI, enables users in the Microsoft Windows environment to develop phone applications. TSPI is also a toolkit for programmers that enables them to develop back-end services to manipulate application requests from TAPI-compliant applications, that is, it provides a way to connect to a particular device. The service daemon (TAPI Server) is designed based on the TSPI interface. It directly drives the communication device and provides telephone service for the application by interacting with the TAPI dynamic connection library. The overall structure is shown in Figure 2.

Figure 2 Schematic diagram of the overall structure of TAPI

3 TAPI modular design

This design mainly uses the C++ class design idea to implement TAPI encapsulation under the framework of MFC (Microsoft Foundation Class). Due to the complexity of TAPI function calls and the variety of parameters and forms, in order to facilitate system integration and application development, three control classes are designed: TAPI application control class Tap iApp licaTIon, TAPI line control class Tap iLine, TAPI Call control class Tap iChannel.Tap iApplicaTIon is the monitoring of the entire TAPI, is the interactive station of the application and communication equipment; TapiL ine is the management of the TAPI line, it operates the line call according to the application instructions; Tap iChannel is the specific one-way call Management, it operates the corresponding communication device according to the line instruction and reports the device status in real time. The call relationship of these three classes is shown in Figure 3.

Figure 3 TAPI call structure

First you need the TAPI definition file. Since TAPI is integrated with Windows, the definition files can be found after the W indows operating system is installed. The TAPI.H and TAPI32.dll files provided in C language contain definitions of all TAPI structures and functions. If you use C, VC or VB to develop an application, just set it in the relevant development environment and import the file into the application project you want to develop. If you use De lph i development, you need to convert TAPI.H into a header file in Delphi. Then introduce this pas file; if you use Java development, you need TAPI c lass file.

The design uses the MFC of VC as an example to modularize the function of TAPI. The development process does not require the support of communication hardware. The debugging and operation need to interact with the communication hardware, and the component can be well-compatible upwards and downwards.

3. 1 TAPI application control class design

TapiA pplicate is the management of TAPI. It is at the top level of the call structure, providing transparent and standardized information services for upper-layer applications through the underlying services. When designing a remote communication program via TAPI, it is essential to call the lineIn itia lizeEx() function to initialize the TAPI, and call the lineOpen() function to open the line before using TAPI for monitoring and proxy calls. In addition, in order to write a reliable remote communication program, the function lineGetDevC aps( ) for detecting the capability of the line device should be called, and the TAPI version compatibility function lineN egotiateAPIV ersion( ) should be detected to detect the current usage state of the line lineSetStatusM essages( ) to adapt to various situations. Finally, call the lineC lose() function to close the line, and call the lineShutdow n() function to disconnect the application from TAPI.

In order to make TAPI easy to manipulate and adapt to different application development environments, this paper designed In itia liseTAPI( ), an initialization function that does not parameter, and integrates the parameters needed to initialize and negotiate TAPI version through inline mechanism, avoiding too much Parameter passing. After successful initialization, the application has obtained the data structure and application handle of TAPI. In order to facilitate control of the communication device, it is necessary to contact the communication device and open the communication line. This paper designs OpenValidL ines( ), a function with no parameters. As long as it returns successfully, it can control the communication lines and communication devices. Its function is declared as follows:

Class T apiApplicat ion


Pub lic:

Tap iApp lication ( CTap isamp leD lg lg) ;

~ T apiApplicat ion( );

/ / TAPI helper funct ions

BOOL InitialiseTAPI( ) ; / / Initialize TAPI

Void ShutdownTAPI( ); / /C lose TAPI

Void OpenV alidL ines ( ) ; / /Open the lines o fTAPI

/ / Variab les

CTapisamp leD lg lg;

HLINEAPP m_hLineApp; / / App lication handle

DWORD m_NumDevs; / / Number of dev ices

DWORD * m _ ApiV ersions; / / API versions

PTAPILINE* m_pL ines; / / Device variables

LONG m _Curren tL ine; / / currently se lected

ADDRARRAY m_AddressA rray;


TAPI initialization work and efficient line opening These complex functions, passed through function built-in or global variables, are integrated into an API function that takes no arguments and returns a boolean type. The application can monitor and operate the TAPI device by simply calling these two functions.

3. 2 TAPI line control class design

Tap iLine is the management of TAPI lines. In order to make the structure of the program clearer and easier to upgrade, and to make TAPI more convenient to port to other applications, some functions and data structures used in TAPI functions to implement functions are implemented. Packaged into a class to use. The following is the header file for the TAPI line control function wrapper class implemented by V ISUALC + + programming.

Class T apiL ine {


TapiA pplicat ion ainA pp; / / paren t object

DWORD m _LineID; / / My index

HLINE m _ hL ine; / / M y line hand le typedef

CL ist

ExtensionLis;t m_extensionLis;t

/ / the list of call channe l


TapiL ine( TapiApp licat ion

~ Tap iLine( ) ;

Vo id OnEvent ( DWORD Device, DWORD Msg,

DWORD Param1, DWORD Param2, DWORD Param3);


Ca llPr iv ilege, DWORD Med iaModes);

TapiChanne*l getChannel( DW dwAddressID);

TapiChanne*l getChanne lCall(HCALL hcall) ;

/ / Functions to support te lephony commands

BOOL M akeCa ll ( DWORD dwAddressID, LPCT??

STR pszA ddress) ;

Vo id D ropCall( DWORD dwA ddressID) ;

Vo idHo ldCall( DWORD dwA ddressID) ;

Vo id UnholdC all( DWORD dwAddressID) ;

Vo id B lindT ransferCa ll ( DWORD dwAddressID,

LPCTSTR pszAddress) ;

Vo id R edirect ( DWORD dwAddressID, LPCTSTR

pszAddress) ;

Vo id Ca llStatus( DWORD dwAddressID );

Vo id Ca llInfo( DWORD dwA ddressID) ;

Vo id Addressstatus( ) ;


TapiL ine encapsulates a large number of internal variables through a complex parameter passing mechanism, and receives user instructions in the form of unified short messages through the API interface while returning the specific state of the line. The final application operates and controls the entire line by calling the specific function of Tap iL ine.

3. 3 TAPI call control class design

TapiChanne l is the control of specific calls, which is one of the most commonly used functions for TAPI development. Call Tap iL ine's MakeC all ( DWORD dwAddressID, LPCTSTR pszAddress), pass the current number and the destination address to make a call and pass the other details of the call internally. When the above function is successfully called, the TSP will control the outgoing call of the communication device. The function will return to the application immediately after the call, but if the call is successfully dialed, it depends on the message, including other functions of TAPI. This is also the way to deal with it. Other commonly used phone functions such as answering, hanging up, transferring, and three parties have corresponding function implementations.

After the TAPI is successfully initialized, the application establishes contact with the TSP device. The application can control the phone line and monitor the line status through the TAPI function. After the function lineOpen is successfully called, it enters the message loop, and the newly generated call is in the IDLE state, and then performs different operations according to the state instruction. When lineM akeC all( ) is called, the line state enters D IAL ING, PROCEDING, enters the call state loop after receiving the asynchronous response or response, and enters CONNECTED and DISCONNECTED in turn, and finally returns to the initialization state. When there is a call, the line status enters OFFER ING, automatically calls lineAnsw er ( ), then enters ACCEPTED, PROCED ING, enters the call state loop after receiving the asynchronous response or response, and then enters CONNECTED and D ISCONNECTED, and finally returns. Initialization state, the entire TAPI state diagram is shown in Figure 4.

Figure 4 TAPI state machine.

3. 4 TAPI message processing

The parameter passed in the third parameter of the line ln itia lizeEx function is the address of the method. This method will process all TAPI messages sent by the communication device. This method must be defined in a fixed format:

Vo id CALLBACK Tap iLineCa llback(

DWORD dwDev ice,

DWORD nM sg,

DWORD dw Instance,

DWORD dwParam1,

DWORD dwParam2,

DWORD dwParam3)

The method name TapiL ineC allback can be defined by itself. As long as this function name is passed as a parameter to linelnitializeEx, the method can work. The method parameters will be filled in by the TSP of the communication device and passed to the upper application. The key is to understand the meaning of each parameter value after triggering this method at a certain moment and the meaning of the message received at this time. It should be noted that even if you complete a simple call, you will get a lot of TAPI messages. These messages are generated in chronological order. Each time a message is generated, it will enter the Tap iL ineCallback method, so you need to grab and process the key messages.

Take the incoming call as an example, mainly processing 2 messages.

(1) The parameter dwMsg = LINE _ CALLSTATE and dwParam: l LINECALLST _OFFER ING. At this point, the hDev ice representing the incoming call can be saved to the application for subsequent processing.

(2) The parameter dwMsg= LINE _CALLINFO. At this time, the caller information, such as the incoming caller number and the called number, can be obtained through the TAPI function lineG etCa lllnfo. After receiving the incoming call message, you can switch the application status on the interface to notify the user, or record the database, etc., and process as needed. Similar to an incoming call message, a corresponding message occurs when another phone event occurs.

4 Conclusion

Although there are not many applications for TAPI productization, the functions it provides are powerful. TAPI is mainly used to control communication devices, and more functions are implemented on this basis. It has also been used to control the normal mode of the home; l if used to control the switch, can achieve advanced functions such as call queue, and can also establish an enterprise call center.

The workflow of TAPI and the implementation of TAPI function module are studied, and the function is packaged and designed. The complete steps of writing a telephone control program using TAPI are introduced, which lays a foundation for the secondary development of TAPI in the softphone application system.

The spinning pole is the use of foreign advanced spinning equipment,forming a whole without welding,forming a conical or profiled bar.And then polishing,remove surface oil,burr and indentation.Then after the quenching intensity,to T6 state,in line with international standards.The product never rust ,strong corrosion resistance,diversified surface treatment process,the appearance of simple fluid lines.Light weight and convenient installation and transportation,the rod body can be 100%recycling,low melting temperature.

Aluminum Alloy Spinning Lighting Pole

Product features

â‘ Using spinning equipment advanced,the whole forming a non welding

â‘¡Product permanent does not rust,corrosion resistance

â‘¢Diversified surface treatment technology,make the appearance line succinct smooth

â‘£The light weight,convenient installation and transportation

⑤The rod body can be 100% recycling,melting temperature is low.

Aluminum Alloy Spinning Lighting Pole

Aluminum Alloy Spinning Lighting Pole,Lightest Aluminum Alloy,Aluminum Alloy Torchlight,Lightweight Aluminum Alloy

Jiangsu chengxu Electric Group Co., Ltd ,