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: 28445 $
00031  * $Author: rjongbloed $
00032  * $Date: 2012-10-02 20:11:02 -0500 (Tue, 02 Oct 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 
00592     void ClearCall(
00593       CallEndReason reason = EndedByLocalUser, 
00594       PSyncPoint * sync = NULL
00595     );
00596 
00601     virtual void ClearCallSynchronous(
00602       PSyncPoint * sync,                       
00603       CallEndReason reason = EndedByLocalUser  
00604     );
00605 
00609     unsigned GetQ931Cause() const { return callEndReason.q931; }
00610 
00614     void SetQ931Cause(unsigned v) { callEndReason.q931 = v; }
00615 
00622     virtual bool TransferConnection(
00623       const PString & remoteParty   
00624     );
00625     
00633     virtual bool Hold(
00634       bool fromRemote,  
00635       bool placeOnHold  
00636     );
00637 
00642     virtual bool IsOnHold(
00643       bool fromRemote  
00644     );
00645 
00650     virtual void OnHold(
00651       bool fromRemote,               
00652       bool onHold                    
00653     );
00655 
00683     virtual PBoolean OnIncomingConnection(unsigned int options, OpalConnection::StringOptions * stringOptions);
00684 
00691     virtual PBoolean SetUpConnection() = 0;
00692 
00696     virtual PBoolean OnSetUpConnection();
00697 
00698     
00713     virtual void OnProceeding();
00714 
00725     virtual void OnAlerting();
00726 
00737     virtual PBoolean SetAlerting(
00738       const PString & calleeName,   
00739       PBoolean withMedia                
00740     ) = 0;
00741 
00758     virtual AnswerCallResponse OnAnswerCall(
00759       const PString & callerName        
00760     );
00761 
00772     virtual void AnsweringCall(
00773       AnswerCallResponse response 
00774     );
00775 
00790     virtual void OnConnected();
00791 
00802     virtual PBoolean SetConnected();
00803 
00815     virtual void OnEstablished();
00816 
00864     virtual bool OnTransferNotify(
00865       const PStringToString & info, 
00866       const OpalConnection * transferringConnection
00868     );
00869 
00878     virtual void Release(
00879       CallEndReason reason = EndedByLocalUser, 
00880       bool synchronous = false                 
00881     );
00882 
00900     virtual void OnReleased();
00902 
00913     virtual PString GetDestinationAddress();
00914 
00924     virtual PBoolean ForwardCall(
00925       const PString & forwardParty   
00926     );
00927 
00930     PSafePtr<OpalConnection> GetOtherPartyConnection() const;
00931 
00934     template <class cls> PSafePtr<cls> GetOtherPartyConnectionAs() const { return PSafePtrCast<OpalConnection, cls>(GetOtherPartyConnection()); }
00936 
00945     virtual OpalMediaFormatList GetMediaFormats() const;
00946 
00951     virtual OpalMediaFormatList GetLocalMediaFormats();
00952 
00966     virtual void AdjustMediaFormats(
00967       bool local,                             
00968       const OpalConnection * otherConnection, 
00969       OpalMediaFormatList & mediaFormats      
00970     ) const;
00971 
00979     virtual unsigned GetNextSessionID(
00980       const OpalMediaType & mediaType,   
00981       bool isSource                      
00982     );
00983 
00990     virtual OpalMediaType::AutoStartMode GetAutoStart(
00991       const OpalMediaType & mediaType  
00992     ) const;
00993 
00996     virtual void AutoStartMediaStreams(
00997       bool force = false 
00998     );
00999 
01000 #if OPAL_FAX
01001 
01003     virtual bool SwitchFaxMediaStreams(
01004       bool toT38  
01005     );
01006 
01011     virtual void OnSwitchedFaxMediaStreams(
01012       bool toT38,       
01013       bool success      
01014     );
01015 
01020     virtual bool OnSwitchingFaxMediaStreams(
01021       bool toT38   
01022     );
01023 #endif
01024 
01027     virtual OpalMediaStreamPtr OpenMediaStream(
01028       const OpalMediaFormat & mediaFormat, 
01029       unsigned sessionID,                  
01030       bool isSource                        
01031     );
01032 
01035     virtual bool CloseMediaStream(
01036       unsigned sessionId,  
01037       bool source          
01038     );
01039 
01042     virtual bool CloseMediaStream(
01043       OpalMediaStream & stream  
01044     );
01045 
01053     bool RemoveMediaStream(
01054       OpalMediaStream & strm  
01055     );
01056 
01059     virtual void StartMediaStreams();
01060     
01063     virtual void CloseMediaStreams();
01064     
01067     virtual void PauseMediaStreams(
01068       bool paused  
01069     );
01070 
01073     virtual void OnPauseMediaStream(
01074       OpalMediaStream & strm,     
01075       bool paused                 
01076     );
01077 
01090     virtual OpalMediaStream * CreateMediaStream(
01091       const OpalMediaFormat & mediaFormat, 
01092       unsigned sessionID,                  
01093       PBoolean isSource                        
01094     );
01095 
01102     OpalMediaStreamPtr GetMediaStream(
01103       const PString & streamID,  
01104       bool source                
01105     ) const;
01106 
01112     OpalMediaStreamPtr GetMediaStream(
01113       unsigned sessionId,  
01114       bool source          
01115     ) const;
01116 
01127     OpalMediaStreamPtr GetMediaStream(
01128       const OpalMediaType & mediaType,    
01129       bool source,                        
01130       OpalMediaStreamPtr previous = NULL  
01131     ) const;
01132 
01144     virtual PBoolean OnOpenMediaStream(
01145       OpalMediaStream & stream    
01146     );
01147 
01152     virtual void OnClosedMediaStream(
01153       const OpalMediaStream & stream     
01154     );
01155 
01164     virtual void OnPatchMediaStream(
01165       PBoolean isSource,        
01166       OpalMediaPatch & patch    
01167     );
01168 
01171     virtual void OnStartMediaPatch(
01172       OpalMediaPatch & patch    
01173     );
01174 
01177     virtual void OnStopMediaPatch(
01178       OpalMediaPatch & patch    
01179     );
01180 
01186     virtual bool OnMediaCommand(
01187       OpalMediaStream & stream,         
01188       const OpalMediaCommand & command  
01189     );
01190 
01195     virtual void AttachRFC2833HandlerToPatch(PBoolean isSource, OpalMediaPatch & patch);
01196 
01202     virtual PBoolean IsMediaBypassPossible(
01203       unsigned sessionID                  
01204     ) const;
01205 
01206 #if OPAL_VIDEO
01207 
01209     virtual PBoolean CreateVideoInputDevice(
01210       const OpalMediaFormat & mediaFormat,  
01211       PVideoInputDevice * & device,         
01212       PBoolean & autoDelete                     
01213     );
01214 
01218     virtual PBoolean CreateVideoOutputDevice(
01219       const OpalMediaFormat & mediaFormat,  
01220       PBoolean preview,                         
01221       PVideoOutputDevice * & device,        
01222       PBoolean & autoDelete                     
01223     );
01224 
01230     virtual bool SendVideoUpdatePicture(
01231       unsigned sessionID = 0, 
01232       bool force = false      
01233     ) const;
01234 #endif
01235 
01239     virtual PBoolean SetAudioVolume(
01240       PBoolean source,        
01241       unsigned percentage     
01242     );
01243 
01247     virtual PBoolean GetAudioVolume(
01248       PBoolean source,        
01249       unsigned & percentage   
01250     );
01251 
01254     virtual bool SetAudioMute(
01255       bool source,        
01256       bool mute           
01257     );
01258 
01261     virtual bool GetAudioMute(
01262       bool source,        
01263       bool & mute         
01264     );
01265 
01269     virtual unsigned GetAudioSignalLevel(
01270       PBoolean source                   
01271     );
01273 
01278     unsigned GetBandwidthAvailable() const { return bandwidthAvailable; }
01279 
01284     virtual PBoolean SetBandwidthAvailable(
01285       unsigned newBandwidth,    
01286       PBoolean force = false        
01287     );
01288 
01293     virtual unsigned GetBandwidthUsed() const;
01294 
01303     virtual PBoolean SetBandwidthUsed(
01304       unsigned releasedBandwidth,   
01305       unsigned requiredBandwidth    
01306     );
01308 
01311     enum SendUserInputModes {
01312       SendUserInputAsQ931,
01313       SendUserInputAsString,
01314       SendUserInputAsTone,
01315       SendUserInputAsRFC2833,
01316       SendUserInputInBand,
01317       SendUserInputAsProtocolDefault,
01318       NumSendUserInputModes,
01319 
01320       SendUserInputAsInlineRFC2833 = SendUserInputAsRFC2833  // For backward compatibility
01321     };
01322 #if PTRACING
01323     friend ostream & operator<<(ostream & o, SendUserInputModes m);
01324 #endif
01325 
01328     virtual void SetSendUserInputMode(SendUserInputModes mode);
01329 
01332     virtual SendUserInputModes GetSendUserInputMode() const { return sendUserInputMode; }
01333 
01339     virtual SendUserInputModes GetRealSendUserInputMode() const { return GetSendUserInputMode(); }
01340 
01347     virtual PBoolean SendUserInputString(
01348       const PString & value                   
01349     );
01350 
01367     virtual PBoolean SendUserInputTone(
01368       char tone,        
01369       unsigned duration = 0  
01370     );
01371 
01378     virtual void OnUserInputString(
01379       const PString & value   
01380     );
01381 
01388     virtual void OnUserInputTone(
01389       char tone,
01390       unsigned duration
01391     );
01392 
01396     void SendUserInputHookFlash(
01397       unsigned duration = 500  
01398     ) { SendUserInputTone('!', duration); }
01399 
01402     virtual PString GetUserInput(
01403       unsigned timeout = 30   
01404     );
01405 
01410     virtual void SetUserInput(
01411       const PString & input     
01412     );
01413 
01416     virtual PString ReadUserInput(
01417       const char * terminators = "#\r\n", 
01418       unsigned lastDigitTimeout = 4,      
01419       unsigned firstDigitTimeout = 30     
01420     );
01421 
01428     virtual PBoolean PromptUserInput(
01429       PBoolean play   
01430     );
01432 
01437     virtual bool GarbageCollection();
01439 
01444     OpalEndPoint & GetEndPoint() const { return endpoint; }
01445     
01448     OpalCall & GetCall() const { return ownerCall; }
01449 
01452     const PString & GetToken() const { return callToken; }
01453 
01456     PBoolean IsOriginating() const { return originating; }
01457 
01460     const PTime & GetPhaseTime(Phases phase) const { return m_phaseTime[phase]; }
01461 
01464     const PTime & GetSetupUpTime() const { return m_phaseTime[SetUpPhase]; }
01465 
01468     const PTime & GetAlertingTime() const { return m_phaseTime[AlertingPhase]; }
01469 
01474     const PTime & GetConnectionStartTime() const { return m_phaseTime[ConnectedPhase]; }
01475 
01478     const PTime & GetConnectionEndTime() const { return m_phaseTime[ReleasingPhase]; }
01479 
01482     const OpalProductInfo & GetProductInfo() const { return productInfo; }
01483 
01486     void SetProductInfo(
01487       const OpalProductInfo & info
01488     ) { productInfo = info; }
01489 
01492     virtual PString GetPrefixName() const;
01493 
01496     const PString & GetLocalPartyName() const { return localPartyName; }
01497 
01500     virtual void SetLocalPartyName(const PString & name);
01501 
01504     virtual PString GetLocalPartyURL() const;
01505 
01508     const PString & GetDisplayName() const { return displayName; }
01509 
01512     void SetDisplayName(const PString & name) { displayName = name; }
01513 
01519     virtual bool IsPresentationBlocked() const;
01520 
01523     const PString & GetRemotePartyName() const { return remotePartyName; }
01524 
01527     void SetRemotePartyName(const PString & name) { remotePartyName = name; }
01528 
01537     const PString & GetRemotePartyNumber() const { return remotePartyNumber; }
01538 
01544     const PString & GetRemotePartyAddress() const { return remotePartyAddress; }
01545 
01548     void SetRemotePartyAddress(const PString & addr) { remotePartyAddress = addr; }
01549 
01556     virtual PString GetRemotePartyURL() const;
01557 
01561     const PString & GetRedirectingParty() const { return m_redirectingParty; }
01562 
01566     void SetRedirectingParty(const PString & party) { m_redirectingParty = party; }
01567 
01568     // Deprecated - backward compatibility only
01569     const PString GetRemotePartyCallbackURL() const { return GetRemotePartyURL(); }
01570 
01574     PCaselessString GetRemoteApplication() const { return remoteProductInfo.AsString(); }
01575 
01578     const OpalProductInfo & GetRemoteProductInfo() const { return remoteProductInfo; }
01579 
01580 
01587     const PString & GetCalledPartyName() const { return m_calledPartyName; }
01588 
01595     const PString & GetCalledPartyNumber() const { return m_calledPartyNumber; }
01596 
01604     virtual PString GetCalledPartyURL();
01605 
01606     /* Internal function to copy party names from "network" connection to
01607        "non-network" connection such as OpalPCSSConnection. This allows
01608        the non-network GetRemoteAddress() function and its ilk to return
01609        the intuitive value, i.e. the value from the OTHER connection.
01610      */
01611     void CopyPartyNames(const OpalConnection & other);
01612 
01613 
01627     virtual PString GetAlertingType() const;
01628 
01642     virtual bool SetAlertingType(const PString & info);
01643 
01651     virtual PString GetCallInfo() const;
01652 
01656     unsigned GetMinAudioJitterDelay() const { return minAudioJitterDelay; }
01657 
01661     unsigned GetMaxAudioJitterDelay() const { return maxAudioJitterDelay; }
01662 
01665     void SetAudioJitterDelay(
01666       unsigned minDelay,   
01667       unsigned maxDelay    
01668     );
01669 
01672     OpalSilenceDetector * GetSilenceDetector() const { return silenceDetector; }
01673     
01674 #if OPAL_AEC
01675 
01677     OpalEchoCanceler * GetEchoCanceler() const { return echoCanceler; }
01678 #endif
01679 
01683     virtual PString GetIdentifier() const;
01684 
01693     virtual PINDEX GetMaxRtpPayloadSize() const;
01694 
01695     virtual OpalTransport & GetTransport() const
01696     { return *(OpalTransport *)NULL; }
01697 
01698     PDICTIONARY(MediaAddressesDict, POrdinalKey, OpalTransportAddress);
01699     MediaAddressesDict & GetMediaTransportAddresses()
01700     { return mediaTransportAddresses; }
01701 
01702 #if OPAL_STATISTICS
01703 
01705     unsigned GetVideoUpdateRequestsSent() const { return m_VideoUpdateRequestsSent; }
01706 #endif
01707 
01708 
01710     const StringOptions & GetStringOptions() const { return m_stringOptions; }
01711 
01713     void SetStringOptions(
01714       const StringOptions & options,
01715       bool overwrite
01716     );
01717 
01719     virtual void OnApplyStringOptions();
01720 
01721 #if OPAL_HAS_MIXER
01722 
01723     virtual void EnableRecording();
01724     virtual void DisableRecording();
01725 
01726 #endif
01727 
01728 #if 0 //OPAL_HAS_IM
01729 
01732     virtual bool TransmitInternalIM(
01733       const OpalMediaFormat & format, 
01734       RTP_IMFrame & body
01735     );
01736 
01740     virtual void OnReceiveInternalIM(
01741       const OpalMediaFormat & format, 
01742       RTP_IMFrame & body
01743     );
01744 
01748     virtual bool TransmitExternalIM(
01749       const OpalMediaFormat & format, 
01750       RTP_IMFrame & body
01751     );
01752 
01756     virtual bool OnReceiveExternalIM(
01757       const OpalMediaFormat & format, 
01758       RTP_IMFrame & body
01759     );
01760 
01765     RFC4103Context & GetRFC4103Context(PINDEX i) { return m_rfc4103Context[i]; };
01766 
01767   protected:
01768     RFC4103Context m_rfc4103Context[2];
01769 
01770 #endif
01771 
01772   protected:
01773     void OnConnectedInternal();
01774 
01775     PDECLARE_NOTIFIER(PThread, OpalConnection, OnReleaseThreadMain);
01776 
01777 #if OPAL_HAS_MIXER
01778     PDECLARE_NOTIFIER(RTP_DataFrame, OpalConnection, OnRecordAudio);
01779 #if OPAL_VIDEO
01780     PDECLARE_NOTIFIER(RTP_DataFrame, OpalConnection, OnRecordVideo);
01781 #endif
01782     void OnStartRecording(OpalMediaPatch * patch);
01783     void OnStopRecording(OpalMediaPatch * patch);
01784 #endif
01785 
01786   // Member variables
01787     OpalCall             & ownerCall;
01788     OpalEndPoint         & endpoint;
01789 
01790   private:
01791     PMutex               m_phaseMutex;
01792     Phases               m_phase;
01793 
01794   protected:
01795     PString              callToken;
01796     PBoolean             originating;
01797     OpalProductInfo      productInfo;
01798     PString              localPartyName;
01799     PString              displayName;
01800     PString              remotePartyName;
01801     PString              remotePartyURL;
01802     OpalProductInfo      remoteProductInfo;
01803     PString              remotePartyNumber;
01804     PString              remotePartyAddress;
01805     PString              m_redirectingParty;
01806     CallEndReason        callEndReason;
01807     PString              m_calledPartyNumber;
01808     PString              m_calledPartyName;
01809 
01810     SendUserInputModes    sendUserInputMode;
01811     PString               userInputString;
01812     PSyncPoint            userInputAvailable;
01813 
01814     OpalSilenceDetector * silenceDetector;
01815 #if OPAL_AEC
01816     OpalEchoCanceler    * echoCanceler;
01817 #endif
01818     OpalMediaFormat       m_filterMediaFormat;
01819 
01820     OpalMediaFormatList        m_localMediaFormats;
01821     MediaAddressesDict         mediaTransportAddresses;
01822     PSafeList<OpalMediaStream> mediaStreams;
01823 
01824     unsigned            minAudioJitterDelay;
01825     unsigned            maxAudioJitterDelay;
01826     unsigned            bandwidthAvailable;
01827 
01828     // The In-Band DTMF detector. This is used inside an audio filter which is
01829     // added to the audio channel.
01830 #if OPAL_PTLIB_DTMF
01831     PDTMFDecoder m_dtmfDecoder;
01832     bool         m_detectInBandDTMF;
01833     unsigned     m_dtmfScaleMultiplier;
01834     unsigned     m_dtmfScaleDivisor;
01835     PNotifier    m_dtmfDetectNotifier;
01836     PDECLARE_NOTIFIER(RTP_DataFrame, OpalConnection, OnDetectInBandDTMF);
01837 
01838     bool            m_sendInBandDTMF;
01839     OpalMediaFormat m_dtmfSendFormat;
01840     PBYTEArray      m_inBandDTMF;
01841     PINDEX          m_emittedInBandDTMF;
01842     PMutex          m_inBandMutex;
01843     PNotifier       m_dtmfSendNotifier;
01844     PDECLARE_NOTIFIER(RTP_DataFrame, OpalConnection, OnSendInBandDTMF);
01845 #endif
01846 
01847 #if PTRACING
01848     friend ostream & operator<<(ostream & o, Phases p);
01849 #endif
01850 
01851     StringOptions m_stringOptions;
01852 
01853 #if OPAL_HAS_MIXER
01854     PString       m_recordingFilename;
01855     PNotifier     m_recordAudioNotifier;
01856 #if OPAL_VIDEO
01857     PNotifier     m_recordVideoNotifier;
01858 #endif
01859 #endif
01860 
01861 #if OPAL_STATISTICS
01862     unsigned m_VideoUpdateRequestsSent;
01863 #endif
01864 
01865     struct AutoStartInfo {
01866       unsigned preferredSessionId;  // preferred session ID (only used for originating)
01867       OpalMediaType::AutoStartMode autoStart;// Mode for this session when the call is started
01868     };
01869 
01870     class AutoStartMap : public std::map<OpalMediaType, AutoStartInfo>
01871     {
01872       public:
01873         AutoStartMap();
01874         void Initialise(const OpalConnection::StringOptions & stringOptions);
01875         OpalMediaType::AutoStartMode GetAutoStart(const OpalMediaType & mediaType) const;
01876         void SetAutoStart(const OpalMediaType & mediaType, OpalMediaType::AutoStartMode autoStart);
01877 
01878       protected:
01879         bool m_initialised;
01880         PMutex m_mutex;
01881 
01882     };
01883     AutoStartMap m_autoStartInfo;
01884 
01885 #if OPAL_FAX
01886     enum {
01887       e_NotSwitchingFaxMediaStreams,
01888       e_SwitchingToFaxMediaStreams,
01889       e_SwitchingFromFaxMediaStreams
01890     } m_faxMediaStreamsSwitchState;
01891 #endif
01892 
01893 #if P_LUA
01894   protected:
01895     PLua m_lua;
01896     bool m_luaScriptLoaded;
01897 
01898   public:
01899     PLUA_BINDING_START(OpalConnection)
01900       PLUA_BINDING2(LuaSetOption, "SetOption")
01901     PLUA_BINDING_END()
01902     PLUA_DECLARE_FUNCTION(LuaSetOption);
01903 #endif
01904 
01905     // A version of PTime where default constructor creates invalid times
01906     class ZeroTime : public PTime
01907     {
01908       public:
01909         ZeroTime() : PTime(0) { }
01910     };
01911     ZeroTime m_phaseTime[NumPhases];
01912 
01913   private:
01914     P_REMOVE_VIRTUAL(PBoolean, OnIncomingConnection(unsigned int), false);
01915     P_REMOVE_VIRTUAL(PBoolean, OnIncomingConnection(), false);
01916     P_REMOVE_VIRTUAL(PBoolean, IsConnectionOnHold(), false);
01917     P_REMOVE_VIRTUAL_VOID(OnMediaPatchStart(unsigned, bool));
01918     P_REMOVE_VIRTUAL_VOID(OnMediaPatchStop(unsigned, bool));
01919     P_REMOVE_VIRTUAL_VOID(AdjustMediaFormats(OpalMediaFormatList &) const);
01920     P_REMOVE_VIRTUAL_VOID(AdjustMediaFormats(OpalMediaFormatList &, OpalConnection *) const);
01921     P_REMOVE_VIRTUAL_VOID(AdjustMediaFormats(bool,OpalMediaFormatList &,OpalConnection *) const);
01922     P_REMOVE_VIRTUAL_VOID(PreviewPeerMediaFormats(const OpalMediaFormatList &));
01923     P_REMOVE_VIRTUAL(bool, HoldConnection(), false);
01924     P_REMOVE_VIRTUAL(bool, RetrieveConnection(), false);
01925     P_REMOVE_VIRTUAL(bool, IsConnectionOnHold(bool), false);
01926     P_REMOVE_VIRTUAL_VOID(ApplyStringOptions(OpalConnection::StringOptions &));
01927     P_REMOVE_VIRTUAL(bool, OnTransferNotify(const PStringToString &), false);
01928     P_REMOVE_VIRTUAL_VOID(OnSwitchedFaxMediaStreams(bool));
01929 };
01930 
01931 #endif // OPAL_OPAL_CONNECTION_H
01932 
01933 
01934 // End of File ///////////////////////////////////////////////////////////////

Generated on 14 Aug 2013 for OPAL by  doxygen 1.4.7