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