Add hooks for recording call audio
[opal.git] / include / opal / connection.h
bloba56e9c2bb13f7ac7793bd6530d98a3029b201d94
1 /*
2 * connection.h
4 * Telephony connection abstraction
6 * Open Phone Abstraction Library (OPAL)
7 * Formally known as the Open H323 project.
9 * Copyright (c) 2001 Equivalence Pty. Ltd.
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/
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.
21 * The Original Code is Open Phone Abstraction Library.
23 * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
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
30 * $Log$
31 * Revision 2.79 2007/04/18 00:00:44 csoutheren
32 * Add hooks for recording call audio
34 * Revision 2.78 2007/04/03 05:27:29 rjongbloed
35 * Cleaned up somewhat confusing usage of the OnAnswerCall() virtual
36 * function. The name is innaccurate and exists as a legacy from the
37 * OpenH323 days. it now only indicates how alerting is done
38 * (with/without media) and does not actually answer the call.
40 * Revision 2.77 2007/03/13 00:32:16 csoutheren
41 * Simple but messy changes to allow compile time removal of protocol
42 * options such as H.450 and H.460
43 * Fix MakeConnection overrides
45 * Revision 2.76 2007/03/01 05:51:03 rjongbloed
46 * Fixed backward compatibility of OnIncomingConnection() virtual
47 * functions on various classes. If an old override returned FALSE
48 * then it will now abort the call as it used to.
50 * Revision 2.75 2007/03/01 05:05:20 csoutheren
51 * Fixed problem with override of OnIncomingConnection
53 * Revision 2.74 2007/03/01 03:52:31 csoutheren
54 * Use local jitter buffer values rather than getting direct from OpalManager
55 * Allow OpalConnection string options to be set during incoming calls
57 * Revision 2.73 2007/02/23 01:01:35 csoutheren
58 * Added abilty to set Q.931 codes through normal OpalConnection::CallEndReason
60 * Revision 2.72 2007/02/19 04:42:27 csoutheren
61 * Added OnIncomingMediaChannels so incoming calls can optionally be handled in two stages
63 * Revision 2.71 2007/02/12 02:44:27 csoutheren
64 * Start of support for ZRTP
67 * Revision 2.70 2007/01/24 04:00:56 csoutheren
68 * Arrrghh. Changing OnIncomingConnection turned out to have a lot of side-effects
69 * Added some pure viritual functions to prevent old code from breaking silently
70 * New OpalEndpoint and OpalConnection descendants will need to re-implement
71 * OnIncomingConnection. Sorry :)
73 * Revision 2.69 2007/01/18 04:45:16 csoutheren
74 * Messy, but simple change to add additional options argument to OpalConnection constructor
75 * This allows the provision of non-trivial arguments for connections
77 * Revision 2.68 2006/12/18 03:18:41 csoutheren
78 * Messy but simple fixes
79 * - Add access to SIP REGISTER timeout
80 * - Ensure OpalConnection options are correctly progagated
82 * Revision 2.67 2006/12/08 04:22:06 csoutheren
83 * Applied 1589261 - new release cause for fxo endpoints
84 * Thanks to Frederic Heem
86 * Revision 2.66 2006/11/20 03:37:12 csoutheren
87 * Allow optional inclusion of RTP aggregation
89 * Revision 2.65 2006/11/11 12:23:18 hfriederich
90 * Code reorganisation to improve RFC2833 handling for both SIP and H.323. Thanks Simon Zwahlen for the idea
92 * Revision 2.64 2006/10/28 16:40:28 dsandras
93 * Fixed SIP reinvite without breaking H.323 calls.
95 * Revision 2.63 2006/10/10 07:18:18 csoutheren
96 * Allow compilation with and without various options
98 * Revision 2.62 2006/09/28 07:42:17 csoutheren
99 * Merge of useful SRTP implementation
101 * Revision 2.61 2006/08/29 08:47:43 rjongbloed
102 * Added functions to get average audio signal level from audio streams in
103 * suitable connection types.
105 * Revision 2.60 2006/08/28 00:07:43 csoutheren
106 * Applied 1545125 - SetPhase mutex protection and transition control
107 * Thanks to Drazen Dimoti
109 * Revision 2.59 2006/08/17 23:09:03 rjongbloed
110 * Added volume controls
112 * Revision 2.58 2006/08/10 05:10:30 csoutheren
113 * Various H.323 stability patches merged in from DeimosPrePLuginBranch
115 * Revision 2.57 2006/08/03 04:57:12 csoutheren
116 * Port additional NAT handling logic from OpenH323 and extend into OpalConnection class
118 * Revision 2.56.2.1 2006/08/09 12:49:21 csoutheren
119 * Improve stablity under heavy H.323 load
121 * Revision 2.56 2006/06/27 13:07:37 csoutheren
122 * Patch 1374533 - add h323 Progress handling
123 * Thanks to Frederich Heem
125 * Revision 2.55 2006/06/09 04:22:24 csoutheren
126 * Implemented mapping between SIP release codes and Q.931 codes as specified
127 * by RFC 3398
129 * Revision 2.54 2006/05/30 04:58:06 csoutheren
130 * Added suport for SIP INFO message (untested as yet)
131 * Fixed some issues with SIP state machine on answering calls
132 * Fixed some formatting issues
134 * Revision 2.53 2006/04/20 16:52:22 hfriederich
135 * Adding support for H.224/H.281
137 * Revision 2.52 2006/03/20 10:37:47 csoutheren
138 * Applied patch #1453753 - added locking on media stream manipulation
139 * Thanks to Dinis Rosario
141 * Revision 2.51 2006/02/22 10:40:09 csoutheren
142 * Added patch #1374583 from Frederic Heem
143 * Added additional H.323 virtual function
145 * Revision 2.50 2006/02/02 07:02:56 csoutheren
146 * Added RTP payload map to transcoders and connections to allow remote SIP endpoints
147 * to change the payload type used for outgoing RTP.
149 * Revision 2.49 2006/01/09 12:19:06 csoutheren
150 * Added member variables to capture incoming destination addresses
152 * Revision 2.48 2005/12/06 21:32:24 dsandras
153 * Applied patch from Frederic Heem <frederic.heem _Atttt_ telsey.it> to fix
154 * assert in PSyncPoint when OnReleased is called twice from different threads.
155 * Thanks! (Patch #1374240)
157 * Revision 2.47 2005/11/30 13:35:26 csoutheren
158 * Changed tags for Doxygen
160 * Revision 2.46 2005/11/24 20:31:54 dsandras
161 * Added support for echo cancelation using Speex.
162 * Added possibility to add a filter to an OpalMediaPatch for all patches of a connection.
164 * Revision 2.45 2005/10/04 12:57:18 rjongbloed
165 * Removed CanOpenSourceMediaStream/CanOpenSinkMediaStream functions and
166 * now use overides on OpenSourceMediaStream/OpenSinkMediaStream
168 * Revision 2.44 2005/09/15 17:02:40 dsandras
169 * Added the possibility for a connection to prevent the opening of a sink/source media stream.
171 * Revision 2.43 2005/08/24 10:43:51 rjongbloed
172 * Changed create video functions yet again so can return pointers that are not to be deleted.
174 * Revision 2.42 2005/08/23 12:45:09 rjongbloed
175 * Fixed creation of video preview window and setting video grab/display initial frame size.
177 * Revision 2.41 2005/08/04 17:21:01 dsandras
178 * Added functions to close/remove the media streams of a connection.
180 * Revision 2.40 2005/07/14 08:51:17 csoutheren
181 * Removed CreateExternalRTPAddress - it's not needed because you can override GetMediaAddress
182 * to do the same thing
183 * Fixed problems with logic associated with media bypass
185 * Revision 2.39 2005/07/11 06:52:15 csoutheren
186 * Added support for outgoing calls using external RTP
188 * Revision 2.38 2005/07/11 01:52:23 csoutheren
189 * Extended AnsweringCall to work for SIP as well as H.323
190 * Fixed problems with external RTP connection in H.323
191 * Added call to OnClosedMediaStream
193 * Revision 2.37 2005/04/11 11:12:00 dsandras
194 * Fixed previous commit.
196 * Revision 2.36 2005/04/11 10:42:35 dsandras
197 * Fixed previous commit.
199 * Revision 2.35 2005/04/10 20:43:39 dsandras
200 * Added support for function allowing to put the OpalMediaStreams on pause.
202 * Revision 2.34 2005/04/10 20:42:33 dsandras
203 * Added support for a function that returns the "best guess" callback URL.
205 * Revision 2.33 2005/04/10 20:41:29 dsandras
206 * Added support for call hold.
208 * Revision 2.32 2005/04/10 20:40:20 dsandras
209 * Added support for Blind Transfert.
211 * Revision 2.31 2005/01/16 11:28:05 csoutheren
212 * Added GetIdentifier virtual function to OpalConnection, and changed H323
213 * and SIP descendants to use this function. This allows an application to
214 * obtain a GUID for any connection regardless of the protocol used
216 * Revision 2.30 2004/12/12 12:29:02 dsandras
217 * Moved GetRemoteApplication () to OpalConnection so that it is usable for all types of connection.
219 * Revision 2.29 2004/08/14 07:56:29 rjongbloed
220 * Major revision to utilise the PSafeCollection classes for the connections and calls.
222 * Revision 2.28 2004/05/17 13:24:18 rjongbloed
223 * Added silence suppression.
225 * Revision 2.27 2004/05/01 10:00:51 rjongbloed
226 * Fixed ClearCallSynchronous so now is actually signalled when call is destroyed.
228 * Revision 2.26 2004/04/26 04:33:05 rjongbloed
229 * Move various call progress times from H.323 specific to general conenction.
231 * Revision 2.25 2004/04/18 13:31:28 rjongbloed
232 * Added new end call value from OpenH323.
234 * Revision 2.24 2004/03/13 06:25:50 rjongbloed
235 * Slight rearrangement of local party name and alias list to beter match common
236 * behaviour in ancestor.
237 * Abstracted local party name for endpoint into ancestor from H.,323.
239 * Revision 2.23 2004/03/11 06:54:27 csoutheren
240 * Added ability to disable SIP or H.323 stacks
242 * Revision 2.22 2004/02/24 11:28:45 rjongbloed
243 * Normalised RTP session management across protocols
245 * Revision 2.21 2003/03/17 10:26:59 robertj
246 * Added video support.
248 * Revision 2.20 2003/03/06 03:57:47 robertj
249 * IVR support (work in progress) requiring large changes everywhere.
251 * Revision 2.19 2003/01/07 04:39:53 robertj
252 * Updated to OpenH323 v1.11.2
254 * Revision 2.18 2002/11/10 11:33:17 robertj
255 * Updated to OpenH323 v1.10.3
257 * Revision 2.17 2002/09/16 02:52:35 robertj
258 * Added #define so can select if #pragma interface/implementation is used on
259 * platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
261 * Revision 2.16 2002/09/12 06:54:06 robertj
262 * Added missing virtual to Release() function so can be overridden.
264 * Revision 2.15 2002/07/01 04:56:30 robertj
265 * Updated to OpenH323 v1.9.1
267 * Revision 2.14 2002/04/10 03:08:42 robertj
268 * Moved code for handling media bypass address resolution into ancestor as
269 * now done ths same way in both SIP and H.323.
271 * Revision 2.13 2002/04/09 00:16:46 robertj
272 * Changed "callAnswered" to better description of "originating".
274 * Revision 2.12 2002/02/19 07:42:07 robertj
275 * Added OpalRFC2833 as a OpalMediaFormat variable.
276 * Restructured media bypass functions to fix problems with RFC2833.
278 * Revision 2.11 2002/02/11 09:32:12 robertj
279 * Updated to openH323 v1.8.0
281 * Revision 2.10 2002/02/11 07:38:35 robertj
282 * Added media bypass for streams between compatible protocols.
284 * Revision 2.9 2002/01/22 05:04:21 robertj
285 * Revamp of user input API triggered by RFC2833 support
287 * Revision 2.8 2001/11/14 01:31:55 robertj
288 * Corrected placement of adjusting media format list.
290 * Revision 2.7 2001/11/02 10:45:19 robertj
291 * Updated to OpenH323 v1.7.3
293 * Revision 2.6 2001/10/15 04:29:14 robertj
294 * Added delayed start of media patch threads.
295 * Removed answerCall signal and replaced with state based functions.
297 * Revision 2.5 2001/10/03 05:56:15 robertj
298 * Changes abndwidth management API.
300 * Revision 2.4 2001/08/22 10:20:09 robertj
301 * Changed connection locking to use double mutex to guarantee that
302 * no threads can ever deadlock or access deleted connection.
304 * Revision 2.3 2001/08/17 08:22:23 robertj
305 * Moved call end reasons enum from OpalConnection to global.
307 * Revision 2.2 2001/08/13 05:10:39 robertj
308 * Updates from OpenH323 v1.6.0 release.
310 * Revision 2.1 2001/08/01 05:26:35 robertj
311 * Moved media formats list from endpoint to connection.
313 * Revision 2.0 2001/07/27 15:48:24 robertj
314 * Conversion of OpenH323 to Open Phone Abstraction Library (OPAL)
318 #ifndef __OPAL_CONNECTION_H
319 #define __OPAL_CONNECTION_H
321 #ifdef P_USE_PRAGMA
322 #pragma interface
323 #endif
325 #include <opal/buildopts.h>
327 #include <opal/mediafmt.h>
328 #include <opal/mediastrm.h>
329 #include <opal/guid.h>
330 #include <opal/transports.h>
331 #include <ptclib/dtmf.h>
332 #include <ptlib/safecoll.h>
333 #include <rtp/rtp.h>
335 class OpalEndPoint;
336 class OpalCall;
337 class OpalSilenceDetector;
338 class OpalEchoCanceler;
339 class OpalRFC2833Proto;
340 class OpalRFC2833Info;
341 class OpalT120Protocol;
342 class OpalT38Protocol;
343 class OpalH224Handler;
344 class OpalH281Handler;
346 /**This is the base class for connections to an endpoint.
347 A particular protocol will have a descendant class from this to implement
348 the specific semantics of that protocols connection.
350 A connection is part of a call, and will be "owned" by an OpalCall object.
351 It is also attached to the creator endpoint to do any protocol specific
352 management of the connection. However the deletion of the connection is
353 done by a special thread in the OpalManager class. A connnection should
354 never be deleted directly.
356 The connection is also in charge of creating media streams. It may do this
357 in respose to an explicit call to OpenMediaStream or implicitly due to
358 requests in the underlying protocol.
360 When media streams are created they must make requests for bandwidth which
361 is managed by the connection.
363 class OpalConnection : public PSafeObject
365 PCLASSINFO(OpalConnection, PSafeObject);
366 public:
367 /**Call/Connection ending reasons.
368 NOTE: if anything is added to this, you also need to add the field to
369 the tables in connection.cxx and h323pdu.cxx.
371 enum CallEndReason {
372 EndedByLocalUser, /// Local endpoint application cleared call
373 EndedByNoAccept, /// Local endpoint did not accept call OnIncomingCall()=FALSE
374 EndedByAnswerDenied, /// Local endpoint declined to answer call
375 EndedByRemoteUser, /// Remote endpoint application cleared call
376 EndedByRefusal, /// Remote endpoint refused call
377 EndedByNoAnswer, /// Remote endpoint did not answer in required time
378 EndedByCallerAbort, /// Remote endpoint stopped calling
379 EndedByTransportFail, /// Transport error cleared call
380 EndedByConnectFail, /// Transport connection failed to establish call
381 EndedByGatekeeper, /// Gatekeeper has cleared call
382 EndedByNoUser, /// Call failed as could not find user (in GK)
383 EndedByNoBandwidth, /// Call failed as could not get enough bandwidth
384 EndedByCapabilityExchange,/// Could not find common capabilities
385 EndedByCallForwarded, /// Call was forwarded using FACILITY message
386 EndedBySecurityDenial, /// Call failed a security check and was ended
387 EndedByLocalBusy, /// Local endpoint busy
388 EndedByLocalCongestion, /// Local endpoint congested
389 EndedByRemoteBusy, /// Remote endpoint busy
390 EndedByRemoteCongestion, /// Remote endpoint congested
391 EndedByUnreachable, /// Could not reach the remote party
392 EndedByNoEndPoint, /// The remote party is not running an endpoint
393 EndedByHostOffline, /// The remote party host off line
394 EndedByTemporaryFailure, /// The remote failed temporarily app may retry
395 EndedByQ931Cause, /// The remote ended the call with unmapped Q.931 cause code
396 EndedByDurationLimit, /// Call cleared due to an enforced duration limit
397 EndedByInvalidConferenceID, /// Call cleared due to invalid conference ID
398 EndedByNoDialTone, /// Call cleared due to missing dial tone
399 EndedByNoRingBackTone, /// Call cleared due to missing ringback tone
400 EndedByOutOfService, /// Call cleared because the line is out of service,
401 EndedByAcceptingCallWaiting, /// Call cleared because another call is answered
402 NumCallEndReasons,
404 EndedWithQ931Code = 0x100 /// Q931 code specified in MS byte
407 #if PTRACING
408 friend ostream & operator<<(ostream & o, CallEndReason reason);
409 #endif
411 enum AnswerCallResponse {
412 AnswerCallNow, /// Answer the call continuing with the connection.
413 AnswerCallDenied, /// Refuse the call sending a release complete.
414 AnswerCallPending, /// Send an Alerting PDU and wait for AnsweringCall()
415 AnswerCallDeferred, /// As for AnswerCallPending but does not send Alerting PDU
416 AnswerCallAlertWithMedia, /// As for AnswerCallPending but starts media channels
417 AnswerCallDeferredWithMedia, /// As for AnswerCallDeferred but starts media channels
418 AnswerCallProgress, /// Answer the call with a h323 progress, or sip 183 session in progress, or ...
419 AnswerCallNowAndReleaseCurrent, /// Answer the call and destroy the current call
420 NumAnswerCallResponses
422 #if PTRACING
423 friend ostream & operator<<(ostream & o, AnswerCallResponse s);
424 #endif
426 /** Connection options
428 enum Options {
429 FastStartOptionDisable = 0x0001, // H.323 specific
430 FastStartOptionEnable = 0x0002,
431 FastStartOptionMask = 0x0003,
433 H245TunnelingOptionDisable = 0x0004, // H.323 specific
434 H245TunnelingOptionEnable = 0x0008,
435 H245TunnelingOptionMask = 0x000c,
437 H245inSetupOptionDisable = 0x0010, // H.323 specific
438 H245inSetupOptionEnable = 0x0020,
439 H245inSetupOptionMask = 0x0030,
441 DetectInBandDTMFOptionDisable = 0x0040, // SIP and H.323
442 DetectInBandDTMFOptionEnable = 0x0080,
443 DetectInBandDTMFOptionMask = 0x00c0,
445 RTPAggregationDisable = 0x0100, // SIP and H.323
446 RTPAggregationEnable = 0x0200,
447 RTPAggregationMask = 0x0300,
449 SendDTMFAsDefault = 0x0000, // SIP and H.323
450 SendDTMFAsString = 0x0400,
451 SendDTMFAsTone = 0x0800,
452 SendDTMFAsRFC2833 = 0x0c00,
453 SendDTMFMask = 0x0c00
456 class StringOptions : public PStringToString
460 /**@name Construction */
461 //@{
462 /**Create a new connection.
464 OpalConnection(
465 OpalCall & call, ///< Owner calll for connection
466 OpalEndPoint & endpoint, ///< Owner endpoint for connection
467 const PString & token, ///< Token to identify the connection
468 unsigned options = 0, ///< Connection options
469 OpalConnection::StringOptions * stringOptions = NULL ///< more complex options
472 /**Destroy connection.
474 ~OpalConnection();
475 //@}
477 /**@name Overrides from PObject */
478 //@{
479 /**Standard stream print function.
480 The PObject class has a << operator defined that calls this function
481 polymorphically.
483 void PrintOn(
484 ostream & strm ///< Stream to output text representation
485 ) const;
486 //@}
488 /**@name Basic operations */
489 //@{
490 enum Phases {
491 UninitialisedPhase,
492 SetUpPhase,
493 AlertingPhase,
494 ConnectedPhase,
495 EstablishedPhase,
496 ReleasingPhase, // Note these must be the last two phases.
497 ReleasedPhase,
498 NumPhases
501 /**Get the phase of the connection.
502 This indicates the current phase of the connection sequence. Whether
503 all phases and the transitions between phases is protocol dependent.
505 inline Phases GetPhase() const { return phase; }
507 /**Get the call clearand reason for this connection shutting down.
508 Note that this function is only generally useful in the
509 H323EndPoint::OnConnectionCleared() function. This is due to the
510 connection not being cleared before that, and the object not even
511 exiting after that.
513 If the call is still active then this will return NumCallEndReasons.
515 CallEndReason GetCallEndReason() const { return callEndReason; }
517 /**Set the call clearance reason.
518 An application should have no cause to use this function. It is present
519 for the H323EndPoint::ClearCall() function to set the clearance reason.
521 virtual void SetCallEndReason(
522 CallEndReason reason ///< Reason for clearance of connection.
525 /**Clear a current call.
526 This hangs up the current call. This will release all connections
527 currently in the call by calling the OpalCall::Clear() function.
529 Note that this function will return quickly as the release and
530 disposal of the connections is done by another thread.
532 void ClearCall(
533 CallEndReason reason = EndedByLocalUser ///< Reason for call clearing
536 /**Clear a current connection, synchronously
538 virtual void ClearCallSynchronous(
539 PSyncPoint * sync,
540 CallEndReason reason = EndedByLocalUser ///< Reason for call clearing
543 /**Get the Q.931 cause code (Q.850) that terminated this call.
544 See Q931::CauseValues for common values.
546 unsigned GetQ931Cause() const { return q931Cause; }
548 /**Set the outgoing Q.931 cause code (Q.850) that is sent for this call
549 See Q931::CauseValues for common values.
551 void SetQ931Cause(unsigned v) { q931Cause = v; }
553 /**Initiate the transfer of an existing call (connection) to a new remote
554 party.
556 virtual void TransferConnection(
557 const PString & remoteParty, ///< Remote party to transfer the existing call to
558 const PString & callIdentity = PString::Empty()
559 ///< Call Identity of secondary call if present
562 /**Put the current connection on hold, suspending all media streams.
564 virtual void HoldConnection();
566 /**Retrieve the current connection from hold, activating all media
567 * streams.
569 virtual void RetrieveConnection();
571 /**Return TRUE if the current connection is on hold.
573 virtual BOOL IsConnectionOnHold();
574 //@}
576 /**@name Call progress functions */
577 //@{
578 /**Call back for an incoming call.
579 This function is used for an application to control the answering of
580 incoming calls.
582 If TRUE is returned then the connection continues. If FALSE then the
583 connection is aborted.
585 Note this function should not block for any length of time. If the
586 decision to answer the call may take some time eg waiting for a user to
587 pick up the phone, then AnswerCallPending or AnswerCallDeferred should
588 be returned.
590 If an application overrides this function, it should generally call the
591 ancestor version to complete calls. Unless the application completely
592 takes over that responsibility. Generally, an application would only
593 intercept this function if it wishes to do some form of logging. For
594 this you can obtain the name of the caller by using the function
595 OpalConnection::GetRemotePartyName().
597 The default behaviour calls the OpalManager function of the same name.
599 Note that the most explicit version of this override is made pure, so as to force
600 descendant classes to implement it. This will only affect code that implements new
601 descendants of OpalConnection - code that uses existing descendants will be unaffected
603 virtual BOOL OnIncomingConnection(unsigned int options, OpalConnection::StringOptions * stringOptions);
604 virtual BOOL OnIncomingConnection(unsigned int options);
605 virtual BOOL OnIncomingConnection();
607 /**Start an outgoing connection.
608 This function will initiate the connection to the remote entity, for
609 example in H.323 it sends a SETUP, in SIP it sends an INVITE etc.
611 The default behaviour is pure.
613 virtual BOOL SetUpConnection() = 0;
615 /**Callback for outgoing connection, it is invoked after SetUpConnection
616 This function allows the application to set up some parameters or to log some messages
618 virtual BOOL OnSetUpConnection();
621 /**Call back for remote party being alerted.
622 This function is called after the connection is informed that the
623 remote endpoint is "ringing". Generally some time after the
624 SetUpConnection() function was called, this is function is called.
626 If FALSE is returned the connection is aborted.
628 If an application overrides this function, it should generally call the
629 ancestor version for correct operation. An application would typically
630 only intercept this function if it wishes to do some form of logging.
631 For this you can obtain the name of the caller by using the function
632 OpalConnection::GetRemotePartyName().
634 The default behaviour calls the OpalEndPoint function of the same name.
636 virtual void OnAlerting();
638 /**Indicate to remote endpoint an alert is in progress.
639 If this is an incoming connection and the AnswerCallResponse is in a
640 AnswerCallDeferred or AnswerCallPending state, then this function is
641 used to indicate to that endpoint that an alert is in progress. This is
642 usually due to another connection which is in the call (the B party)
643 has received an OnAlerting() indicating that its remoteendpoint is
644 "ringing".
646 The default behaviour is pure.
648 virtual BOOL SetAlerting(
649 const PString & calleeName, ///< Name of endpoint being alerted.
650 BOOL withMedia ///< Open media with alerting
651 ) = 0;
653 /**Call back for answering an incoming call.
654 This function is called after the connection has been acknowledged
655 but before the connection is established
657 This gives the application time to wait for some event before
658 signalling to the endpoint that the connection is to proceed. For
659 example the user pressing an "Answer call" button.
661 If AnswerCallDenied is returned the connection is aborted and the
662 connetion specific end call PDU is sent. If AnswerCallNow is returned
663 then the connection proceeding, Finally if AnswerCallPending is returned then the
664 protocol negotiations are paused until the AnsweringCall() function is
665 called.
667 The default behaviour calls the endpoint function of the same name.
669 virtual AnswerCallResponse OnAnswerCall(
670 const PString & callerName ///< Name of caller
673 /**Indicate the result of answering an incoming call.
674 This should only be called if the OnAnswerCall() callback function has
675 returned a AnswerCallPending or AnswerCallDeferred response.
677 Note sending further AnswerCallPending responses via this function will
678 have the result of notification PDUs being sent to the remote endpoint (if possible).
679 In this way multiple notification PDUs may be sent.
681 Sending a AnswerCallDeferred response would have no effect.
683 virtual void AnsweringCall(
684 AnswerCallResponse response ///< Answer response to incoming call
687 /**A call back function whenever a connection is "connected".
688 This indicates that a connection to an endpoint was connected. That
689 is the endpoint received acknowledgement via whatever protocol it uses
690 that the connection may now start media streams.
692 In the context of H.323 this means that the CONNECT pdu has been
693 received.
695 The default behaviour calls the OpalEndPoint function of the same name.
697 virtual void OnConnected();
699 /**Indicate to remote endpoint we are connected.
701 The default behaviour is pure.
703 virtual BOOL SetConnected() = 0;
705 /**A call back function whenever a connection is established.
706 This indicates that a connection to an endpoint was established. This
707 differs from OnConnected() in that the media streams are started.
709 In the context of H.323 this means that the signalling and control
710 channels are open and the TerminalCapabilitySet and MasterSlave
711 negotiations are complete.
713 The default behaviour calls the OpalEndPoint function of the same name.
715 virtual void OnEstablished();
717 /**Release the current connection.
718 This removes the connection from the current call. The call may
719 continue if there are other connections still active on it. If this was
720 the last connection for the call then the call is disposed of as well.
722 Note that this function will return quickly as the release and
723 disposal of the connections is done by another thread.
725 virtual void Release(
726 CallEndReason reason = EndedByLocalUser ///< Reason for call release
729 /**Clean up the termination of the connection.
730 This function can do any internal cleaning up and waiting on background
731 threads that may be using the connection object.
733 Note that there is not a one to one relationship with the
734 OnEstablishedConnection() function. This function may be called without
735 that function being called. For example if SetUpConnection() was used
736 but the call never completed.
738 Classes that override this function should make sure they call the
739 ancestor version for correct operation.
741 An application will not typically call this function as it is used by
742 the OpalManager during a release of the connection.
744 The default behaviour calls the OpalEndPoint function of the same name.
746 virtual void OnReleased();
747 //@}
749 /**@name Additional signalling functions */
750 //@{
751 /**Get the destination address of an incoming connection.
752 This will, for example, collect a phone number from a POTS line, or
753 get the fields from the H.225 SETUP pdu in a H.323 connection.
755 The default behaviour returns "*", which by convention means any
756 address the endpoint/connection can get to.
758 virtual PString GetDestinationAddress();
760 /**Forward incoming call to specified address.
761 This would typically be called from within the OnIncomingCall()
762 function when an application wishes to redirct an unwanted incoming
763 call.
765 The return value is TRUE if the call is to be forwarded, FALSE
766 otherwise. Note that if the call is forwarded the current connection is
767 cleared with teh ended call code of EndedByCallForwarded.
769 virtual BOOL ForwardCall(
770 const PString & forwardParty ///< Party to forward call to.
772 //@}
774 /**@name Media Stream Management */
775 //@{
776 /**Get the data formats this connection is capable of operating.
777 This provides a list of media data format names that a
778 OpalMediaStream may be created in within this connection.
780 The default behaviour is pure.
782 virtual OpalMediaFormatList GetMediaFormats() const = 0;
784 /**Adjust media formats available on a connection.
785 This is called by a connection after it has called
786 OpalCall::GetMediaFormats() to get all media formats that it can use so
787 that an application may remove or reorder the media formats before they
788 are used to open media streams.
790 The default behaviour calls the OpalEndPoint function of the same name.
792 virtual void AdjustMediaFormats(
793 OpalMediaFormatList & mediaFormats ///< Media formats to use
794 ) const;
796 /**Open source transmitter media stream for session.
798 virtual BOOL OpenSourceMediaStream(
799 const OpalMediaFormatList & mediaFormats, ///< Optional media format to open
800 unsigned sessionID ///< Session to start stream on
803 /**Open source transmitter media stream for session.
805 virtual OpalMediaStream * OpenSinkMediaStream(
806 OpalMediaStream & source ///< Source media sink format to open to
809 /**Start media streams for session.
811 virtual void StartMediaStreams();
813 /**Close media streams for session.
815 virtual void CloseMediaStreams();
817 /**Close media streams from session.
819 virtual void RemoveMediaStreams();
821 /**Pause media streams for session.
823 virtual void PauseMediaStreams(BOOL paused);
825 /**Create a new media stream.
826 This will create a media stream of an appropriate subclass as required
827 by the underlying connection protocol. For instance H.323 would create
828 an OpalRTPStream.
830 The sessionID parameter may not be needed by a particular media stream
831 and may be ignored. In the case of an OpalRTPStream it us used.
833 Note that media streams may be created internally to the underlying
834 protocol. This function is not the only way a stream can come into
835 existance.
837 The default behaviour is pure.
839 virtual OpalMediaStream * CreateMediaStream(
840 const OpalMediaFormat & mediaFormat, ///< Media format for stream
841 unsigned sessionID, ///< Session number for stream
842 BOOL isSource ///< Is a source stream
845 /**Call back when opening a media stream.
846 This function is called when a connection has created a new media
847 stream according to the logic of its underlying protocol.
849 The usual requirement is that media streams are created on all other
850 connections participating in the call and all of the media streams are
851 attached to an instance of an OpalMediaPatch object that will read from
852 one of the media streams passing data to the other media streams.
854 The default behaviour calls the OpalEndPoint function of the same name.
856 virtual BOOL OnOpenMediaStream(
857 OpalMediaStream & stream ///< New media stream being opened
860 /**Call back for closed a media stream.
862 The default behaviour calls the OpalEndPoint function of the same name.
864 virtual void OnClosedMediaStream(
865 const OpalMediaStream & stream ///< Media stream being closed
868 /**Call back when patching a media stream.
869 This function is called when a connection has created a new media
870 patch between two streams.
872 virtual void OnPatchMediaStream(
873 BOOL isSource,
874 OpalMediaPatch & patch ///< New patch
877 /**Attaches the RFC 2833 handler to the media patch
878 This method may be called from subclasses, e.g. within
879 OnPatchMediaStream()
881 virtual void AttachRFC2833HandlerToPatch(BOOL isSource, OpalMediaPatch & patch);
883 /**Get a media stream.
884 Locates a stream given a RTP session ID. Each session would usually
885 have two media streams associated with it, so the source flag
886 may be used to distinguish which channel to return.
888 OpalMediaStream * GetMediaStream(
889 unsigned sessionId, ///< Session ID to search for.
890 BOOL source ///< Indicates the direction of stream.
891 ) const;
894 Remove the specified media stream from the list of streams for this channel.
895 This will automatically delete the stream if the stream was found in the
896 stream list.
898 Returns TRUE if the media stream was removed the list and deleted, else
899 returns FALSE if the media stream was unchanged
901 BOOL RemoveMediaStream(
902 OpalMediaStream * strm // media stream to remove
905 /**See if the media can bypass the local host.
907 The default behaviour returns FALSE indicating that media bypass is not
908 possible.
910 virtual BOOL IsMediaBypassPossible(
911 unsigned sessionID ///< Session ID for media channel
912 ) const;
914 /**Meda information structure for GetMediaInformation() function.
916 struct MediaInformation {
917 MediaInformation() {
918 rfc2833 = RTP_DataFrame::IllegalPayloadType;
919 #if OPAL_T38FAX
920 ciscoNSE = RTP_DataFrame::IllegalPayloadType;
921 #endif
924 OpalTransportAddress data; ///< Data channel address
925 OpalTransportAddress control; ///< Control channel address
926 RTP_DataFrame::PayloadTypes rfc2833; ///< Payload type for RFC2833
927 #if OPAL_T38FAX
928 RTP_DataFrame::PayloadTypes ciscoNSE; ///< Payload type for RFC2833
929 #endif
932 /**Get information on the media channel for the connection.
933 The default behaviour checked the mediaTransportAddresses dictionary
934 for the session ID and returns information based on that. It also uses
935 the rfc2833Handler variable for that part of the info.
937 It is up to the descendant class to assure that the mediaTransportAddresses
938 dictionary is set correctly before OnIncomingCall() is executed.
940 virtual BOOL GetMediaInformation(
941 unsigned sessionID, ///< Session ID for media channel
942 MediaInformation & info ///< Information on media channel
943 ) const;
945 #if OPAL_VIDEO
947 /**Add video media formats available on a connection.
949 The default behaviour calls the OpalEndPoint function of the same name.
951 virtual void AddVideoMediaFormats(
952 OpalMediaFormatList & mediaFormats ///< Media formats to use
953 ) const;
955 /**Create an PVideoInputDevice for a source media stream.
957 virtual BOOL CreateVideoInputDevice(
958 const OpalMediaFormat & mediaFormat, ///< Media format for stream
959 PVideoInputDevice * & device, ///< Created device
960 BOOL & autoDelete ///< Flag for auto delete device
963 /**Create an PVideoOutputDevice for a sink media stream or the preview
964 display for a source media stream.
966 virtual BOOL CreateVideoOutputDevice(
967 const OpalMediaFormat & mediaFormat, ///< Media format for stream
968 BOOL preview, ///< Flag indicating is a preview output
969 PVideoOutputDevice * & device, ///< Created device
970 BOOL & autoDelete ///< Flag for auto delete device
972 #endif
974 /**Set the volume (gain) for the audio media channel to the specified percentage.
976 virtual BOOL SetAudioVolume(
977 BOOL source, ///< true for source (microphone), false for sink (speaker)
978 unsigned percentage ///< Gain, 0=silent, 100=maximun
981 /**Get the average signal level (0..32767) for the audio media channel.
982 A return value of UINT_MAX indicates no valid signal, eg no audio channel opened.
984 virtual unsigned GetAudioSignalLevel(
985 BOOL source ///< true for source (microphone), false for sink (speaker)
987 //@}
989 /**@name RTP Session Management */
990 //@{
991 /**Get an RTP session for the specified ID.
992 If there is no session of the specified ID, NULL is returned.
994 virtual RTP_Session * GetSession(
995 unsigned sessionID ///< RTP session number
996 ) const;
998 /**Use an RTP session for the specified ID.
999 This will find a session of the specified ID and increment its
1000 reference count. Multiple OpalRTPStreams use this to indicate their
1001 usage of the RTP session.
1003 If this function is used, then the ReleaseSession() function MUST be
1004 called or the session is never deleted for the lifetime of the Opal
1005 connection.
1007 If there is no session of the specified ID one is created.
1009 The type of RTP session that is created will be compatible with the
1010 transport. At this time only IP (RTp over UDP) is supported.
1012 virtual RTP_Session * UseSession(
1013 const OpalTransport & transport, ///< Transport of signalling
1014 unsigned sessionID, ///< RTP session number
1015 RTP_QOS * rtpqos = NULL ///< Quiality of Service information
1018 /**Release the session.
1019 If the session ID is not being used any more any clients via the
1020 UseSession() function, then the session is deleted.
1022 virtual void ReleaseSession(
1023 unsigned sessionID, ///< RTP session number
1024 BOOL clearAll = FALSE ///< Clear all sessions
1027 /**Create and open a new RTP session.
1028 The type of RTP session that is created will be compatible with the
1029 transport. At this time only IP (RTp over UDP) is supported.
1031 virtual RTP_Session * CreateSession(
1032 const OpalTransport & transport,
1033 unsigned sessionID,
1034 RTP_QOS * rtpqos
1036 //@}
1038 /**@name Bandwidth Management */
1039 //@{
1040 /**Get the available bandwidth in 100's of bits/sec.
1042 unsigned GetBandwidthAvailable() const { return bandwidthAvailable; }
1044 /**Set the available bandwidth in 100's of bits/sec.
1045 Note if the force parameter is TRUE this function will close down
1046 active media streams to meet the new bandwidth requirement.
1048 virtual BOOL SetBandwidthAvailable(
1049 unsigned newBandwidth, ///< New bandwidth limit
1050 BOOL force = FALSE ///< Force bandwidth limit
1053 /**Get the bandwidth currently used.
1054 This totals the bandwidth used by open streams and returns the total
1055 bandwidth used in 100's of bits/sec
1057 virtual unsigned GetBandwidthUsed() const;
1059 /**Set the used bandwidth in 100's of bits/sec.
1060 This is an internal function used by the OpalMediaStream bandwidth
1061 management code.
1063 If there is insufficient bandwidth available, FALSE is returned. If
1064 sufficient bandwidth is available, then TRUE is returned and the amount
1065 of available bandwidth is reduced by the specified amount.
1067 virtual BOOL SetBandwidthUsed(
1068 unsigned releasedBandwidth, ///< Bandwidth to release
1069 unsigned requiredBandwidth ///< Bandwidth required
1071 //@}
1073 /**@name User input */
1074 //@{
1075 enum SendUserInputModes {
1076 SendUserInputAsQ931,
1077 SendUserInputAsString,
1078 SendUserInputAsTone,
1079 SendUserInputAsInlineRFC2833,
1080 SendUserInputAsSeparateRFC2833, // Not implemented
1081 SendUserInputAsProtocolDefault,
1082 NumSendUserInputModes
1084 #if PTRACING
1085 friend ostream & operator<<(ostream & o, SendUserInputModes m);
1086 #endif
1088 /**Set the user input indication transmission mode.
1090 virtual void SetSendUserInputMode(SendUserInputModes mode);
1092 /**Get the user input indication transmission mode.
1094 virtual SendUserInputModes GetSendUserInputMode() const { return sendUserInputMode; }
1096 /**Get the real user input indication transmission mode.
1097 This will return the user input mode that will actually be used for
1098 transmissions. It will be the value of GetSendUserInputMode() provided
1099 the remote endpoint is capable of that mode.
1101 virtual SendUserInputModes GetRealSendUserInputMode() const { return GetSendUserInputMode(); }
1103 /**Send a user input indication to the remote endpoint.
1104 This is for sending arbitrary strings as user indications.
1106 The default behaviour is to call SendUserInputTone() for each character
1107 in the string.
1109 virtual BOOL SendUserInputString(
1110 const PString & value ///< String value of indication
1113 /**Send a user input indication to the remote endpoint.
1114 This sends DTMF emulation user input. If something more sophisticated
1115 than the simple tones that can be sent using the SendUserInput()
1116 function.
1118 A duration of zero indicates that no duration is to be indicated.
1119 A non-zero logical channel indicates that the tone is to be syncronised
1120 with the logical channel at the rtpTimestamp value specified.
1122 The tone parameter must be one of "0123456789#*ABCD!" where '!'
1123 indicates a hook flash. If tone is a ' ' character then a
1124 signalUpdate PDU is sent that updates the last tone indication
1125 sent. See the H.245 specifcation for more details on this.
1127 The default behaviour sends the tone using RFC2833.
1129 virtual BOOL SendUserInputTone(
1130 char tone, ///< DTMF tone code
1131 unsigned duration = 0 ///< Duration of tone in milliseconds
1134 /**Call back for remote enpoint has sent user input as a string.
1135 This will be called irrespective of the source (H.245 string, H.245
1136 signal or RFC2833).
1138 The default behaviour calls the endpoint function of the same name.
1140 virtual void OnUserInputString(
1141 const PString & value ///< String value of indication
1144 /**Call back for remote enpoint has sent user input.
1145 If duration is zero then this indicates the beginning of the tone. If
1146 duration is non-zero then it indicates the end of the tone output.
1148 The default behaviour calls the OpalEndPoint function of the same name.
1150 virtual void OnUserInputTone(
1151 char tone,
1152 unsigned duration
1155 /**Send a user input indication to the remote endpoint.
1156 This sends a Hook Flash emulation user input.
1158 void SendUserInputHookFlash(
1159 unsigned duration = 500 ///< Duration of tone in milliseconds
1160 ) { SendUserInputTone('!', duration); }
1162 /**Get a user input indication string, waiting until one arrives.
1164 virtual PString GetUserInput(
1165 unsigned timeout = 30 ///< Timeout in seconds on input
1168 /**Set a user indication string.
1169 This allows the GetUserInput() function to unblock and return this
1170 string.
1172 virtual void SetUserInput(
1173 const PString & input ///< Input string
1176 /**Read a sequence of user indications with timeouts.
1178 virtual PString ReadUserInput(
1179 const char * terminators = "#\r\n", ///< Characters that can terminte input
1180 unsigned lastDigitTimeout = 4, ///< Timeout on last digit in string
1181 unsigned firstDigitTimeout = 30 ///< Timeout on receiving any digits
1184 /**Play a prompt to the connection before rading user indication string.
1186 For example the LID connection would play a dial tone.
1188 The default behaviour does nothing.
1190 virtual BOOL PromptUserInput(
1191 BOOL play ///< Flag to start or stop playing the prompt
1193 //@}
1195 /**@name Other services */
1196 //@{
1197 #if OPAL_T120DATA
1198 /**Create an instance of the T.120 protocol handler.
1199 This is called when the OpenLogicalChannel subsystem requires that
1200 a T.120 channel be established.
1202 Note that if the application overrides this and returns a pointer to a
1203 heap variable (using new) then it is the responsibility of the creator
1204 to subsequently delete the object. The user of this function (the
1205 H323_T120Channel class) will not do so.
1207 The default behavour returns H323Endpoint::CreateT120ProtocolHandler()
1208 while keeping track of that variable for autmatic deletion.
1210 virtual OpalT120Protocol * CreateT120ProtocolHandler();
1211 #endif
1213 #if OPAL_T38FAX
1214 /**Create an instance of the T.38 protocol handler.
1215 This is called when the OpenLogicalChannel subsystem requires that
1216 a T.38 fax channel be established.
1218 Note that if the application overrides this and returns a pointer to a
1219 heap variable (using new) then it is the responsibility of the creator
1220 to subsequently delete the object. The user of this function (the
1221 H323_T38Channel class) will not do so.
1223 The default behavour returns H323Endpoint::CreateT38ProtocolHandler()
1224 while keeping track of that variable for autmatic deletion.
1226 virtual OpalT38Protocol * CreateT38ProtocolHandler();
1227 #endif
1229 #if OPAL_H224
1231 /** Create an instance of the H.224 protocol handler.
1232 This is called when the subsystem requires that a H.224 channel be established.
1234 Note that if the application overrides this it should return a pointer
1235 to a heap variable (using new) as it will be automatically deleted when
1236 the OpalConnection is deleted.
1238 The default behaviour calls the OpalEndpoint function of the same name if
1239 there is not already a H.224 handler associated with this connection. If there
1240 is already such a H.224 handler associated, this instance is returned instead.
1242 virtual OpalH224Handler *CreateH224ProtocolHandler(unsigned sessionID);
1244 /** Create an instance of the H.281 protocol handler.
1245 This is called when the subsystem requires that a H.224 channel be established.
1247 Note that if the application overrides this it should return a pointer
1248 to a heap variable (using new) as it will be automatically deleted when
1249 the associated H.224 handler is deleted.
1251 The default behaviour calls the OpalEndpoint function of the same name.
1253 virtual OpalH281Handler *CreateH281ProtocolHandler(OpalH224Handler & h224Handler);
1255 /** Returns the H.224 handler associated with this connection or NULL if no
1256 handler was created
1258 OpalH224Handler * GetH224Handler() const { return h224Handler; }
1259 #endif
1261 //@}
1263 /**@name Member variable access */
1264 //@{
1265 /**Get the owner endpoint for this connection.
1267 OpalEndPoint & GetEndPoint() const { return endpoint; }
1269 /**Get the owner call for this connection.
1271 OpalCall & GetCall() const { return ownerCall; }
1273 /**Get the token for this connection.
1275 const PString & GetToken() const { return callToken; }
1277 /**Get the call direction for this connection.
1279 BOOL IsOriginating() const { return originating; }
1281 /**Get the time at which the connection was begun
1283 PTime GetSetupUpTime() const { return setupTime; }
1285 /**Get the time at which the ALERTING was received
1287 PTime GetAlertingTime() const { return alertingTime; }
1289 /**Get the time at which the connection was established
1291 PTime GetConnectionStartTime() const { return connectedTime; }
1293 /**Get the time at which the connection was cleared
1295 PTime GetConnectionEndTime() const { return callEndTime; }
1297 /**Get the local name/alias.
1299 const PString & GetLocalPartyName() const { return localPartyName; }
1301 /**Set the local name/alias.
1303 virtual void SetLocalPartyName(const PString & name);
1305 /**Get the local display name.
1307 const PString & GetDisplayName() const { return displayName; }
1309 /**Set the local display name.
1311 void SetDisplayName(const PString & name) { displayName = name; }
1313 /**Get the caller name/alias.
1315 const PString & GetRemotePartyName() const { return remotePartyName; }
1317 /**Get the remote application.
1319 const PString & GetRemoteApplication() const { return remoteApplication; }
1321 /**Get the remote party number, if there was one one.
1322 If the remote party has indicated an e164 number as one of its aliases
1323 or as a field in the Q.931 PDU, then this function will return it.
1325 const PString & GetRemotePartyNumber() const { return remotePartyNumber; }
1327 /**Get the remote party address.
1329 const PString & GetRemotePartyAddress() const { return remotePartyAddress; }
1331 /**Get the remote party address.
1332 This will return the "best guess" at an address to use in a
1333 to call the user again later.
1335 virtual const PString GetRemotePartyCallbackURL() const { return remotePartyAddress; }
1338 /**Get the called number (for incoming calls). This is useful for gateway
1339 applications where the destination number may not be the same as the local number
1341 virtual const PString & GetCalledDestinationNumber() const { return calledDestinationNumber; }
1343 /**Get the called name (for incoming calls). This is useful for gateway
1344 applications where the destination name may not be the same as the local username
1346 virtual const PString & GetCalledDestinationName() const { return calledDestinationName; }
1348 /**Get the default maximum audio jitter delay parameter.
1349 Defaults to 50ms
1351 unsigned GetMinAudioJitterDelay() const { return minAudioJitterDelay; }
1353 /**Get the default maximum audio delay jitter parameter.
1354 Defaults to 250ms.
1356 unsigned GetMaxAudioJitterDelay() const { return maxAudioJitterDelay; }
1358 /**Set the maximum audio delay jitter parameter.
1360 void SetAudioJitterDelay(
1361 unsigned minDelay, ///< New minimum jitter buffer delay in milliseconds
1362 unsigned maxDelay ///< New maximum jitter buffer delay in milliseconds
1365 /**Get the silence detector active on connection.
1367 OpalSilenceDetector * GetSilenceDetector() const { return silenceDetector; }
1369 /**Get the echo canceler active on connection.
1371 OpalEchoCanceler * GetEchoCanceler() const { return echoCanceler; }
1373 /**Get the protocol-specific unique identifier for this connection.
1375 virtual const OpalGloballyUniqueID & GetIdentifier() const
1376 { return callIdentifier; }
1378 virtual OpalTransport & GetTransport() const
1379 { return *(OpalTransport *)NULL; }
1381 PDICTIONARY(MediaAddressesDict, POrdinalKey, OpalTransportAddress);
1382 MediaAddressesDict & GetMediaTransportAddresses()
1383 { return mediaTransportAddresses; }
1385 //@}
1387 const RTP_DataFrame::PayloadMapType & GetRTPPayloadMap() const
1388 { return rtpPayloadMap; }
1390 PMutex & GetMediaStreamMutex() { return mediaStreamMutex; }
1392 /** Return TRUE if the remote appears to be behind a NAT firewall
1394 BOOL RemoteIsNAT() const
1395 { return remoteIsNAT; }
1397 virtual void SetSecurityMode(const PString & v)
1398 { securityMode = v; }
1400 virtual PString GetSecurityMode() const
1401 { return securityMode; }
1403 StringOptions * GetStringOptions() const
1404 { return stringOptions; }
1406 void SetStringOptions(StringOptions * options);
1408 virtual BOOL OnOpenIncomingMediaChannels();
1410 virtual void ApplyStringOptions();
1412 protected:
1413 PDECLARE_NOTIFIER(OpalRFC2833Info, OpalConnection, OnUserInputInlineRFC2833);
1414 PDECLARE_NOTIFIER(OpalRFC2833Info, OpalConnection, OnUserInputInlineCiscoNSE);
1415 PDECLARE_NOTIFIER(RTP_DataFrame, OpalConnection, OnUserInputInBandDTMF);
1416 PDECLARE_NOTIFIER(PThread, OpalConnection, OnReleaseThreadMain);
1417 PDECLARE_NOTIFIER(RTP_DataFrame, OpalConnection, OnRecordAudio);
1419 // Member variables
1420 OpalCall & ownerCall;
1421 OpalEndPoint & endpoint;
1423 PMutex phaseMutex;
1424 Phases phase;
1426 PString callToken;
1427 OpalGloballyUniqueID callIdentifier;
1428 BOOL originating;
1429 PTime setupTime;
1430 PTime alertingTime;
1431 PTime connectedTime;
1432 PTime callEndTime;
1433 PString localPartyName;
1434 PString displayName;
1435 PString remotePartyName;
1436 PString remoteApplication;
1437 PString remotePartyNumber;
1438 PString remotePartyAddress;
1439 CallEndReason callEndReason;
1440 PString calledDestinationNumber;
1441 PString calledDestinationName;
1442 BOOL remoteIsNAT;
1444 SendUserInputModes sendUserInputMode;
1445 PString userInputString;
1446 PMutex userInputMutex;
1447 PSyncPoint userInputAvailable;
1448 BOOL detectInBandDTMF;
1449 unsigned q931Cause;
1451 OpalSilenceDetector * silenceDetector;
1452 OpalEchoCanceler * echoCanceler;
1453 OpalRFC2833Proto * rfc2833Handler;
1454 #if OPAL_T120DATA
1455 OpalT120Protocol * t120handler;
1456 #endif
1457 #if OPAL_T38FAX
1458 OpalT38Protocol * t38handler;
1459 OpalRFC2833Proto * ciscoNSEHandler;
1460 #endif
1461 #if OPAL_H224
1462 OpalH224Handler * h224Handler;
1463 #endif
1465 MediaAddressesDict mediaTransportAddresses;
1466 PMutex mediaStreamMutex;
1467 OpalMediaStreamList mediaStreams;
1468 RTP_SessionManager rtpSessions;
1469 unsigned minAudioJitterDelay;
1470 unsigned maxAudioJitterDelay;
1471 unsigned bandwidthAvailable;
1473 RTP_DataFrame::PayloadMapType rtpPayloadMap;
1475 // The In-Band DTMF detector. This is used inside an audio filter which is
1476 // added to the audio channel.
1477 PDTMFDecoder dtmfDecoder;
1479 PString securityMode;
1481 /**Set the phase of the connection.
1482 @param phaseToSet the phase to set
1484 void SetPhase(Phases phaseToSet);
1486 #if PTRACING
1487 friend ostream & operator<<(ostream & o, Phases p);
1488 #endif
1490 BOOL useRTPAggregation;
1492 StringOptions * stringOptions;
1495 class RTP_UDP;
1497 class OpalSecurityMode : public PObject
1499 PCLASSINFO(OpalSecurityMode, PObject);
1500 public:
1501 virtual RTP_UDP * CreateRTPSession(
1502 PHandleAggregator * _aggregator, ///< handle aggregator
1503 unsigned id, ///< Session ID for RTP channel
1504 BOOL remoteIsNAT ///< TRUE is remote is behind NAT
1505 ) = 0;
1506 virtual BOOL Open() = 0;
1510 #endif // __OPAL_CONNECTION_H
1513 // End of File ///////////////////////////////////////////////////////////////