endpoint.h

Go to the documentation of this file.
00001 /*
00002  * endpoint.h
00003  *
00004  * Telephony endpoint abstraction
00005  *
00006  * Open Phone Abstraction Library (OPAL)
00007  * Formally known as the Open H323 project.
00008  *
00009  * Copyright (c) 2001 Equivalence Pty. Ltd.
00010  *
00011  * The contents of this file are subject to the Mozilla Public License
00012  * Version 1.0 (the "License"); you may not use this file except in
00013  * compliance with the License. You may obtain a copy of the License at
00014  * http://www.mozilla.org/MPL/
00015  *
00016  * Software distributed under the License is distributed on an "AS IS"
00017  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
00018  * the License for the specific language governing rights and limitations
00019  * under the License.
00020  *
00021  * The Original Code is Open Phone Abstraction Library.
00022  *
00023  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
00024  *
00025  * Contributor(s): ______________________________________.
00026  *
00027  * $Revision: 19970 $
00028  * $Author: csoutheren $
00029  * $Date: 2008-04-11 05:20:10 +0000 (Fri, 11 Apr 2008) $
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();
00092 
00097     virtual void ShutDown();
00099 
00106     void PrintOn(
00107       ostream & strm    
00108     ) const;
00110 
00117     PBoolean StartListeners(
00118       const PStringArray & interfaces 
00119     );
00120 
00125     PBoolean StartListener(
00126       const OpalTransportAddress & iface 
00127     );
00128 
00134     PBoolean StartListener(
00135       OpalListener * listener 
00136     );
00137 
00142     virtual PStringArray GetDefaultListeners() const;
00143 
00146     OpalListener * FindListener(
00147         const OpalTransportAddress & iface 
00148     );
00149 
00153     PBoolean StopListener(
00154         const OpalTransportAddress & iface 
00155     );
00156 
00160     PBoolean RemoveListener(
00161       OpalListener * listener 
00162     );
00163 
00166     OpalTransportAddressArray GetInterfaceAddresses(
00167       PBoolean excludeLocalHost = PTrue,       
00168       OpalTransport * associatedTransport = NULL
00170     );
00171 
00176     PDECLARE_NOTIFIER(PThread, OpalEndPoint, ListenerCallback);
00177 
00186     virtual PBoolean NewIncomingConnection(
00187       OpalTransport * transport  
00188     );
00190 
00222     virtual PBoolean MakeConnection(
00223       OpalCall & call,          
00224       const PString & party,    
00225       void * userData = NULL,          
00226       unsigned int options = 0,     
00227       OpalConnection::StringOptions * stringOptions = NULL
00228     ) = 0;
00229 
00233     virtual PBoolean OnSetUpConnection(OpalConnection &connection);
00234     
00256     virtual PBoolean OnIncomingConnection(
00257       OpalConnection & connection,  
00258       unsigned options,             
00259       OpalConnection::StringOptions * stringOptions
00260     );
00261     virtual PBoolean OnIncomingConnection(
00262       OpalConnection & connection,  
00263       unsigned options              
00264     );
00265     virtual PBoolean OnIncomingConnection(
00266       OpalConnection & connection   
00267     );
00268 
00284     virtual void OnAlerting(
00285       OpalConnection & connection   
00286     );
00287 
00304     virtual OpalConnection::AnswerCallResponse OnAnswerCall(
00305       OpalConnection & connection,    
00306        const PString & caller         
00307     );
00308 
00319     virtual void OnConnected(
00320       OpalConnection & connection   
00321     );
00322 
00334     virtual void OnEstablished(
00335       OpalConnection & connection   
00336     );
00337 
00356     virtual void OnReleased(
00357       OpalConnection & connection   
00358     );
00359 
00366     void OnHold(
00367       OpalConnection & connection   
00368     );
00369 
00374     virtual PBoolean OnForwarded(
00375       OpalConnection & connection,  
00376       const PString & remoteParty         
00377     );
00378 
00386     virtual PBoolean ClearCall(
00387       const PString & token,    
00388       OpalConnection::CallEndReason reason = OpalConnection::EndedByLocalUser, 
00389       PSyncPoint * sync = NULL  
00390     );
00391 
00396     virtual PBoolean ClearCallSynchronous(
00397       const PString & token,    
00398       OpalConnection::CallEndReason reason = OpalConnection::EndedByLocalUser, 
00399       PSyncPoint * sync = NULL  
00400     );
00401 
00408     virtual void ClearAllCalls(
00409       OpalConnection::CallEndReason reason = OpalConnection::EndedByLocalUser, 
00410       PBoolean wait = PTrue   
00411     );
00412 
00417     PSafePtr<OpalConnection> GetConnectionWithLock(
00418       const PString & token,     
00419       PSafetyMode mode = PSafeReadWrite
00420     ) { return connectionsActive.FindWithLock(token, mode); }
00421 
00424     PStringList GetAllConnections();
00425     
00428     PINDEX GetConnectionCount() const { return connectionsActive.GetSize(); }
00429 
00432     virtual PBoolean HasConnection(
00433       const PString & token   
00434     );
00435 
00438     virtual void DestroyConnection(
00439       OpalConnection * connection  
00440     );
00442 
00454     virtual OpalMediaFormatList GetMediaFormats() const = 0;
00455 
00464     virtual void AdjustMediaFormats(
00465       const OpalConnection & connection,  
00466       OpalMediaFormatList & mediaFormats  
00467     ) const;
00468 
00480     virtual PBoolean OnOpenMediaStream(
00481       OpalConnection & connection,  
00482       OpalMediaStream & stream      
00483     );
00484 
00489     virtual void OnClosedMediaStream(
00490       const OpalMediaStream & stream     
00491     );
00492 
00493 #if OPAL_VIDEO
00494 
00498     virtual void AddVideoMediaFormats(
00499       OpalMediaFormatList & mediaFormats, 
00500       const OpalConnection * connection = NULL  
00501     ) const;
00502 
00505     virtual PBoolean CreateVideoInputDevice(
00506       const OpalConnection & connection,    
00507       const OpalMediaFormat & mediaFormat,  
00508       PVideoInputDevice * & device,         
00509       PBoolean & autoDelete                     
00510     );
00511 
00515     virtual PBoolean CreateVideoOutputDevice(
00516       const OpalConnection & connection,    
00517       const OpalMediaFormat & mediaFormat,  
00518       PBoolean preview,                         
00519       PVideoOutputDevice * & device,        
00520       PBoolean & autoDelete                     
00521     );
00522 #endif
00523 
00524 
00531     virtual void OnUserInputString(
00532       OpalConnection & connection,  
00533       const PString & value   
00534     );
00535 
00542     virtual void OnUserInputTone(
00543       OpalConnection & connection,  
00544       char tone,                    
00545       int duration                  
00546     );
00547 
00550     virtual PString ReadUserInput(
00551       OpalConnection & connection,        
00552       const char * terminators = "#\r\n", 
00553       unsigned lastDigitTimeout = 4,      
00554       unsigned firstDigitTimeout = 30     
00555     );
00557 
00560 #if OPAL_T120DATA
00561 
00571     virtual OpalT120Protocol * CreateT120ProtocolHandler(
00572       const OpalConnection & connection  
00573     ) const;
00574 #endif
00575 
00576 #if OPAL_T38FAX
00577 
00588     virtual OpalT38Protocol * CreateT38ProtocolHandler(
00589       const OpalConnection & connection  
00590     ) const;
00591         
00592 #endif
00593 
00594 #if OPAL_H224
00595 
00605     virtual OpalH224Handler * CreateH224ProtocolHandler(
00606       OpalConnection & connection, 
00607       unsigned sessionID
00608     ) const;
00609         
00619     virtual OpalH281Handler * CreateH281ProtocolHandler(
00620       OpalH224Handler & h224Handler
00621     ) const;
00622 #endif
00623 
00628     virtual PBoolean GarbageCollection();
00630 
00635     OpalManager & GetManager() const { return manager; }
00636 
00639     const PString & GetPrefixName() const { return prefixName; }
00640 
00643     PBoolean HasAttribute(Attributes opt) const { return (attributeBits&opt) != 0; }
00644 
00647     WORD GetDefaultSignalPort() const { return defaultSignalPort; }
00648 
00651     const OpalProductInfo & GetProductInfo() const { return productInfo; }
00652 
00655     void SetProductInfo(
00656       const OpalProductInfo & info
00657     ) { productInfo = info; }
00658 
00661     const PString & GetDefaultLocalPartyName() const { return defaultLocalPartyName; }
00662 
00665     void SetDefaultLocalPartyName(const PString & name) { defaultLocalPartyName = name; }
00666 
00669     const PString & GetDefaultDisplayName() const { return defaultDisplayName; }
00670 
00673     void SetDefaultDisplayName(const PString & name) { defaultDisplayName = name; }
00674 
00677     unsigned GetInitialBandwidth() const { return initialBandwidth; }
00678 
00681     void SetInitialBandwidth(unsigned bandwidth) { initialBandwidth = bandwidth; }
00682 
00685     const OpalListenerList & GetListeners() const { return listeners; }
00686 
00689     OpalConnection::SendUserInputModes GetSendUserInputMode() const { return defaultSendUserInputMode; }
00690 
00693     void SetSendUserInputMode(OpalConnection::SendUserInputModes mode) { defaultSendUserInputMode = mode; }
00695 
00696     virtual PString GetDefaultTransport() const;
00697 
00703     virtual void OnNewConnection(
00704       OpalCall & call,              
00705       OpalConnection & connection   
00706     );
00707 
00708 #if P_SSL
00709     PString GetSSLCertificate() const;
00710 #endif
00711 
00712     virtual void SetDefaultSecurityMode(const PString & v)
00713     { defaultSecurityMode = v; }
00714 
00715     virtual PString GetDefaultSecurityMode() const 
00716     { return defaultSecurityMode; }
00717 
00718 #if OPAL_RTP_AGGREGATE
00719     virtual PBoolean UseRTPAggregation() const;
00720 
00723     void SetRTPAggregationSize(
00724       PINDEX size            
00725     );
00726 
00729     PINDEX GetRTPAggregationSize() const;
00730 
00733     PHandleAggregator * GetRTPAggregator();
00734 #endif
00735 
00739     virtual PBoolean AdjustInterfaceTable(PIPSocket::Address & remoteAddress,
00740                                       PIPSocket::InterfaceTable & interfaceTable);
00741 
00759     virtual PBoolean IsRTPNATEnabled(
00760       OpalConnection & connection,            
00761       const PIPSocket::Address & localAddr,   
00762       const PIPSocket::Address & peerAddr,    
00763       const PIPSocket::Address & signalAddr,  
00764       PBoolean incoming                       
00765     );
00766 
00767 
00768   protected:
00769     OpalManager   & manager;
00770     PCaselessString prefixName;
00771     unsigned        attributeBits;
00772     WORD            defaultSignalPort;
00773     OpalProductInfo productInfo;
00774     PString         defaultLocalPartyName;
00775     PString         defaultDisplayName;
00776 
00777     unsigned initialBandwidth;  // in 100s of bits/sev
00778     OpalConnection::SendUserInputModes defaultSendUserInputMode;
00779 
00780     OpalListenerList   listeners;
00781 
00782     class ConnectionDict : public PSafeDictionary<PString, OpalConnection>
00783     {
00784         virtual void DeleteObject(PObject * object) const;
00785     } connectionsActive;
00786     PBoolean AddConnection(OpalConnection * connection);
00787 
00788     PMutex inUseFlag;
00789 
00790     PString defaultSecurityMode; 
00791 
00792 #if OPAL_RTP_AGGREGATE
00793     PMutex rtpAggregationMutex;
00794     PBoolean useRTPAggregation; 
00795     PINDEX rtpAggregationSize;
00796     PHandleAggregator * rtpAggregator;
00797 #endif
00798 
00799     friend void OpalManager::GarbageCollection();
00800     friend void OpalConnection::Release(CallEndReason reason);
00801 };
00802 
00803 
00804 #endif // __OPAL_ENDPOINT_H
00805 
00806 
00807 // End of File ///////////////////////////////////////////////////////////////

Generated on Wed May 7 00:55:30 2008 for OPAL by  doxygen 1.5.1