connection.h

Go to the documentation of this file.
00001 /*
00002  * connection.h
00003  *
00004  * Telephony connection abstraction
00005  *
00006  * Open Phone Abstraction Library (OPAL)
00007  * Formally known as the Open H323 project.
00008  *
00009  * Copyright (c) 2001 Equivalence Pty. Ltd.
00010  *
00011  * The contents of this file are subject to the Mozilla Public License
00012  * Version 1.0 (the "License"); you may not use this file except in
00013  * compliance with the License. You may obtain a copy of the License at
00014  * http://www.mozilla.org/MPL/
00015  *
00016  * Software distributed under the License is distributed on an "AS IS"
00017  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
00018  * the License for the specific language governing rights and limitations
00019  * under the License.
00020  *
00021  * The Original Code is Open Phone Abstraction Library.
00022  *
00023  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
00024  *
00025  * Contributor(s): Post Increment
00026  *     Portions of this code were written with the assistance of funding from
00027  *     US Joint Forces Command Joint Concept Development & Experimentation (J9)
00028  *     http://www.jfcom.mil/about/abt_j9.htm
00029  *
00030  * $Log: connection.h,v $
00031  * Revision 2.89  2007/08/24 07:47:46  csoutheren
00032  * Get access to called URL
00033  *
00034  * Revision 2.88  2007/08/13 16:19:08  csoutheren
00035  * Ensure CreateMediaStream is only called *once* for each stream in H.323 calls
00036  *
00037  * Revision 2.87  2007/07/26 00:38:56  csoutheren
00038  * Make transmission of RFC2833 independent of the media stream
00039  *
00040  * Revision 2.86  2007/06/29 06:59:56  rjongbloed
00041  * Major improvement to the "product info", normalising H.221 and User-Agent mechanisms.
00042  *
00043  * Revision 2.85  2007/06/28 12:08:26  rjongbloed
00044  * Simplified mutex strategy to avoid some wierd deadlocks. All locking of access
00045  *   to an OpalConnection must be via the PSafeObject locks.
00046  *
00047  * Revision 2.84  2007/05/23 11:10:45  dsandras
00048  * Added missing check for PDTMFDecoder presence in PWLIB.
00049  *
00050  * Revision 2.83  2007/05/15 07:26:38  csoutheren
00051  * Remove deprecated  interface to STUN server in H323Endpoint
00052  * Change UseNATForIncomingCall to IsRTPNATEnabled
00053  * Various cleanups of messy and unused code
00054  *
00055  * Revision 2.82  2007/05/15 05:24:50  csoutheren
00056  * Add UseNATForIncomingCall override so applications can optionally implement their own NAT activation strategy
00057  *
00058  * Revision 2.81  2007/05/07 14:13:51  csoutheren
00059  * Add call record capability
00060  *
00061  * Revision 2.80  2007/04/26 07:01:01  csoutheren
00062  * Add extra code to deal with getting media formats from connections early enough to do proper
00063  * gatewaying between calls. The SIP and H.323 code need to have the handing of the remote
00064  * and local formats standardized, but this will do for now
00065  *
00066  * Revision 2.79  2007/04/18 00:00:44  csoutheren
00067  * Add hooks for recording call audio
00068  *
00069  * Revision 2.78  2007/04/03 05:27:29  rjongbloed
00070  * Cleaned up somewhat confusing usage of the OnAnswerCall() virtual
00071  *   function. The name is innaccurate and exists as a legacy from the
00072  *   OpenH323 days. it now only indicates how alerting is done
00073  *   (with/without media) and does not actually answer the call.
00074  *
00075  * Revision 2.77  2007/03/13 00:32:16  csoutheren
00076  * Simple but messy changes to allow compile time removal of protocol
00077  * options such as H.450 and H.460
00078  * Fix MakeConnection overrides
00079  *
00080  * Revision 2.76  2007/03/01 05:51:03  rjongbloed
00081  * Fixed backward compatibility of OnIncomingConnection() virtual
00082  *   functions on various classes. If an old override returned FALSE
00083  *   then it will now abort the call as it used to.
00084  *
00085  * Revision 2.75  2007/03/01 05:05:20  csoutheren
00086  * Fixed problem with override of OnIncomingConnection
00087  *
00088  * Revision 2.74  2007/03/01 03:52:31  csoutheren
00089  * Use local jitter buffer values rather than getting direct from OpalManager
00090  * Allow OpalConnection string options to be set during incoming calls
00091  *
00092  * Revision 2.73  2007/02/23 01:01:35  csoutheren
00093  * Added abilty to set Q.931 codes through normal OpalConnection::CallEndReason
00094  *
00095  * Revision 2.72  2007/02/19 04:42:27  csoutheren
00096  * Added OnIncomingMediaChannels so incoming calls can optionally be handled in two stages
00097  *
00098  * Revision 2.71  2007/02/12 02:44:27  csoutheren
00099  * Start of support for ZRTP
00100  *
00101  *
00102  * Revision 2.70  2007/01/24 04:00:56  csoutheren
00103  * Arrrghh. Changing OnIncomingConnection turned out to have a lot of side-effects
00104  * Added some pure viritual functions to prevent old code from breaking silently
00105  * New OpalEndpoint and OpalConnection descendants will need to re-implement
00106  * OnIncomingConnection. Sorry :)
00107  *
00108  * Revision 2.69  2007/01/18 04:45:16  csoutheren
00109  * Messy, but simple change to add additional options argument to OpalConnection constructor
00110  * This allows the provision of non-trivial arguments for connections
00111  *
00112  * Revision 2.68  2006/12/18 03:18:41  csoutheren
00113  * Messy but simple fixes
00114  *   - Add access to SIP REGISTER timeout
00115  *   - Ensure OpalConnection options are correctly progagated
00116  *
00117  * Revision 2.67  2006/12/08 04:22:06  csoutheren
00118  * Applied 1589261 - new release cause for fxo endpoints
00119  * Thanks to Frederic Heem
00120  *
00121  * Revision 2.66  2006/11/20 03:37:12  csoutheren
00122  * Allow optional inclusion of RTP aggregation
00123  *
00124  * Revision 2.65  2006/11/11 12:23:18  hfriederich
00125  * Code reorganisation to improve RFC2833 handling for both SIP and H.323. Thanks Simon Zwahlen for the idea
00126  *
00127  * Revision 2.64  2006/10/28 16:40:28  dsandras
00128  * Fixed SIP reinvite without breaking H.323 calls.
00129  *
00130  * Revision 2.63  2006/10/10 07:18:18  csoutheren
00131  * Allow compilation with and without various options
00132  *
00133  * Revision 2.62  2006/09/28 07:42:17  csoutheren
00134  * Merge of useful SRTP implementation
00135  *
00136  * Revision 2.61  2006/08/29 08:47:43  rjongbloed
00137  * Added functions to get average audio signal level from audio streams in
00138  *   suitable connection types.
00139  *
00140  * Revision 2.60  2006/08/28 00:07:43  csoutheren
00141  * Applied 1545125 - SetPhase mutex protection and transition control
00142  * Thanks to Drazen Dimoti
00143  *
00144  * Revision 2.59  2006/08/17 23:09:03  rjongbloed
00145  * Added volume controls
00146  *
00147  * Revision 2.58  2006/08/10 05:10:30  csoutheren
00148  * Various H.323 stability patches merged in from DeimosPrePLuginBranch
00149  *
00150  * Revision 2.57  2006/08/03 04:57:12  csoutheren
00151  * Port additional NAT handling logic from OpenH323 and extend into OpalConnection class
00152  *
00153  * Revision 2.56.2.1  2006/08/09 12:49:21  csoutheren
00154  * Improve stablity under heavy H.323 load
00155  *
00156  * Revision 2.56  2006/06/27 13:07:37  csoutheren
00157  * Patch 1374533 - add h323 Progress handling
00158  * Thanks to Frederich Heem
00159  *
00160  * Revision 2.55  2006/06/09 04:22:24  csoutheren
00161  * Implemented mapping between SIP release codes and Q.931 codes as specified
00162  *  by RFC 3398
00163  *
00164  * Revision 2.54  2006/05/30 04:58:06  csoutheren
00165  * Added suport for SIP INFO message (untested as yet)
00166  * Fixed some issues with SIP state machine on answering calls
00167  * Fixed some formatting issues
00168  *
00169  * Revision 2.53  2006/04/20 16:52:22  hfriederich
00170  * Adding support for H.224/H.281
00171  *
00172  * Revision 2.52  2006/03/20 10:37:47  csoutheren
00173  * Applied patch #1453753 - added locking on media stream manipulation
00174  * Thanks to Dinis Rosario
00175  *
00176  * Revision 2.51  2006/02/22 10:40:09  csoutheren
00177  * Added patch #1374583 from Frederic Heem
00178  * Added additional H.323 virtual function
00179  *
00180  * Revision 2.50  2006/02/02 07:02:56  csoutheren
00181  * Added RTP payload map to transcoders and connections to allow remote SIP endpoints
00182  * to change the payload type used for outgoing RTP.
00183  *
00184  * Revision 2.49  2006/01/09 12:19:06  csoutheren
00185  * Added member variables to capture incoming destination addresses
00186  *
00187  * Revision 2.48  2005/12/06 21:32:24  dsandras
00188  * Applied patch from Frederic Heem <frederic.heem _Atttt_ telsey.it> to fix
00189  * assert in PSyncPoint when OnReleased is called twice from different threads.
00190  * Thanks! (Patch #1374240)
00191  *
00192  * Revision 2.47  2005/11/30 13:35:26  csoutheren
00193  * Changed tags for Doxygen
00194  *
00195  * Revision 2.46  2005/11/24 20:31:54  dsandras
00196  * Added support for echo cancelation using Speex.
00197  * Added possibility to add a filter to an OpalMediaPatch for all patches of a connection.
00198  *
00199  * Revision 2.45  2005/10/04 12:57:18  rjongbloed
00200  * Removed CanOpenSourceMediaStream/CanOpenSinkMediaStream functions and
00201  *   now use overides on OpenSourceMediaStream/OpenSinkMediaStream
00202  *
00203  * Revision 2.44  2005/09/15 17:02:40  dsandras
00204  * Added the possibility for a connection to prevent the opening of a sink/source media stream.
00205  *
00206  * Revision 2.43  2005/08/24 10:43:51  rjongbloed
00207  * Changed create video functions yet again so can return pointers that are not to be deleted.
00208  *
00209  * Revision 2.42  2005/08/23 12:45:09  rjongbloed
00210  * Fixed creation of video preview window and setting video grab/display initial frame size.
00211  *
00212  * Revision 2.41  2005/08/04 17:21:01  dsandras
00213  * Added functions to close/remove the media streams of a connection.
00214  *
00215  * Revision 2.40  2005/07/14 08:51:17  csoutheren
00216  * Removed CreateExternalRTPAddress - it's not needed because you can override GetMediaAddress
00217  * to do the same thing
00218  * Fixed problems with logic associated with media bypass
00219  *
00220  * Revision 2.39  2005/07/11 06:52:15  csoutheren
00221  * Added support for outgoing calls using external RTP
00222  *
00223  * Revision 2.38  2005/07/11 01:52:23  csoutheren
00224  * Extended AnsweringCall to work for SIP as well as H.323
00225  * Fixed problems with external RTP connection in H.323
00226  * Added call to OnClosedMediaStream
00227  *
00228  * Revision 2.37  2005/04/11 11:12:00  dsandras
00229  * Fixed previous commit.
00230  *
00231  * Revision 2.36  2005/04/11 10:42:35  dsandras
00232  * Fixed previous commit.
00233  *
00234  * Revision 2.35  2005/04/10 20:43:39  dsandras
00235  * Added support for function allowing to put the OpalMediaStreams on pause.
00236  *
00237  * Revision 2.34  2005/04/10 20:42:33  dsandras
00238  * Added support for a function that returns the "best guess" callback URL.
00239  *
00240  * Revision 2.33  2005/04/10 20:41:29  dsandras
00241  * Added support for call hold.
00242  *
00243  * Revision 2.32  2005/04/10 20:40:20  dsandras
00244  * Added support for Blind Transfert.
00245  *
00246  * Revision 2.31  2005/01/16 11:28:05  csoutheren
00247  * Added GetIdentifier virtual function to OpalConnection, and changed H323
00248  * and SIP descendants to use this function. This allows an application to
00249  * obtain a GUID for any connection regardless of the protocol used
00250  *
00251  * Revision 2.30  2004/12/12 12:29:02  dsandras
00252  * Moved GetRemoteApplication () to OpalConnection so that it is usable for all types of connection.
00253  *
00254  * Revision 2.29  2004/08/14 07:56:29  rjongbloed
00255  * Major revision to utilise the PSafeCollection classes for the connections and calls.
00256  *
00257  * Revision 2.28  2004/05/17 13:24:18  rjongbloed
00258  * Added silence suppression.
00259  *
00260  * Revision 2.27  2004/05/01 10:00:51  rjongbloed
00261  * Fixed ClearCallSynchronous so now is actually signalled when call is destroyed.
00262  *
00263  * Revision 2.26  2004/04/26 04:33:05  rjongbloed
00264  * Move various call progress times from H.323 specific to general conenction.
00265  *
00266  * Revision 2.25  2004/04/18 13:31:28  rjongbloed
00267  * Added new end call value from OpenH323.
00268  *
00269  * Revision 2.24  2004/03/13 06:25:50  rjongbloed
00270  * Slight rearrangement of local party name and alias list to beter match common
00271  *   behaviour in ancestor.
00272  * Abstracted local party name for endpoint into ancestor from H.,323.
00273  *
00274  * Revision 2.23  2004/03/11 06:54:27  csoutheren
00275  * Added ability to disable SIP or H.323 stacks
00276  *
00277  * Revision 2.22  2004/02/24 11:28:45  rjongbloed
00278  * Normalised RTP session management across protocols
00279  *
00280  * Revision 2.21  2003/03/17 10:26:59  robertj
00281  * Added video support.
00282  *
00283  * Revision 2.20  2003/03/06 03:57:47  robertj
00284  * IVR support (work in progress) requiring large changes everywhere.
00285  *
00286  * Revision 2.19  2003/01/07 04:39:53  robertj
00287  * Updated to OpenH323 v1.11.2
00288  *
00289  * Revision 2.18  2002/11/10 11:33:17  robertj
00290  * Updated to OpenH323 v1.10.3
00291  *
00292  * Revision 2.17  2002/09/16 02:52:35  robertj
00293  * Added #define so can select if #pragma interface/implementation is used on
00294  *   platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
00295  *
00296  * Revision 2.16  2002/09/12 06:54:06  robertj
00297  * Added missing virtual to Release() function so can be overridden.
00298  *
00299  * Revision 2.15  2002/07/01 04:56:30  robertj
00300  * Updated to OpenH323 v1.9.1
00301  *
00302  * Revision 2.14  2002/04/10 03:08:42  robertj
00303  * Moved code for handling media bypass address resolution into ancestor as
00304  *   now done ths same way in both SIP and H.323.
00305  *
00306  * Revision 2.13  2002/04/09 00:16:46  robertj
00307  * Changed "callAnswered" to better description of "originating".
00308  *
00309  * Revision 2.12  2002/02/19 07:42:07  robertj
00310  * Added OpalRFC2833 as a OpalMediaFormat variable.
00311  * Restructured media bypass functions to fix problems with RFC2833.
00312  *
00313  * Revision 2.11  2002/02/11 09:32:12  robertj
00314  * Updated to openH323 v1.8.0
00315  *
00316  * Revision 2.10  2002/02/11 07:38:35  robertj
00317  * Added media bypass for streams between compatible protocols.
00318  *
00319  * Revision 2.9  2002/01/22 05:04:21  robertj
00320  * Revamp of user input API triggered by RFC2833 support
00321  *
00322  * Revision 2.8  2001/11/14 01:31:55  robertj
00323  * Corrected placement of adjusting media format list.
00324  *
00325  * Revision 2.7  2001/11/02 10:45:19  robertj
00326  * Updated to OpenH323 v1.7.3
00327  *
00328  * Revision 2.6  2001/10/15 04:29:14  robertj
00329  * Added delayed start of media patch threads.
00330  * Removed answerCall signal and replaced with state based functions.
00331  *
00332  * Revision 2.5  2001/10/03 05:56:15  robertj
00333  * Changes abndwidth management API.
00334  *
00335  * Revision 2.4  2001/08/22 10:20:09  robertj
00336  * Changed connection locking to use double mutex to guarantee that
00337  *   no threads can ever deadlock or access deleted connection.
00338  *
00339  * Revision 2.3  2001/08/17 08:22:23  robertj
00340  * Moved call end reasons enum from OpalConnection to global.
00341  *
00342  * Revision 2.2  2001/08/13 05:10:39  robertj
00343  * Updates from OpenH323 v1.6.0 release.
00344  *
00345  * Revision 2.1  2001/08/01 05:26:35  robertj
00346  * Moved media formats list from endpoint to connection.
00347  *
00348  * Revision 2.0  2001/07/27 15:48:24  robertj
00349  * Conversion of OpenH323 to Open Phone Abstraction Library (OPAL)
00350  *
00351  */
00352 
00353 #ifndef __OPAL_CONNECTION_H
00354 #define __OPAL_CONNECTION_H
00355 
00356 #ifdef P_USE_PRAGMA
00357 #pragma interface
00358 #endif
00359 
00360 #include <opal/buildopts.h>
00361 
00362 #include <opal/mediafmt.h>
00363 #include <opal/mediastrm.h>
00364 #include <opal/guid.h>
00365 #include <opal/transports.h>
00366 #include <ptclib/dtmf.h>
00367 #include <ptlib/safecoll.h>
00368 #include <rtp/rtp.h>
00369 
00370 class OpalEndPoint;
00371 class OpalCall;
00372 class OpalSilenceDetector;
00373 class OpalEchoCanceler;
00374 class OpalRFC2833Proto;
00375 class OpalRFC2833Info;
00376 class OpalT120Protocol;
00377 class OpalT38Protocol;
00378 class OpalH224Handler;
00379 class OpalH281Handler;
00380 
00381 
00384 class OpalProductInfo
00385 {
00386   public:
00387     OpalProductInfo();
00388 
00389     static OpalProductInfo & Default();
00390 
00391     PCaselessString AsString() const;
00392 
00393     PString vendor;
00394     PString name;
00395     PString version;
00396     BYTE    t35CountryCode;
00397     BYTE    t35Extension;
00398     WORD    manufacturerCode;
00399 };
00400 
00401 
00419 class OpalConnection : public PSafeObject
00420 {
00421     PCLASSINFO(OpalConnection, PSafeObject);
00422   public:
00427     enum CallEndReason {
00428       EndedByLocalUser,         
00429       EndedByNoAccept,          
00430       EndedByAnswerDenied,      
00431       EndedByRemoteUser,        
00432       EndedByRefusal,           
00433       EndedByNoAnswer,          
00434       EndedByCallerAbort,       
00435       EndedByTransportFail,     
00436       EndedByConnectFail,       
00437       EndedByGatekeeper,        
00438       EndedByNoUser,            
00439       EndedByNoBandwidth,       
00440       EndedByCapabilityExchange,
00441       EndedByCallForwarded,     
00442       EndedBySecurityDenial,    
00443       EndedByLocalBusy,         
00444       EndedByLocalCongestion,   
00445       EndedByRemoteBusy,        
00446       EndedByRemoteCongestion,  
00447       EndedByUnreachable,       
00448       EndedByNoEndPoint,        
00449       EndedByHostOffline,       
00450       EndedByTemporaryFailure,  
00451       EndedByQ931Cause,         
00452       EndedByDurationLimit,     
00453       EndedByInvalidConferenceID, 
00454       EndedByNoDialTone,        
00455       EndedByNoRingBackTone,    
00456       EndedByOutOfService,      
00457       EndedByAcceptingCallWaiting, 
00458       NumCallEndReasons,
00459 
00460       EndedWithQ931Code = 0x100  
00461     };
00462 
00463 #if PTRACING
00464     friend ostream & operator<<(ostream & o, CallEndReason reason);
00465 #endif
00466 
00467     enum AnswerCallResponse {
00468       AnswerCallNow,               
00469       AnswerCallDenied,            
00470       AnswerCallPending,           
00471       AnswerCallDeferred,          
00472       AnswerCallAlertWithMedia,    
00473       AnswerCallDeferredWithMedia, 
00474       AnswerCallProgress,          
00475       AnswerCallNowAndReleaseCurrent, 
00476       NumAnswerCallResponses
00477     };
00478 #if PTRACING
00479     friend ostream & operator<<(ostream & o, AnswerCallResponse s);
00480 #endif
00481 
00484     enum Options {
00485       FastStartOptionDisable       = 0x0001,   // H.323 specific
00486       FastStartOptionEnable        = 0x0002,
00487       FastStartOptionMask          = 0x0003,
00488 
00489       H245TunnelingOptionDisable   = 0x0004,   // H.323 specific
00490       H245TunnelingOptionEnable    = 0x0008,
00491       H245TunnelingOptionMask      = 0x000c,
00492 
00493       H245inSetupOptionDisable     = 0x0010,   // H.323 specific
00494       H245inSetupOptionEnable      = 0x0020,
00495       H245inSetupOptionMask        = 0x0030,
00496 
00497       DetectInBandDTMFOptionDisable = 0x0040,  // SIP and H.323
00498       DetectInBandDTMFOptionEnable  = 0x0080,
00499       DetectInBandDTMFOptionMask    = 0x00c0,
00500 
00501       RTPAggregationDisable        = 0x0100,   // SIP and H.323
00502       RTPAggregationEnable         = 0x0200,
00503       RTPAggregationMask           = 0x0300,
00504 
00505       SendDTMFAsDefault            = 0x0000,   // SIP and H.323
00506       SendDTMFAsString             = 0x0400,
00507       SendDTMFAsTone               = 0x0800,
00508       SendDTMFAsRFC2833            = 0x0c00,
00509       SendDTMFMask                 = 0x0c00
00510     };
00511 
00512     class StringOptions : public PStringToString 
00513     {
00514     };
00515 
00520     OpalConnection(
00521       OpalCall & call,                         
00522       OpalEndPoint & endpoint,                 
00523       const PString & token,                   
00524       unsigned options = 0,                    
00525       OpalConnection::StringOptions * stringOptions = NULL     
00526     );  
00527 
00530     ~OpalConnection();
00532 
00539     void PrintOn(
00540       ostream & strm    
00541     ) const;
00543 
00546     enum Phases {
00547       UninitialisedPhase,
00548       SetUpPhase,
00549       AlertingPhase,
00550       ConnectedPhase,
00551       EstablishedPhase,
00552       ReleasingPhase, // Note these must be the last two phases.
00553       ReleasedPhase,
00554       NumPhases
00555     };
00556 
00561     inline Phases GetPhase() const { return phase; }
00562 
00571     CallEndReason GetCallEndReason() const { return callEndReason; }
00572 
00577     virtual void SetCallEndReason(
00578       CallEndReason reason        
00579     );
00580 
00588     void ClearCall(
00589       CallEndReason reason = EndedByLocalUser 
00590     );
00591 
00594     virtual void ClearCallSynchronous(
00595       PSyncPoint * sync,
00596       CallEndReason reason = EndedByLocalUser  
00597     );
00598 
00602     unsigned GetQ931Cause() const { return q931Cause; }
00603 
00607     void SetQ931Cause(unsigned v) { q931Cause = v; }
00608 
00612     virtual void TransferConnection(
00613       const PString & remoteParty,   
00614       const PString & callIdentity = PString::Empty()
00616     );
00617     
00620     virtual void HoldConnection();
00621 
00625     virtual void RetrieveConnection();
00626 
00629     virtual BOOL IsConnectionOnHold();
00631 
00659     virtual BOOL OnIncomingConnection(unsigned int options, OpalConnection::StringOptions * stringOptions);
00660     virtual BOOL OnIncomingConnection(unsigned int options);
00661     virtual BOOL OnIncomingConnection();
00662 
00669     virtual BOOL SetUpConnection() = 0;
00670 
00674     virtual BOOL OnSetUpConnection();
00675 
00676     
00692     virtual void OnAlerting();
00693 
00704     virtual BOOL SetAlerting(
00705       const PString & calleeName,   
00706       BOOL withMedia                
00707     ) = 0;
00708 
00725     virtual AnswerCallResponse OnAnswerCall(
00726       const PString & callerName        
00727     );
00728 
00739     virtual void AnsweringCall(
00740       AnswerCallResponse response 
00741     );
00742 
00753     virtual void OnConnected();
00754 
00759     virtual BOOL SetConnected() = 0;
00760 
00771     virtual void OnEstablished();
00772 
00781     virtual void Release(
00782       CallEndReason reason = EndedByLocalUser 
00783     );
00784 
00802     virtual void OnReleased();
00804 
00814     virtual PString GetDestinationAddress();
00815 
00825     virtual BOOL ForwardCall(
00826       const PString & forwardParty   
00827     );
00829 
00838     virtual OpalMediaFormatList GetMediaFormats() const = 0;
00839 
00844     virtual OpalMediaFormatList GetLocalMediaFormats();
00845 
00854     virtual void AdjustMediaFormats(
00855       OpalMediaFormatList & mediaFormats  
00856     ) const;
00857     
00860     virtual BOOL OpenSourceMediaStream(
00861       const OpalMediaFormatList & mediaFormats, 
00862       unsigned sessionID                   
00863     );
00864 
00867     virtual OpalMediaStream * OpenSinkMediaStream(
00868       OpalMediaStream & source    
00869     );
00870 
00873     virtual void StartMediaStreams();
00874     
00877     virtual void CloseMediaStreams();
00878     
00881     virtual void RemoveMediaStreams();
00882     
00885     virtual void PauseMediaStreams(BOOL paused);
00886 
00901     virtual OpalMediaStream * CreateMediaStream(
00902       const OpalMediaFormat & mediaFormat, 
00903       unsigned sessionID,                  
00904       BOOL isSource                        
00905     );
00906 
00918     virtual BOOL OnOpenMediaStream(
00919       OpalMediaStream & stream    
00920     );
00921 
00926     virtual void OnClosedMediaStream(
00927       const OpalMediaStream & stream     
00928     );
00929     
00934     virtual void OnPatchMediaStream(
00935       BOOL isSource,
00936       OpalMediaPatch & patch    
00937     );
00938         
00943     virtual void AttachRFC2833HandlerToPatch(BOOL isSource, OpalMediaPatch & patch);
00944 
00950     OpalMediaStream * GetMediaStream(
00951       unsigned sessionId,  
00952       BOOL source          
00953     ) const;
00954 
00963     BOOL RemoveMediaStream(
00964       OpalMediaStream * strm     // media stream to remove
00965     );
00966 
00972     virtual BOOL IsMediaBypassPossible(
00973       unsigned sessionID                  
00974     ) const;
00975 
00978     struct MediaInformation {
00979       MediaInformation() { 
00980         rfc2833  = RTP_DataFrame::IllegalPayloadType; 
00981 #if OPAL_T38FAX
00982         ciscoNSE = RTP_DataFrame::IllegalPayloadType; 
00983 #endif
00984       }
00985 
00986       OpalTransportAddress data;           
00987       OpalTransportAddress control;        
00988       RTP_DataFrame::PayloadTypes rfc2833; 
00989 #if OPAL_T38FAX
00990       RTP_DataFrame::PayloadTypes ciscoNSE; 
00991 #endif
00992     };
00993 
01002     virtual BOOL GetMediaInformation(
01003       unsigned sessionID,     
01004       MediaInformation & info 
01005     ) const;
01006 
01007 #if OPAL_VIDEO
01008 
01013     virtual void AddVideoMediaFormats(
01014       OpalMediaFormatList & mediaFormats  
01015     ) const;
01016 
01019     virtual BOOL CreateVideoInputDevice(
01020       const OpalMediaFormat & mediaFormat,  
01021       PVideoInputDevice * & device,         
01022       BOOL & autoDelete                     
01023     );
01024 
01028     virtual BOOL CreateVideoOutputDevice(
01029       const OpalMediaFormat & mediaFormat,  
01030       BOOL preview,                         
01031       PVideoOutputDevice * & device,        
01032       BOOL & autoDelete                     
01033     );
01034 #endif 
01035 
01038     virtual BOOL SetAudioVolume(
01039       BOOL source,                  
01040       unsigned percentage           
01041     );
01042 
01046     virtual unsigned GetAudioSignalLevel(
01047       BOOL source                   
01048     );
01050 
01056     virtual RTP_Session * GetSession(
01057       unsigned sessionID    
01058     ) const;
01059 
01074     virtual RTP_Session * UseSession(
01075       unsigned sessionID
01076     );
01077     virtual RTP_Session * UseSession(
01078       const OpalTransport & transport,  
01079       unsigned sessionID,               
01080       RTP_QOS * rtpqos = NULL           
01081     );
01082 
01087     virtual void ReleaseSession(
01088       unsigned sessionID,    
01089       BOOL clearAll = FALSE  
01090     );
01091 
01096     virtual RTP_Session * CreateSession(
01097       const OpalTransport & transport,
01098       unsigned sessionID,
01099       RTP_QOS * rtpqos
01100     );
01102 
01107     unsigned GetBandwidthAvailable() const { return bandwidthAvailable; }
01108 
01113     virtual BOOL SetBandwidthAvailable(
01114       unsigned newBandwidth,    
01115       BOOL force = FALSE        
01116     );
01117 
01122     virtual unsigned GetBandwidthUsed() const;
01123 
01132     virtual BOOL SetBandwidthUsed(
01133       unsigned releasedBandwidth,   
01134       unsigned requiredBandwidth    
01135     );
01137 
01140     enum SendUserInputModes {
01141       SendUserInputAsQ931,
01142       SendUserInputAsString,
01143       SendUserInputAsTone,
01144       SendUserInputAsInlineRFC2833,
01145       SendUserInputAsSeparateRFC2833,  // Not implemented
01146       SendUserInputAsProtocolDefault,
01147       NumSendUserInputModes
01148     };
01149 #if PTRACING
01150     friend ostream & operator<<(ostream & o, SendUserInputModes m);
01151 #endif
01152 
01155     virtual void SetSendUserInputMode(SendUserInputModes mode);
01156 
01159     virtual SendUserInputModes GetSendUserInputMode() const { return sendUserInputMode; }
01160 
01166     virtual SendUserInputModes GetRealSendUserInputMode() const { return GetSendUserInputMode(); }
01167 
01174     virtual BOOL SendUserInputString(
01175       const PString & value                   
01176     );
01177 
01194     virtual BOOL SendUserInputTone(
01195       char tone,        
01196       unsigned duration = 0  
01197     );
01198 
01205     virtual void OnUserInputString(
01206       const PString & value   
01207     );
01208 
01215     virtual void OnUserInputTone(
01216       char tone,
01217       unsigned duration
01218     );
01219 
01223     void SendUserInputHookFlash(
01224       unsigned duration = 500  
01225     ) { SendUserInputTone('!', duration); }
01226 
01229     virtual PString GetUserInput(
01230       unsigned timeout = 30   
01231     );
01232 
01237     virtual void SetUserInput(
01238       const PString & input     
01239     );
01240 
01243     virtual PString ReadUserInput(
01244       const char * terminators = "#\r\n", 
01245       unsigned lastDigitTimeout = 4,      
01246       unsigned firstDigitTimeout = 30     
01247     );
01248 
01255     virtual BOOL PromptUserInput(
01256       BOOL play   
01257     );
01259 
01262 #if OPAL_T120DATA
01263 
01275     virtual OpalT120Protocol * CreateT120ProtocolHandler();
01276 #endif
01277 
01278 #if OPAL_T38FAX
01279 
01291     virtual OpalT38Protocol * CreateT38ProtocolHandler();
01292 #endif
01293 
01294 #if OPAL_H224
01295         
01307         virtual OpalH224Handler *CreateH224ProtocolHandler(unsigned sessionID);
01308         
01318         virtual OpalH281Handler *CreateH281ProtocolHandler(OpalH224Handler & h224Handler);
01319         
01323         OpalH224Handler * GetH224Handler() const { return  h224Handler; }
01324 #endif
01325 
01327 
01332     OpalEndPoint & GetEndPoint() const { return endpoint; }
01333     
01336     OpalCall & GetCall() const { return ownerCall; }
01337 
01340     const PString & GetToken() const { return callToken; }
01341 
01344     BOOL IsOriginating() const { return originating; }
01345 
01348     PTime GetSetupUpTime() const { return setupTime; }
01349 
01352     PTime GetAlertingTime() const { return alertingTime; }
01353 
01356     PTime GetConnectionStartTime() const { return connectedTime; }
01357 
01360     PTime GetConnectionEndTime() const { return callEndTime; }
01361 
01364     const OpalProductInfo & GetProductInfo() const { return productInfo; }
01365 
01368     void SetProductInfo(
01369       const OpalProductInfo & info
01370     ) { productInfo = info; }
01371 
01374     const PString & GetLocalPartyName() const { return localPartyName; }
01375 
01378     virtual void SetLocalPartyName(const PString & name);
01379 
01382     const PString & GetDisplayName() const { return displayName; }
01383 
01386     void SetDisplayName(const PString & name) { displayName = name; }
01387 
01390     const PString & GetRemotePartyName() const { return remotePartyName; }
01391 
01395     PCaselessString GetRemoteApplication() const { return remoteProductInfo.AsString(); }
01396 
01399     const OpalProductInfo & GetRemoteProductInfo() const { return remoteProductInfo; }
01400     
01405     const PString & GetRemotePartyNumber() const { return remotePartyNumber; }
01406 
01409     const PString & GetRemotePartyAddress() const { return remotePartyAddress; }
01410 
01415     virtual const PString GetRemotePartyCallbackURL() const { return remotePartyAddress; }
01416 
01417 
01421     virtual const PString & GetCalledDestinationNumber() const { return calledDestinationNumber; }
01422 
01426     virtual const PString & GetCalledDestinationName() const { return calledDestinationName; }
01427 
01431     virtual const PString & GetCalledDestinationURL() const { return calledDestinationURL; }
01432 
01436     unsigned GetMinAudioJitterDelay() const { return minAudioJitterDelay; }
01437 
01441     unsigned GetMaxAudioJitterDelay() const { return maxAudioJitterDelay; }
01442 
01445     void SetAudioJitterDelay(
01446       unsigned minDelay,   
01447       unsigned maxDelay    
01448     );
01449 
01452     OpalSilenceDetector * GetSilenceDetector() const { return silenceDetector; }
01453     
01456     OpalEchoCanceler * GetEchoCanceler() const { return echoCanceler; }
01457 
01460     virtual const OpalGloballyUniqueID & GetIdentifier() const
01461     { return callIdentifier; }
01462 
01463     virtual OpalTransport & GetTransport() const
01464     { return *(OpalTransport *)NULL; }
01465 
01466     PDICTIONARY(MediaAddressesDict, POrdinalKey, OpalTransportAddress);
01467     MediaAddressesDict & GetMediaTransportAddresses()
01468     { return mediaTransportAddresses; }
01469 
01471 
01472     const RTP_DataFrame::PayloadMapType & GetRTPPayloadMap() const
01473     { return rtpPayloadMap; }
01474 
01477     BOOL RemoteIsNAT() const
01478     { return remoteIsNAT; }
01479 
01480     virtual void SetSecurityMode(const PString & v)
01481     { securityMode = v; }
01482 
01483     virtual PString GetSecurityMode() const 
01484     { return securityMode; }
01485 
01486     StringOptions * GetStringOptions() const
01487     { return stringOptions; }
01488 
01489     void SetStringOptions(StringOptions * options);
01490 
01491     virtual BOOL OnOpenIncomingMediaChannels();
01492 
01493     virtual void ApplyStringOptions();
01494 
01495     virtual void PreviewPeerMediaFormats(const OpalMediaFormatList & fmts);
01496 
01497     virtual void EnableRecording();
01498     virtual void DisableRecording();
01499 
01500     virtual BOOL IsRTPNATEnabled(const PIPSocket::Address & localAddr, 
01501                                  const PIPSocket::Address & peerAddr,
01502                                  const PIPSocket::Address & sigAddr,
01503                                                        BOOL incoming);
01504 
01505   protected:
01506     PDECLARE_NOTIFIER(OpalRFC2833Info, OpalConnection, OnUserInputInlineRFC2833);
01507     PDECLARE_NOTIFIER(OpalRFC2833Info, OpalConnection, OnUserInputInlineCiscoNSE);
01508 #if P_DTMF
01509     PDECLARE_NOTIFIER(RTP_DataFrame, OpalConnection, OnUserInputInBandDTMF);
01510 #endif
01511     PDECLARE_NOTIFIER(PThread, OpalConnection, OnReleaseThreadMain);
01512     PDECLARE_NOTIFIER(RTP_DataFrame, OpalConnection, OnRecordAudio);
01513 
01514   // Member variables
01515     OpalCall             & ownerCall;
01516     OpalEndPoint         & endpoint;
01517 
01518     PMutex               phaseMutex;
01519     Phases               phase;
01520 
01521     PString              callToken;
01522     OpalGloballyUniqueID callIdentifier;
01523     BOOL                 originating;
01524     PTime                setupTime;
01525     PTime                alertingTime;
01526     PTime                connectedTime;
01527     PTime                callEndTime;
01528     OpalProductInfo      productInfo;
01529     PString              localPartyName;
01530     PString              displayName;
01531     PString              remotePartyName;
01532     OpalProductInfo      remoteProductInfo;
01533     PString              remotePartyNumber;
01534     PString              remotePartyAddress;
01535     CallEndReason        callEndReason;
01536     PString              calledDestinationNumber;
01537     PString              calledDestinationName;
01538     PString              calledDestinationURL;
01539     BOOL                 remoteIsNAT;
01540 
01541     SendUserInputModes    sendUserInputMode;
01542     PString               userInputString;
01543     PSyncPoint            userInputAvailable;
01544     BOOL                  detectInBandDTMF;
01545     unsigned              q931Cause;
01546 
01547     OpalSilenceDetector * silenceDetector;
01548     OpalEchoCanceler    * echoCanceler;
01549     OpalRFC2833Proto    * rfc2833Handler;
01550 #if OPAL_T120DATA
01551     OpalT120Protocol    * t120handler;
01552 #endif
01553 #if OPAL_T38FAX
01554     OpalT38Protocol     * t38handler;
01555     OpalRFC2833Proto    * ciscoNSEHandler;
01556 #endif
01557 #if OPAL_H224
01558     OpalH224Handler               * h224Handler;
01559 #endif
01560 
01561     MediaAddressesDict  mediaTransportAddresses;
01562     OpalMediaStreamList mediaStreams;
01563     RTP_SessionManager  rtpSessions;
01564     unsigned            minAudioJitterDelay;
01565     unsigned            maxAudioJitterDelay;
01566     unsigned            bandwidthAvailable;
01567 
01568     RTP_DataFrame::PayloadMapType rtpPayloadMap;
01569 
01570     // The In-Band DTMF detector. This is used inside an audio filter which is
01571     // added to the audio channel.
01572 #if P_DTMF
01573     PDTMFDecoder        dtmfDecoder;
01574 #endif
01575 
01576     PString securityMode;
01577 
01581     void SetPhase(Phases phaseToSet);
01582 
01583 #if PTRACING
01584     friend ostream & operator<<(ostream & o, Phases p);
01585 #endif
01586 
01587     BOOL useRTPAggregation;
01588 
01589     StringOptions * stringOptions;
01590     PString recordAudioFilename;
01591 
01592     virtual OpalMediaStream * InternalCreateMediaStream(const OpalMediaFormat & mediaFormat, unsigned sessionID, BOOL isSource);
01593 };
01594 
01595 class RTP_UDP;
01596 
01597 class OpalSecurityMode : public PObject
01598 {
01599   PCLASSINFO(OpalSecurityMode, PObject);
01600   public:
01601     virtual RTP_UDP * CreateRTPSession(
01602       PHandleAggregator * _aggregator,   
01603       unsigned id,          
01604       BOOL remoteIsNAT      
01605     ) = 0;
01606     virtual BOOL Open() = 0;
01607 };
01608 
01609 
01610 #endif // __OPAL_CONNECTION_H
01611 
01612 
01613 // End of File ///////////////////////////////////////////////////////////////

Generated on Fri Mar 7 06:33:09 2008 for OPAL by  doxygen 1.5.1