mpegfile.h
Go to the documentation of this file.
1 /***************************************************************************
2  copyright : (C) 2002 - 2008 by Scott Wheeler
3  email : wheeler@kde.org
4  ***************************************************************************/
5 
6 /***************************************************************************
7  * This library is free software; you can redistribute it and/or modify *
8  * it under the terms of the GNU Lesser General Public License version *
9  * 2.1 as published by the Free Software Foundation. *
10  * *
11  * This library is distributed in the hope that it will be useful, but *
12  * WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14  * Lesser General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU Lesser General Public *
17  * License along with this library; if not, write to the Free Software *
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
19  * 02110-1301 USA *
20  * *
21  * Alternatively, this file is available under the Mozilla Public *
22  * License Version 1.1. You may obtain a copy of the License at *
23  * http://www.mozilla.org/MPL/ *
24  ***************************************************************************/
25 
26 #ifndef TAGLIB_MPEGFILE_H
27 #define TAGLIB_MPEGFILE_H
28 
29 #include "taglib_export.h"
30 #include "tfile.h"
31 #include "tag.h"
32 
33 #include "mpegproperties.h"
34 
35 namespace TagLib {
36 
37  namespace ID3v2 { class Tag; class FrameFactory; }
38  namespace ID3v1 { class Tag; }
39  namespace APE { class Tag; }
40 
42 
43  namespace MPEG {
44 
46 
54  {
55  public:
60  enum TagTypes {
62  NoTags = 0x0000,
64  ID3v1 = 0x0001,
66  ID3v2 = 0x0002,
68  APE = 0x0004,
70  AllTags = 0xffff
71  };
72 
81  File(FileName file, bool readProperties = true,
82  Properties::ReadStyle propertiesStyle = Properties::Average);
83 
93  File(FileName file, ID3v2::FrameFactory *frameFactory,
94  bool readProperties = true,
95  Properties::ReadStyle propertiesStyle = Properties::Average);
96 
106  // BIC: merge with the above constructor
107  File(IOStream *stream, ID3v2::FrameFactory *frameFactory,
108  bool readProperties = true,
109  Properties::ReadStyle propertiesStyle = Properties::Average);
110 
114  virtual ~File();
115 
133  virtual Tag *tag() const;
134 
141  PropertyMap properties() const;
142 
143  void removeUnsupportedProperties(const StringList &properties);
144 
153  PropertyMap setProperties(const PropertyMap &);
154 
159  virtual Properties *audioProperties() const;
160 
176  virtual bool save();
177 
187  bool save(int tags);
188 
198  // BIC: combine with the above method
199  bool save(int tags, bool stripOthers);
200 
213  // BIC: combine with the above method
214  bool save(int tags, bool stripOthers, int id3v2Version);
215 
227  ID3v2::Tag *ID3v2Tag(bool create = false);
228 
240  ID3v1::Tag *ID3v1Tag(bool create = false);
241 
253  APE::Tag *APETag(bool create = false);
254 
265  bool strip(int tags = AllTags);
266 
275  // BIC: merge with the method above
276  bool strip(int tags, bool freeMemory);
277 
283  void setID3v2FrameFactory(const ID3v2::FrameFactory *factory);
284 
288  long firstFrameOffset();
289 
294  long nextFrameOffset(long position);
295 
300  long previousFrameOffset(long position);
301 
305  long lastFrameOffset();
306 
310  bool hasID3v1Tag() const;
311 
315  bool hasID3v2Tag() const;
316 
320  bool hasAPETag() const;
321 
322  private:
323  File(const File &);
324  File &operator=(const File &);
325 
326  void read(bool readProperties, Properties::ReadStyle propertiesStyle);
327  long findID3v2();
328  long findID3v1();
329  void findAPE();
330 
336  static bool secondSynchByte(char byte);
337 
338  class FilePrivate;
339  FilePrivate *d;
340  };
341  }
342 }
343 
344 #endif