00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef OPAL_OPAL_MANAGER_H
00033 #define OPAL_OPAL_MANAGER_H
00034
00035 #ifdef P_USE_PRAGMA
00036 #pragma interface
00037 #endif
00038
00039 #include <opal/buildopts.h>
00040
00041 #include <opal/pres_ent.h>
00042 #include <opal/call.h>
00043 #include <opal/connection.h>
00044 #include <opal/guid.h>
00045 #include <codec/silencedetect.h>
00046 #include <codec/echocancel.h>
00047 #include <im/im.h>
00048
00049 #include <ptclib/pstun.h>
00050 #include <ptclib/url.h>
00051 #include <ptclib/pxml.h>
00052 #include <ptclib/threadpool.h>
00053
00054 #if OPAL_VIDEO
00055
00056 #include <ptlib/videoio.h>
00057 #endif
00058
00059
00060 class OpalEndPoint;
00061 class OpalMediaPatch;
00062 class PSSLCertificate;
00063 class PSSLPrivateKey;
00064
00065
00066 #define OPAL_SCRIPT_CALL_TABLE_NAME "OpalCall"
00067
00068
00069 class OpalConferenceState : public PObject
00070 {
00071 PCLASSINFO(OpalConferenceState, PObject);
00072 public:
00073 OpalConferenceState()
00074 : m_active(true)
00075 , m_locked(false)
00076 , m_maxUsers(0)
00077 { }
00078
00079 enum ChangeType {
00080 Created,
00081 Destroyed,
00082 UserAdded,
00083 UserRemoved,
00084 NumChangeTypes
00085 };
00086 friend ostream & operator<<(ostream & strm, ChangeType type);
00087
00088 PString m_internalURI;
00089
00090 PString m_displayText;
00091 PString m_subject;
00092 PString m_notes;
00093 PString m_keywords;
00094 bool m_active;
00095 bool m_locked;
00096
00097 struct URI
00098 {
00099 PString m_uri;
00100 PString m_displayText;
00101 PString m_purpose;
00104 };
00105 typedef std::vector<URI> URIs;
00106
00107 URIs m_accessURI;
00108 URIs m_serviceURI;
00112 unsigned m_maxUsers;
00113
00114 struct User
00115 {
00116 PString m_uri;
00117 PString m_displayText;
00118 PStringSet m_roles;
00119 };
00120 typedef std::vector<User> Users;
00121 Users m_users;
00122
00123 #if P_EXPAT
00124
00130 PXML m_xml;
00131 #endif
00132 };
00133
00134 typedef std::list<OpalConferenceState> OpalConferenceStates;
00135
00136
00153 class OpalManager : public PObject
00154 {
00155 PCLASSINFO(OpalManager, PObject);
00156 public:
00161 OpalManager();
00162
00167 ~OpalManager();
00169
00179 void AttachEndPoint(
00180 OpalEndPoint * endpoint,
00181 const PString & prefix = PString::Empty()
00182 );
00183
00187 void DetachEndPoint(
00188 const PString & prefix
00189 );
00190 void DetachEndPoint(
00191 OpalEndPoint * endpoint
00192 );
00193
00196 OpalEndPoint * FindEndPoint(
00197 const PString & prefix
00198 );
00199
00202 template <class T> T * FindEndPointAs(
00203 const PString & prefix
00204 ) { return dynamic_cast<T *>(FindEndPoint(prefix)); }
00205
00208 PList<OpalEndPoint> GetEndPoints() const;
00209
00212 PStringList GetPrefixNames(
00213 const OpalEndPoint * endpoint = NULL
00214 ) const;
00215
00220 virtual PStringList GetNetworkURIs(
00221 const PString & name
00222 ) const;
00223
00229 void ShutDownEndpoints();
00231
00232
00233 #if OPAL_HAS_PRESENCE
00234
00242 virtual PSafePtr<OpalPresentity> AddPresentity(
00243 const PString & presentity
00244 );
00245
00248 virtual PSafePtr<OpalPresentity> GetPresentity(
00249 const PString & presentity,
00250 PSafetyMode mode = PSafeReference
00251 );
00252
00255 virtual PStringList GetPresentities() const;
00256
00259 virtual bool RemovePresentity(
00260 const PString & presentity
00261 );
00263 #endif // OPAL_HAS_PRESENCE
00264
00265
00284 virtual PSafePtr<OpalCall> SetUpCall(
00285 const PString & partyA,
00286 const PString & partyB,
00287 void * userData = NULL,
00288 unsigned options = 0,
00289 OpalConnection::StringOptions * stringOptions = NULL
00290 );
00291 virtual PBoolean SetUpCall(
00292 const PString & partyA,
00293 const PString & partyB,
00294 PString & token,
00295 void * userData = NULL,
00296 unsigned options = 0,
00297 OpalConnection::StringOptions * stringOptions = NULL
00298 );
00299
00305 virtual PBoolean HasCall(
00306 const PString & token
00307 ) { return activeCalls.FindWithLock(token, PSafeReference) != NULL; }
00308
00311 PINDEX GetCallCount() const { return activeCalls.GetSize(); }
00312
00315 PArray<PString> GetAllCalls() const { return activeCalls.GetKeys(); }
00316
00325 PSafePtr<OpalCall> FindCallWithLock(
00326 const PString & token,
00327 PSafetyMode mode = PSafeReadWrite
00328 ) const { return activeCalls.FindWithLock(token, mode); }
00329
00338 virtual void OnEstablishedCall(
00339 OpalCall & call
00340 );
00341
00348 virtual PBoolean IsCallEstablished(
00349 const PString & token
00350 );
00351
00361 virtual PBoolean ClearCall(
00362 const PString & token,
00363 OpalConnection::CallEndReason reason = OpalConnection::EndedByLocalUser,
00364 PSyncPoint * sync = NULL
00365 );
00366
00374 virtual PBoolean ClearCallSynchronous(
00375 const PString & token,
00376 OpalConnection::CallEndReason reason = OpalConnection::EndedByLocalUser
00377 );
00378
00384 virtual void ClearAllCalls(
00385 OpalConnection::CallEndReason reason = OpalConnection::EndedByLocalUser,
00386 PBoolean wait = true
00387 );
00388
00402 virtual void OnClearedCall(
00403 OpalCall & call
00404 );
00405
00414 virtual OpalCall * CreateCall(
00415 void * userData
00416 );
00417 OpalCall * InternalCreateCall();
00418
00427 virtual void DestroyCall(
00428 OpalCall * call
00429 );
00430
00435 virtual PString GetNextToken(char prefix);
00437
00438
00444 class RouteEntry : public PObject
00445 {
00446 PCLASSINFO(RouteEntry, PObject);
00447 public:
00448 RouteEntry(const PString & partyA, const PString & partyB, const PString & dest);
00449 RouteEntry(const PString & spec);
00450
00451 PObject * Clone() const { return new RouteEntry(*this); }
00452 void PrintOn(ostream & strm) const;
00453
00454 bool IsValid() const;
00455 bool IsMatch(const PString & search) const;
00456
00457 const PString & GetPartyA() const { return m_partyA; }
00458 const PString & GetPartyB() const { return m_partyB; }
00459 const PString & GetDestination() const { return m_destination; }
00460
00461 protected:
00462 PString m_partyA;
00463 PString m_partyB;
00464 PString m_destination;
00465 PRegularExpression m_regex;
00466
00467 void CompileRegEx();
00468 };
00469 PARRAY(RouteTable, RouteEntry);
00470
00581 virtual PBoolean AddRouteEntry(
00582 const PString & spec
00583 );
00584
00591 PBoolean SetRouteTable(
00592 const PStringArray & specs
00593 );
00594
00599 void SetRouteTable(
00600 const RouteTable & table
00601 );
00602
00605 const RouteTable & GetRouteTable() const { return m_routeTable; }
00606
00614 virtual PString ApplyRouteTable(
00615 const PString & source,
00616 const PString & destination,
00617 PINDEX & entry
00618 );
00619
00626 virtual bool OnRouteConnection(
00627 PStringSet & routesTried,
00628 const PString & a_party,
00629 const PString & b_party,
00630 OpalCall & call,
00631 unsigned options,
00632 OpalConnection::StringOptions * stringOptions
00633 );
00635
00636
00673 virtual PSafePtr<OpalConnection> MakeConnection(
00674 OpalCall & call,
00675 const PString & party,
00676 void * userData = NULL,
00677 unsigned int options = 0,
00678 OpalConnection::StringOptions * stringOptions = NULL
00679 );
00680
00686 virtual void OnNewConnection(
00687 OpalConnection & connection
00688 );
00689
00716 virtual PBoolean OnIncomingConnection(
00717 OpalConnection & connection,
00718 unsigned options,
00719 OpalConnection::StringOptions * stringOptions
00720 );
00721
00727 virtual void OnApplyStringOptions(
00728 OpalConnection & connection,
00729 OpalConnection::StringOptions & stringOptions
00730 );
00731
00747 virtual void OnProceeding(
00748 OpalConnection & connection
00749 );
00750
00767 virtual void OnAlerting(
00768 OpalConnection & connection
00769 );
00770
00787 virtual OpalConnection::AnswerCallResponse OnAnswerCall(
00788 OpalConnection & connection,
00789 const PString & caller
00790 );
00791
00803 virtual void OnConnected(
00804 OpalConnection & connection
00805 );
00806
00820 virtual void OnEstablished(
00821 OpalConnection & connection
00822 );
00823
00839 virtual void OnReleased(
00840 OpalConnection & connection
00841 );
00842
00849 virtual void OnHold(
00850 OpalConnection & connection,
00851 bool fromRemote,
00852 bool onHold
00853 );
00854 virtual void OnHold(OpalConnection & connection);
00855
00860 virtual PBoolean OnForwarded(
00861 OpalConnection & connection,
00862 const PString & remoteParty
00863 );
00864
00910 virtual bool OnTransferNotify(
00911 OpalConnection & connection,
00912 const PStringToString & info
00913 );
00915
00916
00926 virtual OpalMediaFormatList GetCommonMediaFormats(
00927 bool transportable,
00928 bool pcmAudio
00929 ) const;
00930
00940 virtual void AdjustMediaFormats(
00941 bool local,
00942 const OpalConnection & connection,
00943 OpalMediaFormatList & mediaFormats
00944 ) const;
00945
00947 enum MediaTransferMode {
00948 MediaTransferBypass,
00951 MediaTransferForward,
00954 MediaTransferTranscode
00957 };
00958
00971 virtual MediaTransferMode GetMediaTransferMode(
00972 const OpalConnection & source,
00973 const OpalConnection & destination,
00974 const OpalMediaType & mediaType
00975 ) const;
00976
00992 virtual PBoolean OnOpenMediaStream(
00993 OpalConnection & connection,
00994 OpalMediaStream & stream
00995 );
00996
01013 virtual bool OnLocalRTP(
01014 OpalConnection & connection1,
01015 OpalConnection & connection2,
01016 unsigned sessionID,
01017 bool opened
01018 ) const;
01019
01045 bool SetMediaPassThrough(
01046 const PString & token1,
01047 const PString & token2,
01048 bool bypass,
01049 unsigned sessionID = 0,
01050 bool network = true
01051 );
01052 static bool SetMediaPassThrough(
01053 OpalConnection & connection1,
01054 OpalConnection & connection2,
01055 bool bypass,
01056 unsigned sessionID = 0
01057 );
01058
01063 virtual void OnClosedMediaStream(
01064 const OpalMediaStream & stream
01065 );
01066
01067 #if OPAL_VIDEO
01068
01070 virtual PBoolean CreateVideoInputDevice(
01071 const OpalConnection & connection,
01072 const OpalMediaFormat & mediaFormat,
01073 PVideoInputDevice * & device,
01074 PBoolean & autoDelete
01075 );
01076
01080 virtual PBoolean CreateVideoOutputDevice(
01081 const OpalConnection & connection,
01082 const OpalMediaFormat & mediaFormat,
01083 PBoolean preview,
01084 PVideoOutputDevice * & device,
01085 PBoolean & autoDelete
01086 );
01087 #endif
01088
01096 virtual OpalMediaPatch * CreateMediaPatch(
01097 OpalMediaStream & source,
01098 PBoolean requiresPatchThread = true
01099 );
01100
01107 virtual void OnStartMediaPatch(
01108 OpalConnection & connection,
01109 OpalMediaPatch & patch
01110 );
01111
01114 virtual void OnStopMediaPatch(
01115 OpalConnection & connection,
01116 OpalMediaPatch & patch
01117 );
01118
01134 virtual bool OnMediaFailed(
01135 OpalConnection & connection,
01136 unsigned sessionId,
01137 bool source
01138 );
01140
01141
01149 virtual void OnUserInputString(
01150 OpalConnection & connection,
01151 const PString & value
01152 );
01153
01160 virtual void OnUserInputTone(
01161 OpalConnection & connection,
01162 char tone,
01163 int duration
01164 );
01165
01168 virtual PString ReadUserInput(
01169 OpalConnection & connection,
01170 const char * terminators = "YX#\r\n",
01171 unsigned lastDigitTimeout = 4,
01172 unsigned firstDigitTimeout = 30
01173 );
01175
01176
01177 #if OPAL_HAS_MIXER
01178
01188 virtual PBoolean StartRecording(
01189 const PString & callToken,
01190 const PFilePath & filename,
01191 const OpalRecordManager::Options & options = false
01192 );
01193
01196 virtual bool IsRecording(
01197 const PString & callToken
01198 );
01199
01204 virtual bool StopRecording(
01205 const PString & callToken
01206 );
01207
01209 #endif
01210
01211
01212 #if OPAL_HAS_IM
01213
01218 virtual void OnConversation(
01219 const OpalIMContext::ConversationInfo & info
01220 );
01221
01231 virtual PBoolean Message(
01232 OpalIM & message
01233 );
01234
01236 virtual PBoolean Message(
01237 const PString & to,
01238 const PString & body
01239 );
01240
01242 virtual PBoolean Message(
01243 const PURL & to,
01244 const PString & type,
01245 const PString & body,
01246 PURL & from,
01247 PString & conversationId
01248 );
01249
01255 virtual void OnMessageReceived(
01256 const OpalIM & message
01257 );
01258
01263 virtual void OnMessageDisposition(
01264 const OpalIMContext::DispositionInfo & info
01265 );
01266
01271 virtual void OnCompositionIndication(
01272 const OpalIMContext::CompositionInfo & info
01273 );
01275 #endif
01276
01277
01280
01281 enum MessageWaitingType {
01282 NoMessageWaiting,
01283 VoiceMessageWaiting,
01284 FaxMessageWaiting,
01285 PagerMessageWaiting,
01286 MultimediaMessageWaiting,
01287 TextMessageWaiting,
01288 NumMessageWaitingTypes
01289 };
01290
01301 virtual void OnMWIReceived(
01302 const PString & party,
01303 MessageWaitingType type,
01304 const PString & extraInfo
01305 );
01306
01321 virtual bool GetConferenceStates(
01322 OpalConferenceStates & states,
01323 const PString & name = PString::Empty()
01324 ) const;
01325
01335 virtual void OnConferenceStatusChanged(
01336 OpalEndPoint & endpoint,
01337 const PString & uri,
01338 OpalConferenceState::ChangeType change
01339 );
01340
01348 virtual bool OnChangedPresentationRole(
01349 OpalConnection & connection,
01350 const PString & newChairURI,
01351 bool request
01352 );
01354
01355
01358 #if OPAL_PTLIB_SSL
01359
01371 virtual bool ApplySSLCredentials(
01372 const OpalEndPoint & ep,
01373 PSSLContext & context,
01374 bool create
01375 ) const;
01376
01379 const PString & GetSSLCertificateAuthorityFiles() const { return m_caFiles; }
01380
01383 void SetSSLCertificateAuthorityFiles(const PString & files) { m_caFiles = files; }
01384
01387 const PString & GetSSLCertificateFile() const { return m_certificateFile; }
01388
01391 void SetSSLCertificateFile(const PString & file) { m_certificateFile = file; }
01392
01395 const PString & GetSSLPrivateKeyFile() const { return m_privateKeyFile; }
01396
01399 void SetSSLPrivateKeyFile(const PString & file) { m_privateKeyFile = file; }
01400
01403 void SetSSLAutoCreateCertificate(bool yes) { m_autoCreateCertificate = yes; }
01404 #endif
01405
01412 virtual PBoolean IsLocalAddress(
01413 const PIPSocket::Address & remoteAddress
01414 ) const;
01415
01433 virtual PBoolean IsRTPNATEnabled(
01434 OpalConnection & connection,
01435 const PIPSocket::Address & localAddr,
01436 const PIPSocket::Address & peerAddr,
01437 const PIPSocket::Address & signalAddr,
01438 PBoolean incoming
01439 );
01440
01447 virtual PBoolean TranslateIPAddress(
01448 PIPSocket::Address & localAddress,
01449 const PIPSocket::Address & remoteAddress
01450 );
01451
01452 #if P_NAT
01453
01455 PNatStrategy & GetNatMethods() const { return *m_natMethods; }
01456
01462 virtual PNatMethod * GetNatMethod(
01463 const PIPSocket::Address & remoteAddress = PIPSocket::GetDefaultIpAny()
01464 ) const;
01465
01468 bool SetNATServer(
01469 const PString & method,
01470 const PString & server
01471 );
01472
01475 PString GetNATServer() const
01476 {
01477 return (m_natMethod == NULL) ? PString::Empty() : m_natMethod->GetServer();
01478 }
01479
01482 P_DEPRECATED PString GetTranslationHost() const;
01483
01486 P_DEPRECATED bool SetTranslationHost(
01487 const PString & host
01488 );
01489
01492 P_DEPRECATED PIPSocket::Address GetTranslationAddress() const;
01493
01496 P_DEPRECATED void SetTranslationAddress(
01497 const PIPSocket::Address & address
01498 );
01499
01502 P_DEPRECATED bool HasTranslationAddress() const;
01503
01504 #ifdef P_STUN
01505
01509 P_DEPRECATED PSTUNClient::NatTypes SetSTUNServer(
01510 const PString & server
01511 ) {
01512 return SetNATServer(PSTUNClient::GetNatMethodName(), server) ? m_natMethod->GetNatType() : PSTUNClient::UnknownNat;
01513 }
01514
01517 P_DEPRECATED PString GetSTUNServer() const
01518 {
01519 return (dynamic_cast<PSTUNClient *>(m_natMethod) == NULL) ? PString::Empty() : m_natMethod->GetServer();
01520 }
01521
01524 P_DEPRECATED PSTUNClient * GetSTUNClient() const { return dynamic_cast<PSTUNClient *>(m_natMethod); }
01525 #endif // P_STUN
01526 #endif // P_NAT
01527
01530 WORD GetTCPPortBase() const { return tcpPorts.base; }
01531
01534 WORD GetTCPPortMax() const { return tcpPorts.max; }
01535
01538 void SetTCPPorts(unsigned tcpBase, unsigned tcpMax);
01539
01542 WORD GetNextTCPPort();
01543
01546 WORD GetUDPPortBase() const { return udpPorts.base; }
01547
01550 WORD GetUDPPortMax() const { return udpPorts.max; }
01551
01554 void SetUDPPorts(unsigned udpBase, unsigned udpMax);
01555
01558 WORD GetNextUDPPort();
01559
01562 WORD GetRtpIpPortBase() const { return rtpIpPorts.base; }
01563
01566 WORD GetRtpIpPortMax() const { return rtpIpPorts.max; }
01567
01570 void SetRtpIpPorts(unsigned udpBase, unsigned udpMax);
01571
01574 WORD GetRtpIpPortPair();
01575
01578 BYTE GetMediaTypeOfService() const;
01579
01582 void SetMediaTypeOfService(unsigned tos);
01583
01586 BYTE GetMediaTypeOfService(const OpalMediaType & type) const;
01587
01590 void SetMediaTypeOfService(const OpalMediaType & type, unsigned tos);
01591
01594 const PIPSocket::QoS & GetMediaQoS(const OpalMediaType & type) const;
01595
01598 void SetMediaQoS(const OpalMediaType & type, const PIPSocket::QoS & qos);
01599
01604 PINDEX GetMaxRtpPayloadSize() const { return rtpPayloadSizeMax; }
01605
01610 void SetMaxRtpPayloadSize(
01611 PINDEX size,
01612 bool mtu = false
01613 ) { rtpPayloadSizeMax = size - (mtu ? (20+16+12) : 0); }
01614
01618 PINDEX GetMaxRtpPacketSize() const { return rtpPacketSizeMax; }
01619
01623 void SetMaxRtpPacketSize(
01624 PINDEX size
01625 ) { rtpPacketSizeMax = size; }
01627
01628
01633 const OpalProductInfo & GetProductInfo() const { return productInfo; }
01634
01637 void SetProductInfo(
01638 const OpalProductInfo & info,
01639 bool updateAll = true
01640 );
01641
01644 const PString & GetDefaultUserName() const { return defaultUserName; }
01645
01648 void SetDefaultUserName(
01649 const PString & name,
01650 bool updateAll = true
01651 );
01652
01655 const PString & GetDefaultDisplayName() const { return defaultDisplayName; }
01656
01659 void SetDefaultDisplayName(
01660 const PString & name,
01661 bool updateAll = true
01662 );
01663
01668 void SetDefaultConnectionOptions(
01669 const OpalConnection::StringOptions & stringOptions
01670 ) { m_defaultConnectionOptions = stringOptions; }
01671
01672 #if OPAL_VIDEO
01673
01674
01675
01676
01677
01678
01679
01682 bool CanAutoStartReceiveVideo() const { return (OpalMediaType::Video().GetAutoStart()&OpalMediaType::Receive) != 0; }
01683
01686 void SetAutoStartReceiveVideo(bool can) { OpalMediaType::Video()->SetAutoStart(OpalMediaType::Receive, can); }
01687
01690 bool CanAutoStartTransmitVideo() const { return (OpalMediaType::Video().GetAutoStart()&OpalMediaType::Transmit) != 0; }
01691
01694 void SetAutoStartTransmitVideo(bool can) { OpalMediaType::Video()->SetAutoStart(OpalMediaType::Transmit, can); }
01695
01696 #endif
01697
01701 unsigned GetMinAudioJitterDelay() const { return minAudioJitterDelay; }
01702
01706 unsigned GetMaxAudioJitterDelay() const { return maxAudioJitterDelay; }
01707
01717 void SetAudioJitterDelay(
01718 unsigned minDelay,
01719 unsigned maxDelay
01720 );
01721
01724 const PStringArray & GetMediaFormatOrder() const { return mediaFormatOrder; }
01725
01728 void SetMediaFormatOrder(
01729 const PStringArray & order
01730 );
01731
01737 const PStringArray & GetMediaFormatMask() const { return mediaFormatMask; }
01738
01744 void SetMediaFormatMask(
01745 const PStringArray & mask
01746 );
01747
01750 virtual void SetSilenceDetectParams(
01751 const OpalSilenceDetector::Params & params
01752 ) { silenceDetectParams = params; }
01753
01756 const OpalSilenceDetector::Params & GetSilenceDetectParams() const { return silenceDetectParams; }
01757
01758 #if OPAL_AEC
01759
01761 virtual void SetEchoCancelParams(
01762 const OpalEchoCanceler::Params & params
01763 ) { echoCancelParams = params; }
01764
01767 const OpalEchoCanceler::Params & GetEchoCancelParams() const { return echoCancelParams; }
01768 #endif
01769
01770 #if OPAL_VIDEO
01771
01779 virtual PBoolean SetVideoInputDevice(
01780 const PVideoDevice::OpenArgs & deviceArgs
01781 );
01782
01786 const PVideoDevice::OpenArgs & GetVideoInputDevice() const { return videoInputDevice; }
01787
01795 virtual PBoolean SetVideoPreviewDevice(
01796 const PVideoDevice::OpenArgs & deviceArgs
01797 );
01798
01802 const PVideoDevice::OpenArgs & GetVideoPreviewDevice() const { return videoPreviewDevice; }
01803
01811 virtual PBoolean SetVideoOutputDevice(
01812 const PVideoDevice::OpenArgs & deviceArgs
01813 );
01814
01818 const PVideoDevice::OpenArgs & GetVideoOutputDevice() const { return videoOutputDevice; }
01819
01820 #endif
01821
01822 PBoolean DetectInBandDTMFDisabled() const
01823 { return disableDetectInBandDTMF; }
01824
01827 void DisableDetectInBandDTMF(
01828 PBoolean mode
01829 ) { disableDetectInBandDTMF = mode; }
01830
01833 const PTimeInterval & GetNoMediaTimeout() const { return m_noMediaTimeout; }
01834
01837 void SetNoMediaTimeout(
01838 const PTimeInterval & newInterval
01839 ) { m_noMediaTimeout = newInterval; }
01840
01843 const PTimeInterval & GetSignalingTimeout() const { return m_signalingTimeout; }
01844
01847 void SetSignalingTimeout(
01848 const PTimeInterval & newInterval
01849 ) { m_signalingTimeout = newInterval; }
01850
01853 const PString & GetDefaultILSServer() const { return ilsServer; }
01854
01857 void SetDefaultILSServer(
01858 const PString & server
01859 ) { ilsServer = server; }
01860
01861 #if OPAL_SCRIPT
01862
01907 PScriptLanguage * GetScript() const { return m_script; }
01908
01911 bool RunScript(
01912 const PString & script,
01913 const char * language = "Lua"
01914 );
01915 #endif // OPAL_SCRIPT
01916
01917
01918
01919 void GarbageCollection();
01920
01921
01922 void QueueDecoupledEvent(PSafeWork * work) { m_decoupledEventPool.AddWork(work); }
01923
01924 protected:
01925
01926 OpalProductInfo productInfo;
01927
01928 PString defaultUserName;
01929 PString defaultDisplayName;
01930
01931 typedef std::map<OpalMediaType, PIPSocket::QoS> MediaQoSMap;
01932 mutable MediaQoSMap m_mediaQoS;
01933
01934 OpalConnection::StringOptions m_defaultConnectionOptions;
01935
01936 PINDEX rtpPayloadSizeMax;
01937 PINDEX rtpPacketSizeMax;
01938 unsigned minAudioJitterDelay;
01939 unsigned maxAudioJitterDelay;
01940 PStringArray mediaFormatOrder;
01941 PStringArray mediaFormatMask;
01942 bool disableDetectInBandDTMF;
01943 PTimeInterval m_noMediaTimeout;
01944 PTimeInterval m_signalingTimeout;
01945 PString ilsServer;
01946
01947 OpalSilenceDetector::Params silenceDetectParams;
01948 #if OPAL_AEC
01949 OpalEchoCanceler::Params echoCancelParams;
01950 #endif
01951
01952 #if OPAL_VIDEO
01953 PVideoDevice::OpenArgs videoInputDevice;
01954 PVideoDevice::OpenArgs videoPreviewDevice;
01955 PVideoDevice::OpenArgs videoOutputDevice;
01956 #endif
01957
01958 struct PortInfo {
01959 void Set(
01960 unsigned base,
01961 unsigned max,
01962 unsigned range,
01963 unsigned dflt
01964 );
01965 WORD GetNext(
01966 unsigned increment
01967 );
01968
01969 PMutex mutex;
01970 WORD base;
01971 WORD max;
01972 WORD current;
01973 } tcpPorts, udpPorts, rtpIpPorts;
01974
01975 #if OPAL_PTLIB_SSL
01976 PString m_caFiles;
01977 PFilePath m_certificateFile;
01978 PFilePath m_privateKeyFile;
01979 bool m_autoCreateCertificate;
01980 #endif
01981
01982 #if P_NAT
01983 PNatStrategy * m_natMethods;
01984 PNatMethod * m_natMethod;
01985 PDECLARE_InterfaceNotifier(OpalManager, OnInterfaceChange);
01986 #endif
01987
01988 RouteTable m_routeTable;
01989 PMutex m_routeMutex;
01990
01991
01992 PReadWriteMutex endpointsMutex;
01993 PList<OpalEndPoint> endpointList;
01994 std::map<PString, OpalEndPoint *> endpointMap;
01995
01996 PAtomicInteger lastCallTokenID;
01997
01998 class CallDict : public PSafeDictionary<PString, OpalCall>
01999 {
02000 public:
02001 CallDict(OpalManager & mgr) : manager(mgr) { }
02002 virtual void DeleteObject(PObject * object) const;
02003 OpalManager & manager;
02004 } activeCalls;
02005
02006 #if OPAL_HAS_PRESENCE
02007 PSafeDictionary<PString, OpalPresentity> m_presentities;
02008 #endif // OPAL_HAS_PRESENCE
02009
02010 PAtomicInteger m_clearingAllCallsCount;
02011 PMutex m_clearingAllCallsMutex;
02012 PSyncPoint m_allCallsCleared;
02013 void InternalClearAllCalls(OpalConnection::CallEndReason reason, bool wait, bool first);
02014
02015 PThread * m_garbageCollector;
02016 PSyncPoint m_garbageCollectExit;
02017 bool m_garbageCollectSkip;
02018 PDECLARE_NOTIFIER(PThread, OpalManager, GarbageMain);
02019
02020 friend OpalCall::OpalCall(OpalManager & mgr);
02021 friend void OpalCall::InternalOnClear();
02022
02023 PSafeThreadPool m_decoupledEventPool;
02024
02025 #if OPAL_SCRIPT
02026 PScriptLanguage * m_script;
02027 #endif
02028
02029 private:
02030 P_REMOVE_VIRTUAL(OpalCall *,CreateCall(), 0);
02031 P_REMOVE_VIRTUAL(PBoolean, OnIncomingConnection(OpalConnection &, unsigned), false);
02032 P_REMOVE_VIRTUAL(PBoolean, OnIncomingConnection(OpalConnection &), false);
02033 P_REMOVE_VIRTUAL(PBoolean, OnStartMediaPatch(const OpalMediaPatch &), false);
02034 P_REMOVE_VIRTUAL_VOID(AdjustMediaFormats(const OpalConnection &, OpalMediaFormatList &) const);
02035 P_REMOVE_VIRTUAL_VOID(OnMessageReceived(const PURL&,const PString&,const PURL&,const PString&,const PString&,const PString&));
02036 P_REMOVE_VIRTUAL_VOID(OnRTPStatistics(const OpalConnection &, const OpalRTPSession &));
02037 P_REMOVE_VIRTUAL(PBoolean, IsMediaBypassPossible(const OpalConnection &,const OpalConnection &,unsigned) const, false);
02038 };
02039
02040
02041 PString OpalGetVersion();
02042 unsigned OpalGetMajorVersion();
02043 unsigned OpalGetMinorVersion();
02044 unsigned OpalGetBuildNumber();
02045
02046
02047 #endif // OPAL_OPAL_MANAGER_H
02048
02049
02050