OPAL  Version 3.14.3
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: 32530 $
28  * $Author: rjongbloed $
29  * $Date: 2014-08-15 13:41:56 +1000 (Fri, 15 Aug 2014) $
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_config.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;
63 class PSSLCertificate;
64 class PSSLPrivateKey;
65 
66 
67 #define OPAL_SCRIPT_CALL_TABLE_NAME "OpalCall"
68 
69 
70 class OpalConferenceState : public PObject
71 {
72  PCLASSINFO(OpalConferenceState, PObject);
73 public:
75  : m_active(true)
76  , m_locked(false)
77  , m_maxUsers(0)
78  { }
79 
80  enum ChangeType {
86  };
87  friend ostream & operator<<(ostream & strm, ChangeType type);
88 
89  PString m_internalURI;
90 
91  PString m_displayText;
92  PString m_subject;
93  PString m_notes;
94  PString m_keywords;
95  bool m_active;
96  bool m_locked;
97 
98  struct URI
99  {
100  PString m_uri;
101  PString m_displayText;
102  PString m_purpose;
105  };
106  typedef std::vector<URI> URIs;
107 
113  unsigned m_maxUsers;
114 
115  struct User
116  {
117  PString m_uri;
118  PString m_displayText;
119  PStringSet m_roles;
120  };
121  typedef std::vector<User> Users;
123 
124 #if P_EXPAT
125 
131  PXML m_xml;
132 #endif
133 };
134 
135 typedef std::list<OpalConferenceState> OpalConferenceStates;
136 
137 
154 class OpalManager : public PObject
155 {
156  PCLASSINFO(OpalManager, PObject);
157  public:
162  OpalManager();
163 
168  ~OpalManager();
170 
180  void AttachEndPoint(
181  OpalEndPoint * endpoint,
182  const PString & prefix = PString::Empty()
183  );
184 
188  void DetachEndPoint(
189  const PString & prefix
190  );
191  void DetachEndPoint(
192  OpalEndPoint * endpoint
193  );
194 
198  const PString & prefix
199  ) const;
200 
203  template <class T> T * FindEndPointAs(
204  const PString & prefix
205  ) const { return dynamic_cast<T *>(FindEndPoint(prefix)); }
206 
209  PList<OpalEndPoint> GetEndPoints() const;
210 
213  PStringList GetPrefixNames(
214  const OpalEndPoint * endpoint = NULL
215  ) const;
216 
221  virtual PStringList GetNetworkURIs(
222  const PString & name
223  ) const;
224 
230  void ShutDownEndpoints();
232 
233 
234 #if OPAL_HAS_PRESENCE
235 
243  virtual PSafePtr<OpalPresentity> AddPresentity(
244  const PString & presentity
245  );
246 
249  virtual PSafePtr<OpalPresentity> GetPresentity(
250  const PString & presentity,
251  PSafetyMode mode = PSafeReference
252  );
253 
256  virtual PStringList GetPresentities() const;
257 
260  virtual bool RemovePresentity(
261  const PString & presentity
262  );
264 #endif // OPAL_HAS_PRESENCE
265 
266 
285  virtual PSafePtr<OpalCall> SetUpCall(
286  const PString & partyA,
287  const PString & partyB,
288  void * userData = NULL,
289  unsigned options = 0,
290  OpalConnection::StringOptions * stringOptions = NULL
291  );
292  virtual PBoolean SetUpCall(
293  const PString & partyA,
294  const PString & partyB,
295  PString & token,
296  void * userData = NULL,
297  unsigned options = 0,
298  OpalConnection::StringOptions * stringOptions = NULL
299  );
300 
301 #if OPAL_HAS_MIXER
302 
316  virtual bool SetUpConference(
317  OpalCall & call,
318  const char * mixerURI = NULL,
319  const char * localURI = NULL
320  );
321 #endif // OPAL_HAS_MIXER
322 
328  virtual PBoolean HasCall(
329  const PString & token
330  ) { return activeCalls.FindWithLock(token, PSafeReference) != NULL; }
331 
334  PINDEX GetCallCount() const { return activeCalls.GetSize(); }
335 
338  PArray<PString> GetAllCalls() const { return activeCalls.GetKeys(); }
339 
348  PSafePtr<OpalCall> FindCallWithLock(
349  const PString & token,
350  PSafetyMode mode = PSafeReadWrite
351  ) const { return activeCalls.FindWithLock(token, mode); }
352 
364  virtual bool OnLocalIncomingCall(
365  OpalLocalConnection & connection
366  );
367 
375  virtual bool OnLocalOutgoingCall(
376  const OpalLocalConnection & connection
377  );
378 
387  virtual void OnEstablishedCall(
388  OpalCall & call
389  );
390 
397  virtual PBoolean IsCallEstablished(
398  const PString & token
399  );
400 
410  virtual PBoolean ClearCall(
411  const PString & token,
412  OpalConnection::CallEndReason reason = OpalConnection::EndedByLocalUser,
413  PSyncPoint * sync = NULL
414  );
415 
423  virtual PBoolean ClearCallSynchronous(
424  const PString & token,
425  OpalConnection::CallEndReason reason = OpalConnection::EndedByLocalUser
426  );
427 
433  virtual void ClearAllCalls(
434  OpalConnection::CallEndReason reason = OpalConnection::EndedByLocalUser,
435  PBoolean wait = true
436  );
437 
451  virtual void OnClearedCall(
452  OpalCall & call
453  );
454 
463  virtual OpalCall * CreateCall(
464  void * userData
465  );
466  OpalCall * InternalCreateCall(void * userData = NULL);
467 
476  virtual void DestroyCall(
477  OpalCall * call
478  );
479 
484  virtual PString GetNextToken(char prefix);
486 
487 
493  class RouteEntry : public PObject
494  {
495  PCLASSINFO(RouteEntry, PObject);
496  public:
497  RouteEntry(const PString & partyA, const PString & partyB, const PString & dest);
498  RouteEntry(const PString & spec);
499 
500  PObject * Clone() const { return new RouteEntry(*this); }
501  void PrintOn(ostream & strm) const;
502 
503  bool IsValid() const;
504  bool IsMatch(const PString & search) const;
505 
506  const PString & GetPartyA() const { return m_partyA; }
507  const PString & GetPartyB() const { return m_partyB; }
508  const PString & GetDestination() const { return m_destination; }
509 
510  protected:
511  PString m_partyA;
512  PString m_partyB;
513  PString m_destination;
514  PRegularExpression m_regex;
515 
516  void CompileRegEx();
517  };
518  PARRAY(RouteTable, RouteEntry);
519 
634  virtual PBoolean AddRouteEntry(
635  const PString & spec
636  );
637 
644  PBoolean SetRouteTable(
645  const PStringArray & specs
646  );
647 
652  void SetRouteTable(
653  const RouteTable & table
654  );
655 
658  const RouteTable & GetRouteTable() const { return m_routeTable; }
659 
667  virtual PString ApplyRouteTable(
668  const PString & source,
669  const PString & destination,
670  PINDEX & entry
671  );
672 
679  virtual bool OnRouteConnection(
680  PStringSet & routesTried,
681  const PString & a_party,
682  const PString & b_party,
683  OpalCall & call,
684  unsigned options,
685  OpalConnection::StringOptions * stringOptions
686  );
688 
689 
726  virtual PSafePtr<OpalConnection> MakeConnection(
727  OpalCall & call,
728  const PString & party,
729  void * userData = NULL,
730  unsigned int options = 0,
731  OpalConnection::StringOptions * stringOptions = NULL
732  );
733 
739  virtual void OnNewConnection(
740  OpalConnection & connection
741  );
742 
769  virtual PBoolean OnIncomingConnection(
770  OpalConnection & connection,
771  unsigned options,
772  OpalConnection::StringOptions * stringOptions
773  );
774 
780  virtual void OnApplyStringOptions(
781  OpalConnection & connection,
782  OpalConnection::StringOptions & stringOptions
783  );
784 
800  virtual void OnProceeding(
801  OpalConnection & connection
802  );
803 
820  virtual void OnAlerting(
821  OpalConnection & connection
822  );
823 
840  virtual OpalConnection::AnswerCallResponse OnAnswerCall(
841  OpalConnection & connection,
842  const PString & caller
843  );
844 
856  virtual void OnConnected(
857  OpalConnection & connection
858  );
859 
873  virtual void OnEstablished(
874  OpalConnection & connection
875  );
876 
892  virtual void OnReleased(
893  OpalConnection & connection
894  );
895 
902  virtual void OnHold(
903  OpalConnection & connection,
904  bool fromRemote,
905  bool onHold
906  );
907  virtual void OnHold(OpalConnection & connection); // For backward compatibility
908 
913  virtual PBoolean OnForwarded(
914  OpalConnection & connection,
915  const PString & remoteParty
916  );
917 
963  virtual bool OnTransferNotify(
964  OpalConnection & connection,
965  const PStringToString & info
966  );
968 
969 
980  bool transportable,
981  bool pcmAudio
982  ) const;
983 
993  virtual void AdjustMediaFormats(
994  bool local,
995  const OpalConnection & connection,
996  OpalMediaFormatList & mediaFormats
997  ) const;
998 
1000  P_DECLARE_TRACED_ENUM(MediaTransferMode,
1001  MediaTransferBypass,
1004  MediaTransferForward,
1007  MediaTransferTranscode
1010  );
1011 
1024  virtual MediaTransferMode GetMediaTransferMode(
1025  const OpalConnection & source,
1026  const OpalConnection & destination,
1027  const OpalMediaType & mediaType
1028  ) const;
1029 
1039  virtual bool GetMediaTransportAddresses(
1040  const OpalConnection & source,
1041  const OpalConnection & destination,
1042  const OpalMediaType & mediaType,
1043  OpalTransportAddressArray & transports
1044  ) const;
1045 
1061  virtual PBoolean OnOpenMediaStream(
1062  OpalConnection & connection,
1063  OpalMediaStream & stream
1064  );
1065 
1082  virtual bool OnLocalRTP(
1083  OpalConnection & connection1,
1084  OpalConnection & connection2,
1085  unsigned sessionID,
1086  bool opened
1087  ) const;
1088 
1114  bool SetMediaPassThrough(
1115  const PString & token1,
1116  const PString & token2,
1117  bool bypass,
1118  unsigned sessionID = 0,
1119  bool network = true
1120  );
1121  static bool SetMediaPassThrough(
1122  OpalConnection & connection1,
1123  OpalConnection & connection2,
1124  bool bypass,
1125  unsigned sessionID = 0
1126  );
1127 
1132  virtual void OnClosedMediaStream(
1133  const OpalMediaStream & stream
1134  );
1135 
1140  virtual void OnFailedMediaStream(
1141  OpalConnection & connection,
1142  bool fromRemote,
1143  const PString & reason
1144  );
1145 
1146 #if OPAL_VIDEO
1147 
1149  virtual PBoolean CreateVideoInputDevice(
1150  const OpalConnection & connection,
1151  const OpalMediaFormat & mediaFormat,
1152  PVideoInputDevice * & device,
1153  PBoolean & autoDelete
1154  );
1155 
1159  virtual PBoolean CreateVideoOutputDevice(
1160  const OpalConnection & connection,
1161  const OpalMediaFormat & mediaFormat,
1162  PBoolean preview,
1163  PVideoOutputDevice * & device,
1164  PBoolean & autoDelete
1165  );
1166 
1169  virtual bool CreateVideoInputDevice(
1170  const OpalConnection & connection,
1171  const PVideoDevice::OpenArgs & args,
1172  PVideoInputDevice * & device,
1173  PBoolean & autoDelete
1174  );
1175 
1179  virtual bool CreateVideoOutputDevice(
1180  const OpalConnection & connection,
1181  const PVideoDevice::OpenArgs & args,
1182  PVideoOutputDevice * & device,
1183  PBoolean & autoDelete
1184  );
1185 #endif // OPAL_VIDEO
1186 
1194  virtual OpalMediaPatch * CreateMediaPatch(
1195  OpalMediaStream & source,
1196  PBoolean requiresPatchThread = true
1197  );
1198 
1205  virtual void OnStartMediaPatch(
1206  OpalConnection & connection,
1207  OpalMediaPatch & patch
1208  );
1209 
1212  virtual void OnStopMediaPatch(
1213  OpalConnection & connection,
1214  OpalMediaPatch & patch
1215  );
1216 
1232  virtual bool OnMediaFailed(
1233  OpalConnection & connection,
1234  unsigned sessionId,
1235  bool source
1236  );
1238 
1239 
1247  virtual void OnUserInputString(
1248  OpalConnection & connection,
1249  const PString & value
1250  );
1251 
1266  virtual void OnUserInputTone(
1267  OpalConnection & connection,
1268  char tone,
1269  int duration
1270  );
1271 
1274  virtual PString ReadUserInput(
1275  OpalConnection & connection,
1276  const char * terminators = "YX#\r\n",
1277  unsigned lastDigitTimeout = 4,
1278  unsigned firstDigitTimeout = 30
1279  );
1281 
1282 
1283 #if OPAL_HAS_MIXER
1284 
1294  virtual PBoolean StartRecording(
1295  const PString & callToken,
1296  const PFilePath & filename,
1297  const OpalRecordManager::Options & options = false
1298  );
1299 
1302  virtual bool IsRecording(
1303  const PString & callToken
1304  );
1305 
1310  virtual bool StopRecording(
1311  const PString & callToken
1312  );
1313 
1315 #endif
1316 
1317 
1318 #if OPAL_HAS_IM
1319 
1324  virtual void OnConversation(
1325  const OpalIMContext::ConversationInfo & info
1326  );
1327 
1337  virtual PBoolean Message(
1338  OpalIM & message
1339  );
1340 
1342  virtual PBoolean Message(
1343  const PString & to,
1344  const PString & body
1345  );
1346 
1348  virtual PBoolean Message(
1349  const PURL & to,
1350  const PString & type,
1351  const PString & body,
1352  PURL & from,
1353  PString & conversationId
1354  );
1355 
1361  virtual void OnMessageReceived(
1362  const OpalIM & message
1363  );
1364 
1369  virtual void OnMessageDisposition(
1370  const OpalIMContext::DispositionInfo & info
1371  );
1372 
1377  virtual void OnCompositionIndication(
1378  const OpalIMContext::CompositionInfo & info
1379  );
1381 #endif
1382 
1383 
1386 
1395  };
1396 
1407  virtual void OnMWIReceived(
1408  const PString & party,
1409  MessageWaitingType type,
1410  const PString & extraInfo
1411  );
1412 
1427  virtual bool GetConferenceStates(
1428  OpalConferenceStates & states,
1429  const PString & name = PString::Empty()
1430  ) const;
1431 
1441  virtual void OnConferenceStatusChanged(
1442  OpalEndPoint & endpoint,
1443  const PString & uri,
1445  );
1446 
1454  virtual bool OnChangedPresentationRole(
1455  OpalConnection & connection,
1456  const PString & newChairURI,
1457  bool request
1458  );
1460 
1461 
1464 #if OPAL_PTLIB_SSL
1465 
1477  virtual bool ApplySSLCredentials(
1478  const OpalEndPoint & ep,
1479  PSSLContext & context,
1480  bool create
1481  ) const;
1482 
1485  const PString & GetSSLCertificateAuthorityFiles() const { return m_caFiles; }
1486 
1489  void SetSSLCertificateAuthorityFiles(const PString & files) { m_caFiles = files; }
1490 
1493  const PString & GetSSLCertificateFile() const { return m_certificateFile; }
1494 
1497  void SetSSLCertificateFile(const PString & file) { m_certificateFile = file; }
1498 
1501  const PString & GetSSLPrivateKeyFile() const { return m_privateKeyFile; }
1502 
1505  void SetSSLPrivateKeyFile(const PString & file) { m_privateKeyFile = file; }
1506 
1509  void SetSSLAutoCreateCertificate(bool yes) { m_autoCreateCertificate = yes; }
1510 #endif
1511 
1518  virtual PBoolean IsLocalAddress(
1519  const PIPSocket::Address & remoteAddress
1520  ) const;
1521 
1539  virtual PBoolean IsRTPNATEnabled(
1540  OpalConnection & connection,
1541  const PIPSocket::Address & localAddr,
1542  const PIPSocket::Address & peerAddr,
1543  const PIPSocket::Address & signalAddr,
1544  PBoolean incoming
1545  );
1546 
1553  virtual PBoolean TranslateIPAddress(
1554  PIPSocket::Address & localAddress,
1555  const PIPSocket::Address & remoteAddress
1556  );
1557 
1558 #if OPAL_PTLIB_NAT
1559 
1561  PNatMethods & GetNatMethods() const { return *m_natMethods; }
1562 
1565  bool SetNATServer(
1566  const PString & method,
1567  const PString & server,
1568  bool active = true,
1569  unsigned priority = 0 // Zero is no change
1570  );
1571 
1574  PString GetNATServer(
1575  const PString & method = PString::Empty()
1576  ) const;
1577 
1578  // Backward compatibility
1579  void SetTranslationAddress(const PString & addr) { SetNATServer("Fixed", addr); }
1580  PNatMethod::NatTypes SetSTUNServer(const PString & addr)
1581  { return SetNATServer("STUN", addr) ? GetNatMethods().GetMethodByName("STUN")->GetNatType() : PNatMethod::UnknownNat; }
1582 #endif // OPAL_PTLIB_NAT
1583 
1586  WORD GetTCPPortBase() const { return m_tcpPorts.GetBase(); }
1587 
1590  WORD GetTCPPortMax() const { return m_tcpPorts.GetMax(); }
1591 
1594  void SetTCPPorts(unsigned tcpBase, unsigned tcpMax);
1595 
1598  PIPSocket::PortRange & GetTCPPortRange() { return m_tcpPorts; }
1599  const PIPSocket::PortRange & GetTCPPortRange() const { return m_tcpPorts; }
1600 
1603  WORD GetUDPPortBase() const { return m_udpPorts.GetBase(); }
1604 
1607  WORD GetUDPPortMax() const { return m_udpPorts.GetMax(); }
1608 
1609 
1612  void SetUDPPorts(unsigned udpBase, unsigned udpMax);
1613 
1616  PIPSocket::PortRange & GetUDPPortRange() { return m_udpPorts; }
1617  const PIPSocket::PortRange & GetUDPPortRange() const { return m_udpPorts; }
1618 
1621  WORD GetRtpIpPortBase() const { return m_rtpIpPorts.GetBase(); }
1622 
1625  WORD GetRtpIpPortMax() const { return m_rtpIpPorts.GetMax(); }
1626 
1629  void SetRtpIpPorts(unsigned udpBase, unsigned udpMax);
1630 
1633  PIPSocket::PortRange & GetRtpIpPortRange() { return m_rtpIpPorts; }
1634  const PIPSocket::PortRange & GetRtpIpPortRange() const { return m_rtpIpPorts; }
1635 
1638  BYTE GetMediaTypeOfService() const;
1639 
1642  void SetMediaTypeOfService(unsigned tos);
1643 
1646  BYTE GetMediaTypeOfService(const OpalMediaType & type) const;
1647 
1650  void SetMediaTypeOfService(const OpalMediaType & type, unsigned tos);
1651 
1654  const PIPSocket::QoS & GetMediaQoS(const OpalMediaType & type) const;
1655 
1658  void SetMediaQoS(const OpalMediaType & type, const PIPSocket::QoS & qos);
1659 
1664  PINDEX GetMaxRtpPayloadSize() const { return rtpPayloadSizeMax; }
1665 
1671  PINDEX size,
1672  bool mtu = false
1673  ) { rtpPayloadSizeMax = size - (mtu ? (20+16+12) : 0); }
1674 
1678  PINDEX GetMaxRtpPacketSize() const { return rtpPacketSizeMax; }
1679 
1684  PINDEX size
1685  ) { rtpPacketSizeMax = size; }
1687 
1688 
1693  const OpalProductInfo & GetProductInfo() const { return productInfo; }
1694 
1697  void SetProductInfo(
1698  const OpalProductInfo & info,
1699  bool updateAll = true
1700  );
1701 
1704  const PString & GetDefaultUserName() const { return defaultUserName; }
1705 
1708  void SetDefaultUserName(
1709  const PString & name,
1710  bool updateAll = true
1711  );
1712 
1715  const PString & GetDefaultDisplayName() const { return defaultDisplayName; }
1716 
1719  void SetDefaultDisplayName(
1720  const PString & name,
1721  bool updateAll = true
1722  );
1723 
1729  const OpalConnection::StringOptions & stringOptions
1730  ) { m_defaultConnectionOptions = stringOptions; }
1731 
1732 #if OPAL_VIDEO
1733 
1734  //
1735  // these functions are deprecated and used only for backwards compatibility
1736  // applications should use OpalConnection::GetAutoStart() to check whether
1737  // a specific media type can be auto-started
1738  //
1739 
1742  bool CanAutoStartReceiveVideo() const { return (OpalMediaType::Video().GetAutoStart()&OpalMediaType::Receive) != 0; }
1743 
1746  void SetAutoStartReceiveVideo(bool can) { OpalMediaType::Video()->SetAutoStart(OpalMediaType::Receive, can); }
1747 
1750  bool CanAutoStartTransmitVideo() const { return (OpalMediaType::Video().GetAutoStart()&OpalMediaType::Transmit) != 0; }
1751 
1754  void SetAutoStartTransmitVideo(bool can) { OpalMediaType::Video()->SetAutoStart(OpalMediaType::Transmit, can); }
1755 
1756 #endif
1757 
1761  unsigned GetMinAudioJitterDelay() const { return minAudioJitterDelay; }
1762 
1766  unsigned GetMaxAudioJitterDelay() const { return maxAudioJitterDelay; }
1767 
1777  void SetAudioJitterDelay(
1778  unsigned minDelay,
1779  unsigned maxDelay
1780  );
1781 
1784  const PStringArray & GetMediaFormatOrder() const { return mediaFormatOrder; }
1785 
1788  void SetMediaFormatOrder(
1789  const PStringArray & order
1790  );
1791 
1797  const PStringArray & GetMediaFormatMask() const { return mediaFormatMask; }
1798 
1804  void SetMediaFormatMask(
1805  const PStringArray & mask //< New mask
1806  );
1807 
1811  const OpalSilenceDetector::Params & params
1812  ) { silenceDetectParams = params; }
1813 
1817 
1818 #if OPAL_AEC
1819 
1821  virtual void SetEchoCancelParams(
1822  const OpalEchoCanceler::Params & params
1823  ) { echoCancelParams = params; }
1824 
1827  const OpalEchoCanceler::Params & GetEchoCancelParams() const { return echoCancelParams; }
1828 #endif
1829 
1830 #if OPAL_VIDEO
1831 
1836  virtual bool SetVideoInputDevice(
1837  const PVideoDevice::OpenArgs & deviceArgs,
1838  OpalVideoFormat::ContentRole role = OpalVideoFormat::eNoRole
1839  );
1840 
1843  const PVideoDevice::OpenArgs & GetVideoInputDevice(
1844  OpalVideoFormat::ContentRole role = OpalVideoFormat::eNoRole
1845  ) const { return m_videoInputDevice[role]; }
1846 
1854  virtual PBoolean SetVideoPreviewDevice(
1855  const PVideoDevice::OpenArgs & deviceArgs,
1856  OpalVideoFormat::ContentRole role = OpalVideoFormat::eNoRole
1857  );
1858 
1862  const PVideoDevice::OpenArgs & GetVideoPreviewDevice(
1863  OpalVideoFormat::ContentRole role = OpalVideoFormat::eNoRole
1864  ) const { return m_videoPreviewDevice[role]; }
1865 
1873  virtual PBoolean SetVideoOutputDevice(
1874  const PVideoDevice::OpenArgs & deviceArgs,
1875  OpalVideoFormat::ContentRole role = OpalVideoFormat::eNoRole
1876  );
1877 
1881  const PVideoDevice::OpenArgs & GetVideoOutputDevice(
1882  OpalVideoFormat::ContentRole role = OpalVideoFormat::eNoRole
1883  ) const { return m_videoOutputDevice[role]; }
1884 
1885 #endif
1886 
1887  PBoolean DetectInBandDTMFDisabled() const
1888  { return disableDetectInBandDTMF; }
1889 
1893  PBoolean mode
1894  ) { disableDetectInBandDTMF = mode; }
1895 
1898  const PTimeInterval & GetNoMediaTimeout() const { return m_noMediaTimeout; }
1899 
1903  const PTimeInterval & newInterval
1904  ) { m_noMediaTimeout = newInterval; }
1905 
1908  const PTimeInterval & GetSignalingTimeout() const { return m_signalingTimeout; }
1909 
1913  const PTimeInterval & newInterval
1914  ) { m_signalingTimeout = newInterval; }
1915 
1918  const PTimeInterval & GetTransportIdleTime() const { return m_transportIdleTime; }
1919 
1923  const PTimeInterval & newInterval
1924  ) { m_transportIdleTime = newInterval; }
1925 
1928  const PTimeInterval & GetNatKeepAliveTime() const { return m_natKeepAliveTime; }
1929 
1933  const PTimeInterval & newInterval
1934  ) { m_natKeepAliveTime = newInterval; }
1935 
1938  const PString & GetDefaultILSServer() const { return ilsServer; }
1939 
1943  const PString & server
1944  ) { ilsServer = server; }
1945 
1946 #if OPAL_SCRIPT
1947 
1992  PScriptLanguage * GetScript() const { return m_script; }
1993 
1996  bool RunScript(
1997  const PString & script,
1998  const char * language = "Lua"
1999  );
2000 #endif // OPAL_SCRIPT
2001 
2002 
2003  // needs to be public for gcc 3.4
2004  void GarbageCollection();
2005 
2006  // Decoupled event to avoid deadlocks, especially from patch threads
2007  void QueueDecoupledEvent(PSafeWork * work) { m_decoupledEventPool.AddWork(work); }
2008 
2009  protected:
2010  // Configuration variables
2012 
2015 
2016  typedef std::map<OpalMediaType, PIPSocket::QoS> MediaQoSMap;
2018 
2020 
2025  PStringArray mediaFormatOrder;
2026  PStringArray mediaFormatMask;
2028  PTimeInterval m_noMediaTimeout;
2029  PTimeInterval m_signalingTimeout;
2030  PTimeInterval m_transportIdleTime;
2031  PTimeInterval m_natKeepAliveTime;
2032  PString ilsServer;
2033 
2035 #if OPAL_AEC
2036  OpalEchoCanceler::Params echoCancelParams;
2037 #endif
2038 
2039 #if OPAL_VIDEO
2040  PVideoDevice::OpenArgs m_videoInputDevice[OpalVideoFormat::NumContentRole];
2041  PVideoDevice::OpenArgs m_videoPreviewDevice[OpalVideoFormat::NumContentRole];
2042  PVideoDevice::OpenArgs m_videoOutputDevice[OpalVideoFormat::NumContentRole];
2043 #endif
2044 
2045  PIPSocket::PortRange m_tcpPorts, m_udpPorts, m_rtpIpPorts;
2046 
2047 #if OPAL_PTLIB_SSL
2048  PString m_caFiles;
2049  PFilePath m_certificateFile;
2050  PFilePath m_privateKeyFile;
2051  bool m_autoCreateCertificate;
2052 #endif
2053 
2054 #if OPAL_PTLIB_NAT
2055  PNatMethods * m_natMethods;
2056  PDECLARE_InterfaceNotifier(OpalManager, OnInterfaceChange);
2057  PInterfaceMonitor::Notifier m_onInterfaceChange;
2058 #endif
2059 
2060  RouteTable m_routeTable;
2062 
2063  // Dynamic variables
2064  PReadWriteMutex endpointsMutex;
2065  PList<OpalEndPoint> endpointList;
2066  std::map<PString, OpalEndPoint *> endpointMap;
2067 
2068  PAtomicInteger lastCallTokenID;
2069 
2070  class CallDict : public PSafeDictionary<PString, OpalCall>
2071  {
2072  public:
2073  CallDict(OpalManager & mgr) : manager(mgr) { }
2074  virtual void DeleteObject(PObject * object) const;
2076  } activeCalls;
2077 
2078 #if OPAL_HAS_PRESENCE
2079  PSafeDictionary<PString, OpalPresentity> m_presentities;
2080 #endif // OPAL_HAS_PRESENCE
2081 
2082  PAtomicInteger m_clearingAllCallsCount;
2084  PSyncPoint m_allCallsCleared;
2085  void InternalClearAllCalls(OpalConnection::CallEndReason reason, bool wait, bool first);
2086 
2090  PDECLARE_NOTIFIER(PThread, OpalManager, GarbageMain);
2091 
2092  friend OpalCall::OpalCall(OpalManager & mgr);
2093  friend void OpalCall::InternalOnClear();
2094 
2095  PSafeThreadPool m_decoupledEventPool;
2096 
2097 #if OPAL_SCRIPT
2098  PScriptLanguage * m_script;
2099 #endif
2100 
2101  private:
2102  P_REMOVE_VIRTUAL(OpalCall *,CreateCall(), 0);
2103  P_REMOVE_VIRTUAL(PBoolean, OnIncomingConnection(OpalConnection &, unsigned), false);
2104  P_REMOVE_VIRTUAL(PBoolean, OnIncomingConnection(OpalConnection &), false);
2105  P_REMOVE_VIRTUAL(PBoolean, OnStartMediaPatch(const OpalMediaPatch &), false);
2106  P_REMOVE_VIRTUAL_VOID(AdjustMediaFormats(const OpalConnection &, OpalMediaFormatList &) const);
2107  P_REMOVE_VIRTUAL_VOID(OnMessageReceived(const PURL&,const PString&,const PURL&,const PString&,const PString&,const PString&));
2108  P_REMOVE_VIRTUAL_VOID(OnRTPStatistics(const OpalConnection &, const OpalRTPSession &));
2109  P_REMOVE_VIRTUAL(PBoolean, IsMediaBypassPossible(const OpalConnection &,const OpalConnection &,unsigned) const, false);
2110 #if OPAL_PTLIB_NAT
2111  P_REMOVE_VIRTUAL(PNatMethod *, GetNatMethod(const PIPSocket::Address &) const, NULL);
2112 #endif
2113  P_REMOVE_VIRTUAL(bool,OnLocalIncomingCall(OpalCall &),false);
2114  P_REMOVE_VIRTUAL(bool,OnLocalOutgoingCall(OpalCall &),false);
2115 };
2116 
2117 
2118 PString OpalGetVersion();
2119 unsigned OpalGetMajorVersion();
2120 unsigned OpalGetMinorVersion();
2121 unsigned OpalGetBuildNumber();
2122 
2123 
2124 #endif // OPAL_OPAL_MANAGER_H
2125 
2126 
2127 // End of File ///////////////////////////////////////////////////////////////