OPAL Version 3.10.2
|
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: 25556 $ 00031 * $Author: rjongbloed $ 00032 * $Date: 2011-04-13 04:35:30 -0500 (Wed, 13 Apr 2011) $ 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 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_REDIRECTING_PARTY "Redirecting-Party" ///< String option to set redirecting/refferred-by party 00081 #define OPAL_OPT_PRESENTATION_BLOCK "Presentation-Block" ///< String option to block outgoing calling number presentation 00082 #define OPAL_OPT_ORIGINATOR_ADDRESS "Originator-Address" ///< String option for originator address used by IVR 00083 #define OPAL_OPT_INTERFACE "Interface" ///< String option to set the interface used for outgoing call 00084 #define OPAL_OPT_USER_INPUT_MODE "User-Input-Mode" ///< String option to set User Input indication mode: 00085 00086 #define OPAL_OPT_ENABLE_INBAND_DTMF "EnableInbandDTMF" ///< String option to enable in band DTMF detection 00087 #define OPAL_OPT_ENABLE_INBAND_DTMF "EnableInbandDTMF" ///< String option to enable in band DTMF detection/send 00088 #define OPAL_OPT_DETECT_INBAND_DTMF "DetectInBandDTMF" ///< String option to enable in band DTMF detection 00089 #define OPAL_OPT_SEND_INBAND_DTMF "SendInBandDTMF" ///< String option to enable in band DTMF send as fall back for other UI modes 00090 #define OPAL_OPT_DTMF_MULT "dtmfmult" 00091 #define OPAL_OPT_DTMF_DIV "dtmfdiv" 00092 #define OPAL_OPT_DISABLE_JITTER "Disable-Jitter" ///< String option to disable jitter buffer if "true" 00093 #define OPAL_OPT_MAX_JITTER "Max-Jitter" ///< String option to set maximum jitter in milliseconds 00094 #define OPAL_OPT_MIN_JITTER "Min-Jitter" ///< String option to set minimum jitter in milliseconds 00095 #define OPAL_OPT_RECORD_AUDIO "Record-Audio" ///< String option to start recording to a file for call 00096 #define OPAL_OPT_ALERTING_TYPE "Alerting-Type" ///< String option to set the alerting type string for call 00097 #define OPAL_OPT_REMOVE_CODEC "Remove-Codec" ///< String option to remove codecs for this call 00098 00099 00310 class OpalProductInfo 00311 { 00312 public: 00313 OpalProductInfo(); 00314 00315 static OpalProductInfo & Default(); 00316 00317 friend ostream & operator<<(ostream & strm, const OpalProductInfo & info); 00318 PCaselessString AsString() const; 00319 00320 PCaselessString vendor; 00321 PCaselessString name; 00322 PCaselessString version; 00323 PCaselessString comments; 00324 00325 BYTE t35CountryCode; 00326 BYTE t35Extension; 00327 WORD manufacturerCode; 00328 00329 private: 00330 OpalProductInfo(bool); 00331 }; 00332 00333 00351 class OpalConnection : public PSafeObject 00352 { 00353 PCLASSINFO(OpalConnection, PSafeObject); 00354 public: 00359 enum CallEndReasonCodes { 00360 EndedByLocalUser, 00361 EndedByNoAccept, 00362 EndedByAnswerDenied, 00363 EndedByRemoteUser, 00364 EndedByRefusal, 00365 EndedByNoAnswer, 00366 EndedByCallerAbort, 00367 EndedByTransportFail, 00368 EndedByConnectFail, 00369 EndedByGatekeeper, 00370 EndedByNoUser, 00371 EndedByNoBandwidth, 00372 EndedByCapabilityExchange, 00373 EndedByCallForwarded, 00374 EndedBySecurityDenial, 00375 EndedByLocalBusy, 00376 EndedByLocalCongestion, 00377 EndedByRemoteBusy, 00378 EndedByRemoteCongestion, 00379 EndedByUnreachable, 00380 EndedByNoEndPoint, 00381 EndedByHostOffline, 00382 EndedByTemporaryFailure, 00383 EndedByQ931Cause, 00384 EndedByDurationLimit, 00385 EndedByInvalidConferenceID, 00386 EndedByNoDialTone, 00387 EndedByNoRingBackTone, 00388 EndedByOutOfService, 00389 EndedByAcceptingCallWaiting, 00390 EndedByGkAdmissionFailed, 00391 NumCallEndReasons 00392 }; 00393 00394 struct CallEndReason { 00395 CallEndReason( 00396 CallEndReasonCodes reason = NumCallEndReasons, 00397 unsigned cause = 0 00398 ) : code(reason), q931(cause) { } 00399 explicit CallEndReason( 00400 long reason 00401 ) : code((CallEndReasonCodes)(reason&0xff)), q931((reason>>8)&0xff) { } 00402 00403 __inline operator CallEndReasonCodes() const { return code; } 00404 00405 __inline int AsInteger() const { return code|(q931<<8); } 00406 00407 CallEndReasonCodes code:8; // Normalised OPAL code 00408 unsigned q931:8; // PSTN Interworking code, actually Q.850 00409 }; 00410 00411 #if PTRACING 00412 friend ostream & operator<<(ostream & o, CallEndReason reason); 00413 #endif 00414 00415 enum AnswerCallResponse { 00416 AnswerCallNow, 00417 AnswerCallDenied, 00418 AnswerCallPending, 00419 AnswerCallDeferred, 00420 AnswerCallAlertWithMedia, 00421 AnswerCallDeferredWithMedia, 00422 AnswerCallProgress, 00423 AnswerCallNowAndReleaseCurrent, 00424 NumAnswerCallResponses 00425 }; 00426 #if PTRACING 00427 friend ostream & operator<<(ostream & o, AnswerCallResponse s); 00428 #endif 00429 00432 enum Options { 00433 FastStartOptionDisable = 0x0001, // H.323 specific 00434 FastStartOptionEnable = 0x0002, 00435 FastStartOptionMask = 0x0003, 00436 00437 H245TunnelingOptionDisable = 0x0004, // H.323 specific 00438 H245TunnelingOptionEnable = 0x0008, 00439 H245TunnelingOptionMask = 0x000c, 00440 00441 H245inSetupOptionDisable = 0x0010, // H.323 specific 00442 H245inSetupOptionEnable = 0x0020, 00443 H245inSetupOptionMask = 0x0030, 00444 00445 DetectInBandDTMFOptionDisable = 0x0040, // SIP and H.323 00446 DetectInBandDTMFOptionEnable = 0x0080, 00447 DetectInBandDTMFOptionMask = 0x00c0, 00448 00449 RTPAggregationDisable = 0x0100, // SIP and H.323 00450 RTPAggregationEnable = 0x0200, 00451 RTPAggregationMask = 0x0300, 00452 00453 SendDTMFAsDefault = 0x0000, // SIP and H.323 00454 SendDTMFAsString = 0x0400, 00455 SendDTMFAsTone = 0x0800, 00456 SendDTMFAsRFC2833 = 0x0c00, 00457 SendDTMFMask = 0x0c00 00458 }; 00459 00460 class StringOptions : public PStringOptions 00461 { 00462 public: 00467 void ExtractFromURL( 00468 PURL & url 00469 ); 00470 }; 00471 00476 OpalConnection( 00477 OpalCall & call, 00478 OpalEndPoint & endpoint, 00479 const PString & token, 00480 unsigned options = 0, 00481 OpalConnection::StringOptions * stringOptions = NULL 00482 ); 00483 00486 ~OpalConnection(); 00488 00495 void PrintOn( 00496 ostream & strm 00497 ) const; 00499 00516 virtual bool IsNetworkConnection() const = 0; 00517 00521 enum Phases { 00522 UninitialisedPhase, 00523 SetUpPhase, 00524 ProceedingPhase, 00525 AlertingPhase, 00526 ConnectedPhase, 00527 EstablishedPhase, 00528 ForwardingPhase, 00529 ReleasingPhase, 00530 ReleasedPhase, 00531 NumPhases 00532 }; 00533 00538 __inline Phases GetPhase() const { return m_phase; } 00539 00541 __inline bool IsEstablished() const { return m_phase == EstablishedPhase; } 00542 00544 __inline bool IsReleased() const { return m_phase >= ReleasingPhase; } 00545 00550 void SetPhase( 00551 Phases phaseToSet 00552 ); 00553 00562 CallEndReason GetCallEndReason() const { return callEndReason; } 00563 00566 static PString GetCallEndReasonText(CallEndReason reason); 00567 PString GetCallEndReasonText() const { return GetCallEndReasonText(callEndReason); } 00568 00571 static void SetCallEndReasonText(CallEndReasonCodes reasonCode, const PString & newText); 00572 00577 virtual void SetCallEndReason( 00578 CallEndReason reason 00579 ); 00580 00588 void ClearCall( 00589 CallEndReason reason = EndedByLocalUser 00590 ); 00591 00594 virtual void ClearCallSynchronous( 00595 PSyncPoint * sync, 00596 CallEndReason reason = EndedByLocalUser 00597 ); 00598 00602 unsigned GetQ931Cause() const { return callEndReason.q931; } 00603 00607 void SetQ931Cause(unsigned v) { callEndReason.q931 = v; } 00608 00615 virtual bool TransferConnection( 00616 const PString & remoteParty 00617 ); 00618 00626 virtual bool Hold( 00627 bool fromRemote, 00628 bool placeOnHold 00629 ); 00630 00635 virtual bool IsOnHold( 00636 bool fromRemote 00637 ); 00638 00643 virtual void OnHold( 00644 bool fromRemote, 00645 bool onHold 00646 ); 00648 00676 virtual PBoolean OnIncomingConnection(unsigned int options, OpalConnection::StringOptions * stringOptions); 00677 00684 virtual PBoolean SetUpConnection() = 0; 00685 00689 virtual PBoolean OnSetUpConnection(); 00690 00691 00706 virtual void OnProceeding(); 00707 00718 virtual void OnAlerting(); 00719 00730 virtual PBoolean SetAlerting( 00731 const PString & calleeName, 00732 PBoolean withMedia 00733 ) = 0; 00734 00751 virtual AnswerCallResponse OnAnswerCall( 00752 const PString & callerName 00753 ); 00754 00765 virtual void AnsweringCall( 00766 AnswerCallResponse response 00767 ); 00768 00783 virtual void OnConnected(); 00784 00795 virtual PBoolean SetConnected(); 00796 00808 virtual void OnEstablished(); 00809 00839 virtual bool OnTransferNotify( 00840 const PStringToString & info 00841 ); 00842 00851 virtual void Release( 00852 CallEndReason reason = EndedByLocalUser 00853 ); 00854 00872 virtual void OnReleased(); 00874 00885 virtual PString GetDestinationAddress(); 00886 00896 virtual PBoolean ForwardCall( 00897 const PString & forwardParty 00898 ); 00899 00902 PSafePtr<OpalConnection> GetOtherPartyConnection() const; 00903 00906 template <class cls> PSafePtr<cls> GetOtherPartyConnectionAs() const { return PSafePtrCast<OpalConnection, cls>(GetOtherPartyConnection()); } 00908 00917 virtual OpalMediaFormatList GetMediaFormats() const; 00918 00923 virtual OpalMediaFormatList GetLocalMediaFormats(); 00924 00938 virtual void AdjustMediaFormats( 00939 bool local, 00940 const OpalConnection * otherConnection, 00941 OpalMediaFormatList & mediaFormats 00942 ) const; 00943 00951 virtual unsigned GetNextSessionID( 00952 const OpalMediaType & mediaType, 00953 bool isSource 00954 ); 00955 00962 virtual OpalMediaType::AutoStartMode GetAutoStart( 00963 const OpalMediaType & mediaType 00964 ) const; 00965 00968 virtual void AutoStartMediaStreams( 00969 bool force = false 00970 ); 00971 00972 #if OPAL_FAX 00973 00975 virtual bool SwitchFaxMediaStreams( 00976 bool enableFax 00977 ); 00978 00983 virtual void OnSwitchedFaxMediaStreams( 00984 bool enabledFax 00985 ); 00986 #endif 00987 00990 virtual OpalMediaStreamPtr OpenMediaStream( 00991 const OpalMediaFormat & mediaFormat, 00992 unsigned sessionID, 00993 bool isSource 00994 ); 00995 00998 virtual bool CloseMediaStream( 00999 unsigned sessionId, 01000 bool source 01001 ); 01002 01005 virtual bool CloseMediaStream( 01006 OpalMediaStream & stream 01007 ); 01008 01016 bool RemoveMediaStream( 01017 OpalMediaStream & strm 01018 ); 01019 01022 virtual void StartMediaStreams(); 01023 01026 virtual void CloseMediaStreams(); 01027 01030 virtual void PauseMediaStreams( 01031 bool paused 01032 ); 01033 01036 virtual void OnPauseMediaStream( 01037 OpalMediaStream & strm, 01038 bool paused 01039 ); 01040 01053 virtual OpalMediaStream * CreateMediaStream( 01054 const OpalMediaFormat & mediaFormat, 01055 unsigned sessionID, 01056 PBoolean isSource 01057 ); 01058 01065 OpalMediaStreamPtr GetMediaStream( 01066 const PString & streamID, 01067 bool source 01068 ) const; 01069 01075 OpalMediaStreamPtr GetMediaStream( 01076 unsigned sessionId, 01077 bool source 01078 ) const; 01079 01090 OpalMediaStreamPtr GetMediaStream( 01091 const OpalMediaType & mediaType, 01092 bool source, 01093 OpalMediaStreamPtr previous = NULL 01094 ) const; 01095 01107 virtual PBoolean OnOpenMediaStream( 01108 OpalMediaStream & stream 01109 ); 01110 01115 virtual void OnClosedMediaStream( 01116 const OpalMediaStream & stream 01117 ); 01118 01127 virtual void OnPatchMediaStream( 01128 PBoolean isSource, 01129 OpalMediaPatch & patch 01130 ); 01131 01134 virtual void OnStartMediaPatch( 01135 OpalMediaPatch & patch 01136 ); 01137 01140 virtual void OnStopMediaPatch( 01141 OpalMediaPatch & patch 01142 ); 01143 01147 PDECLARE_NOTIFIER(OpalMediaCommand, OpalConnection, OnMediaCommand); 01148 01153 virtual void AttachRFC2833HandlerToPatch(PBoolean isSource, OpalMediaPatch & patch); 01154 01160 virtual PBoolean IsMediaBypassPossible( 01161 unsigned sessionID 01162 ) const; 01163 01164 #if OPAL_VIDEO 01165 01167 virtual PBoolean CreateVideoInputDevice( 01168 const OpalMediaFormat & mediaFormat, 01169 PVideoInputDevice * & device, 01170 PBoolean & autoDelete 01171 ); 01172 01176 virtual PBoolean CreateVideoOutputDevice( 01177 const OpalMediaFormat & mediaFormat, 01178 PBoolean preview, 01179 PVideoOutputDevice * & device, 01180 PBoolean & autoDelete 01181 ); 01182 01188 virtual bool SendVideoUpdatePicture( 01189 unsigned sessionID = 0, 01190 bool force = false 01191 ) const; 01192 #endif 01193 01196 virtual PBoolean SetAudioVolume( 01197 PBoolean source, 01198 unsigned percentage 01199 ); 01200 01204 virtual unsigned GetAudioSignalLevel( 01205 PBoolean source 01206 ); 01208 01213 unsigned GetBandwidthAvailable() const { return bandwidthAvailable; } 01214 01219 virtual PBoolean SetBandwidthAvailable( 01220 unsigned newBandwidth, 01221 PBoolean force = false 01222 ); 01223 01228 virtual unsigned GetBandwidthUsed() const; 01229 01238 virtual PBoolean SetBandwidthUsed( 01239 unsigned releasedBandwidth, 01240 unsigned requiredBandwidth 01241 ); 01243 01246 enum SendUserInputModes { 01247 SendUserInputAsQ931, 01248 SendUserInputAsString, 01249 SendUserInputAsTone, 01250 SendUserInputAsRFC2833, 01251 SendUserInputInBand, 01252 SendUserInputAsProtocolDefault, 01253 NumSendUserInputModes, 01254 01255 SendUserInputAsInlineRFC2833 = SendUserInputAsRFC2833 // For backward compatibility 01256 }; 01257 #if PTRACING 01258 friend ostream & operator<<(ostream & o, SendUserInputModes m); 01259 #endif 01260 01263 virtual void SetSendUserInputMode(SendUserInputModes mode); 01264 01267 virtual SendUserInputModes GetSendUserInputMode() const { return sendUserInputMode; } 01268 01274 virtual SendUserInputModes GetRealSendUserInputMode() const { return GetSendUserInputMode(); } 01275 01282 virtual PBoolean SendUserInputString( 01283 const PString & value 01284 ); 01285 01302 virtual PBoolean SendUserInputTone( 01303 char tone, 01304 unsigned duration = 0 01305 ); 01306 01313 virtual void OnUserInputString( 01314 const PString & value 01315 ); 01316 01323 virtual void OnUserInputTone( 01324 char tone, 01325 unsigned duration 01326 ); 01327 01331 void SendUserInputHookFlash( 01332 unsigned duration = 500 01333 ) { SendUserInputTone('!', duration); } 01334 01337 virtual PString GetUserInput( 01338 unsigned timeout = 30 01339 ); 01340 01345 virtual void SetUserInput( 01346 const PString & input 01347 ); 01348 01351 virtual PString ReadUserInput( 01352 const char * terminators = "#\r\n", 01353 unsigned lastDigitTimeout = 4, 01354 unsigned firstDigitTimeout = 30 01355 ); 01356 01363 virtual PBoolean PromptUserInput( 01364 PBoolean play 01365 ); 01367 01372 virtual bool GarbageCollection(); 01374 01379 OpalEndPoint & GetEndPoint() const { return endpoint; } 01380 01383 OpalCall & GetCall() const { return ownerCall; } 01384 01387 const PString & GetToken() const { return callToken; } 01388 01391 PBoolean IsOriginating() const { return originating; } 01392 01395 const PTime & GetPhaseTime(Phases phase) const { return m_phaseTime[phase]; } 01396 01399 const PTime & GetSetupUpTime() const { return m_phaseTime[SetUpPhase]; } 01400 01403 const PTime & GetAlertingTime() const { return m_phaseTime[AlertingPhase]; } 01404 01409 const PTime & GetConnectionStartTime() const { return m_phaseTime[ConnectedPhase]; } 01410 01413 const PTime & GetConnectionEndTime() const { return m_phaseTime[ReleasingPhase]; } 01414 01417 const OpalProductInfo & GetProductInfo() const { return productInfo; } 01418 01421 void SetProductInfo( 01422 const OpalProductInfo & info 01423 ) { productInfo = info; } 01424 01427 virtual PString GetPrefixName() const; 01428 01431 const PString & GetLocalPartyName() const { return localPartyName; } 01432 01435 virtual void SetLocalPartyName(const PString & name); 01436 01439 virtual PString GetLocalPartyURL() const; 01440 01443 const PString & GetDisplayName() const { return displayName; } 01444 01447 void SetDisplayName(const PString & name) { displayName = name; } 01448 01454 virtual bool IsPresentationBlocked() const; 01455 01458 const PString & GetRemotePartyName() const { return remotePartyName; } 01459 01462 void SetRemotePartyName(const PString & name) { remotePartyName = name; } 01463 01472 const PString & GetRemotePartyNumber() const { return remotePartyNumber; } 01473 01479 const PString & GetRemotePartyAddress() const { return remotePartyAddress; } 01480 01483 void SetRemotePartyAddress(const PString & addr) { remotePartyAddress = addr; } 01484 01491 virtual PString GetRemotePartyURL() const; 01492 01496 const PString & GetRedirectingParty() const { return m_redirectingParty; } 01497 01501 void SetRedirectingParty(const PString & party) { m_redirectingParty = party; } 01502 01503 // Deprecated - backward compatibility only 01504 const PString GetRemotePartyCallbackURL() const { return GetRemotePartyURL(); } 01505 01509 PCaselessString GetRemoteApplication() const { return remoteProductInfo.AsString(); } 01510 01513 const OpalProductInfo & GetRemoteProductInfo() const { return remoteProductInfo; } 01514 01515 01522 const PString & GetCalledPartyName() const { return m_calledPartyName; } 01523 01530 const PString & GetCalledPartyNumber() const { return m_calledPartyNumber; } 01531 01539 virtual PString GetCalledPartyURL(); 01540 01541 /* Internal function to copy party names from "network" connection to 01542 "non-network" connection such as OpalPCSSConnection. This allows 01543 the non-network GetRemoteAddress() function and its ilk to return 01544 the intuitive value, i.e. the value from the OTHER connection. 01545 */ 01546 void CopyPartyNames(const OpalConnection & other); 01547 01548 01562 virtual PString GetAlertingType() const; 01563 01577 virtual bool SetAlertingType(const PString & info); 01578 01586 virtual PString GetCallInfo() const; 01587 01591 unsigned GetMinAudioJitterDelay() const { return minAudioJitterDelay; } 01592 01596 unsigned GetMaxAudioJitterDelay() const { return maxAudioJitterDelay; } 01597 01600 void SetAudioJitterDelay( 01601 unsigned minDelay, 01602 unsigned maxDelay 01603 ); 01604 01607 OpalSilenceDetector * GetSilenceDetector() const { return silenceDetector; } 01608 01609 #if OPAL_AEC 01610 01612 OpalEchoCanceler * GetEchoCanceler() const { return echoCanceler; } 01613 #endif 01614 01618 virtual PString GetIdentifier() const; 01619 01628 virtual PINDEX GetMaxRtpPayloadSize() const; 01629 01630 virtual OpalTransport & GetTransport() const 01631 { return *(OpalTransport *)NULL; } 01632 01633 PDICTIONARY(MediaAddressesDict, POrdinalKey, OpalTransportAddress); 01634 MediaAddressesDict & GetMediaTransportAddresses() 01635 { return mediaTransportAddresses; } 01636 01637 #if OPAL_STATISTICS 01638 01640 unsigned GetVideoUpdateRequestsSent() const { return m_VideoUpdateRequestsSent; } 01641 #endif 01642 01643 01645 const StringOptions & GetStringOptions() const { return m_stringOptions; } 01646 01648 void SetStringOptions( 01649 const StringOptions & options, 01650 bool overwrite 01651 ); 01652 01654 virtual void OnApplyStringOptions(); 01655 01656 #if OPAL_HAS_MIXER 01657 01658 virtual void EnableRecording(); 01659 virtual void DisableRecording(); 01660 01661 #endif 01662 01663 #if 0 //OPAL_HAS_IM 01664 01667 virtual bool TransmitInternalIM( 01668 const OpalMediaFormat & format, 01669 RTP_IMFrame & body 01670 ); 01671 01675 virtual void OnReceiveInternalIM( 01676 const OpalMediaFormat & format, 01677 RTP_IMFrame & body 01678 ); 01679 01683 virtual bool TransmitExternalIM( 01684 const OpalMediaFormat & format, 01685 RTP_IMFrame & body 01686 ); 01687 01691 virtual bool OnReceiveExternalIM( 01692 const OpalMediaFormat & format, 01693 RTP_IMFrame & body 01694 ); 01695 01700 RFC4103Context & GetRFC4103Context(PINDEX i) { return m_rfc4103Context[i]; }; 01701 01702 protected: 01703 RFC4103Context m_rfc4103Context[2]; 01704 01705 #endif 01706 01707 protected: 01708 void OnConnectedInternal(); 01709 01710 PDECLARE_NOTIFIER(PThread, OpalConnection, OnReleaseThreadMain); 01711 01712 #if OPAL_HAS_MIXER 01713 PDECLARE_NOTIFIER(RTP_DataFrame, OpalConnection, OnRecordAudio); 01714 #if OPAL_VIDEO 01715 PDECLARE_NOTIFIER(RTP_DataFrame, OpalConnection, OnRecordVideo); 01716 #endif 01717 void OnStartRecording(OpalMediaPatch * patch); 01718 void OnStopRecording(OpalMediaPatch * patch); 01719 #endif 01720 01721 // Member variables 01722 OpalCall & ownerCall; 01723 OpalEndPoint & endpoint; 01724 01725 private: 01726 PMutex m_phaseMutex; 01727 Phases m_phase; 01728 01729 protected: 01730 PString callToken; 01731 PBoolean originating; 01732 OpalProductInfo productInfo; 01733 PString localPartyName; 01734 PString displayName; 01735 PString remotePartyName; 01736 PString remotePartyURL; 01737 OpalProductInfo remoteProductInfo; 01738 PString remotePartyNumber; 01739 PString remotePartyAddress; 01740 PString m_redirectingParty; 01741 CallEndReason callEndReason; 01742 bool synchronousOnRelease; 01743 PString m_calledPartyNumber; 01744 PString m_calledPartyName; 01745 01746 SendUserInputModes sendUserInputMode; 01747 PString userInputString; 01748 PSyncPoint userInputAvailable; 01749 01750 OpalSilenceDetector * silenceDetector; 01751 #if OPAL_AEC 01752 OpalEchoCanceler * echoCanceler; 01753 #endif 01754 OpalMediaFormat m_filterMediaFormat; 01755 01756 OpalMediaFormatList m_localMediaFormats; 01757 MediaAddressesDict mediaTransportAddresses; 01758 PSafeList<OpalMediaStream> mediaStreams; 01759 01760 unsigned minAudioJitterDelay; 01761 unsigned maxAudioJitterDelay; 01762 unsigned bandwidthAvailable; 01763 01764 // The In-Band DTMF detector. This is used inside an audio filter which is 01765 // added to the audio channel. 01766 #if OPAL_PTLIB_DTMF 01767 PDTMFDecoder m_dtmfDecoder; 01768 bool m_detectInBandDTMF; 01769 unsigned m_dtmfScaleMultiplier; 01770 unsigned m_dtmfScaleDivisor; 01771 PNotifier m_dtmfDetectNotifier; 01772 PDECLARE_NOTIFIER(RTP_DataFrame, OpalConnection, OnDetectInBandDTMF); 01773 01774 bool m_sendInBandDTMF; 01775 OpalMediaFormat m_dtmfSendFormat; 01776 PBYTEArray m_inBandDTMF; 01777 PINDEX m_emittedInBandDTMF; 01778 PMutex m_inBandMutex; 01779 PNotifier m_dtmfSendNotifier; 01780 PDECLARE_NOTIFIER(RTP_DataFrame, OpalConnection, OnSendInBandDTMF); 01781 #endif 01782 01783 #if PTRACING 01784 friend ostream & operator<<(ostream & o, Phases p); 01785 #endif 01786 01787 StringOptions m_stringOptions; 01788 01789 #if OPAL_HAS_MIXER 01790 PString m_recordingFilename; 01791 PNotifier m_recordAudioNotifier; 01792 #if OPAL_VIDEO 01793 PNotifier m_recordVideoNotifier; 01794 #endif 01795 #endif 01796 01797 #if OPAL_STATISTICS 01798 unsigned m_VideoUpdateRequestsSent; 01799 #endif 01800 01801 struct AutoStartInfo { 01802 unsigned preferredSessionId; // preferred session ID (only used for originating) 01803 OpalMediaType::AutoStartMode autoStart;// Mode for this session when the call is started 01804 }; 01805 01806 class AutoStartMap : public std::map<OpalMediaType, AutoStartInfo> 01807 { 01808 public: 01809 AutoStartMap(); 01810 void Initialise(const OpalConnection::StringOptions & stringOptions); 01811 OpalMediaType::AutoStartMode GetAutoStart(const OpalMediaType & mediaType) const; 01812 void SetAutoStart(const OpalMediaType & mediaType, OpalMediaType::AutoStartMode autoStart); 01813 01814 protected: 01815 bool m_initialised; 01816 PMutex m_mutex; 01817 01818 }; 01819 AutoStartMap m_autoStartInfo; 01820 01821 #if OPAL_FAX 01822 enum { 01823 e_NotSwitchingFaxMediaStreams, 01824 e_SwitchingToFaxMediaStreams, 01825 e_SwitchingFromFaxMediaStreams 01826 } m_faxMediaStreamsSwitchState; 01827 #endif 01828 01829 #if P_LUA 01830 protected: 01831 PLua m_lua; 01832 bool m_luaScriptLoaded; 01833 01834 public: 01835 PLUA_BINDING_START(OpalConnection) 01836 PLUA_BINDING2(LuaSetOption, "SetOption") 01837 PLUA_BINDING_END() 01838 PLUA_DECLARE_FUNCTION(LuaSetOption); 01839 #endif 01840 01841 // A version of PTime where default constructor creates invalid times 01842 class ZeroTime : public PTime 01843 { 01844 public: 01845 ZeroTime() : PTime(0) { } 01846 }; 01847 ZeroTime m_phaseTime[NumPhases]; 01848 01849 private: 01850 P_REMOVE_VIRTUAL(PBoolean, OnIncomingConnection(unsigned int), false); 01851 P_REMOVE_VIRTUAL(PBoolean, OnIncomingConnection(), false); 01852 P_REMOVE_VIRTUAL(PBoolean, IsConnectionOnHold(), false); 01853 P_REMOVE_VIRTUAL_VOID(OnMediaPatchStart(unsigned, bool)); 01854 P_REMOVE_VIRTUAL_VOID(OnMediaPatchStop(unsigned, bool)); 01855 P_REMOVE_VIRTUAL_VOID(AdjustMediaFormats(OpalMediaFormatList &) const); 01856 P_REMOVE_VIRTUAL_VOID(AdjustMediaFormats(OpalMediaFormatList &, OpalConnection *) const); 01857 P_REMOVE_VIRTUAL_VOID(AdjustMediaFormats(bool,OpalMediaFormatList &,OpalConnection *) const); 01858 P_REMOVE_VIRTUAL_VOID(PreviewPeerMediaFormats(const OpalMediaFormatList &)); 01859 P_REMOVE_VIRTUAL(bool, HoldConnection(), false); 01860 P_REMOVE_VIRTUAL(bool, RetrieveConnection(), false); 01861 P_REMOVE_VIRTUAL(bool, IsConnectionOnHold(bool), false); 01862 P_REMOVE_VIRTUAL_VOID(ApplyStringOptions(OpalConnection::StringOptions &)); 01863 }; 01864 01865 #endif // OPAL_OPAL_CONNECTION_H 01866 01867 01868 // End of File ///////////////////////////////////////////////////////////////