00001 #pragma once 00002 00027 #ifndef __MP3_FRAME_HEADER_H__ 00028 #define __MP3_FRAME_HEADER_H__ 00029 00030 // USINGS 00031 using std::string; 00032 using std::exception; 00033 00035 00055 class mp3_frame_header 00056 { 00057 // Constants. 00058 private: 00059 static const int FRAME_SYNC=0x0FFE00000; 00060 00061 static const int NUM_MPEG_VERSION=4; 00062 static const int MPEG_V1=3; 00063 static const int MPEG_V2=2; 00064 static const int MPEG_V25=0; 00065 static const int INVALID_MPEG=1; 00066 00067 static const int NUM_LAYER_VERSION=4; 00068 static const int LAYER_I=3; 00069 static const int LAYER_II=2; 00070 static const int LAYER_III=1; 00071 static const int INVALID_LAYER=0; 00072 00073 static const int SLOT_SIZE_LAYER_I=4; 00074 static const int SLOT_SIZE_LAYER_II_III=1; 00075 static const int SAMPLERATE_CONST_LAYER_I=384; 00076 static const int SAMPLERATE_CONST_LAYER_II_III=1152; 00077 static const int BITRATE_CONST_LAYER_I=12; 00078 static const int BITRATE_CONST_LAYER_II_III=144; 00079 00080 static const int NUM_BITRATE=16; 00081 static const int FREE_BITRATE=0; 00082 static const int INVALID_BITRATE=15; 00083 static const int INVALID_BR_DESC=-1; 00084 static const int FREE_BR_DESC=0; 00085 00086 static const int NUM_SAMPLERATE=4; 00087 static const int INVALID_SAMPLERATE=3; 00088 static const int INVALID_SR_DESC=-1; 00089 00090 static const int NUM_CHANMODE=4; 00091 static const int CHANMODE_EX=1; 00092 static const int NUM_CHANMODE_EX=4; 00093 static const int NUM_EMPHASIS=4; 00094 00095 static const string MPEG_VERSION_DESC[NUM_MPEG_VERSION]; 00096 static const string LAYER_VERSION_DESC[NUM_LAYER_VERSION]; 00097 static const int BITRATE_DESC[NUM_MPEG_VERSION][NUM_LAYER_VERSION][NUM_BITRATE]; 00098 static const int SAMPLERATE_DESC[NUM_MPEG_VERSION][NUM_SAMPLERATE]; 00099 static const string CHANMODE_DESC[NUM_CHANMODE]; 00100 static const string CHANMODE_EX_DESC[NUM_LAYER_VERSION][NUM_CHANMODE_EX]; 00101 static const string EMPHASIS_DESC[NUM_EMPHASIS]; 00102 00103 // Member functions. 00104 public: 00105 mp3_frame_header(void); 00106 mp3_frame_header(char* pMemory); 00107 ~mp3_frame_header(void); 00108 void SetFrameHeader(char* pMemory); 00109 bool IsValidFrameHeader(void) const; 00110 int GetLength(void) const; 00111 int GetSlotSize(void) const; 00112 int GetSamplerateConstant(void) const; 00113 int GetBitrateConstant(void) const; 00114 string GetMPEGVersionDesc(void) const; 00115 string GetLayerVersionDesc(void) const; 00116 int GetBitrateDesc(void) const; 00117 int GetSamplerateDesc(void) const; 00118 string GetChanmodeDesc(void) const; 00119 string GetChanmodeExDesc(void) const; 00120 string GetEmphasisDesc(void) const; 00121 bool GetCRC(void) const; 00122 bool GetPrivate(void) const; 00123 bool GetCopyright(void) const; 00124 bool GetOriginal(void) const; 00125 private: 00126 int GetMPEGVersion(void) const; 00127 int GetLayerVersion(void) const; 00128 int GetBitrate(void) const; 00129 int GetSamplerate(void) const; 00130 int GetPadded(void) const; 00131 int GetChanmode(void) const; 00132 int GetChanmodeEx(void) const; 00133 int GetEmphasis(void) const; 00134 00135 // Attributes. 00136 private: 00137 int m_FrameHeader; 00138 }; 00139 00140 // MP3 frame header exceptions. 00141 namespace except 00142 { 00144 class mp3_frame_header_except: public exception 00145 { 00146 // Member functions. 00147 public: 00149 mp3_frame_header_except(void) throw(): exception() {}; 00151 virtual ~mp3_frame_header_except(void) throw() {}; 00153 virtual const char *what(void) const throw()=0; 00154 }; 00155 00157 class invalid_frame_header: public mp3_frame_header_except 00158 { 00159 // Member functions. 00160 public: 00161 invalid_frame_header(int InvalidFrameHeader) throw(); 00162 virtual ~invalid_frame_header(void) throw(); 00163 virtual const char *what(void) const throw(); 00164 00165 // Attributes. 00166 private: 00167 string m_InvalidFrameHeader; 00168 }; 00169 }; 00170 00171 #endif // __MP3_FRAME_HEADER_H__
![]() |
![]() |
![]() |