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: 20801 $
00028  * $Author: rjongbloed $
00029  * $Date: 2008-09-01 03:05:12 +0000 (Mon, 01 Sep 2008) $
00030  */
00031 
00032 #ifndef __OPAL_CALL_H
00033 #define __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/guid.h>
00043 
00044 #include <ptlib/safecoll.h>
00045 
00046 
00047 class OpalManager;
00048 
00049 
00064 class OpalCall : public PSafeObject
00065 {
00066     PCLASSINFO(OpalCall, PSafeObject);
00067   public:
00072     OpalCall(
00073       OpalManager & manager   
00074     );
00075 
00078     ~OpalCall();
00080 
00087     void PrintOn(
00088       ostream & strm    
00089     ) const;
00091 
00096     PBoolean IsEstablished() const { return isEstablished; }
00097 
00106     virtual void OnEstablishedCall();
00107 
00116     OpalConnection::CallEndReason GetCallEndReason() const { return callEndReason; }
00117 
00122     void SetCallEndReason(
00123       OpalConnection::CallEndReason reason   
00124     );
00125 
00134     void Clear(
00135       OpalConnection::CallEndReason reason = OpalConnection::EndedByLocalUser, 
00136       PSyncPoint * sync = NULL                                                 
00137     );
00138 
00144     virtual void OnCleared();
00146 
00154     virtual void OnNewConnection(
00155       OpalConnection & connection   
00156     );
00157 
00163     virtual PBoolean OnSetUp(
00164       OpalConnection & connection   
00165     );
00166 
00172     virtual PBoolean OnAlerting(
00173       OpalConnection & connection   
00174     );
00175 
00192     virtual OpalConnection::AnswerCallResponse OnAnswerCall(
00193       OpalConnection & connection,
00194       const PString & caller
00195     );
00196 
00208     virtual PBoolean OnConnected(
00209       OpalConnection & connection   
00210     );
00211 
00226     virtual PBoolean OnEstablished(
00227       OpalConnection & connection   
00228     );
00229 
00235     virtual void OnReleased(
00236       OpalConnection & connection   
00237     );
00238 
00245     virtual void OnHold(
00246       OpalConnection & connection,   
00247       bool fromRemote,               
00248       bool onHold                    
00249     );
00250 
00256     PSafePtr<OpalConnection> GetOtherPartyConnection(
00257       const OpalConnection & connection  
00258     ) const;
00259 
00262     PSafePtr<OpalConnection> GetConnection(
00263       PINDEX idx,
00264       PSafetyMode mode = PSafeReference
00265     ) { return connectionsActive.GetAt(idx, mode); }
00266 
00270     template <class ConnClass>
00271     PSafePtr<ConnClass> GetConnectionAs(
00272       PINDEX count = 0,
00273       PSafetyMode mode = PSafeReadWrite
00274     )
00275     {
00276       PSafePtr<ConnClass> connection;
00277       for (PSafePtr<OpalConnection> iterConn(connectionsActive, PSafeReference); iterConn != NULL; ++iterConn) {
00278         if ((connection = PSafePtrCast<OpalConnection, ConnClass>(iterConn)) != NULL && count-- == 0) {
00279           if (!connection.SetSafetyMode(mode))
00280             connection.SetNULL();
00281           break;
00282         }
00283       }
00284       return connection;
00285     }
00286 
00289     bool Hold();
00290 
00293     bool Retrieve();
00294 
00297     bool IsOnHold() const;
00298 
00308     bool Transfer(
00309       OpalConnection & connection, 
00310       const PString & newAddress   
00311     );
00313 
00324     virtual OpalMediaFormatList GetMediaFormats(
00325       const OpalConnection & connection,  
00326       PBoolean includeSpecifiedConnection     
00327     );
00328 
00338     virtual bool OpenSourceMediaStreams(
00339       OpalConnection & connection,              
00340       const OpalMediaType & mediaType,          
00341       unsigned sessionID = 0,                   
00342       const OpalMediaFormat & preselectedFormat = OpalMediaFormat()  
00343     );
00344 
00349     virtual bool SelectMediaFormats(
00350       const OpalMediaFormatList & srcFormats, 
00351       const OpalMediaFormatList & dstFormats, 
00352       const OpalMediaFormatList & allFormats, 
00353       OpalMediaFormat & srcFormat,            
00354       OpalMediaFormat & dstFormat             
00355     ) const;
00356 
00364     virtual void OnRTPStatistics(
00365       const OpalConnection & connection,  
00366       const RTP_Session & session         
00367     );
00368 
00371     virtual void CloseMediaStreams();
00372     
00375     virtual PBoolean IsMediaBypassPossible(
00376       const OpalConnection & connection,  
00377       unsigned sessionID                  
00378     ) const;
00380 
00388     virtual void OnUserInputString(
00389       OpalConnection & connection,  
00390       const PString & value         
00391     );
00392 
00401     virtual void OnUserInputTone(
00402       OpalConnection & connection,  
00403       char tone,                    
00404       int duration                  
00405     );
00407 
00412     OpalManager & GetManager() const { return manager; }
00413 
00416     const PString & GetToken() const { return myToken; }
00417 
00422     const PString & GetPartyA() const { return m_partyA; }
00423 
00429     const PString & GetPartyB() const { return m_partyB; }
00430 
00436     void SetPartyB(
00437       const PString & b
00438     ) { m_partyB = b; }
00439 
00444     bool IsNetworkOriginated() const;
00445 
00448     const PTime & GetStartTime() const { return startTime; }
00450 
00451     virtual PBoolean StartRecording(const PFilePath & fn);
00452     virtual bool IsRecording() const;
00453     virtual void StopRecording();
00454     void OnStopRecordAudio(const PString & callToken);
00455 
00456   protected:
00457     void SetPartyNames();
00458 
00459     bool EnumerateConnections(
00460       PSafePtr<OpalConnection> & connection,
00461       PSafetyMode mode,
00462       const OpalConnection * skipConnection = NULL
00463     ) const;
00464 
00465     OpalManager & manager;
00466 
00467     PString myToken;
00468 
00469     PString m_partyA;
00470     PString m_partyB;
00471     PTime   startTime;
00472     bool    isEstablished;
00473     bool    isClearing;
00474 
00475     OpalConnection::CallEndReason callEndReason;
00476 
00477     PSafeList<OpalConnection> connectionsActive;
00478 
00479     PSyncPoint * endCallSyncPoint;
00480 
00481     
00482   //use to add the connection to the call's connection list
00483   friend OpalConnection::OpalConnection(OpalCall &, OpalEndPoint &, const PString &, unsigned int, OpalConnection::StringOptions *);
00484   //use to remove the connection from the call's connection list
00485   friend OpalConnection::~OpalConnection();
00486 };
00487 
00488 
00489 #endif // __OPAL_CALL_H
00490 
00491 
00492 // End of File ///////////////////////////////////////////////////////////////

Generated on Mon Sep 15 11:48:42 2008 for OPAL by  doxygen 1.5.1