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_ENDPOINT_H
00033 #define __OPAL_ENDPOINT_H
00034
00035 #ifdef P_USE_PRAGMA
00036 #pragma interface
00037 #endif
00038
00039 #include <opal/buildopts.h>
00040
00041 #include <opal/manager.h>
00042 #include <opal/mediafmt.h>
00043 #include <opal/transports.h>
00044
00045 class OpalCall;
00046 class OpalMediaStream;
00047 class OpalH224Handler;
00048 class OpalH281Handler;
00049
00050
00070 class OpalEndPoint : public PObject
00071 {
00072 PCLASSINFO(OpalEndPoint, PObject);
00073 public:
00074 enum Attributes {
00075 CanTerminateCall = 1,
00076 HasLineInterface = 2
00077 };
00078
00083 OpalEndPoint(
00084 OpalManager & manager,
00085 const PCaselessString & prefix,
00086 unsigned attributes
00087 );
00088
00091 ~OpalEndPoint();
00093
00100 void PrintOn(
00101 ostream & strm
00102 ) const;
00104
00111 PBoolean StartListeners(
00112 const PStringArray & interfaces
00113 );
00114
00119 PBoolean StartListener(
00120 const OpalTransportAddress & iface
00121 );
00122
00128 PBoolean StartListener(
00129 OpalListener * listener
00130 );
00131
00136 virtual PStringArray GetDefaultListeners() const;
00137
00140 OpalListener * FindListener(
00141 const OpalTransportAddress & iface
00142 );
00143
00147 PBoolean StopListener(
00148 const OpalTransportAddress & iface
00149 );
00150
00154 PBoolean RemoveListener(
00155 OpalListener * listener
00156 );
00157
00160 OpalTransportAddressArray GetInterfaceAddresses(
00161 PBoolean excludeLocalHost = PTrue,
00162 OpalTransport * associatedTransport = NULL
00164 );
00165
00170 PDECLARE_NOTIFIER(PThread, OpalEndPoint, ListenerCallback);
00171
00180 virtual PBoolean NewIncomingConnection(
00181 OpalTransport * transport
00182 );
00184
00216 virtual PBoolean MakeConnection(
00217 OpalCall & call,
00218 const PString & party,
00219 void * userData = NULL,
00220 unsigned int options = 0,
00221 OpalConnection::StringOptions * stringOptions = NULL
00222 ) = 0;
00223
00227 virtual PBoolean OnSetUpConnection(OpalConnection &connection);
00228
00250 virtual PBoolean OnIncomingConnection(
00251 OpalConnection & connection,
00252 unsigned options,
00253 OpalConnection::StringOptions * stringOptions
00254 );
00255 virtual PBoolean OnIncomingConnection(
00256 OpalConnection & connection,
00257 unsigned options
00258 );
00259 virtual PBoolean OnIncomingConnection(
00260 OpalConnection & connection
00261 );
00262
00278 virtual void OnAlerting(
00279 OpalConnection & connection
00280 );
00281
00298 virtual OpalConnection::AnswerCallResponse OnAnswerCall(
00299 OpalConnection & connection,
00300 const PString & caller
00301 );
00302
00313 virtual void OnConnected(
00314 OpalConnection & connection
00315 );
00316
00328 virtual void OnEstablished(
00329 OpalConnection & connection
00330 );
00331
00350 virtual void OnReleased(
00351 OpalConnection & connection
00352 );
00353
00360 void OnHold(
00361 OpalConnection & connection
00362 );
00363
00368 virtual PBoolean OnForwarded(
00369 OpalConnection & connection,
00370 const PString & remoteParty
00371 );
00372
00380 virtual PBoolean ClearCall(
00381 const PString & token,
00382 OpalConnection::CallEndReason reason = OpalConnection::EndedByLocalUser,
00383 PSyncPoint * sync = NULL
00384 );
00385
00390 virtual PBoolean ClearCallSynchronous(
00391 const PString & token,
00392 OpalConnection::CallEndReason reason = OpalConnection::EndedByLocalUser,
00393 PSyncPoint * sync = NULL
00394 );
00395
00402 virtual void ClearAllCalls(
00403 OpalConnection::CallEndReason reason = OpalConnection::EndedByLocalUser,
00404 PBoolean wait = PTrue
00405 );
00406
00411 PSafePtr<OpalConnection> GetConnectionWithLock(
00412 const PString & token,
00413 PSafetyMode mode = PSafeReadWrite
00414 ) { return connectionsActive.FindWithLock(token, mode); }
00415
00418 PStringList GetAllConnections();
00419
00422 PINDEX GetConnectionCount() const { return connectionsActive.GetSize(); }
00423
00426 virtual PBoolean HasConnection(
00427 const PString & token
00428 );
00429
00432 virtual void DestroyConnection(
00433 OpalConnection * connection
00434 );
00436
00448 virtual OpalMediaFormatList GetMediaFormats() const = 0;
00449
00458 virtual void AdjustMediaFormats(
00459 const OpalConnection & connection,
00460 OpalMediaFormatList & mediaFormats
00461 ) const;
00462
00474 virtual PBoolean OnOpenMediaStream(
00475 OpalConnection & connection,
00476 OpalMediaStream & stream
00477 );
00478
00483 virtual void OnClosedMediaStream(
00484 const OpalMediaStream & stream
00485 );
00486
00487 #if OPAL_VIDEO
00488
00492 virtual void AddVideoMediaFormats(
00493 OpalMediaFormatList & mediaFormats,
00494 const OpalConnection * connection = NULL
00495 ) const;
00496
00499 virtual PBoolean CreateVideoInputDevice(
00500 const OpalConnection & connection,
00501 const OpalMediaFormat & mediaFormat,
00502 PVideoInputDevice * & device,
00503 PBoolean & autoDelete
00504 );
00505
00509 virtual PBoolean CreateVideoOutputDevice(
00510 const OpalConnection & connection,
00511 const OpalMediaFormat & mediaFormat,
00512 PBoolean preview,
00513 PVideoOutputDevice * & device,
00514 PBoolean & autoDelete
00515 );
00516 #endif
00517
00518
00525 virtual void OnUserInputString(
00526 OpalConnection & connection,
00527 const PString & value
00528 );
00529
00536 virtual void OnUserInputTone(
00537 OpalConnection & connection,
00538 char tone,
00539 int duration
00540 );
00541
00544 virtual PString ReadUserInput(
00545 OpalConnection & connection,
00546 const char * terminators = "#\r\n",
00547 unsigned lastDigitTimeout = 4,
00548 unsigned firstDigitTimeout = 30
00549 );
00551
00554 #if OPAL_T120DATA
00555
00565 virtual OpalT120Protocol * CreateT120ProtocolHandler(
00566 const OpalConnection & connection
00567 ) const;
00568 #endif
00569
00570 #if OPAL_T38FAX
00571
00582 virtual OpalT38Protocol * CreateT38ProtocolHandler(
00583 const OpalConnection & connection
00584 ) const;
00585
00586 #endif
00587
00588 #if OPAL_H224
00589
00599 virtual OpalH224Handler * CreateH224ProtocolHandler(
00600 OpalConnection & connection,
00601 unsigned sessionID
00602 ) const;
00603
00613 virtual OpalH281Handler * CreateH281ProtocolHandler(
00614 OpalH224Handler & h224Handler
00615 ) const;
00616 #endif
00617
00622 virtual PBoolean GarbageCollection();
00624
00629 OpalManager & GetManager() const { return manager; }
00630
00633 const PString & GetPrefixName() const { return prefixName; }
00634
00637 PBoolean HasAttribute(Attributes opt) const { return (attributeBits&opt) != 0; }
00638
00641 WORD GetDefaultSignalPort() const { return defaultSignalPort; }
00642
00645 const OpalProductInfo & GetProductInfo() const { return productInfo; }
00646
00649 void SetProductInfo(
00650 const OpalProductInfo & info
00651 ) { productInfo = info; }
00652
00655 const PString & GetDefaultLocalPartyName() const { return defaultLocalPartyName; }
00656
00659 void SetDefaultLocalPartyName(const PString & name) { defaultLocalPartyName = name; }
00660
00663 const PString & GetDefaultDisplayName() const { return defaultDisplayName; }
00664
00667 void SetDefaultDisplayName(const PString & name) { defaultDisplayName = name; }
00668
00671 unsigned GetInitialBandwidth() const { return initialBandwidth; }
00672
00675 void SetInitialBandwidth(unsigned bandwidth) { initialBandwidth = bandwidth; }
00676
00679 const OpalListenerList & GetListeners() const { return listeners; }
00680
00683 OpalConnection::SendUserInputModes GetSendUserInputMode() const { return defaultSendUserInputMode; }
00684
00687 void SetSendUserInputMode(OpalConnection::SendUserInputModes mode) { defaultSendUserInputMode = mode; }
00689
00690 virtual PString GetDefaultTransport() const;
00691
00697 virtual void OnNewConnection(
00698 OpalCall & call,
00699 OpalConnection & connection
00700 );
00701
00702 #if P_SSL
00703 PString GetSSLCertificate() const;
00704 #endif
00705
00706 virtual void SetDefaultSecurityMode(const PString & v)
00707 { defaultSecurityMode = v; }
00708
00709 virtual PString GetDefaultSecurityMode() const
00710 { return defaultSecurityMode; }
00711
00712 #if OPAL_RTP_AGGREGATE
00713 virtual PBoolean UseRTPAggregation() const;
00714
00717 void SetRTPAggregationSize(
00718 PINDEX size
00719 );
00720
00723 PINDEX GetRTPAggregationSize() const;
00724
00727 PHandleAggregator * GetRTPAggregator();
00728 #endif
00729
00733 virtual PBoolean AdjustInterfaceTable(PIPSocket::Address & remoteAddress,
00734 PIPSocket::InterfaceTable & interfaceTable);
00735
00753 virtual PBoolean IsRTPNATEnabled(
00754 OpalConnection & connection,
00755 const PIPSocket::Address & localAddr,
00756 const PIPSocket::Address & peerAddr,
00757 const PIPSocket::Address & signalAddr,
00758 PBoolean incoming
00759 );
00760
00761
00762 protected:
00763 OpalManager & manager;
00764 PCaselessString prefixName;
00765 unsigned attributeBits;
00766 WORD defaultSignalPort;
00767 OpalProductInfo productInfo;
00768 PString defaultLocalPartyName;
00769 PString defaultDisplayName;
00770
00771 unsigned initialBandwidth;
00772 OpalConnection::SendUserInputModes defaultSendUserInputMode;
00773
00774 OpalListenerList listeners;
00775
00776 class ConnectionDict : public PSafeDictionary<PString, OpalConnection>
00777 {
00778 virtual void DeleteObject(PObject * object) const;
00779 } connectionsActive;
00780 PBoolean AddConnection(OpalConnection * connection);
00781
00782 PMutex inUseFlag;
00783
00784 PString defaultSecurityMode;
00785
00786 #if OPAL_RTP_AGGREGATE
00787 PMutex rtpAggregationMutex;
00788 PBoolean useRTPAggregation;
00789 PINDEX rtpAggregationSize;
00790 PHandleAggregator * rtpAggregator;
00791 #endif
00792
00793 friend void OpalManager::GarbageCollection();
00794 friend void OpalConnection::Release(CallEndReason reason);
00795 };
00796
00797
00798 #endif // __OPAL_ENDPOINT_H
00799
00800
00801