Connection handling in the OPAL library

Overview

This page of the documentation is designed to provide an understanding of the use of the OpalConnection class in the OPAL library. From the description, you will be able to add your own voip protocol to OPAL, and utilise the features provided by the existing class structure.

Key to understanding the OpalConnection class is that this class is responsible for supervising the call signaling and media control for one call.

There will be one descendant of this OpalConnection class created for each protocol that is supported.

Call Phases

Defined in OpalConnection, there is an enum (OpalConnection::Phases) that describes the different stages of the call. Note that all OpalConnection instances go through these phases as a call progresses. Even the OpalPCSSConnection, which is the connection of PCM audio to/from the sound card, will (at some time) be in each of the available phases.

To illustrate the meaning of the phases, we will descibe a very simple voip protocol. This example protocol will also be used to show when the different callbacks happen, and when the phases are changed at either endpoint of the call.

The two endpoints in the call are labelled L and R (left and right). L is making a call to R

In the example above, if R had answered yes immediately, the call could not move immediately to OpalConnection::EstablishedPhase as the media types were not agreed on.

In the example above, we have described the decision process as to the codec type, and the ports used. This decision process is not necessarily directly handled by the OpalConnection descendant. For IAX2, where media negotiation is an integral part of setting up the call, the IAX2Connection does media negotiation. However, for SIP, there are SDPBandwidth, SDPMediaDescription, SDPMediaFormat, SDPSessionDescription classes for handling media negotiation. For the case of a pstn gateway using ISDN, there is no media negotiation. It always uses G.711 and the same "port" (the B channel).

The different phases are.

OnEvent Callbacks in Opal

An OnXXX function is called when an external stimuli from the protocol occurs and a SetXXX function may be called by OPAL to perform the protocol command. For example OnAlerting is called when the H.323 ALERTING packet is received, and SetAlerting transmits the ALERTING packet.

It is the OpalConnection class (or descendant) which is in charge of handling the control packets of a particular protocol. Consequently, it is only code in this class which sets the current call phase variable. Further, most events are generated in the OpalConnection class, which are usually passed back to the OpalEndPoint, then to the OpalManager, and usually on to the OpalCall class.

Consequently, if a descendant of the OpalManager has been created, the application will have access to to notification on when the phase of a call has changed. Applications may create descendants of the H323Connection and SIPConnection to get protocol specific information about call progress.

Whenever the application does override a method in OpalManager (or OpalEndPoint, or OpalConnection), the application should

The stages in a call, as applies to the methods provided by the OpalEndPoint, OpalConnection, OpalCall and Manager classes.


Generated on Mon Feb 1 00:25:55 2010 for OPAL by  doxygen 1.5.1