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
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221 #ifndef __OPAL_ENDPOINT_H
00222 #define __OPAL_ENDPOINT_H
00223
00224 #ifdef P_USE_PRAGMA
00225 #pragma interface
00226 #endif
00227
00228 #include <opal/buildopts.h>
00229
00230 #include <opal/manager.h>
00231 #include <opal/mediafmt.h>
00232 #include <opal/transports.h>
00233
00234 class OpalCall;
00235 class OpalMediaStream;
00236 class OpalH224Handler;
00237 class OpalH281Handler;
00238
00239
00259 class OpalEndPoint : public PObject
00260 {
00261 PCLASSINFO(OpalEndPoint, PObject);
00262 public:
00263 enum Attributes {
00264 CanTerminateCall = 1,
00265 HasLineInterface = 2
00266 };
00267
00272 OpalEndPoint(
00273 OpalManager & manager,
00274 const PCaselessString & prefix,
00275 unsigned attributes
00276 );
00277
00280 ~OpalEndPoint();
00282
00289 void PrintOn(
00290 ostream & strm
00291 ) const;
00293
00303 BOOL StartListeners(
00304 const PStringArray & interfaces
00305 );
00306
00314 BOOL StartListener(
00315 const OpalTransportAddress & iface
00316 );
00317
00323 BOOL StartListener(
00324 OpalListener * listener
00325 );
00326
00331 virtual PStringArray GetDefaultListeners() const;
00332
00335 OpalListener * FindListener(
00336 const OpalTransportAddress & iface
00337 );
00338
00342 BOOL StopListener(
00343 const OpalTransportAddress & iface
00344 );
00345
00349 BOOL RemoveListener(
00350 OpalListener * listener
00351 );
00352
00355 OpalTransportAddressArray GetInterfaceAddresses(
00356 BOOL excludeLocalHost = TRUE,
00357 OpalTransport * associatedTransport = NULL
00359 );
00360
00365 PDECLARE_NOTIFIER(PThread, OpalEndPoint, ListenerCallback);
00366
00375 virtual BOOL NewIncomingConnection(
00376 OpalTransport * transport
00377 );
00379
00411 virtual BOOL MakeConnection(
00412 OpalCall & call,
00413 const PString & party,
00414 void * userData = NULL,
00415 unsigned int options = 0,
00416 OpalConnection::StringOptions * stringOptions = NULL
00417 ) = 0;
00418
00422 virtual BOOL OnSetUpConnection(OpalConnection &connection);
00423
00445 virtual BOOL OnIncomingConnection(
00446 OpalConnection & connection,
00447 unsigned options,
00448 OpalConnection::StringOptions * stringOptions
00449 );
00450 virtual BOOL OnIncomingConnection(
00451 OpalConnection & connection,
00452 unsigned options
00453 );
00454 virtual BOOL OnIncomingConnection(
00455 OpalConnection & connection
00456 );
00457
00473 virtual void OnAlerting(
00474 OpalConnection & connection
00475 );
00476
00493 virtual OpalConnection::AnswerCallResponse OnAnswerCall(
00494 OpalConnection & connection,
00495 const PString & caller
00496 );
00497
00508 virtual void OnConnected(
00509 OpalConnection & connection
00510 );
00511
00523 virtual void OnEstablished(
00524 OpalConnection & connection
00525 );
00526
00545 virtual void OnReleased(
00546 OpalConnection & connection
00547 );
00548
00555 void OnHold(
00556 OpalConnection & connection
00557 );
00558
00563 virtual BOOL OnForwarded(
00564 OpalConnection & connection,
00565 const PString & remoteParty
00566 );
00567
00575 virtual BOOL ClearCall(
00576 const PString & token,
00577 OpalConnection::CallEndReason reason = OpalConnection::EndedByLocalUser,
00578 PSyncPoint * sync = NULL
00579 );
00580
00585 virtual BOOL ClearCallSynchronous(
00586 const PString & token,
00587 OpalConnection::CallEndReason reason = OpalConnection::EndedByLocalUser,
00588 PSyncPoint * sync = NULL
00589 );
00590
00597 virtual void ClearAllCalls(
00598 OpalConnection::CallEndReason reason = OpalConnection::EndedByLocalUser,
00599 BOOL wait = TRUE
00600 );
00601
00606 PSafePtr<OpalConnection> GetConnectionWithLock(
00607 const PString & token,
00608 PSafetyMode mode = PSafeReadWrite
00609 ) { return connectionsActive.FindWithLock(token, mode); }
00610
00613 PStringList GetAllConnections();
00614
00617 virtual BOOL HasConnection(
00618 const PString & token
00619 );
00620
00623 virtual void DestroyConnection(
00624 OpalConnection * connection
00625 );
00627
00639 virtual OpalMediaFormatList GetMediaFormats() const = 0;
00640
00649 virtual void AdjustMediaFormats(
00650 const OpalConnection & connection,
00651 OpalMediaFormatList & mediaFormats
00652 ) const;
00653
00665 virtual BOOL OnOpenMediaStream(
00666 OpalConnection & connection,
00667 OpalMediaStream & stream
00668 );
00669
00674 virtual void OnClosedMediaStream(
00675 const OpalMediaStream & stream
00676 );
00677
00678 #if OPAL_VIDEO
00679
00683 virtual void AddVideoMediaFormats(
00684 OpalMediaFormatList & mediaFormats,
00685 const OpalConnection * connection = NULL
00686 ) const;
00687
00690 virtual BOOL CreateVideoInputDevice(
00691 const OpalConnection & connection,
00692 const OpalMediaFormat & mediaFormat,
00693 PVideoInputDevice * & device,
00694 BOOL & autoDelete
00695 );
00696
00700 virtual BOOL CreateVideoOutputDevice(
00701 const OpalConnection & connection,
00702 const OpalMediaFormat & mediaFormat,
00703 BOOL preview,
00704 PVideoOutputDevice * & device,
00705 BOOL & autoDelete
00706 );
00707 #endif
00708
00709
00716 virtual void OnUserInputString(
00717 OpalConnection & connection,
00718 const PString & value
00719 );
00720
00727 virtual void OnUserInputTone(
00728 OpalConnection & connection,
00729 char tone,
00730 int duration
00731 );
00732
00735 virtual PString ReadUserInput(
00736 OpalConnection & connection,
00737 const char * terminators = "#\r\n",
00738 unsigned lastDigitTimeout = 4,
00739 unsigned firstDigitTimeout = 30
00740 );
00742
00745 #if OPAL_T120DATA
00746
00756 virtual OpalT120Protocol * CreateT120ProtocolHandler(
00757 const OpalConnection & connection
00758 ) const;
00759 #endif
00760
00761 #if OPAL_T38FAX
00762
00773 virtual OpalT38Protocol * CreateT38ProtocolHandler(
00774 const OpalConnection & connection
00775 ) const;
00776
00777 #endif
00778
00779 #if OPAL_H224
00780
00790 virtual OpalH224Handler * CreateH224ProtocolHandler(
00791 OpalConnection & connection,
00792 unsigned sessionID
00793 ) const;
00794
00804 virtual OpalH281Handler * CreateH281ProtocolHandler(
00805 OpalH224Handler & h224Handler
00806 ) const;
00807 #endif
00808
00813 virtual BOOL GarbageCollection();
00815
00820 OpalManager & GetManager() const { return manager; }
00821
00824 const PString & GetPrefixName() const { return prefixName; }
00825
00828 BOOL HasAttribute(Attributes opt) const { return (attributeBits&opt) != 0; }
00829
00832 WORD GetDefaultSignalPort() const { return defaultSignalPort; }
00833
00836 const OpalProductInfo & GetProductInfo() const { return productInfo; }
00837
00840 void SetProductInfo(
00841 const OpalProductInfo & info
00842 ) { productInfo = info; }
00843
00846 const PString & GetDefaultLocalPartyName() const { return defaultLocalPartyName; }
00847
00850 void SetDefaultLocalPartyName(const PString & name) { defaultLocalPartyName = name; }
00851
00854 const PString & GetDefaultDisplayName() const { return defaultDisplayName; }
00855
00858 void SetDefaultDisplayName(const PString & name) { defaultDisplayName = name; }
00859
00862 unsigned GetInitialBandwidth() const { return initialBandwidth; }
00863
00866 void SetInitialBandwidth(unsigned bandwidth) { initialBandwidth = bandwidth; }
00867
00870 const OpalListenerList & GetListeners() const { return listeners; }
00871
00874 OpalConnection::SendUserInputModes GetSendUserInputMode() const { return defaultSendUserInputMode; }
00875
00878 void SetSendUserInputMode(OpalConnection::SendUserInputModes mode) { defaultSendUserInputMode = mode; }
00880
00881 virtual PString GetDefaultTransport() const;
00882
00883 virtual void OnNewConnection(OpalCall & call, OpalConnection & conn);
00884
00885 #if P_SSL
00886 PString GetSSLCertificate() const;
00887 #endif
00888
00889 virtual void SetDefaultSecurityMode(const PString & v)
00890 { defaultSecurityMode = v; }
00891
00892 virtual PString GetDefaultSecurityMode() const
00893 { return defaultSecurityMode; }
00894
00895 virtual BOOL UseRTPAggregation() const;
00896
00899 void SetRTPAggregationSize(
00900 PINDEX size
00901 );
00902
00905 PINDEX GetRTPAggregationSize() const;
00906
00909 PHandleAggregator * GetRTPAggregator();
00910
00914 virtual BOOL AdjustInterfaceTable(PIPSocket::Address & remoteAddress,
00915 PIPSocket::InterfaceTable & interfaceTable);
00916
00917 virtual BOOL IsRTPNATEnabled(OpalConnection & conn,
00918 const PIPSocket::Address & localAddr,
00919 const PIPSocket::Address & peerAddr,
00920 const PIPSocket::Address & sigAddr,
00921 BOOL incoming);
00922
00923 protected:
00924 OpalManager & manager;
00925 PCaselessString prefixName;
00926 unsigned attributeBits;
00927 WORD defaultSignalPort;
00928 OpalProductInfo productInfo;
00929 PString defaultLocalPartyName;
00930 PString defaultDisplayName;
00931
00932 unsigned initialBandwidth;
00933 OpalConnection::SendUserInputModes defaultSendUserInputMode;
00934
00935 OpalListenerList listeners;
00936
00937 class ConnectionDict : public PSafeDictionary<PString, OpalConnection>
00938 {
00939 virtual void DeleteObject(PObject * object) const;
00940 } connectionsActive;
00941 BOOL AddConnection(OpalConnection * connection);
00942
00943 PMutex inUseFlag;
00944
00945 PString defaultSecurityMode;
00946
00947 #if OPAL_RTP_AGGREGATE
00948 PMutex rtpAggregationMutex;
00949 BOOL useRTPAggregation;
00950 PINDEX rtpAggregationSize;
00951 PHandleAggregator * rtpAggregator;
00952 #endif
00953
00954 friend void OpalManager::GarbageCollection();
00955 friend void OpalConnection::Release(CallEndReason reason);
00956 };
00957
00958
00959 #endif // __OPAL_ENDPOINT_H
00960
00961
00962