OPAL  Version 3.10.10
OpalConnection Class Referenceabstract

#include <connection.h>

Inheritance diagram for OpalConnection:
IAX2Connection OpalLineConnection OpalLocalConnection OpalRTPConnection OpalFaxConnection OpalIVRConnection OpalMixerConnection OpalPCSSConnection H323Connection SIPConnection

Data Structures

struct  AutoStartInfo
 
class  AutoStartMap
 
struct  CallEndReason
 
class  StringOptions
 
class  ZeroTime
 

Public Types

enum  CallEndReasonCodes {
  EndedByLocalUser, EndedByNoAccept, EndedByAnswerDenied, EndedByRemoteUser,
  EndedByRefusal, EndedByNoAnswer, EndedByCallerAbort, EndedByTransportFail,
  EndedByConnectFail, EndedByGatekeeper, EndedByNoUser, EndedByNoBandwidth,
  EndedByCapabilityExchange, EndedByCallForwarded, EndedBySecurityDenial, EndedByLocalBusy,
  EndedByLocalCongestion, EndedByRemoteBusy, EndedByRemoteCongestion, EndedByUnreachable,
  EndedByNoEndPoint, EndedByHostOffline, EndedByTemporaryFailure, EndedByQ931Cause,
  EndedByDurationLimit, EndedByInvalidConferenceID, EndedByNoDialTone, EndedByNoRingBackTone,
  EndedByOutOfService, EndedByAcceptingCallWaiting, EndedByGkAdmissionFailed, NumCallEndReasons
}
 
enum  AnswerCallResponse {
  AnswerCallNow, AnswerCallDenied, AnswerCallPending, AnswerCallDeferred,
  AnswerCallAlertWithMedia, AnswerCallDeferredWithMedia, AnswerCallProgress, AnswerCallNowAndReleaseCurrent,
  NumAnswerCallResponses
}
 
enum  Options {
  FastStartOptionDisable = 0x0001, FastStartOptionEnable = 0x0002, FastStartOptionMask = 0x0003, H245TunnelingOptionDisable = 0x0004,
  H245TunnelingOptionEnable = 0x0008, H245TunnelingOptionMask = 0x000c, H245inSetupOptionDisable = 0x0010, H245inSetupOptionEnable = 0x0020,
  H245inSetupOptionMask = 0x0030, DetectInBandDTMFOptionDisable = 0x0040, DetectInBandDTMFOptionEnable = 0x0080, DetectInBandDTMFOptionMask = 0x00c0,
  RTPAggregationDisable = 0x0100, RTPAggregationEnable = 0x0200, RTPAggregationMask = 0x0300, SendDTMFAsDefault = 0x0000,
  SendDTMFAsString = 0x0400, SendDTMFAsTone = 0x0800, SendDTMFAsRFC2833 = 0x0c00, SendDTMFMask = 0x0c00
}
 

Public Member Functions

virtual bool GarbageCollection ()
 
const StringOptionsGetStringOptions () const
 Get the string options associated with this connection. More...
 
void SetStringOptions (const StringOptions &options, bool overwrite)
 Set the string options associated with this connection. More...
 
virtual void OnApplyStringOptions ()
 Call back for connection to act on changed string options. More...
 
virtual void EnableRecording ()
 
virtual void DisableRecording ()
 
Construction
 OpalConnection (OpalCall &call, OpalEndPoint &endpoint, const PString &token, unsigned options=0, OpalConnection::StringOptions *stringOptions=NULL)
 
 ~OpalConnection ()
 
Overrides from PObject
void PrintOn (ostream &strm) const
 
Call progress functions
virtual PBoolean OnIncomingConnection (unsigned int options, OpalConnection::StringOptions *stringOptions)
 
virtual PBoolean SetUpConnection ()=0
 
virtual PBoolean OnSetUpConnection ()
 
virtual void OnProceeding ()
 
virtual void OnAlerting ()
 
virtual PBoolean SetAlerting (const PString &calleeName, PBoolean withMedia)=0
 
virtual AnswerCallResponse OnAnswerCall (const PString &callerName)
 
virtual void AnsweringCall (AnswerCallResponse response)
 
virtual void OnConnected ()
 
virtual PBoolean SetConnected ()
 
