capi_ep.h
Go to the documentation of this file.
/*
* capi_ep.h
*
* ISDN via CAPI EndPoint
*
* Open Phone Abstraction Library
*
* Copyright (c) 2010 Vox Lucida 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 H323 Library.
*
* The Initial Developer of the Original Code is Vox Lucida Pty. Ltd.
*
* Contributor(s): ______________________________________.
*
* $Revision: 27341 $
* $Author: rjongbloed $
* $Date: 2012-03-27 20:12:14 -0500 (Tue, 27 Mar 2012) $
*/
#ifndef OPAL_LIDS_CAPI_EP_H
#define OPAL_LIDS_CAPI_EP_H
#ifdef P_USE_PRAGMA
#pragma interface
#endif
#include <opal/buildopts.h>
#if OPAL_CAPI
#include <opal/endpoint.h>
class OpalCapiFunctions;
class OpalCapiConnection;
struct OpalCapiMessage;
class OpalCapiEndPoint : public OpalEndPoint
{
PCLASSINFO(OpalCapiEndPoint, OpalEndPoint);
public:
OpalCapiEndPoint(
OpalManager & manager
);
~OpalCapiEndPoint();
virtual PSafePtr<OpalConnection> MakeConnection(
OpalCall & call,
const PString & party,
void * userData = NULL,
unsigned int options = 0,
OpalConnection::StringOptions * stringOptions = NULL
);
virtual OpalMediaFormatList GetMediaFormats() const;
virtual OpalCapiConnection * CreateConnection(
OpalCall & call,
void * userData,
unsigned int options,
OpalConnection::StringOptions * stringOptions,
unsigned controller,
unsigned bearer
);
unsigned OpenControllers();
PString GetDriverInfo() const;
protected:
bool GetFreeLine(unsigned & controller, unsigned & bearer);
PDECLARE_NOTIFIER(PThread, OpalCapiEndPoint, ProcessMessages);
virtual void ProcessMessage(const OpalCapiMessage & message);
void ProcessConnectInd(const OpalCapiMessage & message);
virtual bool PutMessage(OpalCapiMessage & message);
OpalCapiFunctions * m_capi;
PThread * m_thread;
unsigned m_applicationId;
PSyncPoint m_listenCompleted;
struct Controller {
Controller() : m_active(false) { }
bool m_active;
vector<bool> m_bearerInUse;
};
typedef std::vector<Controller> ControllerVector;
ControllerVector m_controllers;
struct IdToConnMap : public std::map<DWORD, PSafePtr<OpalCapiConnection> >
{
bool Forward(const OpalCapiMessage & message, DWORD id);
PMutex m_mutex;
};
IdToConnMap m_cbciToConnection;
IdToConnMap m_plciToConnection;
friend class OpalCapiConnection;
};
class OpalCapiConnection : public OpalConnection
{
PCLASSINFO(OpalCapiConnection, OpalConnection);
public:
OpalCapiConnection(
OpalCall & call,
OpalCapiEndPoint & endpoint,
unsigned int options,
OpalConnection::StringOptions * stringOptions,
unsigned controller,
unsigned bearer
);
virtual bool IsNetworkConnection() const;
virtual PBoolean SetUpConnection();
virtual PBoolean SetAlerting(
const PString & calleeName,
PBoolean withMedia
);
virtual PBoolean SetConnected();
virtual void OnReleased();
virtual PString GetDestinationAddress();
virtual OpalMediaFormatList GetMediaFormats() const;
virtual OpalMediaStream * CreateMediaStream(
const OpalMediaFormat & mediaFormat,
unsigned sessionID,
PBoolean isSource
);
virtual PBoolean SendUserInputTone(
char tone,
int duration
);
protected:
virtual void ProcessMessage(const OpalCapiMessage & message);
virtual bool PutMessage(OpalCapiMessage & message);
OpalCapiEndPoint & m_endpoint;
unsigned m_controller; // 1..127
unsigned m_bearer;
DWORD m_PLCI;
DWORD m_NCCI;
PSyncPoint m_disconnected;
friend class OpalCapiEndPoint;
friend struct OpalCapiEndPoint::IdToConnMap;
friend class OpalCapiMediaStream;
};
class OpalCapiMediaStream : public OpalMediaStream
{
PCLASSINFO(OpalCapiMediaStream, OpalMediaStream);
public:
OpalCapiMediaStream(
OpalCapiConnection & conn,
const OpalMediaFormat & mediaFormat,
unsigned sessionID,
PBoolean isSource
);
virtual PBoolean ReadData(
BYTE * data,
PINDEX size,
PINDEX & length
);
virtual PBoolean WriteData(
const BYTE * data,
PINDEX length,
PINDEX & written
);
virtual PBoolean IsSynchronous() const;
protected:
virtual void InternalClose();
OpalCapiConnection & m_connection;
PQueueChannel m_queue;
PSyncPoint m_written;
PAdaptiveDelay m_delay;
friend class OpalCapiConnection;
};
#endif // OPAL_CAPI
#endif // OPAL_LIDS_CAPI_EP_H
// End of File ///////////////////////////////////////////////////////////////
OpalConnection::OnReleased
virtual void OnReleased()
OpalEndPoint::GetMediaFormats
virtual OpalMediaFormatList GetMediaFormats() const =0
OpalManager
Definition: manager.h:74
OpalMediaStream::IsSynchronous
virtual PBoolean IsSynchronous() const =0
OpalEndPoint
Definition: endpoint.h:67
OpalConnection::CreateMediaStream
virtual OpalMediaStream * CreateMediaStream(const OpalMediaFormat &mediaFormat, unsigned sessionID, PBoolean isSource)
buildopts.h
OpalConnection::SendUserInputTone
virtual PBoolean SendUserInputTone(char tone, unsigned duration=0)
OpalMediaStream::ReadData
virtual PBoolean ReadData(BYTE *data, PINDEX size, PINDEX &length)
OpalConnection::SetConnected
virtual PBoolean SetConnected()
OpalEndPoint::MakeConnection
virtual PSafePtr< OpalConnection > MakeConnection(OpalCall &call, const PString &party, void *userData=NULL, unsigned int options=0, OpalConnection::StringOptions *stringOptions=NULL)=0
OpalMediaFormatList
Definition: mediafmt.h:72
OpalConnection::StringOptions
Definition: connection.h:462
OpalConnection::SetUpConnection
virtual PBoolean SetUpConnection()=0
OpalMediaFormat
Definition: mediafmt.h:724
OpalCall
Definition: call.h:65
OpalMediaStream::InternalClose
virtual void InternalClose()=0
OpalMediaStream::WriteData
virtual PBoolean WriteData(const BYTE *data, PINDEX length, PINDEX &written)
OpalConnection::GetDestinationAddress
virtual PString GetDestinationAddress()
OpalEndPoint::PDECLARE_NOTIFIER
PDECLARE_NOTIFIER(PThread, OpalEndPoint, ListenerCallback)
OpalConnection::IsNetworkConnection
virtual bool IsNetworkConnection() const =0
OpalMediaStream
Definition: mediastrm.h:111
OpalConnection
Definition: connection.h:353
endpoint.h
OpalConnection::GetMediaFormats
virtual OpalMediaFormatList GetMediaFormats() const
OpalConnection::SetAlerting
virtual PBoolean SetAlerting(const PString &calleeName, PBoolean withMedia)=0