input_mp3.h

Go to the documentation of this file.
00001 #ifndef INPUT_MP3_H
00002 #define INPUT_MP3_H
00003 
00004 #include "mpaudec/mpaudec.h"
00005 #include "audiere.h"
00006 #include "basic_source.h"
00007 #include "types.h"
00008 #include "utility.h"
00009 
00010 namespace audiere {
00011 
00012   class MP3InputStream : public BasicSource {
00013   public:
00014     MP3InputStream();
00015     ~MP3InputStream();
00016 
00017     bool initialize(FilePtr file);
00018 
00019     void ADR_CALL getFormat(
00020       int& channel_count,
00021       int& sample_rate,
00022       SampleFormat& sample_format);
00023     int doRead(int frame_count, void* samples);
00024     void ADR_CALL reset();
00025 
00026     bool ADR_CALL isSeekable();
00027     int  ADR_CALL getLength();
00028     void ADR_CALL setPosition(int position);
00029     int  ADR_CALL getPosition();
00030 
00031 
00032   private:
00033     void readID3v1Tags();
00034     void readID3v2Tags();
00035     bool decodeFrame();
00036 
00037     FilePtr m_file;
00038     bool m_eof;
00039 
00040     // from format chunk
00041     int m_channel_count;
00042     int m_sample_rate;
00043     SampleFormat m_sample_format;
00044 
00045     MPAuDecContext* m_context;
00046     
00047     QueueBuffer m_buffer;
00048 
00049     enum { INPUT_BUFFER_SIZE = 4096 };
00050     u8 m_input_buffer[INPUT_BUFFER_SIZE];
00051     int m_input_position;
00052     int m_input_length;
00053     u8* m_decode_buffer;
00054     bool m_first_frame;
00055 
00056     bool m_seekable;
00057     int m_length;
00058     int m_position;
00059     std::vector<int> m_frame_sizes;
00060     std::vector<int> m_frame_offsets;
00061   };
00062 
00063 }
00064 
00065 #endif

Generated on Mon Feb 13 23:07:47 2006 for audiere by  doxygen 1.4.6