OPAL  Version 3.10.10
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: 28445 $
27  * $Author: rjongbloed $
28  * $Date: 2012-10-02 20:11:02 -0500 (Tue, 02 Oct 2012) $
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 toT38);
219  virtual void OnSwitchedFaxMediaStreams(bool toT38, bool success);
220  virtual bool OnSwitchingFaxMediaStreams(bool toT38);
222 
228  virtual void OnFaxCompleted(
229  bool failed
230  );
231 
232 #if OPAL_STATISTICS
233 
235  virtual void GetStatistics(
236  OpalMediaStatistics & statistics
237  ) const;
238 #endif
239 
242  const PString & GetFileName() const { return m_filename; }
243 
246  bool IsReceive() const { return m_receiving; }
248 
249  protected:
250  PDECLARE_NOTIFIER(PTimer, OpalFaxConnection, OnSwitchTimeout);
251  PDECLARE_NOTIFIER(PThread, OpalFaxConnection, OpenFaxStreams);
252  void SetFaxMediaFormatOptions(OpalMediaFormat & mediaFormat) const;
253 
254 
256  PString m_filename;
260 #if OPAL_STATISTICS
261  void InternalGetStatistics(OpalMediaStatistics & statistics, bool terminate) const;
263 #endif
264 
265  enum {
269  } m_state;
270 
272 
273  friend class OpalFaxMediaStream;
274 };
275 
276 
277 typedef OpalFaxConnection OpalT38Connection; // For backward compatibility
278 
279 
280 #endif // OPAL_FAX
281 
282 #endif // OPAL_T38_T38PROTO_H