Telephony Open Source Interface (TOSI)
--------------------------------------

Overview
--------

TOSI is an interface to a library of C callable functions that
provides a simple way for applications to control telephony hardware
and software.  TOSI is designed to be platform and telephony hardware
independent.  Some examples of telephony devices suitable for control
by TOSI are:

* Voice Modems
* Analogue and digital Computer telephony (CT) cards
* Smart speakerphones with built in CT connectivity
* Daemons that speak the Protocol for Simple Computer Telephony

This will allow any application to communicate with telephony hardware
to accomplish tasks such as:

* Using a GUI on your PC to make a phone call from an on-line phone
  book.

* Have a GUI pop up on your PC for incoming calls, telling you
  who is calling.  

* Handling multiple calls at once and setting up conference calls. 

* Providing a nice GUI interface for all those #$@ DTMF codes you need
  to remember to control your voice mail, call forwarding etc. 

* Using a web interface to tell a call centre when and where to ring
  you, rather than waiting in a queue.  At the appointed time your
  number is automatically dialed and connected to the call center.

* Providing access to any phone system that supports an open protocol
  (we are starting with PSCT). 

History
-------

01-03-2001 v0.0.4 Converted some notes into content where missing - rsb
09-03-2000 v0.0.3 Modded according to discussion with tosi group - rsb
08-31-2000 v0.0.2 Fixed some typos, made a few mods - rsb@ostel.com
08-30-2000 v0.0.1 Initial draft - David Rowe voicet@bigpond.com.au

TOSI is being driven to 0.1.0 status by the TOSI development group,
it's current maintainers.  See tosi.sourceforge.net.

Design Goals
------------

* To provide a simple, flexible, unencumbered, platform independent
  interface which requires no third-party development tools or
  middleware.  A competent programmer should be able to build a
  working prototype application within a few hours. 

* To cover as many of the common terminal settings and third party
  call control functions as possible, while leaving room for extension
  to those we have missed.

* Not to get feature-bloated by trying to encapsulate switch control
  protocols, or the features of every device imagineable.  TOSI should
  remain a small, easy to use interface for use on clients.

Introduction to the TOSI Model
------------------------------

TOSI abstracts physical resources in such a way that an application
can talk to many different types of telephony devices, from an
analogue voice modem to a multi-line digital Computer Telephony (CT)
card.

TOSI deals with one object - the "channel".  A channel corresponds to
a single line telephony device.  In the physical world, this channel
may be:

* A voice modem.
* A single port of a multi-port CT card.
* A smart speaker phone with CT connectivity.

Using TOSI function calls, you can control the channel, for example:

* int tosi_open(chan_type, chan_id), attempts to find an available
  channel of the type and, optionally, with the given id (id can be an
  ip address).

Supported channels in v0.1.0:
	  PSCT channel
	  Vmodem channel

The TOSI library is extensible enough to allow you to write a pluggable
channel of your own.  You just list a few functions and definitions in
chan_types.h and your_chan_type.h.  Most of the tosi_ functions will
then call your functions.

* int tosi_pick_up(chan_id), takes the TOSI channel off hook.

* int tosi_hang_up(chan_id), hangs up the TOSI channel.

* int tosi_dial(chan_id, destination), sends appropriate info down the TOSI
  channel, may be used for control of switch (e.g. transferring
  calls), or control of speakfreely, or control of a modem, or
  whatever the channel is.

* int tosi_xfer(chan_id, destination), transfers the caller on the given
  open channel to the given destination.
 
* int tosi_get_event(), reads events from the channel, such as ring, DTMF
  detection, and Caller ID detection.

* int tosi_send_msg(chan_id), sends a text message if the channel
  supports it.

* int tosi_rcv_msg(chan_id), gets a text message if the channel
  supports it.

Once again, the list above is limited only by the channel capabilities
and your ability to extend it.  For instance, when using tosi_send_msg()
and tosi_rcv_msg() and tosi_get_event() to communicate on a PSCT
channel, you have all of the control that PSCT gives you over the
device on the other end, which can be considerable.
 
Note that there are no media-handling functions in TOSI, you cannot
use TOSI to play or record speech samples to the channel.  TOSI
channels are signalling channels.

RSB> Maybe an ascii art picture here showing signal path and seperate
voice path, different kinds of devices present, etc. will drive this home.

RSB> Also, an example of using get_event().  Since most protocols
require registration for events, should we offer register_4_event() as
well?

Design Notes
------------

1.  My main priority is simplicity, for example a small set of
function, abstracting away as many details as possible to the lower
layers. Note that this is a complete 180 degree shift in my previous
thinking (ie to model TOSI on PSCT)! :-)  Rich - I used some of you
ideas in a previous email for the open & dial functions instead.

I arrived at this current model by looking at what was required to
implement the simple applicatons we have discussed.   

RSB> DR, I think we really need to put together a list of the
applications of this API we are going to solve.  Let's compile this
and then work from there down through this API.

Here is a more detailed version of an example mentioned in the
overview highlighting the usage of the TOSI interface
library and PSCT protocol:

WidgetWare's GroupWare Application, WGroup, recieves alarms from other
applications telling it that an important server is down.  Joe is
paged by Wgroup, and arrives at his terminal.  He finds that the
situation is grave, and all support technicians in the local area must
be paged to arrive on site.  In addition, all of the managers must be
paged, and those who are available should be conferenced in with Joe
within 30 minutes.  Joe tells WGroup that these operations are to
occur.  WGroup opens a TOSI PSCT channel to a telephony server...


2. Event Handling: I have used an event Q rather than call back
function to handle events, as this avoids the need for threads, or the
need for the event handler to execute quickly. 

RSB> I personally like callbacks better.  It actually is just as easy
to implement(given a good example)  and doesn't waste cpu cycles spent
polling.  I have followed along with the no callbacks method in my
mods above.

The get event function is non-blocking, so that a flag in the polling
loop can be used to exit the program.  Are these valid reasons for
using this sort of event handling mechanism?

3. No threads are required with the current model.  No big deal, but
   will make life easier for some.

4. The API is as compact and simple as possible to make people want to
   use it, and build apps quickly.  It also looks suspiciously like
   the VPB-API!  I need you guys to help get my mind out of the VPB
   box on this one!

5. Is "channel" a good term?  What about port, line, phone, extension?

RSB> I think endpoints and channels are good.  If you define a set
such as is defined in the PSTC spec, we should be covered on
definitions.  I would leave port and socket alone, since most
programmers use those in other ways.  













