g726codec.h

Go to the documentation of this file.
00001 /*
00002  * g726codec.h
00003  *
00004  * H.323 protocol handler
00005  *
00006  * Open H323 Library
00007  *
00008  * Copyright (c) 1998-2000 Equivalence Pty. Ltd.
00009  *
00010  * The contents of this file are subject to the Mozilla Public License
00011  * Version 1.0 (the "License"); you may not use this file except in
00012  * compliance with the License. You may obtain a copy of the License at
00013  * http://www.mozilla.org/MPL/
00014  *
00015  * Software distributed under the License is distributed on an "AS IS"
00016  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
00017  * the License for the specific language governing rights and limitations
00018  * under the License.
00019  *
00020  * The Original Code is Open H323 Library.
00021  *
00022  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
00023  *
00024  * Contributor(s): ______________________________________.
00025  *
00026  * $Log: g726codec.h,v $
00027  * Revision 2.10.2.1  2006/02/09 00:32:11  csoutheren
00028  * Backported G.726 fixes from CVS head
00029  *
00030  * Revision 2.11  2006/02/08 04:00:17  csoutheren
00031  * Fixed for G.726 codec
00032  * Thanks to Michael Tinglof
00033  *
00034  * Revision 2.10  2005/11/30 13:35:26  csoutheren
00035  * Changed tags for Doxygen
00036  *
00037  * Revision 2.9  2005/08/28 07:59:17  rjongbloed
00038  * Converted OpalTranscoder to use factory, requiring sme changes in making sure
00039  *   OpalMediaFormat instances are initialised before use.
00040  *
00041  * Revision 2.8  2005/02/21 12:19:44  rjongbloed
00042  * Added new "options list" to the OpalMediaFormat class.
00043  *
00044  * Revision 2.7  2004/09/01 12:21:26  rjongbloed
00045  * Added initialisation of H323EndPoints capability table to be all codecs so can
00046  *   correctly build remote caps from fqast connect params. This had knock on effect
00047  *   with const keywords added in numerous places.
00048  *
00049  * Revision 2.6  2004/05/15 12:53:40  rjongbloed
00050  * Fixed incorrect laoding of H.323 capability for G.726
00051  *
00052  * Revision 2.5  2002/11/10 23:21:49  robertj
00053  * Cosmetic change
00054  *
00055  * Revision 2.4  2002/11/10 11:33:16  robertj
00056  * Updated to OpenH323 v1.10.3
00057  *
00058  * Revision 2.3  2002/09/16 02:52:33  robertj
00059  * Added #define so can select if #pragma interface/implementation is used on
00060  *   platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
00061  *
00062  * Revision 2.2  2002/09/04 06:01:46  robertj
00063  * Updated to OpenH323 v1.9.6
00064  *
00065  */
00066 
00067 #ifndef __OPAL_G726CODEC_H
00068 #define __OPAL_G726CODEC_H
00069 
00070 #ifdef P_USE_PRAGMA
00071 #pragma interface
00072 #endif
00073 
00074 
00075 #include <opal/transcoders.h>
00076 
00077 #ifndef NO_H323
00078 #include <h323/h323caps.h>
00079 #endif
00080 
00081 
00082 struct g726_state_s;
00083 
00084 #define OPAL_G726_40 "G.726-40k"
00085 #define OPAL_G726_32 "G.726-32k"
00086 #define OPAL_G726_24 "G.726-24k"
00087 #define OPAL_G726_16 "G.726-16k"
00088 
00089 extern const OpalAudioFormat & GetOpalG726_40();
00090 extern const OpalAudioFormat & GetOpalG726_32();
00091 extern const OpalAudioFormat & GetOpalG726_24();
00092 extern const OpalAudioFormat & GetOpalG726_16();
00093 
00094 #define OpalG726_40 GetOpalG726_40()
00095 #define OpalG726_32 GetOpalG726_32()
00096 #define OpalG726_24 GetOpalG726_24()
00097 #define OpalG726_16 GetOpalG726_16()
00098 
00100 
00101 #ifndef NO_H323
00102 
00105 class H323_G726_Capability : public H323NonStandardAudioCapability
00106 {
00107   PCLASSINFO(H323_G726_Capability, H323NonStandardAudioCapability)
00108         
00109 
00110   public:
00111     enum Speeds {
00112       e_40k,
00113       e_32k,
00114       e_24k,
00115       e_16k,
00116       NumSpeeds
00117     };
00118 
00123     H323_G726_Capability(
00124       const H323EndPoint & endpoint,  
00125       Speeds speed              
00126     );
00128 
00133     virtual PObject * Clone() const;
00135 
00140     virtual PString GetFormatName() const;
00142 
00152     virtual BOOL OnSendingPDU(
00153       H245_AudioCapability & pdu,  
00154       unsigned packetSize          
00155     ) const;
00156 
00164     virtual BOOL OnReceivedPDU(
00165       const H245_AudioCapability & pdu,  
00166       unsigned & packetSize              
00167     );
00169 
00170   protected:
00171     Speeds speed;
00172 };
00173 
00174 
00175 #if defined(H323_STATIC_LIB)
00176 H323_STATIC_LOAD_REGISTER_CAPABILITY(H323_G726_40_Capability);
00177 H323_STATIC_LOAD_REGISTER_CAPABILITY(H323_G726_32_Capability);
00178 H323_STATIC_LOAD_REGISTER_CAPABILITY(H323_G726_24_Capability);
00179 H323_STATIC_LOAD_REGISTER_CAPABILITY(H323_G726_16_Capability);
00180 #endif
00181 
00182 
00183 #define OPAL_REGISTER_G726_H323 \
00184   H323_REGISTER_CAPABILITY_FUNCTION(H323_G726_40_Capability, OPAL_G726_40, ep) \
00185     { return new H323_G726_Capability(ep, H323_G726_Capability::e_40k); } \
00186   H323_REGISTER_CAPABILITY_FUNCTION(H323_G726_32_Capability, OPAL_G726_32, ep) \
00187     { return new H323_G726_Capability(ep, H323_G726_Capability::e_32k); } \
00188   H323_REGISTER_CAPABILITY_FUNCTION(H323_G726_24_Capability, OPAL_G726_24, ep) \
00189     { return new H323_G726_Capability(ep, H323_G726_Capability::e_24k); } \
00190   H323_REGISTER_CAPABILITY_FUNCTION(H323_G726_16_Capability, OPAL_G726_16, ep) \
00191     { return new H323_G726_Capability(ep, H323_G726_Capability::e_16k); }
00192 
00193 #else // ifndef NO_H323
00194 
00195 #define OPAL_REGISTER_G726_H323
00196 
00197 #endif // ifndef NO_H323
00198 
00199 
00201 
00202 class Opal_G726_Transcoder : public OpalStreamedTranscoder {
00203   public:
00204     Opal_G726_Transcoder(
00205       const OpalMediaFormat & inputMediaFormat,  
00206       const OpalMediaFormat & outputMediaFormat, 
00207       unsigned in_bits,
00208           unsigned out_bits
00209     );
00210     ~Opal_G726_Transcoder();
00211   protected:
00212     g726_state_s * g726;
00213 };
00214 
00215 
00216 class Opal_G726_40_PCM : public Opal_G726_Transcoder {
00217   public:
00218     Opal_G726_40_PCM();
00219     virtual int ConvertOne(int sample) const;
00220 };
00221 
00222 
00223 class Opal_PCM_G726_40 : public Opal_G726_Transcoder {
00224   public:
00225     Opal_PCM_G726_40();
00226     virtual int ConvertOne(int sample) const;
00227 };
00228 
00229 
00230 class Opal_G726_32_PCM : public Opal_G726_Transcoder {
00231   public:
00232     Opal_G726_32_PCM();
00233     virtual int ConvertOne(int sample) const;
00234 };
00235 
00236 
00237 class Opal_PCM_G726_32 : public Opal_G726_Transcoder {
00238   public:
00239     Opal_PCM_G726_32();
00240     virtual int ConvertOne(int sample) const;
00241 };
00242 
00243 
00244 class Opal_G726_24_PCM : public Opal_G726_Transcoder {
00245   public:
00246     Opal_G726_24_PCM();
00247     virtual int ConvertOne(int sample) const;
00248 };
00249 
00250 
00251 class Opal_PCM_G726_24 : public Opal_G726_Transcoder {
00252   public:
00253     Opal_PCM_G726_24();
00254     virtual int ConvertOne(int sample) const;
00255 };
00256 
00257 
00258 class Opal_G726_16_PCM : public Opal_G726_Transcoder {
00259   public:
00260     Opal_G726_16_PCM();
00261     virtual int ConvertOne(int sample) const;
00262 };
00263 
00264 
00265 class Opal_PCM_G726_16 : public Opal_G726_Transcoder {
00266   public:
00267     Opal_PCM_G726_16();
00268     virtual int ConvertOne(int sample) const;
00269 };
00270 
00271 
00273 
00274 #define OPAL_REGISTER_G726() \
00275           OPAL_REGISTER_G726_H323 \
00276           OPAL_REGISTER_TRANSCODER(Opal_G726_40_PCM, OpalG726_40, OpalPCM16); \
00277           OPAL_REGISTER_TRANSCODER(Opal_PCM_G726_40, OpalPCM16,   OpalG726_40); \
00278           OPAL_REGISTER_TRANSCODER(Opal_G726_32_PCM, OpalG726_32, OpalPCM16); \
00279           OPAL_REGISTER_TRANSCODER(Opal_PCM_G726_32, OpalPCM16,   OpalG726_32); \
00280           OPAL_REGISTER_TRANSCODER(Opal_G726_24_PCM, OpalG726_24, OpalPCM16); \
00281           OPAL_REGISTER_TRANSCODER(Opal_PCM_G726_24, OpalPCM16,   OpalG726_24); \
00282           OPAL_REGISTER_TRANSCODER(Opal_G726_16_PCM, OpalG726_16, OpalPCM16); \
00283           OPAL_REGISTER_TRANSCODER(Opal_PCM_G726_16, OpalPCM16,   OpalG726_16)
00284 
00285 
00286 #endif // __OPAL_G726CODEC_H
00287 
00288 

Generated on Mon Sep 25 16:19:33 2006 for OPAL by  doxygen 1.4.7