virtual void OnEstablished ()
 
virtual bool OnTransferNotify (const PStringToString &info, const OpalConnection *transferringConnection)
 
virtual void Release (CallEndReason reason=EndedByLocalUser, bool synchronous=false)
 
virtual void OnReleased ()
 
Additional signalling functions
virtual PString GetDestinationAddress ()
 
virtual PBoolean ForwardCall (const PString &forwardParty)
 
PSafePtr< OpalConnectionGetOtherPartyConnection () const
 
template<class cls >
PSafePtr< cls > GetOtherPartyConnectionAs () const
 
Media Stream Management
virtual OpalMediaFormatList GetMediaFormats () const
 
virtual OpalMediaFormatList GetLocalMediaFormats ()
 
virtual void AdjustMediaFormats (bool local, const OpalConnection *otherConnection, OpalMediaFormatList &mediaFormats) const
 
virtual unsigned GetNextSessionID (const OpalMediaType &mediaType, bool isSource)
 
virtual
OpalMediaType::AutoStartMode 
GetAutoStart (const OpalMediaType &mediaType) const
 
virtual void AutoStartMediaStreams (bool force=false)
 
virtual bool SwitchFaxMediaStreams (bool toT38)
 
virtual void OnSwitchedFaxMediaStreams (bool toT38, bool success)
 
virtual bool OnSwitchingFaxMediaStreams (bool toT38)
 
virtual OpalMediaStreamPtr OpenMediaStream (const OpalMediaFormat &mediaFormat, unsigned sessionID, bool isSource)
 
virtual bool CloseMediaStream (unsigned sessionId, bool source)
 
virtual bool CloseMediaStream (OpalMediaStream &stream)
 
bool RemoveMediaStream (OpalMediaStream &strm)
 
virtual void StartMediaStreams ()
 
virtual void CloseMediaStreams ()
 
virtual void PauseMediaStreams (bool paused)
 
virtual void OnPauseMediaStream (OpalMediaStream &strm, bool paused)
 
virtual OpalMediaStreamCreateMediaStream (const OpalMediaFormat &mediaFormat, unsigned sessionID, PBoolean isSource)
 
OpalMediaStreamPtr GetMediaStream (const PString &streamID, bool source) const
 
OpalMediaStreamPtr GetMediaStream (unsigned sessionId, bool source) const
 
OpalMediaStreamPtr GetMediaStream (const OpalMediaType &mediaType, bool source, OpalMediaStreamPtr previous=NULL) const
 
virtual PBoolean OnOpenMediaStream (OpalMediaStream &stream)
 
virtual void OnClosedMediaStream (const OpalMediaStream &stream)
 
virtual void OnPatchMediaStream (PBoolean isSource, OpalMediaPatch &patch)
 
virtual void OnStartMediaPatch (OpalMediaPatch &patch)
 
virtual void OnStopMediaPatch (OpalMediaPatch &patch)
 
virtual bool OnMediaCommand (OpalMediaStream &stream, const OpalMediaCommand &command)
 
virtual void AttachRFC2833HandlerToPatch (PBoolean isSource, OpalMediaPatch &patch)
 
virtual PBoolean IsMediaBypassPossible (unsigned sessionID) const
 
virtual PBoolean CreateVideoInputDevice (const OpalMediaFormat &mediaFormat, PVideoInputDevice *&device, PBoolean &autoDelete)
 
virtual PBoolean CreateVideoOutputDevice (const OpalMediaFormat &mediaFormat, PBoolean preview, PVideoOutputDevice *&device, PBoolean &autoDelete)
 
virtual bool SendVideoUpdatePicture (unsigned sessionID=0, bool force=false) const
 
virtual PBoolean SetAudioVolume (PBoolean source, unsigned percentage)
 
virtual PBoolean GetAudioVolume (PBoolean source, unsigned &percentage)
 
virtual bool SetAudioMute (bool source, bool mute)
 
virtual bool GetAudioMute (bool source, bool &mute)
 
virtual unsigned GetAudioSignalLevel (PBoolean source)
 
Bandwidth Management
unsigned GetBandwidthAvailable () const
 
virtual PBoolean SetBandwidthAvailable (unsigned newBandwidth, PBoolean force=false)
 
