# capi_ep.h

Go to the documentation of this file.

    00001 /*
    00002  * capi_ep.h
    00003  *
    00004  * ISDN via CAPI EndPoint
    00005  *
    00006  * Open Phone Abstraction Library
    00007  *
    00008  * Copyright (c) 2010 Vox Lucida Pty. Ltd.
    00009  *
    00010  * The contents of this file are subject to the Mozilla Public License
    00011  * Version 1.0 (the "License"); you may not use this file except in
    00012  * compliance with the License. You may obtain a copy of the License at
    00013  * http://www.mozilla.org/MPL/
    00014  *
    00015  * Software distributed under the License is distributed on an "AS IS"
    00016  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
    00017  * the License for the specific language governing rights and limitations
    00018  * under the License.
    00019  *
    00020  * The Original Code is Open H323 Library.
    00021  *
    00022  * The Initial Developer of the Original Code is Vox Lucida Pty. Ltd.
    00023  *
    00024  * Contributor(s): ______________________________________.
    00025  *
    00026  * $Revision: 27643 $
    00027  * $Author: rjongbloed $
    00028  * $Date: 2012-05-16 20:07:54 -0500 (Wed, 16 May 2012) $
    00029  */
    00030
    00031 #ifndef OPAL_LIDS_CAPI_EP_H
    00032 #define OPAL_LIDS_CAPI_EP_H
    00033
    00034 #ifdef P_USE_PRAGMA
    00035 #pragma interface
    00036 #endif
    00037
    00038 #include <opal/buildopts.h>
    00039
    00040 #if OPAL_CAPI
    00041
    00042 #include <opal/endpoint.h>
    00043
    00044
    00045 class OpalCapiFunctions;
    00046 class OpalCapiConnection;
    00047 struct OpalCapiMessage;
    00048
    00049
    00050 #define OPAL_OPT_CAPI_B_PROTO  "B-Proto"
    00051
    00052
    00055 class OpalCapiEndPoint : public OpalEndPoint
    00056 {
    00057   PCLASSINFO(OpalCapiEndPoint, OpalEndPoint);
    00058
    00059   public:
    00064     OpalCapiEndPoint(
    00065       OpalManager & manager
    00066     );
    00067
    00069     ~OpalCapiEndPoint();
    00071
    00097     virtual PSafePtr<OpalConnection> MakeConnection(
    00098       OpalCall & call,
    00099       const PString & party,
    00100       void * userData = NULL,
    00101       unsigned int options = 0,
    00102       OpalConnection::StringOptions * stringOptions  = NULL
    00103     );
    00104
    00114     virtual OpalMediaFormatList GetMediaFormats() const;
    00116
    00119     virtual OpalCapiConnection * CreateConnection(
    00120       OpalCall & call,
    00121       void * userData,
    00122       unsigned int options,
    00123       OpalConnection::StringOptions * stringOptions,
    00124       unsigned controller,
    00125       unsigned bearer
    00126     );
    00128
    00133     unsigned OpenControllers();
    00134
    00138     PString GetDriverInfo() const;
    00140
    00143
    00144
    00145   protected:
    00146     bool GetFreeLine(unsigned & controller, unsigned & bearer);
    00147     PDECLARE_NOTIFIER(PThread, OpalCapiEndPoint, ProcessMessages);
    00148     virtual void ProcessMessage(const OpalCapiMessage & message);
    00149     void ProcessConnectInd(const OpalCapiMessage & message);
    00150     virtual bool PutMessage(OpalCapiMessage & message);
    00151
    00152     OpalCapiFunctions * m_capi;
    00153     PThread           * m_thread;
    00154     unsigned            m_applicationId;
    00155     PSyncPoint          m_listenCompleted;
    00156
    00157     struct Controller {
    00158       Controller() : m_active(false) { }
    00159
    00160       bool GetFreeLine(unsigned & bearer);
    00161
    00162       bool         m_active;
    00163       vector<bool> m_bearerInUse;
    00164     };
    00165     typedef std::vector<Controller> ControllerVector;
    00166     ControllerVector m_controllers;
    00167     PMutex           m_controllerMutex;
    00168
    00169     struct IdToConnMap : public std::map<DWORD, PSafePtr<OpalCapiConnection> >
    00170     {
    00171       bool Forward(const OpalCapiMessage & message, DWORD id);
    00172       PMutex m_mutex;
    00173     };
    00174
    00175     IdToConnMap m_cbciToConnection;
    00176     IdToConnMap m_plciToConnection;
    00177
    00178   friend class OpalCapiConnection;
    00179 };
    00180
    00181
    00184 class OpalCapiConnection : public OpalConnection
    00185 {
    00186   PCLASSINFO(OpalCapiConnection, OpalConnection);
    00187
    00188   public:
    00193     OpalCapiConnection(
    00194       OpalCall & call,
    00195       OpalCapiEndPoint & endpoint,
    00196       unsigned int options,
    00197       OpalConnection::StringOptions * stringOptions,
    00198       unsigned controller,
    00199       unsigned bearer
    00200     );
    00202
    00213     virtual bool IsNetworkConnection() const;
    00214
    00221     virtual PBoolean SetUpConnection();
    00222
    00233     virtual PBoolean SetAlerting(
    00234       const PString & calleeName,
    00235       PBoolean withMedia
    00236     );
    00237
    00242     virtual PBoolean SetConnected();
    00243
    00262     virtual void OnReleased();
    00263
    00270     virtual PString GetDestinationAddress();
    00271
    00278     virtual OpalMediaFormatList GetMediaFormats() const;
    00279
    00294     virtual OpalMediaStream * CreateMediaStream(
    00295       const OpalMediaFormat & mediaFormat,
    00296       unsigned sessionID,
    00297       PBoolean isSource
    00298     );
    00299
    00306     virtual PBoolean SendUserInputTone(
    00307       char tone,
    00308       int duration
    00309     );
    00310
    00312     virtual void OnApplyStringOptions();
    00314
    00317
    00318
    00319   protected:
    00320     virtual void ProcessMessage(const OpalCapiMessage & message);
    00321     virtual bool PutMessage(OpalCapiMessage & message);
    00322
    00323     OpalCapiEndPoint & m_endpoint;
    00324     unsigned           m_controller; // 1..127
    00325     unsigned           m_bearer;
    00326     DWORD              m_PLCI;
    00327     DWORD              m_NCCI;
    00328
    00329     PSyncPoint m_disconnected;
    00330
    00331     PBYTEArray m_Bprotocol;
    00332
    00333   friend class OpalCapiEndPoint;
    00334   friend struct OpalCapiEndPoint::IdToConnMap;
    00335   friend class OpalCapiMediaStream;
    00336 };
    00337
    00338
    00342 class OpalCapiMediaStream : public OpalMediaStream
    00343 {
    00344     PCLASSINFO(OpalCapiMediaStream, OpalMediaStream);
    00345   public:
    00350     OpalCapiMediaStream(
    00351       OpalCapiConnection & conn,
    00352       const OpalMediaFormat & mediaFormat,
    00353       unsigned sessionID,
    00354       PBoolean isSource
    00355     );
    00357
    00358
    00364     virtual PBoolean ReadData(
    00365       BYTE * data,
    00366       PINDEX size,
    00367       PINDEX & length
    00368     );
    00369
    00373     virtual PBoolean WriteData(
    00374       const BYTE * data,
    00375       PINDEX length,
    00376       PINDEX & written
    00377     );
    00378
    00382     virtual PBoolean IsSynchronous() const;
    00384
    00387
    00388
    00389   protected:
    00390     virtual void InternalClose();
    00391
    00392     OpalCapiConnection & m_connection;
    00393     PQueueChannel        m_queue;
    00394     PSyncPoint           m_written;
    00395     PAdaptiveDelay       m_delay;
    00396
    00397   friend class OpalCapiConnection;
    00398 };
    00399
    00400
    00401 #endif // OPAL_CAPI
    00402
    00403 #endif // OPAL_LIDS_CAPI_EP_H
    00404
    00405
    00406 // End of File ///////////////////////////////////////////////////////////////