OPAL  Version 3.12.5
manager.h
Go to the documentation of this file.
1 /*
2  * manager.h
3  *
4  * OPAL system manager.
5  *
6  * Open Phone Abstraction Library (OPAL)
7  * Formally known as the Open H323 project.
8  *
9  * Copyright (c) 2001 Equivalence Pty. Ltd.
10  *
11  * The contents of this file are subject to the Mozilla Public License
12  * Version 1.0 (the "License"); you may not use this file except in
13  * compliance with the License. You may obtain a copy of the License at
14  * http://www.mozilla.org/MPL/
15  *
16  * Software distributed under the License is distributed on an "AS IS"
17  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
18  * the License for the specific language governing rights and limitations
19  * under the License.
20  *
21  * The Original Code is Open Phone Abstraction Library.
22  *
23  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
24  *
25  * Contributor(s): ______________________________________.
26  *
27  * $Revision: 30187 $
28  * $Author: rjongbloed $
29  * $Date: 2013-07-28 23:30:23 -0500 (Sun, 28 Jul 2013) $
30  */
31 
32 #ifndef OPAL_OPAL_MANAGER_H
33 #define OPAL_OPAL_MANAGER_H
34 
35 #ifdef P_USE_PRAGMA
36 #pragma interface
37 #endif
38 
39 #include <opal/buildopts.h>
40 
41 #include <opal/pres_ent.h>
42 #include <opal/call.h>
43 #include <opal/connection.h> //OpalConnection::AnswerCallResponse
44 #include <opal/guid.h>
45 #include <codec/silencedetect.h>
46 #include <codec/echocancel.h>
47 #include <im/im.h>
48 
49 #include <ptclib/pstun.h>
50 #include <ptclib/url.h>
51 #include <ptclib/pxml.h>
52 #include <ptclib/threadpool.h>
53 
54 #if OPAL_VIDEO
55 // Inside #if so does not force loading of factories when statically linked.
56 #include <ptlib/videoio.h>
57 #endif
58 
59 
60 class OpalEndPoint;
61 class OpalMediaPatch;
62 class PSSLCertificate;
63 class PSSLPrivateKey;
64 
65 
66 #define OPAL_SCRIPT_CALL_TABLE_NAME "OpalCall"
67 
68 
69 class OpalConferenceState : public PObject
70 {
71  PCLASSINFO(OpalConferenceState, PObject);
72 public:
74  : m_active(true)
75  , m_locked(false)
76  , m_maxUsers(0)
77  { }
78 
79  enum ChangeType {
85  };
86  friend ostream & operator<<(ostream & strm, ChangeType type);
87 
88  PString m_internalURI;
89 
90  PString m_displayText;
91  PString m_subject;
92  PString m_notes;
93  PString m_keywords;
94  bool m_active;
95  bool m_locked;
96 
97  struct URI
98  {
99  PString m_uri;
100  PString m_displayText;
101  PString m_purpose;
104  };
105  typedef std::vector<URI> URIs;
106 
112  unsigned m_maxUsers;
113 
114  struct User
115  {
116  PString m_uri;
117  PString m_displayText;
118  PStringSet m_roles;
119  };
120  typedef std::vector<User> Users;
122 
123 #if P_EXPAT
124 
130  PXML m_xml;
131 #endif
132 };
133 
134 typedef std::list<OpalConferenceState> OpalConferenceStates;
135 
136 
153 class OpalManager : public PObject
154 {
155  PCLASSINFO(OpalManager, PObject);
156  public:
161  OpalManager();
162 
167  ~OpalManager();
169 
179  void AttachEndPoint(
180  OpalEndPoint * endpoint,
181  const PString & prefix = PString::Empty()
182  );
183 
187  void DetachEndPoint(
188  const PString & prefix
189  );
190  void DetachEndPoint(
191  OpalEndPoint * endpoint
192  );
193 
197  const PString & prefix
198  );
199 
202  template <class T> T * FindEndPointAs(
203  const PString & prefix
204  ) { return dynamic_cast<T *>(FindEndPoint(prefix)); }
205 
208  PList<OpalEndPoint> GetEndPoints() const;
209 
212  PStringList GetPrefixNames(
213  const OpalEndPoint * endpoint = NULL
214  ) const;
215 
220  virtual PStringList GetNetworkURIs(
221  const PString & name
222  ) const;
223 
229  void ShutDownEndpoints();
231 
232 
233 #if OPAL_HAS_PRESENCE
234 
242  virtual PSafePtr<OpalPresentity> AddPresentity(
243  const PString & presentity
244  );
245 
248  virtual PSafePtr<OpalPresentity> GetPresentity(
249  const PString & presentity,
250  PSafetyMode mode = PSafeReference
251  );
252 
255  virtual PStringList GetPresentities() const;
256 
259  virtual bool RemovePresentity(
260  const PString & presentity
261  );
263 #endif // OPAL_HAS_PRESENCE
264 
265 
284  virtual PSafePtr<OpalCall> SetUpCall(
285  const PString & partyA,
286  const PString & partyB,
287  void * userData = NULL,
288  unsigned options = 0,
289  OpalConnection::StringOptions * stringOptions = NULL
290  );
291  virtual PBoolean SetUpCall(
292  const PString & partyA,
293  const PString & partyB,
294  PString & token,
295  void * userData = NULL,
296  unsigned options = 0,
297  OpalConnection::StringOptions * stringOptions = NULL
298  );
299 
305  virtual PBoolean HasCall(
306  const PString & token
307  ) { return activeCalls.FindWithLock(token, PSafeReference) != NULL; }
308 
311  PINDEX GetCallCount() const { return activeCalls.GetSize(); }
312 
315  PArray<PString> GetAllCalls() const { return activeCalls.GetKeys(); }
316 
325  PSafePtr<OpalCall> FindCallWithLock(
326  const PString & token,
327  PSafetyMode mode = PSafeReadWrite
328  ) const { return activeCalls.FindWithLock(token, mode); }
329 
338  virtual void OnEstablishedCall(
339  OpalCall & call
340  );
341 
348  virtual PBoolean IsCallEstablished(
349  const PString & token
350  );
351 
361  virtual PBoolean ClearCall(
362  const PString & token,
363  OpalConnection::CallEndReason reason = OpalConnection::EndedByLocalUser,
364  PSyncPoint * sync = NULL
365  );
366 
374  virtual PBoolean ClearCallSynchronous(
375  const PString & token,
376  OpalConnection::CallEndReason reason = OpalConnection::EndedByLocalUser
377  );
378 
384  virtual void ClearAllCalls(
385  OpalConnection::CallEndReason reason = OpalConnection::EndedByLocalUser,
386  PBoolean wait = true
387  );
388 
402  virtual void OnClearedCall(
403  OpalCall & call
404  );
405 
414  virtual OpalCall * CreateCall(
415  void * userData
416  );
417  OpalCall * InternalCreateCall(void * userData = NULL);
418 
427  virtual void DestroyCall(
428  OpalCall * call
429  );
430 
435  virtual PString GetNextToken(char prefix);
437 
438 
444  class RouteEntry : public PObject
445  {
446  PCLASSINFO(RouteEntry, PObject);
447  public:
448  RouteEntry(const PString & partyA, const PString & partyB, const PString & dest);
449  RouteEntry(const PString & spec);
450 
451  PObject * Clone() const { return new RouteEntry(*this); }
452  void PrintOn(ostream & strm) const;
453 
454  bool IsValid() const;
455  bool IsMatch(const PString & search) const;
456 
457  const PString & GetPartyA() const { return m_partyA; }
458  const PString & GetPartyB() const { return m_partyB; }
459  const PString & GetDestination() const { return m_destination; }
460 
461  protected:
462  PString m_partyA;
463  PString m_partyB;
464  PString m_destination;
465  PRegularExpression m_regex;
466 
467  void CompileRegEx();
468  };
469  PARRAY(RouteTable, RouteEntry);
470 
581  virtual PBoolean AddRouteEntry(
582  const PString & spec
583  );
584 
591  PBoolean SetRouteTable(
592  const PStringArray & specs
593  );
594 
599  void SetRouteTable(
600  const RouteTable & table
601  );
602 
605  const RouteTable & GetRouteTable() const { return m_routeTable; }
606 
614  virtual PString ApplyRouteTable(
615  const PString & source,
616  const PString & destination,
617  PINDEX & entry
618  );
619 
626  virtual bool OnRouteConnection(
627  PStringSet & routesTried,
628  const PString & a_party,
629  const PString & b_party,
630  OpalCall & call,
631  unsigned options,
632  OpalConnection::StringOptions * stringOptions
633  );
635 
636 
673  virtual PSafePtr<OpalConnection> MakeConnection(
674  OpalCall & call,
675  const PString & party,
676  void * userData = NULL,
677  unsigned int options = 0,
678  OpalConnection::StringOptions * stringOptions = NULL
679  );
680 
686  virtual void OnNewConnection(
687  OpalConnection & connection
688  );
689 
716  virtual PBoolean OnIncomingConnection(
717  OpalConnection & connection,
718  unsigned options,
719  OpalConnection::StringOptions * stringOptions
720  );
721 
727  virtual void OnApplyStringOptions(
728  OpalConnection & connection,
729  OpalConnection::StringOptions & stringOptions
730  );
731 
747  virtual void OnProceeding(
748  OpalConnection & connection
749  );
750 
767  virtual void OnAlerting(
768  OpalConnection & connection
769  );
770 
787  virtual OpalConnection::AnswerCallResponse OnAnswerCall(
788  OpalConnection & connection,
789  const PString & caller
790  );
791 
803  virtual void OnConnected(
804  OpalConnection & connection
805  );
806 
820  virtual void OnEstablished(
821  OpalConnection & connection
822  );
823 
839  virtual void OnReleased(
840  OpalConnection & connection
841  );
842 
849  virtual void OnHold(
850  OpalConnection & connection,
851  bool fromRemote,
852  bool onHold
853  );
854  virtual void OnHold(OpalConnection & connection); // For backward compatibility
855 
860  virtual PBoolean OnForwarded(
861  OpalConnection & connection,
862  const PString & remoteParty
863  );
864 
910  virtual bool OnTransferNotify(
911  OpalConnection & connection,
912  const PStringToString & info
913  );
915 
916 
927  bool transportable,
928  bool pcmAudio
929  ) const;
930 
940  virtual void AdjustMediaFormats(
941  bool local,
942  const OpalConnection & connection,
943  OpalMediaFormatList & mediaFormats
944  ) const;
945 
957  };
958 
972  const OpalConnection & source,
973  const OpalConnection & destination,
974  const OpalMediaType & mediaType
975  ) const;
976 
992  virtual PBoolean OnOpenMediaStream(
993  OpalConnection & connection,
994  OpalMediaStream & stream
995  );
996 
1013  virtual bool OnLocalRTP(
1014  OpalConnection & connection1,
1015  OpalConnection & connection2,
1016  unsigned sessionID,
1017  bool opened
1018  ) const;
1019 
1045  bool SetMediaPassThrough(
1046  const PString & token1,
1047  const PString & token2,
1048  bool bypass,
1049  unsigned sessionID = 0,
1050  bool network = true
1051  );
1052  static bool SetMediaPassThrough(
1053  OpalConnection & connection1,
1054  OpalConnection & connection2,
1055  bool bypass,
1056  unsigned sessionID = 0
1057  );
1058 
1063  virtual void OnClosedMediaStream(
1064  const OpalMediaStream & stream
1065  );
1066 
1067 #if OPAL_VIDEO
1068 
1070  virtual PBoolean CreateVideoInputDevice(
1071  const OpalConnection & connection,
1072  const OpalMediaFormat & mediaFormat,
1073  PVideoInputDevice * & device,
1074  PBoolean & autoDelete
1075  );
1076 
1080  virtual PBoolean CreateVideoOutputDevice(
1081  const OpalConnection & connection,
1082  const OpalMediaFormat & mediaFormat,
1083  PBoolean preview,
1084  PVideoOutputDevice * & device,
1085  PBoolean & autoDelete
1086  );
1087 #endif
1088 
1096  virtual OpalMediaPatch * CreateMediaPatch(
1097  OpalMediaStream & source,
1098  PBoolean requiresPatchThread = true
1099  );
1100 
1107  virtual void OnStartMediaPatch(
1108  OpalConnection & connection,
1109  OpalMediaPatch & patch
1110  );
1111 
1114  virtual void OnStopMediaPatch(
1115  OpalConnection & connection,
1116  OpalMediaPatch & patch
1117  );
1118 
1134  virtual bool OnMediaFailed(
1135  OpalConnection & connection,
1136  unsigned sessionId,
1137  bool source
1138  );
1140 
1141 
1149  virtual void OnUserInputString(
1150  OpalConnection & connection,
1151  const PString & value
1152  );
1153 
1160  virtual void OnUserInputTone(
1161  OpalConnection & connection,
1162  char tone,
1163  int duration
1164  );
1165 
1168  virtual PString ReadUserInput(
1169  OpalConnection & connection,
1170  const char * terminators = "YX#\r\n",
1171  unsigned lastDigitTimeout = 4,
1172  unsigned firstDigitTimeout = 30
1173  );
1175 
1176 
1177 #if OPAL_HAS_MIXER
1178 
1188  virtual PBoolean StartRecording(
1189  const PString & callToken,
1190  const PFilePath & filename,
1191  const OpalRecordManager::Options & options = false
1192  );
1193 
1196  virtual bool IsRecording(
1197  const PString & callToken
1198  );
1199 
1204  virtual bool StopRecording(
1205  const PString & callToken
1206  );
1207 
1209 #endif
1210 
1211 
1212 #if OPAL_HAS_IM
1213 
1218  virtual void OnConversation(
1219  const OpalIMContext::ConversationInfo & info
1220  );
1221 
1231  virtual PBoolean Message(
1232  OpalIM & message
1233  );
1234 
1236  virtual PBoolean Message(
1237  const PString & to,
1238  const PString & body
1239  );
1240 
1242  virtual PBoolean Message(
1243  const PURL & to,
1244  const PString & type,
1245  const PString & body,
1246  PURL & from,
1247  PString & conversationId
1248  );
1249 
1255  virtual void OnMessageReceived(
1256  const OpalIM & message
1257  );
1258 
1263  virtual void OnMessageDisposition(
1264  const OpalIMContext::DispositionInfo & info
1265  );
1266 
1271  virtual void OnCompositionIndication(
1272  const OpalIMContext::CompositionInfo & info
1273  );
1275 #endif
1276 
1277 
1280  enum MessageWaitingType {
1289  };
1290 
1301  virtual void OnMWIReceived(
1302  const PString & party,
1303  MessageWaitingType type,
1304  const PString & extraInfo
1305  );
1306 
1321  virtual bool GetConferenceStates(
1322  OpalConferenceStates & states,
1323  const PString & name = PString::Empty()
1324  ) const;
1325 
1335  virtual void OnConferenceStatusChanged(
1336  OpalEndPoint & endpoint,
1337  const PString & uri,
1339  );
1340 
1348  virtual bool OnChangedPresentationRole(
1349  OpalConnection & connection,
1350  const PString & newChairURI,
1351  bool request
1352  );
1354 
1355 
1358 #if OPAL_PTLIB_SSL
1359 
1371  virtual bool ApplySSLCredentials(
1372  const OpalEndPoint & ep,
1373  PSSLContext & context,
1374  bool create
1375  ) const;
1376 
1379  const PString & GetSSLCertificateAuthorityFiles() const { return m_caFiles; }
1380 
1383  void SetSSLCertificateAuthorityFiles(const PString & files) { m_caFiles = files; }
1384 
1387  const PString & GetSSLCertificateFile() const { return m_certificateFile; }
1388 
1391  void SetSSLCertificateFile(const PString & file) { m_certificateFile = file; }
1392 
1395  const PString & GetSSLPrivateKeyFile() const { return m_privateKeyFile; }
1396 
1399  void SetSSLPrivateKeyFile(const PString & file) { m_privateKeyFile = file; }
1400 
1403  void SetSSLAutoCreateCertificate(bool yes) { m_autoCreateCertificate = yes; }
1404 #endif
1405 
1412  virtual PBoolean IsLocalAddress(
1413  const PIPSocket::Address & remoteAddress
1414  ) const;
1415 
1433  virtual PBoolean IsRTPNATEnabled(
1434  OpalConnection & connection,
1435  const PIPSocket::Address & localAddr,
1436  const PIPSocket::Address & peerAddr,
1437  const PIPSocket::Address & signalAddr,
1438  PBoolean incoming
1439  );
1440 
1447  virtual PBoolean TranslateIPAddress(
1448  PIPSocket::Address & localAddress,
1449  const PIPSocket::Address & remoteAddress
1450  );
1451 
1452 #if P_NAT
1453 
1455  PNatStrategy & GetNatMethods() const { return *m_natMethods; }
1456 
1462  virtual PNatMethod * GetNatMethod(
1463  const PIPSocket::Address & remoteAddress = PIPSocket::GetDefaultIpAny()
1464  ) const;
1465 
1468  bool SetNATServer(
1469  const PString & method,
1470  const PString & server
1471  );
1472 
1475  PString GetNATServer() const
1476  {
1477  return (m_natMethod == NULL) ? PString::Empty() : m_natMethod->GetServer();
1478  }
1479 
1482  P_DEPRECATED PString GetTranslationHost() const;
1483 
1486  P_DEPRECATED bool SetTranslationHost(
1487  const PString & host
1488  );
1489 
1492  P_DEPRECATED PIPSocket::Address GetTranslationAddress() const;
1493 
1496  P_DEPRECATED void SetTranslationAddress(
1497  const PIPSocket::Address & address
1498  );
1499 
1502  P_DEPRECATED bool HasTranslationAddress() const;
1503 
1504 #ifdef P_STUN
1505 
1509  P_DEPRECATED PSTUNClient::NatTypes SetSTUNServer(
1510  const PString & server
1511  ) {
1512  return SetNATServer(PSTUNClient::GetNatMethodName(), server) ? m_natMethod->GetNatType() : PSTUNClient::UnknownNat;
1513  }
1514 
1517  P_DEPRECATED PString GetSTUNServer() const
1518  {
1519  return (dynamic_cast<PSTUNClient *>(m_natMethod) == NULL) ? PString::Empty() : m_natMethod->GetServer();
1520  }
1521 
1524  P_DEPRECATED PSTUNClient * GetSTUNClient() const { return dynamic_cast<PSTUNClient *>(m_natMethod); }
1525 #endif // P_STUN
1526 #endif // P_NAT
1527 
1530  WORD GetTCPPortBase() const { return tcpPorts.base; }
1531 
1534  WORD GetTCPPortMax() const { return tcpPorts.max; }
1535 
1538  void SetTCPPorts(unsigned tcpBase, unsigned tcpMax);
1539 
1542  WORD GetNextTCPPort();
1543 
1546  WORD GetUDPPortBase() const { return udpPorts.base; }
1547 
1550  WORD GetUDPPortMax() const { return udpPorts.max; }
1551 
1554  void SetUDPPorts(unsigned udpBase, unsigned udpMax);
1555 
1558  WORD GetNextUDPPort();
1559 
1562  WORD GetRtpIpPortBase() const { return rtpIpPorts.base; }
1563 
1566  WORD GetRtpIpPortMax() const { return rtpIpPorts.max; }
1567 
1570  void SetRtpIpPorts(unsigned udpBase, unsigned udpMax);
1571 
1574  WORD GetRtpIpPortPair();
1575 
1578  BYTE GetMediaTypeOfService() const;
1579 
1582  void SetMediaTypeOfService(unsigned tos);
1583 
1586  BYTE GetMediaTypeOfService(const OpalMediaType & type) const;
1587 
1590  void SetMediaTypeOfService(const OpalMediaType & type, unsigned tos);
1591 
1594  const PIPSocket::QoS & GetMediaQoS(const OpalMediaType & type) const;
1595 
1598  void SetMediaQoS(const OpalMediaType & type, const PIPSocket::QoS & qos);
1599 
1604  PINDEX GetMaxRtpPayloadSize() const { return rtpPayloadSizeMax; }
1605 
1611  PINDEX size,
1612  bool mtu = false
1613  ) { rtpPayloadSizeMax = size - (mtu ? (20+16+12) : 0); }
1614 
1618  PINDEX GetMaxRtpPacketSize() const { return rtpPacketSizeMax; }
1619 
1624  PINDEX size
1625  ) { rtpPacketSizeMax = size; }
1627 
1628 
1633  const OpalProductInfo & GetProductInfo() const { return productInfo; }
1634 
1637  void SetProductInfo(
1638  const OpalProductInfo & info,
1639  bool updateAll = true
1640  );
1641 
1644  const PString & GetDefaultUserName() const { return defaultUserName; }
1645 
1648  void SetDefaultUserName(
1649  const PString & name,
1650  bool updateAll = true
1651  );
1652 
1655  const PString & GetDefaultDisplayName() const { return defaultDisplayName; }
1656 
1659  void SetDefaultDisplayName(
1660  const PString & name,
1661  bool updateAll = true
1662  );
1663 
1669  const OpalConnection::StringOptions & stringOptions
1670  ) { m_defaultConnectionOptions = stringOptions; }
1671 
1672 #if OPAL_VIDEO
1673 
1674  //
1675  // these functions are deprecated and used only for backwards compatibility
1676  // applications should use OpalConnection::GetAutoStart() to check whether
1677  // a specific media type can be auto-started
1678  //
1679 
1682  bool CanAutoStartReceiveVideo() const { return (OpalMediaType::Video().GetAutoStart()&OpalMediaType::Receive) != 0; }
1683 
1686  void SetAutoStartReceiveVideo(bool can) { OpalMediaType::Video()->SetAutoStart(OpalMediaType::Receive, can); }
1687 
1690  bool CanAutoStartTransmitVideo() const { return (OpalMediaType::Video().GetAutoStart()&OpalMediaType::Transmit) != 0; }
1691 
1694  void SetAutoStartTransmitVideo(bool can) { OpalMediaType::Video()->SetAutoStart(OpalMediaType::Transmit, can); }
1695 
1696 #endif
1697 
1701  unsigned GetMinAudioJitterDelay() const { return minAudioJitterDelay; }
1702 
1706  unsigned GetMaxAudioJitterDelay() const { return maxAudioJitterDelay; }
1707 
1717  void SetAudioJitterDelay(
1718  unsigned minDelay,
1719  unsigned maxDelay
1720  );
1721 
1724  const PStringArray & GetMediaFormatOrder() const { return mediaFormatOrder; }
1725 
1728  void SetMediaFormatOrder(
1729  const PStringArray & order
1730  );
1731 
1737  const PStringArray & GetMediaFormatMask() const { return mediaFormatMask; }
1738 
1744  void SetMediaFormatMask(
1745  const PStringArray & mask //< New mask
1746  );
1747 
1751  const OpalSilenceDetector::Params & params
1752  ) { silenceDetectParams = params; }
1753 
1757 
1758 #if OPAL_AEC
1759 
1761  virtual void SetEchoCancelParams(
1762  const OpalEchoCanceler::Params & params
1763  ) { echoCancelParams = params; }
1764 
1767  const OpalEchoCanceler::Params & GetEchoCancelParams() const { return echoCancelParams; }
1768 #endif
1769 
1770 #if OPAL_VIDEO
1771 
1779  virtual PBoolean SetVideoInputDevice(
1780  const PVideoDevice::OpenArgs & deviceArgs
1781  );
1782 
1786  const PVideoDevice::OpenArgs & GetVideoInputDevice() const { return videoInputDevice; }
1787 
1795  virtual PBoolean SetVideoPreviewDevice(
1796  const PVideoDevice::OpenArgs & deviceArgs
1797  );
1798 
1802  const PVideoDevice::OpenArgs & GetVideoPreviewDevice() const { return videoPreviewDevice; }
1803 
1811  virtual PBoolean SetVideoOutputDevice(
1812  const PVideoDevice::OpenArgs & deviceArgs
1813  );
1814 
1818  const PVideoDevice::OpenArgs & GetVideoOutputDevice() const { return videoOutputDevice; }
1819 
1820 #endif
1821 
1822  PBoolean DetectInBandDTMFDisabled() const
1823  { return disableDetectInBandDTMF; }
1824 
1828  PBoolean mode
1829  ) { disableDetectInBandDTMF = mode; }
1830 
1833  const PTimeInterval & GetNoMediaTimeout() const { return m_noMediaTimeout; }
1834 
1838  const PTimeInterval & newInterval
1839  ) { m_noMediaTimeout = newInterval; }
1840 
1843  const PTimeInterval & GetSignalingTimeout() const { return m_signalingTimeout; }
1844 
1848  const PTimeInterval & newInterval
1849  ) { m_signalingTimeout = newInterval; }
1850 
1853  const PTimeInterval & GetTransportIdleTime() const { return m_transportIdleTime; }
1854 
1858  const PTimeInterval & newInterval
1859  ) { m_transportIdleTime = newInterval; }
1860 
1863  const PString & GetDefaultILSServer() const { return ilsServer; }
1864 
1868  const PString & server
1869  ) { ilsServer = server; }
1870 
1871 #if OPAL_SCRIPT
1872 
1917  PScriptLanguage * GetScript() const { return m_script; }
1918 
1921  bool RunScript(
1922  const PString & script,
1923  const char * language = "Lua"
1924  );
1925 #endif // OPAL_SCRIPT
1926 
1927 
1928  // needs to be public for gcc 3.4
1929  void GarbageCollection();
1930 
1931  // Decoupled event to avoid deadlocks, especially from patch threads
1932  void QueueDecoupledEvent(PSafeWork * work) { m_decoupledEventPool.AddWork(work); }
1933 
1934  protected:
1935  // Configuration variables
1937 
1940 
1941  typedef std::map<OpalMediaType, PIPSocket::QoS> MediaQoSMap;
1943 
1945 
1950  PStringArray mediaFormatOrder;
1951  PStringArray mediaFormatMask;
1953  PTimeInterval m_noMediaTimeout;
1954  PTimeInterval m_signalingTimeout;
1955  PTimeInterval m_transportIdleTime;
1956  PString ilsServer;
1957 
1959 #if OPAL_AEC
1960  OpalEchoCanceler::Params echoCancelParams;
1961 #endif
1962 
1963 #if OPAL_VIDEO
1964  PVideoDevice::OpenArgs videoInputDevice;
1965  PVideoDevice::OpenArgs videoPreviewDevice;
1966  PVideoDevice::OpenArgs videoOutputDevice;
1967 #endif
1968 
1969  struct PortInfo {
1970  void Set(
1971  unsigned base,
1972  unsigned max,
1973  unsigned range,
1974  unsigned dflt
1975  );
1976  WORD GetNext(
1977  unsigned increment
1978  );
1979 
1980  PMutex mutex;
1981  WORD base;
1982  WORD max;
1983  WORD current;
1985 
1986 #if OPAL_PTLIB_SSL
1987  PString m_caFiles;
1988  PFilePath m_certificateFile;
1989  PFilePath m_privateKeyFile;
1990  bool m_autoCreateCertificate;
1991 #endif
1992 
1993 #if P_NAT
1994  PNatStrategy * m_natMethods;
1995  PNatMethod * m_natMethod;
1996  PDECLARE_InterfaceNotifier(OpalManager, OnInterfaceChange);
1997  PInterfaceMonitor::Notifier m_onInterfaceChange;
1998 #endif
1999 
2000  RouteTable m_routeTable;
2002 
2003  // Dynamic variables
2004  PReadWriteMutex endpointsMutex;
2005  PList<OpalEndPoint> endpointList;
2006  std::map<PString, OpalEndPoint *> endpointMap;
2007 
2008  PAtomicInteger lastCallTokenID;
2009 
2010  class CallDict : public PSafeDictionary<PString, OpalCall>
2011  {
2012  public:
2013  CallDict(OpalManager & mgr) : manager(mgr) { }
2014  virtual void DeleteObject(PObject * object) const;
2016  } activeCalls;
2017 
2018 #if OPAL_HAS_PRESENCE
2019  PSafeDictionary<PString, OpalPresentity> m_presentities;
2020 #endif // OPAL_HAS_PRESENCE
2021 
2022  PAtomicInteger m_clearingAllCallsCount;
2024  PSyncPoint m_allCallsCleared;
2025  void InternalClearAllCalls(OpalConnection::CallEndReason reason, bool wait, bool first);
2026 
2030  PDECLARE_NOTIFIER(PThread, OpalManager, GarbageMain);
2031 
2032  friend OpalCall::OpalCall(OpalManager & mgr);
2033  friend void OpalCall::InternalOnClear();
2034 
2035  PSafeThreadPool m_decoupledEventPool;
2036 
2037 #if OPAL_SCRIPT
2038  PScriptLanguage * m_script;
2039 #endif
2040 
2041  private:
2042  P_REMOVE_VIRTUAL(OpalCall *,CreateCall(), 0);
2043  P_REMOVE_VIRTUAL(PBoolean, OnIncomingConnection(OpalConnection &, unsigned), false);
2044  P_REMOVE_VIRTUAL(PBoolean, OnIncomingConnection(OpalConnection &), false);
2045  P_REMOVE_VIRTUAL(PBoolean, OnStartMediaPatch(const OpalMediaPatch &), false);
2046  P_REMOVE_VIRTUAL_VOID(AdjustMediaFormats(const OpalConnection &, OpalMediaFormatList &) const);
2047  P_REMOVE_VIRTUAL_VOID(OnMessageReceived(const PURL&,const PString&,const PURL&,const PString&,const PString&,const PString&));
2048  P_REMOVE_VIRTUAL_VOID(OnRTPStatistics(const OpalConnection &, const OpalRTPSession &));
2049  P_REMOVE_VIRTUAL(PBoolean, IsMediaBypassPossible(const OpalConnection &,const OpalConnection &,unsigned) const, false);
2050 };
2051 
2052 
2053 PString OpalGetVersion();
2054 unsigned OpalGetMajorVersion();
2055 unsigned OpalGetMinorVersion();
2056 unsigned OpalGetBuildNumber();
2057 
2058 
2059 #endif // OPAL_OPAL_MANAGER_H
2060 
2061 
2062 // End of File ///////////////////////////////////////////////////////////////