00001 /* 00002 * Copyright (c) 2004 MUSIC TECHNOLOGY GROUP (MTG) 00003 * UNIVERSITAT POMPEU FABRA 00004 * 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 * 00020 */ 00021 00022 #ifndef __MpegAudioStream__ 00023 #define __MpegAudioStream__ 00024 00025 00026 #include "AudioCodecs_Stream.hxx" 00027 #include "MpegBitstream.hxx" 00028 #include <deque> 00029 #include "Array.hxx" 00030 00031 namespace CLAM 00032 { 00033 00034 namespace AudioCodecs 00035 { 00036 class MpegAudioStream 00037 : public Stream 00038 { 00039 public: 00040 00041 MpegAudioStream(); 00042 MpegAudioStream( const AudioFile& file ); 00043 00044 ~MpegAudioStream(); 00045 00046 void SetFOI( const AudioFile& file ); 00047 00048 void PrepareReading(); 00049 void PrepareWriting(); 00050 void PrepareReadWrite(); 00051 void Dispose(); 00052 00053 protected: 00054 00055 void AudioFileToNative( const AudioFile& file ); 00056 void DiskToMemoryTransfer(); 00057 void MemoryToDiskTransfer(); 00058 00059 void ConsumeDecodedSamples(); 00060 00061 protected: 00062 00063 std::string mName; 00064 FILE* mpHandle; 00065 MpegBitstream mBitstream; 00066 int mEncodedSampleRate; 00067 int mEncodedChannels; 00068 00069 static const TSize mMaxDecodedBlockSize; 00070 std::vector<std::deque<mad_fixed_t> > mDecodeBuffer; 00071 TSize mSamplesDecoded; 00072 TSize mSamplesTransferred; 00073 }; 00074 } 00075 00076 } 00077 00078 00079 #endif // MpegAudioStream.hxx 00080