# 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: 28445 $
    00027  * $Author: rjongbloed $
    00028  * $Date: 2012-10-02 20:11:02 -0500 (Tue, 02 Oct 2012) $
    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_OPT_HEADER_INFO "Header-Info"
    00058 #define OPAL_NO_G111_FAX     "No-G711-Fax"
    00059 #define OPAL_SWITCH_ON_CED   "Switch-On-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 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 toT38);
    00219     virtual void OnSwitchedFaxMediaStreams(bool toT38, bool success);
    00220     virtual bool OnSwitchingFaxMediaStreams(bool toT38);
    00222
    00228     virtual void OnFaxCompleted(
    00229       bool failed
    00230     );
    00231
    00232 #if OPAL_STATISTICS
    00233
    00235     virtual void GetStatistics(
    00236       OpalMediaStatistics & statistics
    00237     ) const;
    00238 #endif
    00239
    00242     const PString & GetFileName() const { return m_filename; }
    00243
    00246     bool IsReceive() const { return m_receiving; }
    00248
    00249   protected:
    00250     PDECLARE_NOTIFIER(PTimer,  OpalFaxConnection, OnSwitchTimeout);
    00251     PDECLARE_NOTIFIER(PThread, OpalFaxConnection, OpenFaxStreams);
    00252     void SetFaxMediaFormatOptions(OpalMediaFormat & mediaFormat) const;
    00253
    00254
    00255     OpalFaxEndPoint & m_endpoint;
    00256     PString           m_filename;
    00257     bool              m_receiving;
    00258     bool              m_disableT38;
    00259     OpalMediaFormat   m_tiffFileFormat;
    00260 #if OPAL_STATISTICS
    00261     void InternalGetStatistics(OpalMediaStatistics & statistics, bool terminate) const;
    00262     OpalMediaStatistics m_finalStatistics;
    00263 #endif
    00264
    00265     enum {
    00266       e_AwaitingSwitchToT38,
    00267       e_SwitchingToT38,
    00268       e_CompletedSwitch
    00269     } m_state;
    00270
    00271     PTimer m_switchTimer;
    00272
    00273   friend class OpalFaxMediaStream;
    00274 };
    00275
    00276
    00277 typedef OpalFaxConnection OpalT38Connection; // For backward compatibility
    00278
    00279
    00280 #endif // OPAL_FAX
    00281
    00282 #endif // OPAL_T38_T38PROTO_H