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: 24797 $
00027  * $Author: rjongbloed $
00028  * $Date: 2010-10-14 23:13:13 -0500 (Thu, 14 Oct 2010) $
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"      
00057 #define OPAL_NO_G111_FAX     "No-G711-Fax"     
00058 #define OPAL_SUPPRESS_CED    "Suppress-CED"    
00059 #define OPAL_IGNORE_CED      "Ignore-CED"      
00060 #define OPAL_T38_SWITCH_TIME "T38-Switch-Time" 
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 void OnApplyStringOptions();
00210     virtual OpalMediaFormatList GetMediaFormats() const;
00211     virtual void AdjustMediaFormats(bool local, OpalMediaFormatList & mediaFormats, OpalConnection * otherConnection) const;
00212     virtual void AcceptIncoming();
00213     virtual void OnEstablished();
00214     virtual void OnReleased();
00215     virtual OpalMediaStream * CreateMediaStream(const OpalMediaFormat & mediaFormat, unsigned sessionID, PBoolean isSource);
00216     virtual void OnStartMediaPatch(OpalMediaPatch & patch);
00217     virtual void OnStopMediaPatch(OpalMediaPatch & patch);
00218     virtual PBoolean SendUserInputTone(char tone, unsigned duration);
00219     virtual void OnUserInputTone(char tone, unsigned duration);
00220     virtual bool SwitchFaxMediaStreams(bool enableFax);
00221     virtual void OnSwitchedFaxMediaStreams(bool enabledFax);
00223 
00229     virtual void OnFaxCompleted(
00230       bool failed   
00231     );
00232 
00233 #if OPAL_STATISTICS
00234 
00236     virtual void GetStatistics(
00237       OpalMediaStatistics & statistics  
00238     ) const;
00239 #endif
00240 
00243     const PString & GetFileName() const { return m_filename; }
00244 
00247     bool IsReceive() const { return m_receiving; }
00249 
00250   protected:
00251     PDECLARE_NOTIFIER(PTimer,  OpalFaxConnection, OnSendCNGCED);
00252     PDECLARE_NOTIFIER(PThread, OpalFaxConnection, OpenFaxStreams);
00253 
00254 
00255     OpalFaxEndPoint & m_endpoint;
00256     PString           m_filename;
00257     bool              m_receiving;
00258     PString           m_stationId;
00259     bool              m_disableT38;
00260     PTimeInterval     m_releaseTimeout;
00261     PTimeInterval     m_switchTimeout;
00262     OpalMediaFormat   m_tiffFileFormat;
00263 #if OPAL_STATISTICS
00264     void InternalGetStatistics(OpalMediaStatistics & statistics, bool terminate) const;
00265     OpalMediaStatistics m_finalStatistics;
00266 #endif
00267 
00268     enum {
00269       e_AwaitingSwitchToT38,
00270       e_SwitchingToT38,
00271       e_CompletedSwitch
00272     } m_state;
00273     PTimer   m_faxTimer;
00274 
00275   friend class OpalFaxMediaStream;
00276 };
00277 
00278 
00279 typedef OpalFaxConnection OpalT38Connection; // For backward compatibility
00280 
00281 
00282 #endif // OPAL_FAX
00283 
00284 #endif // OPAL_T38_T38PROTO_H

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