OPAL  Version 3.14.3
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: 29536 $
30  * $Author: rjongbloed $
31  * $Date: 2013-04-19 18:55:15 +1000 (Fri, 19 Apr 2013) $
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_config.h>
42 
43 #if OPAL_LID
44 
45 #include <opal/endpoint.h>
46 #include <lids/lid.h>
47 #include <codec/silencedetect.h>
48 
49 
50 class OpalLineConnection;
51 
52 
58 {
59  PCLASSINFO(OpalLineEndPoint, OpalEndPoint);
60 
61  public:
68  );
69 
73 
105  virtual PSafePtr<OpalConnection> MakeConnection(
106  OpalCall & call,
107  const PString & party,
108  void * userData = NULL,
109  unsigned int options = 0,
110  OpalConnection::StringOptions * stringOptions = NULL
111  );
112 
122  virtual OpalMediaFormatList GetMediaFormats() const;
124 
128  OpalCall & call,
129  OpalLine & line,
130  void * userData,
131  const PString & number
132  );
134 
141  PSafePtr<OpalLineConnection> GetLIDConnectionWithLock(
142  const PString & token,
143  PSafetyMode mode = PSafeReadWrite
144  ) { return PSafePtrCast<OpalConnection, OpalLineConnection>(GetConnectionWithLock(token, mode)); }
145 
153  PBoolean AddLine(
154  OpalLine * line
155  );
156 
160  void RemoveLine(
161  OpalLine * line
162  );
163 
164 
169  const PList<OpalLine> & GetLines() const { return lines;};
170 
174  void RemoveLine(
175  const PString & token
176  );
177 
182  void RemoveAllLines();
183 
193  virtual PBoolean AddLinesFromDevice(
194  OpalLineInterfaceDevice & device
195  );
196 
201  OpalLineInterfaceDevice & device
202  );
203 
209  PBoolean AddDeviceNames(
210  const PStringArray & descriptors
211  );
212 
222  PBoolean AddDeviceName(
223  const PString & descriptor
224  );
225 
229  const PString & descriptor
230  );
231 
243  virtual PBoolean AddDevice(
244  OpalLineInterfaceDevice * device
245  );
246 
250  void RemoveDevice(
251  OpalLineInterfaceDevice * device
252  );
253 
257 
265  OpalLine * GetLine(
266  const PString & lineName,
267  bool enableAudio = false,
268  bool terminating = true
269  );
270 
274  void SetDefaultLine(
275  const PString & lineName
276  );
277 
283  bool SetCountryCode(
285  );
286 
289  bool SetCountryCodeName(
290  const PString & countryName
291  );
293 
294 
295  protected:
296  PDECLARE_NOTIFIER(PThread, OpalLineEndPoint, MonitorLines);
297  virtual void MonitorLine(OpalLine & line);
298 
299  OpalLIDList devices;
300  OpalLineList lines;
301  PString defaultLine;
302  PMutex linesMutex;
303  PThread * monitorThread;
304  PSyncPoint exitFlag;
305 };
306 
307 
311 {
312  PCLASSINFO(OpalLineConnection, OpalConnection);
313 
314  public:
320  OpalCall & call,
322  OpalLine & line,
323  const PString & number
324  );
326 
331  virtual PString GetPrefixName() const;
332 
341  virtual bool IsNetworkConnection() const { return !line.IsTerminal(); }
342 
349  virtual PBoolean SetUpConnection();
350 
361  virtual PBoolean SetAlerting(
362  const PString & calleeName,
363  PBoolean withMedia
364  );
365 
370  virtual PBoolean SetConnected();
371 
390  virtual void OnReleased();
391 
398  virtual PString GetDestinationAddress();
399 
406  virtual OpalMediaFormatList GetMediaFormats() const;
407 
423  const OpalMediaFormat & mediaFormat,
424  unsigned sessionID,
425  PBoolean isSource
426  );
427 
440  virtual PBoolean OnOpenMediaStream(
441  OpalMediaStream & stream
442  );
443 
451  virtual void OnClosedMediaStream(
452  const OpalMediaStream & stream
453  );
454 
457  virtual PBoolean SetAudioVolume(
458  PBoolean source,
459  unsigned percentage
460  );
461 
465  virtual unsigned GetAudioSignalLevel(
466  PBoolean source
467  );
468 
476  virtual PBoolean SendUserInputString(
477  const PString & value
478  );
479 
486  virtual PBoolean SendUserInputTone(
487  char tone,
488  int duration
489  );
490 
497  virtual PBoolean PromptUserInput(
498  PBoolean play
499  );
501 
506  void StartIncoming();
507 
510  virtual void Monitor();
512 
513 
518  OpalLine & GetLine() { return line; }
519 
524 
528 
532  unsigned int uiDialDelay
533  ) { m_dialParams.m_dialStartDelay = uiDialDelay;}
534 
538  unsigned int getDialDelay() const { return m_dialParams.m_dialStartDelay; }
540 
541  protected:
546  PString m_dialedNumber;
549 
550  PDECLARE_NOTIFIER(PThread, OpalLineConnection, HandleIncoming);
551  PThread * handlerThread;
552 };
553 
554 
559 {
561  public:
567  OpalLineConnection & conn,
568  const OpalMediaFormat & mediaFormat,
569  unsigned sessionID,
570  PBoolean isSource,
571  OpalLine & line
572  );
574 
576 
577 
585  virtual PBoolean Open();
586 
592  virtual PBoolean ReadPacket(
593  RTP_DataFrame & packet
594  );
595 
601  virtual PBoolean WritePacket(
602  RTP_DataFrame & packet
603  );
604 
608  virtual PBoolean ReadData(
609  BYTE * data,
610  PINDEX size,
611  PINDEX & length
612  );
613 
617  virtual PBoolean WriteData(
618  const BYTE * data,
619  PINDEX length,
620  PINDEX & written
621  );
622 
628  virtual PBoolean SetDataSize(
629  PINDEX dataSize,
630  PINDEX frameTime
631  );
632 
636  virtual PBoolean IsSynchronous() const;
637 
648  virtual PBoolean RequiresPatchThread(
649  OpalMediaStream * stream
650  ) const;
652 
657  OpalLine & GetLine() { return line; }
659 
660  protected:
661  virtual void InternalClose();
662 
666  unsigned missedCount;
667  BYTE lastSID[4];
670 };
671 
672 
674 {
676  public:
682  OpalLine & line,
683  const Params & newParam
684  );
686 
697  virtual unsigned GetAverageSignalLevel(
698  const BYTE * buffer,
699  PINDEX size
700  );
702 
703  protected:
705 };
706 
707 
708 #endif // OPAL_LID
709 
710 #endif // OPAL_LIDS_LIDEP_H
711 
712 
713 // End of File ///////////////////////////////////////////////////////////////