4 * T.120 protocol handler
6 * Open Phone Abstraction Library
8 * Copyright (c) 1998-2000 Equivalence Pty. Ltd.
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/
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
20 * The Original Code is Open H323 Library.
22 * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
24 * Contributor(s): ______________________________________.
27 * Revision 2.7 2005/02/21 12:20:07 rjongbloed
28 * Added new "options list" to the OpalMediaFormat class.
30 * Revision 2.6 2002/11/10 11:33:20 robertj
31 * Updated to OpenH323 v1.10.3
33 * Revision 2.5 2002/09/04 06:01:49 robertj
34 * Updated to OpenH323 v1.9.6
36 * Revision 2.4 2002/02/11 09:32:13 robertj
37 * Updated to openH323 v1.8.0
39 * Revision 2.3 2002/01/22 05:22:19 robertj
40 * Added RTP encoding name string to media format database.
41 * Changed time units to clock rate in Hz.
43 * Revision 2.2 2001/08/01 05:05:49 robertj
44 * Major changes to H.323 capabilities, uses OpalMediaFormat for base name.
46 * Revision 2.1 2001/07/30 01:07:52 robertj
47 * Post first check in fix ups.
49 * Revision 2.0 2001/07/27 15:48:25 robertj
50 * Conversion of OpenH323 to Open Phone Abstraction Library (OPAL)
52 * Revision 1.4 2002/09/03 06:04:11 robertj
53 * Added globally accessible functions for media format name.
55 * Revision 1.3 2002/08/05 10:03:48 robertj
56 * Cosmetic changes to normalise the usage of pragma interface/implementation.
58 * Revision 1.2 2002/02/01 01:47:34 robertj
59 * Some more fixes for T.120 channel establishment, more to do!
61 * Revision 1.1 2001/07/17 04:44:32 robertj
62 * Partial implementation of T.120 and T.38 logical channels.
69 #pragma implementation "t120proto.h"
72 #include <t120/t120proto.h>
74 #include <h323/transaddr.h>
75 #include <t120/x224.h>
79 class T120_X224
: public X224
{
80 PCLASSINFO(T120_X224
, X224
);
82 BOOL
Read(H323Transport
& transport
);
83 BOOL
Write(H323Transport
& transport
);
87 class T120ConnectPDU
: public MCS_ConnectMCSPDU
{
88 PCLASSINFO(T120ConnectPDU
, MCS_ConnectMCSPDU
);
90 BOOL
Read(H323Transport
& transport
);
91 BOOL
Write(H323Transport
& transport
);
97 const OpalMediaFormat
OpalT120(
99 OpalMediaFormat::DefaultDataSessionID
,
100 RTP_DataFrame::IllegalPayloadType
,
102 FALSE
, // No jitter for data
103 825000, // 100's bits/sec
112 /////////////////////////////////////////////////////////////////////////////
114 BOOL
T120_X224::Read(H323Transport
& transport
)
118 if (!transport
.ReadPDU(rawData
)) {
119 PTRACE(1, "T120\tRead of X224 failed: " << transport
.GetErrorText());
123 if (Decode(rawData
)) {
124 PTRACE(1, "T120\tDecode of PDU failed:\n " << setprecision(2) << *this);
128 PTRACE(4, "T120\tRead X224 PDU:\n " << setprecision(2) << *this);
133 BOOL
T120_X224::Write(H323Transport
& transport
)
137 PTRACE(4, "T120\tWrite X224 PDU:\n " << setprecision(2) << *this);
139 if (!Encode(rawData
)) {
140 PTRACE(1, "T120\tEncode of PDU failed:\n " << setprecision(2) << *this);
144 if (!transport
.WritePDU(rawData
)) {
145 PTRACE(1, "T120\tWrite X224 PDU failed: " << transport
.GetErrorText());
153 /////////////////////////////////////////////////////////////////////////////
155 BOOL
T120ConnectPDU::Read(H323Transport
& transport
)
157 if (!x224
.Read(transport
))
160 // An X224 Data PDU...
161 if (x224
.GetCode() != X224::DataPDU
) {
162 PTRACE(1, "T120\tX224 must be data PDU");
166 // ... contains the T120 MCS PDU
167 PBER_Stream ber
= x224
.GetData();
169 PTRACE(1, "T120\tDecode of PDU failed:\n " << setprecision(2) << *this);
173 PTRACE(4, "T120\tReceived MCS Connect PDU:\n " << setprecision(2) << *this);
178 BOOL
T120ConnectPDU::Write(H323Transport
& transport
)
180 PTRACE(4, "T120\tSending MCS Connect PDU:\n " << setprecision(2) << *this);
184 ber
.CompleteEncoding();
186 return x224
.Write(transport
);
190 /////////////////////////////////////////////////////////////////////////////
192 OpalT120Protocol::OpalT120Protocol()
197 BOOL
OpalT120Protocol::Originate(H323Transport
& transport
)
199 PTRACE(3, "T120\tOriginate, sending X224 CONNECT-REQUEST");
202 x224
.BuildConnectRequest();
203 if (!x224
.Write(transport
))
206 transport
.SetReadTimeout(10000); // Wait 10 seconds for reply
207 if (!x224
.Read(transport
))
210 if (x224
.GetCode() != X224::ConnectConfirm
) {
211 PTRACE(1, "T120\tPDU was not X224 CONNECT-CONFIRM");
216 while (pdu
.Read(transport
)) {
217 if (!HandleConnect(pdu
))
225 BOOL
OpalT120Protocol::Answer(H323Transport
& transport
)
227 PTRACE(3, "T120\tAnswer, awaiting X224 CONNECT-REQUEST");
230 transport
.SetReadTimeout(60000); // Wait 60 seconds for reply
233 if (!x224
.Read(transport
))
235 } while (x224
.GetCode() != X224::ConnectRequest
);
237 x224
.BuildConnectConfirm();
238 if (!x224
.Write(transport
))
242 while (pdu
.Read(transport
)) {
243 if (!HandleConnect(pdu
))
251 BOOL
OpalT120Protocol::HandleConnect(const MCS_ConnectMCSPDU
& /*pdu*/)
257 BOOL
OpalT120Protocol::HandleDomain(const MCS_DomainMCSPDU
& /*pdu*/)
263 /////////////////////////////////////////////////////////////////////////////