00001 // -*- C++ -*- 00002 // $Id: mp3_header.h,v 1.4 2002/11/02 17:48:51 t1mpy Exp $ 00003 00004 // id3lib: a C++ library for creating and manipulating id3v1/v2 tags 00005 // Copyright 2002 Thijmen Klok (thijmen@id3lib.org) 00006 00007 // This library is free software; you can redistribute it and/or modify it 00008 // under the terms of the GNU Library General Public License as published by 00009 // the Free Software Foundation; either version 2 of the License, or (at your 00010 // option) any later version. 00011 // 00012 // This library is distributed in the hope that it will be useful, but WITHOUT 00013 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00014 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00015 // License for more details. 00016 // 00017 // You should have received a copy of the GNU Library General Public License 00018 // along with this library; if not, write to the Free Software Foundation, 00019 // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00020 00021 // The id3lib authors encourage improvements and optimisations to be sent to 00022 // the id3lib coordinator. Please see the README file for details on where to 00023 // send such submissions. See the AUTHORS file for a list of people who have 00024 // contributed to id3lib. See the ChangeLog file for a list of changes to 00025 // id3lib. These files are distributed with id3lib at 00026 // http://download.sourceforge.net/id3lib/ 00027 00028 #ifndef _MP3_HEADER_H_ 00029 #define _MP3_HEADER_H_ 00030 00031 #include "io_decorators.h" //has "readers.h" "io_helpers.h" "utils.h" 00032 00033 class Mp3Info 00034 { 00035 public: 00036 Mp3Info() { _mp3_header_output = new Mp3_Headerinfo; }; 00037 ~Mp3Info() { this->Clean(); }; 00038 void Clean(); 00039 00040 const Mp3_Headerinfo* GetMp3HeaderInfo() const { return _mp3_header_output; }; 00041 bool Parse(ID3_Reader&, size_t mp3size); 00042 00043 Mpeg_Layers Layer() const { return _mp3_header_output->layer; }; 00044 Mpeg_Version Version() const { return _mp3_header_output->version; }; 00045 MP3_BitRates Bitrate() const { return _mp3_header_output->bitrate; }; 00046 Mp3_ChannelMode ChannelMode() const { return _mp3_header_output->channelmode; }; 00047 Mp3_ModeExt ModeExt() const { return _mp3_header_output->modeext; }; 00048 Mp3_Emphasis Emphasis() const { return _mp3_header_output->emphasis; }; 00049 Mp3_Crc Crc() const { return _mp3_header_output->crc; }; 00050 uint32 VbrBitrate() const { return _mp3_header_output->vbr_bitrate; }; 00051 uint32 Frequency() const { return _mp3_header_output->frequency; }; 00052 uint32 Framesize() const { return _mp3_header_output->framesize; }; 00053 uint32 Frames() const { return _mp3_header_output->frames; }; 00054 bool Private() const { return _mp3_header_output->privatebit; }; 00055 bool Copyrighted() const { return _mp3_header_output->copyrighted; }; 00056 bool Original() const { return _mp3_header_output->original; }; 00057 uint32 Seconds() const { return _mp3_header_output->time; }; 00058 00059 private: 00060 00061 struct _mp3_header_internal //http://www.mp3-tech.org/programmer/frame_header.html 00062 { 00063 //byte 1 00064 unsigned char frame_sync_a : 8; /* all bits should be set */ 00065 //byte 2 00066 unsigned char protection_bit : 1; 00067 unsigned char layer : 2; 00068 unsigned char id : 2; 00069 unsigned char frame_sync_b : 3; /* all bits should be set */ 00070 //byte 3 00071 unsigned char private_bit : 1; 00072 unsigned char padding_bit : 1; 00073 unsigned char frequency : 2; 00074 unsigned char bitrate_index : 4; 00075 //byte 4 00076 unsigned char emphasis : 2; 00077 unsigned char original : 1; 00078 unsigned char copyright : 1; 00079 unsigned char mode_ext : 2;//only used in joint stereo 00080 unsigned char mode : 2; 00081 }; 00082 00083 Mp3_Headerinfo* _mp3_header_output; 00084 }; //Info 00085 00086 #endif /* _MP3_HEADER_H_ */ 00087