OPAL  Version 3.12.9
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: 31066 $
28  * $Author: rjongbloed $
29  * $Date: 2013-12-11 17:10:18 +1100 (Wed, 11 Dec 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 
300 #if OPAL_HAS_MIXER
301 
315  virtual bool SetUpConference(
316  OpalCall & call,
317  const char * mixerURI = NULL,
318  const char * localURI = NULL
319  );
320 #endif // OPAL_HAS_MIXER
321 
327  virtual PBoolean HasCall(
328  const PString & token
329  ) { return activeCalls.FindWithLock(token, PSafeReference) != NULL; }
330 
333  PINDEX GetCallCount() const { return activeCalls.GetSize(); }
334 
337  PArray<PString> GetAllCalls() const { return activeCalls.GetKeys(); }
338 
347  PSafePtr<OpalCall> FindCallWithLock(
348  const PString & token,
349  PSafetyMode mode = PSafeReadWrite
350  ) const { return activeCalls.FindWithLock(token, mode); }
351 
360  virtual void OnEstablishedCall(
361  OpalCall & call
362  );
363 
370  virtual PBoolean IsCallEstablished(
371  const PString & token
372  );
373 
383  virtual PBoolean ClearCall(
384  const PString & token,
385  OpalConnection::CallEndReason reason = OpalConnection::EndedByLocalUser,
386  PSyncPoint * sync = NULL
387  );
388 
396  virtual PBoolean ClearCallSynchronous(
397  const PString & token,
398  OpalConnection::CallEndReason reason = OpalConnection::EndedByLocalUser
399  );
400 
406  virtual void ClearAllCalls(
407  OpalConnection::CallEndReason reason = OpalConnection::EndedByLocalUser,
408  PBoolean wait = true
409  );
410 
424  virtual void OnClearedCall(
425  OpalCall & call
426  );
427 
436  virtual OpalCall * CreateCall(
437  void * userData
438  );
439  OpalCall * InternalCreateCall(void * userData = NULL);
440 
449  virtual void DestroyCall(
450  OpalCall * call
451  );
452 
457  virtual PString GetNextToken(char prefix);
459 
460 
466  class RouteEntry : public PObject
467  {
468  PCLASSINFO(RouteEntry, PObject);
469  public:
470  RouteEntry(const PString & partyA, const PString & partyB, const PString & dest);
471  RouteEntry(const PString & spec);
472 
473  PObject * Clone() const { return new RouteEntry(*this); }
474  void PrintOn(ostream & strm) const;
475 
476  bool IsValid() const;
477  bool IsMatch(const PString & search) const;
478 
479  const PString & GetPartyA() const { return m_partyA; }
480  const PString & GetPartyB() const { return m_partyB; }
481  const PString & GetDestination() const { return m_destination; }
482 
483  protected:
484  PString m_partyA;
485  PString m_partyB;
486  PString m_destination;
487  PRegularExpression m_regex;
488 
489  void CompileRegEx();
490  };
491  PARRAY(RouteTable, RouteEntry);
492 
603  virtual PBoolean AddRouteEntry(
604  const PString & spec
605  );
606 
613  PBoolean SetRouteTable(
614  const PStringArray & specs
615  );
616 
621  void SetRouteTable(
622  const RouteTable & table
623  );
624 
627  const RouteTable & GetRouteTable() const { return m_routeTable; }
628 
636  virtual PString ApplyRouteTable(
637  const PString & source,
638  const PString & destination,
639  PINDEX & entry
640  );
641 
648  virtual bool OnRouteConnection(
649  PStringSet & routesTried,
650  const PString & a_party,
651  const PString & b_party,
652  OpalCall & call,
653  unsigned options,
654  OpalConnection::StringOptions * stringOptions
655  );
657 
658 
695  virtual PSafePtr<OpalConnection> MakeConnection(
696  OpalCall & call,
697  const PString & party,
698  void * userData = NULL,
699  unsigned int options = 0,
700  OpalConnection::StringOptions * stringOptions = NULL
701  );
702 
708  virtual void OnNewConnection(
709  OpalConnection & connection
710  );
711 
738  virtual PBoolean OnIncomingConnection(
739  OpalConnection & connection,
740  unsigned options,
741  OpalConnection::StringOptions * stringOptions
742  );
743 
749  virtual void OnApplyStringOptions(
750  OpalConnection & connection,
751  OpalConnection::StringOptions & stringOptions
752  );
753 
769  virtual void OnProceeding(
770  OpalConnection & connection
771  );
772 
789  virtual void OnAlerting(
790  OpalConnection & connection
791  );
792 
809  virtual OpalConnection::AnswerCallResponse OnAnswerCall(
810  OpalConnection & connection,
811  const PString & caller
812  );
813 
825  virtual void OnConnected(
826  OpalConnection & connection
827  );
828 
842  virtual void OnEstablished(
843  OpalConnection & connection
844  );
845 
861  virtual void OnReleased(
862  OpalConnection & connection
863  );
864 
871  virtual void OnHold(
872  OpalConnection & connection,
873  bool fromRemote,
874  bool onHold
875  );
876  virtual void OnHold(OpalConnection & connection); // For backward compatibility
877 
882  virtual PBoolean OnForwarded(
883  OpalConnection & connection,
884  const PString & remoteParty
885  );
886 
932  virtual bool OnTransferNotify(
933  OpalConnection & connection,
934  const PStringToString & info
935  );
937 
938 
949  bool transportable,
950  bool pcmAudio
951  ) const;
952 
962  virtual void AdjustMediaFormats(
963  bool local,
964  const OpalConnection & connection,
965  OpalMediaFormatList & mediaFormats
966  ) const;
967 
979  };
980 
994  const OpalConnection & source,
995  const OpalConnection & destination,
996  const OpalMediaType & mediaType
997  ) const;
998 
1014  virtual PBoolean OnOpenMediaStream(
1015  OpalConnection & connection,
1016  OpalMediaStream & stream
1017  );
1018 
1035  virtual bool OnLocalRTP(
1036  OpalConnection & connection1,
1037  OpalConnection & connection2,
1038  unsigned sessionID,
1039  bool opened
1040  ) const;
1041 
1067  bool SetMediaPassThrough(
1068  const PString & token1,
1069  const PString & token2,
1070  bool bypass,
1071  unsigned sessionID = 0,
1072  bool network = true
1073  );
1074  static bool SetMediaPassThrough(
1075  OpalConnection & connection1,
1076  OpalConnection & connection2,
1077  bool bypass,
1078  unsigned sessionID = 0
1079  );
1080 
1085  virtual void OnClosedMediaStream(
1086  const OpalMediaStream & stream
1087  );
1088 
1089 #if OPAL_VIDEO
1090 
1092  virtual PBoolean CreateVideoInputDevice(
1093  const OpalConnection & connection,
1094  const OpalMediaFormat & mediaFormat,
1095  PVideoInputDevice * & device,
1096  PBoolean & autoDelete
1097  );
1098 
1102  virtual PBoolean CreateVideoOutputDevice(
1103  const OpalConnection & connection,
1104  const OpalMediaFormat & mediaFormat,
1105  PBoolean preview,
1106  PVideoOutputDevice * & device,
1107  PBoolean & autoDelete
1108  );
1109 #endif
1110 
1118  virtual OpalMediaPatch * CreateMediaPatch(
1119  OpalMediaStream & source,
1120  PBoolean requiresPatchThread = true
1121  );
1122 
1129  virtual void OnStartMediaPatch(
1130  OpalConnection & connection,
1131  OpalMediaPatch & patch
1132  );
1133 
1136  virtual void OnStopMediaPatch(
1137  OpalConnection & connection,
1138  OpalMediaPatch & patch
1139  );
1140 
1156  virtual bool OnMediaFailed(
1157  OpalConnection & connection,
1158  unsigned sessionId,
1159  bool source
1160  );
1162 
1163 
1171  virtual void OnUserInputString(
1172  OpalConnection & connection,
1173  const PString & value
1174  );
1175 
1182  virtual void OnUserInputTone(
1183  OpalConnection & connection,
1184  char tone,
1185  int duration
1186  );
1187 
1190  virtual PString ReadUserInput(
1191  OpalConnection & connection,
1192  const char * terminators = "YX#\r\n",
1193  unsigned lastDigitTimeout = 4,
1194  unsigned firstDigitTimeout = 30
1195  );
1197 
1198 
1199 #if OPAL_HAS_MIXER
1200 
1210  virtual PBoolean StartRecording(
1211  const PString & callToken,
1212  const PFilePath & filename,
1213  const OpalRecordManager::Options & options = false
1214  );
1215 
1218  virtual bool IsRecording(
1219  const PString & callToken
1220  );
1221 
1226  virtual bool StopRecording(
1227  const PString & callToken
1228  );
1229 
1231 #endif
1232 
1233 
1234 #if OPAL_HAS_IM
1235 
1240  virtual void OnConversation(
1241  const OpalIMContext::ConversationInfo & info
1242  );
1243 
1253  virtual PBoolean Message(
1254  OpalIM & message
1255  );
1256 
1258  virtual PBoolean Message(
1259  const PString & to,
1260  const PString & body
1261  );
1262 
1264  virtual PBoolean Message(
1265  const PURL & to,
1266  const PString & type,
1267  const PString & body,
1268  PURL & from,
1269  PString & conversationId
1270  );
1271 
1277  virtual void OnMessageReceived(
1278  const OpalIM & message
1279  );
1280 
1285  virtual void OnMessageDisposition(
1286  const OpalIMContext::DispositionInfo & info
1287  );
1288 
1293  virtual void OnCompositionIndication(
1294  const OpalIMContext::CompositionInfo & info
1295  );
1297 #endif
1298 
1299 
1302 
1311  };
1312 
1323  virtual void OnMWIReceived(
1324  const PString & party,
1325  MessageWaitingType type,
1326  const PString & extraInfo
1327  );
1328 
1343  virtual bool GetConferenceStates(
1344  OpalConferenceStates & states,
1345  const PString & name = PString::Empty()
1346  ) const;
1347 
1357  virtual void OnConferenceStatusChanged(
1358  OpalEndPoint & endpoint,
1359  const PString & uri,
1361  );
1362 
1370  virtual bool OnChangedPresentationRole(
1371  OpalConnection & connection,
1372  const PString & newChairURI,
1373  bool request
1374  );
1376 
1377 
1380 #if OPAL_PTLIB_SSL
1381 
1393  virtual bool ApplySSLCredentials(
1394  const OpalEndPoint & ep,
1395  PSSLContext & context,
1396  bool create
1397  ) const;
1398 
1401  const PString & GetSSLCertificateAuthorityFiles() const { return m_caFiles; }
1402 
1405  void SetSSLCertificateAuthorityFiles(const PString & files) { m_caFiles = files; }
1406 
1409  const PString & GetSSLCertificateFile() const { return m_certificateFile; }
1410 
1413  void SetSSLCertificateFile(const PString & file) { m_certificateFile = file; }
1414 
1417  const PString & GetSSLPrivateKeyFile() const { return m_privateKeyFile; }
1418 
1421  void SetSSLPrivateKeyFile(const PString & file) { m_privateKeyFile = file; }
1422 
1425  void SetSSLAutoCreateCertificate(bool yes) { m_autoCreateCertificate = yes; }
1426 #endif
1427 
1434  virtual PBoolean IsLocalAddress(
1435  const PIPSocket::Address & remoteAddress
1436  ) const;
1437 
1455  virtual PBoolean IsRTPNATEnabled(
1456  OpalConnection & connection,
1457  const PIPSocket::Address & localAddr,
1458  const PIPSocket::Address & peerAddr,
1459  const PIPSocket::Address & signalAddr,
1460  PBoolean incoming
1461  );
1462 
1469  virtual PBoolean TranslateIPAddress(
1470  PIPSocket::Address & localAddress,
1471  const PIPSocket::Address & remoteAddress
1472  );
1473 
1474 #if P_NAT
1475 
1477  PNatStrategy & GetNatMethods() const { return *m_natMethods; }
1478 
1484  virtual PNatMethod * GetNatMethod(
1485  const PIPSocket::Address & remoteAddress = PIPSocket::GetDefaultIpAny()
1486  ) const;
1487 
1490  bool SetNATServer(
1491  const PString & method,
1492  const PString & server
1493  );
1494 
1497  PString GetNATServer() const
1498  {
1499  return (m_natMethod == NULL) ? PString::Empty() : m_natMethod->GetServer();
1500  }
1501 
1504  P_DEPRECATED PString GetTranslationHost() const;
1505 
1508  P_DEPRECATED bool SetTranslationHost(
1509  const PString & host
1510  );
1511 
1514  P_DEPRECATED PIPSocket::Address GetTranslationAddress() const;
1515 
1518  P_DEPRECATED void SetTranslationAddress(
1519  const PIPSocket::Address & address
1520  );
1521 
1524  P_DEPRECATED bool HasTranslationAddress() const;
1525 
1526 #ifdef P_STUN
1527 
1531  P_DEPRECATED PSTUNClient::NatTypes SetSTUNServer(
1532  const PString & server
1533  ) {
1534  return SetNATServer(PSTUNClient::GetNatMethodName(), server) ? m_natMethod->GetNatType() : PSTUNClient::UnknownNat;
1535  }
1536 
1539  P_DEPRECATED PString GetSTUNServer() const
1540  {
1541  return (dynamic_cast<PSTUNClient *>(m_natMethod) == NULL) ? PString::Empty() : m_natMethod->GetServer();
1542  }
1543 
1546  P_DEPRECATED PSTUNClient * GetSTUNClient() const { return dynamic_cast<PSTUNClient *>(m_natMethod); }
1547 #endif // P_STUN
1548 #endif // P_NAT
1549 
1552  WORD GetTCPPortBase() const { return tcpPorts.base; }
1553 
1556  WORD GetTCPPortMax() const { return tcpPorts.max; }
1557 
1560  void SetTCPPorts(unsigned tcpBase, unsigned tcpMax);
1561 
1564  WORD GetNextTCPPort();
1565 
1568  WORD GetUDPPortBase() const { return udpPorts.base; }
1569 
1572  WORD GetUDPPortMax() const { return udpPorts.max; }
1573 
1576  void SetUDPPorts(unsigned udpBase, unsigned udpMax);
1577 
1580  WORD GetNextUDPPort();
1581 
1584  WORD GetRtpIpPortBase() const { return rtpIpPorts.base; }
1585 
1588  WORD GetRtpIpPortMax() const { return rtpIpPorts.max; }
1589 
1592  void SetRtpIpPorts(unsigned udpBase, unsigned udpMax);
1593 
1596  WORD GetRtpIpPortPair();
1597 
1600  BYTE GetMediaTypeOfService() const;
1601 
1604  void SetMediaTypeOfService(unsigned tos);
1605 
1608  BYTE GetMediaTypeOfService(const OpalMediaType & type) const;
1609 
1612  void SetMediaTypeOfService(const OpalMediaType & type, unsigned tos);
1613 
1616  const PIPSocket::QoS & GetMediaQoS(const OpalMediaType & type) const;
1617 
1620  void SetMediaQoS(const OpalMediaType & type, const PIPSocket::QoS & qos);
1621 
1626  PINDEX GetMaxRtpPayloadSize() const { return rtpPayloadSizeMax; }
1627 
1633  PINDEX size,
1634  bool mtu = false
1635  ) { rtpPayloadSizeMax = size - (mtu ? (20+16+12) : 0); }
1636 
1640  PINDEX GetMaxRtpPacketSize() const { return rtpPacketSizeMax; }
1641 
1646  PINDEX size
1647  ) { rtpPacketSizeMax = size; }
1649 
1650 
1655  const OpalProductInfo & GetProductInfo() const { return productInfo; }
1656 
1659  void SetProductInfo(
1660  const OpalProductInfo & info,
1661  bool updateAll = true
1662  );
1663 
1666  const PString & GetDefaultUserName() const { return defaultUserName; }
1667 
1670  void SetDefaultUserName(
1671  const PString & name,
1672  bool updateAll = true
1673  );
1674 
1677  const PString & GetDefaultDisplayName() const { return defaultDisplayName; }
1678 
1681  void SetDefaultDisplayName(
1682  const PString & name,
1683  bool updateAll = true
1684  );
1685 
1691  const OpalConnection::StringOptions & stringOptions
1692  ) { m_defaultConnectionOptions = stringOptions; }
1693 
1694 #if OPAL_VIDEO
1695 
1696  //
1697  // these functions are deprecated and used only for backwards compatibility
1698  // applications should use OpalConnection::GetAutoStart() to check whether
1699  // a specific media type can be auto-started
1700  //
1701 
1704  bool CanAutoStartReceiveVideo() const { return (OpalMediaType::Video().GetAutoStart()&OpalMediaType::Receive) != 0; }
1705 
1708  void SetAutoStartReceiveVideo(bool can) { OpalMediaType::Video()->SetAutoStart(OpalMediaType::Receive, can); }
1709 
1712  bool CanAutoStartTransmitVideo() const { return (OpalMediaType::Video().GetAutoStart()&OpalMediaType::Transmit) != 0; }
1713 
1716  void SetAutoStartTransmitVideo(bool can) { OpalMediaType::Video()->SetAutoStart(OpalMediaType::Transmit, can); }
1717 
1718 #endif
1719 
1723  unsigned GetMinAudioJitterDelay() const { return minAudioJitterDelay; }
1724 
1728  unsigned GetMaxAudioJitterDelay() const { return maxAudioJitterDelay; }
1729 
1739  void SetAudioJitterDelay(
1740  unsigned minDelay,
1741  unsigned maxDelay
1742  );
1743 
1746  const PStringArray & GetMediaFormatOrder() const { return mediaFormatOrder; }
1747 
1750  void SetMediaFormatOrder(
1751  const PStringArray & order
1752  );
1753 
1759  const PStringArray & GetMediaFormatMask() const { return mediaFormatMask; }
1760 
1766  void SetMediaFormatMask(
1767  const PStringArray & mask //< New mask
1768  );
1769 
1773  const OpalSilenceDetector::Params & params
1774  ) { silenceDetectParams = params; }
1775 
1779 
1780 #if OPAL_AEC
1781 
1783  virtual void SetEchoCancelParams(
1784  const OpalEchoCanceler::Params & params
1785  ) { echoCancelParams = params; }
1786 
1789  const OpalEchoCanceler::Params & GetEchoCancelParams() const { return echoCancelParams; }
1790 #endif
1791 
1792 #if OPAL_VIDEO
1793 
1801  virtual PBoolean SetVideoInputDevice(
1802  const PVideoDevice::OpenArgs & deviceArgs
1803  );
1804 
1808  const PVideoDevice::OpenArgs & GetVideoInputDevice() const { return videoInputDevice; }
1809 
1817  virtual PBoolean SetVideoPreviewDevice(
1818  const PVideoDevice::OpenArgs & deviceArgs
1819  );
1820 
1824  const PVideoDevice::OpenArgs & GetVideoPreviewDevice() const { return videoPreviewDevice; }
1825 
1833  virtual PBoolean SetVideoOutputDevice(
1834  const PVideoDevice::OpenArgs & deviceArgs
1835  );
1836 
1840  const PVideoDevice::OpenArgs & GetVideoOutputDevice() const { return videoOutputDevice; }
1841 
1842 #endif
1843 
1844  PBoolean DetectInBandDTMFDisabled() const
1845  { return disableDetectInBandDTMF; }
1846 
1850  PBoolean mode
1851  ) { disableDetectInBandDTMF = mode; }
1852 
1855  const PTimeInterval & GetNoMediaTimeout() const { return m_noMediaTimeout; }
1856 
1860  const PTimeInterval & newInterval
1861  ) { m_noMediaTimeout = newInterval; }
1862 
1865  const PTimeInterval & GetSignalingTimeout() const { return m_signalingTimeout; }
1866 
1870  const PTimeInterval & newInterval
1871  ) { m_signalingTimeout = newInterval; }
1872 
1875  const PTimeInterval & GetTransportIdleTime() const { return m_transportIdleTime; }
1876 
1880  const PTimeInterval & newInterval
1881  ) { m_transportIdleTime = newInterval; }
1882 
1885  const PString & GetDefaultILSServer() const { return ilsServer; }
1886 
1890  const PString & server
1891  ) { ilsServer = server; }
1892 
1893 #if OPAL_SCRIPT
1894 
1939  PScriptLanguage * GetScript() const { return m_script; }
1940 
1943  bool RunScript(
1944  const PString & script,
1945  const char * language = "Lua"
1946  );
1947 #endif // OPAL_SCRIPT
1948 
1949 
1950  // needs to be public for gcc 3.4
1951  void GarbageCollection();
1952 
1953  // Decoupled event to avoid deadlocks, especially from patch threads
1954  void QueueDecoupledEvent(PSafeWork * work) { m_decoupledEventPool.AddWork(work); }
1955 
1956  protected:
1957  // Configuration variables
1959 
1962 
1963  typedef std::map<OpalMediaType, PIPSocket::QoS> MediaQoSMap;
1965 
1967 
1972  PStringArray mediaFormatOrder;
1973  PStringArray mediaFormatMask;
1975  PTimeInterval m_noMediaTimeout;
1976  PTimeInterval m_signalingTimeout;
1977  PTimeInterval m_transportIdleTime;
1978  PString ilsServer;
1979 
1981 #if OPAL_AEC
1982  OpalEchoCanceler::Params echoCancelParams;
1983 #endif
1984 
1985 #if OPAL_VIDEO
1986  PVideoDevice::OpenArgs videoInputDevice;
1987  PVideoDevice::OpenArgs videoPreviewDevice;
1988  PVideoDevice::OpenArgs videoOutputDevice;
1989 #endif
1990 
1991  struct PortInfo {
1992  void Set(
1993  unsigned base,
1994  unsigned max,
1995  unsigned range,
1996  unsigned dflt
1997  );
1998  WORD GetNext(
1999  unsigned increment
2000  );
2001 
2002  PMutex mutex;
2003  WORD base;
2004  WORD max;
2005  WORD current;
2007 
2008 #if OPAL_PTLIB_SSL
2009  PString m_caFiles;
2010  PFilePath m_certificateFile;
2011  PFilePath m_privateKeyFile;
2012  bool m_autoCreateCertificate;
2013 #endif
2014 
2015 #if P_NAT
2016  PNatStrategy * m_natMethods;
2017  PNatMethod * m_natMethod;
2018  PDECLARE_InterfaceNotifier(OpalManager, OnInterfaceChange);
2019  PInterfaceMonitor::Notifier m_onInterfaceChange;
2020 #endif
2021 
2022  RouteTable m_routeTable;
2024 
2025  // Dynamic variables
2026  PReadWriteMutex endpointsMutex;
2027  PList<OpalEndPoint> endpointList;
2028  std::map<PString, OpalEndPoint *> endpointMap;
2029 
2030  PAtomicInteger lastCallTokenID;
2031 
2032  class CallDict : public PSafeDictionary<PString, OpalCall>
2033  {
2034  public:
2035  CallDict(OpalManager & mgr) : manager(mgr) { }
2036  virtual void DeleteObject(PObject * object) const;
2038  } activeCalls;
2039 
2040 #if OPAL_HAS_PRESENCE
2041  PSafeDictionary<PString, OpalPresentity> m_presentities;
2042 #endif // OPAL_HAS_PRESENCE
2043 
2044  PAtomicInteger m_clearingAllCallsCount;
2046  PSyncPoint m_allCallsCleared;
2047  void InternalClearAllCalls(OpalConnection::CallEndReason reason, bool wait, bool first);
2048 
2052  PDECLARE_NOTIFIER(PThread, OpalManager, GarbageMain);
2053 
2054  friend OpalCall::OpalCall(OpalManager & mgr);
2055  friend void OpalCall::InternalOnClear();
2056 
2057  PSafeThreadPool m_decoupledEventPool;
2058 
2059 #if OPAL_SCRIPT
2060  PScriptLanguage * m_script;
2061 #endif
2062 
2063  private:
2064  P_REMOVE_VIRTUAL(OpalCall *,CreateCall(), 0);
2065  P_REMOVE_VIRTUAL(PBoolean, OnIncomingConnection(OpalConnection &, unsigned), false);
2066  P_REMOVE_VIRTUAL(PBoolean, OnIncomingConnection(OpalConnection &), false);
2067  P_REMOVE_VIRTUAL(PBoolean, OnStartMediaPatch(const OpalMediaPatch &), false);
2068  P_REMOVE_VIRTUAL_VOID(AdjustMediaFormats(const OpalConnection &, OpalMediaFormatList &) const);
2069  P_REMOVE_VIRTUAL_VOID(OnMessageReceived(const PURL&,const PString&,const PURL&,const PString&,const PString&,const PString&));
2070  P_REMOVE_VIRTUAL_VOID(OnRTPStatistics(const OpalConnection &, const OpalRTPSession &));
2071  P_REMOVE_VIRTUAL(PBoolean, IsMediaBypassPossible(const OpalConnection &,const OpalConnection &,unsigned) const, false);
2072 };
2073 
2074 
2075 PString OpalGetVersion();
2076 unsigned OpalGetMajorVersion();
2077 unsigned OpalGetMinorVersion();
2078 unsigned OpalGetBuildNumber();
2079 
2080 
2081 #endif // OPAL_OPAL_MANAGER_H
2082 
2083 
2084 // End of File ///////////////////////////////////////////////////////////////