OPAL Version 3.10.2
|
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: 24318 $ 00027 * $Author: rjongbloed $ 00028 * $Date: 2010-05-02 21:15:41 -0500 (Sun, 02 May 2010) $ 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(); 00138 00141 00142 00143 protected: 00144 bool GetFreeLine(unsigned & controller, unsigned & bearer); 00145 PDECLARE_NOTIFIER(PThread, OpalCapiEndPoint, ProcessMessages); 00146 virtual void ProcessMessage(const OpalCapiMessage & message); 00147 void ProcessConnectInd(const OpalCapiMessage & message); 00148 virtual bool PutMessage(OpalCapiMessage & message); 00149 00150 OpalCapiFunctions * m_capi; 00151 PThread * m_thread; 00152 unsigned m_applicationId; 00153 PSyncPoint m_listenCompleted; 00154 00155 struct Controller { 00156 Controller() : m_active(false) { } 00157 00158 bool m_active; 00159 vector<bool> m_bearerInUse; 00160 }; 00161 typedef std::vector<Controller> ControllerVector; 00162 ControllerVector m_controllers; 00163 00164 struct IdToConnMap : public std::map<DWORD, PSafePtr<OpalCapiConnection> > 00165 { 00166 bool Forward(const OpalCapiMessage & message, DWORD id); 00167 }; 00168 00169 IdToConnMap m_cbciToConnection; 00170 IdToConnMap m_plciToConnection; 00171 IdToConnMap m_ncciToConnection; 00172 00173 friend class OpalCapiConnection; 00174 }; 00175 00176 00179 class OpalCapiConnection : public OpalConnection 00180 { 00181 PCLASSINFO(OpalCapiConnection, OpalConnection); 00182 00183 public: 00188 OpalCapiConnection( 00189 OpalCall & call, 00190 OpalCapiEndPoint & endpoint, 00191 unsigned int options, 00192 OpalConnection::StringOptions * stringOptions, 00193 unsigned controller, 00194 unsigned bearer 00195 ); 00197 00208 virtual bool IsNetworkConnection() const; 00209 00216 virtual PBoolean SetUpConnection(); 00217 00228 virtual PBoolean SetAlerting( 00229 const PString & calleeName, 00230 PBoolean withMedia 00231 ); 00232 00237 virtual PBoolean SetConnected(); 00238 00257 virtual void OnReleased(); 00258 00265 virtual PString GetDestinationAddress(); 00266 00273 virtual OpalMediaFormatList GetMediaFormats() const; 00274 00289 virtual OpalMediaStream * CreateMediaStream( 00290 const OpalMediaFormat & mediaFormat, 00291 unsigned sessionID, 00292 PBoolean isSource 00293 ); 00294 00301 virtual PBoolean SendUserInputTone( 00302 char tone, 00303 int duration 00304 ); 00306 00309 00310 00311 protected: 00312 virtual void ProcessMessage(const OpalCapiMessage & message); 00313 virtual bool PutMessage(OpalCapiMessage & message); 00314 00315 OpalCapiEndPoint & m_endpoint; 00316 unsigned m_controller; // 1..127 00317 unsigned m_bearer; 00318 DWORD m_PLCI; 00319 DWORD m_NCCI; 00320 00321 PSyncPoint m_disconnected; 00322 00323 friend class OpalCapiEndPoint; 00324 friend struct OpalCapiEndPoint::IdToConnMap; 00325 friend class OpalCapiMediaStream; 00326 }; 00327 00328 00332 class OpalCapiMediaStream : public OpalMediaStream 00333 { 00334 PCLASSINFO(OpalCapiMediaStream, OpalMediaStream); 00335 public: 00340 OpalCapiMediaStream( 00341 OpalCapiConnection & conn, 00342 const OpalMediaFormat & mediaFormat, 00343 unsigned sessionID, 00344 PBoolean isSource 00345 ); 00347 00348 00355 virtual PBoolean Close(); 00356 00360 virtual PBoolean ReadData( 00361 BYTE * data, 00362 PINDEX size, 00363 PINDEX & length 00364 ); 00365 00369 virtual PBoolean WriteData( 00370 const BYTE * data, 00371 PINDEX length, 00372 PINDEX & written 00373 ); 00374 00378 virtual PBoolean IsSynchronous() const; 00380 00383 00384 00385 protected: 00386 OpalCapiConnection & m_connection; 00387 PQueueChannel m_queue; 00388 PSyncPoint m_written; 00389 PAdaptiveDelay m_delay; 00390 00391 friend class OpalCapiConnection; 00392 }; 00393 00394 00395 #endif // OPAL_CAPI 00396 00397 #endif // OPAL_LIDS_CAPI_EP_H 00398 00399 00400 // End of File ///////////////////////////////////////////////////////////////