OPAL Version 3.10.4

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

- File List
- Globals

lidep.h
Go to the documentation of this file.
1 /*
2 * lidep.h
3 *
4 * Line Interface Device EndPoint
5 *
6 * Open Phone Abstraction Library
7 *
8 * Copyright (c) 2001 Equivalence 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 Equivalence Pty. Ltd.
23 *
24 * Portions of this code were written with the assisance of funding from
25 * Quicknet Technologies, Inc. http://www.quicknet.net.
26 *
27 * Contributor(s): ______________________________________.
28 *
29 * $Revision: 24766 $
30 * $Author: rjongbloed $
31 * $Date: 2010-09-30 02:18:52 -0500 (Thu, 30 Sep 2010) $
32 */
33
34 #ifndef OPAL_LIDS_LIDEP_H
35 #define OPAL_LIDS_LIDEP_H
36
37 #ifdef P_USE_PRAGMA
38 #pragma interface
39 #endif
40
41 #include <opal/buildopts.h>
42
43 #include <opal/endpoint.h>
44 #include <lids/lid.h>
45 #include <codec/silencedetect.h>
46
47
48 class OpalLineConnection;
49
50
55 class OpalLineEndPoint : public OpalEndPoint
56 {
57 PCLASSINFO(OpalLineEndPoint, OpalEndPoint);
58
59 public:
64 OpalLineEndPoint(
65 OpalManager & manager
66 );
67
69 ~OpalLineEndPoint();
71
103 virtual PSafePtr<OpalConnection> MakeConnection(
104 OpalCall & call,
105 const PString & party,
106 void * userData = NULL,
107 unsigned int options = 0,
108 OpalConnection::StringOptions * stringOptions = NULL
109 );
110
120 virtual OpalMediaFormatList GetMediaFormats() const;
122
125 virtual OpalLineConnection * CreateConnection(
126 OpalCall & call,
127 OpalLine & line,
128 void * userData,
129 const PString & number
130 );
132
139 PSafePtr<OpalLineConnection> GetLIDConnectionWithLock(
140 const PString & token,
141 PSafetyMode mode = PSafeReadWrite
142 ) { return PSafePtrCast<OpalConnection, OpalLineConnection>(GetConnectionWithLock(token, mode)); }
143
151 PBoolean AddLine(
152 OpalLine * line
153 );
154
158 void RemoveLine(
159 OpalLine * line
160 );
161
162
167 const PList<OpalLine> & GetLines() const { return lines;};
168
172 void RemoveLine(
173 const PString & token
174 );
175
180 void RemoveAllLines();
181
191 virtual PBoolean AddLinesFromDevice(
192 OpalLineInterfaceDevice & device
193 );
194
198 void RemoveLinesFromDevice(
199 OpalLineInterfaceDevice & device
200 );
201
207 PBoolean AddDeviceNames(
208 const PStringArray & descriptors
209 );
210
220 PBoolean AddDeviceName(
221 const PString & descriptor
222 );
223
226 const OpalLineInterfaceDevice * GetDeviceByName(
227 const PString & descriptor
228 );
229
241 virtual PBoolean AddDevice(
242 OpalLineInterfaceDevice * device
243 );
244
248 void RemoveDevice(
249 OpalLineInterfaceDevice * device
250 );
251
254 void RemoveDevices() { RemoveAllLines(); }
255
263 OpalLine * GetLine(
264 const PString & lineName,
265 bool enableAudio = false,
266 bool terminating = true
267 );
268
272 void SetDefaultLine(
273 const PString & lineName
274 );
275
281 bool SetCountryCode(
282 OpalLineInterfaceDevice::T35CountryCodes country
283 );
284
287 bool SetCountryCodeName(
288 const PString & countryName
289 );
291
292
293 protected:
294 PDECLARE_NOTIFIER(PThread, OpalLineEndPoint, MonitorLines);
295 virtual void MonitorLine(OpalLine & line);
296
297 OpalLIDList devices;
298 OpalLineList lines;
299 PString defaultLine;
300 PMutex linesMutex;
301 PThread * monitorThread;
302 PSyncPoint exitFlag;
303 };
304
305
308 class OpalLineConnection : public OpalConnection
309 {
310 PCLASSINFO(OpalLineConnection, OpalConnection);
311
312 public:
317 OpalLineConnection(
318 OpalCall & call,
319 OpalLineEndPoint & endpoint,
320 OpalLine & line,
321 const PString & number
322 );
324
329 virtual PString GetPrefixName() const;
330
339 virtual bool IsNetworkConnection() const { return !line.IsTerminal(); }
340
347 virtual PBoolean SetUpConnection();
348
359 virtual PBoolean SetAlerting(
360 const PString & calleeName,
361 PBoolean withMedia
362 );
363
368 virtual PBoolean SetConnected();
369
388 virtual void OnReleased();
389
396 virtual PString GetDestinationAddress();
397
404 virtual OpalMediaFormatList GetMediaFormats() const;
405
420 virtual OpalMediaStream * CreateMediaStream(
421 const OpalMediaFormat & mediaFormat,
422 unsigned sessionID,
423 PBoolean isSource
424 );
425
438 virtual PBoolean OnOpenMediaStream(
439 OpalMediaStream & stream
440 );
441
449 virtual void OnClosedMediaStream(
450 const OpalMediaStream & stream
451 );
452
455 virtual PBoolean SetAudioVolume(
456 PBoolean source,
457 unsigned percentage
458 );
459
463 virtual unsigned GetAudioSignalLevel(
464 PBoolean source
465 );
466
474 virtual PBoolean SendUserInputString(
475 const PString & value
476 );
477
484 virtual PBoolean SendUserInputTone(
485 char tone,
486 int duration
487 );
488
495 virtual PBoolean PromptUserInput(
496 PBoolean play
497 );
499
504 void StartIncoming();
505
508 virtual void Monitor();
510
511
516 OpalLine & GetLine() { return line; }
517
521 OpalLineInterfaceDevice::CallProgressTones GetPromptTone() const { return m_promptTone; }
522
525 void SetPromptTone(OpalLineInterfaceDevice::CallProgressTones tone) { m_promptTone = tone; }
526
529 void setDialDelay(
530 unsigned int uiDialDelay
531 ) { m_dialParams.m_dialStartDelay = uiDialDelay;}
532
536 unsigned int getDialDelay() const { return m_dialParams.m_dialStartDelay; }
538
539 protected:
540 OpalLineEndPoint & endpoint;
541 OpalLine & line;
542 bool wasOffHook;
543 unsigned minimumRingCount;
544 OpalLineInterfaceDevice::DialParams m_dialParams;
545 OpalLineInterfaceDevice::CallProgressTones m_promptTone;
546
547 PDECLARE_NOTIFIER(PThread, OpalLineConnection, HandleIncoming);
548 PThread * handlerThread;
549 };
550
551
555 class OpalLineMediaStream : public OpalMediaStream
556 {
557 PCLASSINFO(OpalLineMediaStream, OpalMediaStream);
558 public:
563 OpalLineMediaStream(
564 OpalLineConnection & conn,
565 const OpalMediaFormat & mediaFormat,
566 unsigned sessionID,
567 PBoolean isSource,
568 OpalLine & line
569 );
571
572 ~OpalLineMediaStream();
573
574
582 virtual PBoolean Open();
583
588 virtual PBoolean Close();
589
595 virtual PBoolean ReadPacket(
596 RTP_DataFrame & packet
597 );
598
604 virtual PBoolean WritePacket(
605 RTP_DataFrame & packet
606 );
607
611 virtual PBoolean ReadData(
612 BYTE * data,
613 PINDEX size,
614 PINDEX & length
615 );
616
620 virtual PBoolean WriteData(
621 const BYTE * data,
622 PINDEX length,
623 PINDEX & written
624 );
625
631 virtual PBoolean SetDataSize(
632 PINDEX dataSize,
633 PINDEX frameTime
634 );
635
639 virtual PBoolean IsSynchronous() const;
640
651 virtual PBoolean RequiresPatchThread(
652 OpalMediaStream * stream
653 ) const;
655
660 OpalLine & GetLine() { return line; }
662
663 protected:
664 OpalLine & line;
665 bool notUsingRTP;
666 bool useDeblocking;
667 unsigned missedCount;
668 BYTE lastSID[4];
669 bool lastFrameWasSignal;
670 unsigned directLineNumber;
671 };
672
673
674 class OpalLineSilenceDetector : public OpalSilenceDetector
675 {
676 PCLASSINFO(OpalLineSilenceDetector, OpalSilenceDetector);
677 public:
682 OpalLineSilenceDetector(
683 OpalLine & line,
684 const Params & newParam
685 );
687
698 virtual unsigned GetAverageSignalLevel(
699 const BYTE * buffer,
700 PINDEX size
701 );
703
704 protected:
705 OpalLine & line;
706 };
707
708
709 #endif // OPAL_LIDS_LIDEP_H
710
711
712 // End of File ///////////////////////////////////////////////////////////////