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-2013 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 = 0x01, 00032 WA_PCMA = 0x06, 00033 WA_PCMU = 0x07, 00034 WA_IMA_ADPCM = 0x11, 00035 WA_UNKNOWN 00036 } WAV_AUDIO_FORMAT; 00037 00038 00039 class WAVAudioFileSource: public AudioInputDevice { 00040 public: 00041 00042 static WAVAudioFileSource* createNew(UsageEnvironment& env, 00043 char const* fileName); 00044 00045 unsigned numPCMBytes() const; 00046 void setScaleFactor(int scale); 00047 void seekToPCMByte(unsigned byteNumber, unsigned numBytesToStream); 00048 // if "numBytesToStream" is >0, then we limit the stream to that number of bytes, before treating it as EOF 00049 00050 unsigned char getAudioFormat(); 00051 00052 protected: 00053 WAVAudioFileSource(UsageEnvironment& env, FILE* fid); 00054 // called only by createNew() 00055 00056 virtual ~WAVAudioFileSource(); 00057 00058 static void fileReadableHandler(WAVAudioFileSource* source, int mask); 00059 void doReadFromFile(); 00060 00061 private: 00062 // redefined virtual functions: 00063 virtual void doGetNextFrame(); 00064 virtual void doStopGettingFrames(); 00065 virtual Boolean setInputPort(int portIndex); 00066 virtual double getAverageLevel() const; 00067 00068 protected: 00069 unsigned fPreferredFrameSize; 00070 00071 private: 00072 FILE* fFid; 00073 double fPlayTimePerSample; // useconds 00074 Boolean fFidIsSeekable; 00075 unsigned fLastPlayTime; // useconds 00076 Boolean fHaveStartedReading; 00077 unsigned fWAVHeaderSize; 00078 unsigned fFileSize; 00079 int fScaleFactor; 00080 Boolean fLimitNumBytesToStream; 00081 unsigned fNumBytesToStream; // used iff "fLimitNumBytesToStream" is True 00082 unsigned char fAudioFormat; 00083 }; 00084 00085 #endif
1.5.2