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: 27341 $
00027  * $Author: rjongbloed $
00028  * $Date: 2012-03-27 20:12:14 -0500 (Tue, 27 Mar 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 
00052 class OpalCapiEndPoint : public OpalEndPoint
00053 {
00054   PCLASSINFO(OpalCapiEndPoint, OpalEndPoint);
00055 
00056   public:
00061     OpalCapiEndPoint(
00062       OpalManager & manager   
00063     );
00064 
00066     ~OpalCapiEndPoint();
00068 
00100     virtual PSafePtr<OpalConnection> MakeConnection(
00101       OpalCall & call,          
00102       const PString & party,    
00103       void * userData = NULL,   
00104       unsigned int options = 0,  
00105       OpalConnection::StringOptions * stringOptions  = NULL 
00106     );
00107 
00117     virtual OpalMediaFormatList GetMediaFormats() const;
00119 
00122     virtual OpalCapiConnection * CreateConnection(
00123       OpalCall & call,        
00124       void * userData,        
00125       unsigned int options,     
00126       OpalConnection::StringOptions * stringOptions, 
00127       unsigned controller,
00128       unsigned bearer
00129     );
00131 
00136     unsigned OpenControllers();
00137 
00141     PString GetDriverInfo() const;
00143 
00146 
00147 
00148   protected:
00149     bool GetFreeLine(unsigned & controller, unsigned & bearer);
00150     PDECLARE_NOTIFIER(PThread, OpalCapiEndPoint, ProcessMessages);
00151     virtual void ProcessMessage(const OpalCapiMessage & message);
00152     void ProcessConnectInd(const OpalCapiMessage & message);
00153     virtual bool PutMessage(OpalCapiMessage & message);
00154 
00155     OpalCapiFunctions * m_capi;
00156     PThread           * m_thread;
00157     unsigned            m_applicationId;
00158     PSyncPoint          m_listenCompleted;
00159 
00160     struct Controller {
00161       Controller() : m_active(false) { }
00162 
00163       bool         m_active;
00164       vector<bool> m_bearerInUse;
00165     };
00166     typedef std::vector<Controller> ControllerVector;
00167     ControllerVector m_controllers;
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     );
00311 
00314 
00315 
00316   protected:
00317     virtual void ProcessMessage(const OpalCapiMessage & message);
00318     virtual bool PutMessage(OpalCapiMessage & message);
00319 
00320     OpalCapiEndPoint & m_endpoint;
00321     unsigned           m_controller; // 1..127
00322     unsigned           m_bearer;
00323     DWORD              m_PLCI;
00324     DWORD              m_NCCI;
00325 
00326     PSyncPoint m_disconnected;
00327 
00328   friend class OpalCapiEndPoint;
00329   friend struct OpalCapiEndPoint::IdToConnMap;
00330   friend class OpalCapiMediaStream;
00331 };
00332 
00333 
00337 class OpalCapiMediaStream : public OpalMediaStream
00338 {
00339     PCLASSINFO(OpalCapiMediaStream, OpalMediaStream);
00340   public:
00345     OpalCapiMediaStream(
00346       OpalCapiConnection & conn,            
00347       const OpalMediaFormat & mediaFormat,  
00348       unsigned sessionID,                   
00349       PBoolean isSource                     
00350     );
00352 
00353 
00359     virtual PBoolean ReadData(
00360       BYTE * data,      
00361       PINDEX size,      
00362       PINDEX & length   
00363     );
00364 
00368     virtual PBoolean WriteData(
00369       const BYTE * data,   
00370       PINDEX length,       
00371       PINDEX & written     
00372     );
00373 
00377     virtual PBoolean IsSynchronous() const;
00379 
00382 
00383 
00384   protected:
00385     virtual void InternalClose();
00386 
00387     OpalCapiConnection & m_connection;
00388     PQueueChannel        m_queue;
00389     PSyncPoint           m_written;
00390     PAdaptiveDelay       m_delay;
00391 
00392   friend class OpalCapiConnection;
00393 };
00394 
00395 
00396 #endif // OPAL_CAPI
00397 
00398 #endif // OPAL_LIDS_CAPI_EP_H
00399 
00400 
00401 // End of File ///////////////////////////////////////////////////////////////

Generated on 14 Aug 2013 for OPAL by  doxygen 1.4.7