Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

AudioEncoder.h

Go to the documentation of this file.
00001 /*------------------------------------------------------------------------------
00002 
00003    Copyright (c) 2000 Tyrell Corporation. All rights reserved.
00004 
00005    Tyrell DarkIce
00006 
00007    File     : AudioEncoder.h
00008    Version  : $Revision: 1.9 $
00009    Author   : $Author: jbebel $
00010    Location : $Source: /cvsroot/darkice/darkice/src/AudioEncoder.h,v $
00011    
00012    Copyright notice:
00013 
00014     This program is free software; you can redistribute it and/or
00015     modify it under the terms of the GNU General Public License  
00016     as published by the Free Software Foundation; either version 2
00017     of the License, or (at your option) any later version.
00018    
00019     This program is distributed in the hope that it will be useful,
00020     but WITHOUT ANY WARRANTY; without even the implied warranty of 
00021     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
00022     GNU General Public License for more details.
00023    
00024     You should have received a copy of the GNU General Public License
00025     along with this program; if not, write to the Free Software
00026     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00027 
00028 ------------------------------------------------------------------------------*/
00029 #ifndef AUDIO_ENCODER_H
00030 #define AUDIO_ENCODER_H
00031 
00032 #ifndef __cplusplus
00033 #error This is a C++ include file
00034 #endif
00035 
00036 
00037 /* ============================================================ include files */
00038 
00039 #include "Referable.h"
00040 #include "Sink.h"
00041 #include "AudioSource.h"
00042 
00043 
00044 /* ================================================================ constants */
00045 
00046 
00047 /* =================================================================== macros */
00048 
00049 
00050 /* =============================================================== data types */
00051 
00058 class AudioEncoder : public Sink, public virtual Referable
00059 {
00060     public:
00070         enum BitrateMode { cbr, abr, vbr };
00071 
00072     private:
00073 
00077         unsigned int        inSampleRate;
00078 
00082         unsigned int        inBitsPerSample;
00083 
00087         unsigned int        inChannel;
00088 
00092         bool                inBigEndian;
00093 
00097         BitrateMode         outBitrateMode;
00098 
00102         unsigned int        outBitrate;
00103 
00107         double              outQuality;
00108 
00112         unsigned int        outSampleRate;
00113 
00117         unsigned int        outChannel;
00118 
00132         inline void
00133         init (      unsigned int    inSampleRate,
00134                     unsigned int    inBitsPerSample,
00135                     unsigned int    inChannel,
00136                     bool            inBigEndian,
00137                     BitrateMode     outBitrateMode,
00138                     unsigned int    outBitrate,
00139                     double          outQuality,
00140                     unsigned int    outSampleRate,
00141                     unsigned int    outChannel )        throw ( Exception )
00142         {
00143             this->inSampleRate     = inSampleRate;
00144             this->inBitsPerSample  = inBitsPerSample;
00145             this->inChannel        = inChannel;
00146             this->inBigEndian      = inBigEndian;
00147             this->outBitrateMode   = outBitrateMode;
00148             this->outBitrate       = outBitrate;
00149             this->outQuality       = outQuality;
00150             this->outSampleRate    = outSampleRate;
00151             this->outChannel       = outChannel;
00152 
00153             if ( outQuality < -0.1 || 1.0 < outQuality ) {
00154                 throw Exception( __FILE__, __LINE__, "invalid encoder quality");
00155             }
00156         }
00157 
00163         inline void
00164         strip ( void )                                  throw ( Exception )
00165         {
00166         }
00167 
00168 
00169     protected:
00170 
00176         inline
00177         AudioEncoder ( void )                           throw ( Exception )
00178         {
00179             throw Exception( __FILE__, __LINE__);
00180         }
00181 
00198         inline
00199         AudioEncoder (  unsigned int    inSampleRate,
00200                         unsigned int    inBitsPerSample,
00201                         unsigned int    inChannel, 
00202                         bool            inBigEndian,
00203                         BitrateMode     outBitrateMode,
00204                         unsigned int    outBitrate,
00205                         double          outQuality,
00206                         unsigned int    outSampleRate = 0,
00207                         unsigned int    outChannel    = 0 )
00208                                                         throw ( Exception )
00209         {
00210             init ( inSampleRate,
00211                    inBitsPerSample,
00212                    inChannel,
00213                    inBigEndian,
00214                    outBitrateMode,
00215                    outBitrate,
00216                    outQuality,
00217                    outSampleRate ? outSampleRate : inSampleRate,
00218                    outChannel    ? outChannel    : inChannel );
00219         }
00220 
00235         inline
00236         AudioEncoder (  const AudioSource     * as,
00237                         BitrateMode             outBitrateMode,
00238                         unsigned int            outBitrate,
00239                         double                  outQuality,
00240                         unsigned int            outSampleRate = 0,
00241                         unsigned int            outChannel    = 0 )
00242                                                         throw ( Exception)
00243         {
00244             init( as->getSampleRate(),
00245                   as->getBitsPerSample(),
00246                   as->getChannel(),
00247                   as->isBigEndian(),
00248                   outBitrateMode,
00249                   outBitrate,
00250                   outQuality,
00251                   outSampleRate ? outSampleRate : as->getSampleRate(),
00252                   outChannel    ? outChannel    : as->getChannel() );
00253         }
00254 
00260         inline
00261         AudioEncoder (  const AudioEncoder &    encoder )   throw ( Exception )
00262         {
00263             init ( encoder.inSampleRate,
00264                    encoder.inBitsPerSample,
00265                    encoder.inChannel,
00266                    encoder.inBigEndian,
00267                    encoder.outBitrateMode,
00268                    encoder.outBitrate,
00269                    encoder.outQuality,
00270                    encoder.outSampleRate,
00271                    encoder.outChannel );
00272         }
00273 
00281         inline virtual AudioEncoder &
00282         operator= ( const AudioEncoder &        encoder )   throw ( Exception )
00283         {
00284             if ( this != &encoder ) {
00285                 strip();
00286 
00287                 init ( encoder.inSampleRate,
00288                        encoder.inBitsPerSample,
00289                        encoder.inChannel,
00290                        encoder.inBigEndian,
00291                        encoder.outBitrateMode,
00292                        encoder.outBitrate,
00293                        encoder.outQuality,
00294                        encoder.outSampleRate,
00295                        encoder.outChannel );
00296             }
00297 
00298             return *this;
00299         }
00300 
00301 
00302     public:
00303 
00309         inline virtual
00310         ~AudioEncoder ( void )          throw ( Exception )
00311         {
00312             strip();
00313         }
00314 
00320         inline int
00321         getInChannel ( void ) const         throw ()
00322         {
00323             return inChannel;
00324         }
00325 
00331         inline bool
00332         isInBigEndian ( void ) const         throw ()
00333         {
00334             return inBigEndian;
00335         }
00336 
00342         inline int
00343         getInSampleRate ( void ) const      throw ()
00344         {
00345             return inSampleRate;
00346         }
00347 
00353         inline int
00354         getInBitsPerSample ( void ) const   throw ()
00355         {
00356             return inBitsPerSample;
00357         }
00358 
00364         inline int
00365         getOutChannel ( void ) const        throw ()
00366         {
00367             return outChannel;
00368         }
00369 
00375         inline int
00376         getOutSampleRate ( void ) const     throw ()
00377         {
00378             return outSampleRate;
00379         }
00380 
00386         inline BitrateMode
00387         getOutBitrateMode ( void ) const        throw ()
00388         {
00389             return outBitrateMode;
00390         }
00391 
00398         inline unsigned int
00399         getOutBitrate ( void ) const        throw ()
00400         {
00401             return outBitrate;
00402         }
00403 
00410         inline double
00411         getOutQuality ( void ) const        throw ()
00412         {
00413             return outQuality;
00414         }
00415 
00421         virtual bool
00422         isRunning ( void ) const           throw ()                 = 0;
00423 
00431         virtual bool
00432         start ( void )                      throw ( Exception )     = 0;
00433 
00439         virtual void
00440         stop ( void )                       throw ( Exception )     = 0;
00441 };
00442 
00443 
00444 /* ================================================= external data structures */
00445 
00446 
00447 /* ====================================================== function prototypes */
00448 
00449 
00450 
00451 #endif  /* AUDIO_ENCODER_H */
00452 
00453 
00454 /*------------------------------------------------------------------------------
00455  
00456   $Source: /cvsroot/darkice/darkice/src/AudioEncoder.h,v $
00457 
00458   $Log: AudioEncoder.h,v $
00459   Revision 1.9  2005/04/13 18:03:43  jbebel
00460   Allow quality settings down to -0.1 for ogg
00461 
00462   Revision 1.8  2002/08/20 19:35:37  darkeye
00463   added possibility to specify maximum bitrate for Ogg Vorbis streams
00464 
00465   Revision 1.7  2002/04/13 11:26:00  darkeye
00466   added cbr, abr and vbr setting feature with encoding quality
00467 
00468   Revision 1.6  2002/03/28 16:39:32  darkeye
00469   added interface for variable bitrate encoding
00470 
00471   Revision 1.5  2002/02/19 15:23:59  darkeye
00472   fixed typo
00473 
00474   Revision 1.4  2001/09/18 14:57:19  darkeye
00475   finalized Solaris port
00476 
00477   Revision 1.3  2001/09/14 19:31:06  darkeye
00478   added IceCast2 / vorbis support
00479 
00480   Revision 1.2  2000/11/12 14:54:50  darkeye
00481   added kdoc-style documentation comments
00482 
00483   Revision 1.1.1.1  2000/11/05 10:05:47  darkeye
00484   initial version
00485 
00486   
00487 ------------------------------------------------------------------------------*/
00488 

Generated on Sat Oct 22 13:17:03 2005 for DarkIce by  doxygen 1.4.4