00001 /* 00002 * call.h 00003 * 00004 * Telephone call management 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): ______________________________________. 00026 * 00027 * $Log: call.h,v $ 00028 * Revision 2.32 2007/09/20 04:32:36 rjongbloed 00029 * Fixed issue with clearing a call before it has finished setting up. 00030 * 00031 * Revision 2.31 2007/09/18 09:37:52 rjongbloed 00032 * Propagated call backs for RTP statistics through OpalManager and OpalCall. 00033 * 00034 * Revision 2.30 2007/05/07 14:13:51 csoutheren 00035 * Add call record capability 00036 * 00037 * Revision 2.29 2007/04/16 06:48:04 rjongbloed 00038 * Added virtual to OpalCall::GetMediaFormats to allow user override. 00039 * 00040 * Revision 2.28 2007/04/03 05:27:29 rjongbloed 00041 * Cleaned up somewhat confusing usage of the OnAnswerCall() virtual 00042 * function. The name is innaccurate and exists as a legacy from the 00043 * OpenH323 days. it now only indicates how alerting is done 00044 * (with/without media) and does not actually answer the call. 00045 * 00046 * Revision 2.27 2007/01/18 04:45:16 csoutheren 00047 * Messy, but simple change to add additional options argument to OpalConnection constructor 00048 * This allows the provision of non-trivial arguments for connections 00049 * 00050 * Revision 2.26 2006/12/18 03:18:41 csoutheren 00051 * Messy but simple fixes 00052 * - Add access to SIP REGISTER timeout 00053 * - Ensure OpalConnection options are correctly progagated 00054 * 00055 * Revision 2.25 2006/06/30 00:49:06 csoutheren 00056 * Applied 1469865 - remove connection from call's connection list 00057 * Thanks to Frederich Heem 00058 * 00059 * Revision 2.24 2005/11/30 13:35:26 csoutheren 00060 * Changed tags for Doxygen 00061 * 00062 * Revision 2.23 2005/10/22 12:16:05 dsandras 00063 * Moved mutex preventing media streams to be opened before they are completely closed to the SIPConnection class. 00064 * 00065 * Revision 2.22 2005/09/22 17:08:52 dsandras 00066 * Added mutex to protect media streams access and prevent media streams for a call to be closed before they are all opened. 00067 * 00068 * Revision 2.21 2005/08/04 17:21:48 dsandras 00069 * Added functions to close/remove the media streams of a call. 00070 * 00071 * Revision 2.20 2005/07/11 01:52:23 csoutheren 00072 * Extended AnsweringCall to work for SIP as well as H.323 00073 * Fixed problems with external RTP connection in H.323 00074 * Added call to OnClosedMediaStream 00075 * 00076 * Revision 2.19 2005/05/11 04:25:09 dereksmithies 00077 * Add description of the OpalConnection class instances managed by an OpalCall structure. 00078 * 00079 * Revision 2.18 2004/08/14 07:56:29 rjongbloed 00080 * Major revision to utilise the PSafeCollection classes for the connections and calls. 00081 * 00082 * Revision 2.17 2004/07/14 13:26:14 rjongbloed 00083 * Fixed issues with the propagation of the "established" phase of a call. Now 00084 * calling an OnEstablished() chain like OnAlerting() and OnConnected() to 00085 * finally arrive at OnEstablishedCall() on OpalManager 00086 * 00087 * Revision 2.16 2004/05/01 10:00:50 rjongbloed 00088 * Fixed ClearCallSynchronous so now is actually signalled when call is destroyed. 00089 * 00090 * Revision 2.15 2004/04/18 07:09:12 rjongbloed 00091 * Added a couple more API functions to bring OPAL into line with similar functions in OpenH323. 00092 * 00093 * Revision 2.14 2004/03/11 06:54:27 csoutheren 00094 * Added ability to disable SIP or H.323 stacks 00095 * 00096 * Revision 2.13 2004/02/07 00:35:46 rjongbloed 00097 * Fixed calls GetMediaFormats so no DOES return intersection of all connections formats. 00098 * Tidied some API elements to make usage more explicit. 00099 * 00100 * Revision 2.12 2003/06/02 03:13:28 rjongbloed 00101 * Made changes so that media stream in opposite direction to the one already 00102 * opened will use same media format for preference. That is try and use 00103 * symmetric codecs if possible. 00104 * 00105 * Revision 2.11 2003/03/06 03:57:46 robertj 00106 * IVR support (work in progress) requiring large changes everywhere. 00107 * 00108 * Revision 2.10 2002/11/10 11:33:17 robertj 00109 * Updated to OpenH323 v1.10.3 00110 * 00111 * Revision 2.9 2002/09/16 02:52:35 robertj 00112 * Added #define so can select if #pragma interface/implementation is used on 00113 * platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan. 00114 * 00115 * Revision 2.8 2002/04/08 02:40:13 robertj 00116 * Fixed issues with using double originate call, eg from simple app command line. 00117 * 00118 * Revision 2.7 2002/02/19 07:42:25 robertj 00119 * Restructured media bypass functions to fix problems with RFC2833. 00120 * 00121 * Revision 2.6 2002/02/11 07:38:01 robertj 00122 * Added media bypass for streams between compatible protocols. 00123 * 00124 * Revision 2.5 2002/01/22 05:03:47 robertj 00125 * Revamp of user input API triggered by RFC2833 support 00126 * 00127 * Revision 2.4 2001/11/15 07:02:12 robertj 00128 * Changed OpalCall::OpenSourceMediaStreams so the connection to not open 00129 * a media stream on is optional. 00130 * 00131 * Revision 2.3 2001/08/22 10:20:09 robertj 00132 * Changed connection locking to use double mutex to guarantee that 00133 * no threads can ever deadlock or access deleted connection. 00134 * 00135 * Revision 2.2 2001/08/17 08:24:33 robertj 00136 * Added call end reason for whole call, not just connection. 00137 * 00138 * Revision 2.1 2001/08/01 05:28:59 robertj 00139 * Added function to get all media formats possible in a call. 00140 * 00141 * Revision 2.0 2001/07/27 15:48:24 robertj 00142 * Conversion of OpenH323 to Open Phone Abstraction Library (OPAL) 00143 * 00144 */ 00145 00146 #ifndef __OPAL_CALL_H 00147 #define __OPAL_CALL_H 00148 00149 #ifdef P_USE_PRAGMA 00150 #pragma interface 00151 #endif 00152 00153 #include <opal/buildopts.h> 00154 00155 #include <opal/connection.h> 00156 #include <opal/guid.h> 00157 00158 #include <ptlib/safecoll.h> 00159 00160 00161 class OpalManager; 00162 00163 00178 class OpalCall : public PSafeObject 00179 { 00180 PCLASSINFO(OpalCall, PSafeObject); 00181 public: 00186 OpalCall( 00187 OpalManager & manager 00188 ); 00189 00192 ~OpalCall(); 00194 00201 void PrintOn( 00202 ostream & strm 00203 ) const; 00205 00210 BOOL IsEstablished() const { return isEstablished; } 00211 00217 virtual void OnEstablishedCall(); 00218 00227 OpalConnection::CallEndReason GetCallEndReason() const { return callEndReason; } 00228 00233 void SetCallEndReason( 00234 OpalConnection::CallEndReason reason 00235 ); 00236 00245 void Clear( 00246 OpalConnection::CallEndReason reason = OpalConnection::EndedByLocalUser, 00247 PSyncPoint * sync = NULL 00248 ); 00249 00255 virtual void OnCleared(); 00257 00265 virtual BOOL OnSetUp( 00266 OpalConnection & connection 00267 ); 00268 00274 virtual BOOL OnAlerting( 00275 OpalConnection & connection 00276 ); 00277 00294 virtual OpalConnection::AnswerCallResponse OnAnswerCall( 00295 OpalConnection & connection, 00296 const PString & caller 00297 ); 00298 00310 virtual BOOL OnConnected( 00311 OpalConnection & connection 00312 ); 00313 00327 virtual BOOL OnEstablished( 00328 OpalConnection & connection 00329 ); 00330 00336 virtual void OnReleased( 00337 OpalConnection & connection 00338 ); 00339 00345 PSafePtr<OpalConnection> GetOtherPartyConnection( 00346 const OpalConnection & connection 00347 ) const; 00348 00351 PSafePtr<OpalConnection> GetConnection( 00352 PINDEX idx, 00353 PSafetyMode mode = PSafeReference 00354 ) { return connectionsActive.GetAt(idx, mode); } 00356 00367 virtual OpalMediaFormatList GetMediaFormats( 00368 const OpalConnection & connection, 00369 BOOL includeSpecifiedConnection 00370 ); 00371 00377 virtual BOOL OpenSourceMediaStreams( 00378 const OpalConnection & connection, 00379 const OpalMediaFormatList & mediaFormats, 00380 unsigned sessionID 00381 ); 00382 00388 virtual BOOL PatchMediaStreams( 00389 const OpalConnection & connection, 00390 OpalMediaStream & source 00391 ); 00392 00400 virtual void OnRTPStatistics( 00401 const OpalConnection & connection, 00402 const RTP_Session & session 00403 ); 00404 00407 virtual void CloseMediaStreams(); 00408 00411 virtual void RemoveMediaStreams(); 00412 00415 virtual BOOL IsMediaBypassPossible( 00416 const OpalConnection & connection, 00417 unsigned sessionID 00418 ) const; 00420 00428 virtual void OnUserInputString( 00429 OpalConnection & connection, 00430 const PString & value 00431 ); 00432 00441 virtual void OnUserInputTone( 00442 OpalConnection & connection, 00443 char tone, 00444 int duration 00445 ); 00447 00452 OpalManager & GetManager() const { return manager; } 00453 00456 const PString & GetToken() const { return myToken; } 00457 00462 const PString & GetPartyA() const { return partyA; } 00463 00469 const PString & GetPartyB() const { return partyB; } 00470 00476 void SetPartyB( 00477 const PString & b 00478 ) { partyB = b; } 00479 00482 const PTime & GetStartTime() const { return startTime; } 00484 00485 virtual BOOL StartRecording(const PFilePath & fn); 00486 virtual void StopRecording(); 00487 void OnStopRecordAudio(const PString & callToken); 00488 00489 protected: 00490 OpalManager & manager; 00491 00492 PString myToken; 00493 00494 PString partyA; 00495 PString partyB; 00496 PTime startTime; 00497 BOOL isEstablished; 00498 BOOL isClearing; 00499 00500 OpalConnection::CallEndReason callEndReason; 00501 00502 PSafeList<OpalConnection> connectionsActive; 00503 00504 PSyncPoint * endCallSyncPoint; 00505 00506 00507 //use to add the connection to the call's connection list 00508 friend OpalConnection::OpalConnection(OpalCall &, OpalEndPoint &, const PString &, unsigned int, OpalConnection::StringOptions *); 00509 //use to remove the connection from the call's connection list 00510 friend OpalConnection::~OpalConnection(); 00511 }; 00512 00513 00514 #endif // __OPAL_CALL_H 00515 00516 00517 // End of File ///////////////////////////////////////////////////////////////