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: 24787 $
00028  * $Author: rjongbloed $
00029  * $Date: 2010-10-11 17:52:01 -0500 (Mon, 11 Oct 2010) $
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 OnOutgoingCall(
00149       const OpalLocalConnection & connection 
00150     );
00151 
00157     virtual bool OnIncomingCall(
00158       OpalLocalConnection & connection 
00159     );
00160 
00165     virtual bool AlertingIncomingCall(
00166       const PString & token 
00167     );
00168 
00173     virtual bool AcceptIncomingCall(
00174       const PString & token 
00175     );
00176 
00181     virtual bool RejectIncomingCall(
00182       const PString & token,                 
00183       const OpalConnection::CallEndReason & reason = OpalConnection::EndedByAnswerDenied 
00184     );
00185 
00191     virtual bool OnUserInput(
00192       const OpalLocalConnection & connection, 
00193       const PString & indication    
00194     );
00195 
00201     virtual bool OnReadMediaFrame(
00202       const OpalLocalConnection & connection, 
00203       const OpalMediaStream & mediaStream,    
00204       RTP_DataFrame & frame                   
00205     );
00206 
00213     virtual bool OnWriteMediaFrame(
00214       const OpalLocalConnection & connection, 
00215       const OpalMediaStream & mediaStream,    
00216       RTP_DataFrame & frame                   
00217     );
00218 
00224     virtual bool OnReadMediaData(
00225       const OpalLocalConnection & connection, 
00226       const OpalMediaStream & mediaStream,    
00227       void * data,                            
00228       PINDEX size,                            
00229       PINDEX & length                         
00230     );
00231 
00237     virtual bool OnWriteMediaData(
00238       const OpalLocalConnection & connection, 
00239       const OpalMediaStream & mediaStream,    
00240       const void * data,                      
00241       PINDEX length,                          
00242       PINDEX & written                        
00243     );
00244 
00257     virtual bool IsSynchronous() const;
00258 
00261     bool IsDeferredAlerting() const { return m_deferredAlerting; }
00262 
00265     void SetDeferredAlerting(bool defer) { m_deferredAlerting = defer; }
00266 
00269     bool IsDeferredAnswer() const { return m_deferredAnswer; }
00270 
00273     void SetDeferredAnswer(bool defer) { m_deferredAnswer = defer; }
00275 
00276   protected:
00277     bool m_deferredAlerting;
00278     bool m_deferredAnswer;
00279 
00280   private:
00281     P_REMOVE_VIRTUAL(OpalLocalConnection *, CreateConnection(OpalCall &, void *), 0);
00282 };
00283 
00284 
00289 class OpalLocalConnection : public OpalConnection
00290 {
00291     PCLASSINFO(OpalLocalConnection, OpalConnection);
00292   public:
00297     OpalLocalConnection(
00298       OpalCall & call,              
00299       OpalLocalEndPoint & endpoint, 
00300       void * userData,              
00301       unsigned options,             
00302       OpalConnection::StringOptions * stringOptions, 
00303       char tokenPrefix = 'L'        
00304     );
00305 
00308     ~OpalLocalConnection();
00310 
00321     virtual PBoolean IsNetworkConnection() const { return false; }
00322 
00329     virtual PBoolean SetUpConnection();
00330 
00341     virtual PBoolean SetAlerting(
00342       const PString & calleeName,   
00343       PBoolean withMedia            
00344     );
00345 
00356     virtual PBoolean SetConnected();
00357 
00372     virtual OpalMediaStream * CreateMediaStream(
00373       const OpalMediaFormat & mediaFormat, 
00374       unsigned sessionID,                  
00375       PBoolean isSource                    
00376     );
00377 
00380     virtual OpalMediaStreamPtr OpenMediaStream(
00381       const OpalMediaFormat & mediaFormat, 
00382       unsigned sessionID,                  
00383       bool isSource                        
00384     );
00385 
00393     virtual PBoolean SendUserInputString(
00394       const PString & value                   
00395     );
00397 
00402     virtual void AlertingIncoming();
00403 
00406     virtual void AcceptIncoming();
00408 
00411 
00412     void * GetUserData() const  { return userData; }
00413 
00415     void SetUserData(void * v)  { userData = v; }
00417 
00418   protected:
00419     OpalLocalEndPoint & endpoint;
00420     void * userData;
00421 };
00422 
00423 
00428 class OpalLocalMediaStream : public OpalMediaStream, public OpalMediaStreamPacing
00429 {
00430     PCLASSINFO(OpalLocalMediaStream, OpalMediaStream);
00431   public:
00436     OpalLocalMediaStream(
00437       OpalLocalConnection & conn,          
00438       const OpalMediaFormat & mediaFormat, 
00439       unsigned sessionID,                  
00440       bool isSource,                       
00441       bool isSynchronous                   
00442     );
00444 
00452     virtual PBoolean ReadPacket(
00453       RTP_DataFrame & packet
00454     );
00455 
00461     virtual PBoolean WritePacket(
00462       RTP_DataFrame & packet
00463     );
00464 
00468     virtual PBoolean ReadData(
00469       BYTE * data,      
00470       PINDEX size,      
00471       PINDEX & length   
00472     );
00473 
00477     virtual PBoolean WriteData(
00478       const BYTE * data,   
00479       PINDEX length,       
00480       PINDEX & written     
00481     );
00482 
00486     virtual PBoolean IsSynchronous() const;
00488 
00489   protected:
00490     bool m_isSynchronous;
00491 };
00492 
00493 
00494 #endif // OPAL_OPAL_LOCALEP_H
00495 
00496 
00497 // End of File ///////////////////////////////////////////////////////////////

Generated on Sun Nov 21 20:20:50 2010 for OPAL by  doxygen 1.4.7