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: 22501 $
00028  * $Author: rjongbloed $
00029  * $Date: 2009-05-01 04:39:10 +0000 (Fri, 01 May 2009) $
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 
00323     bool Hold();
00324 
00327     bool Retrieve();
00328 
00331     bool IsOnHold() const;
00332 
00355     bool Transfer(
00356       const PString & address,           
00357       OpalConnection * connection = NULL 
00358     );
00360 
00371     virtual OpalMediaFormatList GetMediaFormats(
00372       const OpalConnection & connection,  
00373       PBoolean includeSpecifiedConnection     
00374     );
00375 
00385     virtual bool OpenSourceMediaStreams(
00386       OpalConnection & connection,              
00387       const OpalMediaType & mediaType,          
00388       unsigned sessionID = 0,                   
00389       const OpalMediaFormat & preselectedFormat = OpalMediaFormat()  
00390 #if OPAL_VIDEO
00391       , OpalVideoFormat::ContentRole contentRole = OpalVideoFormat::eNoRole 
00392 #endif
00393     );
00394 
00399     virtual bool SelectMediaFormats(
00400       const OpalMediaType & mediaType,        
00401       const OpalMediaFormatList & srcFormats, 
00402       const OpalMediaFormatList & dstFormats, 
00403       const OpalMediaFormatList & allFormats, 
00404       OpalMediaFormat & srcFormat,            
00405       OpalMediaFormat & dstFormat             
00406     ) const;
00407 
00415     virtual void OnRTPStatistics(
00416       const OpalConnection & connection,  
00417       const RTP_Session & session         
00418     );
00419 
00422     virtual void CloseMediaStreams();
00423     
00426     virtual PBoolean IsMediaBypassPossible(
00427       const OpalConnection & connection,  
00428       unsigned sessionID                  
00429     ) const;
00431 
00439     virtual void OnUserInputString(
00440       OpalConnection & connection,  
00441       const PString & value         
00442     );
00443 
00452     virtual void OnUserInputTone(
00453       OpalConnection & connection,  
00454       char tone,                    
00455       int duration                  
00456     );
00458 
00463     OpalManager & GetManager() const { return manager; }
00464 
00467     const PString & GetToken() const { return myToken; }
00468 
00473     const PString & GetPartyA() const { return m_partyA; }
00474 
00480     const PString & GetPartyB() const { return m_partyB; }
00481 
00487     void SetPartyB(
00488       const PString & b
00489     ) { m_partyB = b; }
00490 
00495     bool IsNetworkOriginated() const;
00496 
00499     const PTime & GetStartTime() const { return startTime; }
00501 
00502 
00508     bool StartRecording(
00509       const PFilePath & filename, 
00510       const OpalRecordManager::Options & options = false 
00511     );
00512 
00515     bool IsRecording() const;
00516 
00520     void StopRecording();
00521 
00524     virtual bool OnStartRecording(
00525       const PString & streamId,       
00526       const OpalMediaFormat & format  
00527     );
00528 
00531     virtual void OnStopRecording(
00532       const PString & streamId       
00533     );
00534 
00537     virtual void OnRecordAudio(
00538       const PString & streamId,       
00539       const RTP_DataFrame & frame     
00540     );
00541 
00544     virtual void OnRecordVideo(
00545       const PString & streamId,       
00546       const RTP_DataFrame & frame     
00547     );
00548 
00549   protected:
00550     void SetPartyNames();
00551 
00552     bool EnumerateConnections(
00553       PSafePtr<OpalConnection> & connection,
00554       PSafetyMode mode,
00555       const OpalConnection * skipConnection = NULL
00556     ) const;
00557 
00558     OpalManager & manager;
00559 
00560     PString myToken;
00561 
00562     PString m_partyA;
00563     PString m_partyB;
00564     PTime   startTime;
00565     bool    isEstablished;
00566     bool    isClearing;
00567 
00568     OpalConnection::CallEndReason callEndReason;
00569     PSyncPoint                  * endCallSyncPoint;
00570 
00571     PSafeList<OpalConnection> connectionsActive;
00572 
00573     OpalRecordManager * m_recordManager;
00574 
00575   //use to add the connection to the call's connection list
00576   friend OpalConnection::OpalConnection(OpalCall &, OpalEndPoint &, const PString &, unsigned int, OpalConnection::StringOptions *);
00577   //use to remove the connection from the call's connection list
00578   friend OpalConnection::~OpalConnection();
00579 };
00580 
00581 
00582 #endif // OPAL_OPAL_CALL_H
00583 
00584 
00585 // End of File ///////////////////////////////////////////////////////////////

Generated on Mon Aug 3 20:49:45 2009 for OPAL by  doxygen 1.5.1