OPAL Version 3.10.2
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: 26102 $
00027  * $Author: rjongbloed $
00028  * $Date: 2011-06-30 00:00:16 -0500 (Thu, 30 Jun 2011) $
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/localep.h>
00048 
00049 
00050 class OpalTransport;
00051 class T38_IFPPacket;
00052 class PASN_OctetString;
00053 class OpalFaxConnection;
00054 
00055 
00056 #define OPAL_OPT_STATION_ID  "Station-Id"      ///< String option for fax station ID string
00057 #define OPAL_OPT_HEADER_INFO "Header-Info"     ///< String option for transmitted fax page header
00058 #define OPAL_NO_G111_FAX     "No-G711-Fax"     ///< Suppress G.711 fall back
00059 #define OPAL_SWITCH_ON_CED   "Switch-On-CED"   ///< Try switch to T.38 on receipt of CED tone
00060 #define OPAL_T38_SWITCH_TIME "T38-Switch-Time" ///< Seconds for fail safe switch to T.38 mode
00061 
00062 #define OPAL_FAX_TIFF_FILE "TIFF-File"
00063 
00064 
00066 
00067 class OpalFaxConnection;
00068 
00080 class OpalFaxEndPoint : public OpalLocalEndPoint
00081 {
00082   PCLASSINFO(OpalFaxEndPoint, OpalLocalEndPoint);
00083   public:
00088     OpalFaxEndPoint(
00089       OpalManager & manager,        
00090       const char * g711Prefix = "fax", 
00091       const char * t38Prefix = "t38"  
00092     );
00093 
00096     ~OpalFaxEndPoint();
00098 
00101     virtual PSafePtr<OpalConnection> MakeConnection(
00102       OpalCall & call,          
00103       const PString & party,    
00104       void * userData = NULL,          
00105       unsigned int options = 0,     
00106       OpalConnection::StringOptions * stringOptions = NULL  
00107     );
00108 
00116     virtual OpalMediaFormatList GetMediaFormats() const;
00118 
00123     virtual bool IsAvailable() const;
00124 
00127     virtual OpalFaxConnection * CreateConnection(
00128       OpalCall & call,          
00129       void * userData,          
00130       OpalConnection::StringOptions * stringOptions, 
00131       const PString & filename, 
00132       bool receiving,           
00133       bool disableT38           
00134     );
00135 
00139     virtual void OnFaxCompleted(
00140       OpalFaxConnection & connection, 
00141       bool failed   
00142     );
00144 
00148     const PString & GetDefaultDirectory() const { return m_defaultDirectory; }
00149 
00152     void SetDefaultDirectory(
00153       const PString & dir    
00154     ) { m_defaultDirectory = dir; }
00155 
00156     const PString & GetT38Prefix() const { return m_t38Prefix; }
00158 
00159   protected:
00160     PString    m_t38Prefix;
00161     PDirectory m_defaultDirectory;
00162 };
00163 
00164 
00166 
00183 class OpalFaxConnection : public OpalLocalConnection
00184 {
00185   PCLASSINFO(OpalFaxConnection, OpalLocalConnection);
00186   public:
00191     OpalFaxConnection(
00192       OpalCall & call,                 
00193       OpalFaxEndPoint & endpoint,      
00194       const PString & filename,        
00195       bool receiving,                  
00196       bool disableT38,                 
00197       OpalConnection::StringOptions * stringOptions = NULL  
00198     );
00199 
00202     ~OpalFaxConnection();
00204 
00207     virtual PString GetPrefixName() const;
00208 
00209     virtual OpalMediaFormatList GetMediaFormats() const;
00210     virtual void AdjustMediaFormats(bool local, const OpalConnection * otherConnection, OpalMediaFormatList & mediaFormats) const;
00211     virtual void OnEstablished();
00212     virtual void OnReleased();
00213     virtual OpalMediaStream * CreateMediaStream(const OpalMediaFormat & mediaFormat, unsigned sessionID, PBoolean isSource);
00214     virtual void OnStartMediaPatch(OpalMediaPatch & patch);
00215     virtual void OnStopMediaPatch(OpalMediaPatch & patch);
00216     virtual PBoolean SendUserInputTone(char tone, unsigned duration);
00217     virtual void OnUserInputTone(char tone, unsigned duration);
00218     virtual bool SwitchFaxMediaStreams(bool enableFax);
00219     virtual void OnSwitchedFaxMediaStreams(bool enabledFax);
00221 
00227     virtual void OnFaxCompleted(
00228       bool failed   
00229     );
00230 
00231 #if OPAL_STATISTICS
00232 
00234     virtual void GetStatistics(
00235       OpalMediaStatistics & statistics  
00236     ) const;
00237 #endif
00238 
00241     const PString & GetFileName() const { return m_filename; }
00242 
00245     bool IsReceive() const { return m_receiving; }
00247 
00248   protected:
00249     PDECLARE_NOTIFIER(PTimer,  OpalFaxConnection, OnSwitchTimeout);
00250     PDECLARE_NOTIFIER(PThread, OpalFaxConnection, OpenFaxStreams);
00251     void SetFaxMediaFormatOptions(OpalMediaFormat & mediaFormat) const;
00252 
00253 
00254     OpalFaxEndPoint & m_endpoint;
00255     PString           m_filename;
00256     bool              m_receiving;
00257     bool              m_disableT38;
00258     OpalMediaFormat   m_tiffFileFormat;
00259 #if OPAL_STATISTICS
00260     void InternalGetStatistics(OpalMediaStatistics & statistics, bool terminate) const;
00261     OpalMediaStatistics m_finalStatistics;
00262 #endif
00263 
00264     enum {
00265       e_AwaitingSwitchToT38,
00266       e_SwitchingToT38,
00267       e_CompletedSwitch
00268     } m_state;
00269 
00270     PTimer m_switchTimer;
00271 
00272   friend class OpalFaxMediaStream;
00273 };
00274 
00275 
00276 typedef OpalFaxConnection OpalT38Connection; // For backward compatibility
00277 
00278 
00279 #endif // OPAL_FAX
00280 
00281 #endif // OPAL_T38_T38PROTO_H