CLAM-Development  1.4.0
AudioFile.hxx
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2001-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 __AUDIOFILE__
23 #define __AUDIOFILE__
24 
25 #include "DataTypes.hxx"
26 #include "AudioFileFormats.hxx"
27 #include "AudioFileHeader.hxx"
28 #include "AudioTextDescriptors.hxx"
29 #include "Filename.hxx"
30 
31 namespace CLAM
32 {
33  namespace AudioCodecs
34  {
35  class Codec; // forward declaration
36  class Stream; // forward declaration
37  }
38 
40  class AudioFile
41  {
42  public:
43 
44  AudioFile();
45  AudioFile( const AudioFile& );
46  const AudioFile& operator=( const AudioFile& );
47  virtual ~AudioFile();
48 
49  const Filename & GetLocation() const { return mLocation; }
50  const AudioFileHeader & GetHeader() const { return mHeaderData; }
51  const AudioTextDescriptors & GetTextDescriptors() const { return mTextDescriptors; }
52  AudioTextDescriptors & GetTextDescriptors() { return mTextDescriptors; }
53 
54  void SetTextDescriptors( const AudioTextDescriptors & descriptors ) { mTextDescriptors=descriptors; }
55 
56  EAudioFileCodec GetCodec() const;
57 
58  bool IsValid() const;
59  bool IsReadable() const;
60  bool IsWritable() const;
61 
63 
64  protected:
66  bool SetHeader( const AudioFileHeader& );
67  void ResolveCodec();
68 
69  void ActivateCodec();
70  void ResetHeaderData();
71 
74  private:
75  AudioCodecs::Codec* mActiveCodec;
76  AudioFileHeader mHeaderData;
77  AudioTextDescriptors mTextDescriptors;
78 
79  };
80 
81  class AudioFileSource : public AudioFile
82  {
83  public:
84  void OpenExisting(const std::string &location);
85  };
86 
87  class AudioFileTarget : public AudioFile
88  {
89  public:
90  bool CreateNew(const std::string &location,
91  const AudioFileHeader &header);
92  };
93 
94 
95 }
96 
97 
98 
99 
100 #endif // AudioFile.hxx
101