t38proto.h

Go to the documentation of this file.
00001 /*
00002  * t38proto.h
00003  *
00004  * T.38 protocol handler
00005  *
00006  * Open Phone Abstraction Library
00007  *
00008  * Copyright (c) 2001 Equivalence Pty. Ltd.
00009  *
00010  * The contents of this file are subject to the Mozilla Public License
00011  * Version 1.0 (the "License"); you may not use this file except in
00012  * compliance with the License. You may obtain a copy of the License at
00013  * http://www.mozilla.org/MPL/
00014  *
00015  * Software distributed under the License is distributed on an "AS IS"
00016  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
00017  * the License for the specific language governing rights and limitations
00018  * under the License.
00019  *
00020  * The Original Code is Open H323 Library.
00021  *
00022  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
00023  *
00024  * Contributor(s): ______________________________________.
00025  *
00026  * $Revision: 23008 $
00027  * $Author: rjongbloed $
00028  * $Date: 2009-06-29 04:24:23 +0000 (Mon, 29 Jun 2009) $
00029  */
00030 
00031 #ifndef OPAL_T38_T38PROTO_H
00032 #define OPAL_T38_T38PROTO_H
00033 
00034 #ifdef P_USE_PRAGMA
00035 #pragma interface
00036 #endif
00037 
00038 #include <opal/buildopts.h>
00039 
00040 
00041 #if OPAL_FAX
00042 
00043 #include <ptlib/pipechan.h>
00044 
00045 #include <opal/mediafmt.h>
00046 #include <opal/mediastrm.h>
00047 #include <opal/endpoint.h>
00048 
00049 
00050 class OpalTransport;
00051 class T38_IFPPacket;
00052 class PASN_OctetString;
00053 class OpalFaxConnection;
00054 
00055 
00057 
00058 class OpalFaxConnection;
00059 
00071 class OpalFaxEndPoint : public OpalEndPoint
00072 {
00073   PCLASSINFO(OpalFaxEndPoint, OpalEndPoint);
00074   public:
00079     OpalFaxEndPoint(
00080       OpalManager & manager,        
00081       const char * g711Prefix = "fax", 
00082       const char * t38Prefix = "t38"  
00083     );
00084 
00087     ~OpalFaxEndPoint();
00089 
00090     virtual PSafePtr<OpalConnection> MakeConnection(
00091       OpalCall & call,          
00092       const PString & party,    
00093       void * userData = NULL,          
00094       unsigned int options = 0,     
00095       OpalConnection::StringOptions * stringOptions = NULL
00096     );
00097 
00100     virtual OpalFaxConnection * CreateConnection(
00101       OpalCall & call,          
00102       void * userData,
00103       OpalConnection::StringOptions * stringOptions,
00104       const PString & filename, 
00105       bool receiving,
00106       bool disableT38
00107     );
00108 
00116     virtual OpalMediaFormatList GetMediaFormats() const;
00117 
00121     virtual void AcceptIncomingConnection(
00122       const PString & connectionToken 
00123     );
00124 
00128     virtual void OnFaxCompleted(
00129       OpalFaxConnection & connection, 
00130       bool failed   
00131     );
00133 
00137     const PString & GetDefaultDirectory() const { return m_defaultDirectory; }
00138 
00141     void SetDefaultDirectory(
00142       const PString & dir    
00143     ) { m_defaultDirectory = dir; }
00144 
00145     const PString & GetT38Prefix() const { return m_t38Prefix; }
00147 
00148   protected:
00149     PString    m_t38Prefix;
00150     PDirectory m_defaultDirectory;
00151 };
00152 
00153 
00155 
00158 class OpalFaxConnection : public OpalConnection
00159 {
00160   PCLASSINFO(OpalFaxConnection, OpalConnection);
00161   public:
00166     OpalFaxConnection(
00167       OpalCall & call,                 
00168       OpalFaxEndPoint & endpoint,      
00169       const PString & filename,        
00170       bool receiving,                  
00171       bool disableT38,                 
00172       OpalConnection::StringOptions * stringOptions = NULL
00173     );
00174 
00177     ~OpalFaxConnection();
00179 
00182     virtual PString GetPrefixName() const;
00183 
00192     virtual bool IsNetworkConnection() const { return false; }
00193 
00194     virtual void ApplyStringOptions(OpalConnection::StringOptions & stringOptions);
00195     virtual OpalMediaFormatList GetMediaFormats() const;
00196     virtual void AdjustMediaFormats(OpalMediaFormatList & mediaFormats) const;
00197 
00204     virtual PBoolean SetUpConnection();
00205 
00216     virtual PBoolean SetAlerting(
00217       const PString & calleeName,   
00218       PBoolean withMedia                
00219     );
00220 
00221     virtual PBoolean SetConnected();
00222     virtual void OnEstablished();
00223     virtual void OnReleased();
00224     virtual OpalMediaStream * CreateMediaStream(const OpalMediaFormat & mediaFormat, unsigned sessionID, PBoolean isSource);
00225     virtual void OnMediaPatchStop(
00226       unsigned sessionId, 
00227           bool isSource
00228     );
00229     virtual PBoolean SendUserInputTone(
00230       char tone,
00231       unsigned duration
00232     );
00233 
00238     virtual void AcceptIncoming();
00239 
00243     virtual void OnFaxCompleted(
00244       bool failed   
00245     );
00246 
00249     bool IsReceive() const { return m_receiving; }
00251 
00252   protected:
00253     PDECLARE_NOTIFIER(PTimer,  OpalFaxConnection, OnSendCNGCED);
00254     PDECLARE_NOTIFIER(PThread, OpalFaxConnection, OpenFaxStreams);
00255     void RequestFax(bool toFax);
00256 
00257 
00258     OpalFaxEndPoint & m_endpoint;
00259     PString           m_filename;
00260     bool              m_receiving;
00261     PString           m_stationId;
00262     bool              m_disableT38;
00263     PTimeInterval     m_releaseTimeout;
00264     PTimeInterval     m_switchTimeout;
00265     OpalMediaFormat   m_tiffFileFormat;
00266 
00267     bool     m_faxMode;  // false if audio preamble, true if in TIFF->fax mode
00268     PTimer   m_faxTimer;
00269 
00270   friend class OpalFaxMediaStream;
00271 };
00272 
00273 
00274 typedef OpalFaxConnection OpalT38Connection; // For backward compatibility
00275 
00276 
00277 #endif // OPAL_FAX
00278 
00279 #endif // OPAL_T38_T38PROTO_H

Generated on Mon Aug 3 20:50:25 2009 for OPAL by  doxygen 1.5.1