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: 24547 $
00028  * $Author: rjongbloed $
00029  * $Date: 2010-06-30 01:36:31 -0500 (Wed, 30 Jun 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 
00323     bool Hold();
00324 
00327     bool Retrieve();
00328 
00331     bool IsOnHold() const;
00332 
00365     bool Transfer(
00366       const PString & address,           
00367       OpalConnection * connection = NULL 
00368     );
00370 
00381     virtual OpalMediaFormatList GetMediaFormats(
00382       const OpalConnection & connection,  
00383       PBoolean includeSpecifiedConnection     
00384     );
00385 
00395     virtual bool OpenSourceMediaStreams(
00396       OpalConnection & connection,              
00397       const OpalMediaType & mediaType,          
00398       unsigned sessionID = 0,                   
00399       const OpalMediaFormat & preselectedFormat = OpalMediaFormat()  
00400 #if OPAL_VIDEO
00401       , OpalVideoFormat::ContentRole contentRole = OpalVideoFormat::eNoRole 
00402 #endif
00403     );
00404 
00409     virtual bool SelectMediaFormats(
00410       const OpalMediaType & mediaType,        
00411       const OpalMediaFormatList & srcFormats, 
00412       const OpalMediaFormatList & dstFormats, 
00413       const OpalMediaFormatList & allFormats, 
00414       OpalMediaFormat & srcFormat,            
00415       OpalMediaFormat & dstFormat             
00416     ) const;
00417 
00425     virtual void OnRTPStatistics(
00426       const OpalConnection & connection,  
00427       const RTP_Session & session         
00428     );
00429 
00432     virtual void StartMediaStreams();
00433 
00436     virtual void CloseMediaStreams();
00437 
00440     virtual PBoolean IsMediaBypassPossible(
00441       const OpalConnection & connection,  
00442       unsigned sessionID                  
00443     ) const;
00445 
00453     virtual void OnUserInputString(
00454       OpalConnection & connection,  
00455       const PString & value         
00456     );
00457 
00466     virtual void OnUserInputTone(
00467       OpalConnection & connection,  
00468       char tone,                    
00469       int duration                  
00470     );
00472 
00477     OpalManager & GetManager() const { return manager; }
00478 
00481     const PString & GetToken() const { return myToken; }
00482 
00487     const PString & GetPartyA() const { return m_partyA; }
00488 
00494     const PString & GetPartyB() const { return m_partyB; }
00495 
00501     void SetPartyB(
00502       const PString & b
00503     ) { m_partyB = b; }
00504 
00509     bool IsNetworkOriginated() const;
00510 
00513     const PTime & GetStartTime() const { return startTime; }
00515 
00516 #if OPAL_HAS_MIXER
00517 
00522     bool StartRecording(
00523       const PFilePath & filename, 
00524       const OpalRecordManager::Options & options = false 
00525     );
00526 
00529     bool IsRecording() const;
00530 
00534     void StopRecording();
00535 
00538     virtual bool OnStartRecording(
00539       const PString & streamId,       
00540       const OpalMediaFormat & format  
00541     );
00542 
00545     virtual void OnStopRecording(
00546       const PString & streamId       
00547     );
00548 
00551     virtual void OnRecordAudio(
00552       const PString & streamId,       
00553       const RTP_DataFrame & frame     
00554     );
00555 
00556 #if OPAL_VIDEO
00557 
00559     virtual void OnRecordVideo(
00560       const PString & streamId,       
00561       const RTP_DataFrame & frame     
00562     );
00563 #endif
00564 #endif // OPAL_HAS_MIXER
00565 
00566     void InternalOnClear();
00567 
00568   protected:
00569     void SetPartyNames();
00570 
00571     bool EnumerateConnections(
00572       PSafePtr<OpalConnection> & connection,
00573       PSafetyMode mode,
00574       const OpalConnection * skipConnection = NULL
00575     ) const;
00576 
00577     OpalManager & manager;
00578 
00579     PString myToken;
00580 
00581     PString m_partyA;
00582     PString m_partyB;
00583     PTime   startTime;
00584     bool    isEstablished;
00585     bool    isClearing;
00586 
00587     OpalConnection::CallEndReason callEndReason;
00588     PSyncPoint                  * endCallSyncPoint;
00589 
00590     PSafeList<OpalConnection> connectionsActive;
00591 
00592 #if OPAL_HAS_MIXER
00593     OpalRecordManager * m_recordManager;
00594 #endif
00595 
00596   //use to add the connection to the call's connection list
00597   friend OpalConnection::OpalConnection(OpalCall &, OpalEndPoint &, const PString &, unsigned int, OpalConnection::StringOptions *);
00598   //use to remove the connection from the call's connection list
00599   friend OpalConnection::~OpalConnection();
00600 };
00601 
00602 
00603 #endif // OPAL_OPAL_CALL_H
00604 
00605 
00606 // End of File ///////////////////////////////////////////////////////////////

Generated on Mon Feb 21 20:19:20 2011 for OPAL by  doxygen 1.4.7