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: 29572 $
00028  * $Author: rjongbloed $
00029  * $Date: 2013-04-24 23:28:21 -0500 (Wed, 24 Apr 2013) $
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 m_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     PINDEX GetConnectionCount() const { return connectionsActive.GetSize(); }
00297 
00300     PSafePtr<OpalConnection> GetConnection(
00301       PINDEX idx,
00302       PSafetyMode mode = PSafeReference
00303     ) { return connectionsActive.GetAt(idx, mode); }
00304 
00308     template <class ConnClass>
00309     PSafePtr<ConnClass> GetConnectionAs(
00310       PINDEX count = 0,
00311       PSafetyMode mode = PSafeReadWrite
00312     )
00313     {
00314       PSafePtr<ConnClass> connection;
00315       for (PSafePtr<OpalConnection> iterConn(connectionsActive, PSafeReference); iterConn != NULL; ++iterConn) {
00316         if ((connection = PSafePtrCast<OpalConnection, ConnClass>(iterConn)) != NULL && count-- == 0) {
00317           if (!connection.SetSafetyMode(mode))
00318             connection.SetNULL();
00319           break;
00320         }
00321       }
00322       return connection;
00323     }
00324 
00329     bool Hold();
00330 
00335     bool Retrieve();
00336 
00341     bool IsOnHold() const;
00342 
00375     bool Transfer(
00376       const PString & address,           
00377       OpalConnection * connection = NULL 
00378     );
00380 
00391     virtual OpalMediaFormatList GetMediaFormats(
00392       const OpalConnection & connection  
00393     );
00394 
00403     virtual void AdjustMediaFormats(
00404       bool local,                         
00405       const OpalConnection & connection,  
00406       OpalMediaFormatList & mediaFormats  
00407     ) const;
00408 
00418     virtual bool OpenSourceMediaStreams(
00419       OpalConnection & connection,              
00420       const OpalMediaType & mediaType,          
00421       unsigned sessionID = 0,                   
00422       const OpalMediaFormat & preselectedFormat = OpalMediaFormat(),  
00423 #if OPAL_VIDEO
00424       OpalVideoFormat::ContentRole contentRole = OpalVideoFormat::eNoRole, 
00425 #endif
00426       bool transfer = false
00427     );
00428 
00433     virtual bool SelectMediaFormats(
00434       const OpalMediaType & mediaType,        
00435       const OpalMediaFormatList & srcFormats, 
00436       const OpalMediaFormatList & dstFormats, 
00437       const OpalMediaFormatList & allFormats, 
00438       OpalMediaFormat & srcFormat,            
00439       OpalMediaFormat & dstFormat             
00440     ) const;
00441 
00444     virtual void StartMediaStreams();
00445 
00448     virtual void CloseMediaStreams();
00450 
00458     virtual void OnUserInputString(
00459       OpalConnection & connection,  
00460       const PString & value         
00461     );
00462 
00471     virtual void OnUserInputTone(
00472       OpalConnection & connection,  
00473       char tone,                    
00474       int duration                  
00475     );
00477 
00482     OpalManager & GetManager() const { return manager; }
00483 
00486     const PString & GetToken() const { return myToken; }
00487 
00492     const PString & GetPartyA() const { return m_partyA; }
00493 
00499     const PString & GetPartyB() const { return m_partyB; }
00500 
00506     void SetPartyB(
00507       const PString & b
00508     ) { m_partyB = b; }
00509 
00514     const PString & GetNameA() const { return m_nameA; }
00515 
00521     const PString & GetNameB() const { return m_nameB; }
00522 
00527     bool IsNetworkOriginated() const { return m_networkOriginated; }
00528 
00531     const PString & GetRemoteParty() const { return m_networkOriginated ? m_partyA : m_partyB; }
00532 
00535     const PString & GetLocalParty() const { return m_networkOriginated ? m_partyB : m_partyA; }
00536 
00539     const PString & GetRemoteName() const { return m_networkOriginated ? m_nameA : m_nameB; }
00540 
00543     const PString & GetLocalName() const { return m_networkOriginated ? m_nameB : m_nameA; }
00544 
00547     const PTime & GetStartTime() const { return m_startTime; }
00548 
00551     const PTime & GetEstablishedTime() const { return m_establishedTime; }
00553 
00554 #if OPAL_HAS_MIXER
00555 
00560     bool StartRecording(
00561       const PFilePath & filename, 
00562       const OpalRecordManager::Options & options = false 
00563     );
00564 
00567     bool IsRecording() const;
00568 
00572     void StopRecording();
00573 
00576     virtual bool OnStartRecording(
00577       const PString & streamId,       
00578       const OpalMediaFormat & format  
00579     );
00580 
00583     virtual void OnStopRecording(
00584       const PString & streamId       
00585     );
00586 
00589     virtual void OnRecordAudio(
00590       const PString & streamId,       
00591       const RTP_DataFrame & frame     
00592     );
00593 
00594 #if OPAL_VIDEO
00595 
00597     virtual void OnRecordVideo(
00598       const PString & streamId,       
00599       const RTP_DataFrame & frame     
00600     );
00601 #endif
00602 #endif // OPAL_HAS_MIXER
00603 
00604     void InternalOnClear();
00605 
00606     void SetPartyNames();
00607 
00608 #if OPAL_T38_CAPABILITY
00609     bool IsSwitchingT38()     const { return m_T38SwitchState != e_NotSwitchingT38; }
00610     bool IsSwitchingToT38()   const { return m_T38SwitchState == e_SwitchingToT38;  }
00611     void ResetSwitchingT38()        { m_T38SwitchState = e_NotSwitchingT38; }
00612     void SetSwitchingT38(bool to)   { m_T38SwitchState = to ? e_SwitchingToT38 : e_SwitchingFromT38; }
00613 #endif
00614 
00615   protected:
00616     bool EnumerateConnections(
00617       PSafePtr<OpalConnection> & connection,
00618       PSafetyMode mode,
00619       const OpalConnection * skipConnection = NULL
00620     ) const;
00621 
00622     OpalManager & manager;
00623 
00624     PString myToken;
00625 
00626     PString m_partyA;
00627     PString m_partyB;
00628     PString m_nameA;
00629     PString m_nameB;
00630     bool    m_networkOriginated;
00631     PTime   m_startTime;
00632     PTime   m_establishedTime;
00633     bool    m_isEstablished;
00634     bool    m_isClearing;
00635     PAtomicBoolean m_isCleared;
00636 
00637     OpalConnection::CallEndReason callEndReason;
00638     std::list<PSyncPoint *> m_endCallSyncPoint;
00639 
00640     PSafeList<OpalConnection> connectionsActive;
00641 
00642 #if OPAL_HAS_MIXER
00643     OpalRecordManager * m_recordManager;
00644 #endif
00645 
00646 #if OPAL_SCRIPT
00647     PDECLARE_ScriptFunctionNotifier(OpalCall, ScriptClear);
00648 #endif
00649 
00650 #if OPAL_T38_CAPABILITY
00651     enum {
00652       e_NotSwitchingT38,
00653       e_SwitchingToT38,
00654       e_SwitchingFromT38
00655     } m_T38SwitchState;
00656 #endif
00657 
00658   //use to add the connection to the call's connection list
00659   friend OpalConnection::OpalConnection(OpalCall &, OpalEndPoint &, const PString &, unsigned int, OpalConnection::StringOptions *);
00660   //use to remove the connection from the call's connection list
00661   friend OpalConnection::~OpalConnection();
00662 
00663   P_REMOVE_VIRTUAL_VOID(OnRTPStatistics(const OpalConnection &, const OpalRTPSession &));
00664 };
00665 
00666 
00667 #endif // OPAL_OPAL_CALL_H
00668 
00669 
00670 // End of File ///////////////////////////////////////////////////////////////

Generated on 21 Jun 2013 for OPAL by  doxygen 1.4.7