00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
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"
00074 #define OPAL_OPT_CALL_IDENTIFIER "Call-Identifier"
00075 #define OPAL_OPT_CALLING_PARTY_URL "Calling-Party-URL"
00076 #define OPAL_OPT_CALLING_PARTY_NUMBER "Calling-Party-Number"
00077 #define OPAL_OPT_CALLING_PARTY_NAME "Calling-Party-Name"
00078 #define OPAL_OPT_CALLING_PARTY_DOMAIN "Calling-Party-Domain"
00079 #define OPAL_OPT_CALLING_DISPLAY_NAME "Calling-Display-Name"
00080 #define OPAL_OPT_CALLED_PARTY_NAME "Called-Party-Name"
00081 #define OPAL_OPT_CALLED_DISPLAY_NAME "Called-Display-Name"
00082 #define OPAL_OPT_REDIRECTING_PARTY "Redirecting-Party"
00083 #define OPAL_OPT_PRESENTATION_BLOCK "Presentation-Block"
00084 #define OPAL_OPT_ORIGINATOR_ADDRESS "Originator-Address"
00085 #define OPAL_OPT_INTERFACE "Interface"
00086 #define OPAL_OPT_USER_INPUT_MODE "User-Input-Mode"
00087
00088 #define OPAL_OPT_ENABLE_INBAND_DTMF "EnableInbandDTMF"
00089 #define OPAL_OPT_ENABLE_INBAND_DTMF "EnableInbandDTMF"
00090 #define OPAL_OPT_DETECT_INBAND_DTMF "DetectInBandDTMF"
00091 #define OPAL_OPT_SEND_INBAND_DTMF "SendInBandDTMF"
00092 #define OPAL_OPT_DTMF_MULT "dtmfmult"
00093 #define OPAL_OPT_DTMF_DIV "dtmfdiv"
00094 #define OPAL_OPT_DISABLE_JITTER "Disable-Jitter"
00095 #define OPAL_OPT_MAX_JITTER "Max-Jitter"
00096 #define OPAL_OPT_MIN_JITTER "Min-Jitter"
00097 #define OPAL_OPT_RECORD_AUDIO "Record-Audio"
00098 #define OPAL_OPT_ALERTING_TYPE "Alerting-Type"
00099 #define OPAL_OPT_REMOVE_CODEC "Remove-Codec"
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;
00410 unsigned q931:8;
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,
00436 FastStartOptionEnable = 0x0002,
00437 FastStartOptionMask = 0x0003,
00438
00439 H245TunnelingOptionDisable = 0x0004,
00440 H245TunnelingOptionEnable = 0x0008,
00441 H245TunnelingOptionMask = 0x000c,
00442
00443 H245inSetupOptionDisable = 0x0010,
00444 H245inSetupOptionEnable = 0x0020,
00445 H245inSetupOptionMask = 0x0030,
00446
00447 DetectInBandDTMFOptionDisable = 0x0040,
00448 DetectInBandDTMFOptionEnable = 0x0080,
00449 DetectInBandDTMFOptionMask = 0x00c0,
00450
00451 RTPAggregationDisable = 0x0100,
00452 RTPAggregationEnable = 0x0200,
00453 RTPAggregationMask = 0x0300,
00454
00455 SendDTMFAsDefault = 0x0000,
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
00592 void ClearCall(
00593 CallEndReason reason = EndedByLocalUser,
00594 PSyncPoint * sync = NULL
00595 );
00596
00601 virtual void ClearCallSynchronous(
00602 PSyncPoint * sync,
00603 CallEndReason reason = EndedByLocalUser
00604 );
00605
00609 unsigned GetQ931Cause() const { return callEndReason.q931; }
00610
00614 void SetQ931Cause(unsigned v) { callEndReason.q931 = v; }
00615
00622 virtual bool TransferConnection(
00623 const PString & remoteParty
00624 );
00625
00633 virtual bool Hold(
00634 bool fromRemote,
00635 bool placeOnHold
00636 );
00637
00642 virtual bool IsOnHold(
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
00864 virtual bool OnTransferNotify(
00865 const PStringToString & info,
00866 const OpalConnection * transferringConnection
00868 );
00869
00878 virtual void Release(
00879 CallEndReason reason = EndedByLocalUser,
00880 bool synchronous = false
00881 );
00882
00900 virtual void OnReleased();
00902
00913 virtual PString GetDestinationAddress();
00914
00924 virtual PBoolean ForwardCall(
00925 const PString & forwardParty
00926 );
00927
00930 PSafePtr<OpalConnection> GetOtherPartyConnection() const;
00931
00934 template <class cls> PSafePtr<cls> GetOtherPartyConnectionAs() const { return PSafePtrCast<OpalConnection, cls>(GetOtherPartyConnection()); }
00936
00945 virtual OpalMediaFormatList GetMediaFormats() const;
00946
00951 virtual OpalMediaFormatList GetLocalMediaFormats();
00952
00966 virtual void AdjustMediaFormats(
00967 bool local,
00968 const OpalConnection * otherConnection,
00969 OpalMediaFormatList & mediaFormats
00970 ) const;
00971
00979 virtual unsigned GetNextSessionID(
00980 const OpalMediaType & mediaType,
00981 bool isSource
00982 );
00983
00990 virtual OpalMediaType::AutoStartMode GetAutoStart(
00991 const OpalMediaType & mediaType
00992 ) const;
00993
00996 virtual void AutoStartMediaStreams(
00997 bool force = false
00998 );
00999
01000 #if OPAL_FAX
01001
01003 virtual bool SwitchFaxMediaStreams(
01004 bool enableFax
01005 );
01006
01011 virtual void OnSwitchedFaxMediaStreams(
01012 bool enabledFax
01013 );
01014 #endif
01015
01018 virtual OpalMediaStreamPtr OpenMediaStream(
01019 const OpalMediaFormat & mediaFormat,
01020 unsigned sessionID,
01021 bool isSource
01022 );
01023
01026 virtual bool CloseMediaStream(
01027 unsigned sessionId,
01028 bool source
01029 );
01030
01033 virtual bool CloseMediaStream(
01034 OpalMediaStream & stream
01035 );
01036
01044 bool RemoveMediaStream(
01045 OpalMediaStream & strm
01046 );
01047
01050 virtual void StartMediaStreams();
01051
01054 virtual void CloseMediaStreams();
01055
01058 virtual void PauseMediaStreams(
01059 bool paused
01060 );
01061
01064 virtual void OnPauseMediaStream(
01065 OpalMediaStream & strm,
01066 bool paused
01067 );
01068
01081 virtual OpalMediaStream * CreateMediaStream(
01082 const OpalMediaFormat & mediaFormat,
01083 unsigned sessionID,
01084 PBoolean isSource
01085 );
01086
01093 OpalMediaStreamPtr GetMediaStream(
01094 const PString & streamID,
01095 bool source
01096 ) const;
01097
01103 OpalMediaStreamPtr GetMediaStream(
01104 unsigned sessionId,
01105 bool source
01106 ) const;
01107
01118 OpalMediaStreamPtr GetMediaStream(
01119 const OpalMediaType & mediaType,
01120 bool source,
01121 OpalMediaStreamPtr previous = NULL
01122 ) const;
01123
01135 virtual PBoolean OnOpenMediaStream(
01136 OpalMediaStream & stream
01137 );
01138
01143 virtual void OnClosedMediaStream(
01144 const OpalMediaStream & stream
01145 );
01146
01155 virtual void OnPatchMediaStream(
01156 PBoolean isSource,
01157 OpalMediaPatch & patch
01158 );
01159
01162 virtual void OnStartMediaPatch(
01163 OpalMediaPatch & patch
01164 );
01165
01168 virtual void OnStopMediaPatch(
01169 OpalMediaPatch & patch
01170 );
01171
01177 virtual bool OnMediaCommand(
01178 OpalMediaStream & stream,
01179 const OpalMediaCommand & command
01180 );
01181
01186 virtual void AttachRFC2833HandlerToPatch(PBoolean isSource, OpalMediaPatch & patch);
01187
01193 virtual PBoolean IsMediaBypassPossible(
01194 unsigned sessionID
01195 ) const;
01196
01197 #if OPAL_VIDEO
01198
01200 virtual PBoolean CreateVideoInputDevice(
01201 const OpalMediaFormat & mediaFormat,
01202 PVideoInputDevice * & device,
01203 PBoolean & autoDelete
01204 );
01205
01209 virtual PBoolean CreateVideoOutputDevice(
01210 const OpalMediaFormat & mediaFormat,
01211 PBoolean preview,
01212 PVideoOutputDevice * & device,
01213 PBoolean & autoDelete
01214 );
01215
01221 virtual bool SendVideoUpdatePicture(
01222 unsigned sessionID = 0,
01223 bool force = false
01224 ) const;
01225 #endif
01226
01229 virtual PBoolean SetAudioVolume(
01230 PBoolean source,
01231 unsigned percentage
01232 );
01233
01237 virtual unsigned GetAudioSignalLevel(
01238 PBoolean source
01239 );
01241
01246 unsigned GetBandwidthAvailable() const { return bandwidthAvailable; }
01247
01252 virtual PBoolean SetBandwidthAvailable(
01253 unsigned newBandwidth,
01254 PBoolean force = false
01255 );
01256
01261 virtual unsigned GetBandwidthUsed() const;
01262
01271 virtual PBoolean SetBandwidthUsed(
01272 unsigned releasedBandwidth,
01273 unsigned requiredBandwidth
01274 );
01276
01279 enum SendUserInputModes {
01280 SendUserInputAsQ931,
01281 SendUserInputAsString,
01282 SendUserInputAsTone,
01283 SendUserInputAsRFC2833,
01284 SendUserInputInBand,
01285 SendUserInputAsProtocolDefault,
01286 NumSendUserInputModes,
01287
01288 SendUserInputAsInlineRFC2833 = SendUserInputAsRFC2833
01289 };
01290 #if PTRACING
01291 friend ostream & operator<<(ostream & o, SendUserInputModes m);
01292 #endif
01293
01296 virtual void SetSendUserInputMode(SendUserInputModes mode);
01297
01300 virtual SendUserInputModes GetSendUserInputMode() const { return sendUserInputMode; }
01301
01307 virtual SendUserInputModes GetRealSendUserInputMode() const { return GetSendUserInputMode(); }
01308
01315 virtual PBoolean SendUserInputString(
01316 const PString & value
01317 );
01318
01335 virtual PBoolean SendUserInputTone(
01336 char tone,
01337 unsigned duration = 0
01338 );
01339
01346 virtual void OnUserInputString(
01347 const PString & value
01348 );
01349
01356 virtual void OnUserInputTone(
01357 char tone,
01358 unsigned duration
01359 );
01360
01364 void SendUserInputHookFlash(
01365 unsigned duration = 500
01366 ) { SendUserInputTone('!', duration); }
01367
01370 virtual PString GetUserInput(
01371 unsigned timeout = 30
01372 );
01373
01378 virtual void SetUserInput(
01379 const PString & input
01380 );
01381
01384 virtual PString ReadUserInput(
01385 const char * terminators = "#\r\n",
01386 unsigned lastDigitTimeout = 4,
01387 unsigned firstDigitTimeout = 30
01388 );
01389
01396 virtual PBoolean PromptUserInput(
01397 PBoolean play
01398 );
01400
01405 virtual bool GarbageCollection();
01407
01412 OpalEndPoint & GetEndPoint() const { return endpoint; }
01413
01416 OpalCall & GetCall() const { return ownerCall; }
01417
01420 const PString & GetToken() const { return callToken; }
01421
01424 PBoolean IsOriginating() const { return originating; }
01425
01428 const PTime & GetPhaseTime(Phases phase) const { return m_phaseTime[phase]; }
01429
01432 const PTime & GetSetupUpTime() const { return m_phaseTime[SetUpPhase]; }
01433
01436 const PTime & GetAlertingTime() const { return m_phaseTime[AlertingPhase]; }
01437
01442 const PTime & GetConnectionStartTime() const { return m_phaseTime[ConnectedPhase]; }
01443
01446 const PTime & GetConnectionEndTime() const { return m_phaseTime[ReleasingPhase]; }
01447
01450 const OpalProductInfo & GetProductInfo() const { return productInfo; }
01451
01454 void SetProductInfo(
01455 const OpalProductInfo & info
01456 ) { productInfo = info; }
01457
01460 virtual PString GetPrefixName() const;
01461
01464 const PString & GetLocalPartyName() const { return localPartyName; }
01465
01468 virtual void SetLocalPartyName(const PString & name);
01469
01472 virtual PString GetLocalPartyURL() const;
01473
01476 const PString & GetDisplayName() const { return displayName; }
01477
01480 void SetDisplayName(const PString & name) { displayName = name; }
01481
01487 virtual bool IsPresentationBlocked() const;
01488
01491 const PString & GetRemotePartyName() const { return remotePartyName; }
01492
01495 void SetRemotePartyName(const PString & name) { remotePartyName = name; }
01496
01505 const PString & GetRemotePartyNumber() const { return remotePartyNumber; }
01506
01512 const PString & GetRemotePartyAddress() const { return remotePartyAddress; }
01513
01516 void SetRemotePartyAddress(const PString & addr) { remotePartyAddress = addr; }
01517
01524 virtual PString GetRemotePartyURL() const;
01525
01529 const PString & GetRedirectingParty() const { return m_redirectingParty; }
01530
01534 void SetRedirectingParty(const PString & party) { m_redirectingParty = party; }
01535
01536
01537 const PString GetRemotePartyCallbackURL() const { return GetRemotePartyURL(); }
01538
01542 PCaselessString GetRemoteApplication() const { return remoteProductInfo.AsString(); }
01543
01546 const OpalProductInfo & GetRemoteProductInfo() const { return remoteProductInfo; }
01547
01548
01555 const PString & GetCalledPartyName() const { return m_calledPartyName; }
01556
01563 const PString & GetCalledPartyNumber() const { return m_calledPartyNumber; }
01564
01572 virtual PString GetCalledPartyURL();
01573
01574
01575
01576
01577
01578
01579 void CopyPartyNames(const OpalConnection & other);
01580
01581
01595 virtual PString GetAlertingType() const;
01596
01610 virtual bool SetAlertingType(const PString & info);
01611
01619 virtual PString GetCallInfo() const;
01620
01624 unsigned GetMinAudioJitterDelay() const { return minAudioJitterDelay; }
01625
01629 unsigned GetMaxAudioJitterDelay() const { return maxAudioJitterDelay; }
01630
01633 void SetAudioJitterDelay(
01634 unsigned minDelay,
01635 unsigned maxDelay
01636 );
01637
01640 OpalSilenceDetector * GetSilenceDetector() const { return silenceDetector; }
01641
01642 #if OPAL_AEC
01643
01645 OpalEchoCanceler * GetEchoCanceler() const { return echoCanceler; }
01646 #endif
01647
01651 virtual PString GetIdentifier() const;
01652
01661 virtual PINDEX GetMaxRtpPayloadSize() const;
01662
01663 virtual OpalTransport & GetTransport() const
01664 { return *(OpalTransport *)NULL; }
01665
01666 PDICTIONARY(MediaAddressesDict, POrdinalKey, OpalTransportAddress);
01667 MediaAddressesDict & GetMediaTransportAddresses()
01668 { return mediaTransportAddresses; }
01669
01670 #if OPAL_STATISTICS
01671
01673 unsigned GetVideoUpdateRequestsSent() const { return m_VideoUpdateRequestsSent; }
01674 #endif
01675
01676
01678 const StringOptions & GetStringOptions() const { return m_stringOptions; }
01679
01681 void SetStringOptions(
01682 const StringOptions & options,
01683 bool overwrite
01684 );
01685
01687 virtual void OnApplyStringOptions();
01688
01689 #if OPAL_HAS_MIXER
01690
01691 virtual void EnableRecording();
01692 virtual void DisableRecording();
01693
01694 #endif
01695
01696 #if 0 //OPAL_HAS_IM
01697
01700 virtual bool TransmitInternalIM(
01701 const OpalMediaFormat & format,
01702 RTP_IMFrame & body
01703 );
01704
01708 virtual void OnReceiveInternalIM(
01709 const OpalMediaFormat & format,
01710 RTP_IMFrame & body
01711 );
01712
01716 virtual bool TransmitExternalIM(
01717 const OpalMediaFormat & format,
01718 RTP_IMFrame & body
01719 );
01720
01724 virtual bool OnReceiveExternalIM(
01725 const OpalMediaFormat & format,
01726 RTP_IMFrame & body
01727 );
01728
01733 RFC4103Context & GetRFC4103Context(PINDEX i) { return m_rfc4103Context[i]; };
01734
01735 protected:
01736 RFC4103Context m_rfc4103Context[2];
01737
01738 #endif
01739
01740 protected:
01741 void OnConnectedInternal();
01742
01743 PDECLARE_NOTIFIER(PThread, OpalConnection, OnReleaseThreadMain);
01744
01745 #if OPAL_HAS_MIXER
01746 PDECLARE_NOTIFIER(RTP_DataFrame, OpalConnection, OnRecordAudio);
01747 #if OPAL_VIDEO
01748 PDECLARE_NOTIFIER(RTP_DataFrame, OpalConnection, OnRecordVideo);
01749 #endif
01750 void OnStartRecording(OpalMediaPatch * patch);
01751 void OnStopRecording(OpalMediaPatch * patch);
01752 #endif
01753
01754
01755 OpalCall & ownerCall;
01756 OpalEndPoint & endpoint;
01757
01758 private:
01759 PMutex m_phaseMutex;
01760 Phases m_phase;
01761
01762 protected:
01763 PString callToken;
01764 PBoolean originating;
01765 OpalProductInfo productInfo;
01766 PString localPartyName;
01767 PString displayName;
01768 PString remotePartyName;
01769 PString remotePartyURL;
01770 OpalProductInfo remoteProductInfo;
01771 PString remotePartyNumber;
01772 PString remotePartyAddress;
01773 PString m_redirectingParty;
01774 CallEndReason callEndReason;
01775 PString m_calledPartyNumber;
01776 PString m_calledPartyName;
01777
01778 SendUserInputModes sendUserInputMode;
01779 PString userInputString;
01780 PSyncPoint userInputAvailable;
01781
01782 OpalSilenceDetector * silenceDetector;
01783 #if OPAL_AEC
01784 OpalEchoCanceler * echoCanceler;
01785 #endif
01786 OpalMediaFormat m_filterMediaFormat;
01787
01788 OpalMediaFormatList m_localMediaFormats;
01789 MediaAddressesDict mediaTransportAddresses;
01790 PSafeList<OpalMediaStream> mediaStreams;
01791
01792 unsigned minAudioJitterDelay;
01793 unsigned maxAudioJitterDelay;
01794 unsigned bandwidthAvailable;
01795
01796
01797
01798 #if OPAL_PTLIB_DTMF
01799 PDTMFDecoder m_dtmfDecoder;
01800 bool m_detectInBandDTMF;
01801 unsigned m_dtmfScaleMultiplier;
01802 unsigned m_dtmfScaleDivisor;
01803 PNotifier m_dtmfDetectNotifier;
01804 PDECLARE_NOTIFIER(RTP_DataFrame, OpalConnection, OnDetectInBandDTMF);
01805
01806 bool m_sendInBandDTMF;
01807 OpalMediaFormat m_dtmfSendFormat;
01808 PBYTEArray m_inBandDTMF;
01809 PINDEX m_emittedInBandDTMF;
01810 PMutex m_inBandMutex;
01811 PNotifier m_dtmfSendNotifier;
01812 PDECLARE_NOTIFIER(RTP_DataFrame, OpalConnection, OnSendInBandDTMF);
01813 #endif
01814
01815 #if PTRACING
01816 friend ostream & operator<<(ostream & o, Phases p);
01817 #endif
01818
01819 StringOptions m_stringOptions;
01820
01821 #if OPAL_HAS_MIXER
01822 PString m_recordingFilename;
01823 PNotifier m_recordAudioNotifier;
01824 #if OPAL_VIDEO
01825 PNotifier m_recordVideoNotifier;
01826 #endif
01827 #endif
01828
01829 #if OPAL_STATISTICS
01830 unsigned m_VideoUpdateRequestsSent;
01831 #endif
01832
01833 struct AutoStartInfo {
01834 unsigned preferredSessionId;
01835 OpalMediaType::AutoStartMode autoStart;
01836 };
01837
01838 class AutoStartMap : public std::map<OpalMediaType, AutoStartInfo>
01839 {
01840 public:
01841 AutoStartMap();
01842 void Initialise(const OpalConnection::StringOptions & stringOptions);
01843 OpalMediaType::AutoStartMode GetAutoStart(const OpalMediaType & mediaType) const;
01844 void SetAutoStart(const OpalMediaType & mediaType, OpalMediaType::AutoStartMode autoStart);
01845
01846 protected:
01847 bool m_initialised;
01848 PMutex m_mutex;
01849
01850 };
01851 AutoStartMap m_autoStartInfo;
01852
01853 #if OPAL_FAX
01854 enum {
01855 e_NotSwitchingFaxMediaStreams,
01856 e_SwitchingToFaxMediaStreams,
01857 e_SwitchingFromFaxMediaStreams
01858 } m_faxMediaStreamsSwitchState;
01859 #endif
01860
01861 #if P_LUA
01862 protected:
01863 PLua m_lua;
01864 bool m_luaScriptLoaded;
01865
01866 public:
01867 PLUA_BINDING_START(OpalConnection)
01868 PLUA_BINDING2(LuaSetOption, "SetOption")
01869 PLUA_BINDING_END()
01870 PLUA_DECLARE_FUNCTION(LuaSetOption);
01871 #endif
01872
01873
01874 class ZeroTime : public PTime
01875 {
01876 public:
01877 ZeroTime() : PTime(0) { }
01878 };
01879 ZeroTime m_phaseTime[NumPhases];
01880
01881 private:
01882 P_REMOVE_VIRTUAL(PBoolean, OnIncomingConnection(unsigned int), false);
01883 P_REMOVE_VIRTUAL(PBoolean, OnIncomingConnection(), false);
01884 P_REMOVE_VIRTUAL(PBoolean, IsConnectionOnHold(), false);
01885 P_REMOVE_VIRTUAL_VOID(OnMediaPatchStart(unsigned, bool));
01886 P_REMOVE_VIRTUAL_VOID(OnMediaPatchStop(unsigned, bool));
01887 P_REMOVE_VIRTUAL_VOID(AdjustMediaFormats(OpalMediaFormatList &) const);
01888 P_REMOVE_VIRTUAL_VOID(AdjustMediaFormats(OpalMediaFormatList &, OpalConnection *) const);
01889 P_REMOVE_VIRTUAL_VOID(AdjustMediaFormats(bool,OpalMediaFormatList &,OpalConnection *) const);
01890 P_REMOVE_VIRTUAL_VOID(PreviewPeerMediaFormats(const OpalMediaFormatList &));
01891 P_REMOVE_VIRTUAL(bool, HoldConnection(), false);
01892 P_REMOVE_VIRTUAL(bool, RetrieveConnection(), false);
01893 P_REMOVE_VIRTUAL(bool, IsConnectionOnHold(bool), false);
01894 P_REMOVE_VIRTUAL_VOID(ApplyStringOptions(OpalConnection::StringOptions &));
01895 P_REMOVE_VIRTUAL(bool, OnTransferNotify(const PStringToString &), false);
01896 };
01897
01898 #endif // OPAL_OPAL_CONNECTION_H
01899
01900
01901