endpoint.h
Go to the documentation of this file.
/*
* endpoint.h
*
* Telephony endpoint abstraction
*
* Open Phone Abstraction Library (OPAL)
* Formally known as the Open H323 project.
*
* Copyright (c) 2001 Equivalence Pty. Ltd.
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Open Phone Abstraction Library.
*
* The Initial Developer of the Original Code is Equivalence Pty. Ltd.
*
* Contributor(s): ______________________________________.
*
* $Revision: 27984 $
* $Author: rjongbloed $
* $Date: 2012-07-10 03:24:24 -0500 (Tue, 10 Jul 2012) $
*/
#ifndef OPAL_OPAL_ENDPOINT_H
#define OPAL_OPAL_ENDPOINT_H
#ifdef P_USE_PRAGMA
#pragma interface
#endif
#include <opal/buildopts.h>
#include <opal/manager.h>
#include <opal/mediafmt.h>
#include <opal/transports.h>
class OpalCall;
class OpalMediaStream;
class OpalEndPoint : public PObject
{
PCLASSINFO(OpalEndPoint, PObject);
public:
enum Attributes {
CanTerminateCall = 1,
SupportsE164 = 2
};
OpalEndPoint(
OpalManager & manager,
const PCaselessString & prefix,
unsigned attributes
);
~OpalEndPoint();
virtual void ShutDown();
void PrintOn(
ostream & strm
) const;
PBoolean StartListeners(
const PStringArray & interfaces
);
PBoolean StartListener(
const OpalTransportAddress & iface
);
PBoolean StartListener(
OpalListener * listener
);
virtual PStringArray GetDefaultListeners() const;
virtual PString GetDefaultTransport() const;
OpalListener * FindListener(
const OpalTransportAddress & iface
);
bool FindListenerForProtocol(
const char * proto,
OpalTransportAddress & addr
);
PBoolean StopListener(
const OpalTransportAddress & iface
);
PBoolean RemoveListener(
OpalListener * listener
);
OpalTransportAddressArray GetInterfaceAddresses(
PBoolean excludeLocalHost = true,
const OpalTransport * associatedTransport = NULL
);
PDECLARE_NOTIFIER(PThread, OpalEndPoint, ListenerCallback);
virtual PBoolean NewIncomingConnection(
OpalTransport * transport
);
virtual void OnNewConnection(
OpalCall & call,
OpalConnection & connection
);
virtual PSafePtr<OpalConnection> MakeConnection(
OpalCall & call,
const PString & party,
void * userData = NULL,
unsigned int options = 0,
OpalConnection::StringOptions * stringOptions = NULL
) = 0;
virtual PBoolean OnSetUpConnection(OpalConnection &connection);
virtual PBoolean OnIncomingConnection(
OpalConnection & connection,
unsigned options,
OpalConnection::StringOptions * stringOptions
);
virtual void OnProceeding(
OpalConnection & connection
);
virtual void OnAlerting(
OpalConnection & connection
);
virtual OpalConnection::AnswerCallResponse OnAnswerCall(
OpalConnection & connection,
const PString & caller
);
virtual void OnConnected(
OpalConnection & connection
);
virtual void OnEstablished(
OpalConnection & connection
);
virtual void OnReleased(
OpalConnection & connection
);
virtual void OnHold(
OpalConnection & connection,
bool fromRemote,
bool onHold
);
virtual void OnHold(OpalConnection & connection); // For backward compatibility
virtual PBoolean OnForwarded(
OpalConnection & connection,
const PString & remoteParty
);
virtual bool OnTransferNotify(
OpalConnection & connection,
const PStringToString & info
);
virtual PBoolean ClearCall(
const PString & token,
OpalConnection::CallEndReason reason = OpalConnection::EndedByLocalUser,
PSyncPoint * sync = NULL
);
virtual PBoolean ClearCallSynchronous(
const PString & token,
OpalConnection::CallEndReason reason = OpalConnection::EndedByLocalUser,
PSyncPoint * sync = NULL
);
virtual void ClearAllCalls(
OpalConnection::CallEndReason reason = OpalConnection::EndedByLocalUser,
PBoolean wait = true
);
PSafePtr<OpalConnection> GetConnectionWithLock(
const PString & token,
PSafetyMode mode = PSafeReadWrite
) { return connectionsActive.FindWithLock(token, mode); }
template <class ConnClass>
PSafePtr<ConnClass> GetConnectionWithLockAs(
const PString & token,
PSafetyMode mode = PSafeReadWrite
)
{
PSafePtr<ConnClass> connection = PSafePtrCast<OpalConnection, ConnClass>(GetConnectionWithLock(token, mode));
if (connection == NULL) {
PSafePtr<OpalCall> call = manager.FindCallWithLock(token, PSafeReadOnly);
if (call != NULL) {
connection = PSafePtrCast<OpalConnection, ConnClass>(call->GetConnection(0, mode));
if (connection == NULL)
connection = PSafePtrCast<OpalConnection, ConnClass>(call->GetConnection(1, mode));
}
}
return connection;
}
PStringList GetAllConnections();
PINDEX GetConnectionCount() const { return connectionsActive.GetSize(); }
virtual PBoolean HasConnection(
const PString & token
);
virtual void DestroyConnection(
OpalConnection * connection
);
virtual OpalMediaFormatList GetMediaFormats() const = 0;
virtual void AdjustMediaFormats(
bool local,
const OpalConnection & connection,
OpalMediaFormatList & mediaFormats
) const;
virtual PBoolean OnOpenMediaStream(
OpalConnection & connection,
OpalMediaStream & stream
);
virtual void OnClosedMediaStream(
const OpalMediaStream & stream
);
#if OPAL_VIDEO
virtual PBoolean CreateVideoInputDevice(
const OpalConnection & connection,
const OpalMediaFormat & mediaFormat,
PVideoInputDevice * & device,
PBoolean & autoDelete
);
virtual PBoolean CreateVideoOutputDevice(
const OpalConnection & connection,
const OpalMediaFormat & mediaFormat,
PBoolean preview,
PVideoOutputDevice * & device,
PBoolean & autoDelete
);
#endif
virtual void OnUserInputString(
OpalConnection & connection,
const PString & value
);
virtual void OnUserInputTone(
OpalConnection & connection,
char tone,
int duration
);
virtual PString ReadUserInput(
OpalConnection & connection,
const char * terminators = "#\r\n",
unsigned lastDigitTimeout = 4,
unsigned firstDigitTimeout = 30
);
virtual PBoolean Message(
const PString & to,
const PString & body
);
virtual PBoolean Message(
const PURL & to,
const PString & type,
const PString & body,
PURL & from,
PString & conversationId
);
virtual PBoolean Message(
OpalIM & Message
);
virtual void OnMessageReceived(
const OpalIM & message
);
virtual void OnMWIReceived (
const PString & party,
OpalManager::MessageWaitingType type,
const PString & extraInfo
);
virtual PBoolean GarbageCollection();
OpalManager & GetManager() const { return manager; }
const PString & GetPrefixName() const { return prefixName; }
PBoolean HasAttribute(Attributes opt) const { return (attributeBits&opt) != 0; }
WORD GetDefaultSignalPort() const { return defaultSignalPort; }
const OpalProductInfo & GetProductInfo() const { return productInfo; }
void SetProductInfo(
const OpalProductInfo & info
) { productInfo = info; }
const PString & GetDefaultLocalPartyName() const { return defaultLocalPartyName; }
virtual void SetDefaultLocalPartyName(
const PString & name
) { defaultLocalPartyName = name; }
const PString & GetDefaultDisplayName() const { return defaultDisplayName; }
void SetDefaultDisplayName(const PString & name) { defaultDisplayName = name; }
unsigned GetInitialBandwidth() const { return initialBandwidth; }
void SetInitialBandwidth(unsigned bandwidth) { initialBandwidth = bandwidth; }
const OpalListenerList & GetListeners() const { return listeners; }
const OpalConnection::StringOptions & GetDefaultStringOptions() const { return m_defaultStringOptions; }
void SetDefaultStringOptions(const OpalConnection::StringOptions & opts) { m_defaultStringOptions = opts; }
void SetDefaultStringOption(const PCaselessString & key, const PString & data) { m_defaultStringOptions.SetAt(key, data); }
OpalConnection::SendUserInputModes GetSendUserInputMode() const { return defaultSendUserInputMode; }
void SetSendUserInputMode(OpalConnection::SendUserInputModes mode) { defaultSendUserInputMode = mode; }
#if OPAL_PTLIB_SSL
PString GetSSLCertificate() const;
#endif
protected:
OpalManager & manager;
PCaselessString prefixName;
unsigned attributeBits;
WORD defaultSignalPort;
PINDEX m_maxSizeUDP;
OpalProductInfo productInfo;
PString defaultLocalPartyName;
PString defaultDisplayName;
unsigned initialBandwidth; // in 100s of bits/sev
OpalConnection::StringOptions m_defaultStringOptions;
OpalConnection::SendUserInputModes defaultSendUserInputMode;
OpalListenerList listeners;
class ConnectionDict : public PSafeDictionary<PString, OpalConnection>
{
virtual void DeleteObject(PObject * object) const;
} connectionsActive;
OpalConnection * AddConnection(OpalConnection * connection);
PMutex inUseFlag;
friend void OpalManager::GarbageCollection();
friend void OpalConnection::Release(CallEndReason,bool);
private:
P_REMOVE_VIRTUAL(PBoolean, OnIncomingConnection(OpalConnection &, unsigned), false);
P_REMOVE_VIRTUAL(PBoolean, OnIncomingConnection(OpalConnection &), false);
P_REMOVE_VIRTUAL_VOID(AdjustMediaFormats(const OpalConnection &, OpalMediaFormatList &) const);
P_REMOVE_VIRTUAL_VOID(OnMessageReceived(const PURL&,const PString&,const PURL&,const PString&,const PString&,const PString&));
};
bool OpalIsE164(
const PString & number,
bool strict = false
);
#endif // OPAL_OPAL_ENDPOINT_H
// End of File ///////////////////////////////////////////////////////////////
OpalManager::GarbageCollection
void GarbageCollection()
OpalEndPoint::PrintOn
void PrintOn(ostream &strm) const
OpalEndPoint::GetMediaFormats
virtual OpalMediaFormatList GetMediaFormats() const =0
OpalManager
Definition: manager.h:74
OpalEndPoint
Definition: endpoint.h:67
OpalEndPoint::OnClosedMediaStream
virtual void OnClosedMediaStream(const OpalMediaStream &stream)
OpalEndPoint::OnProceeding
virtual void OnProceeding(OpalConnection &connection)
OpalEndPoint::defaultSignalPort
WORD defaultSignalPort
Definition: endpoint.h:810
OpalIsE164
bool OpalIsE164(const PString &number, bool strict=false)
Test for if string is a valid E.164 number.
OpalEndPoint::OnNewConnection
virtual void OnNewConnection(OpalCall &call, OpalConnection &connection)
OpalEndPoint::CreateVideoOutputDevice
virtual PBoolean CreateVideoOutputDevice(const OpalConnection &connection, const OpalMediaFormat &mediaFormat, PBoolean preview, PVideoOutputDevice *&device, PBoolean &autoDelete)
OpalEndPoint::OnUserInputString
virtual void OnUserInputString(OpalConnection &connection, const PString &value)
OpalEndPoint::SetDefaultDisplayName
void SetDefaultDisplayName(const PString &name)
Definition: endpoint.h:765
buildopts.h
OpalEndPoint::GetAllConnections
PStringList GetAllConnections()
OpalEndPoint::RemoveListener
PBoolean RemoveListener(OpalListener *listener)
OpalEndPoint::ReadUserInput
virtual PString ReadUserInput(OpalConnection &connection, const char *terminators="#\r\n", unsigned lastDigitTimeout=4, unsigned firstDigitTimeout=30)
OpalEndPoint::GetDefaultStringOptions
const OpalConnection::StringOptions & GetDefaultStringOptions() const
Definition: endpoint.h:781
OpalEndPoint::initialBandwidth
unsigned initialBandwidth
Definition: endpoint.h:816
OpalEndPoint::OnUserInputTone
virtual void OnUserInputTone(OpalConnection &connection, char tone, int duration)
OpalTransport
Definition: transports.h:703
OpalEndPoint::OnForwarded
virtual PBoolean OnForwarded(OpalConnection &connection, const PString &remoteParty)
OpalEndPoint::defaultDisplayName
PString defaultDisplayName
Definition: endpoint.h:814
OpalEndPoint::SetProductInfo
void SetProductInfo(const OpalProductInfo &info)
Definition: endpoint.h:745
OpalEndPoint::inUseFlag
PMutex inUseFlag
Definition: endpoint.h:828
OpalEndPoint::SetDefaultStringOption
void SetDefaultStringOption(const PCaselessString &key, const PString &data)
Definition: endpoint.h:789
OpalEndPoint::StartListener
PBoolean StartListener(const OpalTransportAddress &iface)
OpalEndPoint::SetSendUserInputMode
void SetSendUserInputMode(OpalConnection::SendUserInputModes mode)
Definition: endpoint.h:797
OpalEndPoint::HasAttribute
PBoolean HasAttribute(Attributes opt) const
Definition: endpoint.h:733
OpalEndPoint::HasConnection
virtual PBoolean HasConnection(const PString &token)
OpalEndPoint::OnEstablished
virtual void OnEstablished(OpalConnection &connection)
OpalIM
Definition: im.h:42
OpalEndPoint::OnAnswerCall
virtual OpalConnection::AnswerCallResponse OnAnswerCall(OpalConnection &connection, const PString &caller)
OpalEndPoint::connectionsActive
OpalEndPoint::ConnectionDict connectionsActive
OpalEndPoint::StartListeners
PBoolean StartListeners(const PStringArray &interfaces)
OpalListener
Definition: transports.h:351
OpalEndPoint::ConnectionDict
Definition: endpoint.h:822
OpalEndPoint::m_defaultStringOptions
OpalConnection::StringOptions m_defaultStringOptions
Definition: endpoint.h:817
OpalEndPoint::attributeBits
unsigned attributeBits
Definition: endpoint.h:809
OpalEndPoint::MakeConnection
virtual PSafePtr< OpalConnection > MakeConnection(OpalCall &call, const PString &party, void *userData=NULL, unsigned int options=0, OpalConnection::StringOptions *stringOptions=NULL)=0
OpalEndPoint::ClearCallSynchronous
virtual PBoolean ClearCallSynchronous(const PString &token, OpalConnection::CallEndReason reason=OpalConnection::EndedByLocalUser, PSyncPoint *sync=NULL)
OpalConnection::Release
virtual void Release(CallEndReason reason=EndedByLocalUser, bool synchronous=false)
OpalEndPoint::AddConnection
OpalConnection * AddConnection(OpalConnection *connection)
OpalMediaFormatList
Definition: mediafmt.h:72
OpalEndPoint::GetInterfaceAddresses
OpalTransportAddressArray GetInterfaceAddresses(PBoolean excludeLocalHost=true, const OpalTransport *associatedTransport=NULL)
OpalConnection::SendUserInputModes
SendUserInputModes
Definition: connection.h:1311
OpalEndPoint::prefixName
PCaselessString prefixName
Definition: endpoint.h:808
OpalEndPoint::OnMessageReceived
virtual void OnMessageReceived(const OpalIM &message)
OpalConnection::AnswerCallResponse
AnswerCallResponse
Definition: connection.h:417
OpalEndPoint::StopListener
PBoolean StopListener(const OpalTransportAddress &iface)
OpalConnection::StringOptions
Definition: connection.h:462
OpalEndPoint::OnHold
virtual void OnHold(OpalConnection &connection, bool fromRemote, bool onHold)
OpalEndPoint::OpalEndPoint
OpalEndPoint(OpalManager &manager, const PCaselessString &prefix, unsigned attributes)
OpalManager::MessageWaitingType
MessageWaitingType
Message waiting sub-types.
Definition: manager.h:886
OpalEndPoint::SetInitialBandwidth
void SetInitialBandwidth(unsigned bandwidth)
Definition: endpoint.h:773
OpalMediaFormat
Definition: mediafmt.h:724
OpalEndPoint::OnIncomingConnection
virtual PBoolean OnIncomingConnection(OpalConnection &connection, unsigned options, OpalConnection::StringOptions *stringOptions)
OpalEndPoint::m_maxSizeUDP
PINDEX m_maxSizeUDP
Definition: endpoint.h:811
OpalEndPoint::CreateVideoInputDevice
virtual PBoolean CreateVideoInputDevice(const OpalConnection &connection, const OpalMediaFormat &mediaFormat, PVideoInputDevice *&device, PBoolean &autoDelete)
OpalCall
Definition: call.h:65
OpalEndPoint::Attributes
Attributes
Definition: endpoint.h:71
OpalEndPoint::FindListenerForProtocol
bool FindListenerForProtocol(const char *proto, OpalTransportAddress &addr)
manager.h
OpalEndPoint::~OpalEndPoint
~OpalEndPoint()
OpalEndPoint::GetDefaultLocalPartyName
const PString & GetDefaultLocalPartyName() const
Definition: endpoint.h:751
OpalEndPoint::SupportsE164
Definition: endpoint.h:73
OpalEndPoint::GetConnectionCount
PINDEX GetConnectionCount() const
Definition: endpoint.h:548
OpalEndPoint::ClearCall
virtual PBoolean ClearCall(const PString &token, OpalConnection::CallEndReason reason=OpalConnection::EndedByLocalUser, PSyncPoint *sync=NULL)
OpalEndPoint::ShutDown
virtual void ShutDown()
OpalEndPoint::OnReleased
virtual void OnReleased(OpalConnection &connection)
transports.h
OpalEndPoint::GetConnectionWithLockAs
PSafePtr< ConnClass > GetConnectionWithLockAs(const PString &token, PSafetyMode mode=PSafeReadWrite)
Definition: endpoint.h:525
OpalEndPoint::GetManager
OpalManager & GetManager() const
Definition: endpoint.h:725
OpalEndPoint::OnAlerting
virtual void OnAlerting(OpalConnection &connection)
OpalEndPoint::SetDefaultStringOptions
void SetDefaultStringOptions(const OpalConnection::StringOptions &opts)
Definition: endpoint.h:785
OpalEndPoint::manager
OpalManager & manager
Definition: endpoint.h:807
OpalEndPoint::DestroyConnection
virtual void DestroyConnection(OpalConnection *connection)
OpalEndPoint::FindListener
OpalListener * FindListener(const OpalTransportAddress &iface)
OpalEndPoint::defaultSendUserInputMode
OpalConnection::SendUserInputModes defaultSendUserInputMode
Definition: endpoint.h:818
OpalTransportAddressArray
OpalTransportAddressArray(const OpalTransportAddress &address)
Definition: transports.h:305
mediafmt.h
OpalEndPoint::CanTerminateCall
Definition: endpoint.h:72
OpalConnection::CallEndReason
Definition: connection.h:396
OpalManager::FindCallWithLock
PSafePtr< OpalCall > FindCallWithLock(const PString &token, PSafetyMode mode=PSafeReadWrite)
Definition: manager.h:192
OpalEndPoint::listeners
OpalListenerList listeners
Definition: endpoint.h:820
OpalEndPoint::OnTransferNotify
virtual bool OnTransferNotify(OpalConnection &connection, const PStringToString &info)
OpalEndPoint::defaultLocalPartyName
PString defaultLocalPartyName
Definition: endpoint.h:813
OpalEndPoint::PDECLARE_NOTIFIER
PDECLARE_NOTIFIER(PThread, OpalEndPoint, ListenerCallback)
OpalEndPoint::OnConnected
virtual void OnConnected(OpalConnection &connection)
OpalMediaStream
Definition: mediastrm.h:111
OpalEndPoint::AdjustMediaFormats
virtual void AdjustMediaFormats(bool local, const OpalConnection &connection, OpalMediaFormatList &mediaFormats) const
OpalEndPoint::productInfo
OpalProductInfo productInfo
Definition: endpoint.h:812
OpalEndPoint::GetInitialBandwidth
unsigned GetInitialBandwidth() const
Definition: endpoint.h:769
OpalEndPoint::ClearAllCalls
virtual void ClearAllCalls(OpalConnection::CallEndReason reason=OpalConnection::EndedByLocalUser, PBoolean wait=true)
OpalEndPoint::Message
virtual PBoolean Message(const PString &to, const PString &body)
OpalEndPoint::OnOpenMediaStream
virtual PBoolean OnOpenMediaStream(OpalConnection &connection, OpalMediaStream &stream)
OpalConnection
Definition: connection.h:353
OpalEndPoint::GetDefaultSignalPort
WORD GetDefaultSignalPort() const
Definition: endpoint.h:737
OpalEndPoint::GarbageCollection
virtual PBoolean GarbageCollection()
OpalEndPoint::OnSetUpConnection
virtual PBoolean OnSetUpConnection(OpalConnection &connection)
OpalEndPoint::GetProductInfo
const OpalProductInfo & GetProductInfo() const
Definition: endpoint.h:741
OpalTransportAddress
Definition: transports.h:149
OpalEndPoint::GetSendUserInputMode
OpalConnection::SendUserInputModes GetSendUserInputMode() const
Definition: endpoint.h:793
OpalEndPoint::OnMWIReceived
virtual void OnMWIReceived(const PString &party, OpalManager::MessageWaitingType type, const PString &extraInfo)
OpalEndPoint::SetDefaultLocalPartyName
virtual void SetDefaultLocalPartyName(const PString &name)
Definition: endpoint.h:755
OpalEndPoint::GetDefaultTransport
virtual PString GetDefaultTransport() const
OpalEndPoint::GetDefaultDisplayName
const PString & GetDefaultDisplayName() const
Definition: endpoint.h:761
OpalEndPoint::GetDefaultListeners
virtual PStringArray GetDefaultListeners() const
OpalEndPoint::GetPrefixName
const PString & GetPrefixName() const
Definition: endpoint.h:729
OpalEndPoint::GetConnectionWithLock
PSafePtr< OpalConnection > GetConnectionWithLock(const PString &token, PSafetyMode mode=PSafeReadWrite)
Definition: endpoint.h:513
OpalConnection::EndedByLocalUser
Definition: connection.h:362
OpalProductInfo
Definition: connection.h:312
OpalEndPoint::GetListeners
const OpalListenerList & GetListeners() const
Definition: endpoint.h:777
OpalEndPoint::NewIncomingConnection
virtual PBoolean NewIncomingConnection(OpalTransport *transport)