1 // -*- C++ -*- 2 // $Id: mp3_header.h,v 1.4 2002/11/02 17:48:51 t1mpy Exp $ 3 4 // id3lib: a C++ library for creating and manipulating id3v1/v2 tags 5 // Copyright 2002 Thijmen Klok (thijmen@id3lib.org) 6 7 // This library is free software; you can redistribute it and/or modify it 8 // under the terms of the GNU Library General Public License as published by 9 // the Free Software Foundation; either version 2 of the License, or (at your 10 // option) any later version. 11 // 12 // This library is distributed in the hope that it will be useful, but WITHOUT 13 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 15 // License for more details. 16 // 17 // You should have received a copy of the GNU Library General Public License 18 // along with this library; if not, write to the Free Software Foundation, 19 // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 21 // The id3lib authors encourage improvements and optimisations to be sent to 22 // the id3lib coordinator. Please see the README file for details on where to 23 // send such submissions. See the AUTHORS file for a list of people who have 24 // contributed to id3lib. See the ChangeLog file for a list of changes to 25 // id3lib. These files are distributed with id3lib at 26 // http://download.sourceforge.net/id3lib/ 27 28 #ifndef _MP3_HEADER_H_ 29 #define _MP3_HEADER_H_ 30 31 #include "io_decorators.h" //has "readers.h" "io_helpers.h" "utils.h" 32 33 class Mp3Info 34 { 35 public: Mp3Info()36 Mp3Info() { _mp3_header_output = new Mp3_Headerinfo; }; ~Mp3Info()37 ~Mp3Info() { this->Clean(); }; 38 void Clean(); 39 GetMp3HeaderInfo()40 const Mp3_Headerinfo* GetMp3HeaderInfo() const { return _mp3_header_output; }; 41 bool Parse(ID3_Reader&, size_t mp3size); 42 Layer()43 Mpeg_Layers Layer() const { return _mp3_header_output->layer; }; Version()44 Mpeg_Version Version() const { return _mp3_header_output->version; }; Bitrate()45 MP3_BitRates Bitrate() const { return _mp3_header_output->bitrate; }; ChannelMode()46 Mp3_ChannelMode ChannelMode() const { return _mp3_header_output->channelmode; }; ModeExt()47 Mp3_ModeExt ModeExt() const { return _mp3_header_output->modeext; }; Emphasis()48 Mp3_Emphasis Emphasis() const { return _mp3_header_output->emphasis; }; Crc()49 Mp3_Crc Crc() const { return _mp3_header_output->crc; }; VbrBitrate()50 uint32 VbrBitrate() const { return _mp3_header_output->vbr_bitrate; }; Frequency()51 uint32 Frequency() const { return _mp3_header_output->frequency; }; Framesize()52 uint32 Framesize() const { return _mp3_header_output->framesize; }; Frames()53 uint32 Frames() const { return _mp3_header_output->frames; }; Private()54 bool Private() const { return _mp3_header_output->privatebit; }; Copyrighted()55 bool Copyrighted() const { return _mp3_header_output->copyrighted; }; Original()56 bool Original() const { return _mp3_header_output->original; }; Seconds()57 uint32 Seconds() const { return _mp3_header_output->time; }; 58 59 private: 60 61 struct _mp3_header_internal //http://www.mp3-tech.org/programmer/frame_header.html 62 { 63 //byte 1 64 unsigned char frame_sync_a : 8; /* all bits should be set */ 65 //byte 2 66 unsigned char protection_bit : 1; 67 unsigned char layer : 2; 68 unsigned char id : 2; 69 unsigned char frame_sync_b : 3; /* all bits should be set */ 70 //byte 3 71 unsigned char private_bit : 1; 72 unsigned char padding_bit : 1; 73 unsigned char frequency : 2; 74 unsigned char bitrate_index : 4; 75 //byte 4 76 unsigned char emphasis : 2; 77 unsigned char original : 1; 78 unsigned char copyright : 1; 79 unsigned char mode_ext : 2;//only used in joint stereo 80 unsigned char mode : 2; 81 }; 82 83 Mp3_Headerinfo* _mp3_header_output; 84 }; //Info 85 86 #endif /* _MP3_HEADER_H_ */ 87 88