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: 24339 $
00031  * $Author: rjongbloed $
00032  * $Date: 2010-05-12 15:46:09 -0500 (Wed, 12 May 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 class OpalEndPoint;
00059 class OpalCall;
00060 class OpalSilenceDetector;
00061 class OpalEchoCanceler;
00062 class OpalRFC2833Proto;
00063 class OpalRFC2833Info;
00064 class PURL;
00065 
00066 
00067 #define OPAL_OPT_AUTO_START           "AutoStart"             
00068 #define OPAL_OPT_CALL_IDENTIFIER      "Call-Identifier"       
00069 #define OPAL_OPT_CALLING_PARTY_URL    "Calling-Party-URL"     
00070 #define OPAL_OPT_CALLING_PARTY_NUMBER "Calling-Party-Number"  
00071 #define OPAL_OPT_CALLING_PARTY_NAME   "Calling-Party-Name"    
00072 #define OPAL_OPT_CALLING_PARTY_DOMAIN "Calling-Party-Domain"  
00073 #define OPAL_OPT_CALLING_DISPLAY_NAME "Calling-Display-Name"  
00074 #define OPAL_OPT_PRESENTATION_BLOCK   "Presentation-Block"    
00075 #define OPAL_OPT_ORIGINATOR_ADDRESS   "Originator-Address"    
00076 #define OPAL_OPT_INTERFACE            "Interface"             
00077 #define OPAL_OPT_ENABLE_INBAND_DTMF   "EnableInbandDTMF"      
00078 #define OPAL_OPT_ENABLE_INBAND_DTMF   "EnableInbandDTMF"      
00079 #define OPAL_OPT_DETECT_INBAND_DTMF   "DetectInBandDTMF"      
00080 #define OPAL_OPT_SEND_INBAND_DTMF     "SendInBandDTMF"        
00081 #define OPAL_OPT_DTMF_MULT            "dtmfmult"
00082 #define OPAL_OPT_DTMF_DIV             "dtmfdiv"
00083 #define OPAL_OPT_DISABLE_JITTER       "Disable-Jitter"        
00084 #define OPAL_OPT_MAX_JITTER           "Max-Jitter"            
00085 #define OPAL_OPT_MIN_JITTER           "Min-Jitter"            
00086 #define OPAL_OPT_RECORD_AUDIO         "Record-Audio"          
00087 #define OPAL_OPT_ALERTING_TYPE        "Alerting-Type"         
00088 #define OPAL_OPT_REMOVE_CODEC         "Remove-Codec"          
00089 
00090 
00301 class OpalProductInfo
00302 {
00303   public:
00304     OpalProductInfo();
00305 
00306     static OpalProductInfo & Default();
00307 
00308     PCaselessString AsString() const;
00309 
00310     PString vendor;
00311     PString name;
00312     PString version;
00313     PString comments;
00314     BYTE    t35CountryCode;
00315     BYTE    t35Extension;
00316     WORD    manufacturerCode;
00317 };
00318 
00319 
00337 class OpalConnection : public PSafeObject
00338 {
00339     PCLASSINFO(OpalConnection, PSafeObject);
00340   public:
00345     enum CallEndReasonCodes {
00346       EndedByLocalUser,            
00347       EndedByNoAccept,             
00348       EndedByAnswerDenied,         
00349       EndedByRemoteUser,           
00350       EndedByRefusal,              
00351       EndedByNoAnswer,             
00352       EndedByCallerAbort,          
00353       EndedByTransportFail,        
00354       EndedByConnectFail,          
00355       EndedByGatekeeper,           
00356       EndedByNoUser,               
00357       EndedByNoBandwidth,          
00358       EndedByCapabilityExchange,   
00359       EndedByCallForwarded,        
00360       EndedBySecurityDenial,       
00361       EndedByLocalBusy,            
00362       EndedByLocalCongestion,      
00363       EndedByRemoteBusy,           
00364       EndedByRemoteCongestion,     
00365       EndedByUnreachable,          
00366       EndedByNoEndPoint,           
00367       EndedByHostOffline,          
00368       EndedByTemporaryFailure,     
00369       EndedByQ931Cause,            
00370       EndedByDurationLimit,        
00371       EndedByInvalidConferenceID,  
00372       EndedByNoDialTone,           
00373       EndedByNoRingBackTone,       
00374       EndedByOutOfService,         
00375       EndedByAcceptingCallWaiting, 
00376       EndedByGkAdmissionFailed,    
00377       NumCallEndReasons
00378     };
00379 
00380     struct CallEndReason {
00381       CallEndReason(
00382         CallEndReasonCodes reason = NumCallEndReasons,
00383         unsigned cause = 0
00384       ) : code(reason), q931(cause) { }
00385       explicit CallEndReason(
00386         long reason
00387       ) : code((CallEndReasonCodes)reason), q931(0) { }
00388 
00389       operator CallEndReasonCodes() const { return code; }
00390 
00391       CallEndReasonCodes code:8; // Normalised OPAL code
00392       unsigned           q931:8; // PSTN Interworking code, actually Q.850
00393     };
00394 
00395 #if PTRACING
00396     friend ostream & operator<<(ostream & o, CallEndReason reason);
00397 #endif
00398 
00399     enum AnswerCallResponse {
00400       AnswerCallNow,               
00401       AnswerCallDenied,            
00402       AnswerCallPending,           
00403       AnswerCallDeferred,          
00404       AnswerCallAlertWithMedia,    
00405       AnswerCallDeferredWithMedia, 
00406       AnswerCallProgress,          
00407       AnswerCallNowAndReleaseCurrent, 
00408       NumAnswerCallResponses
00409     };
00410 #if PTRACING
00411     friend ostream & operator<<(ostream & o, AnswerCallResponse s);
00412 #endif
00413 
00416     enum Options {
00417       FastStartOptionDisable       = 0x0001,   // H.323 specific
00418       FastStartOptionEnable        = 0x0002,
00419       FastStartOptionMask          = 0x0003,
00420 
00421       H245TunnelingOptionDisable   = 0x0004,   // H.323 specific
00422       H245TunnelingOptionEnable    = 0x0008,
00423       H245TunnelingOptionMask      = 0x000c,
00424 
00425       H245inSetupOptionDisable     = 0x0010,   // H.323 specific
00426       H245inSetupOptionEnable      = 0x0020,
00427       H245inSetupOptionMask        = 0x0030,
00428 
00429       DetectInBandDTMFOptionDisable = 0x0040,  // SIP and H.323
00430       DetectInBandDTMFOptionEnable  = 0x0080,
00431       DetectInBandDTMFOptionMask    = 0x00c0,
00432 
00433       RTPAggregationDisable        = 0x0100,   // SIP and H.323
00434       RTPAggregationEnable         = 0x0200,
00435       RTPAggregationMask           = 0x0300,
00436 
00437       SendDTMFAsDefault            = 0x0000,   // SIP and H.323
00438       SendDTMFAsString             = 0x0400,
00439       SendDTMFAsTone               = 0x0800,
00440       SendDTMFAsRFC2833            = 0x0c00,
00441       SendDTMFMask                 = 0x0c00
00442     };
00443 
00444     class StringOptions : public PStringToString 
00445     {
00446       public:
00447         // Make sure the key set in a StringOptions is caseless
00448         PBoolean SetAt(const char * key, const PString & data)
00449         {
00450           return PStringToString::SetAt(PCaselessString(key), data);
00451         }
00452         PBoolean SetAt(const PString & key, const PString & data)
00453         {
00454           return PStringToString::SetAt(PCaselessString(key), data);
00455         }
00456         PBoolean SetAt(const PCaselessString & key, const PString & data)
00457         {
00458           return PStringToString::SetAt(key, data);
00459         }
00460 
00461         bool GetBoolean(
00462           const char * key,
00463           bool dflt = false
00464         ) const;
00465         bool GetBoolean(
00466           const PString & key,
00467           bool dflt = false
00468         ) const { return GetBoolean((const char *)key, dflt); }
00469 
00470         long GetInteger(
00471           const char * key,
00472           long dflt = 0
00473         ) const;
00474         long GetInteger(
00475           const PString & key,
00476           long dflt = 0
00477         ) const { return GetInteger((const char *)key, dflt); }
00478 
00483         void ExtractFromURL(
00484           PURL & url
00485         );
00486     };
00487 
00492     OpalConnection(
00493       OpalCall & call,                         
00494       OpalEndPoint & endpoint,                 
00495       const PString & token,                   
00496       unsigned options = 0,                    
00497       OpalConnection::StringOptions * stringOptions = NULL     
00498     );  
00499 
00502     ~OpalConnection();
00504 
00511     void PrintOn(
00512       ostream & strm    
00513     ) const;
00515 
00532     virtual bool IsNetworkConnection() const = 0;
00533 
00537     enum Phases {
00538       UninitialisedPhase,   
00539       SetUpPhase,           
00540       ProceedingPhase,      
00541       AlertingPhase,        
00542       ConnectedPhase,       
00543       EstablishedPhase,     
00544       ForwardingPhase,      
00545       ReleasingPhase,       
00546       ReleasedPhase,        
00547       NumPhases             
00548     };
00549 
00554     inline Phases GetPhase() const { return phase; }
00555 
00560     void SetPhase(
00561       Phases phaseToSet  
00562     );
00563 
00572     CallEndReason GetCallEndReason() const { return callEndReason; }
00573 
00576     static PString GetCallEndReasonText(CallEndReason reason);
00577     PString GetCallEndReasonText() const { return GetCallEndReasonText(callEndReason); }
00578 
00581     static void SetCallEndReasonText(CallEndReasonCodes reasonCode, const PString & newText);
00582 
00587     virtual void SetCallEndReason(
00588       CallEndReason reason        
00589     );
00590 
00598     void ClearCall(
00599       CallEndReason reason = EndedByLocalUser 
00600     );
00601 
00604     virtual void ClearCallSynchronous(
00605       PSyncPoint * sync,
00606       CallEndReason reason = EndedByLocalUser  
00607     );
00608 
00612     unsigned GetQ931Cause() const { return callEndReason.q931; }
00613 
00617     void SetQ931Cause(unsigned v) { callEndReason.q931 = v; }
00618 
00625     virtual bool TransferConnection(
00626       const PString & remoteParty   
00627     );
00628     
00631     virtual bool HoldConnection();
00632 
00636     virtual bool RetrieveConnection();
00637 
00642     virtual bool IsConnectionOnHold(
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 
00825     virtual void Release(
00826       CallEndReason reason = EndedByLocalUser 
00827     );
00828 
00846     virtual void OnReleased();
00848 
00859     virtual PString GetDestinationAddress();
00860 
00870     virtual PBoolean ForwardCall(
00871       const PString & forwardParty   
00872     );
00873 
00876     PSafePtr<OpalConnection> GetOtherPartyConnection() const;
00877 
00880     template <class cls> PSafePtr<cls> GetOtherPartyConnectionAs() const { return PSafePtrCast<OpalConnection, cls>(GetOtherPartyConnection()); }
00882 
00891     virtual OpalMediaFormatList GetMediaFormats() const;
00892 
00897     virtual OpalMediaFormatList GetLocalMediaFormats();
00898 
00911     virtual void AdjustMediaFormats(
00912       bool local,                          
00913       OpalMediaFormatList & mediaFormats,  
00914       OpalConnection * otherConnection     
00915     ) const;
00916 
00924     virtual unsigned GetNextSessionID(
00925       const OpalMediaType & mediaType,   
00926       bool isSource                      
00927     );
00928 
00935     virtual OpalMediaType::AutoStartMode GetAutoStart(
00936       const OpalMediaType & mediaType  
00937     ) const;
00938 
00941     virtual void AutoStartMediaStreams(
00942       bool force = false 
00943     );
00944 
00945 #if OPAL_FAX
00946 
00948     virtual bool SwitchFaxMediaStreams(
00949       bool enableFax  
00950     );
00951 
00956     virtual void OnSwitchedFaxMediaStreams(
00957       bool enabledFax  
00958     );
00959 #endif
00960 
00963     virtual OpalMediaStreamPtr OpenMediaStream(
00964       const OpalMediaFormat & mediaFormat, 
00965       unsigned sessionID,                  
00966       bool isSource                        
00967     );
00968 
00973     virtual bool CloseMediaStream(
00974       unsigned sessionId,  
00975       bool source          
00976     );
00977 
00982     virtual bool CloseMediaStream(
00983       OpalMediaStream & stream  
00984     );
00985 
00993     bool RemoveMediaStream(
00994       OpalMediaStream & strm     // media stream to remove
00995     );
00996 
00999     virtual void StartMediaStreams();
01000     
01003     virtual void CloseMediaStreams();
01004     
01007     virtual void PauseMediaStreams(PBoolean paused);
01008 
01021     virtual OpalMediaStream * CreateMediaStream(
01022       const OpalMediaFormat & mediaFormat, 
01023       unsigned sessionID,                  
01024       PBoolean isSource                        
01025     );
01026 
01033     OpalMediaStreamPtr GetMediaStream(
01034       const PString & streamID,  
01035       bool source                
01036     ) const;
01037 
01043     OpalMediaStreamPtr GetMediaStream(
01044       unsigned sessionId,  
01045       bool source          
01046     ) const;
01047 
01058     OpalMediaStreamPtr GetMediaStream(
01059       const OpalMediaType & mediaType,    
01060       bool source,                        
01061       OpalMediaStreamPtr previous = NULL  
01062     ) const;
01063 
01075     virtual PBoolean OnOpenMediaStream(
01076       OpalMediaStream & stream    
01077     );
01078 
01083     virtual void OnClosedMediaStream(
01084       const OpalMediaStream & stream     
01085     );
01086     
01095     virtual void OnPatchMediaStream(
01096       PBoolean isSource,        
01097       OpalMediaPatch & patch    
01098     );
01099 
01102     virtual void OnStartMediaPatch(
01103       OpalMediaPatch & patch    
01104     );
01105 
01108     virtual void OnStopMediaPatch(
01109       OpalMediaPatch & patch    
01110     );
01111 
01115     PDECLARE_NOTIFIER(OpalMediaCommand, OpalConnection, OnMediaCommand);
01116 
01121     virtual void AttachRFC2833HandlerToPatch(PBoolean isSource, OpalMediaPatch & patch);
01122 
01128     virtual PBoolean IsMediaBypassPossible(
01129       unsigned sessionID                  
01130     ) const;
01131 
01132 #if OPAL_VIDEO
01133 
01135     virtual PBoolean CreateVideoInputDevice(
01136       const OpalMediaFormat & mediaFormat,  
01137       PVideoInputDevice * & device,         
01138       PBoolean & autoDelete                     
01139     );
01140 
01144     virtual PBoolean CreateVideoOutputDevice(
01145       const OpalMediaFormat & mediaFormat,  
01146       PBoolean preview,                         
01147       PVideoOutputDevice * & device,        
01148       PBoolean & autoDelete                     
01149     );
01150 
01153     virtual bool SendVideoUpdatePicture(
01154       unsigned sessionID = 0, 
01155       int firstGOB = -1,      
01156       int firstMB = -1,       
01157       int numBlocks = 0       
01158     ) const;
01159 #endif
01160 
01163     virtual PBoolean SetAudioVolume(
01164       PBoolean source,                  
01165       unsigned percentage           
01166     );
01167 
01171     virtual unsigned GetAudioSignalLevel(
01172       PBoolean source                   
01173     );
01175 
01180     unsigned GetBandwidthAvailable() const { return bandwidthAvailable; }
01181 
01186     virtual PBoolean SetBandwidthAvailable(
01187       unsigned newBandwidth,    
01188       PBoolean force = PFalse        
01189     );
01190 
01195     virtual unsigned GetBandwidthUsed() const;
01196 
01205     virtual PBoolean SetBandwidthUsed(
01206       unsigned releasedBandwidth,   
01207       unsigned requiredBandwidth    
01208     );
01210 
01213     enum SendUserInputModes {
01214       SendUserInputAsQ931,
01215       SendUserInputAsString,
01216       SendUserInputAsTone,
01217       SendUserInputAsInlineRFC2833,
01218       SendUserInputAsSeparateRFC2833,  // Not implemented
01219       SendUserInputAsProtocolDefault,
01220       NumSendUserInputModes
01221     };
01222 #if PTRACING
01223     friend ostream & operator<<(ostream & o, SendUserInputModes m);
01224 #endif
01225 
01228     virtual void SetSendUserInputMode(SendUserInputModes mode);
01229 
01232     virtual SendUserInputModes GetSendUserInputMode() const { return sendUserInputMode; }
01233 
01239     virtual SendUserInputModes GetRealSendUserInputMode() const { return GetSendUserInputMode(); }
01240 
01247     virtual PBoolean SendUserInputString(
01248       const PString & value                   
01249     );
01250 
01267     virtual PBoolean SendUserInputTone(
01268       char tone,        
01269       unsigned duration = 0  
01270     );
01271 
01278     virtual void OnUserInputString(
01279       const PString & value   
01280     );
01281 
01288     virtual void OnUserInputTone(
01289       char tone,
01290       unsigned duration
01291     );
01292 
01296     void SendUserInputHookFlash(
01297       unsigned duration = 500  
01298     ) { SendUserInputTone('!', duration); }
01299 
01302     virtual PString GetUserInput(
01303       unsigned timeout = 30   
01304     );
01305 
01310     virtual void SetUserInput(
01311       const PString & input     
01312     );
01313 
01316     virtual PString ReadUserInput(
01317       const char * terminators = "#\r\n", 
01318       unsigned lastDigitTimeout = 4,      
01319       unsigned firstDigitTimeout = 30     
01320     );
01321 
01328     virtual PBoolean PromptUserInput(
01329       PBoolean play   
01330     );
01332 
01337     virtual bool GarbageCollection();
01339 
01344     OpalEndPoint & GetEndPoint() const { return endpoint; }
01345     
01348     OpalCall & GetCall() const { return ownerCall; }
01349 
01352     const PString & GetToken() const { return callToken; }
01353 
01356     PBoolean IsOriginating() const { return originating; }
01357 
01360     PTime GetSetupUpTime() const { return setupTime; }
01361 
01364     PTime GetAlertingTime() const { return alertingTime; }
01365 
01368     PTime GetConnectionStartTime() const { return connectedTime; }
01369 
01372     PTime GetConnectionEndTime() const { return callEndTime; }
01373 
01376     const OpalProductInfo & GetProductInfo() const { return productInfo; }
01377 
01380     void SetProductInfo(
01381       const OpalProductInfo & info
01382     ) { productInfo = info; }
01383 
01386     virtual PString GetPrefixName() const;
01387 
01390     const PString & GetLocalPartyName() const { return localPartyName; }
01391 
01394     virtual void SetLocalPartyName(const PString & name);
01395 
01398     virtual PString GetLocalPartyURL() const;
01399 
01402     const PString & GetDisplayName() const { return displayName; }
01403 
01406     void SetDisplayName(const PString & name) { displayName = name; }
01407 
01413     virtual bool IsPresentationBlocked() const;
01414 
01417     const PString & GetRemotePartyName() const { return remotePartyName; }
01418 
01421     void SetRemotePartyName(const PString & name) { remotePartyName = name; }
01422 
01431     const PString & GetRemotePartyNumber() const { return remotePartyNumber; }
01432 
01438     const PString & GetRemotePartyAddress() const { return remotePartyAddress; }
01439 
01442     void SetRemotePartyAddress(const PString & addr) { remotePartyAddress = addr; }
01443 
01450     virtual PString GetRemotePartyURL() const;
01451 
01452     // Deprecated - backward compatibility only
01453     const PString GetRemotePartyCallbackURL() const { return GetRemotePartyURL(); }
01454 
01458     PCaselessString GetRemoteApplication() const { return remoteProductInfo.AsString(); }
01459 
01462     const OpalProductInfo & GetRemoteProductInfo() const { return remoteProductInfo; }
01463 
01464 
01471     const PString & GetCalledPartyName() const { return m_calledPartyName; }
01472 
01479     const PString & GetCalledPartyNumber() const { return m_calledPartyNumber; }
01480 
01488     virtual PString GetCalledPartyURL();
01489 
01490     /* Internal function to copy party names from "network" connection to
01491        "non-network" connection such as OpalPCSSConnection. This allows
01492        the non-network GetRemoteAddress() function and its ilk to return
01493        the intuitive value, i.e. the value from the OTHER connection.
01494      */
01495     void CopyPartyNames(const OpalConnection & other);
01496 
01497 
01511     virtual PString GetAlertingType() const;
01512 
01526     virtual bool SetAlertingType(const PString & info);
01527 
01528 
01532     unsigned GetMinAudioJitterDelay() const { return minAudioJitterDelay; }
01533 
01537     unsigned GetMaxAudioJitterDelay() const { return maxAudioJitterDelay; }
01538 
01541     void SetAudioJitterDelay(
01542       unsigned minDelay,   
01543       unsigned maxDelay    
01544     );
01545 
01548     OpalSilenceDetector * GetSilenceDetector() const { return silenceDetector; }
01549     
01550 #if OPAL_AEC
01551 
01553     OpalEchoCanceler * GetEchoCanceler() const { return echoCanceler; }
01554 #endif
01555 
01559     virtual PString GetIdentifier() const;
01560 
01569     virtual PINDEX GetMaxRtpPayloadSize() const;
01570 
01571     virtual OpalTransport & GetTransport() const
01572     { return *(OpalTransport *)NULL; }
01573 
01574     PDICTIONARY(MediaAddressesDict, POrdinalKey, OpalTransportAddress);
01575     MediaAddressesDict & GetMediaTransportAddresses()
01576     { return mediaTransportAddresses; }
01577 
01578 #if OPAL_STATISTICS
01579 
01581     unsigned GetVideoUpdateRequestsSent() const { return m_VideoUpdateRequestsSent; }
01582 #endif
01583 
01584 
01586     const StringOptions & GetStringOptions() const { return m_connStringOptions; }
01587 
01589     void SetStringOptions(
01590       const StringOptions & options,
01591       bool overwrite
01592     );
01593 
01594     virtual void ApplyStringOptions(OpalConnection::StringOptions & stringOptions);
01595     virtual void OnApplyStringOptions();
01596 
01597 #if OPAL_HAS_MIXER
01598 
01599     virtual void EnableRecording();
01600     virtual void DisableRecording();
01601 
01602 #endif
01603 
01604 #if OPAL_HAS_IM
01605 
01608     virtual bool TransmitInternalIM(
01609       const OpalMediaFormat & format, 
01610       RTP_IMFrame & body
01611     );
01612 
01616     virtual void OnReceiveInternalIM(
01617       const OpalMediaFormat & format, 
01618       RTP_IMFrame & body
01619     );
01620 
01624     virtual bool TransmitExternalIM(
01625       const OpalMediaFormat & format, 
01626       RTP_IMFrame & body
01627     );
01628 
01632     virtual bool OnReceiveExternalIM(
01633       const OpalMediaFormat & format, 
01634       RTP_IMFrame & body
01635     );
01636 
01641     RFC4103Context & GetRFC4103Context(PINDEX i) { return m_rfc4103Context[i]; };
01642 
01643   protected:
01644     RFC4103Context m_rfc4103Context[2];
01645 
01646 #endif
01647 
01648   protected:
01649     void OnConnectedInternal();
01650 
01651     PDECLARE_NOTIFIER(PThread, OpalConnection, OnReleaseThreadMain);
01652 
01653 #if OPAL_HAS_MIXER
01654     PDECLARE_NOTIFIER(RTP_DataFrame, OpalConnection, OnRecordAudio);
01655 #if OPAL_VIDEO
01656     PDECLARE_NOTIFIER(RTP_DataFrame, OpalConnection, OnRecordVideo);
01657 #endif
01658     void OnStartRecording(OpalMediaPatch * patch);
01659     void OnStopRecording(OpalMediaPatch * patch);
01660 #endif
01661 
01662   // Member variables
01663     OpalCall             & ownerCall;
01664     OpalEndPoint         & endpoint;
01665 
01666   private:
01667     PMutex               phaseMutex;
01668     Phases               phase;
01669 
01670   protected:
01671     PString              callToken;
01672     PBoolean             originating;
01673     PTime                setupTime;
01674     PTime                alertingTime;
01675     PTime                connectedTime;
01676     PTime                callEndTime;
01677     OpalProductInfo      productInfo;
01678     PString              localPartyName;
01679     PString              displayName;
01680     PString              remotePartyName;
01681     OpalProductInfo      remoteProductInfo;
01682     PString              remotePartyNumber;
01683     PString              remotePartyAddress;
01684     CallEndReason        callEndReason;
01685     bool                 synchronousOnRelease;
01686     PString              m_calledPartyNumber;
01687     PString              m_calledPartyName;
01688 
01689     SendUserInputModes    sendUserInputMode;
01690     PString               userInputString;
01691     PSyncPoint            userInputAvailable;
01692 
01693     OpalSilenceDetector * silenceDetector;
01694 #if OPAL_AEC
01695     OpalEchoCanceler    * echoCanceler;
01696 #endif
01697 
01698     MediaAddressesDict         mediaTransportAddresses;
01699     PSafeList<OpalMediaStream> mediaStreams;
01700 
01701     unsigned            minAudioJitterDelay;
01702     unsigned            maxAudioJitterDelay;
01703     unsigned            bandwidthAvailable;
01704 
01705     // The In-Band DTMF detector. This is used inside an audio filter which is
01706     // added to the audio channel.
01707 #if OPAL_PTLIB_DTMF
01708     PDTMFDecoder m_dtmfDecoder;
01709     bool         m_detectInBandDTMF;
01710     unsigned     m_dtmfScaleMultiplier;
01711     unsigned     m_dtmfScaleDivisor;
01712     PNotifier    m_dtmfNotifier;
01713     PDECLARE_NOTIFIER(RTP_DataFrame, OpalConnection, OnDetectInBandDTMF);
01714 
01715     bool         m_sendInBandDTMF;
01716     bool         m_installedInBandDTMF;
01717     PDTMFEncoder m_inBandDTMF;
01718     PINDEX       m_emittedInBandDTMF;
01719     PMutex       m_inBandMutex;
01720     PDECLARE_NOTIFIER(RTP_DataFrame, OpalConnection, OnSendInBandDTMF);
01721 #endif
01722 
01723 #if PTRACING
01724     friend ostream & operator<<(ostream & o, Phases p);
01725 #endif
01726 
01727     StringOptions m_connStringOptions;
01728 
01729 #if OPAL_HAS_MIXER
01730     PString       m_recordingFilename;
01731     PNotifier     m_recordAudioNotifier;
01732 #if OPAL_VIDEO
01733     PNotifier     m_recordVideoNotifier;
01734 #endif
01735 #endif
01736 
01737 #if OPAL_STATISTICS
01738     unsigned m_VideoUpdateRequestsSent;
01739 #endif
01740 
01741     struct AutoStartInfo {
01742       unsigned preferredSessionId;  // preferred session ID (only used for originating)
01743       OpalMediaType::AutoStartMode autoStart;// Mode for this session when the call is started
01744     };
01745 
01746     class AutoStartMap : public std::map<OpalMediaType, AutoStartInfo>
01747     {
01748       public:
01749         AutoStartMap();
01750         void Initialise(const OpalConnection::StringOptions & stringOptions);
01751         OpalMediaType::AutoStartMode GetAutoStart(const OpalMediaType & mediaType) const;
01752         void SetAutoStart(const OpalMediaType & mediaType, OpalMediaType::AutoStartMode autoStart);
01753 
01754       protected:
01755         bool m_initialised;
01756         PMutex m_mutex;
01757 
01758     };
01759     AutoStartMap m_autoStartInfo;
01760 
01761 #if OPAL_FAX
01762     enum {
01763       e_NotSwitchingFaxMediaStreams,
01764       e_SwitchingToFaxMediaStreams,
01765       e_SwitchingFromFaxMediaStreams
01766     } m_faxMediaStreamsSwitchState;
01767 #endif
01768 
01769   private:
01770     P_REMOVE_VIRTUAL(PBoolean, OnIncomingConnection(unsigned int), false);
01771     P_REMOVE_VIRTUAL(PBoolean, OnIncomingConnection(), false);
01772     P_REMOVE_VIRTUAL(PBoolean, IsConnectionOnHold(), false);
01773     P_REMOVE_VIRTUAL_VOID(OnMediaPatchStart(unsigned, bool));
01774     P_REMOVE_VIRTUAL_VOID(OnMediaPatchStop(unsigned, bool));
01775     P_REMOVE_VIRTUAL_VOID(AdjustMediaFormats(OpalMediaFormatList &) const);
01776     P_REMOVE_VIRTUAL_VOID(AdjustMediaFormats(OpalMediaFormatList &, OpalConnection *) const);
01777     P_REMOVE_VIRTUAL_VOID(PreviewPeerMediaFormats(const OpalMediaFormatList &));
01778 };
01779 
01780 #endif // OPAL_OPAL_CONNECTION_H
01781 
01782 
01783 // End of File ///////////////////////////////////////////////////////////////

Generated on Wed Dec 15 07:55:08 2010 for OPAL by  doxygen 1.4.7