ast_h323.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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. #ifndef AST_H323_H
  29. #define AST_H323_H
  30. #include "ast_ptlib.h"
  31. #define VERSION(a,b,c) ((a)*10000+(b)*100+(c))
  32. class MyH323EndPoint : public H323EndPoint
  33. {
  34. PCLASSINFO(MyH323EndPoint, H323EndPoint);
  35. public:
  36. MyH323EndPoint();
  37. int MyMakeCall(const PString &, PString &, void *_callReference, void *_opts);
  38. PBoolean ClearCall(const PString &, H323Connection::CallEndReason reason);
  39. PBoolean ClearCall(const PString &);
  40. void OnClosedLogicalChannel(H323Connection &, const H323Channel &);
  41. void OnConnectionEstablished(H323Connection &, const PString &);
  42. void OnConnectionCleared(H323Connection &, const PString &);
  43. virtual H323Connection * CreateConnection(unsigned, void *, H323Transport *, H323SignalPDU *);
  44. void SendUserTone(const PString &, char);
  45. PBoolean OnConnectionForwarded(H323Connection &, const PString &, const H323SignalPDU &);
  46. PBoolean ForwardConnection(H323Connection &, const PString &, const H323SignalPDU &);
  47. void SetEndpointTypeInfo( H225_EndpointType & info ) const;
  48. void SetGateway(void);
  49. PStringArray SupportedPrefixes;
  50. };
  51. class MyH323Connection : public H323Connection
  52. {
  53. PCLASSINFO(MyH323Connection, H323Connection);
  54. public:
  55. MyH323Connection(MyH323EndPoint &, unsigned, unsigned);
  56. ~MyH323Connection();
  57. H323Channel * CreateRealTimeLogicalChannel(const H323Capability &,
  58. H323Channel::Directions,
  59. unsigned,
  60. const H245_H2250LogicalChannelParameters *,
  61. RTP_QOS *);
  62. H323Connection::AnswerCallResponse OnAnswerCall(const PString &,
  63. const H323SignalPDU &,
  64. H323SignalPDU &);
  65. void OnReceivedReleaseComplete(const H323SignalPDU &);
  66. PBoolean OnAlerting(const H323SignalPDU &, const PString &);
  67. PBoolean OnSendReleaseComplete(H323SignalPDU &);
  68. PBoolean OnReceivedSignalSetup(const H323SignalPDU &);
  69. PBoolean OnReceivedFacility(const H323SignalPDU &);
  70. PBoolean OnSendSignalSetup(H323SignalPDU &);
  71. PBoolean OnStartLogicalChannel(H323Channel &);
  72. PBoolean OnClosingLogicalChannel(H323Channel &);
  73. virtual void SendUserInputTone(char tone, unsigned duration = 0, unsigned logicalChannel = 0, unsigned rtpTimestamp = 0);
  74. virtual void OnUserInputTone(char, unsigned, unsigned, unsigned);
  75. virtual void OnUserInputString(const PString &value);
  76. PBoolean OnReceivedProgress(const H323SignalPDU &);
  77. PBoolean MySendProgress();
  78. void OnSendCapabilitySet(H245_TerminalCapabilitySet &);
  79. void OnSetLocalCapabilities();
  80. void SetCapabilities(int, int, void *, int);
  81. PBoolean OnReceivedCapabilitySet(const H323Capabilities &, const H245_MultiplexCapability *,
  82. H245_TerminalCapabilitySetReject &);
  83. void SetCause(int _cause) { cause = _cause; };
  84. virtual PBoolean StartControlChannel(const H225_TransportAddress & h245Address);
  85. void SetCallOptions(void *opts, PBoolean isIncoming);
  86. void SetCallDetails(void *callDetails, const H323SignalPDU &setupPDU, PBoolean isIncoming);
  87. virtual H323Connection::CallEndReason SendSignalSetup(const PString&, const H323TransportAddress&);
  88. #ifdef TUNNELLING
  89. virtual PBoolean HandleSignalPDU(H323SignalPDU &pdu);
  90. PBoolean EmbedTunneledInfo(H323SignalPDU &pdu);
  91. #endif
  92. #ifdef H323_H450
  93. virtual void OnReceivedLocalCallHold(int linkedId);
  94. virtual void OnReceivedLocalCallRetrieve(int linkedId);
  95. #endif
  96. void MyHoldCall(BOOL localHold);
  97. PString sourceAliases;
  98. PString destAliases;
  99. PString sourceE164;
  100. PString destE164;
  101. int cid_presentation;
  102. int cid_ton;
  103. PString rdnis;
  104. int redirect_reason;
  105. int transfer_capability;
  106. WORD sessionId;
  107. PBoolean bridging;
  108. #ifdef TUNNELLING
  109. int remoteTunnelOptions;
  110. int tunnelOptions;
  111. #endif
  112. unsigned holdHandling;
  113. unsigned progressSetup;
  114. unsigned progressAlert;
  115. int cause;
  116. RTP_DataFrame::PayloadTypes dtmfCodec[2];
  117. int dtmfMode;
  118. };
  119. class MyH323_ExternalRTPChannel : public H323_ExternalRTPChannel
  120. {
  121. PCLASSINFO(MyH323_ExternalRTPChannel, H323_ExternalRTPChannel);
  122. public:
  123. MyH323_ExternalRTPChannel(
  124. MyH323Connection & connection,
  125. const H323Capability & capability,
  126. Directions direction,
  127. unsigned sessionID);
  128. ~MyH323_ExternalRTPChannel();
  129. /* Overrides */
  130. PBoolean Start(void);
  131. PBoolean OnReceivedAckPDU(const H245_H2250LogicalChannelAckParameters & param);
  132. protected:
  133. BYTE payloadCode;
  134. PIPSocket::Address localIpAddr;
  135. PIPSocket::Address remoteIpAddr;
  136. /* Additional functions in order to have chan_h323 compile with H323Plus */
  137. #if VERSION(OPENH323_MAJOR, OPENH323_MINOR, OPENH323_BUILD) > VERSION(1,19,4)
  138. BOOL OnReceivedAltPDU(const H245_ArrayOf_GenericInformation & alternate );
  139. BOOL OnSendingAltPDU(H245_ArrayOf_GenericInformation & alternate) const;
  140. void OnSendOpenAckAlt(H245_ArrayOf_GenericInformation & alternate) const;
  141. BOOL OnReceivedAckAltPDU(const H245_ArrayOf_GenericInformation & alternate);
  142. #endif
  143. WORD localPort;
  144. WORD remotePort;
  145. };
  146. #ifdef H323_H450
  147. #if VERSION(OPENH323_MAJOR, OPENH323_MINOR, OPENH323_BUILD) > VERSION(1,19,4)
  148. #include <h450/h450pdu.h>
  149. #else
  150. #include <h450pdu.h>
  151. #endif
  152. class MyH4504Handler : public H4504Handler
  153. {
  154. PCLASSINFO(MyH4504Handler, H4504Handler);
  155. public:
  156. MyH4504Handler(MyH323Connection &_conn, H450xDispatcher &_disp);
  157. virtual void OnReceivedLocalCallHold(int linkedId);
  158. virtual void OnReceivedLocalCallRetrieve(int linkedId);
  159. private:
  160. MyH323Connection *conn;
  161. };
  162. #endif
  163. #endif /* !defined AST_H323_H */