4 * OpenH323 Channel Driver for ASTERISK PBX.
6 * For The NuFone Network
8 * This code has been derived from code created by
9 * Michael Manousos and Mark Spencer
11 * This file is part of the chan_h323 driver for Asterisk
13 * chan_h323 is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * chan_h323 is distributed WITHOUT ANY WARRANTY; without even
19 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
20 * PURPOSE. See the GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
40 #include "chan_h323.h"
42 /** These need to be redefined here because the C++
43 side of this driver is blind to the asterisk headers */
45 /*! G.723.1 compression */
46 #define AST_FORMAT_G723_1 (1 << 0)
47 /*! GSM compression */
48 #define AST_FORMAT_GSM (1 << 1)
49 /*! Raw mu-law data (G.711) */
50 #define AST_FORMAT_ULAW (1 << 2)
51 /*! Raw A-law data (G.711) */
52 #define AST_FORMAT_ALAW (1 << 3)
54 #define AST_FORMAT_MP3 (1 << 4)
56 #define AST_FORMAT_ADPCM (1 << 5)
57 /*! Raw 16-bit Signed Linear (8000 Hz) PCM */
58 #define AST_FORMAT_SLINEAR (1 << 6)
59 /*! LPC10, 180 samples/frame */
60 #define AST_FORMAT_LPC10 (1 << 7)
62 #define AST_FORMAT_G729A (1 << 8)
63 /*! SpeeX Free Compression */
64 #define AST_FORMAT_SPEEX (1 << 9)
65 /*! ILBC Free Codec */
66 #define AST_FORMAT_ILBC (1 << 10)
68 /**This class describes the G.723.1 codec capability.
70 class H323_G7231Capability : public H323AudioCapability
72 PCLASSINFO(H323_G7231Capability, H323AudioCapability);
75 BOOL annexA = TRUE /// Enable Annex A silence insertion descriptors
77 Comparison Compare(const PObject & obj) const;
79 PObject * Clone() const;
81 virtual H323Codec * CreateCodec(
82 H323Codec::Direction direction /// Direction in which this instance runs
85 unsigned GetSubType() const;
86 PString GetFormatName() const;
88 H245_AudioCapability & pdu, /// PDU to set information on
89 unsigned packetSize /// Packet size to use in capability
93 const H245_AudioCapability & pdu, /// PDU to get information from
94 unsigned & packetSize /// Packet size to use in capability
101 /**This class describes the (fake) G729 codec capability.
103 class AST_G729Capability : public H323AudioCapability
105 PCLASSINFO(AST_G729Capability, H323AudioCapability);
108 /**@name Construction */
110 /**Create a new G.729 capability.
112 AST_G729Capability();
115 /**@name Overrides from class PObject */
117 /**Create a copy of the object.
119 virtual PObject * Clone() const;
122 /**@name Operations */
124 /**Create the codec instance, allocating resources as required.
126 virtual H323Codec * CreateCodec(
127 H323Codec::Direction direction /// Direction in which this instance runs
131 /**@name Identification functions */
133 /**Get the sub-type of the capability. This is a code dependent on the
134 main type of the capability.
136 This returns one of the four possible combinations of mode and speed
137 using the enum values of the protocol ASN H245_AudioCapability class.
139 virtual unsigned GetSubType() const;
141 /**Get the name of the media data format this class represents.
143 virtual PString GetFormatName() const;
148 /**This class describes the VoiceAge G729A codec capability.
150 class AST_G729ACapability : public H323AudioCapability
152 PCLASSINFO(AST_G729ACapability, H323AudioCapability);
155 /**@name Construction */
157 /**Create a new G.729A capability.
159 AST_G729ACapability();
162 /**@name Overrides from class PObject */
164 /**Create a copy of the object.
166 virtual PObject * Clone() const;
169 /**@name Operations */
171 /**Create the codec instance, allocating resources as required.
173 virtual H323Codec * CreateCodec(
174 H323Codec::Direction direction /// Direction in which this instance runs
178 /**@name Identification functions */
180 /**Get the sub-type of the capability. This is a code dependent on the
181 main type of the capability.
183 This returns one of the four possible combinations of mode and speed
184 using the enum values of the protocol ASN H245_AudioCapability class.
186 virtual unsigned GetSubType() const;
188 /**Get the name of the media data format this class represents.
190 virtual PString GetFormatName() const;
195 class MyH323EndPoint : public H323EndPoint {
197 PCLASSINFO(MyH323EndPoint, H323EndPoint);
201 int MakeCall(const PString &, PString &, unsigned int *, unsigned int, char *);
202 BOOL ClearCall(const PString &);
204 void OnClosedLogicalChannel(H323Connection &, const H323Channel &);
205 void OnConnectionEstablished(H323Connection &, const PString &);
206 void OnConnectionCleared(H323Connection &, const PString &);
207 H323Connection * CreateConnection(unsigned, void *);
208 void SendUserTone(const PString &, char);
209 H323Capabilities GetCapabilities(void);
210 BOOL OnConnectionForwarded(H323Connection &, const PString &, const H323SignalPDU &);
212 BOOL ForwardConnection(H323Connection &, const PString &, const H323SignalPDU &);
214 PStringArray SupportedPrefixes;
216 void SetEndpointTypeInfo( H225_EndpointType & info ) const;
217 void SetGateway(void);
220 class MyH323Connection : public H323Connection {
222 PCLASSINFO(MyH323Connection, H323Connection);
225 MyH323Connection(MyH323EndPoint &, unsigned, unsigned);
228 H323Channel * CreateRealTimeLogicalChannel(const H323Capability &, H323Channel::Directions, unsigned,
229 const H245_H2250LogicalChannelParameters *);
230 H323Connection::AnswerCallResponse OnAnswerCall(const PString &, const H323SignalPDU &, H323SignalPDU &);
231 void OnReceivedReleaseComplete(const H323SignalPDU &);
232 BOOL OnAlerting(const H323SignalPDU &, const PString &);
233 BOOL OnSendReleaseComplete(H323SignalPDU &);
234 BOOL OnReceivedSignalSetup(const H323SignalPDU &);
235 BOOL OnReceivedFacility(const H323SignalPDU &);
236 BOOL OnSendSignalSetup(H323SignalPDU &);
237 BOOL OnStartLogicalChannel(H323Channel &);
238 BOOL OnClosingLogicalChannel(H323Channel &);
239 void SendUserInputTone(char, unsigned);
240 void OnUserInputTone(char, unsigned, unsigned, unsigned);
241 void OnUserInputString(const PString &value);
243 PString sourceAliases;
248 PIPSocket::Address externalIpAddress; // IP address of media server
249 PIPSocket::Address remoteIpAddress; // IP Address of remote endpoint
250 WORD externalPort; // local media server Data port (control is dataPort+1)
251 WORD remotePort; // remote endpoint Data port (control is dataPort+1)
253 BOOL bridging; // Used to help determine which IP to use
256 class MyH323_ExternalRTPChannel : public H323_ExternalRTPChannel {
258 PCLASSINFO(MyH323_ExternalRTPChannel, H323_ExternalRTPChannel);
262 MyH323_ExternalRTPChannel(MyH323Connection &, const H323Capability &, Directions,
263 unsigned, const PIPSocket::Address &, WORD);
265 ~MyH323_ExternalRTPChannel();
268 const H245_H2250LogicalChannelParameters & param, /// Acknowledgement PDU
269 unsigned & errorCode /// Error on failure
272 BOOL OnReceivedAckPDU(const H245_H2250LogicalChannelAckParameters & param);
277 * The MyProcess is a necessary descendant PProcess class so that the H323EndPoint
278 * objected to be created from within that class. (Who owns main() problem).
280 class MyProcess : public PProcess {
282 PCLASSINFO(MyProcess, PProcess);