OPAL  Version 3.18.8
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 
27 #ifndef OPAL_LIDS_CAPI_EP_H
28 #define OPAL_LIDS_CAPI_EP_H
29 
30 #ifdef P_USE_PRAGMA
31 #pragma interface
32 #endif
33 
34 #include <opal_config.h>
35 
36 #if OPAL_CAPI
37 
38 #include <opal/endpoint.h>
39 #include <ptclib/qchannel.h>
40 
41 
42 class OpalCapiFunctions;
43 class OpalCapiConnection;
44 struct OpalCapiMessage;
45 
46 
47 #define OPAL_OPT_CAPI_B_PROTO "B-Proto"
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 
94  virtual PSafePtr<OpalConnection> MakeConnection(
95  OpalCall & call,
96  const PString & party,
97  void * userData = NULL,
98  unsigned int options = 0,
99  OpalConnection::StringOptions * stringOptions = NULL
100  );
101 
111  virtual OpalMediaFormatList GetMediaFormats() const;
112 
115  virtual PStringList GetAvailableStringOptions() const;
117 
120  virtual OpalCapiConnection * CreateConnection(
121  OpalCall & call,
122  void * userData,
123  unsigned int options,
124  OpalConnection::StringOptions * stringOptions,
125  unsigned controller,
126  unsigned bearer
127  );
129 
134  unsigned OpenControllers();
135 
139  PString GetDriverInfo() const;
141 
144 
145 
146  protected:
147  bool GetFreeLine(unsigned & controller, unsigned & bearer);
148  PDECLARE_NOTIFIER(PThread, OpalCapiEndPoint, ProcessMessages);
149  virtual void ProcessMessage(const OpalCapiMessage & message);
150  void ProcessConnectInd(const OpalCapiMessage & message);
151  virtual bool PutMessage(OpalCapiMessage & message);
152 
153  OpalCapiFunctions * m_capi;
154  PThread * m_thread;
155  unsigned m_applicationId;
156  PSyncPoint m_listenCompleted;
157 
158  struct Controller {
159  Controller() : m_active(false) { }
160 
161  bool GetFreeLine(unsigned & bearer);
162 
163  bool m_active;
164  vector<bool> m_bearerInUse;
165  };
166  typedef std::vector<Controller> ControllerVector;
167  ControllerVector m_controllers;
168  PDECLARE_MUTEX( m_controllerMutex);
169 
170  struct IdToConnMap : public std::map<unsigned, PSafePtr<OpalCapiConnection> >
171  {
172  bool Forward(const OpalCapiMessage & message, unsigned id);
173  PDECLARE_MUTEX(m_mutex);
174  };
175 
176  IdToConnMap m_cbciToConnection;
177  IdToConnMap m_plciToConnection;
178 
179  friend class OpalCapiConnection;
180 };
181 
182 
185 class OpalCapiConnection : public OpalConnection
186 {
187  PCLASSINFO(OpalCapiConnection, OpalConnection);
188 
189  public:
194  OpalCapiConnection(
195  OpalCall & call,
196  OpalCapiEndPoint & endpoint,
197  unsigned int options,
198  OpalConnection::StringOptions * stringOptions,
199  unsigned controller,
200  unsigned bearer
201  );
203 
214  virtual bool IsNetworkConnection() const;
215 
222  virtual PBoolean SetUpConnection();
223 
234  virtual PBoolean SetAlerting(
235  const PString & calleeName,
236  PBoolean withMedia
237  );
238 
243  virtual PBoolean SetConnected();
244 
263  virtual void OnReleased();
264 
271  virtual PString GetDestinationAddress();
272 
279  virtual OpalMediaFormatList GetMediaFormats() const;
280 
296  const OpalMediaFormat & mediaFormat,
297  unsigned sessionID,
298  PBoolean isSource
299  );
300 
307  virtual PBoolean SendUserInputTone(
308  char tone,
309  int duration
310  );
311 
313  virtual void OnApplyStringOptions();
315 
318 
319 
320  protected:
321  virtual void ProcessMessage(const OpalCapiMessage & message);
322  virtual bool PutMessage(OpalCapiMessage & message);
323 
324  OpalCapiEndPoint & m_endpoint;
325  unsigned m_controller; // 1..127
326  unsigned m_bearer;
327  DWORD m_PLCI;
328  DWORD m_NCCI;
329 
330  PSyncPoint m_disconnected;
331 
332  PBYTEArray m_Bprotocol;
333 
334  friend class OpalCapiEndPoint;
335  friend struct OpalCapiEndPoint::IdToConnMap;
336  friend class OpalCapiMediaStream;
337 };
338 
339 
343 class OpalCapiMediaStream : public OpalMediaStream
344 {
345  PCLASSINFO(OpalCapiMediaStream, OpalMediaStream);
346  public:
351  OpalCapiMediaStream(
352  OpalCapiConnection & conn,
353  const OpalMediaFormat & mediaFormat,
354  unsigned sessionID,
355  PBoolean isSource
356  );
358 
359 
365  virtual PBoolean ReadData(
366  BYTE * data,
367  PINDEX size,
368  PINDEX & length
369  );
370 
374  virtual PBoolean WriteData(
375  const BYTE * data,
376  PINDEX length,
377  PINDEX & written
378  );
379 
383  virtual PBoolean IsSynchronous() const;
385 
388 
389 
390  protected:
391  virtual void InternalClose();
392 
393  OpalCapiConnection & m_connection;
394  PQueueChannel m_queue;
395  PSyncPoint m_written;
396  PAdaptiveDelay m_delay;
397 
398  friend class OpalCapiConnection;
399 };
400 
401 
402 #endif // OPAL_CAPI
403 
404 #endif // OPAL_LIDS_CAPI_EP_H
405 
406 
407 // End of File ///////////////////////////////////////////////////////////////
virtual PStringList GetAvailableStringOptions() const
virtual void OnReleased()
virtual OpalMediaFormatList GetMediaFormats() const =0
Definition: manager.h:150
virtual PBoolean IsSynchronous() const =0
Definition: endpoint.h:65
virtual OpalMediaStream * CreateMediaStream(const OpalMediaFormat &mediaFormat, unsigned sessionID, PBoolean isSource)
virtual PBoolean SendUserInputTone(char tone, unsigned duration=0)
virtual PBoolean ReadData(BYTE *data, PINDEX size, PINDEX &length)
virtual PBoolean SetConnected()
virtual PSafePtr< OpalConnection > MakeConnection(OpalCall &call, const PString &party, void *userData=NULL, unsigned int options=0, OpalConnection::StringOptions *stringOptions=NULL)=0
Definition: mediafmt.h:112
OpalEndPoint & m_endpoint
Definition: connection.h:1961
Definition: connection.h:530
virtual PBoolean SetAlerting(const PString &calleeName, PBoolean withMedia)
Definition: mediafmt.h:806
virtual PBoolean SetUpConnection()
Definition: call.h:62
virtual void InternalClose()=0
virtual PBoolean WriteData(const BYTE *data, PINDEX length, PINDEX &written)
virtual PString GetDestinationAddress()
OpalConnection & m_connection
Definition: mediastrm.h:463
virtual bool IsNetworkConnection() const =0
Definition: mediastrm.h:110
Definition: connection.h:415
virtual void OnApplyStringOptions()
Call back for connection to act on changed string options.
virtual OpalMediaFormatList GetMediaFormats() const