OPAL Version 3.10.4

- Main Page
- Related Pages
- Namespaces
- Data Structures
- Files

- File List
- Globals

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: 24318 $
27 * $Author: rjongbloed $
28 * $Date: 2010-05-02 21:15:41 -0500 (Sun, 02 May 2010) $
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();
138
141
142
143 protected:
144 bool GetFreeLine(unsigned & controller, unsigned & bearer);
145 PDECLARE_NOTIFIER(PThread, OpalCapiEndPoint, ProcessMessages);
146 virtual void ProcessMessage(const OpalCapiMessage & message);
147 void ProcessConnectInd(const OpalCapiMessage & message);
148 virtual bool PutMessage(OpalCapiMessage & message);
149
150 OpalCapiFunctions * m_capi;
151 PThread * m_thread;
152 unsigned m_applicationId;
153 PSyncPoint m_listenCompleted;
154
155 struct Controller {
156 Controller() : m_active(false) { }
157
158 bool m_active;
159 vector<bool> m_bearerInUse;
160 };
161 typedef std::vector<Controller> ControllerVector;
162 ControllerVector m_controllers;
163
164 struct IdToConnMap : public std::map<DWORD, PSafePtr<OpalCapiConnection> >
165 {
166 bool Forward(const OpalCapiMessage & message, DWORD id);
167 };
168
169 IdToConnMap m_cbciToConnection;
170 IdToConnMap m_plciToConnection;
171 IdToConnMap m_ncciToConnection;
172
173 friend class OpalCapiConnection;
174 };
175
176
179 class OpalCapiConnection : public OpalConnection
180 {
181 PCLASSINFO(OpalCapiConnection, OpalConnection);
182
183 public:
188 OpalCapiConnection(
189 OpalCall & call,
190 OpalCapiEndPoint & endpoint,
191 unsigned int options,
192 OpalConnection::StringOptions * stringOptions,
193 unsigned controller,
194 unsigned bearer
195 );
197
208 virtual bool IsNetworkConnection() const;
209
216 virtual PBoolean SetUpConnection();
217
228 virtual PBoolean SetAlerting(
229 const PString & calleeName,
230 PBoolean withMedia
231 );
232
237 virtual PBoolean SetConnected();
238
257 virtual void OnReleased();
258
265 virtual PString GetDestinationAddress();
266
273 virtual OpalMediaFormatList GetMediaFormats() const;
274
289 virtual OpalMediaStream * CreateMediaStream(
290 const OpalMediaFormat & mediaFormat,
291 unsigned sessionID,
292 PBoolean isSource
293 );
294
301 virtual PBoolean SendUserInputTone(
302 char tone,
303 int duration
304 );
306
309
310
311 protected:
312 virtual void ProcessMessage(const OpalCapiMessage & message);
313 virtual bool PutMessage(OpalCapiMessage & message);
314
315 OpalCapiEndPoint & m_endpoint;
316 unsigned m_controller; // 1..127
317 unsigned m_bearer;
318 DWORD m_PLCI;
319 DWORD m_NCCI;
320
321 PSyncPoint m_disconnected;
322
323 friend class OpalCapiEndPoint;
324 friend struct OpalCapiEndPoint::IdToConnMap;
325 friend class OpalCapiMediaStream;
326 };
327
328
332 class OpalCapiMediaStream : public OpalMediaStream
333 {
334 PCLASSINFO(OpalCapiMediaStream, OpalMediaStream);
335 public:
340 OpalCapiMediaStream(
341 OpalCapiConnection & conn,
342 const OpalMediaFormat & mediaFormat,
343 unsigned sessionID,
344 PBoolean isSource
345 );
347
348
355 virtual PBoolean Close();
356
360 virtual PBoolean ReadData(
361 BYTE * data,
362 PINDEX size,
363 PINDEX & length
364 );
365
369 virtual PBoolean WriteData(
370 const BYTE * data,
371 PINDEX length,
372 PINDEX & written
373 );
374
378 virtual PBoolean IsSynchronous() const;
380
383
384
385 protected:
386 OpalCapiConnection & m_connection;
387 PQueueChannel m_queue;
388 PSyncPoint m_written;
389 PAdaptiveDelay m_delay;
390
391 friend class OpalCapiConnection;
392 };
393
394
395 #endif // OPAL_CAPI
396
397 #endif // OPAL_LIDS_CAPI_EP_H
398
399
400 // End of File ///////////////////////////////////////////////////////////////