00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
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;
00280
00281
00282 #endif // OPAL_FAX
00283
00284 #endif // OPAL_T38_T38PROTO_H