# OpalLocalConnection Class Reference

`#include <localep.h>`

Inheritance diagram for OpalLocalConnection:

[legend]
Collaboration diagram for OpalLocalConnection:
[legend]

## Public Member Functions

Construction
| OpalLocalConnection (OpalCall &call, OpalLocalEndPoint &endpoint, void *userData, unsigned options, OpalConnection::StringOptions *stringOptions, char tokenPrefix= 'L')
| ~OpalLocalConnection ()
Overrides from OpalConnection
virtual PBoolean | OnIncomingConnection (unsigned int options, OpalConnection::StringOptions *stringOptions)
virtual PBoolean | IsNetworkConnection () const
virtual void | OnApplyStringOptions ()
| Call back for connection to act on changed string options.
virtual PBoolean | SetUpConnection ()
virtual PBoolean | SetAlerting (const PString &calleeName, PBoolean withMedia)
virtual PBoolean | SetConnected ()
virtual OpalMediaStream * | CreateMediaStream (const OpalMediaFormat &mediaFormat, unsigned sessionID, PBoolean isSource)
virtual OpalMediaStreamPtr | OpenMediaStream (const OpalMediaFormat &mediaFormat, unsigned sessionID, bool isSource)
virtual PBoolean | SendUserInputString (const PString &value)
New operations
virtual bool | OnOutgoingSetUp ()
virtual bool | OnOutgoing ()
virtual bool | OnIncoming ()
virtual void | AlertingIncoming (bool withMedia=false)
virtual void | AcceptIncoming ()
Member variable access
void * | GetUserData () const
| Get user data pointer.
void | SetUserData (void *v)
| Set user data pointer.

## Protected Member Functions

void | InternalAcceptIncoming ()

## Protected Attributes

OpalLocalEndPoint & | endpoint
void * | m_userData

## Friends

class | PSafeWorkNoArg< OpalLocalConnection >

## Detailed Description

Local connection. This class represents a connection on the local machine that can receive media via virtual functions.

## Constructor & Destructor Documentation

OpalLocalConnection::OpalLocalConnection | ( | OpalCall & | call,
|  | OpalLocalEndPoint & | endpoint,
|  | void * | userData,
|  | unsigned | options,
|  | OpalConnection::StringOptions * | stringOptions,
|  | char | tokenPrefix = `'L'` |
| ) |  |  |

Create a new connection.

Parameters:

  call | Owner call for connection
  endpoint | Owner endpoint for connection
  userData | Arbitrary data to pass to connection
  options | Option bit mask to pass to connection
  stringOptions | Options to pass to connection
  tokenPrefix | Prefix for token generation

OpalLocalConnection::~OpalLocalConnection | ( |  | ) |

Destroy connection.

## Member Function Documentation

virtual void OpalLocalConnection::AcceptIncoming | ( |  | ) | `[virtual]`

Accept the incoming connection.

virtual void OpalLocalConnection::AlertingIncoming | ( | bool | withMedia = `false` | ) | `[virtual]`

Indicate alerting for the incoming connection.

Parameters:

  withMedia | Indicate media should be started

virtual OpalMediaStream* OpalLocalConnection::CreateMediaStream | ( | const OpalMediaFormat & | mediaFormat,
|  | unsigned | sessionID,
|  | PBoolean | isSource |
| ) |  |  | `[virtual]`

Open a new media stream. This will create a media stream of an appropriate subclass as required by the underlying connection protocol. For instance H.323 would create an OpalRTPStream.

The sessionID parameter may not be needed by a particular media stream and may be ignored. In the case of an OpalRTPStream it us used.

Note that media streams may be created internally to the underlying protocol. This function is not the only way a stream can come into existance.

The default behaviour is pure.

Parameters:

  mediaFormat | Media format for stream
  sessionID | Session number for stream
  isSource | Is a source stream

Reimplemented from OpalConnection.

Reimplemented in OpalIVRConnection, OpalMixerConnection, OpalPCSSConnection, and OpalFaxConnection.

void* OpalLocalConnection::GetUserData | ( |  | ) | const`[inline]`

Get user data pointer.

void OpalLocalConnection::InternalAcceptIncoming | ( |  | ) | `[protected]`

virtual PBoolean OpalLocalConnection::IsNetworkConnection | ( |  | ) | const`[inline, virtual]`

Get indication of connection being to a "network". This indicates the if the connection may be regarded as a "network" connection. The distinction is about if there is a concept of a "remote" party being connected to and is best described by example: sip, h323, iax and pstn are all "network" connections as they connect to something "remote". While pc, pots and ivr are not as the entity being connected to is intrinsically local.

Implements OpalConnection.

Reimplemented in OpalIVRConnection.

virtual void OpalLocalConnection::OnApplyStringOptions | ( |  | ) | `[virtual]`

Call back for connection to act on changed string options.

Reimplemented from OpalConnection.

Reimplemented in OpalMixerConnection, and OpalFaxConnection.

