OPAL  Version 3.14.3
connection.h
Go to the documentation of this file.
1 /*
2  * connection.h
3  *
4  * Telephony connection abstraction
5  *
6  * Open Phone Abstraction Library (OPAL)
7  * Formally known as the Open H323 project.
8  *
9  * Copyright (c) 2001 Equivalence Pty. Ltd.
10  *
11  * The contents of this file are subject to the Mozilla Public License
12  * Version 1.0 (the "License"); you may not use this file except in
13  * compliance with the License. You may obtain a copy of the License at
14  * http://www.mozilla.org/MPL/
15  *
16  * Software distributed under the License is distributed on an "AS IS"
17  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
18  * the License for the specific language governing rights and limitations
19  * under the License.
20  *
21  * The Original Code is Open Phone Abstraction Library.
22  *
23  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
24  *
25  * Contributor(s): Post Increment
26  * Portions of this code were written with the assistance of funding from
27  * US Joint Forces Command Joint Concept Development & Experimentation (J9)
28  * http://www.jfcom.mil/about/abt_j9.htm
29  *
30  * $Revision: 32841 $
31  * $Author: rjongbloed $
32  * $Date: 2014-09-29 08:46:31 +1000 (Mon, 29 Sep 2014) $
33  */
34 
35 #ifndef OPAL_OPAL_CONNECTION_H
36 #define OPAL_OPAL_CONNECTION_H
37 
38 #ifdef P_USE_PRAGMA
39 #pragma interface
40 #endif
41 
42 #include <opal_config.h>
43 
44 #include <opal/mediafmt.h>
45 #include <opal/mediastrm.h>
46 #include <opal/guid.h>
47 #include <opal/transports.h>
48 #include <ptclib/dtmf.h>
49 #include <ptlib/safecoll.h>
50 #include <rtp/rtp.h>
51 
52 #if OPAL_SCRIPT
53 // Inside #if so does not force loading of factories when statically linked.
54 #include <ptclib/script.h>
55 #endif
56 
57 
58 class OpalEndPoint;
59 class OpalCall;
62 class OpalEchoCanceler;
63 class OpalRFC2833Proto;
64 class OpalRFC2833Info;
65 class PURL;
66 
67 
68 #define OPAL_URL_PARAM_PREFIX "OPAL-"
69 #define OPAL_MAKE_URL_PARAM(opt) ";" OPAL_URL_PARAM_PREFIX opt
70 #define OPAL_MAKE_URL_PARAM2(opt, val) OPAL_MAKE_URL_PARAM(opt) "=" val
71 
72 #define OPAL_OPT_AUTO_START "AutoStart"
77 #define OPAL_OPT_CALL_IDENTIFIER "Call-Identifier"
78 #define OPAL_OPT_CALLING_PARTY_URL "Calling-Party-URL"
79 #define OPAL_OPT_CALLING_PARTY_NUMBER "Calling-Party-Number"
80 #define OPAL_OPT_CALLING_PARTY_NAME "Calling-Party-Name"
81 #define OPAL_OPT_CALLING_PARTY_DOMAIN "Calling-Party-Domain"
82 #define OPAL_OPT_CALLING_DISPLAY_NAME "Calling-Display-Name"
83 #define OPAL_OPT_CALLED_PARTY_NAME "Called-Party-Name"
84 #define OPAL_OPT_CALLED_DISPLAY_NAME "Called-Display-Name"
85 #define OPAL_OPT_REDIRECTING_PARTY "Redirecting-Party"
86 #define OPAL_OPT_PRESENTATION_BLOCK "Presentation-Block"
87 #define OPAL_OPT_ORIGINATOR_ADDRESS "Originator-Address"
88 #define OPAL_OPT_INTERFACE "Interface"
89 #define OPAL_OPT_USER_INPUT_MODE "User-Input-Mode"
90 
91 #define OPAL_OPT_ENABLE_INBAND_DTMF "EnableInbandDTMF"
92 #define OPAL_OPT_ENABLE_INBAND_DTMF "EnableInbandDTMF"
93 #define OPAL_OPT_DETECT_INBAND_DTMF "DetectInBandDTMF"
94 #define OPAL_OPT_SEND_INBAND_DTMF "SendInBandDTMF"
95 #define OPAL_OPT_DTMF_MULT "dtmfmult"
96 #define OPAL_OPT_DTMF_DIV "dtmfdiv"
97 #define OPAL_OPT_DISABLE_JITTER "Disable-Jitter"
98 #define OPAL_OPT_MAX_JITTER "Max-Jitter"
99 #define OPAL_OPT_MIN_JITTER "Min-Jitter"
100 #define OPAL_OPT_RECORD_AUDIO "Record-Audio"
101 #define OPAL_OPT_ALERTING_TYPE "Alerting-Type"
102 #define OPAL_OPT_REMOVE_CODEC "Remove-Codec"
108 #define OPAL_OPT_SILENCE_DETECT_MODE "Silence-Detect"
109 
110 
130 #define OPAL_OPT_VIDUP_METHODS "Video-Update-Picture-Method"
131 #define OPAL_OPT_VIDUP_METHOD_OOB 1
132 #define OPAL_OPT_VIDUP_METHOD_RTCP 2
133 #define OPAL_OPT_VIDUP_METHOD_PLI 4
134 #define OPAL_OPT_VIDUP_METHOD_FIR 8
135 #define OPAL_OPT_VIDUP_METHOD_DEFAULT 3
351 class OpalProductInfo
352 {
353  public:
354  OpalProductInfo();
356  static OpalProductInfo & Default();
357 
358  friend ostream & operator<<(ostream & strm, const OpalProductInfo & info);
359 
363  PCaselessString AsString() const;
364 
365  PCaselessString vendor;
366  PCaselessString name;
367  PCaselessString version;
368  PCaselessString comments;
373 
374  private:
376 };
377 
378 
396 class OpalConnection : public PSafeObject
397 {
398  PCLASSINFO(OpalConnection, PSafeObject);
399  public:
404  P_DECLARE_TRACED_ENUM_EX(CallEndReasonCodes,NumCallEndReasons,
405  EndedByLocalUser,0,
406  EndedByNoAccept,
407  EndedByAnswerDenied,
408  EndedByRemoteUser,
409  EndedByRefusal,
410  EndedByNoAnswer,
411  EndedByCallerAbort,
412  EndedByTransportFail,
413  EndedByConnectFail,
414  EndedByGatekeeper,
415  EndedByNoUser,
416  EndedByNoBandwidth,
417  EndedByCapabilityExchange,
418  EndedByCallForwarded,
419  EndedBySecurityDenial,
420  EndedByLocalBusy,
421  EndedByLocalCongestion,
422  EndedByRemoteBusy,
423  EndedByRemoteCongestion,
424  EndedByUnreachable,
425  EndedByNoEndPoint,
426  EndedByHostOffline,
427  EndedByTemporaryFailure,
428  EndedByQ931Cause,
429  EndedByDurationLimit,
430  EndedByInvalidConferenceID,
431  EndedByNoDialTone,
432  EndedByNoRingBackTone,
433  EndedByOutOfService,
434  EndedByAcceptingCallWaiting,
435  EndedByGkAdmissionFailed,
436  EndedByMediaFailed,
437  EndedByCallCompletedElsewhere,
438  EndedByCertificateAuthority,
439  EndedByIllegalAddress,
440  EndedByCustomCode
441  );
442 
443  struct CallEndReason {
445  CallEndReasonCodes reason = NumCallEndReasons,
446  unsigned cause = 0
447  ) : code(reason), q931(cause) { }
448  explicit CallEndReason(
449  long reason
450  ) : code((CallEndReasonCodes)(reason&0xff)), q931((reason>>8)&0xff) { }
451 
452  __inline operator CallEndReasonCodes() const { return code; }
453 
454  __inline int AsInteger() const { return code|(q931<<8); }
455 
456  CallEndReasonCodes code:8; // Normalised OPAL code
457  union
458  {
459  unsigned q931:16; // PSTN Interworking code, actually Q.850
460  unsigned custom:16; // Custom code
461  };
462  };
464 #if PTRACING
465  friend ostream & operator<<(ostream & o, CallEndReason reason);
466 #endif
467 
468  P_DECLARE_TRACED_ENUM(AnswerCallResponse,
469  AnswerCallNow,
470  AnswerCallDenied,
471  AnswerCallPending,
472  AnswerCallDeferred,
473  AnswerCallAlertWithMedia,
474  AnswerCallDeferredWithMedia,
475  AnswerCallProgress,
476  AnswerCallNowAndReleaseCurrent
477  );
478 
481  enum Options {
482  FastStartOptionDisable = 0x0001, // H.323 specific
483  FastStartOptionEnable = 0x0002,
484  FastStartOptionMask = 0x0003,
486  H245TunnelingOptionDisable = 0x0004, // H.323 specific
489 
490  H245inSetupOptionDisable = 0x0010, // H.323 specific
493 
494  DetectInBandDTMFOptionDisable = 0x0040, // SIP and H.323
497 
498  RTPAggregationDisable = 0x0100, // SIP and H.323
501 
502  SendDTMFAsDefault = 0x0000, // SIP and H.323
504  SendDTMFAsTone = 0x0800,
505  SendDTMFAsRFC2833 = 0x0c00,
506  SendDTMFMask = 0x0c00
507  };
509  class StringOptions : public PStringOptions
510  {
511  public:
512  StringOptions() { }
513  StringOptions(const PString & str) : PStringOptions(str) { }
514 
519  void ExtractFromURL(
520  PURL & url
521  );
522 
528  void ExtractFromString(
529  PString & str
530  );
531  };
532 
538  OpalCall & call,
540  const PString & token,
541  unsigned options = 0,
542  OpalConnection::StringOptions * stringOptions = NULL
543  );
544 
547  ~OpalConnection();
549 
556  void PrintOn(
557  ostream & strm
558  ) const;
560 
577  virtual bool IsNetworkConnection() const = 0;
578 
582  P_DECLARE_TRACED_ENUM(Phases,
583  UninitialisedPhase,
584  SetUpPhase,
585  ProceedingPhase,
586  AlertingPhase,
587  ConnectedPhase,
588  EstablishedPhase,
589  ForwardingPhase,
590  ReleasingPhase,
591  ReleasedPhase
592  );
593 
598  __inline Phases GetPhase() const { return m_phase; }
599 
601  __inline bool IsEstablished() const { return m_phase == EstablishedPhase; }
604  __inline bool IsReleased() const { return m_phase >= ReleasingPhase; }
610  void SetPhase(
611  Phases phaseToSet
612  );
613 
622  CallEndReason GetCallEndReason() const { return callEndReason; }
623 
626  static PString GetCallEndReasonText(CallEndReason reason);
627  PString GetCallEndReasonText() const { return GetCallEndReasonText(callEndReason); }
628 
631  static void SetCallEndReasonText(CallEndReasonCodes reasonCode, const PString & newText);
632 
637  virtual void SetCallEndReason(
638  CallEndReason reason
639  );
640 
650  void ClearCall(
651  CallEndReason reason = EndedByLocalUser,
652  PSyncPoint * sync = NULL
653  );
654 
659  virtual void ClearCallSynchronous(
660  PSyncPoint * sync,
661  CallEndReason reason = EndedByLocalUser
662  );
663 
667  unsigned GetQ931Cause() const { return callEndReason.q931; }
668 
672  void SetQ931Cause(unsigned v) { callEndReason.q931 = v; }
673 
680  virtual bool TransferConnection(
681  const PString & remoteParty
682  );
683 
698  virtual bool HoldRemote(
699  bool placeOnHold
700  );
701 
706  virtual bool IsOnHold(
707  bool fromRemote
708  ) const;
709 
714  virtual void OnHold(
715  bool fromRemote,
716  bool onHold
717  );
719 
747  virtual PBoolean OnIncomingConnection(unsigned int options, OpalConnection::StringOptions * stringOptions);
748 
756  virtual PBoolean SetUpConnection();
757 
761  virtual PBoolean OnSetUpConnection();
762 
763 
778  virtual void OnProceeding();
779 
790  virtual void OnAlerting();
791 
802  virtual PBoolean SetAlerting(
803  const PString & calleeName,
804  PBoolean withMedia
805  );
806 
823  virtual AnswerCallResponse OnAnswerCall(
824  const PString & callerName
825  );
826 
837  virtual void AnsweringCall(
838  AnswerCallResponse response
839  );
840 
855  virtual void OnConnected();
856 
867  virtual PBoolean SetConnected();
868 
880  virtual void OnEstablished();
881 
929  virtual bool OnTransferNotify(
930  const PStringToString & info,
931  const OpalConnection * transferringConnection
933  );
934 
943  virtual void Release(
944  CallEndReason reason = EndedByLocalUser,
945  bool synchronous = false
946  );
947 
965  virtual void OnReleased();
967 
978  virtual PString GetDestinationAddress();
979 
989  virtual PBoolean ForwardCall(
990  const PString & forwardParty
991  );
992 
995  PSafePtr<OpalConnection> GetOtherPartyConnection() const;
996 
999  template <class cls> PSafePtr<cls> GetOtherPartyConnectionAs() const { return PSafePtrCast<OpalConnection, cls>(GetOtherPartyConnection()); }
1001 
1010  virtual OpalMediaFormatList GetMediaFormats() const;
1011 
1017 
1031  virtual void AdjustMediaFormats(
1032  bool local,
1033  const OpalConnection * otherConnection,
1034  OpalMediaFormatList & mediaFormats
1035  ) const;
1036 
1041  virtual PStringArray GetMediaCryptoSuites() const;
1042 
1050  virtual unsigned GetNextSessionID(
1051  const OpalMediaType & mediaType,
1052  bool isSource
1053  );
1054 
1058  virtual bool RequireSymmetricMediaStreams() const;
1059 
1066  virtual OpalMediaType::AutoStartMode GetAutoStart(
1067  const OpalMediaType & mediaType
1068  ) const;
1069 
1072  virtual void AutoStartMediaStreams(
1073  bool transfer = false
1074  );
1075 
1076 #if OPAL_T38_CAPABILITY
1077 
1079  virtual bool SwitchFaxMediaStreams(
1080  bool toT38
1081  );
1082 
1087  virtual void OnSwitchedFaxMediaStreams(
1088  bool toT38,
1089  bool success
1090  );
1091 
1096  virtual bool OnSwitchingFaxMediaStreams(
1097  bool toT38
1098  );
1099 #endif // OPAL_T38_CAPABILITY
1100 
1104  const OpalMediaFormat & mediaFormat,
1105  unsigned sessionID,
1106  bool isSource
1107  );
1108 
1111  bool CloseMediaStream(
1112  unsigned sessionId,
1113  bool source
1114  );
1115 
1118  bool CloseMediaStream(
1119  OpalMediaStreamPtr stream
1120  );
1121 
1129  bool RemoveMediaStream(
1130  OpalMediaStream & strm
1131  );
1132 
1135  virtual void StartMediaStreams();
1136 
1139  virtual void CloseMediaStreams();
1140 
1143  virtual void PauseMediaStreams(
1144  bool paused
1145  );
1146 
1149  virtual void OnPauseMediaStream(
1150  OpalMediaStream & strm,
1151  bool paused
1152  );
1153 
1167  const OpalMediaFormat & mediaFormat,
1168  unsigned sessionID,
1169  PBoolean isSource
1170  );
1171 
1179  const PString & streamID,
1180  bool source
1181  ) const;
1182 
1189  unsigned sessionId,
1190  bool source
1191  ) const;
1192 
1204  const OpalMediaType & mediaType,
1205  bool source,
1206  OpalMediaStreamPtr previous = NULL
1207  ) const;
1208 
1220  virtual PBoolean OnOpenMediaStream(
1221  OpalMediaStream & stream
1222  );
1223 
1228  virtual void OnClosedMediaStream(
1229  const OpalMediaStream & stream
1230  );
1231 
1236  virtual void OnFailedMediaStream(
1237  bool fromRemote,
1238  const PString & reason
1239  );
1240 
1249  virtual void OnPatchMediaStream(
1250  PBoolean isSource,
1251  OpalMediaPatch & patch
1252  );
1253 
1258  virtual void OnStartMediaPatch(
1259  OpalMediaPatch & patch
1260  );
1261 
1266  virtual void OnStopMediaPatch(
1267  OpalMediaPatch & patch
1268  );
1269 
1285  virtual bool OnMediaFailed(
1286  unsigned sessionId,
1287  bool source
1288  );
1289 
1292  bool AllMediaFailed() const;
1293 
1299  virtual bool OnMediaCommand(
1300  OpalMediaStream & stream,
1301  const OpalMediaCommand & command
1302  );
1303 
1309  virtual bool ExecuteMediaCommand(
1310  const OpalMediaCommand & command,
1311  unsigned sessionID = 0,
1312  const OpalMediaType & mediaType = OpalMediaType()
1313  ) const;
1314 
1324  virtual bool GetMediaTransportAddresses(
1325  OpalConnection & otherConnection,
1326  const OpalMediaType & mediaType,
1327  OpalTransportAddressArray & transports
1328  ) const;
1329 
1330 #if OPAL_VIDEO
1331 
1336  virtual bool SendVideoUpdatePicture(
1337  unsigned sessionID = 0,
1338  bool force = false
1339  ) const;
1340  void SendVideoUpdatePictureCallback(unsigned sessionID, bool force) { SendVideoUpdatePicture(sessionID, force); }
1341 
1346  virtual void OnRxIntraFrameRequest(
1347  const OpalMediaSession & session,
1348  bool force
1349  );
1350 #endif // OPAL_VIDEO
1351 
1355  virtual PBoolean SetAudioVolume(
1356  PBoolean source,
1357  unsigned percentage
1358  );
1359 
1363  virtual PBoolean GetAudioVolume(
1364  PBoolean source,
1365  unsigned & percentage
1366  );
1367 
1370  virtual bool SetAudioMute(
1371  bool source,
1372  bool mute
1373  );
1374 
1377  virtual bool GetAudioMute(
1378  bool source,
1379  bool & mute
1380  );
1381 
1385  virtual unsigned GetAudioSignalLevel(
1386  PBoolean source
1387  );
1389 
1396  ) const;
1397 
1400  virtual bool SetBandwidthAvailable(
1402  OpalBandwidth availableBandwidth
1403  );
1404 
1408  virtual bool SetBandwidthAllocated(
1410  OpalBandwidth newBandwidth
1411  );
1412 
1419  ) const;
1420 
1429  virtual bool SetBandwidthUsed(
1431  OpalBandwidth releasedBandwidth,
1432  OpalBandwidth requiredBandwidth
1433  );
1435 
1438  P_DECLARE_TRACED_ENUM(SendUserInputModes,
1439  SendUserInputAsQ931,
1440  SendUserInputAsString,
1441  SendUserInputAsTone,
1442  SendUserInputAsRFC2833,
1443  SendUserInputAsInlineRFC2833 = SendUserInputAsRFC2833, // For backward compatibility
1444  SendUserInputInBand,
1445  SendUserInputAsProtocolDefault
1446  );
1447 
1450  virtual void SetSendUserInputMode(SendUserInputModes mode);
1451 
1454  virtual SendUserInputModes GetSendUserInputMode() const { return sendUserInputMode; }
1455 
1461  virtual SendUserInputModes GetRealSendUserInputMode() const { return GetSendUserInputMode(); }
1462 
1469  virtual PBoolean SendUserInputString(
1470  const PString & value
1471  );
1472 
1486  virtual PBoolean SendUserInputTone(
1487  char tone,
1488  unsigned duration = 0
1489  );
1490 
1497  virtual void OnUserInputString(
1498  const PString & value
1499  );
1500  void OnUserInputStringCallback(PString value) { OnUserInputString(value); }
1501 
1516  virtual void OnUserInputTone(
1517  char tone,
1518  unsigned duration
1519  );
1520 
1525  unsigned duration = 500
1526  ) { SendUserInputTone('!', duration); }
1527 
1530  virtual PString GetUserInput(
1531  unsigned timeout = 30
1532  );
1533 
1538  virtual void SetUserInput(
1539  const PString & input
1540  );
1541 
1544  virtual PString ReadUserInput(
1545  const char * terminators = "YX#\r\n",
1546  unsigned lastDigitTimeout = 4,
1547  unsigned firstDigitTimeout = 30
1548  );
1549 
1556  virtual PBoolean PromptUserInput(
1557  PBoolean play
1558  );
1560 
1574  virtual bool GetConferenceState(
1575  OpalConferenceState * state
1576  ) const;
1577 
1590  virtual bool RequestPresentationRole(
1591  bool release
1592  );
1593 
1601  virtual bool OnChangedPresentationRole(
1602  const PString & newChairURI,
1603  bool request
1604  );
1605 
1610  virtual bool HasPresentationRole() const;
1611 
1616  virtual bool GarbageCollection();
1618 
1623  OpalEndPoint & GetEndPoint() const { return endpoint; }
1624 
1627  OpalCall & GetCall() const { return ownerCall; }
1628 
1631  const PString & GetToken() const { return callToken; }
1632 
1635  PBoolean IsOriginating() const { return m_originating; }
1636 
1639  const PTime & GetPhaseTime(Phases phase) const { return m_phaseTime[phase]; }
1640 
1643  const PTime & GetSetupUpTime() const { return m_phaseTime[SetUpPhase]; }
1644 
1647  const PTime & GetAlertingTime() const { return m_phaseTime[AlertingPhase]; }
1648 
1653  const PTime & GetConnectionStartTime() const { return m_phaseTime[ConnectedPhase]; }
1654 
1657  const PTime & GetConnectionEndTime() const { return m_phaseTime[ReleasingPhase]; }
1658 
1661  const OpalProductInfo & GetProductInfo() const { return productInfo; }
1662 
1666  const OpalProductInfo & info
1667  ) { productInfo = info; }
1668 
1671  virtual PString GetPrefixName() const;
1672 
1675  const PString & GetLocalPartyName() const { return localPartyName; }
1676 
1679  virtual void SetLocalPartyName(const PString & name);
1680 
1683  virtual PString GetLocalPartyURL() const;
1684 
1687  const PString & GetDisplayName() const { return displayName; }
1688 
1691  void SetDisplayName(const PString & name) { displayName = name; }
1692 
1698  virtual bool IsPresentationBlocked() const;
1699 
1702  const PString & GetRemotePartyName() const { return remotePartyName; }
1703 
1706  void SetRemotePartyName(const PString & name) { remotePartyName = name; }
1707 
1716  const PString & GetRemotePartyNumber() const { return remotePartyNumber; }
1717 
1721 
1728  virtual PString GetRemotePartyURL() const;
1729 
1735  virtual PString GetRemoteIdentity() const { return GetRemotePartyURL(); }
1736 
1737  // Deprecated - backward compatibility only
1738  P_DEPRECATED PString GetRemotePartyAddress() const { return GetRemotePartyURL(); }
1740  // Deprecated - backward compatibility only
1741  P_DEPRECATED const PString GetRemotePartyCallbackURL() const { return GetRemotePartyURL(); }
1746  PCaselessString GetRemoteApplication() const { return remoteProductInfo.AsString(); }
1747 
1751 
1755  const PString & GetRedirectingParty() const { return m_redirectingParty; }
1756 
1760  void SetRedirectingParty(const PString & party) { m_redirectingParty = party; }
1761 
1768  const PString & GetCalledPartyName() const { return m_calledPartyName; }
1769 
1776  const PString & GetCalledPartyNumber() const { return m_calledPartyNumber; }
1777 
1785  virtual PString GetCalledPartyURL();
1786 
1787  /* Internal function to copy party names from "network" connection to
1788  "non-network" connection such as OpalPCSSConnection. This allows
1789  the non-network GetRemoteAddress() function and its ilk to return
1790  the intuitive value, i.e. the value from the OTHER connection.
1791  */
1792  void CopyPartyNames(const OpalConnection & other);
1793 
1794 
1808  virtual PString GetAlertingType() const;
1809 
1823  virtual bool SetAlertingType(const PString & info);
1824 
1832  virtual PString GetCallInfo() const;
1833 
1837  unsigned GetMinAudioJitterDelay() const { return m_minAudioJitterDelay; }
1838 
1842  unsigned GetMaxAudioJitterDelay() const { return m_maxAudioJitterDelay; }
1843 
1847  unsigned minDelay,
1848  unsigned maxDelay
1849  );
1850 
1854 
1855 #if OPAL_AEC
1856 
1858  OpalEchoCanceler * GetEchoCanceler() const { return echoCanceler; }
1859 #endif
1860 
1864  virtual PString GetIdentifier() const;
1865 
1874  virtual PINDEX GetMaxRtpPayloadSize() const;
1875 
1876 #if OPAL_STATISTICS
1877 
1879  unsigned GetVideoUpdateRequestsSent() const { return m_VideoUpdateRequestsSent; }
1880 
1884 #endif
1885 
1886 
1888  const StringOptions & GetStringOptions() const { return m_stringOptions; }
1889  StringOptions & GetStringOptions() { return m_stringOptions; }
1890 
1893  const StringOptions & options,
1894  bool overwrite
1895  );
1896 
1898  virtual void OnApplyStringOptions();
1899 
1900 #if OPAL_HAS_MIXER
1901 
1902  virtual void EnableRecording();
1903  virtual void DisableRecording();
1904 
1905 #endif
1906 
1907  protected:
1908  void OnConnectedInternal();
1909  void InternalSetAsOriginating();
1910 
1911  bool InternalRelease(CallEndReason reason);
1912  void InternalOnReleased();
1913 
1914 #if OPAL_HAS_MIXER
1916 #if OPAL_VIDEO
1918 #endif
1919  void OnStartRecording(OpalMediaPatch * patch);
1920  void OnStopRecording(OpalMediaPatch * patch);
1921 #endif
1922 
1923  // Member variables
1924  OpalCall & ownerCall;
1926 
1927  private:
1928  PMutex m_phaseMutex;
1929  Phases m_phase;
1930 
1931  protected:
1932  PString callToken;
1933  PBoolean m_originating;
1935  PString localPartyName;
1936  PString displayName;
1946  SendUserInputModes sendUserInputMode;
1949 
1951 #if OPAL_AEC
1952  OpalEchoCanceler * echoCanceler;
1953 #endif
1955 
1957  PSafeList<OpalMediaStream> mediaStreams;
1959  unsigned m_minAudioJitterDelay;
1964  // The In-Band DTMF detector. This is used inside an audio filter which is
1965  // added to the audio channel.
1966 #if OPAL_PTLIB_DTMF
1967  PDTMFDecoder m_dtmfDecoder;
1968  bool m_detectInBandDTMF;
1969  unsigned m_dtmfScaleMultiplier;
1970  unsigned m_dtmfScaleDivisor;
1971  PNotifier m_dtmfDetectNotifier;
1972  PDECLARE_NOTIFIER(RTP_DataFrame, OpalConnection, OnDetectInBandDTMF);
1973 
1974  bool m_sendInBandDTMF;
1975  OpalMediaFormat m_dtmfSendFormat;
1976  PBYTEArray m_inBandDTMF;
1977  PINDEX m_emittedInBandDTMF;
1978  PMutex m_inBandMutex;
1979  PNotifier m_dtmfSendNotifier;
1980  PDECLARE_NOTIFIER(RTP_DataFrame, OpalConnection, OnSendInBandDTMF);
1981 #endif
1982 
1984 
1985 #if OPAL_HAS_MIXER
1986  PString m_recordingFilename;
1988 #if OPAL_VIDEO
1989  PNotifier m_recordVideoNotifier;
1990 #endif
1991 #endif
1992 
1993 #if OPAL_STATISTICS
1994  unsigned m_VideoUpdateRequestsSent;
1996 #endif
1997 
2000 #if OPAL_SCRIPT
2001  PString m_scriptTableName;
2002  PDECLARE_ScriptFunctionNotifier(OpalConnection, ScriptRelease);
2003  PDECLARE_ScriptFunctionNotifier(OpalConnection, ScriptSetOption);
2004  PDECLARE_ScriptFunctionNotifier(OpalConnection, ScriptGetLocalPartyURL);
2005  PDECLARE_ScriptFunctionNotifier(OpalConnection, ScriptGetRemotePartyURL);
2006  PDECLARE_ScriptFunctionNotifier(OpalConnection, ScriptGetCalledPartyURL);
2007  PDECLARE_ScriptFunctionNotifier(OpalConnection, ScriptGetRedirectingParty);
2008 #endif // OPAL_SCRIPT
2009 
2010  // A version of PTime where default constructor creates invalid times
2011  class ZeroTime : public PTime
2012  {
2013  public:
2014  ZeroTime() : PTime(0) { }
2015  };
2016  ZeroTime m_phaseTime[NumPhases];
2017 
2018  std::set<unsigned> m_mediaSessionFailed;
2019 
2021  private:
2022  P_REMOVE_VIRTUAL(PBoolean, OnIncomingConnection(unsigned int), false);
2023  P_REMOVE_VIRTUAL(PBoolean, OnIncomingConnection(), false);
2024  P_REMOVE_VIRTUAL(PBoolean, IsConnectionOnHold(), false);
2025  P_REMOVE_VIRTUAL_VOID(OnMediaPatchStart(unsigned, bool));
2026  P_REMOVE_VIRTUAL_VOID(OnMediaPatchStop(unsigned, bool));
2027  P_REMOVE_VIRTUAL_VOID(AdjustMediaFormats(OpalMediaFormatList &) const);
2028  P_REMOVE_VIRTUAL_VOID(AdjustMediaFormats(OpalMediaFormatList &, OpalConnection *) const);
2029  P_REMOVE_VIRTUAL_VOID(AdjustMediaFormats(bool,OpalMediaFormatList &,OpalConnection *) const);
2030  P_REMOVE_VIRTUAL_VOID(PreviewPeerMediaFormats(const OpalMediaFormatList &));
2031  P_REMOVE_VIRTUAL(bool, HoldConnection(), false);
2032  P_REMOVE_VIRTUAL(bool, RetrieveConnection(), false);
2033  P_REMOVE_VIRTUAL(bool, IsConnectionOnHold(bool), false);
2034  P_REMOVE_VIRTUAL_VOID(ApplyStringOptions(OpalConnection::StringOptions &));
2035  P_REMOVE_VIRTUAL(PBoolean, IsMediaBypassPossible(unsigned) const, false);
2036  P_REMOVE_VIRTUAL(bool, OnTransferNotify(const PStringToString &), false);
2037  P_REMOVE_VIRTUAL(OpalMediaSession *, CreateMediaSession(unsigned, const OpalMediaType &), NULL);
2038  P_REMOVE_VIRTUAL(PBoolean, SetBandwidthAvailable(unsigned, PBoolean), false);
2039  P_REMOVE_VIRTUAL(unsigned, GetBandwidthUsed() const, 0);
2040  P_REMOVE_VIRTUAL(PBoolean, SetBandwidthUsed(unsigned, unsigned), false);
2041  P_REMOVE_VIRTUAL_VOID(OnSwitchedFaxMediaStreams(bool));
2042  P_REMOVE_VIRTUAL(bool, CloseMediaStream(OpalMediaStream &),false);
2043  P_REMOVE_VIRTUAL(bool,GetMediaTransportAddresses(const OpalMediaType&,OpalTransportAddressArray&) const,false);
2044 #if OPAL_PTLIB_NAT
2045  P_REMOVE_VIRTUAL(PNatMethod *, GetNatMethod(const PIPSocket::Address &) const,NULL);
2046 #endif
2047  P_REMOVE_VIRTUAL(bool,Hold(bool,bool),false);
2048 };
2049 
2050 #endif // OPAL_OPAL_CONNECTION_H
2051 
2052 
2053 // End of File ///////////////////////////////////////////////////////////////