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: 24857 $
00031  * $Author: rjongbloed $
00032  * $Date: 2010-11-01 22:58:45 -0500 (Mon, 01 Nov 2010) $
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_OPT_AUTO_START           "AutoStart"             
00072 #define OPAL_OPT_CALL_IDENTIFIER      "Call-Identifier"       
00073 #define OPAL_OPT_CALLING_PARTY_URL    "Calling-Party-URL"     
00074 #define OPAL_OPT_CALLING_PARTY_NUMBER "Calling-Party-Number"  
00075 #define OPAL_OPT_CALLING_PARTY_NAME   "Calling-Party-Name"    
00076 #define OPAL_OPT_CALLING_PARTY_DOMAIN "Calling-Party-Domain"  
00077 #define OPAL_OPT_CALLING_DISPLAY_NAME "Calling-Display-Name"  
00078 #define OPAL_OPT_REDIRECTING_PARTY    "Redirecting-Party"     
00079 #define OPAL_OPT_PRESENTATION_BLOCK   "Presentation-Block"    
00080 #define OPAL_OPT_ORIGINATOR_ADDRESS   "Originator-Address"    
00081 #define OPAL_OPT_INTERFACE            "Interface"             
00082 #define OPAL_OPT_USER_INPUT_MODE      "User-Input-Mode"       
00083 
00084 #define OPAL_OPT_ENABLE_INBAND_DTMF   "EnableInbandDTMF"      
00085 #define OPAL_OPT_ENABLE_INBAND_DTMF   "EnableInbandDTMF"      
00086 #define OPAL_OPT_DETECT_INBAND_DTMF   "DetectInBandDTMF"      
00087 #define OPAL_OPT_SEND_INBAND_DTMF     "SendInBandDTMF"        
00088 #define OPAL_OPT_DTMF_MULT            "dtmfmult"
00089 #define OPAL_OPT_DTMF_DIV             "dtmfdiv"
00090 #define OPAL_OPT_DISABLE_JITTER       "Disable-Jitter"        
00091 #define OPAL_OPT_MAX_JITTER           "Max-Jitter"            
00092 #define OPAL_OPT_MIN_JITTER           "Min-Jitter"            
00093 #define OPAL_OPT_RECORD_AUDIO         "Record-Audio"          
00094 #define OPAL_OPT_ALERTING_TYPE        "Alerting-Type"         
00095 #define OPAL_OPT_REMOVE_CODEC         "Remove-Codec"          
00096 
00097 
00308 class OpalProductInfo
00309 {
00310   public:
00311     OpalProductInfo();
00312 
00313     static OpalProductInfo & Default();
00314 
00315     PCaselessString AsString() const;
00316 
00317     PString vendor;
00318     PString name;
00319     PString version;
00320     PString comments;
00321     BYTE    t35CountryCode;
00322     BYTE    t35Extension;
00323     WORD    manufacturerCode;
00324 };
00325 
00326 
00344 class OpalConnection : public PSafeObject
00345 {
00346     PCLASSINFO(OpalConnection, PSafeObject);
00347   public:
00352     enum CallEndReasonCodes {
00353       EndedByLocalUser,            
00354       EndedByNoAccept,             
00355       EndedByAnswerDenied,         
00356       EndedByRemoteUser,           
00357       EndedByRefusal,              
00358       EndedByNoAnswer,             
00359       EndedByCallerAbort,          
00360       EndedByTransportFail,        
00361       EndedByConnectFail,          
00362       EndedByGatekeeper,           
00363       EndedByNoUser,               
00364       EndedByNoBandwidth,          
00365       EndedByCapabilityExchange,   
00366       EndedByCallForwarded,        
00367       EndedBySecurityDenial,       
00368       EndedByLocalBusy,            
00369       EndedByLocalCongestion,      
00370       EndedByRemoteBusy,           
00371       EndedByRemoteCongestion,     
00372       EndedByUnreachable,          
00373       EndedByNoEndPoint,           
00374       EndedByHostOffline,          
00375       EndedByTemporaryFailure,     
00376       EndedByQ931Cause,            
00377       EndedByDurationLimit,        
00378       EndedByInvalidConferenceID,  
00379       EndedByNoDialTone,           
00380       EndedByNoRingBackTone,       
00381       EndedByOutOfService,         
00382       EndedByAcceptingCallWaiting, 
00383       EndedByGkAdmissionFailed,    
00384       NumCallEndReasons
00385     };
00386 
00387     struct CallEndReason {
00388       CallEndReason(
00389         CallEndReasonCodes reason = NumCallEndReasons,
00390         unsigned cause = 0
00391       ) : code(reason), q931(cause) { }
00392       explicit CallEndReason(
00393         long reason
00394       ) : code((CallEndReasonCodes)(reason&0xff)), q931((reason>>8)&0xff) { }
00395 
00396       __inline operator CallEndReasonCodes() const { return code; }
00397 
00398       __inline int AsInteger() const { return code|(q931<<8); }
00399 
00400       CallEndReasonCodes code:8; // Normalised OPAL code
00401       unsigned           q931:8; // PSTN Interworking code, actually Q.850
00402     };
00403 
00404 #if PTRACING
00405     friend ostream & operator<<(ostream & o, CallEndReason reason);
00406 #endif
00407 
00408     enum AnswerCallResponse {
00409       AnswerCallNow,               
00410       AnswerCallDenied,            
00411       AnswerCallPending,           
00412       AnswerCallDeferred,          
00413       AnswerCallAlertWithMedia,    
00414       AnswerCallDeferredWithMedia, 
00415       AnswerCallProgress,          
00416       AnswerCallNowAndReleaseCurrent, 
00417       NumAnswerCallResponses
00418     };
00419 #if PTRACING
00420     friend ostream & operator<<(ostream & o, AnswerCallResponse s);
00421 #endif
00422 
00425     enum Options {
00426       FastStartOptionDisable       = 0x0001,   // H.323 specific
00427       FastStartOptionEnable        = 0x0002,
00428       FastStartOptionMask          = 0x0003,
00429 
00430       H245TunnelingOptionDisable   = 0x0004,   // H.323 specific
00431       H245TunnelingOptionEnable    = 0x0008,
00432       H245TunnelingOptionMask      = 0x000c,
00433 
00434       H245inSetupOptionDisable     = 0x0010,   // H.323 specific
00435       H245inSetupOptionEnable      = 0x0020,
00436       H245inSetupOptionMask        = 0x0030,
00437 
00438       DetectInBandDTMFOptionDisable = 0x0040,  // SIP and H.323
00439       DetectInBandDTMFOptionEnable  = 0x0080,
00440       DetectInBandDTMFOptionMask    = 0x00c0,
00441 
00442       RTPAggregationDisable        = 0x0100,   // SIP and H.323
00443       RTPAggregationEnable         = 0x0200,
00444       RTPAggregationMask           = 0x0300,
00445 
00446       SendDTMFAsDefault            = 0x0000,   // SIP and H.323
00447       SendDTMFAsString             = 0x0400,
00448       SendDTMFAsTone               = 0x0800,
00449       SendDTMFAsRFC2833            = 0x0c00,
00450       SendDTMFMask                 = 0x0c00
00451     };
00452 
00453     class StringOptions : public PStringToString 
00454     {
00455       public:
00456         // Make sure the key set in a StringOptions is caseless
00457         PBoolean SetAt(const char * key, const PString & data)
00458         {
00459           return PStringToString::SetAt(PCaselessString(key), data);
00460         }
00461         PBoolean SetAt(const PString & key, const PString & data)
00462         {
00463           return PStringToString::SetAt(PCaselessString(key), data);
00464         }
00465         PBoolean SetAt(const PCaselessString & key, const PString & data)
00466         {
00467           return PStringToString::SetAt(key, data);
00468         }
00469 
00470         bool GetBoolean(
00471           const char * key,
00472           bool dflt = false
00473         ) const;
00474         bool GetBoolean(
00475           const PString & key,
00476           bool dflt = false
00477         ) const { return GetBoolean((const char *)key, dflt); }
00478 
00479         long GetInteger(
00480           const char * key,
00481           long dflt = 0
00482         ) const;
00483         long GetInteger(
00484           const PString & key,
00485           long dflt = 0
00486         ) const { return GetInteger((const char *)key, dflt); }
00487 
00492         void ExtractFromURL(
00493           PURL & url
00494         );
00495     };
00496 
00501     OpalConnection(
00502       OpalCall & call,                         
00503       OpalEndPoint & endpoint,                 
00504       const PString & token,                   
00505       unsigned options = 0,                    
00506       OpalConnection::StringOptions * stringOptions = NULL 
00507     );  
00508 
00511     ~OpalConnection();
00513 
00520     void PrintOn(
00521       ostream & strm    
00522     ) const;
00524 
00541     virtual bool IsNetworkConnection() const = 0;
00542 
00546     enum Phases {
00547       UninitialisedPhase,   
00548       SetUpPhase,           
00549       ProceedingPhase,      
00550       AlertingPhase,        
00551       ConnectedPhase,       
00552       EstablishedPhase,     
00553       ForwardingPhase,      
00554       ReleasingPhase,       
00555       ReleasedPhase,        
00556       NumPhases             
00557     };
00558 
00563     __inline Phases GetPhase() const { return phase; }
00564 
00566     __inline bool IsEstablished() const { return phase == EstablishedPhase; }
00567 
00569     __inline bool IsReleased() const { return phase >= ReleasingPhase; }
00570 
00575     void SetPhase(
00576       Phases phaseToSet  
00577     );
00578 
00587     CallEndReason GetCallEndReason() const { return callEndReason; }
00588 
00591     static PString GetCallEndReasonText(CallEndReason reason);
00592     PString GetCallEndReasonText() const { return GetCallEndReasonText(callEndReason); }
00593 
00596     static void SetCallEndReasonText(CallEndReasonCodes reasonCode, const PString & newText);
00597 
00602     virtual void SetCallEndReason(
00603       CallEndReason reason        
00604     );
00605 
00613     void ClearCall(
00614       CallEndReason reason = EndedByLocalUser 
00615     );
00616 
00619     virtual void ClearCallSynchronous(
00620       PSyncPoint * sync,                       
00621       CallEndReason reason = EndedByLocalUser  
00622     );
00623 
00627     unsigned GetQ931Cause() const { return callEndReason.q931; }
00628 
00632     void SetQ931Cause(unsigned v) { callEndReason.q931 = v; }
00633 
00640     virtual bool TransferConnection(
00641       const PString & remoteParty   
00642     );
00643     
00651     virtual bool Hold(
00652       bool fromRemote,  
00653       bool placeOnHold  
00654     );
00655 
00660     virtual bool IsOnHold(
00661       bool fromRemote  
00662     );
00663 
00668     virtual void OnHold(
00669       bool fromRemote,               
00670       bool onHold                    
00671     );
00673 
00701     virtual PBoolean OnIncomingConnection(unsigned int options, OpalConnection::StringOptions * stringOptions);
00702 
00709     virtual PBoolean SetUpConnection() = 0;
00710 
00714     virtual PBoolean OnSetUpConnection();
00715 
00716     
00731     virtual void OnProceeding();
00732 
00743     virtual void OnAlerting();
00744 
00755     virtual PBoolean SetAlerting(
00756       const PString & calleeName,   
00757       PBoolean withMedia                
00758     ) = 0;
00759 
00776     virtual AnswerCallResponse OnAnswerCall(
00777       const PString & callerName        
00778     );
00779 
00790     virtual void AnsweringCall(
00791       AnswerCallResponse response 
00792     );
00793 
00808     virtual void OnConnected();
00809 
00820     virtual PBoolean SetConnected();
00821 
00833     virtual void OnEstablished();
00834 
00864     virtual bool OnTransferNotify(
00865       const PStringToString & info 
00866     );
00867 
00876     virtual void Release(
00877       CallEndReason reason = EndedByLocalUser 
00878     );
00879 
00897     virtual void OnReleased();
00899 
00910     virtual PString GetDestinationAddress();
00911 
00921     virtual PBoolean ForwardCall(
00922       const PString & forwardParty   
00923     );
00924 
00927     PSafePtr<OpalConnection> GetOtherPartyConnection() const;
00928 
00931     template <class cls> PSafePtr<cls> GetOtherPartyConnectionAs() const { return PSafePtrCast<OpalConnection, cls>(GetOtherPartyConnection()); }
00933 
00942     virtual OpalMediaFormatList GetMediaFormats() const;
00943 
00948     virtual OpalMediaFormatList GetLocalMediaFormats();
00949 
00962     virtual void AdjustMediaFormats(
00963       bool local,                          
00964       OpalMediaFormatList & mediaFormats,  
00965       OpalConnection * otherConnection     
00966     ) const;
00967 
00975     virtual unsigned GetNextSessionID(
00976       const OpalMediaType & mediaType,   
00977       bool isSource                      
00978     );
00979 
00986     virtual OpalMediaType::AutoStartMode GetAutoStart(
00987       const OpalMediaType & mediaType  
00988     ) const;
00989 
00992     virtual void AutoStartMediaStreams(
00993       bool force = false 
00994     );
00995 
00996 #if OPAL_FAX
00997 
00999     virtual bool SwitchFaxMediaStreams(
01000       bool enableFax  
01001     );
01002 
01007     virtual void OnSwitchedFaxMediaStreams(
01008       bool enabledFax  
01009     );
01010 #endif
01011 
01014     virtual OpalMediaStreamPtr OpenMediaStream(
01015       const OpalMediaFormat & mediaFormat, 
01016       unsigned sessionID,                  
01017       bool isSource                        
01018     );
01019 
01022     virtual bool CloseMediaStream(
01023       unsigned sessionId,  
01024       bool source          
01025     );
01026 
01029     virtual bool CloseMediaStream(
01030       OpalMediaStream & stream  
01031     );
01032 
01040     bool RemoveMediaStream(
01041       OpalMediaStream & strm  
01042     );
01043 
01046     virtual void StartMediaStreams();
01047     
01050     virtual void CloseMediaStreams();
01051     
01054     virtual void PauseMediaStreams(
01055       bool paused  
01056     );
01057 
01060     virtual void OnPauseMediaStream(
01061       OpalMediaStream & strm,     
01062       bool paused                 
01063     );
01064 
01077     virtual OpalMediaStream * CreateMediaStream(
01078       const OpalMediaFormat & mediaFormat, 
01079       unsigned sessionID,                  
01080       PBoolean isSource                        
01081     );
01082 
01089     OpalMediaStreamPtr GetMediaStream(
01090       const PString & streamID,  
01091       bool source                
01092     ) const;
01093 
01099     OpalMediaStreamPtr GetMediaStream(
01100       unsigned sessionId,  
01101       bool source          
01102     ) const;
01103 
01114     OpalMediaStreamPtr GetMediaStream(
01115       const OpalMediaType & mediaType,    
01116       bool source,                        
01117       OpalMediaStreamPtr previous = NULL  
01118     ) const;
01119 
01131     virtual PBoolean OnOpenMediaStream(
01132       OpalMediaStream & stream    
01133     );
01134 
01139     virtual void OnClosedMediaStream(
01140       const OpalMediaStream & stream     
01141     );
01142 
01151     virtual void OnPatchMediaStream(
01152       PBoolean isSource,        
01153       OpalMediaPatch & patch    
01154     );
01155 
01158     virtual void OnStartMediaPatch(
01159       OpalMediaPatch & patch    
01160     );
01161 
01164     virtual void OnStopMediaPatch(
01165       OpalMediaPatch & patch    
01166     );
01167 
01171     PDECLARE_NOTIFIER(OpalMediaCommand, OpalConnection, OnMediaCommand);
01172 
01177     virtual void AttachRFC2833HandlerToPatch(PBoolean isSource, OpalMediaPatch & patch);
01178 
01184     virtual PBoolean IsMediaBypassPossible(
01185       unsigned sessionID                  
01186     ) const;
01187 
01188 #if OPAL_VIDEO
01189 
01191     virtual PBoolean CreateVideoInputDevice(
01192       const OpalMediaFormat & mediaFormat,  
01193       PVideoInputDevice * & device,         
01194       PBoolean & autoDelete                     
01195     );
01196 
01200     virtual PBoolean CreateVideoOutputDevice(
01201       const OpalMediaFormat & mediaFormat,  
01202       PBoolean preview,                         
01203       PVideoOutputDevice * & device,        
01204       PBoolean & autoDelete                     
01205     );
01206 
01212     virtual bool SendVideoUpdatePicture(
01213       unsigned sessionID = 0, 
01214       bool force = false      
01215     ) const;
01216 #endif
01217 
01220     virtual PBoolean SetAudioVolume(
01221       PBoolean source,                  
01222       unsigned percentage           
01223     );
01224 
01228     virtual unsigned GetAudioSignalLevel(
01229       PBoolean source                   
01230     );
01232 
01237     unsigned GetBandwidthAvailable() const { return bandwidthAvailable; }
01238 
01243     virtual PBoolean SetBandwidthAvailable(
01244       unsigned newBandwidth,    
01245       PBoolean force = false        
01246     );
01247 
01252     virtual unsigned GetBandwidthUsed() const;
01253 
01262     virtual PBoolean SetBandwidthUsed(
01263       unsigned releasedBandwidth,   
01264       unsigned requiredBandwidth    
01265     );
01267 
01270     enum SendUserInputModes {
01271       SendUserInputAsQ931,
01272       SendUserInputAsString,
01273       SendUserInputAsTone,
01274       SendUserInputAsRFC2833,
01275       SendUserInputInBand,
01276       SendUserInputAsProtocolDefault,
01277       NumSendUserInputModes,
01278 
01279       SendUserInputAsInlineRFC2833 = SendUserInputAsRFC2833  // For backward compatibility
01280     };
01281 #if PTRACING
01282     friend ostream & operator<<(ostream & o, SendUserInputModes m);
01283 #endif
01284 
01287     virtual void SetSendUserInputMode(SendUserInputModes mode);
01288 
01291     virtual SendUserInputModes GetSendUserInputMode() const { return sendUserInputMode; }
01292 
01298     virtual SendUserInputModes GetRealSendUserInputMode() const { return GetSendUserInputMode(); }
01299 
01306     virtual PBoolean SendUserInputString(
01307       const PString & value                   
01308     );
01309 
01326     virtual PBoolean SendUserInputTone(
01327       char tone,        
01328       unsigned duration = 0  
01329     );
01330 
01337     virtual void OnUserInputString(
01338       const PString & value   
01339     );
01340 
01347     virtual void OnUserInputTone(
01348       char tone,
01349       unsigned duration
01350     );
01351 
01355     void SendUserInputHookFlash(
01356       unsigned duration = 500  
01357     ) { SendUserInputTone('!', duration); }
01358 
01361     virtual PString GetUserInput(
01362       unsigned timeout = 30   
01363     );
01364 
01369     virtual void SetUserInput(
01370       const PString & input     
01371     );
01372 
01375     virtual PString ReadUserInput(
01376       const char * terminators = "#\r\n", 
01377       unsigned lastDigitTimeout = 4,      
01378       unsigned firstDigitTimeout = 30     
01379     );
01380 
01387     virtual PBoolean PromptUserInput(
01388       PBoolean play   
01389     );
01391 
01396     virtual bool GarbageCollection();
01398 
01403     OpalEndPoint & GetEndPoint() const { return endpoint; }
01404     
01407     OpalCall & GetCall() const { return ownerCall; }
01408 
01411     const PString & GetToken() const { return callToken; }
01412 
01415     PBoolean IsOriginating() const { return originating; }
01416 
01419     PTime GetSetupUpTime() const { return setupTime; }
01420 
01423     PTime GetAlertingTime() const { return alertingTime; }
01424 
01427     PTime GetConnectionStartTime() const { return connectedTime; }
01428 
01431     PTime GetConnectionEndTime() const { return callEndTime; }
01432 
01435     const OpalProductInfo & GetProductInfo() const { return productInfo; }
01436 
01439     void SetProductInfo(
01440       const OpalProductInfo & info
01441     ) { productInfo = info; }
01442 
01445     virtual PString GetPrefixName() const;
01446 
01449     const PString & GetLocalPartyName() const { return localPartyName; }
01450 
01453     virtual void SetLocalPartyName(const PString & name);
01454 
01457     virtual PString GetLocalPartyURL() const;
01458 
01461     const PString & GetDisplayName() const { return displayName; }
01462 
01465     void SetDisplayName(const PString & name) { displayName = name; }
01466 
01472     virtual bool IsPresentationBlocked() const;
01473 
01476     const PString & GetRemotePartyName() const { return remotePartyName; }
01477 
01480     void SetRemotePartyName(const PString & name) { remotePartyName = name; }
01481 
01490     const PString & GetRemotePartyNumber() const { return remotePartyNumber; }
01491 
01497     const PString & GetRemotePartyAddress() const { return remotePartyAddress; }
01498 
01501     void SetRemotePartyAddress(const PString & addr) { remotePartyAddress = addr; }
01502 
01509     virtual PString GetRemotePartyURL() const;
01510 
01514     const PString & GetRedirectingParty() const { return m_redirectingParty; }
01515 
01519     void SetRedirectingParty(const PString & party) { m_redirectingParty = party; }
01520 
01521     // Deprecated - backward compatibility only
01522     const PString GetRemotePartyCallbackURL() const { return GetRemotePartyURL(); }
01523 
01527     PCaselessString GetRemoteApplication() const { return remoteProductInfo.AsString(); }
01528 
01531     const OpalProductInfo & GetRemoteProductInfo() const { return remoteProductInfo; }
01532 
01533 
01540     const PString & GetCalledPartyName() const { return m_calledPartyName; }
01541 
01548     const PString & GetCalledPartyNumber() const { return m_calledPartyNumber; }
01549 
01557     virtual PString GetCalledPartyURL();
01558 
01559     /* Internal function to copy party names from "network" connection to
01560        "non-network" connection such as OpalPCSSConnection. This allows
01561        the non-network GetRemoteAddress() function and its ilk to return
01562        the intuitive value, i.e. the value from the OTHER connection.
01563      */
01564     void CopyPartyNames(const OpalConnection & other);
01565 
01566 
01580     virtual PString GetAlertingType() const;
01581 
01595     virtual bool SetAlertingType(const PString & info);
01596 
01604     virtual PString GetCallInfo() const;
01605 
01609     unsigned GetMinAudioJitterDelay() const { return minAudioJitterDelay; }
01610 
01614     unsigned GetMaxAudioJitterDelay() const { return maxAudioJitterDelay; }
01615 
01618     void SetAudioJitterDelay(
01619       unsigned minDelay,   
01620       unsigned maxDelay    
01621     );
01622 
01625     OpalSilenceDetector * GetSilenceDetector() const { return silenceDetector; }
01626     
01627 #if OPAL_AEC
01628 
01630     OpalEchoCanceler * GetEchoCanceler() const { return echoCanceler; }
01631 #endif
01632 
01636     virtual PString GetIdentifier() const;
01637 
01646     virtual PINDEX GetMaxRtpPayloadSize() const;
01647 
01648     virtual OpalTransport & GetTransport() const
01649     { return *(OpalTransport *)NULL; }
01650 
01651     PDICTIONARY(MediaAddressesDict, POrdinalKey, OpalTransportAddress);
01652     MediaAddressesDict & GetMediaTransportAddresses()
01653     { return mediaTransportAddresses; }
01654 
01655 #if OPAL_STATISTICS
01656 
01658     unsigned GetVideoUpdateRequestsSent() const { return m_VideoUpdateRequestsSent; }
01659 #endif
01660 
01661 
01663     const StringOptions & GetStringOptions() const { return m_stringOptions; }
01664 
01666     void SetStringOptions(
01667       const StringOptions & options,
01668       bool overwrite
01669     );
01670 
01672     virtual void OnApplyStringOptions();
01673 
01674 #if OPAL_HAS_MIXER
01675 
01676     virtual void EnableRecording();
01677     virtual void DisableRecording();
01678 
01679 #endif
01680 
01681 #if OPAL_HAS_IM
01682 
01685     virtual bool TransmitInternalIM(
01686       const OpalMediaFormat & format, 
01687       RTP_IMFrame & body
01688     );
01689 
01693     virtual void OnReceiveInternalIM(
01694       const OpalMediaFormat & format, 
01695       RTP_IMFrame & body
01696     );
01697 
01701     virtual bool TransmitExternalIM(
01702       const OpalMediaFormat & format, 
01703       RTP_IMFrame & body
01704     );
01705 
01709     virtual bool OnReceiveExternalIM(
01710       const OpalMediaFormat & format, 
01711       RTP_IMFrame & body
01712     );
01713 
01718     RFC4103Context & GetRFC4103Context(PINDEX i) { return m_rfc4103Context[i]; };
01719 
01720   protected:
01721     RFC4103Context m_rfc4103Context[2];
01722 
01723 #endif
01724 
01725   protected:
01726     void OnConnectedInternal();
01727 
01728     PDECLARE_NOTIFIER(PThread, OpalConnection, OnReleaseThreadMain);
01729 
01730 #if OPAL_HAS_MIXER
01731     PDECLARE_NOTIFIER(RTP_DataFrame, OpalConnection, OnRecordAudio);
01732 #if OPAL_VIDEO
01733     PDECLARE_NOTIFIER(RTP_DataFrame, OpalConnection, OnRecordVideo);
01734 #endif
01735     void OnStartRecording(OpalMediaPatch * patch);
01736     void OnStopRecording(OpalMediaPatch * patch);
01737 #endif
01738 
01739   // Member variables
01740     OpalCall             & ownerCall;
01741     OpalEndPoint         & endpoint;
01742 
01743   private:
01744     PMutex               phaseMutex;
01745     Phases               phase;
01746 
01747   protected:
01748     PString              callToken;
01749     PBoolean             originating;
01750     PTime                setupTime;
01751     PTime                alertingTime;
01752     PTime                connectedTime;
01753     PTime                callEndTime;
01754     OpalProductInfo      productInfo;
01755     PString              localPartyName;
01756     PString              displayName;
01757     PString              remotePartyName;
01758     PString              remotePartyURL;
01759     OpalProductInfo      remoteProductInfo;
01760     PString              remotePartyNumber;
01761     PString              remotePartyAddress;
01762     PString              m_redirectingParty;
01763     CallEndReason        callEndReason;
01764     bool                 synchronousOnRelease;
01765     PString              m_calledPartyNumber;
01766     PString              m_calledPartyName;
01767 
01768     SendUserInputModes    sendUserInputMode;
01769     PString               userInputString;
01770     PSyncPoint            userInputAvailable;
01771 
01772     OpalSilenceDetector * silenceDetector;
01773 #if OPAL_AEC
01774     OpalEchoCanceler    * echoCanceler;
01775 #endif
01776     OpalMediaFormat       m_filterMediaFormat;
01777 
01778     MediaAddressesDict         mediaTransportAddresses;
01779     PSafeList<OpalMediaStream> mediaStreams;
01780 
01781     unsigned            minAudioJitterDelay;
01782     unsigned            maxAudioJitterDelay;
01783     unsigned            bandwidthAvailable;
01784 
01785     // The In-Band DTMF detector. This is used inside an audio filter which is
01786     // added to the audio channel.
01787 #if OPAL_PTLIB_DTMF
01788     PDTMFDecoder m_dtmfDecoder;
01789     bool         m_detectInBandDTMF;
01790     unsigned     m_dtmfScaleMultiplier;
01791     unsigned     m_dtmfScaleDivisor;
01792     PNotifier    m_dtmfDetectNotifier;
01793     PDECLARE_NOTIFIER(RTP_DataFrame, OpalConnection, OnDetectInBandDTMF);
01794 
01795     bool            m_sendInBandDTMF;
01796     OpalMediaFormat m_dtmfSendFormat;
01797     PBYTEArray      m_inBandDTMF;
01798     PINDEX          m_emittedInBandDTMF;
01799     PMutex          m_inBandMutex;
01800     PNotifier       m_dtmfSendNotifier;
01801     PDECLARE_NOTIFIER(RTP_DataFrame, OpalConnection, OnSendInBandDTMF);
01802 #endif
01803 
01804 #if PTRACING
01805     friend ostream & operator<<(ostream & o, Phases p);
01806 #endif
01807 
01808     StringOptions m_stringOptions;
01809 
01810 #if OPAL_HAS_MIXER
01811     PString       m_recordingFilename;
01812     PNotifier     m_recordAudioNotifier;
01813 #if OPAL_VIDEO
01814     PNotifier     m_recordVideoNotifier;
01815 #endif
01816 #endif
01817 
01818 #if OPAL_STATISTICS
01819     unsigned m_VideoUpdateRequestsSent;
01820 #endif
01821 
01822     struct AutoStartInfo {
01823       unsigned preferredSessionId;  // preferred session ID (only used for originating)
01824       OpalMediaType::AutoStartMode autoStart;// Mode for this session when the call is started
01825     };
01826 
01827     class AutoStartMap : public std::map<OpalMediaType, AutoStartInfo>
01828     {
01829       public:
01830         AutoStartMap();
01831         void Initialise(const OpalConnection::StringOptions & stringOptions);
01832         OpalMediaType::AutoStartMode GetAutoStart(const OpalMediaType & mediaType) const;
01833         void SetAutoStart(const OpalMediaType & mediaType, OpalMediaType::AutoStartMode autoStart);
01834 
01835       protected:
01836         bool m_initialised;
01837         PMutex m_mutex;
01838 
01839     };
01840     AutoStartMap m_autoStartInfo;
01841 
01842 #if OPAL_FAX
01843     enum {
01844       e_NotSwitchingFaxMediaStreams,
01845       e_SwitchingToFaxMediaStreams,
01846       e_SwitchingFromFaxMediaStreams
01847     } m_faxMediaStreamsSwitchState;
01848 #endif
01849 
01850 #if P_LUA
01851   protected:
01852     PLua m_lua;
01853     bool m_luaScriptLoaded;
01854 
01855   public:
01856     PLUA_BINDING_START(OpalConnection)
01857       PLUA_BINDING2(LuaSetOption, "SetOption")
01858     PLUA_BINDING_END()
01859     PLUA_DECLARE_FUNCTION(LuaSetOption);
01860 #endif
01861 
01862   private:
01863     P_REMOVE_VIRTUAL(PBoolean, OnIncomingConnection(unsigned int), false);
01864     P_REMOVE_VIRTUAL(PBoolean, OnIncomingConnection(), false);
01865     P_REMOVE_VIRTUAL(PBoolean, IsConnectionOnHold(), false);
01866     P_REMOVE_VIRTUAL_VOID(OnMediaPatchStart(unsigned, bool));
01867     P_REMOVE_VIRTUAL_VOID(OnMediaPatchStop(unsigned, bool));
01868     P_REMOVE_VIRTUAL_VOID(AdjustMediaFormats(OpalMediaFormatList &) const);
01869     P_REMOVE_VIRTUAL_VOID(AdjustMediaFormats(OpalMediaFormatList &, OpalConnection *) const);
01870     P_REMOVE_VIRTUAL_VOID(PreviewPeerMediaFormats(const OpalMediaFormatList &));
01871     P_REMOVE_VIRTUAL(bool, HoldConnection(), false);
01872     P_REMOVE_VIRTUAL(bool, RetrieveConnection(), false);
01873     P_REMOVE_VIRTUAL(bool, IsConnectionOnHold(bool), false);
01874     P_REMOVE_VIRTUAL_VOID(ApplyStringOptions(OpalConnection::StringOptions &));
01875 };
01876 
01877 #endif // OPAL_OPAL_CONNECTION_H
01878 
01879 
01880 // End of File ///////////////////////////////////////////////////////////////

Generated on Sun Nov 21 20:20:50 2010 for OPAL by  doxygen 1.4.7