call.h

Go to the documentation of this file.
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: 24763 $
00028  * $Author: rjongbloed $
00029  * $Date: 2010-09-29 22:17:02 -0500 (Wed, 29 Sep 2010) $
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       PBoolean includeSpecifiedConnection     
00390     );
00391 
00401     virtual bool OpenSourceMediaStreams(
00402       OpalConnection & connection,              
00403       const OpalMediaType & mediaType,          
00404       unsigned sessionID = 0,                   
00405       const OpalMediaFormat & preselectedFormat = OpalMediaFormat()  
00406 #if OPAL_VIDEO
00407       , OpalVideoFormat::ContentRole contentRole = OpalVideoFormat::eNoRole 
00408 #endif
00409     );
00410 
00415     virtual bool SelectMediaFormats(
00416       const OpalMediaType & mediaType,        
00417       const OpalMediaFormatList & srcFormats, 
00418       const OpalMediaFormatList & dstFormats, 
00419       const OpalMediaFormatList & allFormats, 
00420       OpalMediaFormat & srcFormat,            
00421       OpalMediaFormat & dstFormat             
00422     ) const;
00423 
00431     virtual void OnRTPStatistics(
00432       const OpalConnection & connection,  
00433       const RTP_Session & session         
00434     );
00435 
00438     virtual void StartMediaStreams();
00439 
00442     virtual void CloseMediaStreams();
00443 
00446     virtual PBoolean IsMediaBypassPossible(
00447       const OpalConnection & connection,  
00448       unsigned sessionID                  
00449     ) const;
00451 
00459     virtual void OnUserInputString(
00460       OpalConnection & connection,  
00461       const PString & value         
00462     );
00463 
00472     virtual void OnUserInputTone(
00473       OpalConnection & connection,  
00474       char tone,                    
00475       int duration                  
00476     );
00478 
00483     OpalManager & GetManager() const { return manager; }
00484 
00487     const PString & GetToken() const { return myToken; }
00488 
00493     const PString & GetPartyA() const { return m_partyA; }
00494 
00500     const PString & GetPartyB() const { return m_partyB; }
00501 
00507     void SetPartyB(
00508       const PString & b
00509     ) { m_partyB = b; }
00510 
00515     bool IsNetworkOriginated() const;
00516 
00519     const PTime & GetStartTime() const { return startTime; }
00521 
00522 #if OPAL_HAS_MIXER
00523 
00528     bool StartRecording(
00529       const PFilePath & filename, 
00530       const OpalRecordManager::Options & options = false 
00531     );
00532 
00535     bool IsRecording() const;
00536 
00540     void StopRecording();
00541 
00544     virtual bool OnStartRecording(
00545       const PString & streamId,       
00546       const OpalMediaFormat & format  
00547     );
00548 
00551     virtual void OnStopRecording(
00552       const PString & streamId       
00553     );
00554 
00557     virtual void OnRecordAudio(
00558       const PString & streamId,       
00559       const RTP_DataFrame & frame     
00560     );
00561 
00562 #if OPAL_VIDEO
00563 
00565     virtual void OnRecordVideo(
00566       const PString & streamId,       
00567       const RTP_DataFrame & frame     
00568     );
00569 #endif
00570 #endif // OPAL_HAS_MIXER
00571 
00572     void InternalOnClear();
00573 
00574   protected:
00575     void SetPartyNames();
00576 
00577     bool EnumerateConnections(
00578       PSafePtr<OpalConnection> & connection,
00579       PSafetyMode mode,
00580       const OpalConnection * skipConnection = NULL
00581     ) const;
00582 
00583     OpalManager & manager;
00584 
00585     PString myToken;
00586 
00587     PString m_partyA;
00588     PString m_partyB;
00589     PTime   startTime;
00590     bool    isEstablished;
00591     bool    isClearing;
00592 
00593     OpalConnection::CallEndReason callEndReason;
00594     PSyncPoint                  * endCallSyncPoint;
00595 
00596     PSafeList<OpalConnection> connectionsActive;
00597 
00598 #if OPAL_HAS_MIXER
00599     OpalRecordManager * m_recordManager;
00600 #endif
00601 
00602   //use to add the connection to the call's connection list
00603   friend OpalConnection::OpalConnection(OpalCall &, OpalEndPoint &, const PString &, unsigned int, OpalConnection::StringOptions *);
00604   //use to remove the connection from the call's connection list
00605   friend OpalConnection::~OpalConnection();
00606 };
00607 
00608 
00609 #endif // OPAL_OPAL_CALL_H
00610 
00611 
00612 // End of File ///////////////////////////////////////////////////////////////

Generated on Sun Nov 21 20:20:50 2010 for OPAL by  doxygen 1.4.7