liveMedia/include/WAVAudioFileSource.hh

Go to the documentation of this file.
00001 /**********
00002 This library is free software; you can redistribute it and/or modify it under
00003 the terms of the GNU Lesser General Public License as published by the
00004 Free Software Foundation; either version 2.1 of the License, or (at your
00005 option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
00006 
00007 This library is distributed in the hope that it will be useful, but WITHOUT
00008 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00009 FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
00010 more details.
00011 
00012 You should have received a copy of the GNU Lesser General Public License
00013 along with this library; if not, write to the Free Software Foundation, Inc.,
00014 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
00015 **********/
00016 // "liveMedia"
00017 // Copyright (c) 1996-2008 Live Networks, Inc.  All rights reserved.
00018 // A WAV audio file source
00019 // NOTE: Samples are returned in little-endian order (the same order in which
00020 // they were stored in the file).
00021 // C++ header
00022 
00023 #ifndef _WAV_AUDIO_FILE_SOURCE_HH
00024 #define _WAV_AUDIO_FILE_SOURCE_HH
00025 
00026 #ifndef _AUDIO_INPUT_DEVICE_HH
00027 #include "AudioInputDevice.hh"
00028 #endif
00029 
00030 typedef enum {
00031   WA_PCM = 1,
00032   WA_PCMA = 6,
00033   WA_PCMU = 7,
00034   WA_UNKNOWN
00035 }WAV_AUDIO_FORMAT;
00036 
00037 
00038 class WAVAudioFileSource: public AudioInputDevice {
00039 public:
00040 
00041   static WAVAudioFileSource* createNew(UsageEnvironment& env,
00042                                         char const* fileName);
00043 
00044   unsigned numPCMBytes() const;
00045   void setScaleFactor(int scale);
00046   void seekToPCMByte(unsigned byteNumber);
00047 
00048   unsigned char getAudioFormat();
00049 
00050 protected:
00051   WAVAudioFileSource(UsageEnvironment& env, FILE* fid);
00052         // called only by createNew()
00053 
00054   virtual ~WAVAudioFileSource();
00055 
00056 private:
00057   // redefined virtual functions:
00058   virtual void doGetNextFrame();
00059   virtual Boolean setInputPort(int portIndex);
00060   virtual double getAverageLevel() const;
00061 
00062 private:
00063   FILE* fFid;
00064   double fPlayTimePerSample; // useconds
00065   unsigned fPreferredFrameSize;
00066   unsigned fLastPlayTime; // useconds
00067   unsigned fWAVHeaderSize;
00068   unsigned fFileSize;
00069   int fScaleFactor;
00070 
00071   unsigned char fAudioFormat;
00072 };
00073 
00074 #endif

Generated on Tue Oct 7 15:38:09 2008 for live by  doxygen 1.5.2