CLAM-Development  1.4.0
MpegBitstream.hxx
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2004 MUSIC TECHNOLOGY GROUP (MTG)
3  * UNIVERSITAT POMPEU FABRA
4  *
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  */
21 
22 #ifndef __MpegBitstream__
23 #define __MpegBitstream__
24 
25 #if USE_MAD != 1
26 #error USE_MAD was not set to 1 in your settings.cfg file, but you are including files that require this. Please fix your settings.cfg
27 #endif
28 
29 #include <mad.h>
30 #include <cstdio>
31 #include "DataTypes.hxx"
32 
33 namespace CLAM
34 {
35 
36 namespace AudioCodecs
37 {
39  {
40  struct mad_stream mBitstream;
41  struct mad_frame mCurrentFrame;
42  struct mad_synth mMpegSynth;
43  mad_timer_t mStreamTimer;
44 
45  unsigned char* mInputBuffer;
46  static const int mInputBufferSize;
47  unsigned long mBufferFileOffset;
48 
49  bool mFatalError;
50  FILE* mpFile;
51 
52  public:
53  MpegBitstream();
55 
56  void Init();
57  void Init(FILE*);
58  TTime Finish();
59  bool EOS();
60  bool FatalError();
61  bool NextFrame();
62  void SynthesizeCurrent();
64  unsigned long CurrentFrameFileOffset() const;
65  struct mad_frame& CurrentFrame();
66  struct mad_synth& CurrentSynthesis();
67  struct mad_stream& StreamState();
68  };
69 
70  inline struct mad_stream& MpegBitstream::StreamState()
71  {
72  return mBitstream;
73  }
74 }
75 
76 
77 }
78 
79 
80 #endif // MpegBitstream.hxx
81