localep.h

Go to the documentation of this file.
00001 /*
00002  * localep.h
00003  *
00004  * Local EndPoint/Connection.
00005  *
00006  * Open Phone Abstraction Library (OPAL)
00007  * Formally known as the Open H323 project.
00008  *
00009  * Copyright (c) 2008 Vox Lucida 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: 28040 $
00028  * $Author: rjongbloed $
00029  * $Date: 2012-07-16 01:23:59 -0500 (Mon, 16 Jul 2012) $
00030  */
00031 
00032 #ifndef OPAL_OPAL_LOCALEP_H
00033 #define OPAL_OPAL_LOCALEP_H
00034 
00035 #ifdef P_USE_PRAGMA
00036 #pragma interface
00037 #endif
00038 
00039 #include <opal/buildopts.h>
00040 
00041 #include <opal/endpoint.h>
00042 
00043 class OpalLocalConnection;
00044 
00045 
00050 class OpalLocalEndPoint : public OpalEndPoint
00051 {
00052     PCLASSINFO(OpalLocalEndPoint, OpalEndPoint);
00053   public:
00058     OpalLocalEndPoint(
00059       OpalManager & manager,        
00060       const char * prefix = "local" 
00061     );
00062 
00065     ~OpalLocalEndPoint();
00067 
00080     virtual OpalMediaFormatList GetMediaFormats() const;
00081 
00111     virtual PSafePtr<OpalConnection> MakeConnection(
00112       OpalCall & call,           
00113       const PString & party,     
00114       void * userData = NULL,    
00115       unsigned int options = 0,  
00116       OpalConnection::StringOptions * stringOptions  = NULL 
00117     );
00119 
00128     PSafePtr<OpalLocalConnection> GetLocalConnectionWithLock(
00129       const PString & token,     
00130       PSafetyMode mode = PSafeReadWrite   
00131     ) { return GetConnectionWithLockAs<OpalLocalConnection>(token, mode); }
00132 
00136     virtual OpalLocalConnection * CreateConnection(
00137       OpalCall & call,    
00138       void * userData,    
00139       unsigned options,   
00140       OpalConnection::StringOptions * stringOptions 
00141     );
00142 
00148     virtual bool OnOutgoingSetUp(
00149       const OpalLocalConnection & connection 
00150     );
00151 
00157     virtual bool OnOutgoingCall(
00158       const OpalLocalConnection & connection 
00159     );
00160 
00169     virtual bool OnIncomingCall(
00170       OpalLocalConnection & connection 
00171     );
00172 
00177     virtual bool AlertingIncomingCall(
00178       const PString & token, 
00179       OpalConnection::StringOptions * options = NULL  
00180     );
00181 
00186     virtual bool AcceptIncomingCall(
00187       const PString & token, 
00188       OpalConnection::StringOptions * options = NULL  
00189     );
00190 
00195     virtual bool RejectIncomingCall(
00196       const PString & token,                 
00197       const OpalConnection::CallEndReason & reason = OpalConnection::EndedByAnswerDenied 
00198     );
00199 
00205     virtual bool OnUserInput(
00206       const OpalLocalConnection & connection, 
00207       const PString & indication    
00208     );
00209 
00218     virtual bool OnReadMediaFrame(
00219       const OpalLocalConnection & connection, 
00220       const OpalMediaStream & mediaStream,    
00221       RTP_DataFrame & frame                   
00222     );
00223 
00232     virtual bool OnWriteMediaFrame(
00233       const OpalLocalConnection & connection, 
00234       const OpalMediaStream & mediaStream,    
00235       RTP_DataFrame & frame                   
00236     );
00237 
00246     virtual bool OnReadMediaData(
00247       const OpalLocalConnection & connection, 
00248       const OpalMediaStream & mediaStream,    
00249       void * data,                            
00250       PINDEX size,                            
00251       PINDEX & length                         
00252     );
00253 
00262     virtual bool OnWriteMediaData(
00263       const OpalLocalConnection & connection, 
00264       const OpalMediaStream & mediaStream,    
00265       const void * data,                      
00266       PINDEX length,                          
00267       PINDEX & written                        
00268     );
00269 
00291     enum Synchronicity {
00292       e_Synchronous,        
00293       e_Asynchronous,       
00294       e_SimulateSyncronous  
00295     };
00296 
00305     virtual Synchronicity GetSynchronicity(
00306       const OpalMediaFormat & mediaFormat,  
00307       bool isSource                         
00308     ) const;
00309 
00312     Synchronicity GetDefaultAudioSynchronicity() const { return m_defaultAudioSynchronicity; }
00313 
00316     void SetDefaultAudioSynchronicity(Synchronicity sync) { m_defaultAudioSynchronicity = sync; }
00317 
00320     Synchronicity GetDefaultVideoSourceSynchronicity() const { return m_defaultVideoSourceSynchronicity; }
00321 
00324     void SetDefaultVideoSourceSynchronicity(Synchronicity sync) { m_defaultVideoSourceSynchronicity = sync; }
00325 
00328     bool IsDeferredAlerting() const { return m_deferredAlerting; }
00329 
00332     void SetDeferredAlerting(bool defer) { m_deferredAlerting = defer; }
00333 
00336     bool IsDeferredAnswer() const { return m_deferredAnswer; }
00337 
00340     void SetDeferredAnswer(bool defer) { m_deferredAnswer = defer; }
00342 
00343   protected:
00344     bool m_deferredAlerting;
00345     bool m_deferredAnswer;
00346 
00347     Synchronicity m_defaultAudioSynchronicity;
00348     Synchronicity m_defaultVideoSourceSynchronicity;
00349 
00350   private:
00351     P_REMOVE_VIRTUAL(OpalLocalConnection *, CreateConnection(OpalCall &, void *), 0);
00352     P_REMOVE_VIRTUAL(bool, IsSynchronous() const, false);
00353 };
00354 
00355 
00360 class OpalLocalConnection : public OpalConnection
00361 {
00362     PCLASSINFO(OpalLocalConnection, OpalConnection);
00363   public:
00368     OpalLocalConnection(
00369       OpalCall & call,              
00370       OpalLocalEndPoint & endpoint, 
00371       void * userData,              
00372       unsigned options,             
00373       OpalConnection::StringOptions * stringOptions, 
00374       char tokenPrefix = 'L'        
00375     );
00376 
00379     ~OpalLocalConnection();
00381 
00392     virtual PBoolean IsNetworkConnection() const { return false; }
00393 
00395     virtual void OnApplyStringOptions();
00396 
00406     virtual PBoolean SetUpConnection();
00407 
00418     virtual PBoolean SetAlerting(
00419       const PString & calleeName,   
00420       PBoolean withMedia            
00421     );
00422 
00433     virtual PBoolean SetConnected();
00434 
00449     virtual OpalMediaStream * CreateMediaStream(
00450       const OpalMediaFormat & mediaFormat, 
00451       unsigned sessionID,                  
00452       PBoolean isSource                    
00453     );
00454 
00457     virtual OpalMediaStreamPtr OpenMediaStream(
00458       const OpalMediaFormat & mediaFormat, 
00459       unsigned sessionID,                  
00460       bool isSource                        
00461     );
00462 
00470     virtual PBoolean SendUserInputString(
00471       const PString & value                   
00472     );
00474 
00483     virtual bool OnOutgoingSetUp();
00484 
00491     virtual bool OnOutgoing();
00492 
00501     virtual bool OnIncoming();
00502 
00505     virtual void AlertingIncoming();
00506 
00509     virtual void AcceptIncoming();
00511 
00514 
00515     void * GetUserData() const  { return m_userData; }
00516 
00518     void SetUserData(void * v)  { m_userData = v; }
00520 
00521   protected:
00522     OpalLocalEndPoint & endpoint;
00523     void * m_userData;
00524 };
00525 
00526 
00531 class OpalLocalMediaStream : public OpalMediaStream, public OpalMediaStreamPacing
00532 {
00533     PCLASSINFO(OpalLocalMediaStream, OpalMediaStream);
00534   public:
00539     OpalLocalMediaStream(
00540       OpalLocalConnection & conn,          
00541       const OpalMediaFormat & mediaFormat, 
00542       unsigned sessionID,                  
00543       bool isSource,                       
00544       OpalLocalEndPoint::Synchronicity synchronicity 
00545     );
00547 
00555     virtual PBoolean ReadPacket(
00556       RTP_DataFrame & packet
00557     );
00558 
00564     virtual PBoolean WritePacket(
00565       RTP_DataFrame & packet
00566     );
00567 
00571     virtual PBoolean ReadData(
00572       BYTE * data,      
00573       PINDEX size,      
00574       PINDEX & length   
00575     );
00576 
00580     virtual PBoolean WriteData(
00581       const BYTE * data,   
00582       PINDEX length,       
00583       PINDEX & written     
00584     );
00585 
00589     virtual PBoolean IsSynchronous() const;
00591 
00592   protected:
00593     virtual void InternalClose() { }
00594 
00595     OpalLocalEndPoint::Synchronicity m_synchronicity;
00596 };
00597 
00598 
00599 #endif // OPAL_OPAL_LOCALEP_H
00600 
00601 
00602 // End of File ///////////////////////////////////////////////////////////////

Generated on 14 Aug 2013 for OPAL by  doxygen 1.4.7