OPAL  Version 3.12.9
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: 27410 $
22  * $Author: rjongbloed $
23  * $Date: 2012-04-02 17:36:39 +1000 (Mon, 02 Apr 2012) $
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 #ifndef _PTLIB_H
34 #include <ptlib.h>
35 #endif
36 
37 #include <opal/buildopts.h>
38 
39 #include <opal/connection.h>
40 #include <opal/transports.h>
41 #include <opal/mediastrm.h>
42 #include <rtp/rtp.h>
43 #include <h224/h224.h>
44 
45 class OpalH224Handler;
46 
47 class OpalH224Client : public PObject
48 {
49  PCLASSINFO(OpalH224Client, PObject);
50 
51 public:
52 
55 
56  enum {
57  CMEClientID = 0x00,
58  H281ClientID = 0x01,
61  };
62 
66  virtual BYTE GetClientID() const = 0;
67 
70  virtual BYTE GetExtendedClientID() const { return 0x00; }
71 
75  virtual BYTE GetCountryCode() const { return 0xff; /* CountryCodeEscape */ }
76 
80  virtual BYTE GetCountryCodeExtension() const { return 0x00; }
81 
85  virtual WORD GetManufacturerCode() const { return 0x0000; }
86 
90  virtual BYTE GetManufacturerClientID() const { return 0x00; }
91 
95  virtual PBoolean HasExtraCapabilities() const { return false; }
96 
100  virtual void OnReceivedExtraCapabilities(const BYTE * /*capabilities*/, PINDEX /*size*/) { }
101 
105  virtual void OnReceivedMessage(const H224_Frame & /*message*/) { }
106 
110  virtual void SendExtraCapabilities() const { }
111 
112  virtual Comparison Compare(const PObject & obj);
113 
115  void SetH224Handler(OpalH224Handler * handler) { h224Handler = handler; }
116 
119 
120  PBoolean GetRemoteClientAvailable() const { return remoteClientAvailable; }
122 
123 protected:
124 
128 };
129 
130 PSORTED_LIST(OpalH224ClientList, OpalH224Client);
131 
133 
134 class OpalH224MediaStream;
135 
136 class OpalH224Handler : public PObject
137 {
138  PCLASSINFO(OpalH224Handler, PObject);
139 
140 public:
141 
142  OpalH224Handler();
144 
145  enum {
146  Broadcast = 0x0000,
147 
150  CMEMessage = 0x00,
151  CMECommand = 0xff,
152 
154  };
155 
157  PBoolean AddClient(OpalH224Client & client);
158  PBoolean RemoveClient(OpalH224Client & client);
159 
161  void SetTransmitMediaFormat(const OpalMediaFormat & mediaFormat);
162  void SetReceiveMediaFormat(const OpalMediaFormat & mediaFormat);
163 
166 
167  virtual void StartTransmit();
168  virtual void StopTransmit();
169 
171  PBoolean SendClientList();
172 
174  PBoolean SendExtraCapabilities();
175 
177  PBoolean SendClientListCommand();
178 
180  PBoolean SendExtraCapabilitiesCommand(const OpalH224Client & client);
181 
183  PBoolean SendExtraCapabilitiesMessage(const OpalH224Client & client, BYTE *data, PINDEX length);
184 
186  PBoolean TransmitClientFrame(const OpalH224Client & client, H224_Frame & frame);
187 
188  PBoolean HandleFrame(const RTP_DataFrame & rtpFrame);
189  virtual PBoolean OnReceivedFrame(H224_Frame & frame);
190  virtual PBoolean OnReceivedCMEMessage(H224_Frame & frame);
191  virtual PBoolean OnReceivedClientList(H224_Frame & frame);
192  virtual PBoolean OnReceivedClientListCommand();
193  virtual PBoolean OnReceivedExtraCapabilities(H224_Frame & frame);
194  virtual PBoolean OnReceivedExtraCapabilitiesCommand();
195 
196  PMutex & GetTransmitMutex() { return transmitMutex; }
197 
198 protected:
199 
201  PBoolean canTransmit;
206 
208 
209  OpalH224ClientList clients;
210 
211 private:
212  void TransmitFrame(H224_Frame & frame);
213 
214  PBoolean transmitHDLCTunneling;
215  PBoolean receiveHDLCTunneling;
216 };
217 
219 
221 {
223 
224  public:
226  OpalH224Handler & h224Handler,
228  unsigned sessionID,
229  PBoolean isSource);
231 
232  virtual void OnStartMediaPatch();
233  virtual PBoolean ReadPacket(RTP_DataFrame & packet);
234  virtual PBoolean WritePacket(RTP_DataFrame & packet);
235  virtual PBoolean IsSynchronous() const { return false; }
236  virtual PBoolean RequiresPatchThread() const { return IsSink(); }
237 
238  private:
239  virtual void InternalClose();
240 
241  OpalH224Handler & h224Handler;
242 };
243 
244 #endif // OPAL_H224_H224HANDLER_H
245