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
00158 class OpalFaxConnection : public OpalConnection
00159 {
00160 PCLASSINFO(OpalFaxConnection, OpalConnection);
00161 public:
00166 OpalFaxConnection(
00167 OpalCall & call,
00168 OpalFaxEndPoint & endpoint,
00169 const PString & filename,
00170 bool receiving,
00171 bool disableT38,
00172 OpalConnection::StringOptions * stringOptions = NULL
00173 );
00174
00177 ~OpalFaxConnection();
00179
00182 virtual PString GetPrefixName() const;
00183
00192 virtual bool IsNetworkConnection() const { return false; }
00193
00194 virtual void ApplyStringOptions(OpalConnection::StringOptions & stringOptions);
00195 virtual OpalMediaFormatList GetMediaFormats() const;
00196 virtual void AdjustMediaFormats(OpalMediaFormatList & mediaFormats) const;
00197
00204 virtual PBoolean SetUpConnection();
00205
00216 virtual PBoolean SetAlerting(
00217 const PString & calleeName,
00218 PBoolean withMedia
00219 );
00220
00221 virtual PBoolean SetConnected();
00222 virtual void OnEstablished();
00223 virtual void OnReleased();
00224 virtual OpalMediaStream * CreateMediaStream(const OpalMediaFormat & mediaFormat, unsigned sessionID, PBoolean isSource);
00225 virtual void OnMediaPatchStop(
00226 unsigned sessionId,
00227 bool isSource
00228 );
00229 virtual PBoolean SendUserInputTone(
00230 char tone,
00231 unsigned duration
00232 );
00233
00238 virtual void AcceptIncoming();
00239
00243 virtual void OnFaxCompleted(
00244 bool failed
00245 );
00246
00249 bool IsReceive() const { return m_receiving; }
00251
00252 protected:
00253 PDECLARE_NOTIFIER(PTimer, OpalFaxConnection, OnSendCNGCED);
00254 PDECLARE_NOTIFIER(PThread, OpalFaxConnection, OpenFaxStreams);
00255 void RequestFax(bool toFax);
00256
00257
00258 OpalFaxEndPoint & m_endpoint;
00259 PString m_filename;
00260 bool m_receiving;
00261 PString m_stationId;
00262 bool m_disableT38;
00263 PTimeInterval m_releaseTimeout;
00264 PTimeInterval m_switchTimeout;
00265 OpalMediaFormat m_tiffFileFormat;
00266
00267 bool m_faxMode;
00268 PTimer m_faxTimer;
00269
00270 friend class OpalFaxMediaStream;
00271 };
00272
00273
00274 typedef OpalFaxConnection OpalT38Connection;
00275
00276
00277 #endif // OPAL_FAX
00278
00279 #endif // OPAL_T38_T38PROTO_H