virtual bool OpalLocalConnection::OnIncoming | ( |  | ) | `[virtual]`

Call back to indicate that there is an incoming call. Note this function should not block or it will impede the operation of the stack.

The default implementation call OpalLocalEndPoint::OnIncomingCall().

Returns:
  false if the call is to be aborted with status of EndedByLocalBusy.

virtual PBoolean OpalLocalConnection::OnIncomingConnection | ( | unsigned int | options,
|  | OpalConnection::StringOptions * | stringOptions |
| ) |  |  | `[virtual]`

Call back for an incoming call. This function is used for an application to control the answering of incoming calls.

If true is returned then the connection continues. If false then the connection is aborted.

Note this function should not block for any length of time. If the decision to answer the call may take some time eg waiting for a user to pick up the phone, then AnswerCallPending or AnswerCallDeferred should be returned.

If an application overrides this function, it should generally call the ancestor version to complete calls. Unless the application completely takes over that responsibility. Generally, an application would only intercept this function if it wishes to do some form of logging. For this you can obtain the name of the caller by using the function OpalConnection::GetRemotePartyName().

The default behaviour calls the base class then OnOutgoingSetUp().

Note that the most explicit version of this override is made pure, so as to force descendant classes to implement it. This will only affect code that implements new descendants of OpalConnection - code that uses existing descendants will be unaffected

Reimplemented from OpalConnection.

virtual bool OpalLocalConnection::OnOutgoing | ( |  | ) | `[virtual]`

Call back to indicate that remote is ringing.

The default implementation call OpalLocalEndPoint::OnOutgoingCall().

Returns:
  false if the call is to be aborted with EndedByNoAccept.

virtual bool OpalLocalConnection::OnOutgoingSetUp | ( |  | ) | `[virtual]`

Call back just before remote is contacted.

The default implementation call OpalLocalEndPoint::OnOutgoingSetUp().

Returns:
  false if the call is to be aborted with EndedByNoAccept.

virtual OpalMediaStreamPtr OpalLocalConnection::OpenMediaStream | ( | const OpalMediaFormat & | mediaFormat,
|  | unsigned | sessionID,
|  | bool | isSource |
| ) |  |  | `[virtual]`

Open source or sink media stream for session.

Parameters:

  mediaFormat | Media format to open
  sessionID | Session to start stream on
  isSource | Stream is a source/sink

Reimplemented from OpalConnection.

virtual PBoolean OpalLocalConnection::SendUserInputString | ( | const PString & | value | ) | `[virtual]`

Send a user input indication to the remote endpoint. This sends an arbitrary string as a user indication. If DTMF tones in particular are required to be sent then the SendIndicationTone() function should be used.

The default behaviour plays the DTMF tones on the line.

Parameters:

  value | String value of indication

Reimplemented from OpalConnection.

Reimplemented in OpalIVRConnection, and OpalMixerConnection.

virtual PBoolean OpalLocalConnection::SetAlerting | ( | const PString & | calleeName,
|  | PBoolean | withMedia |
| ) |  |  | `[virtual]`

Indicate to remote endpoint an alert is in progress. If this is an incoming connection and the AnswerCallResponse is in a AnswerCallDeferred or AnswerCallPending state, then this function is used to indicate to that endpoint that an alert is in progress. This is usually due to another connection which is in the call (the B party) has received an OnAlerting() indicating that its remote endpoint is "ringing".

The default behaviour does nothing.

Parameters:

  calleeName | Name of endpoint being alerted.
  withMedia | Open media with alerting

Reimplemented from OpalConnection.

virtual PBoolean OpalLocalConnection::SetConnected | ( |  | ) | `[virtual]`

Indicate to remote endpoint we are connected.

The default behaviour sets the phase to ConnectedPhase, sets the connection start time and then checks if there is any media channels opened and if so, moves on to the established phase, calling OnEstablished().

In other words, this method is used to handle incoming calls, and is an indication that we have accepted the incoming call.

Reimplemented from OpalConnection.

virtual PBoolean OpalLocalConnection::SetUpConnection | ( |  | ) | `[virtual]`

Start an outgoing connection. This function will initiate the connection to the remote entity, for example in H.323 it sends a SETUP, in SIP it sends an INVITE etc.

The default behaviour determines if this si incoming or outgoing call by checking if we are party A or B, then does approriate setting up of the conenction, including calling OnOutgoing() or OnIncoming() as appropriate.

Reimplemented from OpalConnection.

void OpalLocalConnection::SetUserData | ( | void * | v | ) | `[inline]`

Set user data pointer.

## Friends And Related Function Documentation

friend class PSafeWorkNoArg< OpalLocalConnection >`[friend]`

## Field Documentation

OpalLocalEndPoint& OpalLocalConnection::endpoint `[protected]`

Reimplemented from OpalConnection.

Reimplemented in OpalIVRConnection, and OpalPCSSConnection.

void* OpalLocalConnection::m_userData `[protected]`

The documentation for this class was generated from the following file:

- localep.h