Allow H.323 Plus library to be used in addition to the OpenH323 library
[asterisk/asterisk.git] / channels / h323 / ast_h323.h
1 /*
2  * ast_h323.h
3  *
4  * OpenH323 Channel Driver for ASTERISK PBX.
5  *                      By Jeremy McNamara
6  *                      For The NuFone Network 
7  * 
8  * This code has been derived from code created by
9  *              Michael Manousos and Mark Spencer
10  *
11  * This file is part of the chan_h323 driver for Asterisk
12  *
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.
17  *
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.
21  *
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.
25  *
26  * Version Info: $Id$
27  */
28
29 #ifndef AST_H323_H
30 #define AST_H323_H
31
32 #include "ast_ptlib.h"
33
34 #define VERSION(a,b,c) ((a)*10000+(b)*100+(c))
35
36 class MyH323EndPoint : public H323EndPoint
37 {
38         PCLASSINFO(MyH323EndPoint, H323EndPoint);
39
40 public:
41         MyH323EndPoint();
42         int MyMakeCall(const PString &, PString &, void *_callReference, void *_opts);
43         PBoolean ClearCall(const PString &, H323Connection::CallEndReason reason);
44         PBoolean ClearCall(const PString &);
45
46         void OnClosedLogicalChannel(H323Connection &, const H323Channel &);
47         void OnConnectionEstablished(H323Connection &, const PString &);
48         void OnConnectionCleared(H323Connection &, const PString &);
49         virtual H323Connection * CreateConnection(unsigned, void *, H323Transport *, H323SignalPDU *);
50         void SendUserTone(const PString &, char);
51         PBoolean OnConnectionForwarded(H323Connection &, const PString &, const H323SignalPDU &);
52         PBoolean ForwardConnection(H323Connection &, const PString &, const H323SignalPDU &);
53         void SetEndpointTypeInfo( H225_EndpointType & info ) const;
54         void SetGateway(void);
55         PStringArray SupportedPrefixes;
56 };
57
58 class MyH323Connection : public H323Connection
59 {
60         PCLASSINFO(MyH323Connection, H323Connection);
61
62 public:
63         MyH323Connection(MyH323EndPoint &, unsigned, unsigned);
64         ~MyH323Connection();
65         H323Channel * CreateRealTimeLogicalChannel(const H323Capability &,
66                         H323Channel::Directions,
67                         unsigned,
68                         const H245_H2250LogicalChannelParameters *,
69                         RTP_QOS *);
70         H323Connection::AnswerCallResponse OnAnswerCall(const PString &,
71                         const H323SignalPDU &,
72                         H323SignalPDU &);
73         void OnReceivedReleaseComplete(const H323SignalPDU &);
74         PBoolean OnAlerting(const H323SignalPDU &, const PString &);
75         PBoolean OnSendReleaseComplete(H323SignalPDU &);
76         PBoolean OnReceivedSignalSetup(const H323SignalPDU &);
77         PBoolean OnReceivedFacility(const H323SignalPDU &);
78         PBoolean OnSendSignalSetup(H323SignalPDU &);
79         PBoolean OnStartLogicalChannel(H323Channel &);
80         PBoolean OnClosingLogicalChannel(H323Channel &);
81         virtual void SendUserInputTone(char tone, unsigned duration = 0, unsigned logicalChannel = 0, unsigned rtpTimestamp = 0);
82         virtual void OnUserInputTone(char, unsigned, unsigned, unsigned);
83         virtual void OnUserInputString(const PString &value);
84         PBoolean OnReceivedProgress(const H323SignalPDU &);
85         PBoolean MySendProgress();
86         void OnSendCapabilitySet(H245_TerminalCapabilitySet &);
87         void OnSetLocalCapabilities();
88         void SetCapabilities(int, int, void *, int);
89         PBoolean OnReceivedCapabilitySet(const H323Capabilities &, const H245_MultiplexCapability *,
90                         H245_TerminalCapabilitySetReject &);
91         void SetCause(int _cause) { cause = _cause; };
92         virtual PBoolean StartControlChannel(const H225_TransportAddress & h245Address);
93         void SetCallOptions(void *opts, PBoolean isIncoming);
94         void SetCallDetails(void *callDetails, const H323SignalPDU &setupPDU, PBoolean isIncoming);
95         virtual H323Connection::CallEndReason SendSignalSetup(const PString&, const H323TransportAddress&);
96 #ifdef TUNNELLING
97         virtual PBoolean HandleSignalPDU(H323SignalPDU &pdu);
98         PBoolean EmbedTunneledInfo(H323SignalPDU &pdu);
99 #endif
100 #ifdef H323_H450
101         virtual void OnReceivedLocalCallHold(int linkedId);
102         virtual void OnReceivedLocalCallRetrieve(int linkedId);
103 #endif
104         void MyHoldCall(BOOL localHold);
105
106         PString sourceAliases;
107         PString destAliases;
108         PString sourceE164;
109         PString destE164;
110         int cid_presentation;
111         int cid_ton;
112         PString rdnis;
113         int redirect_reason;
114         int transfer_capability;
115
116         WORD sessionId;
117         PBoolean bridging;
118 #ifdef TUNNELLING
119         int remoteTunnelOptions;
120         int tunnelOptions;
121 #endif
122
123         unsigned holdHandling;
124         unsigned progressSetup;
125         unsigned progressAlert;
126         int cause;
127
128         RTP_DataFrame::PayloadTypes dtmfCodec[2];
129         int dtmfMode;
130 };
131
132 class MyH323_ExternalRTPChannel : public H323_ExternalRTPChannel
133 {
134         PCLASSINFO(MyH323_ExternalRTPChannel, H323_ExternalRTPChannel);
135
136 public:
137         MyH323_ExternalRTPChannel(
138                         MyH323Connection & connection,
139                         const H323Capability & capability,
140                         Directions direction,
141                         unsigned sessionID);
142
143         ~MyH323_ExternalRTPChannel();
144
145         /* Overrides */
146         PBoolean Start(void);
147         PBoolean OnReceivedAckPDU(const H245_H2250LogicalChannelAckParameters & param);
148
149 protected:
150         BYTE payloadCode;
151
152         PIPSocket::Address localIpAddr;
153         PIPSocket::Address remoteIpAddr;
154         /* Additional functions in order to have chan_h323 compile with H323Plus */
155 #if VERSION(OPENH323_MAJOR, OPENH323_MINOR, OPENH323_BUILD) > VERSION(1,19,4)
156         BOOL OnReceivedAltPDU(const H245_ArrayOf_GenericInformation & alternate );
157         BOOL OnSendingAltPDU(H245_ArrayOf_GenericInformation & alternate) const;
158         void OnSendOpenAckAlt(H245_ArrayOf_GenericInformation & alternate) const;
159         BOOL OnReceivedAckAltPDU(const H245_ArrayOf_GenericInformation & alternate);
160 #endif
161         WORD localPort;
162         WORD remotePort;
163 };
164
165 #ifdef H323_H450
166
167 #if VERSION(OPENH323_MAJOR, OPENH323_MINOR, OPENH323_BUILD) > VERSION(1,19,4)
168 #include <h450/h450pdu.h>
169 #else
170 #include <h450pdu.h>
171 #endif
172
173 class MyH4504Handler : public H4504Handler
174 {
175         PCLASSINFO(MyH4504Handler, H4504Handler);
176
177 public:
178         MyH4504Handler(MyH323Connection &_conn, H450xDispatcher &_disp);
179         virtual void OnReceivedLocalCallHold(int linkedId);
180         virtual void OnReceivedLocalCallRetrieve(int linkedId);
181
182 private:
183         MyH323Connection *conn;
184 };
185 #endif
186
187 #endif /* !defined AST_H323_H */