mp4tag.h
Go to the documentation of this file.
1 /**************************************************************************
2  copyright : (C) 2007 by Lukáš Lalinský
3  email : lalinsky@gmail.com
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_MP4TAG_H
27 #define TAGLIB_MP4TAG_H
28 
29 #include "tag.h"
30 #include "tbytevectorlist.h"
31 #include "tfile.h"
32 #include "tmap.h"
33 #include "tstringlist.h"
34 #include "taglib_export.h"
35 #include "mp4atom.h"
36 #include "mp4item.h"
37 
38 namespace TagLib {
39 
40  namespace MP4 {
41 
43 
45  {
46  public:
47  Tag(TagLib::File *file, Atoms *atoms);
48  ~Tag();
49  bool save();
50 
51  String title() const;
52  String artist() const;
53  String album() const;
54  String comment() const;
55  String genre() const;
56  uint year() const;
57  uint track() const;
58 
59  void setTitle(const String &value);
60  void setArtist(const String &value);
61  void setAlbum(const String &value);
62  void setComment(const String &value);
63  void setGenre(const String &value);
64  void setYear(uint value);
65  void setTrack(uint value);
66 
67  ItemListMap &itemListMap();
68 
69  private:
70  TagLib::ByteVectorList parseData(Atom *atom, TagLib::File *file, int expectedFlags = -1, bool freeForm = false);
71  void parseText(Atom *atom, TagLib::File *file, int expectedFlags = 1);
72  void parseFreeForm(Atom *atom, TagLib::File *file);
73  void parseInt(Atom *atom, TagLib::File *file);
74  void parseGnre(Atom *atom, TagLib::File *file);
75  void parseIntPair(Atom *atom, TagLib::File *file);
76  void parseBool(Atom *atom, TagLib::File *file);
77  void parseCovr(Atom *atom, TagLib::File *file);
78 
79  TagLib::ByteVector padIlst(const ByteVector &data, int length = -1);
80  TagLib::ByteVector renderAtom(const ByteVector &name, const TagLib::ByteVector &data);
81  TagLib::ByteVector renderData(const ByteVector &name, int flags, const TagLib::ByteVectorList &data);
82  TagLib::ByteVector renderText(const ByteVector &name, Item &item, int flags = 1);
83  TagLib::ByteVector renderFreeForm(const String &name, Item &item);
84  TagLib::ByteVector renderBool(const ByteVector &name, Item &item);
85  TagLib::ByteVector renderInt(const ByteVector &name, Item &item);
86  TagLib::ByteVector renderIntPair(const ByteVector &name, Item &item);
87  TagLib::ByteVector renderIntPairNoTrailing(const ByteVector &name, Item &item);
88  TagLib::ByteVector renderCovr(const ByteVector &name, Item &item);
89 
90  void updateParents(AtomList &path, long delta, int ignore = 0);
91  void updateOffsets(long delta, long offset);
92 
93  void saveNew(TagLib::ByteVector &data);
94  void saveExisting(TagLib::ByteVector &data, AtomList &path);
95 
96  class TagPrivate;
97  TagPrivate *d;
98  };
99 
100  }
101 
102 }
103 
104 #endif