virtual unsigned GetBandwidthUsed () const
 
virtual PBoolean SetBandwidthUsed (unsigned releasedBandwidth, unsigned requiredBandwidth)
 
Member variable access
OpalEndPointGetEndPoint () const
 
OpalCallGetCall () const
 
const PString & GetToken () const
 
PBoolean IsOriginating () const
 
const PTime & GetPhaseTime (Phases phase) const
 
const PTime & GetSetupUpTime () const
 
const PTime & GetAlertingTime () const
 
const PTime & GetConnectionStartTime () const
 
const PTime & GetConnectionEndTime () const
 
const OpalProductInfoGetProductInfo () const
 
void SetProductInfo (const OpalProductInfo &info)
 
virtual PString GetPrefixName () const
 
const PString & GetLocalPartyName () const
 
virtual void SetLocalPartyName (const PString &name)
 
virtual PString GetLocalPartyURL () const
 
const PString & GetDisplayName () const
 
void SetDisplayName (const PString &name)
 
virtual bool IsPresentationBlocked () const
 
const PString & GetRemotePartyName () const
 
void SetRemotePartyName (const PString &name)
 
const PString & GetRemotePartyNumber () const
 
const PString & GetRemotePartyAddress () const
 
void SetRemotePartyAddress (const PString &addr)
 
virtual PString GetRemotePartyURL () const
 
const PString & GetRedirectingParty () const
 
void SetRedirectingParty (const PString &party)
 
const PString GetRemotePartyCallbackURL () const
 
PCaselessString GetRemoteApplication () const
 
const OpalProductInfoGetRemoteProductInfo () const
 
const PString & GetCalledPartyName () const
 
const PString & GetCalledPartyNumber () const
 
virtual PString GetCalledPartyURL ()
 
void CopyPartyNames (const OpalConnection &other)
 
virtual PString GetAlertingType () const
 
virtual bool SetAlertingType (const PString &info)
 
virtual PString GetCallInfo () const
 
unsigned GetMinAudioJitterDelay () const
 
unsigned GetMaxAudioJitterDelay () const
 
void SetAudioJitterDelay (unsigned minDelay, unsigned maxDelay)
 
OpalSilenceDetectorGetSilenceDetector () const
 
virtual PString GetIdentifier () const
 
virtual PINDEX GetMaxRtpPayloadSize () const
 
virtual OpalTransportGetTransport () const
 
 PDICTIONARY (MediaAddressesDict, POrdinalKey, OpalTransportAddress)
 
MediaAddressesDict & GetMediaTransportAddresses ()
 
unsigned GetVideoUpdateRequestsSent () const
 

Protected Types

enum  { e_NotSwitchingFaxMediaStreams, e_SwitchingToFaxMediaStreams, e_SwitchingFromFaxMediaStreams }
 

Protected Member Functions

void OnConnectedInternal ()
 
 PDECLARE_NOTIFIER (PThread, OpalConnection, OnReleaseThreadMain)
 
 PDECLARE_NOTIFIER (RTP_DataFrame, OpalConnection, OnRecordAudio)
 
 PDECLARE_NOTIFIER (RTP_DataFrame, OpalConnection, OnRecordVideo)
 
void OnStartRecording (OpalMediaPatch *patch)
 
void OnStopRecording (OpalMediaPatch *patch)
 

Protected Attributes

OpalCallownerCall
 
OpalEndPointendpoint
 
PString callToken
 
PBoolean originating
 
OpalProductInfo productInfo
 
PString localPartyName
 
PString displayName
 
PString remotePartyName
 
PString remotePartyURL
 
OpalProductInfo remoteProductInfo
 
PString remotePartyNumber
 
PString remotePartyAddress
 
PString m_redirectingParty
 
CallEndReason callEndReason
 
PString m_calledPartyNumber
 
PString m_calledPartyName
 
SendUserInputModes sendUserInputMode
 
PString userInputString
 
PSyncPoint userInputAvailable
 
OpalSilenceDetectorsilenceDetector
 
OpalMediaFormat m_filterMediaFormat
 
OpalMediaFormatList m_localMediaFormats
 
MediaAddressesDict mediaTransportAddresses
 
PSafeList< OpalMediaStreammediaStreams
 
