home *** CD-ROM | disk | FTP | other *** search
/ ftp.muug.mb.ca / 2014.06.ftp.muug.mb.ca.tar / ftp.muug.mb.ca / pub / openh323.tar.gz / openh323.tar / openh323 / include / g7231codec.h < prev    next >
C/C++ Source or Header  |  2002-09-15  |  6KB  |  201 lines

  1. /*
  2.  * g7231codec.h
  3.  *
  4.  * H.323 interface for a G.723.1 codec
  5.  *
  6.  * Open H323 Library
  7.  *
  8.  * Copyright (c) 2001 Equivalence Pty. Ltd.
  9.  *
  10.  * The contents of this file are subject to the Mozilla Public License
  11.  * Version 1.0 (the "License"); you may not use this file except in
  12.  * compliance with the License. You may obtain a copy of the License at
  13.  * http://www.mozilla.org/MPL/
  14.  *
  15.  * Software distributed under the License is distributed on an "AS IS"
  16.  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
  17.  * the License for the specific language governing rights and limitations
  18.  * under the License.
  19.  *
  20.  * The Original Code is Open H323 Library.
  21.  *
  22.  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
  23.  *
  24.  * Contributor(s): ______________________________________.
  25.  *
  26.  * $Log: g7231codec.h,v $
  27.  * Revision 1.5  2002/09/16 01:14:15  robertj
  28.  * Added #define so can select if #pragma interface/implementation is used on
  29.  *   platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
  30.  *
  31.  * Revision 1.4  2002/09/03 06:19:36  robertj
  32.  * Normalised the multi-include header prevention ifdef/define symbol.
  33.  *
  34.  * Revision 1.3  2002/08/05 10:03:47  robertj
  35.  * Cosmetic changes to normalise the usage of pragma interface/implementation.
  36.  *
  37.  * Revision 1.2  2002/06/25 08:30:08  robertj
  38.  * Changes to differentiate between stright G.723.1 and G.723.1 Annex A using
  39.  *   the OLC dataType silenceSuppression field so does not send SID frames
  40.  *   to receiver codecs that do not understand them.
  41.  *
  42.  * Revision 1.1  2001/09/21 02:54:47  robertj
  43.  * Added new codec framework with no actual implementation.
  44.  *
  45.  */
  46.  
  47. #ifndef __OPAL_G7231CODEC_H
  48. #define __OPAL_G7231CODEC_H
  49.  
  50. #ifdef P_USE_PRAGMA
  51. #pragma interface
  52. #endif
  53.  
  54.  
  55. #include "h323caps.h"
  56.  
  57.  
  58. /**This class describes the G.723.1 codec capability.
  59.  */
  60. class H323_G7231Capability : public H323AudioCapability
  61. {
  62.     PCLASSINFO(H323_G7231Capability, H323AudioCapability);
  63.   public:
  64.   /**@name Construction */
  65.   //@{
  66.     /**Create a new G.723.1 capability.
  67.      */
  68.     H323_G7231Capability(
  69.       BOOL annexA = TRUE  /// Enable Annex A silence insertion descriptors
  70.     );
  71.   //@}
  72.  
  73.   /**@name Overrides from class PObject */
  74.   //@{
  75.     /**Compare the object with another of the same class.
  76.       */
  77.     Comparison Compare(const PObject & obj) const;
  78.  
  79.     /**Create a copy of the object.
  80.       */
  81.     virtual PObject * Clone() const;
  82.   //@}
  83.  
  84.   /**@name Operations */
  85.   //@{
  86.     /**Create the codec instance, allocating resources as required.
  87.      */
  88.     virtual H323Codec * CreateCodec(
  89.       H323Codec::Direction direction  /// Direction in which this instance runs
  90.     ) const;
  91.   //@}
  92.  
  93.   /**@name Identification functions */
  94.   //@{
  95.     /**Get the sub-type of the capability. This is a code dependent on the
  96.        main type of the capability.
  97.  
  98.        This returns one of the four possible combinations of mode and speed
  99.        using the enum values of the protocol ASN H245_AudioCapability class.
  100.      */
  101.     virtual unsigned GetSubType() const;
  102.  
  103.     /**Get the name of the media data format this class represents.
  104.      */
  105.     virtual PString GetFormatName() const;
  106.   //@}
  107.  
  108.   /**@name Protocol manipulation */
  109.   //@{
  110.     /**This function is called whenever and outgoing TerminalCapabilitySet
  111.        or OpenLogicalChannel PDU is being constructed for the control channel.
  112.        It allows the capability to set the PDU fields from information in
  113.        members specific to the class.
  114.  
  115.        The default behaviour sets the data rate field in the PDU.
  116.      */
  117.     virtual BOOL OnSendingPDU(
  118.       H245_AudioCapability & pdu,  /// PDU to set information on
  119.       unsigned packetSize          /// Packet size to use in capability
  120.     ) const;
  121.  
  122.     /**This function is called whenever and incoming TerminalCapabilitySet
  123.        or OpenLogicalChannel PDU has been used to construct the control
  124.        channel. It allows the capability to set from the PDU fields,
  125.        information in members specific to the class.
  126.  
  127.        The default behaviour gets the data rate field from the PDU.
  128.      */
  129.     virtual BOOL OnReceivedPDU(
  130.       const H245_AudioCapability & pdu,  /// PDU to get information from
  131.       unsigned & packetSize              /// Packet size to use in capability
  132.     );
  133.   //@}
  134.  
  135.   protected:
  136.     BOOL annexA;
  137. };
  138.  
  139.  
  140. #ifdef ITU_REFERENCE_G7231
  141. struct dec_state;
  142. struct cod_state;
  143. #endif
  144.  
  145.  
  146. /**This class is a G.723.1 codec.
  147.  */
  148. class H323_G7231Codec : public H323FramedAudioCodec
  149. {
  150.     PCLASSINFO(H323_G7231Codec, H323FramedAudioCodec);
  151.   public:
  152.     enum {
  153.       SamplesPerFrame = 240,  // 30 milliseconds
  154.       BytesPerFrame = 24      // Encoded size
  155.     };
  156.  
  157.   /**@name Construction */
  158.   //@{
  159.     /**Create a new G.723.1 codec.
  160.      */
  161.     H323_G7231Codec(
  162.       Direction direction, /// Direction in which this instance runs
  163.       BOOL annexA          /// Use Annex A silence insertion descriptors
  164.     );
  165.     ~H323_G7231Codec();
  166.   //@}
  167.  
  168.     /**Encode a sample block into the buffer specified.
  169.        The samples have been read and are waiting in the readBuffer member
  170.        variable. it is expected this function will encode exactly
  171.        encodedBlockSize bytes.
  172.      */
  173.     virtual BOOL EncodeFrame(
  174.       BYTE * buffer,    /// Buffer into which encoded bytes are placed
  175.       unsigned & length /// Actual length of encoded data buffer
  176.     );
  177.  
  178.     /**Decode a sample block from the buffer specified.
  179.        The samples must be placed into the writeBuffer member variable. It is
  180.        expected that no more than frameSamples is decoded. The return value
  181.        is the number of samples decoded. Zero indicates an error.
  182.      */
  183.     virtual BOOL DecodeFrame(
  184.       const BYTE * buffer,  /// Buffer from which encoded data is found
  185.       unsigned length,      /// Length of encoded data buffer
  186.       unsigned & written    /// Number of bytes used from data buffer
  187.     );
  188.  
  189.   protected:
  190. #ifdef ITU_REFERENCE_G7231
  191.     struct cod_state * encoderState;
  192.     struct dec_state * decoderState;
  193. #endif
  194. };
  195.  
  196.  
  197. #endif // __OPAL_G7231CODEC_H
  198.  
  199.  
  200. /////////////////////////////////////////////////////////////////////////////
  201.