speexcodec.h

Go to the documentation of this file.
00001 /*
00002  * speexcodec.h
00003  *
00004  * Speex codec handler
00005  *
00006  * Open H323 Library
00007  *
00008  * Copyright (c) 2002 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: speexcodec.h,v $
00027  * Revision 2.10  2005/12/30 14:33:12  dsandras
00028  * Added support for Packet Loss Concealment frames for framed codecs supporting it similarly to what was done for OpenH323.
00029  *
00030  * Revision 2.9  2005/12/28 20:01:52  dsandras
00031  * Reverted mode to mode 6. Get rid of encoder_frame_size.
00032  *
00033  * Revision 2.8  2005/12/24 17:52:08  dsandras
00034  * Fixed calls to speex_encoder_ctl so that the correct mode is used. Added support for the mode 6 wideband codec.
00035  *
00036  * Revision 2.7  2005/11/30 13:35:26  csoutheren
00037  * Changed tags for Doxygen
00038  *
00039  * Revision 2.6  2005/08/28 07:59:17  rjongbloed
00040  * Converted OpalTranscoder to use factory, requiring sme changes in making sure
00041  *   OpalMediaFormat instances are initialised before use.
00042  *
00043  * Revision 2.5  2005/02/21 12:19:45  rjongbloed
00044  * Added new "options list" to the OpalMediaFormat class.
00045  *
00046  * Revision 2.4  2004/02/19 10:46:43  rjongbloed
00047  * Merged OpenH323 version 1.13.1 changes.
00048  *
00049  * Revision 2.3  2004/02/15 03:12:51  rjongbloed
00050  * Fixed typo in symbol for Speex codec, thanks Ted Szoczei
00051  *
00052  * Revision 2.2  2002/11/10 23:20:52  robertj
00053  * Fixed class names in static variable macros.
00054  *
00055  * Revision 2.1  2002/11/10 11:33:16  robertj
00056  * Updated to OpenH323 v1.10.3
00057  *
00058  * Revision 1.16  2004/01/30 00:55:40  csoutheren
00059  * Removed the Xiph capability variants per Roger Hardiman as these
00060  * were development-only code that should not have made it into a release
00061  *
00062  * Revision 1.15  2002/12/08 22:59:41  rogerh
00063  * Add XiphSpeex codec. Not yet finished.
00064  *
00065  * Revision 1.11  2002/10/24 05:32:57  robertj
00066  * MSVC compatibility
00067  *
00068  * Revision 1.10  2002/10/22 11:54:32  rogerh
00069  * Fix including of speex.h
00070  *
00071  * Revision 1.9  2002/10/22 11:33:04  rogerh
00072  * Use the local speex.h header file
00073  *
00074  * Revision 1.8  2002/09/16 01:14:15  robertj
00075  * Added #define so can select if #pragma interface/implementation is used on
00076  *   platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
00077  *
00078  * Revision 1.7  2002/08/22 08:30:23  craigs
00079  * Fixed remainder of Clone operators
00080  *
00081  * Revision 1.6  2002/08/20 15:22:50  rogerh
00082  * Make the codec name include the bitstream format for Speex to prevent users
00083  * with incompatible copies of Speex trying to use this codec.
00084  *
00085  * Revision 1.5  2002/08/15 18:35:36  rogerh
00086  * Fix more bugs with the Speex codec
00087  *
00088  * Revision 1.4  2002/08/14 19:34:31  rogerh
00089  * fix typo
00090  *
00091  * Revision 1.3  2002/08/14 04:26:20  craigs
00092  * Fixed ifdef problem
00093  *
00094  * Revision 1.2  2002/08/13 14:25:25  craigs
00095  * Added trailing newlines to avoid Linux warnings
00096  *
00097  * Revision 1.1  2002/08/13 14:14:28  craigs
00098  * Initial version
00099  *
00100  */
00101 
00102 #ifndef __OPAL_SPEEXCODEC_H
00103 #define __OPAL_SPEEXCODEC_H
00104 
00105 #ifdef P_USE_PRAGMA
00106 #pragma interface
00107 #endif
00108 
00109 #include <opal/transcoders.h>
00110 
00111 #ifndef NO_H323
00112 #include <h323/h323caps.h>
00113 #endif
00114 
00115 
00116 #define OPAL_SPEEX_NARROW_5k95 "SpeexNarrow-5.95k"
00117 #define OPAL_SPEEX_NARROW_8k   "SpeexNarrow-8k"
00118 #define OPAL_SPEEX_NARROW_11k  "SpeexNarrow-11k"
00119 #define OPAL_SPEEX_NARROW_15k  "SpeexNarrow-15k"
00120 #define OPAL_SPEEX_NARROW_18k2 "SpeexNarrow-18.2k"
00121 #define OPAL_SPEEX_WIDE_20k6   "SpeexWide-20.6k"
00122 
00123 extern const OpalAudioFormat & GetOpalSpeexNarrow_5k95();
00124 extern const OpalAudioFormat & GetOpalSpeexNarrow_8k();
00125 extern const OpalAudioFormat & GetOpalSpeexNarrow_11k();
00126 extern const OpalAudioFormat & GetOpalSpeexNarrow_15k();
00127 extern const OpalAudioFormat & GetOpalSpeexNarrow_18k2();
00128 extern const OpalAudioFormat & GetOpalSpeexWide_20k6();
00129 
00130 #define OpalSpeexNarrow_5k95 GetOpalSpeexNarrow_5k95()
00131 #define OpalSpeexNarrow_8k   GetOpalSpeexNarrow_8k()
00132 #define OpalSpeexNarrow_11k  GetOpalSpeexNarrow_11k()
00133 #define OpalSpeexNarrow_15k  GetOpalSpeexNarrow_15k()
00134 #define OpalSpeexNarrow_18k2 GetOpalSpeexNarrow_18k2()
00135 #define OpalSpeexWide_20k6   GetOpalSpeexWide_20k6()
00136 
00137 
00138 struct SpeexBits;
00139 
00140 
00142 
00143 #ifndef NO_H323
00144 
00147 class SpeexNonStandardAudioCapability : public H323NonStandardAudioCapability
00148 {
00149   PCLASSINFO(SpeexNonStandardAudioCapability, H323NonStandardAudioCapability);
00150 
00151   public:
00152     SpeexNonStandardAudioCapability(int mode, 
00153                                     int sampleRate);
00154 };
00155 
00157 
00158 class SpeexNarrow2AudioCapability : public SpeexNonStandardAudioCapability
00159 {
00160   PCLASSINFO(SpeexNarrow2AudioCapability, SpeexNonStandardAudioCapability);
00161 
00162   public:
00163     SpeexNarrow2AudioCapability();
00164     PObject * Clone() const;
00165     PString GetFormatName() const;
00166 };
00167 
00168 class SpeexNarrow3AudioCapability : public SpeexNonStandardAudioCapability
00169 {
00170   PCLASSINFO(SpeexNarrow3AudioCapability, SpeexNonStandardAudioCapability);
00171 
00172   public:
00173     SpeexNarrow3AudioCapability();
00174     PObject * Clone() const;
00175     PString GetFormatName() const;
00176 };
00177 
00178 class SpeexNarrow4AudioCapability : public SpeexNonStandardAudioCapability
00179 {
00180   PCLASSINFO(SpeexNarrow4AudioCapability, SpeexNonStandardAudioCapability);
00181 
00182   public:
00183     SpeexNarrow4AudioCapability();
00184     PObject * Clone() const;
00185     PString GetFormatName() const;
00186 };
00187 
00188 class SpeexNarrow5AudioCapability : public SpeexNonStandardAudioCapability
00189 {
00190   PCLASSINFO(SpeexNarrow5AudioCapability, SpeexNonStandardAudioCapability);
00191 
00192   public:
00193     SpeexNarrow5AudioCapability();
00194     PObject * Clone() const;
00195     PString GetFormatName() const;
00196 };
00197 
00198 class SpeexNarrow6AudioCapability : public SpeexNonStandardAudioCapability
00199 {
00200   PCLASSINFO(SpeexNarrow6AudioCapability, SpeexNonStandardAudioCapability);
00201 
00202   public:
00203     SpeexNarrow6AudioCapability();
00204     PObject * Clone() const;
00205     PString GetFormatName() const;
00206 };
00207 
00208 class SpeexWide6AudioCapability : public SpeexNonStandardAudioCapability
00209 {
00210   PCLASSINFO(SpeexWide6AudioCapability, SpeexNonStandardAudioCapability);
00211 
00212   public:
00213     SpeexWide6AudioCapability();
00214     PObject * Clone() const;
00215     PString GetFormatName() const;
00216 };
00217 
00218 
00219 #ifdef H323_STATIC_LIB
00220 H323_STATIC_LOAD_REGISTER_CAPABILITY(SpeexNarrow2AudioCapability);
00221 H323_STATIC_LOAD_REGISTER_CAPABILITY(SpeexNarrow3AudioCapability);
00222 H323_STATIC_LOAD_REGISTER_CAPABILITY(SpeexNarrow4AudioCapability);
00223 H323_STATIC_LOAD_REGISTER_CAPABILITY(SpeexNarrow5AudioCapability);
00224 H323_STATIC_LOAD_REGISTER_CAPABILITY(SpeexNarrow6AudioCapability);
00225 H323_STATIC_LOAD_REGISTER_CAPABILITY(SpeexWide6AudioCapability);
00226 #endif
00227 
00228 
00229 #define OPAL_REGISTER_SPEEX_H323 \
00230           H323_REGISTER_CAPABILITY(SpeexNarrow2AudioCapability, OPAL_SPEEX_NARROW_5k95) \
00231           H323_REGISTER_CAPABILITY(SpeexNarrow3AudioCapability, OPAL_SPEEX_NARROW_8k) \
00232           H323_REGISTER_CAPABILITY(SpeexNarrow4AudioCapability, OPAL_SPEEX_NARROW_11k) \
00233           H323_REGISTER_CAPABILITY(SpeexNarrow5AudioCapability, OPAL_SPEEX_NARROW_15k) \
00234           H323_REGISTER_CAPABILITY(SpeexNarrow6AudioCapability, OPAL_SPEEX_NARROW_18k2) \
00235           H323_REGISTER_CAPABILITY(SpeexWide6AudioCapability, OPAL_SPEEX_WIDE_20k6) 
00236 
00237 
00238 #else // ifndef NO_H323
00239 
00240 #define OPAL_REGISTER_SPEEX_H323
00241 
00242 #endif // ifndef NO_H323
00243 
00244 
00246 
00247 class Opal_Speex_Transcoder : public OpalFramedTranscoder {
00248   public:
00249     Opal_Speex_Transcoder(
00250       const OpalMediaFormat & inputMediaFormat,  
00251       const OpalMediaFormat & outputMediaFormat, 
00252       unsigned inputBytesPerFrame,  
00253       unsigned outputBytesPerFrame  
00254     );
00255     ~Opal_Speex_Transcoder();
00256   protected:
00257     SpeexBits * bits;
00258 };
00259 
00260 
00262 
00263 class Opal_Speex_Decoder : public Opal_Speex_Transcoder {
00264   public:
00265     Opal_Speex_Decoder(
00266       const OpalMediaFormat & inputMediaFormat,  
00267       int mode,
00268       int sampleRate
00269     );
00270     ~Opal_Speex_Decoder();
00271     virtual BOOL ConvertFrame(const BYTE * src, BYTE * dst);
00272     virtual BOOL ConvertSilentFrame(BYTE * dst);
00273   protected:
00274     void * decoder;
00275     int    samples_per_frame;
00276 };
00277 
00278 
00280 
00281 class Opal_Speex_Encoder : public Opal_Speex_Transcoder {
00282   public:
00283     Opal_Speex_Encoder(
00284       const OpalMediaFormat & outputMediaFormat, 
00285       int mode,
00286       int sampleRate
00287     );
00288     ~Opal_Speex_Encoder();
00289     virtual BOOL ConvertFrame(const BYTE * src, BYTE * dst);
00290   protected:
00291     void   * encoder;
00292     int      samples_per_frame;
00293 };
00294 
00295 
00297 
00298 class Opal_Speex_5k95_PCM : public Opal_Speex_Decoder {
00299   public:
00300     Opal_Speex_5k95_PCM();
00301 };
00302 
00303 
00304 class Opal_PCM_Speex_5k95 : public Opal_Speex_Encoder {
00305   public:
00306     Opal_PCM_Speex_5k95();
00307 };
00308 
00309 
00311 
00312 class Opal_Speex_8k_PCM : public Opal_Speex_Decoder {
00313   public:
00314     Opal_Speex_8k_PCM();
00315 };
00316 
00317 
00318 class Opal_PCM_Speex_8k : public Opal_Speex_Encoder {
00319   public:
00320     Opal_PCM_Speex_8k();
00321 };
00322 
00323 
00325 
00326 class Opal_Speex_11k_PCM : public Opal_Speex_Decoder {
00327   public:
00328     Opal_Speex_11k_PCM();
00329 };
00330 
00331 
00332 class Opal_PCM_Speex_11k : public Opal_Speex_Encoder {
00333   public:
00334     Opal_PCM_Speex_11k();
00335 };
00336 
00337 
00339 
00340 class Opal_Speex_15k_PCM : public Opal_Speex_Decoder {
00341   public:
00342     Opal_Speex_15k_PCM();
00343 };
00344 
00345 
00346 class Opal_PCM_Speex_15k : public Opal_Speex_Encoder {
00347   public:
00348     Opal_PCM_Speex_15k();
00349 };
00350 
00351 
00353 
00354 class Opal_Speex_18k2_PCM : public Opal_Speex_Decoder {
00355   public:
00356     Opal_Speex_18k2_PCM();
00357 };
00358 
00359 
00360 class Opal_PCM_Speex_18k2 : public Opal_Speex_Encoder {
00361   public:
00362     Opal_PCM_Speex_18k2();
00363 };
00364 
00365 
00366 
00368 
00369 class Opal_Speex_20k6_PCM : public Opal_Speex_Decoder {
00370   public:
00371     Opal_Speex_20k6_PCM();
00372 };
00373 
00374 
00375 class Opal_PCM_Speex_20k6 : public Opal_Speex_Encoder {
00376   public:
00377     Opal_PCM_Speex_20k6();
00378 };
00379 
00380 
00382 
00383 #define OPAL_REGISTER_SPEEX() \
00384           OPAL_REGISTER_SPEEX_H323 \
00385           OPAL_REGISTER_TRANSCODER(Opal_Speex_5k95_PCM, OpalSpeexNarrow_5k95, OpalPCM16); \
00386           OPAL_REGISTER_TRANSCODER(Opal_PCM_Speex_5k95, OpalPCM16,            OpalSpeexNarrow_5k95); \
00387           OPAL_REGISTER_TRANSCODER(Opal_Speex_8k_PCM,   OpalSpeexNarrow_8k,   OpalPCM16); \
00388           OPAL_REGISTER_TRANSCODER(Opal_PCM_Speex_8k,   OpalPCM16,            OpalSpeexNarrow_8k); \
00389           OPAL_REGISTER_TRANSCODER(Opal_Speex_11k_PCM,  OpalSpeexNarrow_11k,  OpalPCM16); \
00390           OPAL_REGISTER_TRANSCODER(Opal_PCM_Speex_11k,  OpalPCM16,            OpalSpeexNarrow_11k); \
00391           OPAL_REGISTER_TRANSCODER(Opal_Speex_15k_PCM,  OpalSpeexNarrow_15k,  OpalPCM16); \
00392           OPAL_REGISTER_TRANSCODER(Opal_PCM_Speex_15k,  OpalPCM16,            OpalSpeexNarrow_15k); \
00393           OPAL_REGISTER_TRANSCODER(Opal_Speex_18k2_PCM, OpalSpeexNarrow_18k2, OpalPCM16); \
00394           OPAL_REGISTER_TRANSCODER(Opal_PCM_Speex_18k2, OpalPCM16,            OpalSpeexNarrow_18k2); \
00395           OPAL_REGISTER_TRANSCODER(Opal_Speex_20k6_PCM, OpalSpeexWide_20k6, OpalPCM16); \
00396           OPAL_REGISTER_TRANSCODER(Opal_PCM_Speex_20k6, OpalPCM16,            OpalSpeexWide_20k6)
00397 
00398 
00399 
00400 #endif // __OPAL_SPEEXCODEC_H
00401 
00402 

Generated on Mon Sep 25 16:20:11 2006 for OPAL by  doxygen 1.4.7