OPAL  Version 3.14.3
h224handler.h
Go to the documentation of this file.
1 /*
2  * h224handler.h
3  *
4  * H.224 protocol handler implementation for the OpenH323 Project.
5  *
6  * Copyright (c) 2006 Network for Educational Technology, ETH Zurich.
7  * Written by Hannes Friederich.
8  *
9  * The contents of this file are subject to the Mozilla Public License
10  * Version 1.0 (the "License"); you may not use this file except in
11  * compliance with the License. You may obtain a copy of the License at
12  * http://www.mozilla.org/MPL/
13  *
14  * Software distributed under the License is distributed on an "AS IS"
15  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
16  * the License for the specific language governing rights and limitations
17  * under the License.
18  *
19  * Contributor(s): ______________________________________.
20  *
21  * $Revision: 31467 $
22  * $Author: rjongbloed $
23  * $Date: 2014-02-14 17:10:49 +1100 (Fri, 14 Feb 2014) $
24  */
25 
26 #ifndef OPAL_H224_H224HANDLER_H
27 #define OPAL_H224_H224HANDLER_H
28 
29 #ifdef P_USE_PRAGMA
30 #pragma interface
31 #endif
32 
33 #include <opal_config.h>
34 
35 #if OPAL_HAS_H224
36 
37 #include <opal/connection.h>
38 #include <opal/transports.h>
39 #include <opal/mediastrm.h>
40 #include <rtp/rtp.h>
41 #include <h224/h224.h>
42 
43 class OpalH224Handler;
44 
45 class OpalH224Client : public PObject
46 {
47  PCLASSINFO(OpalH224Client, PObject);
48 
49 public:
50 
53 
54  enum {
55  CMEClientID = 0x00,
56  H281ClientID = 0x01,
59  };
60 
64  virtual BYTE GetClientID() const = 0;
65 
68  virtual BYTE GetExtendedClientID() const { return 0x00; }
69 
73  virtual BYTE GetCountryCode() const { return 0xff; /* CountryCodeEscape */ }
74 
78  virtual BYTE GetCountryCodeExtension() const { return 0x00; }
79 
83  virtual WORD GetManufacturerCode() const { return 0x0000; }
84 
88  virtual BYTE GetManufacturerClientID() const { return 0x00; }
89 
93  virtual bool HasExtraCapabilities() const { return false; }
94 
98  virtual void OnReceivedExtraCapabilities(const BYTE * /*capabilities*/, PINDEX /*size*/) { }
99 
103  virtual void OnReceivedMessage(const H224_Frame & /*message*/) { }
104 
108  virtual void SendExtraCapabilities() const { }
109 
110  virtual Comparison Compare(const PObject & obj);
111 
113  void SetH224Handler(OpalH224Handler * handler) { m_h224Handler = handler; }
114 
116  void SetRemoteClientAvailable(bool remoteClientAvailable, bool remoteClientHasExtraCapabilities);
117 
120 
121 protected:
125 };
126 
127 PSORTED_LIST(OpalH224ClientList, OpalH224Client);
128 
129 
131 
132 class OpalH224MediaStream;
133 
134 class OpalH224Handler : public PObject
135 {
136  PCLASSINFO(OpalH224Handler, PObject);
137 
138 public:
139 
140  OpalH224Handler();
142 
143  enum {
144  Broadcast = 0x0000,
145 
148  CMEMessage = 0x00,
149  CMECommand = 0xff,
150 
152  };
153 
155  bool AddClient(OpalH224Client & client);
156  bool RemoveClient(OpalH224Client & client);
157 
159  void SetTransmitMediaStream(OpalH224MediaStream * transmitMediaStream);
160 
161  virtual void StartTransmit();
162  virtual void StopTransmit();
163 
165  bool SendClientList();
166 
168  bool SendExtraCapabilities();
169 
171  bool SendClientListCommand();
172 
174  bool SendExtraCapabilitiesCommand(const OpalH224Client & client);
175 
177  bool SendExtraCapabilitiesMessage(const OpalH224Client & client, BYTE *data, PINDEX length);
178 
180  bool TransmitClientFrame(const OpalH224Client & client, H224_Frame & frame);
181 
182  virtual bool OnReceivedFrame(H224_Frame & frame);
183  virtual bool OnReceivedCMEMessage(H224_Frame & frame);
184  virtual bool OnReceivedClientList(H224_Frame & frame);
185  virtual bool OnReceivedClientListCommand();
186  virtual bool OnReceivedExtraCapabilities(H224_Frame & frame);
187  virtual bool OnReceivedExtraCapabilitiesCommand();
188 
189 protected:
190  bool TransmitFrame(H224_Frame & frame);
192  BYTE clientID,
193  BYTE extendedClientID,
194  BYTE countryCode,
195  BYTE countryCodeExtension,
196  WORD manufacturerCode,
197  BYTE manufacturerClientID
198  ) const;
199 
206 
207  OpalH224ClientList m_clients;
208 };
209 
211 
213 {
215 
216  public:
218  OpalH224Handler & h224Handler,
220  unsigned sessionID,
221  bool isSource);
223 
224  virtual void OnStartMediaPatch();
225  virtual PBoolean ReadPacket(RTP_DataFrame & packet);
226  virtual PBoolean WritePacket(RTP_DataFrame & packet);
227  virtual PBoolean IsSynchronous() const { return false; }
228  virtual PBoolean RequiresPatchThread() const { return IsSink(); }
229 
230  private:
231  virtual void InternalClose();
232 
233  OpalH224Handler & m_h224Handler;
234  unsigned m_consecutiveErrors;
235 };
236 
237 
238 #endif // OPAL_HAS_H224
239 
240 #endif // OPAL_H224_H224HANDLER_H