unsigned minAudioJitterDelay
 
unsigned maxAudioJitterDelay
 
unsigned bandwidthAvailable
 
StringOptions m_stringOptions
 
PString m_recordingFilename
 
PNotifier m_recordAudioNotifier
 
PNotifier m_recordVideoNotifier
 
unsigned m_VideoUpdateRequestsSent
 
AutoStartMap m_autoStartInfo
 
enum OpalConnection:: { ... }  m_faxMediaStreamsSwitchState
 
ZeroTime m_phaseTime [NumPhases]
 

Basic operations

enum  Phases {
  UninitialisedPhase, SetUpPhase, ProceedingPhase, AlertingPhase,
  ConnectedPhase, EstablishedPhase, ForwardingPhase, ReleasingPhase,
  ReleasedPhase, NumPhases
}
 
virtual bool IsNetworkConnection () const =0
 
__inline Phases GetPhase () const
 
__inline bool IsEstablished () const
 Return true if connection is in the established phase. More...
 
__inline bool IsReleased () const
 Return true if connection is in the established phase. More...
 
void SetPhase (Phases phaseToSet)
 
CallEndReason GetCallEndReason () const
 
PString GetCallEndReasonText () const
 
virtual void SetCallEndReason (CallEndReason reason)
 
void ClearCall (CallEndReason reason=EndedByLocalUser, PSyncPoint *sync=NULL)
 
virtual void ClearCallSynchronous (PSyncPoint *sync, CallEndReason reason=EndedByLocalUser)
 
unsigned GetQ931Cause () const
 
void SetQ931Cause (unsigned v)
 
virtual bool TransferConnection (const PString &remoteParty)
 
virtual bool Hold (bool fromRemote, bool placeOnHold)
 
virtual bool IsOnHold (bool fromRemote)
 
virtual void OnHold (bool fromRemote, bool onHold)
 
static PString GetCallEndReasonText (CallEndReason reason)
 
static void SetCallEndReasonText (CallEndReasonCodes reasonCode, const PString &newText)
 

User input

enum  SendUserInputModes {
  SendUserInputAsQ931, SendUserInputAsString, SendUserInputAsTone, SendUserInputAsRFC2833,
  SendUserInputInBand, SendUserInputAsProtocolDefault, NumSendUserInputModes, SendUserInputAsInlineRFC2833 = SendUserInputAsRFC2833
}
 
virtual void SetSendUserInputMode (SendUserInputModes mode)
 
virtual SendUserInputModes GetSendUserInputMode () const
 
virtual SendUserInputModes GetRealSendUserInputMode () const
 
virtual PBoolean SendUserInputString (const PString &value)
 
virtual PBoolean SendUserInputTone (char tone, unsigned duration=0)
 
virtual void OnUserInputString (const PString &value)
 
virtual void OnUserInputTone (char tone, unsigned duration)
 
void SendUserInputHookFlash (unsigned duration=500)
 
virtual PString GetUserInput (unsigned timeout=30)
 
virtual void SetUserInput (const PString &input)
 
virtual PString ReadUserInput (const char *terminators="#\r\n", unsigned lastDigitTimeout=4, unsigned firstDigitTimeout=30)
 
virtual PBoolean PromptUserInput (PBoolean play)
 

Detailed Description

This is the base class for connections to an endpoint. A particular protocol will have a descendant class from this to implement the specific semantics of that protocols connection.

A connection is part of a call, and will be "owned" by an OpalCall object. It is also attached to the creator endpoint to do any protocol specific management of the connection. However the deletion of the connection is done by a special thread in the OpalManager class. A connnection should never be deleted directly.

The connection is also in charge of creating media streams. It may do this in respose to an explicit call to OpenMediaStream or implicitly due to requests in the underlying protocol.

When media streams are created they must make requests for bandwidth which is managed by the connection.

Member Enumeration Documentation

anonymous enum
protected
Enumerator
e_NotSwitchingFaxMediaStreams 
e_SwitchingToFaxMediaStreams 
e_SwitchingFromFaxMediaStreams 
Enumerator
AnswerCallNow 
AnswerCallDenied 

Answer the call continuing with the connection.

AnswerCallPending 

Refuse the call sending a release complete.

