Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

mp3info.h

Go to the documentation of this file.
00001 #pragma once
00002 
00027 #ifndef __MP3INFO_H__
00028 #define __MP3INFO_H__
00029 
00030 // INCLUDES
00031 #include "fileinfo.h"
00032 #include "mp3_frame_header.h"
00033 #include "fileio.h"
00034 
00035 // USINGS
00036 using std::string;
00037 using std::streamsize;
00038 using std::streamoff;
00039 using std::exception;
00040 
00042 class mp3info: public fileinfo
00043 {
00044     // Member functions.
00045 public:
00046     mp3info(const string& FileName);
00047     virtual ~mp3info(void);
00048     virtual void Show(void) const;
00049 protected:
00050     virtual void FirstStep(void);
00051     virtual streamoff Step(char* pContent, streamsize ContentSize, streamoff FileOffset);
00052     virtual void LastStep(void);
00053 private:
00054     streamsize GetID3v2Size(void);
00055     streamoff FindFrameSync(char* pContent, streamsize ContentSize);
00056     bool IsValidFrameSync(char* pContent, streamsize ContentSize);
00057     streamoff ReadFrames(char* pContent, streamsize ContentSize, streamoff FileOffset);
00058     int GetDuration(void);
00059 
00060     // Attributes.
00061 private:
00062     streamoff m_FirstFrameOffset;           
00063     mp3_frame_header* m_pMP3FrameHeader;    
00064     int m_Frames;                           
00065     long long m_BitrateAcum;                
00066     bool m_GotMoreFrames;                   
00067 };
00068 
00069 // MP3info exceptions.
00070 namespace except
00071 {
00073         class mp3info_except: public exception
00074         {
00075         // Member functions.
00076     public:
00078         mp3info_except(void) throw(): exception() {};
00080         virtual ~mp3info_except(void) throw() {};
00082         virtual const char *what(void) const throw()=0;
00083         };
00084 
00086         class no_mp3_file: public mp3info_except
00087         {
00088                 // Member functions.
00089         public:
00090                 no_mp3_file(const string& FileName) throw();
00091         virtual ~no_mp3_file(void) throw();
00092                 virtual const char *what(void) const throw();
00093         
00094         // Attributes.
00095     private:
00096         string m_FileName;    
00097         };
00098 
00100         class no_frame_sync: public mp3info_except
00101         {
00102                 // Member functions.
00103         public:
00104                 no_frame_sync(void) throw();
00105         virtual ~no_frame_sync(void) throw();
00106                 virtual const char *what(void) const throw();
00107                 void SetOffset(streamoff Offset) throw();
00108         
00109         // Attributes.
00110     private:
00111         string m_Offset;    
00112         };
00113 };
00114 
00115 #endif // __MP3INFO_H__

doxygen sourceforge id3lib