OPAL  Version 3.18.8
h460_std19.h
Go to the documentation of this file.
1 /*
2  * h460_std19.h
3  *
4  * Copyright (c) 2009 ISVO (Asia) Pte Ltd. All Rights Reserved.
5  *
6  * The contents of this file are subject to the Mozilla Public License
7  * Version 1.1 (the "License"); you may not use this file except in
8  * compliance with the License. You may obtain a copy of the License at
9  * http://www.mozilla.org/MPL/
10  *
11  * Alternatively, the contents of this file may be used under the terms
12  * of the General Public License (the "GNU License"), in which case the
13  * provisions of GNU License are applicable instead of those
14  * above. If you wish to allow use of your version of this file only
15  * under the terms of the GNU License and not to allow others to use
16  * your version of this file under the MPL, indicate your decision by
17  * deleting the provisions above and replace them with the notice and
18  * other provisions required by the GNU License. If you do not delete
19  * the provisions above, a recipient may use your version of this file
20  * under either the MPL or the GNU License."
21  *
22  * Software distributed under the License is distributed on an "AS IS"
23  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
24  * the License for the specific language governing rights and limitations
25  * under the License.
26  *
27  * The Original Code is derived from and used in conjunction with the
28  * H323Plus Project (www.h323plus.org/)
29  *
30  * The Initial Developer of the Original Code is ISVO (Asia) Pte Ltd.
31  *
32  * Contributor(s): Many thanks to Simon Horne.
33  * Robert Jongbloed (robertj@voxlucida.com.au).
34  */
35 
36 #ifndef OPAL_H460_STD19_H
37 #define OPAL_H460_STD19_H
38 
39 #include <h460/h4601.h>
40 
41 #if OPAL_H460_NAT
42 
43 #include <rtp/rtp.h>
44 
45 #if _MSC_VER
46 #pragma once
47 #endif
48 
49 
50 class OpalRTPSession;
52 
53 
54 class H460_FeatureStd19 : public H460_Feature
55 {
56  PCLASSINFO_WITH_CLONE(H460_FeatureStd19, H460_Feature);
57  public:
58  H460_FeatureStd19();
59 
60  static const H460_FeatureID & ID();
61  virtual bool Initialise(H323EndPoint & ep, H323Connection * con);
62 
63  // H.225.0 Messages
64  virtual bool OnSendPDU(H460_MessageType pduType, H460_FeatureDescriptor & pdu);
65  virtual void OnReceivePDU(H460_MessageType pduType, const H460_FeatureDescriptor & pdu);
66 
67  virtual bool OnSendingOLCGenericInformation(unsigned sessionID, H245_ArrayOf_GenericParameter & param, bool isAck);
68  virtual void OnReceiveOLCGenericInformation(unsigned sessionID, const H245_ArrayOf_GenericParameter & param, bool isAck);
69 
70  // Member access
71  bool IsRemoteServer() const { return m_remoteIsServer; }
72 
73  protected:
74  PNatMethod * m_natMethod;
75  bool m_disabledByH46024;
76  bool m_remoteSupportsMux;
77  bool m_remoteIsServer;
78 };
79 
80 
82 
83 class H46019Server : public PObject
84 {
85  PCLASSINFO(H46019Server, PObject)
86  public:
87  H46019Server(H323EndPoint & ep);
88  H46019Server(
89  H323EndPoint & ep,
90  const PIPSocket::Address & localInterface
91  );
92  ~H46019Server();
93 
94  unsigned GetKeepAliveTTL() const { return m_keepAliveTTL; }
95  void SetKeepAliveTTL(unsigned val) { m_keepAliveTTL = val; }
96 
97  H323TransportAddress GetKeepAliveAddress() const;
98  H323TransportAddress GetMuxRTPAddress() const;
99  H323TransportAddress GetMuxRTCPAddress() const;
100 
101  unsigned CreateMultiplexID(
102  const PIPSocketAddressAndPort & rtp,
103  const PIPSocketAddressAndPort & rtcp
104  );
105 
106  protected:
107  H323EndPoint & m_endpoint;
108  unsigned m_keepAliveTTL;
109 
110  PUDPSocket * m_keepAliveSocket;
111  PUDPSocket * m_rtpSocket;
112  PUDPSocket * m_rtcpSocket;
113 
114  struct SocketPair {
115  SocketPair(const PIPSocketAddressAndPort & rtp, const PIPSocketAddressAndPort & rtcp) : m_rtp(rtp), m_rtcp(rtcp) { }
116  PIPSocketAddressAndPort m_rtp;
117  PIPSocketAddressAndPort m_rtcp;
118  };
119  typedef map<uint32_t, SocketPair> MuxMap;
120  MuxMap m_multiplexedSockets;
121 
122  PThread * m_multiplexThread;
123  void MultiplexThread();
124  bool Multiplex(bool rtcp);
125 };
126 
127 
129 
130 class PNatMethod_H46019 : public PNatMethod
131 {
132  PCLASSINFO(PNatMethod_H46019, PNatMethod);
133  public:
134  enum { DefaultPriority = 20 };
135  PNatMethod_H46019(unsigned priority = DefaultPriority);
136 
142  virtual PCaselessString GetMethodName() const;
143  static const char * MethodName();
144 
147  virtual PString GetServer() const;
148 
157  virtual bool IsAvailable(const PIPSocket::Address & address, PObject * userData);
159 
160  protected:
161  virtual bool InternalGetServerAddress(PIPSocketAddressAndPort & ap) const;
162  virtual PNATUDPSocket * InternalCreateSocket(Component component, PObject * context);
163  virtual void InternalUpdate(bool);
164 };
165 
166 
168 
169 class H46019UDPSocket : public PNATUDPSocket
170 {
171  PCLASSINFO(H46019UDPSocket, PNATUDPSocket);
172  public:
178  H46019UDPSocket(
179  PNatMethod::Component component,
180  OpalRTPSession & session
181  );
182 
183  ~H46019UDPSocket();
185 
188  virtual const char * GetNatName() const;
189 
192  void ActivateKeepAliveRTP(
193  const H323TransportAddress & address,
194  unsigned ttl
195  );
196 
197  void ActivateKeepAliveRTCP(unsigned ttl);
198 
199  void SetMultiplexID(unsigned multiplexID) { m_multiplexedTransmit = true; m_multiplexID = multiplexID; }
200 
201  RTP_DataFrame::PayloadTypes FindKeepAlivePayloadType(H323Connection & connection);
202 
203  protected:
204  bool InternalWriteTo(const Slice * slices, size_t sliceCount, const PIPSocketAddressAndPort & ipAndPort);
205 
206  // Memeber variables
207  OpalRTPSession & m_session;
208 
209  // H.460.19 keep alives
210  PIPSocketAddressAndPort m_keepAliveAddress;
211  RTP_DataFrame::PayloadTypes m_keepAlivePayloadType;
212  PTimeInterval m_keepAliveTTL;
213  WORD m_keepAliveSequence;
214 
215  PDECLARE_NOTIFIER(PTimer, H46019UDPSocket, KeepAliveTimeout);
216  PTimer m_keepAliveTimer;
217  void SendKeepAliveRTP(const PIPSocketAddressAndPort & ipAndPort);
218 
219  // H.460.19 multiplex transmit
220  bool m_multiplexedTransmit;
221  PUInt32b m_multiplexID;
222 };
223 
224 
225 #endif // OPAL_H460_NAT
226 
227 #endif // OPAL_H460_STD19_H
virtual bool OnSendPDU(H460_MessageType pduType, H460_FeatureDescriptor &pdu)
Definition: h46019.h:28
Definition: h4601.h:267
virtual void OnReceivePDU(H460_MessageType pduType, const H460_FeatureDescriptor &pdu)
virtual void OnReceiveOLCGenericInformation(unsigned, const H245_ArrayOf_GenericParameter &, bool)
Definition: h4601.h:592
PayloadTypes
Definition: rtp.h:556
virtual bool Initialise(H323EndPoint &ep, H323Connection *con)
Definition: rtp_session.h:90
Definition: h323con.h:137
Definition: h460.h:53
virtual bool OnSendingOLCGenericInformation(unsigned, H245_ArrayOf_GenericParameter &, bool)
Definition: h4601.h:591
Definition: h4601.h:75
Definition: h323ep.h:82
Definition: transaddr.h:62
Definition: h4601.h:369