OPAL  Version 3.10.4
t38proto.h
Go to the documentation of this file.
1 /*
2  * t38proto.h
3  *
4  * T.38 protocol handler
5  *
6  * Open Phone Abstraction Library
7  *
8  * Copyright (c) 2001 Equivalence Pty. Ltd.
9  *
10  * The contents of this file are subject to the Mozilla Public License
11  * Version 1.0 (the "License"); you may not use this file except in
12  * compliance with the License. You may obtain a copy of the License at
13  * http://www.mozilla.org/MPL/
14  *
15  * Software distributed under the License is distributed on an "AS IS"
16  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17  * the License for the specific language governing rights and limitations
18  * under the License.
19  *
20  * The Original Code is Open H323 Library.
21  *
22  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
23  *
24  * Contributor(s): ______________________________________.
25  *
26  * $Revision: 26102 $
27  * $Author: rjongbloed $
28  * $Date: 2011-06-30 00:00:16 -0500 (Thu, 30 Jun 2011) $
29  */
30 
31 #ifndef OPAL_T38_T38PROTO_H
32 #define OPAL_T38_T38PROTO_H
33 
34 #ifdef P_USE_PRAGMA
35 #pragma interface
36 #endif
37 
38 #include <opal/buildopts.h>
39 
40 
41 #if OPAL_FAX
42 
43 #include <ptlib/pipechan.h>
44 
45 #include <opal/mediafmt.h>
46 #include <opal/mediastrm.h>
47 #include <opal/localep.h>
48 
49 
50 class OpalTransport;
51 class T38_IFPPacket;
52 class PASN_OctetString;
53 class OpalFaxConnection;
54 
55 
56 #define OPAL_OPT_STATION_ID "Station-Id"
57 #define OPAL_OPT_HEADER_INFO "Header-Info"
58 #define OPAL_NO_G111_FAX "No-G711-Fax"
59 #define OPAL_SWITCH_ON_CED "Switch-On-CED"
60 #define OPAL_T38_SWITCH_TIME "T38-Switch-Time"
61 
62 #define OPAL_FAX_TIFF_FILE "TIFF-File"
63 
64 
66 
67 class OpalFaxConnection;
68 
81 {
83  public:
90  const char * g711Prefix = "fax",
91  const char * t38Prefix = "t38"
92  );
93 
98 
101  virtual PSafePtr<OpalConnection> MakeConnection(
102  OpalCall & call,
103  const PString & party,
104  void * userData = NULL,
105  unsigned int options = 0,
106  OpalConnection::StringOptions * stringOptions = NULL
107  );
108 
116  virtual OpalMediaFormatList GetMediaFormats() const;
118 
123  virtual bool IsAvailable() const;
124 
128  OpalCall & call,
129  void * userData,
130  OpalConnection::StringOptions * stringOptions,
131  const PString & filename,
132  bool receiving,
133  bool disableT38
134  );
135 
139  virtual void OnFaxCompleted(
140  OpalFaxConnection & connection,
141  bool failed
142  );
144 
148  const PString & GetDefaultDirectory() const { return m_defaultDirectory; }
149 
153  const PString & dir
154  ) { m_defaultDirectory = dir; }
155 
156  const PString & GetT38Prefix() const { return m_t38Prefix; }
158 
159  protected:
160  PString m_t38Prefix;
161  PDirectory m_defaultDirectory;
162 };
163 
164 
166 
184 {
186  public:
192  OpalCall & call,
194  const PString & filename,
195  bool receiving,
196  bool disableT38,
197  OpalConnection::StringOptions * stringOptions = NULL
198  );
199 
204 
207  virtual PString GetPrefixName() const;
208 
209  virtual OpalMediaFormatList GetMediaFormats() const;
210  virtual void AdjustMediaFormats(bool local, const OpalConnection * otherConnection, OpalMediaFormatList & mediaFormats) const;
211  virtual void OnEstablished();
212  virtual void OnReleased();
213  virtual OpalMediaStream * CreateMediaStream(const OpalMediaFormat & mediaFormat, unsigned sessionID, PBoolean isSource);
214  virtual void OnStartMediaPatch(OpalMediaPatch & patch);
215  virtual void OnStopMediaPatch(OpalMediaPatch & patch);
216  virtual PBoolean SendUserInputTone(char tone, unsigned duration);
217  virtual void OnUserInputTone(char tone, unsigned duration);
218  virtual bool SwitchFaxMediaStreams(bool enableFax);
219  virtual void OnSwitchedFaxMediaStreams(bool enabledFax);
221 
227  virtual void OnFaxCompleted(
228  bool failed
229  );
230 
231 #if OPAL_STATISTICS
232 
234  virtual void GetStatistics(
235  OpalMediaStatistics & statistics
236  ) const;
237 #endif
238 
241  const PString & GetFileName() const { return m_filename; }
242 
245  bool IsReceive() const { return m_receiving; }
247 
248  protected:
249  PDECLARE_NOTIFIER(PTimer, OpalFaxConnection, OnSwitchTimeout);
250  PDECLARE_NOTIFIER(PThread, OpalFaxConnection, OpenFaxStreams);
251  void SetFaxMediaFormatOptions(OpalMediaFormat & mediaFormat) const;
252 
253 
255  PString m_filename;
259 #if OPAL_STATISTICS
260  void InternalGetStatistics(OpalMediaStatistics & statistics, bool terminate) const;
262 #endif
263 
264  enum {
268  } m_state;
269 
271 
272  friend class OpalFaxMediaStream;
273 };
274 
275 
276 typedef OpalFaxConnection OpalT38Connection; // For backward compatibility
277 
278 
279 #endif // OPAL_FAX
280 
281 #endif // OPAL_T38_T38PROTO_H