iax2ep.h
Go to the documentation of this file.
/*
*
* Inter Asterisk Exchange 2
*
* Open Phone Abstraction Library (OPAL)
*
* Describes the IAX2 extension of the OpalEndpoint class.
*
* Copyright (c) 2005 Indranet Technologies 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 Indranet Technologies Ltd.
*
* The author of this code is Derek J Smithies
*
* $Revision: 24719 $
* $Author: rjongbloed $
* $Date: 2010-09-23 18:55:55 -0500 (Thu, 23 Sep 2010) $
*/
#ifndef OPAL_IAX2_IAX2EP_H
#define OPAL_IAX2_IAX2EP_H
#ifndef _PTLIB_H
#include <ptlib.h>
#endif
#ifdef P_USE_PRAGMA
#pragma interface
#endif
#include <opal/buildopts.h>
#if OPAL_IAX2
#include <opal/endpoint.h>
#include <iax2/iax2con.h>
#include <iax2/processor.h>
#include <iax2/regprocessor.h>
#include <iax2/specialprocessor.h>
class IAX2Receiver;
class IAX2Transmit;
class IAX2Processor;
class IAX2IncomingEthernetFrames : public PThread
{
PCLASSINFO(IAX2IncomingEthernetFrames, PThread);
public:
IAX2IncomingEthernetFrames();
~IAX2IncomingEthernetFrames() { }
/*The method which gets everythig to happen */
virtual void Main();
void Assign(IAX2EndPoint *ep);
void ProcessList() { activate.Signal(); }
void Terminate();
protected:
IAX2EndPoint *endpoint;
PSyncPoint activate;
PBoolean keepGoing;
};
class IAX2EndPoint : public OpalEndPoint
{
PCLASSINFO(IAX2EndPoint, OpalEndPoint);
public:
IAX2EndPoint(
OpalManager & manager,
unsigned short port = 4569
);
~IAX2EndPoint();
virtual PBoolean NewIncomingConnection(
OpalTransport * transport
);
virtual PSafePtr<OpalConnection> MakeConnection(
OpalCall & call,
const PString & party,
void * userData = NULL,
unsigned int options = 0,
OpalConnection::StringOptions * stringOptions = NULL
);
virtual IAX2Connection * CreateConnection(
OpalCall & call,
const PString & token,
void * userData,
const PString & remoteParty,
const PString & remotePartyName = PString::Empty()
);
PBoolean Initialise();
virtual void IncomingEthernetFrame (IAX2Frame *frame);
PBoolean ConectionForFrameIsAlive(IAX2Frame *f);
PINDEX NextSrcCallNumber(IAX2Processor * processor);
void ReportStoredConnections();
WORD ListenPortNumber() { return 4569; }
IAX2Transmit *transmitter;
IAX2Receiver *receiver;
PString GetLocalUserName() { return localUserName; }
PString GetLocalNumber() { return localNumber; }
void SetLocalUserName(PString newValue);
void SetLocalNumber(PString newValue);
PString & GetPassword() { return password; }
void SetPassword(PString newValue);
PBoolean ConnectionForFrameIsAlive(IAX2Frame *f);
PINDEX GetOutSequenceNumberForStatusQuery();
void StartRinging(PString remoteCaller);
void NewIncomingConnection(
IAX2Frame *f
);
void OnEstablished(
OpalConnection & con
);
virtual void OnReleased(
OpalConnection & connection
);
virtual OpalMediaFormatList GetMediaFormats() const;
PINDEX GetSupportedCodecs(OpalMediaFormatList & list);
PINDEX GetPreferredCodec(OpalMediaFormatList & list);
void GetCodecLengths(PINDEX src, PINDEX &compressedBytes, PINDEX &duration);
enum IAX2RemoteAddressFields {
protoIndex = 0,
userIndex = 1,
transportIndex = 2,
addressIndex = 3,
portIndex = 4,
extensionIndex = 5,
contextIndex = 6,
maximumIndex = 7
};
static PStringArray DissectRemoteParty(const PString & other);
void ProcessReceivedEthernetFrames();
void ReportTransmitterLists(PString & answer, bool getFullReport = false);
void CopyLocalMediaFormats(OpalMediaFormatList & list);
void Register(
const PString & host,
const PString & username,
const PString & password = PString::Empty(),
PINDEX requestedRefreshTime = 60
);
enum RegisteredError {
RegisteredFailureUnknown
};
virtual void OnRegistered(
const PString & host,
const PString & userName,
PBoolean isFailure,
RegisteredError reason = RegisteredFailureUnknown);
void Unregister(
const PString & host,
const PString & username);
enum UnregisteredError {
UnregisteredFailureUnknown
};
virtual void OnUnregistered(
const PString & host,
const PString & userName,
PBoolean isFailure,
UnregisteredError reason = UnregisteredFailureUnknown);
PBoolean IsRegistered(const PString & host, const PString & username);
PINDEX GetRegistrationsCount();
PString BuildUrl(
const PString & host,
const PString & userName = PString::Empty(),
const PString & extension = PString::Empty(),
const PString & context = PString::Empty(),
const PString & transport = PString::Empty()
);
PBoolean InitialisedOK() { return (transmitter != NULL) && (receiver != NULL); }
PBoolean EthernetFramesToBeProcessed()
{ return packetsReadFromEthernet.GetSize() > 0; }
protected:
IAX2IncomingEthernetFrames incomingFrameHandler;
IAX2FrameList packetsReadFromEthernet;
PUDPSocket *sock;
unsigned short localPort;
int callnumbs;
PMutex callNumbLock;
PTime callStartTime;
PString localUserName;
PString localNumber;
PString password;
PINDEX statusQueryCounter;
PMutex statusQueryMutex;
IAX2SpecialProcessor * specialPacketHandler;
PBoolean ProcessInMatchingConnection(IAX2Frame *f);
PBoolean ProcessFrameInConnection(IAX2Frame *f, const PString & token);
PBoolean ProcessInConnectionTestAll(IAX2Frame *f);
PStringToString tokenTable;
PReadWriteMutex mutexTokenTable;
PAtomicInteger callsEstablished;
OpalMediaFormatList localMediaFormats;
PMutex regProcessorsMutex;
PArrayObjects regProcessors;
};
#endif // OPAL_IAX2
#endif // OPAL_IAX2_IAX2EP_H
/* The comment below is magic for those who use emacs to edit this file.
* With the comment below, the tab key does auto indent to 2 spaces.
*
* Local Variables:
* mode:c
* c-basic-offset:2
* End:
*/
IAX2EndPoint::IAX2RemoteAddressFields
IAX2RemoteAddressFields
Definition: iax2ep.h:308
IAX2EndPoint::localMediaFormats
OpalMediaFormatList localMediaFormats
Definition: iax2ep.h:506
IAX2EndPoint::GetMediaFormats
virtual OpalMediaFormatList GetMediaFormats() const
OpalManager
Definition: manager.h:74
IAX2IncomingEthernetFrames::keepGoing
PBoolean keepGoing
Definition: iax2ep.h:97
OpalEndPoint
Definition: endpoint.h:67
IAX2EndPoint::GetPreferredCodec
PINDEX GetPreferredCodec(OpalMediaFormatList &list)
IAX2EndPoint::SetLocalUserName
void SetLocalUserName(PString newValue)
IAX2EndPoint::callNumbLock
PMutex callNumbLock
Definition: iax2ep.h:431
IAX2EndPoint::OnUnregistered
virtual void OnUnregistered(const PString &host, const PString &userName, PBoolean isFailure, UnregisteredError reason=UnregisteredFailureUnknown)
IAX2IncomingEthernetFrames::Assign
void Assign(IAX2EndPoint *ep)
IAX2FrameList
Definition: frame.h:1168
IAX2EndPoint::password
PString password
Definition: iax2ep.h:443
IAX2EndPoint::Unregister
void Unregister(const PString &host, const PString &username)
IAX2EndPoint::localUserName
PString localUserName
Definition: iax2ep.h:437
IAX2IncomingEthernetFrames::Terminate
void Terminate()
IAX2EndPoint::portIndex
Definition: iax2ep.h:313
IAX2EndPoint
Definition: iax2ep.h:104
IAX2EndPoint::OnRegistered
virtual void OnRegistered(const PString &host, const PString &userName, PBoolean isFailure, RegisteredError reason=RegisteredFailureUnknown)
buildopts.h
IAX2EndPoint::tokenTable
PStringToString tokenTable
Definition: iax2ep.h:494
IAX2EndPoint::CreateConnection
virtual IAX2Connection * CreateConnection(OpalCall &call, const PString &token, void *userData, const PString &remoteParty, const PString &remotePartyName=PString::Empty())
IAX2EndPoint::Register
void Register(const PString &host, const PString &username, const PString &password=PString::Empty(), PINDEX requestedRefreshTime=60)
OpalTransport
Definition: transports.h:703
IAX2Connection
Definition: iax2con.h:63
IAX2EndPoint::IsRegistered
PBoolean IsRegistered(const PString &host, const PString &username)
IAX2Transmit
Definition: transmit.h:63
IAX2EndPoint::ReportStoredConnections
void ReportStoredConnections()
IAX2EndPoint::localNumber
PString localNumber
Definition: iax2ep.h:440
IAX2EndPoint::regProcessors
PArrayObjects regProcessors
Definition: iax2ep.h:515
IAX2EndPoint::InitialisedOK
PBoolean InitialisedOK()
Definition: iax2ep.h:400
IAX2SpecialProcessor
Definition: specialprocessor.h:56
IAX2EndPoint::ProcessInMatchingConnection
PBoolean ProcessInMatchingConnection(IAX2Frame *f)
IAX2EndPoint::RegisteredFailureUnknown
Definition: iax2ep.h:352
IAX2EndPoint::ListenPortNumber
WORD ListenPortNumber()
Definition: iax2ep.h:209
IAX2EndPoint::extensionIndex
Definition: iax2ep.h:314
IAX2EndPoint::ProcessReceivedEthernetFrames
void ProcessReceivedEthernetFrames()
IAX2EndPoint::EthernetFramesToBeProcessed
PBoolean EthernetFramesToBeProcessed()
Definition: iax2ep.h:404
IAX2EndPoint::IncomingEthernetFrame
virtual void IncomingEthernetFrame(IAX2Frame *frame)
IAX2EndPoint::SetPassword
void SetPassword(PString newValue)
IAX2EndPoint::DissectRemoteParty
static PStringArray DissectRemoteParty(const PString &other)
IAX2EndPoint::SetLocalNumber
void SetLocalNumber(PString newValue)
IAX2EndPoint::GetLocalUserName
PString GetLocalUserName()
Definition: iax2ep.h:218
IAX2EndPoint::ConectionForFrameIsAlive
PBoolean ConectionForFrameIsAlive(IAX2Frame *f)
IAX2EndPoint::OnEstablished
void OnEstablished(OpalConnection &con)
iax2con.h
IAX2EndPoint::transmitter
IAX2Transmit * transmitter
Definition: iax2ep.h:212
OpalMediaFormatList
Definition: mediafmt.h:72
IAX2EndPoint::UnregisteredFailureUnknown
Definition: iax2ep.h:370
IAX2EndPoint::ProcessInConnectionTestAll
PBoolean ProcessInConnectionTestAll(IAX2Frame *f)
IAX2EndPoint::NewIncomingConnection
virtual PBoolean NewIncomingConnection(OpalTransport *transport)
OpalConnection::StringOptions
Definition: connection.h:462
IAX2EndPoint::callsEstablished
PAtomicInteger callsEstablished
Definition: iax2ep.h:503
IAX2IncomingEthernetFrames::ProcessList
void ProcessList()
Definition: iax2ep.h:83
IAX2IncomingEthernetFrames::activate
PSyncPoint activate
Definition: iax2ep.h:94
IAX2EndPoint::NextSrcCallNumber
PINDEX NextSrcCallNumber(IAX2Processor *processor)
IAX2EndPoint::RegisteredError
RegisteredError
Definition: iax2ep.h:351
IAX2IncomingEthernetFrames
Definition: iax2ep.h:60
IAX2EndPoint::mutexTokenTable
PReadWriteMutex mutexTokenTable
Definition: iax2ep.h:499
specialprocessor.h
IAX2EndPoint::statusQueryMutex
PMutex statusQueryMutex
Definition: iax2ep.h:449
IAX2EndPoint::maximumIndex
Definition: iax2ep.h:316
OpalCall
Definition: call.h:65
IAX2EndPoint::ProcessFrameInConnection
PBoolean ProcessFrameInConnection(IAX2Frame *f, const PString &token)
regprocessor.h
IAX2IncomingEthernetFrames::~IAX2IncomingEthernetFrames
~IAX2IncomingEthernetFrames()
Definition: iax2ep.h:71
IAX2EndPoint::packetsReadFromEthernet
IAX2FrameList packetsReadFromEthernet
Definition: iax2ep.h:419
IAX2EndPoint::GetCodecLengths
void GetCodecLengths(PINDEX src, PINDEX &compressedBytes, PINDEX &duration)
IAX2EndPoint::protoIndex
Definition: iax2ep.h:309
IAX2EndPoint::regProcessorsMutex
PMutex regProcessorsMutex
Definition: iax2ep.h:509
IAX2EndPoint::GetSupportedCodecs
PINDEX GetSupportedCodecs(OpalMediaFormatList &list)
IAX2EndPoint::addressIndex
Definition: iax2ep.h:312
processor.h
IAX2IncomingEthernetFrames::IAX2IncomingEthernetFrames
IAX2IncomingEthernetFrames()
OpalEndPoint::manager
OpalManager & manager
Definition: endpoint.h:807
IAX2EndPoint::OnReleased
virtual void OnReleased(OpalConnection &connection)
IAX2Processor
Definition: processor.h:136
IAX2IncomingEthernetFrames::endpoint
IAX2EndPoint * endpoint
Definition: iax2ep.h:91
IAX2EndPoint::ReportTransmitterLists
void ReportTransmitterLists(PString &answer, bool getFullReport=false)
IAX2EndPoint::IAX2EndPoint
IAX2EndPoint(OpalManager &manager, unsigned short port=4569)
IAX2EndPoint::specialPacketHandler
IAX2SpecialProcessor * specialPacketHandler
Definition: iax2ep.h:453
IAX2EndPoint::transportIndex
Definition: iax2ep.h:311
IAX2EndPoint::callnumbs
int callnumbs
Definition: iax2ep.h:428
IAX2IncomingEthernetFrames::Main
virtual void Main()
IAX2EndPoint::BuildUrl
PString BuildUrl(const PString &host, const PString &userName=PString::Empty(), const PString &extension=PString::Empty(), const PString &context=PString::Empty(), const PString &transport=PString::Empty())
IAX2EndPoint::contextIndex
Definition: iax2ep.h:315
OpalConnection
Definition: connection.h:353
IAX2EndPoint::GetPassword
PString & GetPassword()
Definition: iax2ep.h:230
IAX2EndPoint::localPort
unsigned short localPort
Definition: iax2ep.h:425
IAX2EndPoint::CopyLocalMediaFormats
void CopyLocalMediaFormats(OpalMediaFormatList &list)
endpoint.h
IAX2EndPoint::StartRinging
void StartRinging(PString remoteCaller)
IAX2EndPoint::GetLocalNumber
PString GetLocalNumber()
Definition: iax2ep.h:221
IAX2EndPoint::GetRegistrationsCount
PINDEX GetRegistrationsCount()
IAX2Frame
Definition: frame.h:75
IAX2EndPoint::statusQueryCounter
PINDEX statusQueryCounter
Definition: iax2ep.h:446
IAX2EndPoint::Initialise
PBoolean Initialise()
IAX2EndPoint::callStartTime
PTime callStartTime
Definition: iax2ep.h:434
IAX2EndPoint::receiver
IAX2Receiver * receiver
Definition: iax2ep.h:215
IAX2EndPoint::incomingFrameHandler
IAX2IncomingEthernetFrames incomingFrameHandler
Definition: iax2ep.h:415
IAX2EndPoint::ConnectionForFrameIsAlive
PBoolean ConnectionForFrameIsAlive(IAX2Frame *f)
IAX2Receiver
Definition: receiver.h:60
IAX2EndPoint::GetOutSequenceNumberForStatusQuery
PINDEX GetOutSequenceNumberForStatusQuery()
IAX2EndPoint::MakeConnection
virtual PSafePtr< OpalConnection > MakeConnection(OpalCall &call, const PString &party, void *userData=NULL, unsigned int options=0, OpalConnection::StringOptions *stringOptions=NULL)
IAX2EndPoint::userIndex
Definition: iax2ep.h:310
IAX2EndPoint::~IAX2EndPoint
~IAX2EndPoint()
IAX2FrameList::GetSize
virtual PINDEX GetSize()
Definition: frame.h:1205
IAX2EndPoint::sock
PUDPSocket * sock
Definition: iax2ep.h:422
IAX2EndPoint::UnregisteredError
UnregisteredError
Definition: iax2ep.h:369