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: 22096 $
00028  * $Author: rjongbloed $
00029  * $Date: 2009-02-21 03:25:23 +0000 (Sat, 21 Feb 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/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 
00181     virtual void OnProceeding(
00182       OpalConnection & connection   
00183     );
00184 
00201     virtual PBoolean OnAlerting(
00202       OpalConnection & connection   
00203     );
00204 
00221     virtual OpalConnection::AnswerCallResponse OnAnswerCall(
00222       OpalConnection & connection,
00223       const PString & caller
00224     );
00225 
00237     virtual PBoolean OnConnected(
00238       OpalConnection & connection   
00239     );
00240 
00255     virtual PBoolean OnEstablished(
00256       OpalConnection & connection   
00257     );
00258 
00264     virtual void OnReleased(
00265       OpalConnection & connection   
00266     );
00267 
00274     virtual void OnHold(
00275       OpalConnection & connection,   
00276       bool fromRemote,               
00277       bool onHold                    
00278     );
00279 
00285     PSafePtr<OpalConnection> GetOtherPartyConnection(
00286       const OpalConnection & connection  
00287     ) const;
00288 
00291     PSafePtr<OpalConnection> GetConnection(
00292       PINDEX idx,
00293       PSafetyMode mode = PSafeReference
00294     ) { return connectionsActive.GetAt(idx, mode); }
00295 
00299     template <class ConnClass>
00300     PSafePtr<ConnClass> GetConnectionAs(
00301       PINDEX count = 0,
00302       PSafetyMode mode = PSafeReadWrite
00303     )
00304     {
00305       PSafePtr<ConnClass> connection;
00306       for (PSafePtr<OpalConnection> iterConn(connectionsActive, PSafeReference); iterConn != NULL; ++iterConn) {
00307         if ((connection = PSafePtrCast<OpalConnection, ConnClass>(iterConn)) != NULL && count-- == 0) {
00308           if (!connection.SetSafetyMode(mode))
00309             connection.SetNULL();
00310           break;
00311         }
00312       }
00313       return connection;
00314     }
00315 
00318     bool Hold();
00319 
00322     bool Retrieve();
00323 
00326     bool IsOnHold() const;
00327 
00337     bool Transfer(
00338       OpalConnection & connection, 
00339       const PString & newAddress   
00340     );
00342 
00353     virtual OpalMediaFormatList GetMediaFormats(
00354       const OpalConnection & connection,  
00355       PBoolean includeSpecifiedConnection     
00356     );
00357 
00367     virtual bool OpenSourceMediaStreams(
00368       OpalConnection & connection,              
00369       const OpalMediaType & mediaType,          
00370       unsigned sessionID = 0,                   
00371       const OpalMediaFormat & preselectedFormat = OpalMediaFormat()  
00372     );
00373 
00378     virtual bool SelectMediaFormats(
00379       const OpalMediaFormatList & srcFormats, 
00380       const OpalMediaFormatList & dstFormats, 
00381       const OpalMediaFormatList & allFormats, 
00382       OpalMediaFormat & srcFormat,            
00383       OpalMediaFormat & dstFormat             
00384     ) const;
00385 
00393     virtual void OnRTPStatistics(
00394       const OpalConnection & connection,  
00395       const RTP_Session & session         
00396     );
00397 
00400     virtual void CloseMediaStreams();
00401     
00404     virtual PBoolean IsMediaBypassPossible(
00405       const OpalConnection & connection,  
00406       unsigned sessionID                  
00407     ) const;
00409 
00417     virtual void OnUserInputString(
00418       OpalConnection & connection,  
00419       const PString & value         
00420     );
00421 
00430     virtual void OnUserInputTone(
00431       OpalConnection & connection,  
00432       char tone,                    
00433       int duration                  
00434     );
00436 
00441     OpalManager & GetManager() const { return manager; }
00442 
00445     const PString & GetToken() const { return myToken; }
00446 
00451     const PString & GetPartyA() const { return m_partyA; }
00452 
00458     const PString & GetPartyB() const { return m_partyB; }
00459 
00465     void SetPartyB(
00466       const PString & b
00467     ) { m_partyB = b; }
00468 
00473     bool IsNetworkOriginated() const;
00474 
00477     const PTime & GetStartTime() const { return startTime; }
00479 
00480 
00486     bool StartRecording(
00487       const PFilePath & filename, 
00488       bool mono = false           
00489     );
00490 
00493     bool IsRecording() const;
00494 
00498     void StopRecording();
00499 
00502     virtual void OnRecordAudio(const PString & streamId, const RTP_DataFrame & frame);
00503 
00506     virtual void OnStopRecordAudio(const PString & streamId);
00507 
00508   protected:
00509     void SetPartyNames();
00510 
00511     bool EnumerateConnections(
00512       PSafePtr<OpalConnection> & connection,
00513       PSafetyMode mode,
00514       const OpalConnection * skipConnection = NULL
00515     ) const;
00516 
00517     OpalManager & manager;
00518 
00519     PString myToken;
00520 
00521     PString m_partyA;
00522     PString m_partyB;
00523     PTime   startTime;
00524     bool    isEstablished;
00525     bool    isClearing;
00526 
00527     OpalConnection::CallEndReason callEndReason;
00528 
00529     PSafeList<OpalConnection> connectionsActive;
00530 
00531     PSyncPoint * endCallSyncPoint;
00532 
00533     
00534   //use to add the connection to the call's connection list
00535   friend OpalConnection::OpalConnection(OpalCall &, OpalEndPoint &, const PString &, unsigned int, OpalConnection::StringOptions *);
00536   //use to remove the connection from the call's connection list
00537   friend OpalConnection::~OpalConnection();
00538 };
00539 
00540 
00541 #endif // OPAL_OPAL_CALL_H
00542 
00543 
00544 // End of File ///////////////////////////////////////////////////////////////

Generated on Mon Feb 1 00:25:19 2010 for OPAL by  doxygen 1.5.1