AnswerCallDeferred 

Send an Alerting PDU and wait for AnsweringCall()

AnswerCallAlertWithMedia 

As for AnswerCallPending but does not send Alerting PDU.

AnswerCallDeferredWithMedia 

As for AnswerCallPending but starts media channels.

AnswerCallProgress 

As for AnswerCallDeferred but starts media channels.

AnswerCallNowAndReleaseCurrent 

Answer the call with a h323 progress, or sip 183 session in progress, or ...

NumAnswerCallResponses 

Answer the call and destroy the current call.

Call/Connection ending reasons. NOTE: if anything is added to this, you also need to add the field to the tables in connection.cxx and h323pdu.cxx.

Enumerator
EndedByLocalUser 
EndedByNoAccept 

Local endpoint application cleared call.

EndedByAnswerDenied 

Local endpoint did not accept call OnIncomingCall()=false.

EndedByRemoteUser 

Local endpoint declined to answer call.

EndedByRefusal 

Remote endpoint application cleared call.

EndedByNoAnswer 

Remote endpoint refused call.

EndedByCallerAbort 

Remote endpoint did not answer in required time.

EndedByTransportFail 

Remote endpoint stopped calling.

EndedByConnectFail 

Transport error cleared call.

EndedByGatekeeper 

Transport connection failed to establish call.

EndedByNoUser 

Gatekeeper has cleared call.

EndedByNoBandwidth 

Call failed as could not find user (in GK)

EndedByCapabilityExchange 

Call failed as could not get enough bandwidth.

EndedByCallForwarded 

Could not find common capabilities.

EndedBySecurityDenial 

Call was forwarded using FACILITY message.

EndedByLocalBusy 

Call failed a security check and was ended.

EndedByLocalCongestion 

Local endpoint busy.

EndedByRemoteBusy 

Local endpoint congested.

EndedByRemoteCongestion 

Remote endpoint busy.

EndedByUnreachable 

Remote endpoint congested.

EndedByNoEndPoint 

Could not reach the remote party.

EndedByHostOffline 

The remote party is not running an endpoint.

EndedByTemporaryFailure 

The remote party host off line.

EndedByQ931Cause 

The remote failed temporarily app may retry.

EndedByDurationLimit 

The remote ended the call with unmapped Q.931 cause code.

EndedByInvalidConferenceID 

Call cleared due to an enforced duration limit.

EndedByNoDialTone 

Call cleared due to invalid conference ID.

EndedByNoRingBackTone 

Call cleared due to missing dial tone.

EndedByOutOfService 

Call cleared due to missing ringback tone.

EndedByAcceptingCallWaiting 

Call cleared because the line is out of service,.

EndedByGkAdmissionFailed 

Call cleared because another call is answered.

NumCallEndReasons 

Call cleared because gatekeeper admission request failed.

Connection options

Enumerator
FastStartOptionDisable 
FastStartOptionEnable 
FastStartOptionMask 
H245TunnelingOptionDisable 
H245TunnelingOptionEnable 
H245TunnelingOptionMask 
H245inSetupOptionDisable 
H245inSetupOptionEnable 
H245inSetupOptionMask 
DetectInBandDTMFOptionDisable 
DetectInBandDTMFOptionEnable 
DetectInBandDTMFOptionMask 
RTPAggregationDisable 
RTPAggregationEnable 
RTPAggregationMask 
SendDTMFAsDefault 
SendDTMFAsString 
SendDTMFAsTone 
SendDTMFAsRFC2833 
SendDTMFMask 

Different phases of a call, which are used in all OpalConnection instances. These phases are fully described in the documentation page Connection handling in the OPAL library.

Enumerator
UninitialisedPhase 

Indicates the OpalConnection instance has just been constructed.

SetUpPhase 

Has just sent/received the initial SETUP/INVITE packet.

ProceedingPhase 

The receipt of SETUP/INVITE has been acknowledged.

AlertingPhase 

The remote says there is a phone ringing, somewhere.

ConnectedPhase 

There is agreement on having a call, usually means billing will apply.

EstablishedPhase 

Media is established, streams are all operational.

ForwardingPhase 

Connection is in the process of being forwarded.

ReleasingPhase 

