id3lib  3.8.3
mp3_header.h
Go to the documentation of this file.
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:
36  Mp3Info() { _mp3_header_output = new Mp3_Headerinfo; };
37  ~Mp3Info() { this->Clean(); };
38  void Clean();
39 
40  const Mp3_Headerinfo* GetMp3HeaderInfo() const { return _mp3_header_output; };
41  bool Parse(ID3_Reader&, size_t mp3size);
42 
43  Mpeg_Layers Layer() const { return _mp3_header_output->layer; };
44  Mpeg_Version Version() const { return _mp3_header_output->version; };
45  MP3_BitRates Bitrate() const { return _mp3_header_output->bitrate; };
46  Mp3_ChannelMode ChannelMode() const { return _mp3_header_output->channelmode; };
47  Mp3_ModeExt ModeExt() const { return _mp3_header_output->modeext; };
48  Mp3_Emphasis Emphasis() const { return _mp3_header_output->emphasis; };
49  Mp3_Crc Crc() const { return _mp3_header_output->crc; };
50  uint32 VbrBitrate() const { return _mp3_header_output->vbr_bitrate; };
51  uint32 Frequency() const { return _mp3_header_output->frequency; };
52  uint32 Framesize() const { return _mp3_header_output->framesize; };
53  uint32 Frames() const { return _mp3_header_output->frames; };
54  bool Private() const { return _mp3_header_output->privatebit; };
55  bool Copyrighted() const { return _mp3_header_output->copyrighted; };
56  bool Original() const { return _mp3_header_output->original; };
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 
Mp3_Emphasis Emphasis() const
Definition: mp3_header.h:48
bool Original() const
Definition: mp3_header.h:56
bool Private() const
Definition: mp3_header.h:54
Mp3_ModeExt ModeExt() const
Definition: mp3_header.h:47
~Mp3Info()
Definition: mp3_header.h:37
uint32 Frequency() const
Definition: mp3_header.h:51
MP3_BitRates Bitrate() const
Definition: mp3_header.h:45
Mpeg_Layers Layer() const
Definition: mp3_header.h:43
const Mp3_Headerinfo * GetMp3HeaderInfo() const
Definition: mp3_header.h:40
Mpeg_Version Version() const
Definition: mp3_header.h:44
uint32 Frames() const
Definition: mp3_header.h:53
uint32 VbrBitrate() const
Definition: mp3_header.h:50
bool Copyrighted() const
Definition: mp3_header.h:55
Mp3_Crc Crc() const
Definition: mp3_header.h:49
uint32 Seconds() const
Definition: mp3_header.h:57
Mp3Info()
Definition: mp3_header.h:36
Mp3_ChannelMode ChannelMode() const
Definition: mp3_header.h:46
void Clean()
Definition: mp3_parse.cpp:93
uint32 Framesize() const
Definition: mp3_header.h:52
bool Parse(ID3_Reader &, size_t mp3size)
Definition: mp3_parse.cpp:102
Mp3_ModeExt
Definition: globals.h:496
Mp3_Emphasis
Definition: globals.h:505
Mpeg_Layers
Definition: globals.h:454
Mp3_ChannelMode
Definition: globals.h:487
Mp3_Crc
Definition: globals.h:514
MP3_BitRates
Definition: globals.h:424
Mpeg_Version
Definition: globals.h:463
MP3_BitRates bitrate
Definition: globals.h:525
Mpeg_Layers layer
Definition: globals.h:523
Mp3_ChannelMode channelmode
Definition: globals.h:526
bool original
Definition: globals.h:537
uint32 time
Definition: globals.h:534
Mp3_Emphasis emphasis
Definition: globals.h:528
bool copyrighted
Definition: globals.h:536
uint32 frames
Definition: globals.h:533
Mp3_Crc crc
Definition: globals.h:529
uint32 vbr_bitrate
Definition: globals.h:530
uint32 framesize
Definition: globals.h:532
Mpeg_Version version
Definition: globals.h:524
bool privatebit
Definition: globals.h:535
Mp3_ModeExt modeext
Definition: globals.h:527
uint32 frequency
Definition: globals.h:531