OPAL  Version 3.10.10
capi_ep.h
Go to the documentation of this file.
1 /*
2  * capi_ep.h
3  *
4  * ISDN via CAPI EndPoint
5  *
6  * Open Phone Abstraction Library
7  *
8  * Copyright (c) 2010 Vox Lucida Pty. Ltd.
9  *
10  * The contents of this file are subject to the Mozilla Public License
11  * Version 1.0 (the "License"); you may not use this file except in
12  * compliance with the License. You may obtain a copy of the License at
13  * http://www.mozilla.org/MPL/
14  *
15  * Software distributed under the License is distributed on an "AS IS"
16  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17  * the License for the specific language governing rights and limitations
18  * under the License.
19  *
20  * The Original Code is Open H323 Library.
21  *
22  * The Initial Developer of the Original Code is Vox Lucida Pty. Ltd.
23  *
24  * Contributor(s): ______________________________________.
25  *
26  * $Revision: 27341 $
27  * $Author: rjongbloed $
28  * $Date: 2012-03-27 20:12:14 -0500 (Tue, 27 Mar 2012) $
29  */
30 
31 #ifndef OPAL_LIDS_CAPI_EP_H
32 #define OPAL_LIDS_CAPI_EP_H
33 
34 #ifdef P_USE_PRAGMA
35 #pragma interface
36 #endif
37 
38 #include <opal/buildopts.h>
39 
40 #if OPAL_CAPI
41 
42 #include <opal/endpoint.h>
43 
44 
45 class OpalCapiFunctions;
46 class OpalCapiConnection;
47 struct OpalCapiMessage;
48 
49 
52 class OpalCapiEndPoint : public OpalEndPoint
53 {
54  PCLASSINFO(OpalCapiEndPoint, OpalEndPoint);
55 
56  public:
61  OpalCapiEndPoint(
62  OpalManager & manager
63  );
64 
66  ~OpalCapiEndPoint();
68 
100  virtual PSafePtr<OpalConnection> MakeConnection(
101  OpalCall & call,
102  const PString & party,
103  void * userData = NULL,
104  unsigned int options = 0,
105  OpalConnection::StringOptions * stringOptions = NULL
106  );
107 
117  virtual OpalMediaFormatList GetMediaFormats() const;
119 
122  virtual OpalCapiConnection * CreateConnection(
123  OpalCall & call,
124  void * userData,
125  unsigned int options,
126  OpalConnection::StringOptions * stringOptions,
127  unsigned controller,
128  unsigned bearer
129  );
131 
136  unsigned OpenControllers();
137 
141  PString GetDriverInfo() const;
143 
146 
147 
148  protected:
149  bool GetFreeLine(unsigned & controller, unsigned & bearer);
150  PDECLARE_NOTIFIER(PThread, OpalCapiEndPoint, ProcessMessages);
151  virtual void ProcessMessage(const OpalCapiMessage & message);
152  void ProcessConnectInd(const OpalCapiMessage & message);
153  virtual bool PutMessage(OpalCapiMessage & message);
154 
155  OpalCapiFunctions * m_capi;
156  PThread * m_thread;
157  unsigned m_applicationId;
158  PSyncPoint m_listenCompleted;
159 
160  struct Controller {
161  Controller() : m_active(false) { }
162 
163  bool m_active;
164  vector<bool> m_bearerInUse;
165  };
166  typedef std::vector<Controller> ControllerVector;
167  ControllerVector m_controllers;
168 
169  struct IdToConnMap : public std::map<DWORD, PSafePtr<OpalCapiConnection> >
170  {
171  bool Forward(const OpalCapiMessage & message, DWORD id);
172  PMutex m_mutex;
173  };
174 
175  IdToConnMap m_cbciToConnection;
176  IdToConnMap m_plciToConnection;
177 
178  friend class OpalCapiConnection;
179 };
180 
181 
184 class OpalCapiConnection : public OpalConnection
185 {
186  PCLASSINFO(OpalCapiConnection, OpalConnection);
187 
188  public:
193  OpalCapiConnection(
194  OpalCall & call,
195  OpalCapiEndPoint & endpoint,
196  unsigned int options,
197  OpalConnection::StringOptions * stringOptions,
198  unsigned controller,
199  unsigned bearer
200  );
202 
213  virtual bool IsNetworkConnection() const;
214 
221  virtual PBoolean SetUpConnection();
222 
233  virtual PBoolean SetAlerting(
234  const PString & calleeName,
235  PBoolean withMedia
236  );
237 
242  virtual PBoolean SetConnected();
243 
262  virtual void OnReleased();
263 
270  virtual PString GetDestinationAddress();
271 
278  virtual OpalMediaFormatList GetMediaFormats() const;
279 
295  const OpalMediaFormat & mediaFormat,
296  unsigned sessionID,
297  PBoolean isSource
298  );
299 
306  virtual PBoolean SendUserInputTone(
307  char tone,
308  int duration
309  );
311 
314 
315 
316  protected:
317  virtual void ProcessMessage(const OpalCapiMessage & message);
318  virtual bool PutMessage(OpalCapiMessage & message);
319 
320  OpalCapiEndPoint & m_endpoint;
321  unsigned m_controller; // 1..127
322  unsigned m_bearer;
323  DWORD m_PLCI;
324  DWORD m_NCCI;
325 
326  PSyncPoint m_disconnected;
327 
328  friend class OpalCapiEndPoint;
329  friend struct OpalCapiEndPoint::IdToConnMap;
330  friend class OpalCapiMediaStream;
331 };
332 
333 
337 class OpalCapiMediaStream : public OpalMediaStream
338 {
339  PCLASSINFO(OpalCapiMediaStream, OpalMediaStream);
340  public:
345  OpalCapiMediaStream(
346  OpalCapiConnection & conn,
347  const OpalMediaFormat & mediaFormat,
348  unsigned sessionID,
349  PBoolean isSource
350  );
352 
353 
359  virtual PBoolean ReadData(
360  BYTE * data,
361  PINDEX size,
362  PINDEX & length
363  );
364 
368  virtual PBoolean WriteData(
369  const BYTE * data,
370  PINDEX length,
371  PINDEX & written
372  );
373 
377  virtual PBoolean IsSynchronous() const;
379 
382 
383 
384  protected:
385  virtual void InternalClose();
386 
387  OpalCapiConnection & m_connection;
388  PQueueChannel m_queue;
389  PSyncPoint m_written;
390  PAdaptiveDelay m_delay;
391 
392  friend class OpalCapiConnection;
393 };
394 
395 
396 #endif // OPAL_CAPI
397 
398 #endif // OPAL_LIDS_CAPI_EP_H
399 
400 
401 // End of File ///////////////////////////////////////////////////////////////