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_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;
00278
00279
00280 #endif // OPAL_FAX
00281
00282 #endif // OPAL_T38_T38PROTO_H