OPAL
Version 3.12.5
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
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: 29550 $
27
* $Author: rjongbloed $
28
* $Date: 2013-04-22 22:08:10 -0500 (Mon, 22 Apr 2013) $
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
#if OPAL_FAX
41
42
#include <
opal/mediafmt.h
>
43
#include <
opal/mediastrm.h
>
44
#include <
opal/mediasession.h
>
45
#include <
ep/localep.h
>
46
47
48
class
OpalTransport
;
49
class
OpalFaxConnection
;
50
51
#if OPAL_PTLIB_ASN
52
class
T38_IFPPacket;
53
class
PASN_OctetString;
54
#endif
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
80
class
OpalFaxEndPoint
:
public
OpalLocalEndPoint
81
{
82
PCLASSINFO(
OpalFaxEndPoint
,
OpalLocalEndPoint
);
83
public
:
88
OpalFaxEndPoint
(
89
OpalManager
&
manager
,
90
const
char
* g711Prefix =
"fax"
,
91
const
char
* t38Prefix =
"t38"
92
);
93
96
~OpalFaxEndPoint
();
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
127
virtual
OpalFaxConnection
*
CreateConnection
(
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
152
void
SetDefaultDirectory
(
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
183
class
OpalFaxConnection
:
public
OpalLocalConnection
184
{
185
PCLASSINFO(
OpalFaxConnection
,
OpalLocalConnection
);
186
public
:
191
OpalFaxConnection
(
192
OpalCall
& call,
193
OpalFaxEndPoint
&
endpoint
,
194
const
PString & filename,
195
bool
receiving,
196
bool
disableT38,
197
OpalConnection::StringOptions
* stringOptions = NULL
198
);
199
202
~OpalFaxConnection
();
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
OnClosedMediaStream
(
const
OpalMediaStream
& stream);
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);
221
virtual
void
OnApplyStringOptions
();
223
229
virtual
void
OnFaxCompleted
(
230
bool
failed
231
);
232
235
virtual
void
GetStatistics
(
236
OpalMediaStatistics
& statistics
237
)
const
;
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
void
InternalOpenFaxStreams
();
251
void
InternalOnFaxCompleted
();
252
253
void
SetFaxMediaFormatOptions
(
OpalMediaFormat
& mediaFormat)
const
;
254
255
OpalFaxEndPoint
&
m_endpoint
;
256
PString
m_filename
;
257
bool
m_receiving
;
258
bool
m_disableT38
;
259
unsigned
m_switchTime
;
260
OpalMediaFormat
m_tiffFileFormat
;
261
262
PTimer
m_switchTimer
;
263
264
OpalMediaStatistics
m_finalStatistics
;
265
PAtomicBoolean
m_completed
;
266
};
267
268
269
typedef
OpalFaxConnection
OpalT38Connection
;
// For backward compatibility
270
271
class
T38_UDPTLPacket;
272
273
class
OpalFaxSession
:
public
OpalMediaSession
274
{
275
public
:
276
static
const
PCaselessString &
UDPTL
();
277
278
OpalFaxSession
(
const
Init
& init);
279
~OpalFaxSession
();
280
281
virtual
const
PCaselessString &
GetSessionType
()
const
{
return
UDPTL
(); }
282
virtual
bool
Open
(
const
PString & localInterface,
const
OpalTransportAddress
& remoteAddress,
bool
isMediaAddress);
283
virtual
bool
IsOpen
()
const
;
284
virtual
bool
Close
();
285
virtual
OpalTransportAddress
GetLocalAddress
(
bool
isMediaAddress =
true
)
const
;
286
virtual
OpalTransportAddress
GetRemoteAddress
(
bool
isMediaAddress =
true
)
const
;
287
virtual
bool
SetRemoteAddress
(
const
OpalTransportAddress
& remoteAddress,
bool
isMediaAddress =
true
);
288
289
virtual
void
AttachTransport
(
Transport
& transport);
290
virtual
Transport
DetachTransport
();
291
292
virtual
OpalMediaStream
*
CreateMediaStream
(
293
const
OpalMediaFormat
& mediaFormat,
294
unsigned
sessionID,
295
bool
isSource
296
);
297
298
bool
WriteData
(
RTP_DataFrame
& frame);
299
bool
ReadData
(
RTP_DataFrame
& frame);
300
301
void
ApplyMediaOptions
(
const
OpalMediaFormat
& mediaFormat);
302
303
protected
:
304
void
SetFrameFromIFP
(
RTP_DataFrame
& frame,
const
PASN_OctetString & ifp,
unsigned
sequenceNumber);
305
void
DecrementSentPacketRedundancy
(
bool
stripRedundancy);
306
bool
WriteUDPTL
();
307
308
Transport
m_savedTransport
;
309
PIPSocket *
m_dataSocket
;
310
bool
m_shuttingDown
;
311
312
bool
m_rawUDPTL
;
// Put UDPTL directly in RTP payload
313
PINDEX
m_datagramSize
;
314
315
int
m_consecutiveBadPackets
;
316
bool
m_awaitingGoodPacket
;
317
T38_UDPTLPacket *
m_receivedPacket
;
318
unsigned
m_expectedSequenceNumber
;
319
int
m_secondaryPacket
;
320
321
std::map<int, int>
m_redundancy
;
322
PTimeInterval
m_redundancyInterval
;
323
PTimeInterval
m_keepAliveInterval
;
324
bool
m_optimiseOnRetransmit
;
325
std::vector<int>
m_sentPacketRedundancy
;
326
T38_UDPTLPacket *
m_sentPacket
;
327
PMutex
m_writeMutex
;
328
PTimer
m_timerWriteDataIdle
;
329
PDECLARE_NOTIFIER
(PTimer,
OpalFaxSession
, OnWriteDataIdle);
330
};
331
332
class
OpalFaxMediaStream
:
public
OpalMediaStream
333
{
334
PCLASSINFO(
OpalFaxMediaStream
,
OpalMediaStream
);
335
336
public
:
337
OpalFaxMediaStream
(
OpalConnection
& conn,
338
const
OpalMediaFormat
&
mediaFormat
,
339
unsigned
sessionID
,
340
bool
isSource,
341
OpalFaxSession
& session);
342
343
virtual
PBoolean
Open
();
344
virtual
PBoolean
ReadPacket
(
RTP_DataFrame
& packet);
345
virtual
PBoolean
WritePacket
(
RTP_DataFrame
& packet);
346
virtual
PBoolean
IsSynchronous
()
const
;
347
virtual
bool
InternalUpdateMediaFormat
(
const
OpalMediaFormat
& mediaFormat);
348
349
protected
:
350
virtual
void
InternalClose
();
351
352
OpalFaxSession
&
m_session
;
353
};
354
355
#endif // OPAL_FAX
356
357
#endif // OPAL_T38_T38PROTO_H
include
t38
t38proto.h
Generated on Tue Sep 3 2013 06:40:24 for OPAL by
1.8.4