h224handler.h

Go to the documentation of this file.
00001 /*
00002  * h224handler.h
00003  *
00004  * H.224 protocol handler implementation for the OpenH323 Project.
00005  *
00006  * Copyright (c) 2006 Network for Educational Technology, ETH Zurich.
00007  * Written by Hannes Friederich.
00008  *
00009  * The contents of this file are subject to the Mozilla Public License
00010  * Version 1.0 (the "License"); you may not use this file except in
00011  * compliance with the License. You may obtain a copy of the License at
00012  * http://www.mozilla.org/MPL/
00013  *
00014  * Software distributed under the License is distributed on an "AS IS"
00015  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
00016  * the License for the specific language governing rights and limitations
00017  * under the License.
00018  *
00019  * Contributor(s): ______________________________________.
00020  *
00021  * $Revision: 21346 $
00022  * $Author: hfriederich $
00023  * $Date: 2008-10-15 22:21:15 +0000 (Wed, 15 Oct 2008) $
00024  */
00025 
00026 #ifndef OPAL_H224_H224HANDLER_H
00027 #define OPAL_H224_H224HANDLER_H
00028 
00029 #ifdef P_USE_PRAGMA
00030 #pragma interface
00031 #endif
00032 
00033 #ifndef _PTLIB_H
00034 #include <ptlib.h>
00035 #endif
00036 
00037 #include <opal/buildopts.h>
00038 
00039 #include <opal/connection.h>
00040 #include <opal/transports.h>
00041 #include <opal/mediastrm.h>
00042 #include <rtp/rtp.h>
00043 #include <h224/h224.h>
00044 
00045 class OpalH224Handler;
00046 
00047 class OpalH224Client : public PObject
00048 {
00049   PCLASSINFO(OpalH224Client, PObject);
00050   
00051 public:
00052 
00053   OpalH224Client();
00054   ~OpalH224Client();
00055   
00056   enum {
00057     CMEClientID         = 0x00,
00058     H281ClientID        = 0x01,
00059     ExtendedClientID    = 0x7e,
00060     NonStandardClientID = 0x7f,
00061   };
00062 
00066   virtual BYTE GetClientID() const = 0;
00067 
00070   virtual BYTE GetExtendedClientID() const { return 0x00; }
00071 
00075   virtual BYTE GetCountryCode() const { return 0xff; /* CountryCodeEscape */ }
00076 
00080   virtual BYTE GetCountryCodeExtension() const { return 0x00; }
00081 
00085   virtual WORD GetManufacturerCode() const { return 0x0000; }
00086 
00090   virtual BYTE GetManufacturerClientID() const { return 0x00; }
00091 
00095   virtual PBoolean HasExtraCapabilities() const { return PFalse; }
00096 
00100   virtual void OnReceivedExtraCapabilities(const BYTE * /*capabilities*/, PINDEX /*size*/) { }
00101 
00105   virtual void OnReceivedMessage(const H224_Frame & /*message*/) { }
00106 
00110   virtual void SendExtraCapabilities() const { }
00111 
00112   virtual Comparison Compare(const PObject & obj);
00113 
00115   void SetH224Handler(OpalH224Handler * handler) { h224Handler = handler; }
00116 
00118   void SetRemoteClientAvailable(PBoolean remoteClientAvailable, PBoolean remoteClientHasExtraCapabilities);
00119 
00120   PBoolean GetRemoteClientAvailable() const { return remoteClientAvailable; }
00121   PBoolean GetRemoteClientHasExtraCapabilities() const { return remoteClientHasExtraCapabilities; }
00122 
00123 protected:
00124 
00125   PBoolean remoteClientAvailable;
00126   PBoolean remoteClientHasExtraCapabilities;
00127   OpalH224Handler * h224Handler;
00128 };
00129 
00130 PSORTED_LIST(OpalH224ClientList, OpalH224Client);
00131 
00133 
00134 class OpalH224MediaStream;
00135 
00136 class OpalH224Handler : public PObject
00137 {
00138   PCLASSINFO(OpalH224Handler, PObject);
00139         
00140 public:
00141         
00142   OpalH224Handler();
00143   ~OpalH224Handler();
00144   
00145   enum {
00146     Broadcast = 0x0000,
00147     
00148     CMEClientListCode        = 0x01,
00149     CMEExtraCapabilitiesCode = 0x02,
00150     CMEMessage               = 0x00,
00151     CMECommand               = 0xff,
00152     
00153     CountryCodeEscape   = 0xff,
00154   };
00155   
00157   PBoolean AddClient(OpalH224Client & client);
00158   PBoolean RemoveClient(OpalH224Client & client);
00159   
00161   void SetTransmitMediaFormat(const OpalMediaFormat & mediaFormat);
00162   void SetReceiveMediaFormat(const OpalMediaFormat & mediaFormat);
00163   
00165   void SetTransmitMediaStream(OpalH224MediaStream * transmitMediaStream);
00166         
00167   virtual void StartTransmit();
00168   virtual void StopTransmit();
00169   
00171   PBoolean SendClientList();
00172   
00174   PBoolean SendExtraCapabilities();
00175   
00177   PBoolean SendClientListCommand();
00178   
00180   PBoolean SendExtraCapabilitiesCommand(const OpalH224Client & client);
00181 
00183   PBoolean SendExtraCapabilitiesMessage(const OpalH224Client & client, BYTE *data, PINDEX length);
00184 
00186   PBoolean TransmitClientFrame(const OpalH224Client & client, H224_Frame & frame);
00187         
00188   PBoolean HandleFrame(const RTP_DataFrame & rtpFrame);
00189   virtual PBoolean OnReceivedFrame(H224_Frame & frame);
00190   virtual PBoolean OnReceivedCMEMessage(H224_Frame & frame);
00191   virtual PBoolean OnReceivedClientList(H224_Frame & frame);
00192   virtual PBoolean OnReceivedClientListCommand();
00193   virtual PBoolean OnReceivedExtraCapabilities(H224_Frame & frame);
00194   virtual PBoolean OnReceivedExtraCapabilitiesCommand();
00195   
00196   PMutex & GetTransmitMutex() { return transmitMutex; }
00197         
00198 protected:
00199 
00200   PMutex transmitMutex;
00201   PBoolean canTransmit;
00202   RTP_DataFrame transmitFrame;
00203   BYTE transmitBitIndex;
00204   PTime *transmitStartTime;
00205   OpalH224MediaStream * transmitMediaStream;
00206   
00207   H224_Frame receiveFrame;
00208   
00209   OpalH224ClientList clients;
00210         
00211 private:
00212   void TransmitFrame(H224_Frame & frame);
00213         
00214   PBoolean transmitHDLCTunneling;
00215   PBoolean receiveHDLCTunneling;
00216 };
00217 
00219 
00220 class OpalH224MediaStream : public OpalMediaStream
00221 {
00222   PCLASSINFO(OpalH224MediaStream, OpalMediaStream);
00223   
00224 public:
00225   OpalH224MediaStream(OpalConnection & connection,
00226                       OpalH224Handler & h224Handler,
00227                       const OpalMediaFormat & mediaFormat,
00228                       unsigned sessionID,
00229                       PBoolean isSource);
00230   ~OpalH224MediaStream();
00231   
00232   virtual void OnPatchStart();
00233   virtual PBoolean Close();
00234   virtual PBoolean ReadPacket(RTP_DataFrame & packet);
00235   virtual PBoolean WritePacket(RTP_DataFrame & packet);
00236   virtual PBoolean IsSynchronous() const { return PFalse; }
00237   virtual PBoolean RequiresPatchThread() const { return isSource ? PFalse : PTrue; }
00238   
00239 private:
00240     OpalH224Handler & h224Handler;
00241 };
00242 
00243 #endif // OPAL_H224_H224HANDLER_H
00244 

Generated on Mon Feb 1 00:25:22 2010 for OPAL by  doxygen 1.5.1