OPAL
Version 3.10.4
|
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 * $Revision: 25336 $ 00028 * $Author: rjongbloed $ 00029 * $Date: 2011-03-16 03:51:39 -0500 (Wed, 16 Mar 2011) $ 00030 */ 00031 00032 #ifndef OPAL_OPAL_CALL_H 00033 #define OPAL_OPAL_CALL_H 00034 00035 #ifdef P_USE_PRAGMA 00036 #pragma interface 00037 #endif 00038 00039 #include <opal/buildopts.h> 00040 00041 #include <opal/connection.h> 00042 #include <opal/recording.h> 00043 #include <opal/guid.h> 00044 00045 #include <ptlib/safecoll.h> 00046 00047 00048 class OpalManager; 00049 00050 00065 class OpalCall : public PSafeObject 00066 { 00067 PCLASSINFO(OpalCall, PSafeObject); 00068 public: 00073 OpalCall( 00074 OpalManager & manager 00075 ); 00076 00079 ~OpalCall(); 00081 00088 void PrintOn( 00089 ostream & strm 00090 ) const; 00092 00097 PBoolean IsEstablished() const { return isEstablished; } 00098 00107 virtual void OnEstablishedCall(); 00108 00117 OpalConnection::CallEndReason GetCallEndReason() const { return callEndReason; } 00118 00121 PString GetCallEndReasonText() const { return OpalConnection::GetCallEndReasonText(callEndReason); } 00122 00127 void SetCallEndReason( 00128 OpalConnection::CallEndReason reason 00129 ); 00130 00139 void Clear( 00140 OpalConnection::CallEndReason reason = OpalConnection::EndedByLocalUser, 00141 PSyncPoint * sync = NULL 00142 ); 00143 00149 virtual void OnCleared(); 00151 00159 virtual void OnNewConnection( 00160 OpalConnection & connection 00161 ); 00162 00168 virtual PBoolean OnSetUp( 00169 OpalConnection & connection 00170 ); 00171 00186 virtual void OnProceeding( 00187 OpalConnection & connection 00188 ); 00189 00206 virtual PBoolean OnAlerting( 00207 OpalConnection & connection 00208 ); 00209 00226 virtual OpalConnection::AnswerCallResponse OnAnswerCall( 00227 OpalConnection & connection, 00228 const PString & caller 00229 ); 00230 00242 virtual PBoolean OnConnected( 00243 OpalConnection & connection 00244 ); 00245 00260 virtual PBoolean OnEstablished( 00261 OpalConnection & connection 00262 ); 00263 00269 virtual void OnReleased( 00270 OpalConnection & connection 00271 ); 00272 00279 virtual void OnHold( 00280 OpalConnection & connection, 00281 bool fromRemote, 00282 bool onHold 00283 ); 00284 00290 PSafePtr<OpalConnection> GetOtherPartyConnection( 00291 const OpalConnection & connection 00292 ) const; 00293 00296 PSafePtr<OpalConnection> GetConnection( 00297 PINDEX idx, 00298 PSafetyMode mode = PSafeReference 00299 ) { return connectionsActive.GetAt(idx, mode); } 00300 00304 template <class ConnClass> 00305 PSafePtr<ConnClass> GetConnectionAs( 00306 PINDEX count = 0, 00307 PSafetyMode mode = PSafeReadWrite 00308 ) 00309 { 00310 PSafePtr<ConnClass> connection; 00311 for (PSafePtr<OpalConnection> iterConn(connectionsActive, PSafeReference); iterConn != NULL; ++iterConn) { 00312 if ((connection = PSafePtrCast<OpalConnection, ConnClass>(iterConn)) != NULL && count-- == 0) { 00313 if (!connection.SetSafetyMode(mode)) 00314 connection.SetNULL(); 00315 break; 00316 } 00317 } 00318 return connection; 00319 } 00320 00325 bool Hold(); 00326 00331 bool Retrieve(); 00332 00337 bool IsOnHold() const; 00338 00371 bool Transfer( 00372 const PString & address, 00373 OpalConnection * connection = NULL 00374 ); 00376 00387 virtual OpalMediaFormatList GetMediaFormats( 00388 const OpalConnection & connection 00389 ); 00390 00399 virtual void AdjustMediaFormats( 00400 bool local, 00401 const OpalConnection & connection, 00402 OpalMediaFormatList & mediaFormats 00403 ) const; 00404 00414 virtual bool OpenSourceMediaStreams( 00415 OpalConnection & connection, 00416 const OpalMediaType & mediaType, 00417 unsigned sessionID = 0, 00418 const OpalMediaFormat & preselectedFormat = OpalMediaFormat() 00419 #if OPAL_VIDEO 00420 , OpalVideoFormat::ContentRole contentRole = OpalVideoFormat::eNoRole 00421 #endif 00422 ); 00423 00428 virtual bool SelectMediaFormats( 00429 const OpalMediaType & mediaType, 00430 const OpalMediaFormatList & srcFormats, 00431 const OpalMediaFormatList & dstFormats, 00432 const OpalMediaFormatList & allFormats, 00433 OpalMediaFormat & srcFormat, 00434 OpalMediaFormat & dstFormat 00435 ) const; 00436 00444 virtual void OnRTPStatistics( 00445 const OpalConnection & connection, 00446 const RTP_Session & session 00447 ); 00448 00451 virtual void StartMediaStreams(); 00452 00455 virtual void CloseMediaStreams(); 00456 00459 virtual PBoolean IsMediaBypassPossible( 00460 const OpalConnection & connection, 00461 unsigned sessionID 00462 ) const; 00464 00472 virtual void OnUserInputString( 00473 OpalConnection & connection, 00474 const PString & value 00475 ); 00476 00485 virtual void OnUserInputTone( 00486 OpalConnection & connection, 00487 char tone, 00488 int duration 00489 ); 00491 00496 OpalManager & GetManager() const { return manager; } 00497 00500 const PString & GetToken() const { return myToken; } 00501 00506 const PString & GetPartyA() const { return m_partyA; } 00507 00513 const PString & GetPartyB() const { return m_partyB; } 00514 00520 void SetPartyB( 00521 const PString & b 00522 ) { m_partyB = b; } 00523 00528 bool IsNetworkOriginated() const; 00529 00532 const PTime & GetStartTime() const { return startTime; } 00534 00535 #if OPAL_HAS_MIXER 00536 00541 bool StartRecording( 00542 const PFilePath & filename, 00543 const OpalRecordManager::Options & options = false 00544 ); 00545 00548 bool IsRecording() const; 00549 00553 void StopRecording(); 00554 00557 virtual bool OnStartRecording( 00558 const PString & streamId, 00559 const OpalMediaFormat & format 00560 ); 00561 00564 virtual void OnStopRecording( 00565 const PString & streamId 00566 ); 00567 00570 virtual void OnRecordAudio( 00571 const PString & streamId, 00572 const RTP_DataFrame & frame 00573 ); 00574 00575 #if OPAL_VIDEO 00576 00578 virtual void OnRecordVideo( 00579 const PString & streamId, 00580 const RTP_DataFrame & frame 00581 ); 00582 #endif 00583 #endif // OPAL_HAS_MIXER 00584 00585 void InternalOnClear(); 00586 00587 protected: 00588 void SetPartyNames(); 00589 00590 bool EnumerateConnections( 00591 PSafePtr<OpalConnection> & connection, 00592 PSafetyMode mode, 00593 const OpalConnection * skipConnection = NULL 00594 ) const; 00595 00596 OpalManager & manager; 00597 00598 PString myToken; 00599 00600 PString m_partyA; 00601 PString m_partyB; 00602 PTime startTime; 00603 bool isEstablished; 00604 bool isClearing; 00605 00606 OpalConnection::CallEndReason callEndReason; 00607 PSyncPoint * endCallSyncPoint; 00608 00609 PSafeList<OpalConnection> connectionsActive; 00610 00611 #if OPAL_HAS_MIXER 00612 OpalRecordManager * m_recordManager; 00613 #endif 00614 00615 //use to add the connection to the call's connection list 00616 friend OpalConnection::OpalConnection(OpalCall &, OpalEndPoint &, const PString &, unsigned int, OpalConnection::StringOptions *); 00617 //use to remove the connection from the call's connection list 00618 friend OpalConnection::~OpalConnection(); 00619 }; 00620 00621 00622 #endif // OPAL_OPAL_CALL_H 00623 00624 00625 // End of File ///////////////////////////////////////////////////////////////