mp4tag.h
Go to the documentation of this file.
1 /**************************************************************************
2  copyright : (C) 2007,2011 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();
48  Tag(TagLib::File *file, Atoms *atoms);
49  ~Tag();
50  bool save();
51 
52  String title() const;
53  String artist() const;
54  String album() const;
55  String comment() const;
56  String genre() const;
57  uint year() const;
58  uint track() const;
59 
60  void setTitle(const String &value);
61  void setArtist(const String &value);
62  void setAlbum(const String &value);
63  void setComment(const String &value);
64  void setGenre(const String &value);
65  void setYear(uint value);
66  void setTrack(uint value);
67 
68  ItemListMap &itemListMap();
69 
70  PropertyMap properties() const;
71  void removeUnsupportedProperties(const StringList& properties);
72  PropertyMap setProperties(const PropertyMap &properties);
73 
74  private:
75  AtomDataList parseData2(Atom *atom, TagLib::File *file, int expectedFlags = -1, bool freeForm = false);
76  TagLib::ByteVectorList parseData(Atom *atom, TagLib::File *file, int expectedFlags = -1, bool freeForm = false);
77  void parseText(Atom *atom, TagLib::File *file, int expectedFlags = 1);
78  void parseFreeForm(Atom *atom, TagLib::File *file);
79  void parseInt(Atom *atom, TagLib::File *file);
80  void parseByte(Atom *atom, TagLib::File *file);
81  void parseUInt(Atom *atom, TagLib::File *file);
82  void parseLongLong(Atom *atom, TagLib::File *file);
83  void parseGnre(Atom *atom, TagLib::File *file);
84  void parseIntPair(Atom *atom, TagLib::File *file);
85  void parseBool(Atom *atom, TagLib::File *file);
86  void parseCovr(Atom *atom, TagLib::File *file);
87 
88  TagLib::ByteVector padIlst(const ByteVector &data, int length = -1);
89  TagLib::ByteVector renderAtom(const ByteVector &name, const TagLib::ByteVector &data);
90  TagLib::ByteVector renderData(const ByteVector &name, int flags, const TagLib::ByteVectorList &data);
91  TagLib::ByteVector renderText(const ByteVector &name, Item &item, int flags = TypeUTF8);
92  TagLib::ByteVector renderFreeForm(const String &name, Item &item);
93  TagLib::ByteVector renderBool(const ByteVector &name, Item &item);
94  TagLib::ByteVector renderInt(const ByteVector &name, Item &item);
95  TagLib::ByteVector renderByte(const ByteVector &name, Item &item);
96  TagLib::ByteVector renderUInt(const ByteVector &name, Item &item);
97  TagLib::ByteVector renderLongLong(const ByteVector &name, Item &item);
98  TagLib::ByteVector renderIntPair(const ByteVector &name, Item &item);
99  TagLib::ByteVector renderIntPairNoTrailing(const ByteVector &name, Item &item);
100  TagLib::ByteVector renderCovr(const ByteVector &name, Item &item);
101 
102  void updateParents(AtomList &path, long delta, int ignore = 0);
103  void updateOffsets(long delta, long offset);
104 
105  void saveNew(TagLib::ByteVector &data);
106  void saveExisting(TagLib::ByteVector &data, AtomList &path);
107 
108  void addItem(const String &name, const Item &value);
109 
110  class TagPrivate;
111  TagPrivate *d;
112  };
113 
114  }
115 
116 }
117 
118 #endif