connection.h

Go to the documentation of this file.
00001 /*
00002  * connection.h
00003  *
00004  * Telephony connection 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): Post Increment
00026  *     Portions of this code were written with the assistance of funding from
00027  *     US Joint Forces Command Joint Concept Development & Experimentation (J9)
00028  *     http://www.jfcom.mil/about/abt_j9.htm
00029  *
00030  * $Revision: 27078 $
00031  * $Author: rjongbloed $
00032  * $Date: 2012-02-29 22:40:38 -0600 (Wed, 29 Feb 2012) $
00033  */
00034 
00035 #ifndef OPAL_OPAL_CONNECTION_H
00036 #define OPAL_OPAL_CONNECTION_H
00037 
00038 #ifdef P_USE_PRAGMA
00039 #pragma interface
00040 #endif
00041 
00042 #include <opal/buildopts.h>
00043 
00044 #include <opal/mediafmt.h>
00045 #include <opal/mediastrm.h>
00046 #include <opal/guid.h>
00047 #include <opal/transports.h>
00048 #include <ptclib/dtmf.h>
00049 #include <ptlib/safecoll.h>
00050 #include <rtp/rtp.h>
00051 
00052 #if OPAL_HAS_IM
00053 #include <im/t140.h>
00054 #include <im/rfc4103.h>
00055 #include <im/im.h>
00056 #endif
00057 
00058 #if P_LUA
00059 #include <ptclib/lua.h>
00060 #endif
00061 
00062 class OpalEndPoint;
00063 class OpalCall;
00064 class OpalSilenceDetector;
00065 class OpalEchoCanceler;
00066 class OpalRFC2833Proto;
00067 class OpalRFC2833Info;
00068 class PURL;
00069 
00070 
00071 #define OPAL_URL_PARAM_PREFIX "OPAL-"
00072 
00073 #define OPAL_OPT_AUTO_START           "AutoStart"             
00074 #define OPAL_OPT_CALL_IDENTIFIER      "Call-Identifier"       
00075 #define OPAL_OPT_CALLING_PARTY_URL    "Calling-Party-URL"     
00076 #define OPAL_OPT_CALLING_PARTY_NUMBER "Calling-Party-Number"  
00077 #define OPAL_OPT_CALLING_PARTY_NAME   "Calling-Party-Name"    
00078 #define OPAL_OPT_CALLING_PARTY_DOMAIN "Calling-Party-Domain"  
00079 #define OPAL_OPT_CALLING_DISPLAY_NAME "Calling-Display-Name"  
00080 #define OPAL_OPT_CALLED_PARTY_NAME    "Called-Party-Name"     
00081 #define OPAL_OPT_CALLED_DISPLAY_NAME  "Called-Display-Name"   
00082 #define OPAL_OPT_REDIRECTING_PARTY    "Redirecting-Party"     
00083 #define OPAL_OPT_PRESENTATION_BLOCK   "Presentation-Block"    
00084 #define OPAL_OPT_ORIGINATOR_ADDRESS   "Originator-Address"    
00085 #define OPAL_OPT_INTERFACE            "Interface"             
00086 #define OPAL_OPT_USER_INPUT_MODE      "User-Input-Mode"       
00087 
00088 #define OPAL_OPT_ENABLE_INBAND_DTMF   "EnableInbandDTMF"      
00089 #define OPAL_OPT_ENABLE_INBAND_DTMF   "EnableInbandDTMF"      
00090 #define OPAL_OPT_DETECT_INBAND_DTMF   "DetectInBandDTMF"      
00091 #define OPAL_OPT_SEND_INBAND_DTMF     "SendInBandDTMF"        
00092 #define OPAL_OPT_DTMF_MULT            "dtmfmult"
00093 #define OPAL_OPT_DTMF_DIV             "dtmfdiv"
00094 #define OPAL_OPT_DISABLE_JITTER       "Disable-Jitter"        
00095 #define OPAL_OPT_MAX_JITTER           "Max-Jitter"            
00096 #define OPAL_OPT_MIN_JITTER           "Min-Jitter"            
00097 #define OPAL_OPT_RECORD_AUDIO         "Record-Audio"          
00098 #define OPAL_OPT_ALERTING_TYPE        "Alerting-Type"         
00099 #define OPAL_OPT_REMOVE_CODEC         "Remove-Codec"          
00100 
00101 
00312 class OpalProductInfo
00313 {
00314   public:
00315     OpalProductInfo();
00316 
00317     static OpalProductInfo & Default();
00318 
00319     friend ostream & operator<<(ostream & strm, const OpalProductInfo & info);
00320     PCaselessString AsString() const;
00321 
00322     PCaselessString vendor;
00323     PCaselessString name;
00324     PCaselessString version;
00325     PCaselessString comments;
00326 
00327     BYTE t35CountryCode;
00328     BYTE t35Extension;
00329     WORD manufacturerCode;
00330 
00331   private:
00332     OpalProductInfo(bool);
00333 };
00334 
00335 
00353 class OpalConnection : public PSafeObject
00354 {
00355     PCLASSINFO(OpalConnection, PSafeObject);
00356   public:
00361     enum CallEndReasonCodes {
00362       EndedByLocalUser,            
00363       EndedByNoAccept,             
00364       EndedByAnswerDenied,         
00365       EndedByRemoteUser,           
00366       EndedByRefusal,              
00367       EndedByNoAnswer,             
00368       EndedByCallerAbort,          
00369       EndedByTransportFail,        
00370       EndedByConnectFail,          
00371       EndedByGatekeeper,           
00372       EndedByNoUser,               
00373       EndedByNoBandwidth,          
00374       EndedByCapabilityExchange,   
00375       EndedByCallForwarded,        
00376       EndedBySecurityDenial,       
00377       EndedByLocalBusy,            
00378       EndedByLocalCongestion,      
00379       EndedByRemoteBusy,           
00380       EndedByRemoteCongestion,     
00381       EndedByUnreachable,          
00382       EndedByNoEndPoint,           
00383       EndedByHostOffline,          
00384       EndedByTemporaryFailure,     
00385       EndedByQ931Cause,            
00386       EndedByDurationLimit,        
00387       EndedByInvalidConferenceID,  
00388       EndedByNoDialTone,           
00389       EndedByNoRingBackTone,       
00390       EndedByOutOfService,         
00391       EndedByAcceptingCallWaiting, 
00392       EndedByGkAdmissionFailed,    
00393       NumCallEndReasons
00394     };
00395 
00396     struct CallEndReason {
00397       CallEndReason(
00398         CallEndReasonCodes reason = NumCallEndReasons,
00399         unsigned cause = 0
00400       ) : code(reason), q931(cause) { }
00401       explicit CallEndReason(
00402         long reason
00403       ) : code((CallEndReasonCodes)(reason&0xff)), q931((reason>>8)&0xff) { }
00404 
00405       __inline operator CallEndReasonCodes() const { return code; }
00406 
00407       __inline int AsInteger() const { return code|(q931<<8); }
00408 
00409       CallEndReasonCodes code:8; // Normalised OPAL code
00410       unsigned           q931:8; // PSTN Interworking code, actually Q.850
00411     };
00412 
00413 #if PTRACING
00414     friend ostream & operator<<(ostream & o, CallEndReason reason);
00415 #endif
00416 
00417     enum AnswerCallResponse {
00418       AnswerCallNow,               
00419       AnswerCallDenied,            
00420       AnswerCallPending,           
00421       AnswerCallDeferred,          
00422       AnswerCallAlertWithMedia,    
00423       AnswerCallDeferredWithMedia, 
00424       AnswerCallProgress,          
00425       AnswerCallNowAndReleaseCurrent, 
00426       NumAnswerCallResponses
00427     };
00428 #if PTRACING
00429     friend ostream & operator<<(ostream & o, AnswerCallResponse s);
00430 #endif
00431 
00434     enum Options {
00435       FastStartOptionDisable       = 0x0001,   // H.323 specific
00436       FastStartOptionEnable        = 0x0002,
00437       FastStartOptionMask          = 0x0003,
00438 
00439       H245TunnelingOptionDisable   = 0x0004,   // H.323 specific
00440       H245TunnelingOptionEnable    = 0x0008,
00441       H245TunnelingOptionMask      = 0x000c,
00442 
00443       H245inSetupOptionDisable     = 0x0010,   // H.323 specific
00444       H245inSetupOptionEnable      = 0x0020,
00445       H245inSetupOptionMask        = 0x0030,
00446 
00447       DetectInBandDTMFOptionDisable = 0x0040,  // SIP and H.323
00448       DetectInBandDTMFOptionEnable  = 0x0080,
00449       DetectInBandDTMFOptionMask    = 0x00c0,
00450 
00451       RTPAggregationDisable        = 0x0100,   // SIP and H.323
00452       RTPAggregationEnable         = 0x0200,
00453       RTPAggregationMask           = 0x0300,
00454 
00455       SendDTMFAsDefault            = 0x0000,   // SIP and H.323
00456       SendDTMFAsString             = 0x0400,
00457       SendDTMFAsTone               = 0x0800,
00458       SendDTMFAsRFC2833            = 0x0c00,
00459       SendDTMFMask                 = 0x0c00
00460     };
00461 
00462     class StringOptions : public PStringOptions 
00463     {
00464       public:
00469         void ExtractFromURL(
00470           PURL & url
00471         );
00472     };
00473 
00478     OpalConnection(
00479       OpalCall & call,                         
00480       OpalEndPoint & endpoint,                 
00481       const PString & token,                   
00482       unsigned options = 0,                    
00483       OpalConnection::StringOptions * stringOptions = NULL 
00484     );  
00485 
00488     ~OpalConnection();
00490 
00497     void PrintOn(
00498       ostream & strm    
00499     ) const;
00501 
00518     virtual bool IsNetworkConnection() const = 0;
00519 
00523     enum Phases {
00524       UninitialisedPhase,   
00525       SetUpPhase,           
00526       ProceedingPhase,      
00527       AlertingPhase,        
00528       ConnectedPhase,       
00529       EstablishedPhase,     
00530       ForwardingPhase,      
00531       ReleasingPhase,       
00532       ReleasedPhase,        
00533       NumPhases             
00534     };
00535 
00540     __inline Phases GetPhase() const { return m_phase; }
00541 
00543     __inline bool IsEstablished() const { return m_phase == EstablishedPhase; }
00544 
00546     __inline bool IsReleased() const { return m_phase >= ReleasingPhase; }
00547 
00552     void SetPhase(
00553       Phases phaseToSet  
00554     );
00555 
00564     CallEndReason GetCallEndReason() const { return callEndReason; }
00565 
00568     static PString GetCallEndReasonText(CallEndReason reason);
00569     PString GetCallEndReasonText() const { return GetCallEndReasonText(callEndReason); }
00570 
00573     static void SetCallEndReasonText(CallEndReasonCodes reasonCode, const PString & newText);
00574 
00579     virtual void SetCallEndReason(
00580       CallEndReason reason        
00581     );
00582 
00590     void ClearCall(
00591       CallEndReason reason = EndedByLocalUser 
00592     );
00593 
00596     virtual void ClearCallSynchronous(
00597       PSyncPoint * sync,                       
00598       CallEndReason reason = EndedByLocalUser  
00599     );
00600 
00604     unsigned GetQ931Cause() const { return callEndReason.q931; }
00605 
00609     void SetQ931Cause(unsigned v) { callEndReason.q931 = v; }
00610 
00617     virtual bool TransferConnection(
00618       const PString & remoteParty   
00619     );
00620     
00628     virtual bool Hold(
00629       bool fromRemote,  
00630       bool placeOnHold  
00631     );
00632 
00637     virtual bool IsOnHold(
00638       bool fromRemote  
00639     );
00640 
00645     virtual void OnHold(
00646       bool fromRemote,               
00647       bool onHold                    
00648     );
00650 
00678     virtual PBoolean OnIncomingConnection(unsigned int options, OpalConnection::StringOptions * stringOptions);
00679 
00686     virtual PBoolean SetUpConnection() = 0;
00687 
00691     virtual PBoolean OnSetUpConnection();
00692 
00693     
00708     virtual void OnProceeding();
00709 
00720     virtual void OnAlerting();
00721 
00732     virtual PBoolean SetAlerting(
00733       const PString & calleeName,   
00734       PBoolean withMedia                
00735     ) = 0;
00736 
00753     virtual AnswerCallResponse OnAnswerCall(
00754       const PString & callerName        
00755     );
00756 
00767     virtual void AnsweringCall(
00768       AnswerCallResponse response 
00769     );
00770 
00785     virtual void OnConnected();
00786 
00797     virtual PBoolean SetConnected();
00798 
00810     virtual void OnEstablished();
00811 
00859     virtual bool OnTransferNotify(
00860       const PStringToString & info, 
00861       const OpalConnection * transferringConnection
00863     );
00864 
00873     virtual void Release(
00874       CallEndReason reason = EndedByLocalUser, 
00875       bool synchronous = false                 
00876     );
00877 
00895     virtual void OnReleased();
00897 
00908     virtual PString GetDestinationAddress();
00909 
00919     virtual PBoolean ForwardCall(
00920       const PString & forwardParty   
00921     );
00922 
00925     PSafePtr<OpalConnection> GetOtherPartyConnection() const;
00926 
00929     template <class cls> PSafePtr<cls> GetOtherPartyConnectionAs() const { return PSafePtrCast<OpalConnection, cls>(GetOtherPartyConnection()); }
00931 
00940     virtual OpalMediaFormatList GetMediaFormats() const;
00941 
00946     virtual OpalMediaFormatList GetLocalMediaFormats();
00947 
00961     virtual void AdjustMediaFormats(
00962       bool local,                             
00963       const OpalConnection * otherConnection, 
00964       OpalMediaFormatList & mediaFormats      
00965     ) const;
00966 
00974     virtual unsigned GetNextSessionID(
00975       const OpalMediaType & mediaType,   
00976       bool isSource                      
00977     );
00978 
00985     virtual OpalMediaType::AutoStartMode GetAutoStart(
00986       const OpalMediaType & mediaType  
00987     ) const;
00988 
00991     virtual void AutoStartMediaStreams(
00992       bool force = false 
00993     );
00994 
00995 #if OPAL_FAX
00996 
00998     virtual bool SwitchFaxMediaStreams(
00999       bool enableFax  
01000     );
01001 
01006     virtual void OnSwitchedFaxMediaStreams(
01007       bool enabledFax  
01008     );
01009 #endif
01010 
01013     virtual OpalMediaStreamPtr OpenMediaStream(
01014       const OpalMediaFormat & mediaFormat, 
01015       unsigned sessionID,                  
01016       bool isSource                        
01017     );
01018 
01021     virtual bool CloseMediaStream(
01022       unsigned sessionId,  
01023       bool source          
01024     );
01025 
01028     virtual bool CloseMediaStream(
01029       OpalMediaStream & stream  
01030     );
01031 
01039     bool RemoveMediaStream(
01040       OpalMediaStream & strm  
01041     );
01042 
01045     virtual void StartMediaStreams();
01046     
01049     virtual void CloseMediaStreams();
01050     
01053     virtual void PauseMediaStreams(
01054       bool paused  
01055     );
01056 
01059     virtual void OnPauseMediaStream(
01060       OpalMediaStream & strm,     
01061       bool paused                 
01062     );
01063 
01076     virtual OpalMediaStream * CreateMediaStream(
01077       const OpalMediaFormat & mediaFormat, 
01078       unsigned sessionID,                  
01079       PBoolean isSource                        
01080     );
01081 
01088     OpalMediaStreamPtr GetMediaStream(
01089       const PString & streamID,  
01090       bool source                
01091     ) const;
01092 
01098     OpalMediaStreamPtr GetMediaStream(
01099       unsigned sessionId,  
01100       bool source          
01101     ) const;
01102 
01113     OpalMediaStreamPtr GetMediaStream(
01114       const OpalMediaType & mediaType,    
01115       bool source,                        
01116       OpalMediaStreamPtr previous = NULL  
01117     ) const;
01118 
01130     virtual PBoolean OnOpenMediaStream(
01131       OpalMediaStream & stream    
01132     );
01133 
01138     virtual void OnClosedMediaStream(
01139       const OpalMediaStream & stream     
01140     );
01141 
01150     virtual void OnPatchMediaStream(
01151       PBoolean isSource,        
01152       OpalMediaPatch & patch    
01153     );
01154 
01157     virtual void OnStartMediaPatch(
01158       OpalMediaPatch & patch    
01159     );
01160 
01163     virtual void OnStopMediaPatch(
01164       OpalMediaPatch & patch    
01165     );
01166 
01172     virtual bool OnMediaCommand(
01173       OpalMediaStream & stream,         
01174       const OpalMediaCommand & command  
01175     );
01176 
01181     virtual void AttachRFC2833HandlerToPatch(PBoolean isSource, OpalMediaPatch & patch);
01182 
01188     virtual PBoolean IsMediaBypassPossible(
01189       unsigned sessionID                  
01190     ) const;
01191 
01192 #if OPAL_VIDEO
01193 
01195     virtual PBoolean CreateVideoInputDevice(
01196       const OpalMediaFormat & mediaFormat,  
01197       PVideoInputDevice * & device,         
01198       PBoolean & autoDelete                     
01199     );
01200 
01204     virtual PBoolean CreateVideoOutputDevice(
01205       const OpalMediaFormat & mediaFormat,  
01206       PBoolean preview,                         
01207       PVideoOutputDevice * & device,        
01208       PBoolean & autoDelete                     
01209     );
01210 
01216     virtual bool SendVideoUpdatePicture(
01217       unsigned sessionID = 0, 
01218       bool force = false      
01219     ) const;
01220 #endif
01221 
01224     virtual PBoolean SetAudioVolume(
01225       PBoolean source,                  
01226       unsigned percentage           
01227     );
01228 
01232     virtual unsigned GetAudioSignalLevel(
01233       PBoolean source                   
01234     );
01236 
01241     unsigned GetBandwidthAvailable() const { return bandwidthAvailable; }
01242 
01247     virtual PBoolean SetBandwidthAvailable(
01248       unsigned newBandwidth,    
01249       PBoolean force = false        
01250     );
01251 
01256     virtual unsigned GetBandwidthUsed() const;
01257 
01266     virtual PBoolean SetBandwidthUsed(
01267       unsigned releasedBandwidth,   
01268       unsigned requiredBandwidth    
01269     );
01271 
01274     enum SendUserInputModes {
01275       SendUserInputAsQ931,
01276       SendUserInputAsString,
01277       SendUserInputAsTone,
01278       SendUserInputAsRFC2833,
01279       SendUserInputInBand,
01280       SendUserInputAsProtocolDefault,
01281       NumSendUserInputModes,
01282 
01283       SendUserInputAsInlineRFC2833 = SendUserInputAsRFC2833  // For backward compatibility
01284     };
01285 #if PTRACING
01286     friend ostream & operator<<(ostream & o, SendUserInputModes m);
01287 #endif
01288 
01291     virtual void SetSendUserInputMode(SendUserInputModes mode);
01292 
01295     virtual SendUserInputModes GetSendUserInputMode() const { return sendUserInputMode; }
01296 
01302     virtual SendUserInputModes GetRealSendUserInputMode() const { return GetSendUserInputMode(); }
01303 
01310     virtual PBoolean SendUserInputString(
01311       const PString & value                   
01312     );
01313 
01330     virtual PBoolean SendUserInputTone(
01331       char tone,        
01332       unsigned duration = 0  
01333     );
01334 
01341     virtual void OnUserInputString(
01342       const PString & value   
01343     );
01344 
01351     virtual void OnUserInputTone(
01352       char tone,
01353       unsigned duration
01354     );
01355 
01359     void SendUserInputHookFlash(
01360       unsigned duration = 500  
01361     ) { SendUserInputTone('!', duration); }
01362 
01365     virtual PString GetUserInput(
01366       unsigned timeout = 30   
01367     );
01368 
01373     virtual void SetUserInput(
01374       const PString & input     
01375     );
01376 
01379     virtual PString ReadUserInput(
01380       const char * terminators = "#\r\n", 
01381       unsigned lastDigitTimeout = 4,      
01382       unsigned firstDigitTimeout = 30     
01383     );
01384 
01391     virtual PBoolean PromptUserInput(
01392       PBoolean play   
01393     );
01395 
01400     virtual bool GarbageCollection();
01402 
01407     OpalEndPoint & GetEndPoint() const { return endpoint; }
01408     
01411     OpalCall & GetCall() const { return ownerCall; }
01412 
01415     const PString & GetToken() const { return callToken; }
01416 
01419     PBoolean IsOriginating() const { return originating; }
01420 
01423     const PTime & GetPhaseTime(Phases phase) const { return m_phaseTime[phase]; }
01424 
01427     const PTime & GetSetupUpTime() const { return m_phaseTime[SetUpPhase]; }
01428 
01431     const PTime & GetAlertingTime() const { return m_phaseTime[AlertingPhase]; }
01432 
01437     const PTime & GetConnectionStartTime() const { return m_phaseTime[ConnectedPhase]; }
01438 
01441     const PTime & GetConnectionEndTime() const { return m_phaseTime[ReleasingPhase]; }
01442 
01445     const OpalProductInfo & GetProductInfo() const { return productInfo; }
01446 
01449     void SetProductInfo(
01450       const OpalProductInfo & info
01451     ) { productInfo = info; }
01452 
01455     virtual PString GetPrefixName() const;
01456 
01459     const PString & GetLocalPartyName() const { return localPartyName; }
01460 
01463     virtual void SetLocalPartyName(const PString & name);
01464 
01467     virtual PString GetLocalPartyURL() const;
01468 
01471     const PString & GetDisplayName() const { return displayName; }
01472 
01475     void SetDisplayName(const PString & name) { displayName = name; }
01476 
01482     virtual bool IsPresentationBlocked() const;
01483 
01486     const PString & GetRemotePartyName() const { return remotePartyName; }
01487 
01490     void SetRemotePartyName(const PString & name) { remotePartyName = name; }
01491 
01500     const PString & GetRemotePartyNumber() const { return remotePartyNumber; }
01501 
01507     const PString & GetRemotePartyAddress() const { return remotePartyAddress; }
01508 
01511     void SetRemotePartyAddress(const PString & addr) { remotePartyAddress = addr; }
01512 
01519     virtual PString GetRemotePartyURL() const;
01520 
01524     const PString & GetRedirectingParty() const { return m_redirectingParty; }
01525 
01529     void SetRedirectingParty(const PString & party) { m_redirectingParty = party; }
01530 
01531     // Deprecated - backward compatibility only
01532     const PString GetRemotePartyCallbackURL() const { return GetRemotePartyURL(); }
01533 
01537     PCaselessString GetRemoteApplication() const { return remoteProductInfo.AsString(); }
01538 
01541     const OpalProductInfo & GetRemoteProductInfo() const { return remoteProductInfo; }
01542 
01543 
01550     const PString & GetCalledPartyName() const { return m_calledPartyName; }
01551 
01558     const PString & GetCalledPartyNumber() const { return m_calledPartyNumber; }
01559 
01567     virtual PString GetCalledPartyURL();
01568 
01569     /* Internal function to copy party names from "network" connection to
01570        "non-network" connection such as OpalPCSSConnection. This allows
01571        the non-network GetRemoteAddress() function and its ilk to return
01572        the intuitive value, i.e. the value from the OTHER connection.
01573      */
01574     void CopyPartyNames(const OpalConnection & other);
01575 
01576 
01590     virtual PString GetAlertingType() const;
01591 
01605     virtual bool SetAlertingType(const PString & info);
01606 
01614     virtual PString GetCallInfo() const;
01615 
01619     unsigned GetMinAudioJitterDelay() const { return minAudioJitterDelay; }
01620 
01624     unsigned GetMaxAudioJitterDelay() const { return maxAudioJitterDelay; }
01625 
01628     void SetAudioJitterDelay(
01629       unsigned minDelay,   
01630       unsigned maxDelay    
01631     );
01632 
01635     OpalSilenceDetector * GetSilenceDetector() const { return silenceDetector; }
01636     
01637 #if OPAL_AEC
01638 
01640     OpalEchoCanceler * GetEchoCanceler() const { return echoCanceler; }
01641 #endif
01642 
01646     virtual PString GetIdentifier() const;
01647 
01656     virtual PINDEX GetMaxRtpPayloadSize() const;
01657 
01658     virtual OpalTransport & GetTransport() const
01659     { return *(OpalTransport *)NULL; }
01660 
01661     PDICTIONARY(MediaAddressesDict, POrdinalKey, OpalTransportAddress);
01662     MediaAddressesDict & GetMediaTransportAddresses()
01663     { return mediaTransportAddresses; }
01664 
01665 #if OPAL_STATISTICS
01666 
01668     unsigned GetVideoUpdateRequestsSent() const { return m_VideoUpdateRequestsSent; }
01669 #endif
01670 
01671 
01673     const StringOptions & GetStringOptions() const { return m_stringOptions; }
01674 
01676     void SetStringOptions(
01677       const StringOptions & options,
01678       bool overwrite
01679     );
01680 
01682     virtual void OnApplyStringOptions();
01683 
01684 #if OPAL_HAS_MIXER
01685 
01686     virtual void EnableRecording();
01687     virtual void DisableRecording();
01688 
01689 #endif
01690 
01691 #if 0 //OPAL_HAS_IM
01692 
01695     virtual bool TransmitInternalIM(
01696       const OpalMediaFormat & format, 
01697       RTP_IMFrame & body
01698     );
01699 
01703     virtual void OnReceiveInternalIM(
01704       const OpalMediaFormat & format, 
01705       RTP_IMFrame & body
01706     );
01707 
01711     virtual bool TransmitExternalIM(
01712       const OpalMediaFormat & format, 
01713       RTP_IMFrame & body
01714     );
01715 
01719     virtual bool OnReceiveExternalIM(
01720       const OpalMediaFormat & format, 
01721       RTP_IMFrame & body
01722     );
01723 
01728     RFC4103Context & GetRFC4103Context(PINDEX i) { return m_rfc4103Context[i]; };
01729 
01730   protected:
01731     RFC4103Context m_rfc4103Context[2];
01732 
01733 #endif
01734 
01735   protected:
01736     void OnConnectedInternal();
01737 
01738     PDECLARE_NOTIFIER(PThread, OpalConnection, OnReleaseThreadMain);
01739 
01740 #if OPAL_HAS_MIXER
01741     PDECLARE_NOTIFIER(RTP_DataFrame, OpalConnection, OnRecordAudio);
01742 #if OPAL_VIDEO
01743     PDECLARE_NOTIFIER(RTP_DataFrame, OpalConnection, OnRecordVideo);
01744 #endif
01745     void OnStartRecording(OpalMediaPatch * patch);
01746     void OnStopRecording(OpalMediaPatch * patch);
01747 #endif
01748 
01749   // Member variables
01750     OpalCall             & ownerCall;
01751     OpalEndPoint         & endpoint;
01752 
01753   private:
01754     PMutex               m_phaseMutex;
01755     Phases               m_phase;
01756 
01757   protected:
01758     PString              callToken;
01759     PBoolean             originating;
01760     OpalProductInfo      productInfo;
01761     PString              localPartyName;
01762     PString              displayName;
01763     PString              remotePartyName;
01764     PString              remotePartyURL;
01765     OpalProductInfo      remoteProductInfo;
01766     PString              remotePartyNumber;
01767     PString              remotePartyAddress;
01768     PString              m_redirectingParty;
01769     CallEndReason        callEndReason;
01770     PString              m_calledPartyNumber;
01771     PString              m_calledPartyName;
01772 
01773     SendUserInputModes    sendUserInputMode;
01774     PString               userInputString;
01775     PSyncPoint            userInputAvailable;
01776 
01777     OpalSilenceDetector * silenceDetector;
01778 #if OPAL_AEC
01779     OpalEchoCanceler    * echoCanceler;
01780 #endif
01781     OpalMediaFormat       m_filterMediaFormat;
01782 
01783     OpalMediaFormatList        m_localMediaFormats;
01784     MediaAddressesDict         mediaTransportAddresses;
01785     PSafeList<OpalMediaStream> mediaStreams;
01786 
01787     unsigned            minAudioJitterDelay;
01788     unsigned            maxAudioJitterDelay;
01789     unsigned            bandwidthAvailable;
01790 
01791     // The In-Band DTMF detector. This is used inside an audio filter which is
01792     // added to the audio channel.
01793 #if OPAL_PTLIB_DTMF
01794     PDTMFDecoder m_dtmfDecoder;
01795     bool         m_detectInBandDTMF;
01796     unsigned     m_dtmfScaleMultiplier;
01797     unsigned     m_dtmfScaleDivisor;
01798     PNotifier    m_dtmfDetectNotifier;
01799     PDECLARE_NOTIFIER(RTP_DataFrame, OpalConnection, OnDetectInBandDTMF);
01800 
01801     bool            m_sendInBandDTMF;
01802     OpalMediaFormat m_dtmfSendFormat;
01803     PBYTEArray      m_inBandDTMF;
01804     PINDEX          m_emittedInBandDTMF;
01805     PMutex          m_inBandMutex;
01806     PNotifier       m_dtmfSendNotifier;
01807     PDECLARE_NOTIFIER(RTP_DataFrame, OpalConnection, OnSendInBandDTMF);
01808 #endif
01809 
01810 #if PTRACING
01811     friend ostream & operator<<(ostream & o, Phases p);
01812 #endif
01813 
01814     StringOptions m_stringOptions;
01815 
01816 #if OPAL_HAS_MIXER
01817     PString       m_recordingFilename;
01818     PNotifier     m_recordAudioNotifier;
01819 #if OPAL_VIDEO
01820     PNotifier     m_recordVideoNotifier;
01821 #endif
01822 #endif
01823 
01824 #if OPAL_STATISTICS
01825     unsigned m_VideoUpdateRequestsSent;
01826 #endif
01827 
01828     struct AutoStartInfo {
01829       unsigned preferredSessionId;  // preferred session ID (only used for originating)
01830       OpalMediaType::AutoStartMode autoStart;// Mode for this session when the call is started
01831     };
01832 
01833     class AutoStartMap : public std::map<OpalMediaType, AutoStartInfo>
01834     {
01835       public:
01836         AutoStartMap();
01837         void Initialise(const OpalConnection::StringOptions & stringOptions);
01838         OpalMediaType::AutoStartMode GetAutoStart(const OpalMediaType & mediaType) const;
01839         void SetAutoStart(const OpalMediaType & mediaType, OpalMediaType::AutoStartMode autoStart);
01840 
01841       protected:
01842         bool m_initialised;
01843         PMutex m_mutex;
01844 
01845     };
01846     AutoStartMap m_autoStartInfo;
01847 
01848 #if OPAL_FAX
01849     enum {
01850       e_NotSwitchingFaxMediaStreams,
01851       e_SwitchingToFaxMediaStreams,
01852       e_SwitchingFromFaxMediaStreams
01853     } m_faxMediaStreamsSwitchState;
01854 #endif
01855 
01856 #if P_LUA
01857   protected:
01858     PLua m_lua;
01859     bool m_luaScriptLoaded;
01860 
01861   public:
01862     PLUA_BINDING_START(OpalConnection)
01863       PLUA_BINDING2(LuaSetOption, "SetOption")
01864     PLUA_BINDING_END()
01865     PLUA_DECLARE_FUNCTION(LuaSetOption);
01866 #endif
01867 
01868     // A version of PTime where default constructor creates invalid times
01869     class ZeroTime : public PTime
01870     {
01871       public:
01872         ZeroTime() : PTime(0) { }
01873     };
01874     ZeroTime m_phaseTime[NumPhases];
01875 
01876   private:
01877     P_REMOVE_VIRTUAL(PBoolean, OnIncomingConnection(unsigned int), false);
01878     P_REMOVE_VIRTUAL(PBoolean, OnIncomingConnection(), false);
01879     P_REMOVE_VIRTUAL(PBoolean, IsConnectionOnHold(), false);
01880     P_REMOVE_VIRTUAL_VOID(OnMediaPatchStart(unsigned, bool));
01881     P_REMOVE_VIRTUAL_VOID(OnMediaPatchStop(unsigned, bool));
01882     P_REMOVE_VIRTUAL_VOID(AdjustMediaFormats(OpalMediaFormatList &) const);
01883     P_REMOVE_VIRTUAL_VOID(AdjustMediaFormats(OpalMediaFormatList &, OpalConnection *) const);
01884     P_REMOVE_VIRTUAL_VOID(AdjustMediaFormats(bool,OpalMediaFormatList &,OpalConnection *) const);
01885     P_REMOVE_VIRTUAL_VOID(PreviewPeerMediaFormats(const OpalMediaFormatList &));
01886     P_REMOVE_VIRTUAL(bool, HoldConnection(), false);
01887     P_REMOVE_VIRTUAL(bool, RetrieveConnection(), false);
01888     P_REMOVE_VIRTUAL(bool, IsConnectionOnHold(bool), false);
01889     P_REMOVE_VIRTUAL_VOID(ApplyStringOptions(OpalConnection::StringOptions &));
01890     P_REMOVE_VIRTUAL(bool, OnTransferNotify(const PStringToString &), false);
01891 };
01892 
01893 #endif // OPAL_OPAL_CONNECTION_H
01894 
01895 
01896 // End of File ///////////////////////////////////////////////////////////////

Generated on 5 Jun 2012 for OPAL by  doxygen 1.6.1