TAPI was designed to establish connections between end-points on a telephone
network. These end-points are called addresses. You can think of an
address as a phone number. On a business phone system where you're allowed to
have multiple calls at once (although you can only talk on one at a time), an
address is called a call appearance. Either way, it's possible to have
more than one address on a single line. The line is the physical
connection between each end-point and the CO switch. Of course, you're allowed
multiple lines at any location. All businesses of any size have multiple phone
lines. Most homes have one, although some have two or more.
Most homes built within the last twenty years are wired internally for two or three lines even if they only have one. For example, my house is wired for three phone lines. This means that at every phone outlet in my house, I've got six copper wires, i.e. three pairs. Currently, the phone company has only connected two pairs to the CO. At any time, however, I could spend the money (usually between $35 and $75) to have the third line activated. I'd love this, of course, being a telephony nerd, but it was hard enough to talk my wife into two... |
The physical connections between each end-point and a CO and the telephone
network between each CO allows a logical connection to be made from any
end-point to any other end-point. This logical connection is a call. You
make a call, of course, by providing the switch with another address
- you know, dialing a phone number.
When establishing a call, an address can have several forms. If you're connecting to another person on your key system or PBX, you can dial an abbreviated version called an extension number. This is usually the last three, four or five digits of the full phone number. If you're dialing someone in your area code, you dial just the phone number without the area code. If you're dialing long distance within the US, you first have to dial 1 followed by the area code. If you're dialing an international number, you first have to dial the prefix string that identifies an international number - 011 in the US - followed by the country code, the area code and then the number. The further away you get, the more complicated the phone number becomes.
For example, let's say someone wanted to dial the Addison-Wesley Developer's Press to order this book for a friend. Here's the digits they'd have to dial based on where they're calling from:
Dialing From | Number to Dial | Digits |
---|---|---|
Inside AW | 4-3700 | 5 |
In same area code | 944-3700 | 7 |
Inside the US | 1-617-944-3700 | 11 |
From Germany | 001-617-944-3700 | 13 |
From a PBX in Germany using an AT&T credit card | 9-0130-0010-617-944-3700-xxx-xxxx-xxxx | 30 |
According to the psychology classes I took in college, people are able to group
together about five things, give or take a couple, in a single thought. The
typical phone number is seven digits long, which is pushing it, and dialing
long distance is about all I can manage. When I have to dial internationally
using a calling card and some number to get an outside line first
- well, let's just say I don't usually get it right the first time.
Wouldn't it be great if we could just give the computer a phone number and let it figure out what digits to actually dial? TAPI has support for doing just that. To transform a phone number into a dial string, TAPI needs two things, an phone number in canonical address format for a specific country and a description of a dialing location. The canonical address format is:
+ country-code space [(area-code) space] subscriber-number [more]
country-code | Identifies the country of the address. One or more digits followed by a space. |
area-code | Identifies the area code of the address. Zero or more digits. If there are digits, they're surrounded by parenthesis which are followed by a space. |
subscriber-number | The rest of the phone number. One or more digits, dialing control characters or formatting characters. |
more | Optional delimiter character and one or more characters denoting an ISDN sub-address, name information or another address. Multiple addresses are used in ISDN to combine multiple data channels. |
Therefore, the canonical format of the Addison-Wesley Developer's Press is +1
(617) 944-3700.
Since I know the country where phone I'm calling is located, all I need now is a description of the location I'm dialing from. The Telephony Control Panel allows access to the Dialing Properties available on your system. The "My Locations" tab allows you to set up one or more dialing locations.
Figure 3: Dialing Locations settings
The Default Location is for desktop computers. You set up the dialing rules for
your computer once - what country you're in, what to
dial to get an outside line, et cetera - and it'll
be used by every TAPI application. Being able to configure multiple locations
is for laptop computers. For example, I take my laptop to hotels all over the
US. Invariably, hotels require me to dial either 8 or 9 to get an outside line
and a 1 for long distance calls. I've set up two dialing locations, one called
Prefix 8 and one called Prefix 9, both of which are identical except for the
prefix. When I want to access my Internet Service Provider (ISP) from the road,
I choose the location I'm dialing from based on how the hotel's switch is set
up. This means I can enter phone number information once and the dial string
will be properly composed based on my location.
When dialing a number, every good TAPI application will let you enter the area code, the subscriber number, the name of the country you're dialing and the dialing location you're calling from. For example, HyperTerminal has a dialog that looks like this:
Figure 4: Dialing a TAPI phone number
The phone number country, area code and subscriber number can be changed by
pressing the Modify button and the location can be changed in the Your location
list box. If I want to access the Dialing Properties dialog just like I can
from the Telephony Control Panel, I can press the Dialing Properties button.
HyperTerminal uses this information to form the canonical address of the phone
number you're dialing. It then asks TAPI to translate this address into dialable
address format. Dialable addresses are the actual string of numbers and
control characters needed to dial the address from your location. The possible
characters are listed below:
0-9 and A-D | Dial digits. A-D are special tones used for telephony maintenance and are not available on most phone keypads. |
! | Flash hook (500ms on-hook, 500ms off-hook). Most phones have a hook switch that the phone rests on when you hang up. Holding this switch for a short time is called a flash |
P or p | Dial following digits using pulses. |
T or t | Dial following digits using tones. |
, | Pause (time based on device settings). |
W or w | Wait for dial tone before proceeding. |
@ | Wait for quiet answer (a ring followed by several seconds of silence). |
; | Indicates the end of a partial dialing string. Another dial string will follow in a separate dial string. |
For example, on a line supporting tone dialing, the dial string for the
Addison-Wesley Developer's Press in the US from a home in another US area code
is T16179443700. This is the string that will actually be sent to TAPI to dial
the phone.
After translating a canonical address into a dialable address and dialing, a call has begun. Before it's connected, a call will go through a number of call states. These states include dialing, proceeding and ringing. If the call is picked up on the other end, it will transition into the connected state. If it's busy or there is a network error ("doo-doo-do. I'm sorry, your call could not be connected..."), the call will transition into the appropriate state. Once the call has been disconnected, it will translate into its final state, idle. It's the responsibility of a Full TAPI application to properly handle these states. (See Chapter 2, Assisted Telephony, for a discussion of the difference between Full TAPI and Assisted TAPI).
TAPI provides programming access to three objects for call control: lines, addresses and calls. As I said, one location can have multiple lines and one line can have multiple addresses. In addition, one address can have multiple calls. You can switch between calls, by placing one on hold before activating another. You can place a call on hold, establish another call and transfer the initial call to the new address. You join two or more calls together and have a conference. These and many other advanced call control techniques are all supported by TAPI.
One other telephony object supported by TAPI is the phone. The phone is the hunk of hardware that you use for its convenient placement of speaker, microphone and keypad. Using TAPI, call control can take place independently of the phone. To connect input and output to a line, TAPI allows a terminal to be established. Often, the default terminal will be the phone. However, this facility allows a sound card, speakers and a microphone to be used instead of a phone. It also allows the phone to be used as an input-output peripheral without connecting it to a line.