OPAL  Version 3.10.4
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 
56 {
57  PCLASSINFO(OpalLineEndPoint, OpalEndPoint);
58 
59  public:
66  );
67 
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 
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 
199  OpalLineInterfaceDevice & device
200  );
201 
207  PBoolean AddDeviceNames(
208  const PStringArray & descriptors
209  );
210 
220  PBoolean AddDeviceName(
221  const PString & descriptor
222  );
223 
227  const PString & descriptor
228  );
229 
241  virtual PBoolean AddDevice(
242  OpalLineInterfaceDevice * device
243  );
244 
248  void RemoveDevice(
249  OpalLineInterfaceDevice * device
250  );
251 
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(
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 
309 {
310  PCLASSINFO(OpalLineConnection, OpalConnection);
311 
312  public:
318  OpalCall & call,
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 
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 
522 
526 
530  unsigned int uiDialDelay
531  ) { m_dialParams.m_dialStartDelay = uiDialDelay;}
532 
536  unsigned int getDialDelay() const { return m_dialParams.m_dialStartDelay; }
538 
539  protected:
546 
547  PDECLARE_NOTIFIER(PThread, OpalLineConnection, HandleIncoming);
548  PThread * handlerThread;
549 };
550 
551 
556 {
558  public:
564  OpalLineConnection & conn,
565  const OpalMediaFormat & mediaFormat,
566  unsigned sessionID,
567  PBoolean isSource,
568  OpalLine & line
569  );
571 
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:
667  unsigned missedCount;
668  BYTE lastSID[4];
671 };
672 
673 
675 {
677  public:
683  OpalLine & line,
684  const Params & newParam
685  );
687 
698  virtual unsigned GetAverageSignalLevel(
699  const BYTE * buffer,
700  PINDEX size
701  );
703 
704  protected:
706 };
707 
708 
709 #endif // OPAL_LIDS_LIDEP_H
710 
711 
712 // End of File ///////////////////////////////////////////////////////////////