OPAL  Version 3.12.9
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: 27643 $
27  * $Author: rjongbloed $
28  * $Date: 2012-05-17 11:07:54 +1000 (Thu, 17 May 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 
50 #define OPAL_OPT_CAPI_B_PROTO "B-Proto"
51 
52 
55 class OpalCapiEndPoint : public OpalEndPoint
56 {
57  PCLASSINFO(OpalCapiEndPoint, OpalEndPoint);
58 
59  public:
64  OpalCapiEndPoint(
65  OpalManager & manager
66  );
67 
69  ~OpalCapiEndPoint();
71 
97  virtual PSafePtr<OpalConnection> MakeConnection(
98  OpalCall & call,
99  const PString & party,
100  void * userData = NULL,
101  unsigned int options = 0,
102  OpalConnection::StringOptions * stringOptions = NULL
103  );
104 
114  virtual OpalMediaFormatList GetMediaFormats() const;
116 
119  virtual OpalCapiConnection * CreateConnection(
120  OpalCall & call,
121  void * userData,
122  unsigned int options,
123  OpalConnection::StringOptions * stringOptions,
124  unsigned controller,
125  unsigned bearer
126  );
128 
133  unsigned OpenControllers();
134 
138  PString GetDriverInfo() const;
140 
143 
144 
145  protected:
146  bool GetFreeLine(unsigned & controller, unsigned & bearer);
147  PDECLARE_NOTIFIER(PThread, OpalCapiEndPoint, ProcessMessages);
148  virtual void ProcessMessage(const OpalCapiMessage & message);
149  void ProcessConnectInd(const OpalCapiMessage & message);
150  virtual bool PutMessage(OpalCapiMessage & message);
151 
152  OpalCapiFunctions * m_capi;
153  PThread * m_thread;
154  unsigned m_applicationId;
155  PSyncPoint m_listenCompleted;
156 
157  struct Controller {
158  Controller() : m_active(false) { }
159 
160  bool GetFreeLine(unsigned & bearer);
161 
162  bool m_active;
163  vector<bool> m_bearerInUse;
164  };
165  typedef std::vector<Controller> ControllerVector;
166  ControllerVector m_controllers;
167  PMutex m_controllerMutex;
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  );
310 
312  virtual void OnApplyStringOptions();
314 
317 
318 
319  protected:
320  virtual void ProcessMessage(const OpalCapiMessage & message);
321  virtual bool PutMessage(OpalCapiMessage & message);
322 
323  OpalCapiEndPoint & m_endpoint;
324  unsigned m_controller; // 1..127
325  unsigned m_bearer;
326  DWORD m_PLCI;
327  DWORD m_NCCI;
328 
329  PSyncPoint m_disconnected;
330 
331  PBYTEArray m_Bprotocol;
332 
333  friend class OpalCapiEndPoint;
334  friend struct OpalCapiEndPoint::IdToConnMap;
335  friend class OpalCapiMediaStream;
336 };
337 
338 
342 class OpalCapiMediaStream : public OpalMediaStream
343 {
344  PCLASSINFO(OpalCapiMediaStream, OpalMediaStream);
345  public:
350  OpalCapiMediaStream(
351  OpalCapiConnection & conn,
352  const OpalMediaFormat & mediaFormat,
353  unsigned sessionID,
354  PBoolean isSource
355  );
357 
358 
364  virtual PBoolean ReadData(
365  BYTE * data,
366  PINDEX size,
367  PINDEX & length
368  );
369 
373  virtual PBoolean WriteData(
374  const BYTE * data,
375  PINDEX length,
376  PINDEX & written
377  );
378 
382  virtual PBoolean IsSynchronous() const;
384 
387 
388 
389  protected:
390  virtual void InternalClose();
391 
392  OpalCapiConnection & m_connection;
393  PQueueChannel m_queue;
394  PSyncPoint m_written;
395  PAdaptiveDelay m_delay;
396 
397  friend class OpalCapiConnection;
398 };
399 
400 
401 #endif // OPAL_CAPI
402 
403 #endif // OPAL_LIDS_CAPI_EP_H
404 
405 
406 // End of File ///////////////////////////////////////////////////////////////