Hangup packet has been sent/received, media and control not yet stopped.

ReleasedPhase 

Media and control streams have been terminated.

NumPhases 

Number of available phases. Can be used to indicate an unknown phase.

Enumerator
SendUserInputAsQ931 
SendUserInputAsString 
SendUserInputAsTone 
SendUserInputAsRFC2833 
SendUserInputInBand 
SendUserInputAsProtocolDefault 
NumSendUserInputModes 
SendUserInputAsInlineRFC2833 

Constructor & Destructor Documentation

OpalConnection::OpalConnection ( OpalCall call,
OpalEndPoint endpoint,
const PString &  token,
unsigned  options = 0,
OpalConnection::StringOptions stringOptions = NULL 
)

Create a new connection.

Parameters
callOwner calll for connection
endpointOwner endpoint for connection
tokenToken to identify the connection
optionsOption bit map to be passed to connection
stringOptionsOptions to be passed to connection
OpalConnection::~OpalConnection ( )

Destroy connection.

Member Function Documentation

virtual void OpalConnection::AdjustMediaFormats ( bool  local,
const OpalConnection otherConnection,
OpalMediaFormatList mediaFormats 
) const
virtual

Adjust media formats available on a connection. This is called by a connection after it has called OpalCall::GetMediaFormats() to get all media formats that it can use so that an application may remove or reorder the media formats before they are used to open media streams.

This function may also be executed by other connections in the call. If this happens then the "otherConnection" parameter will be non-NULL. The "local" parameter sense is relative to the "otherConnection" parameter, if NULL then it is relative to "this".

The default behaviour calls the OpalEndPoint function of the same name.

Parameters
localMedia formats a local ones to be presented to remote
otherConnectionOther connection we are adjusting media for
mediaFormatsMedia formats to use

Reimplemented in OpalRTPConnection, and OpalFaxConnection.

virtual void OpalConnection::AnsweringCall ( AnswerCallResponse  response)
virtual

Indicate the result of answering an incoming call. This should only be called if the OnAnswerCall() callback function has returned a AnswerCallPending or AnswerCallDeferred response.

Note sending further AnswerCallPending responses via this function will have the result of notification PDUs being sent to the remote endpoint (if possible). In this way multiple notification PDUs may be sent.

Sending a AnswerCallDeferred response would have no effect.

Parameters
responseAnswer response to incoming call

Reimplemented in H323Connection, and IAX2Connection.

virtual void OpalConnection::AttachRFC2833HandlerToPatch ( PBoolean  isSource,
OpalMediaPatch patch 
)
virtual

Attaches the RFC 2833 handler to the media patch This method may be called from subclasses, e.g. within OnPatchMediaStream()

Reimplemented in OpalRTPConnection.

virtual void OpalConnection::AutoStartMediaStreams ( bool  force = false)
virtual

Open source media streams, if needed.

Parameters
forceForce re-open even if already open
void OpalConnection::ClearCall ( CallEndReason  reason = EndedByLocalUser,
PSyncPoint *  sync = NULL 
)

Clear a current call. This hangs up the current call. This will release all connections currently in the call by calling the OpalCall::Clear() function.

Note that this function will return quickly as the release and disposal of the connections is done by another thread.

If sync is not NULL then it is signalled when the calls are cleared.

Parameters
reasonReason for call clearing
virtual void OpalConnection::ClearCallSynchronous ( PSyncPoint *  sync,
CallEndReason  reason = EndedByLocalUser 
)
virtual

Clear a current connection, synchronously. This hangs up the connection to a remote endpoint. Note that this function is always synchronous. If sync is NULL then a local PSyncPoint is used.

Parameters
syncSynchronisation object to signal
reasonReason for call clearing
virtual bool OpalConnection::CloseMediaStream ( unsigned  sessionId,
bool  source 
)
virtual

Close of a media stream by session.

Parameters
sessionIdSession ID to search for.
sourceIndicates the direction of stream.
virtual bool OpalConnection::CloseMediaStream ( OpalMediaStream stream)
virtual

Close of a specific media stream.

Parameters
streamStream to close

Reimplemented in SIPConnection, and H323Connection.

virtual void OpalConnection::CloseMediaStreams ( )
virtual

Request close all media streams on connection.