OPAL Version 3.10.4

- Main Page
- Related Pages
- Namespaces
- Data Structures
- Files

- File List
- Globals

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: 26939 $
31 * $Author: rjongbloed $
32 * $Date: 2012-02-07 01:17:49 -0600 (Tue, 07 Feb 2012) $
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/buildopts.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_HAS_IM
53 #include <im/t140.h>
54 #include <im/rfc4103.h>
55 #include <im/im.h>
56 #endif
57
58 #if P_LUA
59 #include <ptclib/lua.h>
60 #endif
61
62 class OpalEndPoint;
63 class OpalCall;
64 class OpalSilenceDetector;
65 class OpalEchoCanceler;
66 class OpalRFC2833Proto;
67 class OpalRFC2833Info;
68 class PURL;
69
70
71 #define OPAL_URL_PARAM_PREFIX "OPAL-"
72
73 #define OPAL_OPT_AUTO_START "AutoStart"
74 #define OPAL_OPT_CALL_IDENTIFIER "Call-Identifier"
75 #define OPAL_OPT_CALLING_PARTY_URL "Calling-Party-URL"
76 #define OPAL_OPT_CALLING_PARTY_NUMBER "Calling-Party-Number"
77 #define OPAL_OPT_CALLING_PARTY_NAME "Calling-Party-Name"
78 #define OPAL_OPT_CALLING_PARTY_DOMAIN "Calling-Party-Domain"
79 #define OPAL_OPT_CALLING_DISPLAY_NAME "Calling-Display-Name"
80 #define OPAL_OPT_CALLED_PARTY_NAME "Called-Party-Name"
81 #define OPAL_OPT_CALLED_DISPLAY_NAME "Called-Display-Name"
82 #define OPAL_OPT_REDIRECTING_PARTY "Redirecting-Party"
83 #define OPAL_OPT_PRESENTATION_BLOCK "Presentation-Block"
84 #define OPAL_OPT_ORIGINATOR_ADDRESS "Originator-Address"
85 #define OPAL_OPT_INTERFACE "Interface"
86 #define OPAL_OPT_USER_INPUT_MODE "User-Input-Mode"
87
88 #define OPAL_OPT_ENABLE_INBAND_DTMF "EnableInbandDTMF"
89 #define OPAL_OPT_ENABLE_INBAND_DTMF "EnableInbandDTMF"
90 #define OPAL_OPT_DETECT_INBAND_DTMF "DetectInBandDTMF"
91 #define OPAL_OPT_SEND_INBAND_DTMF "SendInBandDTMF"
92 #define OPAL_OPT_DTMF_MULT "dtmfmult"
93 #define OPAL_OPT_DTMF_DIV "dtmfdiv"
94 #define OPAL_OPT_DISABLE_JITTER "Disable-Jitter"
95 #define OPAL_OPT_MAX_JITTER "Max-Jitter"
96 #define OPAL_OPT_MIN_JITTER "Min-Jitter"
97 #define OPAL_OPT_RECORD_AUDIO "Record-Audio"
98 #define OPAL_OPT_ALERTING_TYPE "Alerting-Type"
99 #define OPAL_OPT_REMOVE_CODEC "Remove-Codec"
100
101
312 class OpalProductInfo
313 {
314 public:
315 OpalProductInfo();
316
317 static OpalProductInfo & Default();
318
319 friend ostream & operator<<(ostream & strm, const OpalProductInfo & info);
320 PCaselessString AsString() const;
321
322 PCaselessString vendor;
323 PCaselessString name;
324 PCaselessString version;
325 PCaselessString comments;
326
327 BYTE t35CountryCode;
328 BYTE t35Extension;
329 WORD manufacturerCode;
330
331 private:
332 OpalProductInfo(bool);
333 };
334
335
353 class OpalConnection : public PSafeObject
354 {
355 PCLASSINFO(OpalConnection, PSafeObject);
356 public:
361 enum CallEndReasonCodes {
362 EndedByLocalUser,
363 EndedByNoAccept,
364 EndedByAnswerDenied,
365 EndedByRemoteUser,
366 EndedByRefusal,
367 EndedByNoAnswer,
368 EndedByCallerAbort,
369 EndedByTransportFail,
370 EndedByConnectFail,
371 EndedByGatekeeper,
372 EndedByNoUser,
373 EndedByNoBandwidth,
374 EndedByCapabilityExchange,
375 EndedByCallForwarded,
376 EndedBySecurityDenial,
377 EndedByLocalBusy,
378 EndedByLocalCongestion,
379 EndedByRemoteBusy,
380 EndedByRemoteCongestion,
381 EndedByUnreachable,
382 EndedByNoEndPoint,
383 EndedByHostOffline,
384 EndedByTemporaryFailure,
385 EndedByQ931Cause,
386 EndedByDurationLimit,
387 EndedByInvalidConferenceID,
388 EndedByNoDialTone,
389 EndedByNoRingBackTone,
390 EndedByOutOfService,
391 EndedByAcceptingCallWaiting,
392 EndedByGkAdmissionFailed,
393 NumCallEndReasons
394 };
395
396 struct CallEndReason {
397 CallEndReason(
398 CallEndReasonCodes reason = NumCallEndReasons,
399 unsigned cause = 0
400 ) : code(reason), q931(cause) { }
401 explicit CallEndReason(
402 long reason
403 ) : code((CallEndReasonCodes)(reason&0xff)), q931((reason>>8)&0xff) { }
404
405 __inline operator CallEndReasonCodes() const { return code; }
406
407 __inline int AsInteger() const { return code|(q931<<8); }
408
409 CallEndReasonCodes code:8; // Normalised OPAL code
410 unsigned q931:8; // PSTN Interworking code, actually Q.850
411 };
412
413 #if PTRACING
414 friend ostream & operator<<(ostream & o, CallEndReason reason);
415 #endif
416
417 enum AnswerCallResponse {
418 AnswerCallNow,
419 AnswerCallDenied,
420 AnswerCallPending,
421 AnswerCallDeferred,
422 AnswerCallAlertWithMedia,
423 AnswerCallDeferredWithMedia,
424 AnswerCallProgress,
425 AnswerCallNowAndReleaseCurrent,
426 NumAnswerCallResponses
427 };
428 #if PTRACING
429 friend ostream & operator<<(ostream & o, AnswerCallResponse s);
430 #endif
431
434 enum Options {
435 FastStartOptionDisable = 0x0001, // H.323 specific
436 FastStartOptionEnable = 0x0002,
437 FastStartOptionMask = 0x0003,
438
439 H245TunnelingOptionDisable = 0x0004, // H.323 specific
440 H245TunnelingOptionEnable = 0x0008,
441 H245TunnelingOptionMask = 0x000c,
442
443 H245inSetupOptionDisable = 0x0010, // H.323 specific
444 H245inSetupOptionEnable = 0x0020,
445 H245inSetupOptionMask = 0x0030,
446
447 DetectInBandDTMFOptionDisable = 0x0040, // SIP and H.323
448 DetectInBandDTMFOptionEnable = 0x0080,
449 DetectInBandDTMFOptionMask = 0x00c0,
450
451 RTPAggregationDisable = 0x0100, // SIP and H.323
452 RTPAggregationEnable = 0x0200,
453 RTPAggregationMask = 0x0300,
454
455 SendDTMFAsDefault = 0x0000, // SIP and H.323
456 SendDTMFAsString = 0x0400,
457 SendDTMFAsTone = 0x0800,
458 SendDTMFAsRFC2833 = 0x0c00,
459 SendDTMFMask = 0x0c00
460 };
461
462 class StringOptions : public PStringOptions
463 {
464 public:
469 void ExtractFromURL(
470 PURL & url
471 );
472 };
473
478 OpalConnection(
479 OpalCall & call,
480 OpalEndPoint & endpoint,
481 const PString & token,
482 unsigned options = 0,
483 OpalConnection::StringOptions * stringOptions = NULL
484 );
485
488 ~OpalConnection();
490
497 void PrintOn(
498 ostream & strm
499 ) const;
501
518 virtual bool IsNetworkConnection() const = 0;
519
523 enum Phases {
524 UninitialisedPhase,
525 SetUpPhase,
526 ProceedingPhase,
527 AlertingPhase,
528 ConnectedPhase,
529 EstablishedPhase,
530 ForwardingPhase,
531 ReleasingPhase,
532 ReleasedPhase,
533 NumPhases
534 };
535
540 __inline Phases GetPhase() const { return m_phase; }
541
543 __inline bool IsEstablished() const { return m_phase == EstablishedPhase; }
544
546 __inline bool IsReleased() const { return m_phase >= ReleasingPhase; }
547
552 void SetPhase(
553 Phases phaseToSet
554 );
555
564 CallEndReason GetCallEndReason() const { return callEndReason; }
565
568 static PString GetCallEndReasonText(CallEndReason reason);
569 PString GetCallEndReasonText() const { return GetCallEndReasonText(callEndReason); }
570
573 static void SetCallEndReasonText(CallEndReasonCodes reasonCode, const PString & newText);
574
579 virtual void SetCallEndReason(
580 CallEndReason reason
581 );
582
590 void ClearCall(
591 CallEndReason reason = EndedByLocalUser
592 );
593
596 virtual void ClearCallSynchronous(
597 PSyncPoint * sync,
598 CallEndReason reason = EndedByLocalUser
599 );
600
604 unsigned GetQ931Cause() const { return callEndReason.q931; }
605
609 void SetQ931Cause(unsigned v) { callEndReason.q931 = v; }
610
617 virtual bool TransferConnection(
618 const PString & remoteParty
619 );
620
628 virtual bool Hold(
629 bool fromRemote,
630 bool placeOnHold
631 );
632
637 virtual bool IsOnHold(
638 bool fromRemote
639 );
640
645 virtual void OnHold(
646 bool fromRemote,
647 bool onHold
648 );
650
678 virtual PBoolean OnIncomingConnection(unsigned int options, OpalConnection::StringOptions * stringOptions);
679
686 virtual PBoolean SetUpConnection() = 0;
687
691 virtual PBoolean OnSetUpConnection();
692
693
708 virtual void OnProceeding();
709
720 virtual void OnAlerting();
721
732 virtual PBoolean SetAlerting(
733 const PString & calleeName,
734 PBoolean withMedia
735 ) = 0;
736
753 virtual AnswerCallResponse OnAnswerCall(
754 const PString & callerName
755 );
756
767 virtual void AnsweringCall(
768 AnswerCallResponse response
769 );
770
785 virtual void OnConnected();
786
797 virtual PBoolean SetConnected();
798
810 virtual void OnEstablished();
811
859 virtual bool OnTransferNotify(
860 const PStringToString & info,
861 const OpalConnection * transferringConnection
863 );
864
873 virtual void Release(
874 CallEndReason reason = EndedByLocalUser
875 );
876
894 virtual void OnReleased();
896
907 virtual PString GetDestinationAddress();
908
918 virtual PBoolean ForwardCall(
919 const PString & forwardParty
920 );
921
924 PSafePtr<OpalConnection> GetOtherPartyConnection() const;
925
928 template <class cls> PSafePtr<cls> GetOtherPartyConnectionAs() const { return PSafePtrCast<OpalConnection, cls>(GetOtherPartyConnection()); }
930
939 virtual OpalMediaFormatList GetMediaFormats() const;
940
945 virtual OpalMediaFormatList GetLocalMediaFormats();
946
960 virtual void AdjustMediaFormats(
961 bool local,
962 const OpalConnection * otherConnection,
963 OpalMediaFormatList & mediaFormats
964 ) const;
965
973 virtual unsigned GetNextSessionID(
974 const OpalMediaType & mediaType,
975 bool isSource
976 );
977
984 virtual OpalMediaType::AutoStartMode GetAutoStart(
985 const OpalMediaType & mediaType
986 ) const;
987
990 virtual void AutoStartMediaStreams(
991 bool force = false
992 );
993
994 #if OPAL_FAX
995
997 virtual bool SwitchFaxMediaStreams(
998 bool enableFax
999 );
1000
1005 virtual void OnSwitchedFaxMediaStreams(
1006 bool enabledFax
1007 );
1008 #endif
1009
1012 virtual OpalMediaStreamPtr OpenMediaStream(
1013 const OpalMediaFormat & mediaFormat,
1014 unsigned sessionID,
1015 bool isSource
1016 );
1017
1020 virtual bool CloseMediaStream(
1021 unsigned sessionId,
1022 bool source
1023 );
1024
1027 virtual bool CloseMediaStream(
1028 OpalMediaStream & stream
1029 );
1030
1038 bool RemoveMediaStream(
1039 OpalMediaStream & strm
1040 );
1041
1044 virtual void StartMediaStreams();
1045
1048 virtual void CloseMediaStreams();
1049
1052 virtual void PauseMediaStreams(
1053 bool paused
1054 );
1055
1058 virtual void OnPauseMediaStream(
1059 OpalMediaStream & strm,
1060 bool paused
1061 );
1062
1075 virtual OpalMediaStream * CreateMediaStream(
1076 const OpalMediaFormat & mediaFormat,
1077 unsigned sessionID,
1078 PBoolean isSource
1079 );
1080
1087 OpalMediaStreamPtr GetMediaStream(
1088 const PString & streamID,
1089 bool source
1090 ) const;
1091
1097 OpalMediaStreamPtr GetMediaStream(
1098 unsigned sessionId,
1099 bool source
1100 ) const;
1101
1112 OpalMediaStreamPtr GetMediaStream(
1113 const OpalMediaType & mediaType,
1114 bool source,
1115 OpalMediaStreamPtr previous = NULL
1116 ) const;
1117
1129 virtual PBoolean OnOpenMediaStream(
1130 OpalMediaStream & stream
1131 );
1132
1137 virtual void OnClosedMediaStream(
1138 const OpalMediaStream & stream
1139 );
1140
1149 virtual void OnPatchMediaStream(
1150 PBoolean isSource,
1151 OpalMediaPatch & patch
1152 );
1153
1156 virtual void OnStartMediaPatch(
1157 OpalMediaPatch & patch
1158 );
1159
1162 virtual void OnStopMediaPatch(
1163 OpalMediaPatch & patch
1164 );
1165
1171 virtual bool OnMediaCommand(
1172 OpalMediaStream & stream,
1173 const OpalMediaCommand & command
1174 );
1175
1180 virtual void AttachRFC2833HandlerToPatch(PBoolean isSource, OpalMediaPatch & patch);
1181
1187 virtual PBoolean IsMediaBypassPossible(
1188 unsigned sessionID
1189 ) const;
1190
1191 #if OPAL_VIDEO
1192
1194 virtual PBoolean CreateVideoInputDevice(
1195 const OpalMediaFormat & mediaFormat,
1196 PVideoInputDevice * & device,
1197 PBoolean & autoDelete
1198 );
1199
1203 virtual PBoolean CreateVideoOutputDevice(
1204 const OpalMediaFormat & mediaFormat,
1205 PBoolean preview,
1206 PVideoOutputDevice * & device,
1207 PBoolean & autoDelete
1208 );
1209
1215 virtual bool SendVideoUpdatePicture(
1216 unsigned sessionID = 0,
1217 bool force = false
1218 ) const;
1219 #endif
1220
1223 virtual PBoolean SetAudioVolume(
1224 PBoolean source,
1225 unsigned percentage
1226 );
1227
1231 virtual unsigned GetAudioSignalLevel(
1232 PBoolean source
1233 );
1235
1240 unsigned GetBandwidthAvailable() const { return bandwidthAvailable; }
1241
1246 virtual PBoolean SetBandwidthAvailable(
1247 unsigned newBandwidth,
1248 PBoolean force = false
1249 );
1250
1255 virtual unsigned GetBandwidthUsed() const;
1256
1265 virtual PBoolean SetBandwidthUsed(
1266 unsigned releasedBandwidth,
1267 unsigned requiredBandwidth
1268 );
1270
1273 enum SendUserInputModes {
1274 SendUserInputAsQ931,
1275 SendUserInputAsString,
1276 SendUserInputAsTone,
1277 SendUserInputAsRFC2833,
1278 SendUserInputInBand,
1279 SendUserInputAsProtocolDefault,
1280 NumSendUserInputModes,
1281
1282 SendUserInputAsInlineRFC2833 = SendUserInputAsRFC2833 // For backward compatibility
1283 };
1284 #if PTRACING
1285 friend ostream & operator<<(ostream & o, SendUserInputModes m);
1286 #endif
1287
1290 virtual void SetSendUserInputMode(SendUserInputModes mode);
1291
1294 virtual SendUserInputModes GetSendUserInputMode() const { return sendUserInputMode; }
1295
1301 virtual SendUserInputModes GetRealSendUserInputMode() const { return GetSendUserInputMode(); }
1302
1309 virtual PBoolean SendUserInputString(
1310 const PString & value
1311 );
1312
1329 virtual PBoolean SendUserInputTone(
1330 char tone,
1331 unsigned duration = 0
1332 );
1333
1340 virtual void OnUserInputString(
1341 const PString & value
1342 );
1343
1350 virtual void OnUserInputTone(
1351 char tone,
1352 unsigned duration
1353 );
1354
1358 void SendUserInputHookFlash(
1359 unsigned duration = 500
1360 ) { SendUserInputTone('!', duration); }
1361
1364 virtual PString GetUserInput(
1365 unsigned timeout = 30
1366 );
1367
1372 virtual void SetUserInput(
1373 const PString & input
1374 );
1375
1378 virtual PString ReadUserInput(
1379 const char * terminators = "#\r\n",
1380 unsigned lastDigitTimeout = 4,
1381 unsigned firstDigitTimeout = 30
1382 );
1383
1390 virtual PBoolean PromptUserInput(
1391 PBoolean play
1392 );
1394
1399 virtual bool GarbageCollection();
1401
1406 OpalEndPoint & GetEndPoint() const { return endpoint; }
1407
1410 OpalCall & GetCall() const { return ownerCall; }
1411
1414 const PString & GetToken() const { return callToken; }
1415
1418 PBoolean IsOriginating() const { return originating; }
1419
1422 const PTime & GetPhaseTime(Phases phase) const { return m_phaseTime[phase]; }
1423
1426 const PTime & GetSetupUpTime() const { return m_phaseTime[SetUpPhase]; }
1427
1430 const PTime & GetAlertingTime() const { return m_phaseTime[AlertingPhase]; }
1431
1436 const PTime & GetConnectionStartTime() const { return m_phaseTime[ConnectedPhase]; }
1437
1440 const PTime & GetConnectionEndTime() const { return m_phaseTime[ReleasingPhase]; }
1441
1444 const OpalProductInfo & GetProductInfo() const { return productInfo; }
1445
1448 void SetProductInfo(
1449 const OpalProductInfo & info
1450 ) { productInfo = info; }
1451
1454 virtual PString GetPrefixName() const;
1455
1458 const PString & GetLocalPartyName() const { return localPartyName; }
1459
1462 virtual void SetLocalPartyName(const PString & name);
1463
1466 virtual PString GetLocalPartyURL() const;
1467
1470 const PString & GetDisplayName() const { return displayName; }
1471
1474 void SetDisplayName(const PString & name) { displayName = name; }
1475
1481 virtual bool IsPresentationBlocked() const;
1482
1485 const PString & GetRemotePartyName() const { return remotePartyName; }
1486
1489 void SetRemotePartyName(const PString & name) { remotePartyName = name; }
1490
1499 const PString & GetRemotePartyNumber() const { return remotePartyNumber; }
1500
1506 const PString & GetRemotePartyAddress() const { return remotePartyAddress; }
1507
1510 void SetRemotePartyAddress(const PString & addr) { remotePartyAddress = addr; }
1511
1518 virtual PString GetRemotePartyURL() const;
1519
1523 const PString & GetRedirectingParty() const { return m_redirectingParty; }
1524
1528 void SetRedirectingParty(const PString & party) { m_redirectingParty = party; }
1529
1530 // Deprecated - backward compatibility only
1531 const PString GetRemotePartyCallbackURL() const { return GetRemotePartyURL(); }
1532
1536 PCaselessString GetRemoteApplication() const { return remoteProductInfo.AsString(); }
1537
1540 const OpalProductInfo & GetRemoteProductInfo() const { return remoteProductInfo; }
1541
1542
1549 const PString & GetCalledPartyName() const { return m_calledPartyName; }
1550
1557 const PString & GetCalledPartyNumber() const { return m_calledPartyNumber; }
1558
1566 virtual PString GetCalledPartyURL();
1567
1568 /* Internal function to copy party names from "network" connection to
1569 "non-network" connection such as OpalPCSSConnection. This allows
1570 the non-network GetRemoteAddress() function and its ilk to return
1571 the intuitive value, i.e. the value from the OTHER connection.
1572 */
1573 void CopyPartyNames(const OpalConnection & other);
1574
1575
1589 virtual PString GetAlertingType() const;
1590
1604 virtual bool SetAlertingType(const PString & info);
1605
1613 virtual PString GetCallInfo() const;
1614
1618 unsigned GetMinAudioJitterDelay() const { return minAudioJitterDelay; }
1619
1623 unsigned GetMaxAudioJitterDelay() const { return maxAudioJitterDelay; }
1624
1627 void SetAudioJitterDelay(
1628 unsigned minDelay,
1629 unsigned maxDelay
1630 );
1631
1634 OpalSilenceDetector * GetSilenceDetector() const { return silenceDetector; }
1635
1636 #if OPAL_AEC
1637
1639 OpalEchoCanceler * GetEchoCanceler() const { return echoCanceler; }
1640 #endif
1641
1645 virtual PString GetIdentifier() const;
1646
1655 virtual PINDEX GetMaxRtpPayloadSize() const;
1656
1657 virtual OpalTransport & GetTransport() const
1658 { return *(OpalTransport *)NULL; }
1659
1660 PDICTIONARY(MediaAddressesDict, POrdinalKey, OpalTransportAddress);
1661 MediaAddressesDict & GetMediaTransportAddresses()
1662 { return mediaTransportAddresses; }
1663
1664 #if OPAL_STATISTICS
1665
1667 unsigned GetVideoUpdateRequestsSent() const { return m_VideoUpdateRequestsSent; }
1668 #endif
1669
1670
1672 const StringOptions & GetStringOptions() const { return m_stringOptions; }
1673
1675 void SetStringOptions(
1676 const StringOptions & options,
1677 bool overwrite
1678 );
1679
1681 virtual void OnApplyStringOptions();
1682
1683 #if OPAL_HAS_MIXER
1684
1685 virtual void EnableRecording();
1686 virtual void DisableRecording();
1687
1688 #endif
1689
1690 #if 0 //OPAL_HAS_IM
1691
1694 virtual bool TransmitInternalIM(
1695 const OpalMediaFormat & format,
1696 RTP_IMFrame & body
1697 );
1698
1702 virtual void OnReceiveInternalIM(
1703 const OpalMediaFormat & format,
1704 RTP_IMFrame & body
1705 );
1706
1710 virtual bool TransmitExternalIM(
1711 const OpalMediaFormat & format,
1712 RTP_IMFrame & body
1713 );
1714
1718 virtual bool OnReceiveExternalIM(
1719 const OpalMediaFormat & format,
1720 RTP_IMFrame & body
1721 );
1722
1727 RFC4103Context & GetRFC4103Context(PINDEX i) { return m_rfc4103Context[i]; };
1728
1729 protected:
1730 RFC4103Context m_rfc4103Context[2];
1731
1732 #endif
1733
1734 protected:
1735 void OnConnectedInternal();
1736
1737 PDECLARE_NOTIFIER(PThread, OpalConnection, OnReleaseThreadMain);
1738
1739 #if OPAL_HAS_MIXER
1740 PDECLARE_NOTIFIER(RTP_DataFrame, OpalConnection, OnRecordAudio);
1741 #if OPAL_VIDEO
1742 PDECLARE_NOTIFIER(RTP_DataFrame, OpalConnection, OnRecordVideo);
1743 #endif
1744 void OnStartRecording(OpalMediaPatch * patch);
1745 void OnStopRecording(OpalMediaPatch * patch);
1746 #endif
1747
1748 // Member variables
1749 OpalCall & ownerCall;
1750 OpalEndPoint & endpoint;
1751
1752 private:
1753 PMutex m_phaseMutex;
1754 Phases m_phase;
1755
1756 protected:
1757 PString callToken;
1758 PBoolean originating;
1759 OpalProductInfo productInfo;
1760 PString localPartyName;
1761 PString displayName;
1762 PString remotePartyName;
1763 PString remotePartyURL;
1764 OpalProductInfo remoteProductInfo;
1765 PString remotePartyNumber;
1766 PString remotePartyAddress;
1767 PString m_redirectingParty;
1768 CallEndReason callEndReason;
1769 bool synchronousOnRelease;
1770 PString m_calledPartyNumber;
1771 PString m_calledPartyName;
1772
1773 SendUserInputModes sendUserInputMode;
1774 PString userInputString;
1775 PSyncPoint userInputAvailable;
1776
1777 OpalSilenceDetector * silenceDetector;
1778 #if OPAL_AEC
1779 OpalEchoCanceler * echoCanceler;
1780 #endif
1781 OpalMediaFormat m_filterMediaFormat;
1782
1783 OpalMediaFormatList m_localMediaFormats;
1784 MediaAddressesDict mediaTransportAddresses;
1785 PSafeList<OpalMediaStream> mediaStreams;
1786
1787 unsigned minAudioJitterDelay;
1788 unsigned maxAudioJitterDelay;
1789 unsigned bandwidthAvailable;
1790
1791 // The In-Band DTMF detector. This is used inside an audio filter which is
1792 // added to the audio channel.
1793 #if OPAL_PTLIB_DTMF
1794 PDTMFDecoder m_dtmfDecoder;
1795 bool m_detectInBandDTMF;
1796 unsigned m_dtmfScaleMultiplier;
1797 unsigned m_dtmfScaleDivisor;
1798 PNotifier m_dtmfDetectNotifier;
1799 PDECLARE_NOTIFIER(RTP_DataFrame, OpalConnection, OnDetectInBandDTMF);
1800
1801 bool m_sendInBandDTMF;
1802 OpalMediaFormat m_dtmfSendFormat;
1803 PBYTEArray m_inBandDTMF;
1804 PINDEX m_emittedInBandDTMF;
1805 PMutex m_inBandMutex;
1806 PNotifier m_dtmfSendNotifier;
1807 PDECLARE_NOTIFIER(RTP_DataFrame, OpalConnection, OnSendInBandDTMF);
1808 #endif
1809
1810 #if PTRACING
1811 friend ostream & operator<<(ostream & o, Phases p);
1812 #endif
1813
1814 StringOptions m_stringOptions;
1815
1816 #if OPAL_HAS_MIXER
1817 PString m_recordingFilename;
1818 PNotifier m_recordAudioNotifier;
1819 #if OPAL_VIDEO
1820 PNotifier m_recordVideoNotifier;
1821 #endif
1822 #endif
1823
1824 #if OPAL_STATISTICS
1825 unsigned m_VideoUpdateRequestsSent;
1826 #endif
1827
1828 struct AutoStartInfo {
1829 unsigned preferredSessionId; // preferred session ID (only used for originating)
1830 OpalMediaType::AutoStartMode autoStart;// Mode for this session when the call is started
1831 };
1832
1833 class AutoStartMap : public std::map<OpalMediaType, AutoStartInfo>
1834 {
1835 public:
1836 AutoStartMap();
1837 void Initialise(const OpalConnection::StringOptions & stringOptions);
1838 OpalMediaType::AutoStartMode GetAutoStart(const OpalMediaType & mediaType) const;
1839 void SetAutoStart(const OpalMediaType & mediaType, OpalMediaType::AutoStartMode autoStart);
1840
1841 protected:
1842 bool m_initialised;
1843 PMutex m_mutex;
1844
1845 };
1846 AutoStartMap m_autoStartInfo;
1847
1848 #if OPAL_FAX
1849 enum {
1850 e_NotSwitchingFaxMediaStreams,
1851 e_SwitchingToFaxMediaStreams,
1852 e_SwitchingFromFaxMediaStreams
1853 } m_faxMediaStreamsSwitchState;
1854 #endif
1855
1856 #if P_LUA
1857 protected:
1858 PLua m_lua;
1859 bool m_luaScriptLoaded;
1860
1861 public:
1862 PLUA_BINDING_START(OpalConnection)
1863 PLUA_BINDING2(LuaSetOption, "SetOption")
1864 PLUA_BINDING_END()
1865 PLUA_DECLARE_FUNCTION(LuaSetOption);
1866 #endif
1867
1868 // A version of PTime where default constructor creates invalid times
1869 class ZeroTime : public PTime
1870 {
1871 public:
1872 ZeroTime() : PTime(0) { }
1873 };
1874 ZeroTime m_phaseTime[NumPhases];
1875
1876 private:
1877 P_REMOVE_VIRTUAL(PBoolean, OnIncomingConnection(unsigned int), false);
1878 P_REMOVE_VIRTUAL(PBoolean, OnIncomingConnection(), false);
1879 P_REMOVE_VIRTUAL(PBoolean, IsConnectionOnHold(), false);
1880 P_REMOVE_VIRTUAL_VOID(OnMediaPatchStart(unsigned, bool));
1881 P_REMOVE_VIRTUAL_VOID(OnMediaPatchStop(unsigned, bool));
1882 P_REMOVE_VIRTUAL_VOID(AdjustMediaFormats(OpalMediaFormatList &) const);
1883 P_REMOVE_VIRTUAL_VOID(AdjustMediaFormats(OpalMediaFormatList &, OpalConnection *) const);
1884 P_REMOVE_VIRTUAL_VOID(AdjustMediaFormats(bool,OpalMediaFormatList &,OpalConnection *) const);
1885 P_REMOVE_VIRTUAL_VOID(PreviewPeerMediaFormats(const OpalMediaFormatList &));
1886 P_REMOVE_VIRTUAL(bool, HoldConnection(), false);
1887 P_REMOVE_VIRTUAL(bool, RetrieveConnection(), false);
1888 P_REMOVE_VIRTUAL(bool, IsConnectionOnHold(bool), false);
1889 P_REMOVE_VIRTUAL_VOID(ApplyStringOptions(OpalConnection::StringOptions &));
1890 P_REMOVE_VIRTUAL(bool, OnTransferNotify(const PStringToString &), false);
1891 };
1892
1893 #endif // OPAL_OPAL_CONNECTION_H
1894
1895
1896 // End of File ///////////////////////////////////////////////////////////////