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: 29937 $
00028  * $Author: rjongbloed $
00029  * $Date: 2013-06-12 21:03:10 -0500 (Wed, 12 Jun 2013) $
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       bool withMedia = false  
00181     );
00182 
00187     virtual bool AcceptIncomingCall(
00188       const PString & token, 
00189       OpalConnection::StringOptions * options = NULL  
00190     );
00191 
00196     virtual bool RejectIncomingCall(
00197       const PString & token,                 
00198       const OpalConnection::CallEndReason & reason = OpalConnection::EndedByAnswerDenied 
00199     );
00200 
00206     virtual bool OnUserInput(
00207       const OpalLocalConnection & connection, 
00208       const PString & indication    
00209     );
00210 
00219     virtual bool OnReadMediaFrame(
00220       const OpalLocalConnection & connection, 
00221       const OpalMediaStream & mediaStream,    
00222       RTP_DataFrame & frame                   
00223     );
00224 
00233     virtual bool OnWriteMediaFrame(
00234       const OpalLocalConnection & connection, 
00235       const OpalMediaStream & mediaStream,    
00236       RTP_DataFrame & frame                   
00237     );
00238 
00247     virtual bool OnReadMediaData(
00248       const OpalLocalConnection & connection, 
00249       const OpalMediaStream & mediaStream,    
00250       void * data,                            
00251       PINDEX size,                            
00252       PINDEX & length                         
00253     );
00254 
00274     virtual bool OnWriteMediaData(
00275       const OpalLocalConnection & connection, 
00276       const OpalMediaStream & mediaStream,    
00277       const void * data,                      
00278       PINDEX length,                          
00279       PINDEX & written                        
00280     );
00281 
00303     enum Synchronicity {
00304       e_Synchronous,        
00305       e_Asynchronous,       
00306       e_SimulateSyncronous  
00307     };
00308 
00317     virtual Synchronicity GetSynchronicity(
00318       const OpalMediaFormat & mediaFormat,  
00319       bool isSource                         
00320     ) const;
00321 
00324     Synchronicity GetDefaultAudioSynchronicity() const { return m_defaultAudioSynchronicity; }
00325 
00328     void SetDefaultAudioSynchronicity(Synchronicity sync) { m_defaultAudioSynchronicity = sync; }
00329 
00332     Synchronicity GetDefaultVideoSourceSynchronicity() const { return m_defaultVideoSourceSynchronicity; }
00333 
00336     void SetDefaultVideoSourceSynchronicity(Synchronicity sync) { m_defaultVideoSourceSynchronicity = sync; }
00337 
00340     bool IsDeferredAlerting() const { return m_deferredAlerting; }
00341 
00344     void SetDeferredAlerting(bool defer) { m_deferredAlerting = defer; }
00345 
00348     bool IsDeferredAnswer() const { return m_deferredAnswer; }
00349 
00352     void SetDeferredAnswer(bool defer) { m_deferredAnswer = defer; }
00354 
00355   protected:
00356     bool m_deferredAlerting;
00357     bool m_deferredAnswer;
00358 
00359     Synchronicity m_defaultAudioSynchronicity;
00360     Synchronicity m_defaultVideoSourceSynchronicity;
00361 
00362   private:
00363     P_REMOVE_VIRTUAL(OpalLocalConnection *, CreateConnection(OpalCall &, void *), 0);
00364     P_REMOVE_VIRTUAL(bool, IsSynchronous() const, false);
00365 };
00366 
00367 
00372 class OpalLocalConnection : public OpalConnection
00373 {
00374     PCLASSINFO(OpalLocalConnection, OpalConnection);
00375   public:
00380     OpalLocalConnection(
00381       OpalCall & call,              
00382       OpalLocalEndPoint & endpoint, 
00383       void * userData,              
00384       unsigned options,             
00385       OpalConnection::StringOptions * stringOptions, 
00386       char tokenPrefix = 'L'        
00387     );
00388 
00391     ~OpalLocalConnection();
00393 
00421     virtual PBoolean OnIncomingConnection(unsigned int options, OpalConnection::StringOptions * stringOptions);
00422 
00431     virtual PBoolean IsNetworkConnection() const { return false; }
00432 
00434     virtual void OnApplyStringOptions();
00435 
00445     virtual PBoolean SetUpConnection();
00446 
00457     virtual PBoolean SetAlerting(
00458       const PString & calleeName,   
00459       PBoolean withMedia            
00460     );
00461 
00472     virtual PBoolean SetConnected();
00473 
00488     virtual OpalMediaStream * CreateMediaStream(
00489       const OpalMediaFormat & mediaFormat, 
00490       unsigned sessionID,                  
00491       PBoolean isSource                    
00492     );
00493 
00496     virtual OpalMediaStreamPtr OpenMediaStream(
00497       const OpalMediaFormat & mediaFormat, 
00498       unsigned sessionID,                  
00499       bool isSource                        
00500     );
00501 
00509     virtual PBoolean SendUserInputString(
00510       const PString & value                   
00511     );
00513 
00522     virtual bool OnOutgoingSetUp();
00523 
00530     virtual bool OnOutgoing();
00531 
00540     virtual bool OnIncoming();
00541 
00544     virtual void AlertingIncoming(
00545       bool withMedia = false  
00546     );
00547 
00550     virtual void AcceptIncoming();
00552 
00555 
00556     void * GetUserData() const  { return m_userData; }
00557 
00559     void SetUserData(void * v)  { m_userData = v; }
00561 
00562   protected:
00563     friend class PSafeWorkNoArg<OpalLocalConnection>;
00564     void InternalAcceptIncoming();
00565 
00566     OpalLocalEndPoint & endpoint;
00567     void * m_userData;
00568 };
00569 
00570 
00575 class OpalLocalMediaStream : public OpalMediaStream, public OpalMediaStreamPacing
00576 {
00577     PCLASSINFO(OpalLocalMediaStream, OpalMediaStream);
00578   public:
00583     OpalLocalMediaStream(
00584       OpalLocalConnection & conn,          
00585       const OpalMediaFormat & mediaFormat, 
00586       unsigned sessionID,                  
00587       bool isSource,                       
00588       OpalLocalEndPoint::Synchronicity synchronicity 
00589     );
00591 
00599     virtual PBoolean ReadPacket(
00600       RTP_DataFrame & packet
00601     );
00602 
00608     virtual PBoolean WritePacket(
00609       RTP_DataFrame & packet
00610     );
00611 
00615     virtual PBoolean ReadData(
00616       BYTE * data,      
00617       PINDEX size,      
00618       PINDEX & length   
00619     );
00620 
00624     virtual PBoolean WriteData(
00625       const BYTE * data,   
00626       PINDEX length,       
00627       PINDEX & written     
00628     );
00629 
00633     virtual PBoolean IsSynchronous() const;
00635 
00636   protected:
00637     virtual void InternalClose() { }
00638 
00639     OpalLocalEndPoint::Synchronicity m_synchronicity;
00640 };
00641 
00642 
00643 #endif // OPAL_OPAL_LOCALEP_H
00644 
00645 
00646 // End of File ///////////////////////////////////////////////////////////////

Generated on 21 Jun 2013 for OPAL by  doxygen 1.4.7