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: 29960 $
00031  * $Author: rjongbloed $
00032  * $Date: 2013-06-13 23:26:53 -0500 (Thu, 13 Jun 2013) $
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_SCRIPT
00053 // Inside #if so does not force loading of factories when statically linked.
00054 #include <ptclib/script.h>
00055 #endif
00056 
00057 
00058 class OpalEndPoint;
00059 class OpalCall;
00060 class OpalConferenceState;
00061 class OpalSilenceDetector;
00062 class OpalEchoCanceler;
00063 class OpalRFC2833Proto;
00064 class OpalRFC2833Info;
00065 class PURL;
00066 
00067 
00068 #define OPAL_URL_PARAM_PREFIX "OPAL-"
00069 
00070 #define OPAL_OPT_AUTO_START           "AutoStart"             
00071 #define OPAL_OPT_CALL_IDENTIFIER      "Call-Identifier"       
00072 #define OPAL_OPT_CALLING_PARTY_URL    "Calling-Party-URL"     
00073 #define OPAL_OPT_CALLING_PARTY_NUMBER "Calling-Party-Number"  
00074 #define OPAL_OPT_CALLING_PARTY_NAME   "Calling-Party-Name"    
00075 #define OPAL_OPT_CALLING_PARTY_DOMAIN "Calling-Party-Domain"  
00076 #define OPAL_OPT_CALLING_DISPLAY_NAME "Calling-Display-Name"  
00077 #define OPAL_OPT_CALLED_PARTY_NAME    "Called-Party-Name"     
00078 #define OPAL_OPT_CALLED_DISPLAY_NAME  "Called-Display-Name"   
00079 #define OPAL_OPT_REDIRECTING_PARTY    "Redirecting-Party"     
00080 #define OPAL_OPT_PRESENTATION_BLOCK   "Presentation-Block"    
00081 #define OPAL_OPT_ORIGINATOR_ADDRESS   "Originator-Address"    
00082 #define OPAL_OPT_INTERFACE            "Interface"             
00083 #define OPAL_OPT_USER_INPUT_MODE      "User-Input-Mode"       
00084 
00085 #define OPAL_OPT_ENABLE_INBAND_DTMF   "EnableInbandDTMF"      
00086 #define OPAL_OPT_ENABLE_INBAND_DTMF   "EnableInbandDTMF"      
00087 #define OPAL_OPT_DETECT_INBAND_DTMF   "DetectInBandDTMF"      
00088 #define OPAL_OPT_SEND_INBAND_DTMF     "SendInBandDTMF"        
00089 #define OPAL_OPT_DTMF_MULT            "dtmfmult"
00090 #define OPAL_OPT_DTMF_DIV             "dtmfdiv"
00091 #define OPAL_OPT_DISABLE_JITTER       "Disable-Jitter"        
00092 #define OPAL_OPT_MAX_JITTER           "Max-Jitter"            
00093 #define OPAL_OPT_MIN_JITTER           "Min-Jitter"            
00094 #define OPAL_OPT_RECORD_AUDIO         "Record-Audio"          
00095 #define OPAL_OPT_ALERTING_TYPE        "Alerting-Type"         
00096 #define OPAL_OPT_REMOVE_CODEC         "Remove-Codec"          
00097 
00098 
00117 #define OPAL_OPT_VIDUP_METHODS        "Video-Update-Picture-Method"
00118 #define OPAL_OPT_VIDUP_METHOD_OOB     1
00119 #define OPAL_OPT_VIDUP_METHOD_RTCP    2
00120 #define OPAL_OPT_VIDUP_METHOD_PLI     4
00121 #define OPAL_OPT_VIDUP_METHOD_FIR     8
00122 #define OPAL_OPT_VIDUP_METHOD_DEFAULT 3
00123 
00124 
00125 
00338 class OpalProductInfo
00339 {
00340   public:
00341     OpalProductInfo();
00342 
00343     static OpalProductInfo & Default();
00344 
00345     friend ostream & operator<<(ostream & strm, const OpalProductInfo & info);
00346 
00350     PCaselessString AsString() const;
00351 
00352     PCaselessString vendor;
00353     PCaselessString name;
00354     PCaselessString version;
00355     PCaselessString comments;
00356 
00357     BYTE t35CountryCode;
00358     BYTE t35Extension;
00359     WORD manufacturerCode;
00360 
00361   private:
00362     OpalProductInfo(bool);
00363 };
00364 
00365 
00383 class OpalConnection : public PSafeObject
00384 {
00385     PCLASSINFO(OpalConnection, PSafeObject);
00386   public:
00391     P_DECLARE_TRACED_ENUM_EX(CallEndReasonCodes,NumCallEndReasons,
00392       EndedByLocalUser,0,            
00393       EndedByNoAccept,               
00394       EndedByAnswerDenied,           
00395       EndedByRemoteUser,             
00396       EndedByRefusal,                
00397       EndedByNoAnswer,               
00398       EndedByCallerAbort,            
00399       EndedByTransportFail,          
00400       EndedByConnectFail,            
00401       EndedByGatekeeper,             
00402       EndedByNoUser,                 
00403       EndedByNoBandwidth,            
00404       EndedByCapabilityExchange,     
00405       EndedByCallForwarded,          
00406       EndedBySecurityDenial,         
00407       EndedByLocalBusy,              
00408       EndedByLocalCongestion,        
00409       EndedByRemoteBusy,             
00410       EndedByRemoteCongestion,       
00411       EndedByUnreachable,            
00412       EndedByNoEndPoint,             
00413       EndedByHostOffline,            
00414       EndedByTemporaryFailure,       
00415       EndedByQ931Cause,              
00416       EndedByDurationLimit,          
00417       EndedByInvalidConferenceID,    
00418       EndedByNoDialTone,             
00419       EndedByNoRingBackTone,         
00420       EndedByOutOfService,           
00421       EndedByAcceptingCallWaiting,   
00422       EndedByGkAdmissionFailed,      
00423       EndedByMediaFailed,            
00424       EndedByCallCompletedElsewhere, 
00425       EndedByCertificateAuthority,   
00426       EndedByIllegalAddress          
00427     );
00428 
00429     struct CallEndReason {
00430       CallEndReason(
00431         CallEndReasonCodes reason = NumCallEndReasons,
00432         unsigned cause = 0
00433       ) : code(reason), q931(cause) { }
00434       explicit CallEndReason(
00435         long reason
00436       ) : code((CallEndReasonCodes)(reason&0xff)), q931((reason>>8)&0xff) { }
00437 
00438       __inline operator CallEndReasonCodes() const { return code; }
00439 
00440       __inline int AsInteger() const { return code|(q931<<8); }
00441 
00442       CallEndReasonCodes code:8; // Normalised OPAL code
00443       unsigned           q931:8; // PSTN Interworking code, actually Q.850
00444     };
00445 
00446 #if PTRACING
00447     friend ostream & operator<<(ostream & o, CallEndReason reason);
00448 #endif
00449 
00450     P_DECLARE_TRACED_ENUM(AnswerCallResponse,
00451       AnswerCallNow,               
00452       AnswerCallDenied,            
00453       AnswerCallPending,           
00454       AnswerCallDeferred,          
00455       AnswerCallAlertWithMedia,    
00456       AnswerCallDeferredWithMedia, 
00457       AnswerCallProgress,          
00458       AnswerCallNowAndReleaseCurrent 
00459     );
00460 
00463     enum Options {
00464       FastStartOptionDisable       = 0x0001,   // H.323 specific
00465       FastStartOptionEnable        = 0x0002,
00466       FastStartOptionMask          = 0x0003,
00467 
00468       H245TunnelingOptionDisable   = 0x0004,   // H.323 specific
00469       H245TunnelingOptionEnable    = 0x0008,
00470       H245TunnelingOptionMask      = 0x000c,
00471 
00472       H245inSetupOptionDisable     = 0x0010,   // H.323 specific
00473       H245inSetupOptionEnable      = 0x0020,
00474       H245inSetupOptionMask        = 0x0030,
00475 
00476       DetectInBandDTMFOptionDisable = 0x0040,  // SIP and H.323
00477       DetectInBandDTMFOptionEnable  = 0x0080,
00478       DetectInBandDTMFOptionMask    = 0x00c0,
00479 
00480       RTPAggregationDisable        = 0x0100,   // SIP and H.323
00481       RTPAggregationEnable         = 0x0200,
00482       RTPAggregationMask           = 0x0300,
00483 
00484       SendDTMFAsDefault            = 0x0000,   // SIP and H.323
00485       SendDTMFAsString             = 0x0400,
00486       SendDTMFAsTone               = 0x0800,
00487       SendDTMFAsRFC2833            = 0x0c00,
00488       SendDTMFMask                 = 0x0c00
00489     };
00490 
00491     class StringOptions : public PStringOptions 
00492     {
00493       public:
00498         void ExtractFromURL(
00499           PURL & url
00500         );
00501     };
00502 
00507     OpalConnection(
00508       OpalCall & call,                         
00509       OpalEndPoint & endpoint,                 
00510       const PString & token,                   
00511       unsigned options = 0,                    
00512       OpalConnection::StringOptions * stringOptions = NULL 
00513     );  
00514 
00517     ~OpalConnection();
00519 
00526     void PrintOn(
00527       ostream & strm    
00528     ) const;
00530 
00547     virtual bool IsNetworkConnection() const = 0;
00548 
00552     P_DECLARE_TRACED_ENUM(Phases,
00553       UninitialisedPhase,   
00554       SetUpPhase,           
00555       ProceedingPhase,      
00556       AlertingPhase,        
00557       ConnectedPhase,       
00558       EstablishedPhase,     
00559       ForwardingPhase,      
00560       ReleasingPhase,       
00561       ReleasedPhase         
00562     );
00563 
00568     __inline Phases GetPhase() const { return m_phase; }
00569 
00571     __inline bool IsEstablished() const { return m_phase == EstablishedPhase; }
00572 
00574     __inline bool IsReleased() const { return m_phase >= ReleasingPhase; }
00575 
00580     void SetPhase(
00581       Phases phaseToSet  
00582     );
00583 
00592     CallEndReason GetCallEndReason() const { return callEndReason; }
00593 
00596     static PString GetCallEndReasonText(CallEndReason reason);
00597     PString GetCallEndReasonText() const { return GetCallEndReasonText(callEndReason); }
00598 
00601     static void SetCallEndReasonText(CallEndReasonCodes reasonCode, const PString & newText);
00602 
00607     virtual void SetCallEndReason(
00608       CallEndReason reason        
00609     );
00610 
00620     void ClearCall(
00621       CallEndReason reason = EndedByLocalUser, 
00622       PSyncPoint * sync = NULL
00623     );
00624 
00629     virtual void ClearCallSynchronous(
00630       PSyncPoint * sync,                       
00631       CallEndReason reason = EndedByLocalUser  
00632     );
00633 
00637     unsigned GetQ931Cause() const { return callEndReason.q931; }
00638 
00642     void SetQ931Cause(unsigned v) { callEndReason.q931 = v; }
00643 
00650     virtual bool TransferConnection(
00651       const PString & remoteParty   
00652     );
00653     
00661     virtual bool Hold(
00662       bool fromRemote,  
00663       bool placeOnHold  
00664     );
00665 
00670     virtual bool IsOnHold(
00671       bool fromRemote  
00672     );
00673 
00678     virtual void OnHold(
00679       bool fromRemote,               
00680       bool onHold                    
00681     );
00683 
00711     virtual PBoolean OnIncomingConnection(unsigned int options, OpalConnection::StringOptions * stringOptions);
00712 
00720     virtual PBoolean SetUpConnection();
00721 
00725     virtual PBoolean OnSetUpConnection();
00726 
00727     
00742     virtual void OnProceeding();
00743 
00754     virtual void OnAlerting();
00755 
00766     virtual PBoolean SetAlerting(
00767       const PString & calleeName,   
00768       PBoolean withMedia                
00769     );
00770 
00787     virtual AnswerCallResponse OnAnswerCall(
00788       const PString & callerName        
00789     );
00790 
00801     virtual void AnsweringCall(
00802       AnswerCallResponse response 
00803     );
00804 
00819     virtual void OnConnected();
00820 
00831     virtual PBoolean SetConnected();
00832 
00844     virtual void OnEstablished();
00845 
00893     virtual bool OnTransferNotify(
00894       const PStringToString & info, 
00895       const OpalConnection * transferringConnection
00897     );
00898 
00907     virtual void Release(
00908       CallEndReason reason = EndedByLocalUser, 
00909       bool synchronous = false                 
00910     );
00911 
00929     virtual void OnReleased();
00931 
00942     virtual PString GetDestinationAddress();
00943 
00953     virtual PBoolean ForwardCall(
00954       const PString & forwardParty   
00955     );
00956 
00959     PSafePtr<OpalConnection> GetOtherPartyConnection() const;
00960 
00963     template <class cls> PSafePtr<cls> GetOtherPartyConnectionAs() const { return PSafePtrCast<OpalConnection, cls>(GetOtherPartyConnection()); }
00965 
00974     virtual OpalMediaFormatList GetMediaFormats() const;
00975 
00980     virtual OpalMediaFormatList GetLocalMediaFormats();
00981 
00995     virtual void AdjustMediaFormats(
00996       bool local,                             
00997       const OpalConnection * otherConnection, 
00998       OpalMediaFormatList & mediaFormats      
00999     ) const;
01000 
01008     virtual unsigned GetNextSessionID(
01009       const OpalMediaType & mediaType,   
01010       bool isSource                      
01011     );
01012 
01016     virtual bool RequireSymmetricMediaStreams() const;
01017 
01024     virtual OpalMediaType::AutoStartMode GetAutoStart(
01025       const OpalMediaType & mediaType  
01026     ) const;
01027 
01030     virtual void AutoStartMediaStreams(
01031       bool transfer = false 
01032     );
01033 
01034 #if OPAL_T38_CAPABILITY
01035 
01037     virtual bool SwitchFaxMediaStreams(
01038       bool toT38  
01039     );
01040 
01045     virtual void OnSwitchedFaxMediaStreams(
01046       bool toT38,       
01047       bool success      
01048     );
01049 
01054     virtual bool OnSwitchingFaxMediaStreams(
01055       bool toT38   
01056     );
01057 #endif // OPAL_T38_CAPABILITY
01058 
01061     virtual OpalMediaStreamPtr OpenMediaStream(
01062       const OpalMediaFormat & mediaFormat, 
01063       unsigned sessionID,                  
01064       bool isSource                        
01065     );
01066 
01069     bool CloseMediaStream(
01070       unsigned sessionId,  
01071       bool source          
01072     );
01073 
01081     bool RemoveMediaStream(
01082       OpalMediaStream & strm  
01083     );
01084 
01087     virtual void StartMediaStreams();
01088     
01091     virtual void CloseMediaStreams();
01092     
01095     virtual void PauseMediaStreams(
01096       bool paused  
01097     );
01098 
01101     virtual void OnPauseMediaStream(
01102       OpalMediaStream & strm,     
01103       bool paused                 
01104     );
01105 
01118     virtual OpalMediaStream * CreateMediaStream(
01119       const OpalMediaFormat & mediaFormat, 
01120       unsigned sessionID,                  
01121       PBoolean isSource                        
01122     );
01123 
01130     OpalMediaStreamPtr GetMediaStream(
01131       const PString & streamID,  
01132       bool source                
01133     ) const;
01134 
01140     OpalMediaStreamPtr GetMediaStream(
01141       unsigned sessionId,  
01142       bool source          
01143     ) const;
01144 
01155     OpalMediaStreamPtr GetMediaStream(
01156       const OpalMediaType & mediaType,    
01157       bool source,                        
01158       OpalMediaStreamPtr previous = NULL  
01159     ) const;
01160 
01172     virtual PBoolean OnOpenMediaStream(
01173       OpalMediaStream & stream    
01174     );
01175 
01180     virtual void OnClosedMediaStream(
01181       const OpalMediaStream & stream     
01182     );
01183 
01192     virtual void OnPatchMediaStream(
01193       PBoolean isSource,        
01194       OpalMediaPatch & patch    
01195     );
01196 
01201     virtual void OnStartMediaPatch(
01202       OpalMediaPatch & patch    
01203     );
01204 
01209     virtual void OnStopMediaPatch(
01210       OpalMediaPatch & patch    
01211     );
01212 
01228     virtual bool OnMediaFailed(
01229       unsigned sessionId,  
01230       bool source          
01231     );
01232 
01235     bool AllMediaFailed() const;
01236 
01242     virtual bool OnMediaCommand(
01243       OpalMediaStream & stream,         
01244       const OpalMediaCommand & command  
01245     );
01246 
01252     virtual bool ExecuteMediaCommand(
01253       const OpalMediaCommand & command, 
01254       unsigned sessionID = 0,           
01255       const OpalMediaType & mediaType = OpalMediaType() 
01256     ) const;
01257 
01258 #if P_NAT
01259     // Get Nat Method in use
01260     virtual PNatMethod * GetNatMethod(
01261       const PIPSocket::Address & remoteAddress = PIPSocket::GetDefaultIpAny()
01262     ) const;
01263 #endif
01264 
01274     virtual bool GetMediaTransportAddresses(
01275       const OpalMediaType & mediaType,       
01276       OpalTransportAddressArray & transports 
01277     ) const;
01278 
01279 #if OPAL_VIDEO
01280 
01282     virtual PBoolean CreateVideoInputDevice(
01283       const OpalMediaFormat & mediaFormat,  
01284       PVideoInputDevice * & device,         
01285       PBoolean & autoDelete                     
01286     );
01287 
01291     virtual PBoolean CreateVideoOutputDevice(
01292       const OpalMediaFormat & mediaFormat,  
01293       PBoolean preview,                         
01294       PVideoOutputDevice * & device,        
01295       PBoolean & autoDelete                     
01296     );
01297 
01300     virtual bool ChangeVideoInputDevice(
01301       const PVideoDevice::OpenArgs & device,  
01302       unsigned sessionID = 0                  
01303     );
01304 
01308     virtual bool ChangeVideoOutputDevice(
01309       const PVideoDevice::OpenArgs & device,  
01310       unsigned sessionID = 0,                 
01311       bool preview = false                    
01312     );
01313 
01319     virtual bool SendVideoUpdatePicture(
01320       unsigned sessionID = 0, 
01321       bool force = false      
01322     ) const;
01323     void SendVideoUpdatePictureCallback(unsigned sessionID, bool force) { SendVideoUpdatePicture(sessionID, force); }
01324 
01329     virtual void OnRxIntraFrameRequest(
01330       const OpalMediaSession & session,   
01331       bool force                          
01332     );
01333 #endif
01334 
01338     virtual PBoolean SetAudioVolume(
01339       PBoolean source,        
01340       unsigned percentage     
01341     );
01342 
01346     virtual PBoolean GetAudioVolume(
01347       PBoolean source,       
01348       unsigned & percentage  
01349     );
01350 
01353     virtual bool SetAudioMute(
01354       bool source,        
01355       bool mute           
01356     );
01357 
01360     virtual bool GetAudioMute(
01361       bool source,        
01362       bool & mute         
01363     );
01364 
01368     virtual unsigned GetAudioSignalLevel(
01369       PBoolean source                   
01370     );
01372 
01377     OpalBandwidth GetBandwidthAvailable(
01378       OpalBandwidth::Direction dir   
01379     ) const;
01380 
01384     virtual bool SetBandwidthAvailable(
01385       OpalBandwidth::Direction dir,  
01386       OpalBandwidth newBandwidth     
01387     );
01388 
01393     virtual OpalBandwidth GetBandwidthUsed(
01394       OpalBandwidth::Direction dir   
01395     ) const;
01396 
01405     virtual bool SetBandwidthUsed(
01406       OpalBandwidth::Direction dir,     
01407       OpalBandwidth releasedBandwidth,  
01408       OpalBandwidth requiredBandwidth   
01409     );
01411 
01414     P_DECLARE_TRACED_ENUM(SendUserInputModes,
01415       SendUserInputAsQ931,
01416       SendUserInputAsString,
01417       SendUserInputAsTone,
01418       SendUserInputAsRFC2833,
01419       SendUserInputAsInlineRFC2833 = SendUserInputAsRFC2833, // For backward compatibility
01420       SendUserInputInBand,
01421       SendUserInputAsProtocolDefault
01422     );
01423 
01426     virtual void SetSendUserInputMode(SendUserInputModes mode);
01427 
01430     virtual SendUserInputModes GetSendUserInputMode() const { return sendUserInputMode; }
01431 
01437     virtual SendUserInputModes GetRealSendUserInputMode() const { return GetSendUserInputMode(); }
01438 
01445     virtual PBoolean SendUserInputString(
01446       const PString & value                   
01447     );
01448 
01465     virtual PBoolean SendUserInputTone(
01466       char tone,        
01467       unsigned duration = 0  
01468     );
01469 
01476     virtual void OnUserInputString(
01477       const PString & value   
01478     );
01479     void OnUserInputStringCallback(PString value) { OnUserInputString(value); }
01480 
01487     virtual void OnUserInputTone(
01488       char tone,
01489       unsigned duration
01490     );
01491 
01495     void SendUserInputHookFlash(
01496       unsigned duration = 500  
01497     ) { SendUserInputTone('!', duration); }
01498 
01501     virtual PString GetUserInput(
01502       unsigned timeout = 30   
01503     );
01504 
01509     virtual void SetUserInput(
01510       const PString & input     
01511     );
01512 
01515     virtual PString ReadUserInput(
01516       const char * terminators = "YX#\r\n", 
01517       unsigned lastDigitTimeout = 4,      
01518       unsigned firstDigitTimeout = 30     
01519     );
01520 
01527     virtual PBoolean PromptUserInput(
01528       PBoolean play   
01529     );
01531 
01545     virtual bool GetConferenceState(
01546       OpalConferenceState * state  
01547     ) const;
01548 
01561     virtual bool RequestPresentationRole(
01562       bool release   
01563     );
01564 
01572     virtual bool OnChangedPresentationRole(
01573       const PString & newChairURI,   
01574       bool request                   
01575     );
01576 
01581     virtual bool HasPresentationRole() const;
01582 
01587     virtual bool GarbageCollection();
01589 
01594     OpalEndPoint & GetEndPoint() const { return endpoint; }
01595     
01598     OpalCall & GetCall() const { return ownerCall; }
01599 
01602     const PString & GetToken() const { return callToken; }
01603 
01606     PBoolean IsOriginating() const { return m_originating; }
01607 
01610     const PTime & GetPhaseTime(Phases phase) const { return m_phaseTime[phase]; }
01611 
01614     const PTime & GetSetupUpTime() const { return m_phaseTime[SetUpPhase]; }
01615 
01618     const PTime & GetAlertingTime() const { return m_phaseTime[AlertingPhase]; }
01619 
01624     const PTime & GetConnectionStartTime() const { return m_phaseTime[ConnectedPhase]; }
01625 
01628     const PTime & GetConnectionEndTime() const { return m_phaseTime[ReleasingPhase]; }
01629 
01632     const OpalProductInfo & GetProductInfo() const { return productInfo; }
01633 
01636     void SetProductInfo(
01637       const OpalProductInfo & info
01638     ) { productInfo = info; }
01639 
01642     virtual PString GetPrefixName() const;
01643 
01646     const PString & GetLocalPartyName() const { return localPartyName; }
01647 
01650     virtual void SetLocalPartyName(const PString & name);
01651 
01654     virtual PString GetLocalPartyURL() const;
01655 
01658     const PString & GetDisplayName() const { return displayName; }
01659 
01662     void SetDisplayName(const PString & name) { displayName = name; }
01663 
01669     virtual bool IsPresentationBlocked() const;
01670 
01673     const PString & GetRemotePartyName() const { return remotePartyName; }
01674 
01677     void SetRemotePartyName(const PString & name) { remotePartyName = name; }
01678 
01687     const PString & GetRemotePartyNumber() const { return remotePartyNumber; }
01688 
01689     // Deprecated - backward compatibility only
01690     P_DEPRECATED PString GetRemotePartyAddress() const { return GetRemotePartyURL(); }
01691 
01698     virtual PString GetRemotePartyURL() const;
01699 
01703     const PString & GetRedirectingParty() const { return m_redirectingParty; }
01704 
01708     void SetRedirectingParty(const PString & party) { m_redirectingParty = party; }
01709 
01710     // Deprecated - backward compatibility only
01711     P_DEPRECATED const PString GetRemotePartyCallbackURL() const { return GetRemotePartyURL(); }
01712 
01716     PCaselessString GetRemoteApplication() const { return remoteProductInfo.AsString(); }
01717 
01720     const OpalProductInfo & GetRemoteProductInfo() const { return remoteProductInfo; }
01721 
01724     virtual OpalTransportAddress GetRemoteAddress() const { return OpalTransportAddress(); }
01725 
01732     const PString & GetCalledPartyName() const { return m_calledPartyName; }
01733 
01740     const PString & GetCalledPartyNumber() const { return m_calledPartyNumber; }
01741 
01749     virtual PString GetCalledPartyURL();
01750 
01751     /* Internal function to copy party names from "network" connection to
01752        "non-network" connection such as OpalPCSSConnection. This allows
01753        the non-network GetRemoteAddress() function and its ilk to return
01754        the intuitive value, i.e. the value from the OTHER connection.
01755      */
01756     void CopyPartyNames(const OpalConnection & other);
01757 
01758 
01772     virtual PString GetAlertingType() const;
01773 
01787     virtual bool SetAlertingType(const PString & info);
01788 
01796     virtual PString GetCallInfo() const;
01797 
01801     unsigned GetMinAudioJitterDelay() const { return m_minAudioJitterDelay; }
01802 
01806     unsigned GetMaxAudioJitterDelay() const { return m_maxAudioJitterDelay; }
01807 
01810     void SetAudioJitterDelay(
01811       unsigned minDelay,   
01812       unsigned maxDelay    
01813     );
01814 
01817     OpalSilenceDetector * GetSilenceDetector() const { return silenceDetector; }
01818     
01819 #if OPAL_AEC
01820 
01822     OpalEchoCanceler * GetEchoCanceler() const { return echoCanceler; }
01823 #endif
01824 
01828     virtual PString GetIdentifier() const;
01829 
01838     virtual PINDEX GetMaxRtpPayloadSize() const;
01839 
01840 #if OPAL_STATISTICS
01841 
01843     unsigned GetVideoUpdateRequestsSent() const { return m_VideoUpdateRequestsSent; }
01844 #endif
01845 
01846 
01848     const StringOptions & GetStringOptions() const { return m_stringOptions; }
01849           StringOptions & GetStringOptions()       { return m_stringOptions; }
01850 
01852     void SetStringOptions(
01853       const StringOptions & options,
01854       bool overwrite
01855     );
01856 
01858     virtual void OnApplyStringOptions();
01859 
01860 #if OPAL_HAS_MIXER
01861 
01862     virtual void EnableRecording();
01863     virtual void DisableRecording();
01864 
01865 #endif
01866 
01867   protected:
01868     void OnConnectedInternal();
01869     void InternalSetAsOriginating();
01870 
01871     void InternalOnReleased();
01872 
01873 #if OPAL_HAS_MIXER
01874     PDECLARE_NOTIFIER(RTP_DataFrame, OpalConnection, OnRecordAudio);
01875 #if OPAL_VIDEO
01876     PDECLARE_NOTIFIER(RTP_DataFrame, OpalConnection, OnRecordVideo);
01877 #endif
01878     void OnStartRecording(OpalMediaPatch * patch);
01879     void OnStopRecording(OpalMediaPatch * patch);
01880 #endif
01881 
01882   // Member variables
01883     OpalCall             & ownerCall;
01884     OpalEndPoint         & endpoint;
01885 
01886   private:
01887     PMutex               m_phaseMutex;
01888     Phases               m_phase;
01889 
01890   protected:
01891     PString              callToken;
01892     PBoolean             m_originating;
01893     OpalProductInfo      productInfo;
01894     PString              localPartyName;
01895     PString              displayName;
01896     PString              remotePartyName;
01897     PString              m_remotePartyURL;
01898     OpalProductInfo      remoteProductInfo;
01899     PString              remotePartyNumber;
01900     PString              m_redirectingParty;
01901     CallEndReason        callEndReason;
01902     PString              m_calledPartyNumber;
01903     PString              m_calledPartyName;
01904 
01905     SendUserInputModes    sendUserInputMode;
01906     PString               userInputString;
01907     PSyncPoint            userInputAvailable;
01908 
01909     OpalSilenceDetector * silenceDetector;
01910 #if OPAL_AEC
01911     OpalEchoCanceler    * echoCanceler;
01912 #endif
01913     OpalMediaFormat       m_filterMediaFormat;
01914 
01915     OpalMediaFormatList        m_localMediaFormats;
01916     PSafeList<OpalMediaStream> mediaStreams;
01917 
01918     unsigned            m_minAudioJitterDelay;
01919     unsigned            m_maxAudioJitterDelay;
01920     OpalBandwidth       m_rxBandwidthAvailable;
01921     OpalBandwidth       m_txBandwidthAvailable;
01922 
01923     // The In-Band DTMF detector. This is used inside an audio filter which is
01924     // added to the audio channel.
01925 #if OPAL_PTLIB_DTMF
01926     PDTMFDecoder m_dtmfDecoder;
01927     bool         m_detectInBandDTMF;
01928     unsigned     m_dtmfScaleMultiplier;
01929     unsigned     m_dtmfScaleDivisor;
01930     PNotifier    m_dtmfDetectNotifier;
01931     PDECLARE_NOTIFIER(RTP_DataFrame, OpalConnection, OnDetectInBandDTMF);
01932 
01933     bool            m_sendInBandDTMF;
01934     OpalMediaFormat m_dtmfSendFormat;
01935     PBYTEArray      m_inBandDTMF;
01936     PINDEX          m_emittedInBandDTMF;
01937     PMutex          m_inBandMutex;
01938     PNotifier       m_dtmfSendNotifier;
01939     PDECLARE_NOTIFIER(RTP_DataFrame, OpalConnection, OnSendInBandDTMF);
01940 #endif
01941 
01942     StringOptions m_stringOptions;
01943 
01944 #if OPAL_HAS_MIXER
01945     PString       m_recordingFilename;
01946     PNotifier     m_recordAudioNotifier;
01947 #if OPAL_VIDEO
01948     PNotifier     m_recordVideoNotifier;
01949 #endif
01950 #endif
01951 
01952 #if OPAL_STATISTICS
01953     unsigned m_VideoUpdateRequestsSent;
01954 #endif
01955 
01956     struct AutoStartInfo {
01957       unsigned preferredSessionId;  // preferred session ID (only used for originating)
01958       OpalMediaType::AutoStartMode autoStart;// Mode for this session when the call is started
01959     };
01960 
01961     class AutoStartMap : public std::map<OpalMediaType, AutoStartInfo>
01962     {
01963       public:
01964         AutoStartMap();
01965         void Initialise(const OpalConnection::StringOptions & stringOptions);
01966         OpalMediaType::AutoStartMode GetAutoStart(const OpalMediaType & mediaType) const;
01967         void SetAutoStart(const OpalMediaType & mediaType, OpalMediaType::AutoStartMode autoStart);
01968 
01969       protected:
01970         bool m_initialised;
01971         PMutex m_mutex;
01972 
01973     };
01974     AutoStartMap m_autoStartInfo;
01975 
01976 #if OPAL_SCRIPT
01977     PString m_scriptTableName;
01978     PDECLARE_ScriptFunctionNotifier(OpalConnection, ScriptRelease);
01979     PDECLARE_ScriptFunctionNotifier(OpalConnection, ScriptSetOption);
01980     PDECLARE_ScriptFunctionNotifier(OpalConnection, ScriptGetLocalPartyURL);
01981     PDECLARE_ScriptFunctionNotifier(OpalConnection, ScriptGetRemotePartyURL);
01982     PDECLARE_ScriptFunctionNotifier(OpalConnection, ScriptGetCalledPartyURL);
01983     PDECLARE_ScriptFunctionNotifier(OpalConnection, ScriptGetRedirectingParty);
01984 #endif // OPAL_SCRIPT
01985 
01986     // A version of PTime where default constructor creates invalid times
01987     class ZeroTime : public PTime
01988     {
01989       public:
01990         ZeroTime() : PTime(0) { }
01991     };
01992     ZeroTime m_phaseTime[NumPhases];
01993 
01994     std::vector<bool> m_mediaSessionFailed;
01995 
01996 
01997   private:
01998     P_REMOVE_VIRTUAL(PBoolean, OnIncomingConnection(unsigned int), false);
01999     P_REMOVE_VIRTUAL(PBoolean, OnIncomingConnection(), false);
02000     P_REMOVE_VIRTUAL(PBoolean, IsConnectionOnHold(), false);
02001     P_REMOVE_VIRTUAL_VOID(OnMediaPatchStart(unsigned, bool));
02002     P_REMOVE_VIRTUAL_VOID(OnMediaPatchStop(unsigned, bool));
02003     P_REMOVE_VIRTUAL_VOID(AdjustMediaFormats(OpalMediaFormatList &) const);
02004     P_REMOVE_VIRTUAL_VOID(AdjustMediaFormats(OpalMediaFormatList &, OpalConnection *) const);
02005     P_REMOVE_VIRTUAL_VOID(AdjustMediaFormats(bool,OpalMediaFormatList &,OpalConnection *) const);
02006     P_REMOVE_VIRTUAL_VOID(PreviewPeerMediaFormats(const OpalMediaFormatList &));
02007     P_REMOVE_VIRTUAL(bool, HoldConnection(), false);
02008     P_REMOVE_VIRTUAL(bool, RetrieveConnection(), false);
02009     P_REMOVE_VIRTUAL(bool, IsConnectionOnHold(bool), false);
02010     P_REMOVE_VIRTUAL_VOID(ApplyStringOptions(OpalConnection::StringOptions &));
02011     P_REMOVE_VIRTUAL(PBoolean, IsMediaBypassPossible(unsigned) const, false);
02012     P_REMOVE_VIRTUAL(bool, OnTransferNotify(const PStringToString &), false);
02013     P_REMOVE_VIRTUAL(OpalMediaSession *, CreateMediaSession(unsigned, const OpalMediaType &), NULL);
02014     P_REMOVE_VIRTUAL(PBoolean, SetBandwidthAvailable(unsigned, PBoolean), false);
02015     P_REMOVE_VIRTUAL(unsigned, GetBandwidthUsed() const, 0);
02016     P_REMOVE_VIRTUAL(PBoolean, SetBandwidthUsed(unsigned, unsigned), false);
02017     P_REMOVE_VIRTUAL_VOID(OnSwitchedFaxMediaStreams(bool));
02018     P_REMOVE_VIRTUAL(bool, CloseMediaStream(OpalMediaStream &),false);
02019 };
02020 
02021 #endif // OPAL_OPAL_CONNECTION_H
02022 
02023 
02024 // End of File ///////////////////////////////////////////////////////////////

Generated on 21 Jun 2013 for OPAL by  doxygen 1.4.7