Using ThbTapiLine
 

Prior you are able to use a line device to make or receive calls, the following steps are required:

  Select the Line Device

Set DeviceName or DeviceID to select the device you wish to work with.

All installed devices are listed in the ThbTapiLine's DeviceList property. In this list, the index of an device is equal to the DeviceID. To select a device you are able to set either the DeviceID or the DeviceName. If you set the DeviceID the DeviceName property will be updated. If you set the DeviceName property the name must match exactly the desired device. The DeviceID will be updated too.

Example 1: Get all installed line devices

procedure TForm1.FormCreate(Sender: TObject);
begin
  ComboBox1.Items := hbTapiLine1.DeviceList;
end;

Example 2: Select one installed line device

procedure TForm1.ComboBox1Change(Sender: TObject);
begin
  hbTapiLine1.DeviceID := Combobox1.ItemIndex;
  // or hbTapiLine1.DeviceName := Combobox1.Text;
end;

After a device is selected successfully and the Available property returns True, you are able to read the device's capabilities and examine the addresses too.

Your application should not save the DeviceID to restore an users configuration because it could change in due to installing/removing TAPI-devices. The better choice is to store the DeviceName.

 

  Select the Media Modes

Set the MediaModes property to the type(s) of calls you want to handle. If your application is an inbound application that has to handle incoming calls of special media modes, you need to specify the media modes to become an owner of such calls.

The supported media modes of the device can be found within the Caps.MediaModes property. You are able to select one or more media modes or set this value to zero to let ThbTapiLine select all supported media modes automatically.

hbTapiLine1.DeviceID := 'Modem XYZ';

 if not hbTapiLine1.Available then
   exit; // Modem XYZ not installed

if hbTapiLine1.Caps.MediaModes and LINEMEDIAMODE_DATAMODEM > 0 then
  hbTapiLine1.MediaModes := LINEMEDIAMODE_DATAMODEM
  
else
  exit; // LINEMEDIAMODE_DATAMODEM not supported

{ or hbTapiLine1.MediaModes := 0 to select all supported media modes }

This setting works directly together with the Privileges property and is ignored if privileges are set to "None".

  Set the Privileges

Set the Privileges property to that required for incoming calls. This setting does not affect the ability to make outbound calls.

If your application has to make outgoing calls only, it is recommended to specify privilege None (selected media modes are ignored). The application will not be notified of any inbound or outbound calls aside from the one it creates by it's onw.

If the application just wants to monitor calls, then it can specify privilege Monitor.

If the application has to answer inbound calls of the specified MediaModes (Step 2), it must use privilege Owner. In that case, the application is NOT notified of calls, if another application has already opened the line device with owner privileges to the calls media mode.

If the application has to handle inbound calls as an owner and wants to be notified of calls too, then it can specify privilege Owner and Monitor together. This is the most far-reaching selection and gives your application the full control to all calls.

hbTapiLine1.Privileges.Owner := True;
hbTapiLine1.Privileges.Monitor := True;

- or -

hbTapiLine1.Privileges.AutoSelect := True; // Let ThbTapiLine select the best available privileges

ThbTapiLine supports also the AutoSelect property to simpify selection of privileges. If AutoSelect is used, your Application should check the privileges is has gotten after activation.

  Activate the Line Device

Activate the line device by setting ThbTapiLine's Active property to True.

hbTapiLine1.DeviceName := 'Sample TSP v1.0';
hbTapiLine1.MediaModes := 0;
hbTapiLine1.Privileges.AutoSelect := TRUE;

if hbTapiLine1.Available the
try
  hbTapiLine1.Active := True;
except
  on E:EhbTapiError do
    MessageDlg('Error opening line device: ' + E.Message, mtError, [mbOk],0);
end;

Activating a line could raise an EhbTapiError exception e.g. if the selected media modes are not supported by the telephony line device.