q922.h

Go to the documentation of this file.
00001 /*
00002  * q922.h
00003  *
00004  * Q.922 PDU 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  * $Log: q922.h,v $
00022  * Revision 1.1  2006/06/22 11:07:22  shorne
00023  * Backport of FECC (H.224) from Opal
00024  *
00025  * Revision 1.2  2006/04/23 18:52:19  dsandras
00026  * Removed warnings when compiling with gcc on Linux.
00027  *
00028  * Revision 1.1  2006/04/20 16:48:17  hfriederich
00029  * Initial version of H.224/H.281 implementation.
00030  *
00031  */
00032 
00033 #ifndef __OPAL_Q922_H
00034 #define __OPAL_Q922_H
00035 
00036 #ifdef P_USE_PRAGMA
00037 #pragma interface
00038 #endif
00039 
00040 #include <ptlib.h>
00041 
00042 #define Q922_HEADER_SIZE 3
00043 
00044 class Q922_Frame : public PBYTEArray
00045 {
00046   PCLASSINFO(Q922_Frame, PBYTEArray);
00047         
00048 public:
00049         
00050   Q922_Frame(PINDEX informationFieldSize = 260);
00051   ~Q922_Frame();
00052         
00053   BYTE GetHighOrderAddressOctet() const { return theArray[0]; }
00054   BYTE GetLowOrderAddressOctet() const { return theArray[1]; }
00055   void SetHighOrderAddressOctet(BYTE octet) { theArray[0] = octet; }
00056   void SetLowOrderAddressOctet(BYTE octet) { theArray[1] = octet; }
00057         
00058   BYTE GetControlFieldOctet() const { return theArray[2]; }
00059   void SetControlFieldOctet(BYTE octet) { theArray[2] = octet; }
00060         
00061   BYTE *GetInformationFieldPtr() const { return (BYTE *)(theArray + Q922_HEADER_SIZE); }
00062         
00063   PINDEX GetInformationFieldSize() const { return informationFieldSize; }
00064   void SetInformationFieldSize(PINDEX size);
00065         
00068   BOOL Decode(const BYTE *data, PINDEX size);
00069         
00073   PINDEX GetEncodedSize() const;
00074   
00078   BOOL Encode(BYTE *buffer, PINDEX & size) const;
00079 
00087   BOOL Encode(BYTE *buffer, PINDEX & size, BYTE & bitPosition) const;
00088         
00089 protected:
00090         
00091   PINDEX informationFieldSize;
00092         
00093 private:
00094 
00095   inline BOOL FindFlagEnd(const BYTE *buffer, PINDEX bufferSize, PINDEX & octetIndex, BYTE & bitIndex);
00096   inline BYTE DecodeByte(const BYTE *buffer, BYTE *destination, PINDEX & octetIndex, BYTE & bitIndex, BYTE & onesCounter);
00097   inline BYTE DecodeBit(const BYTE *buffer, PINDEX & octetIndex, BYTE & bitIndex);
00098         
00099   inline void EncodeOctet(BYTE octet, BYTE *buffer, PINDEX & octetIndex, BYTE & bitIndex, BYTE & onesCounter) const;
00100   inline void EncodeOctetNoEscape(BYTE octet, BYTE *buffer, PINDEX & octetIndex, BYTE & bitIndex) const;
00101   inline void EncodeBit(BYTE bit, BYTE *buffer, PINDEX & octetIndex, BYTE & bitIndex) const;
00102         
00103   inline WORD CalculateFCS(const BYTE*data, PINDEX length) const;
00104 };
00105 
00106 #endif // __OPAL_Q922_H
00107 

Generated on Wed Feb 6 09:02:44 2008 for OpenH323 by  doxygen 1.5.4