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/endpoint.h>
00048
00049
00050 class OpalTransport;
00051 class T38_IFPPacket;
00052 class PASN_OctetString;
00053 class OpalFaxConnection;
00054
00055
00057
00058 class OpalFaxConnection;
00059
00071 class OpalFaxEndPoint : public OpalEndPoint
00072 {
00073 PCLASSINFO(OpalFaxEndPoint, OpalEndPoint);
00074 public:
00079 OpalFaxEndPoint(
00080 OpalManager & manager,
00081 const char * g711Prefix = "fax",
00082 const char * t38Prefix = "t38"
00083 );
00084
00087 ~OpalFaxEndPoint();
00089
00090 virtual PSafePtr<OpalConnection> MakeConnection(
00091 OpalCall & call,
00092 const PString & party,
00093 void * userData = NULL,
00094 unsigned int options = 0,
00095 OpalConnection::StringOptions * stringOptions = NULL
00096 );
00097
00100 virtual OpalFaxConnection * CreateConnection(
00101 OpalCall & call,
00102 void * userData,
00103 OpalConnection::StringOptions * stringOptions,
00104 const PString & filename,
00105 bool receiving,
00106 bool disableT38
00107 );
00108
00116 virtual OpalMediaFormatList GetMediaFormats() const;
00117
00121 virtual void AcceptIncomingConnection(
00122 const PString & connectionToken
00123 );
00124
00128 virtual void OnFaxCompleted(
00129 OpalFaxConnection & connection,
00130 bool failed
00131 );
00133
00137 const PString & GetDefaultDirectory() const { return m_defaultDirectory; }
00138
00141 void SetDefaultDirectory(
00142 const PString & dir
00143 ) { m_defaultDirectory = dir; }
00144
00145 const PString & GetT38Prefix() const { return m_t38Prefix; }
00147
00148 protected:
00149 PString m_t38Prefix;
00150 PDirectory m_defaultDirectory;
00151 };
00152
00153
00155
00172 class OpalFaxConnection : public OpalConnection
00173 {
00174 PCLASSINFO(OpalFaxConnection, OpalConnection);
00175 public:
00180 OpalFaxConnection(
00181 OpalCall & call,
00182 OpalFaxEndPoint & endpoint,
00183 const PString & filename,
00184 bool receiving,
00185 bool disableT38,
00186 OpalConnection::StringOptions * stringOptions = NULL
00187 );
00188
00191 ~OpalFaxConnection();
00193
00196 virtual PString GetPrefixName() const;
00197
00206 virtual bool IsNetworkConnection() const { return false; }
00207
00208 virtual void ApplyStringOptions(OpalConnection::StringOptions & stringOptions);
00209 virtual OpalMediaFormatList GetMediaFormats() const;
00210 virtual void AdjustMediaFormats(bool local, OpalMediaFormatList & mediaFormats, OpalConnection * otherConnection) const;
00211
00218 virtual PBoolean SetUpConnection();
00219
00230 virtual PBoolean SetAlerting(
00231 const PString & calleeName,
00232 PBoolean withMedia
00233 );
00234
00235 virtual PBoolean SetConnected();
00236 virtual void OnEstablished();
00237 virtual void OnReleased();
00238 virtual OpalMediaStream * CreateMediaStream(const OpalMediaFormat & mediaFormat, unsigned sessionID, PBoolean isSource);
00239 virtual void OnStartMediaPatch(OpalMediaPatch & patch);
00240 virtual void OnStopMediaPatch(OpalMediaPatch & patch);
00241 virtual PBoolean SendUserInputTone(char tone, unsigned duration);
00242 virtual void OnUserInputTone(char tone, unsigned duration);
00243 virtual bool SwitchFaxMediaStreams(bool enableFax);
00244 virtual void OnSwitchedFaxMediaStreams(bool enabledFax);
00245
00250 virtual void AcceptIncoming();
00251
00255 virtual void OnFaxCompleted(
00256 bool failed
00257 );
00258
00259 #if OPAL_STATISTICS
00260
00262 virtual void GetStatistics(
00263 OpalMediaStatistics & statistics
00264 ) const;
00265 #endif
00266
00269 const PString & GetFileName() const { return m_filename; }
00270
00273 bool IsReceive() const { return m_receiving; }
00275
00276 protected:
00277 PDECLARE_NOTIFIER(PTimer, OpalFaxConnection, OnSendCNGCED);
00278 PDECLARE_NOTIFIER(PThread, OpalFaxConnection, OpenFaxStreams);
00279 PDECLARE_NOTIFIER(PThread, OpalFaxConnection, ReleaseConnection);
00280
00281
00282 OpalFaxEndPoint & m_endpoint;
00283 PString m_filename;
00284 bool m_receiving;
00285 PString m_stationId;
00286 bool m_disableT38;
00287 PTimeInterval m_releaseTimeout;
00288 PTimeInterval m_switchTimeout;
00289 OpalMediaFormat m_tiffFileFormat;
00290
00291 bool m_awaitingSwitchToT38;
00292 PTimer m_faxTimer;
00293
00294 friend class OpalFaxMediaStream;
00295 };
00296
00297
00298 typedef OpalFaxConnection OpalT38Connection;
00299
00300
00301 #endif // OPAL_FAX
00302
00303 #endif // OPAL_T38_T38PROTO_H