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
38namespace TagLib {
39
40 namespace MP4 {
41
42 /*!
43 * \deprecated
44 */
45 typedef TagLib::Map<String, Item> ItemListMap;
46 typedef TagLib::Map<String, Item> ItemMap;
47
48 class TAGLIB_EXPORT Tag: public TagLib::Tag
49 {
50 public:
51 Tag();
52 Tag(TagLib::File *file, Atoms *atoms);
53 virtual ~Tag();
54 bool save();
55
56 virtual String title() const;
57 virtual String artist() const;
58 virtual String album() const;
59 virtual String comment() const;
60 virtual String genre() const;
61 virtual unsigned int year() const;
62 virtual unsigned int track() const;
63
64 virtual void setTitle(const String &value);
65 virtual void setArtist(const String &value);
66 virtual void setAlbum(const String &value);
67 virtual void setComment(const String &value);
68 virtual void setGenre(const String &value);
69 virtual void setYear(unsigned int value);
70 virtual void setTrack(unsigned int value);
71
72 virtual bool isEmpty() const;
73
74 /*!
75 * \deprecated Use the item() and setItem() API instead
76 */
77 ItemMap &itemListMap();
78
79 /*!
80 * Returns a string-keyed map of the MP4::Items for this tag.
81 */
82 const ItemMap &itemMap() const;
83
84 /*!
85 * \return The item, if any, corresponding to \a key.
86 */
87 Item item(const String &key) const;
88
89 /*!
90 * Sets the value of \a key to \a value, overwriting any previous value.
91 */
92 void setItem(const String &key, const Item &value);
93
94 /*!
95 * Removes the entry with \a key from the tag, or does nothing if it does
96 * not exist.
97 */
98 void removeItem(const String &key);
99
100 /*!
101 * \return True if the tag contains an entry for \a key.
102 */
103 bool contains(const String &key) const;
104
105 PropertyMap properties() const;
106 void removeUnsupportedProperties(const StringList& properties);
107 PropertyMap setProperties(const PropertyMap &properties);
108
109 private:
110 AtomDataList parseData2(const Atom *atom, int expectedFlags = -1,
111 bool freeForm = false);
112 ByteVectorList parseData(const Atom *atom, int expectedFlags = -1,
113 bool freeForm = false);
114 void parseText(const Atom *atom, int expectedFlags = 1);
115 void parseFreeForm(const Atom *atom);
116 void parseInt(const Atom *atom);
117 void parseByte(const Atom *atom);
118 void parseUInt(const Atom *atom);
119 void parseLongLong(const Atom *atom);
120 void parseGnre(const Atom *atom);
121 void parseIntPair(const Atom *atom);
122 void parseBool(const Atom *atom);
123 void parseCovr(const Atom *atom);
124
125 ByteVector padIlst(const ByteVector &data, int length = -1) const;
126 ByteVector renderAtom(const ByteVector &name, const ByteVector &data) const;
127 ByteVector renderData(const ByteVector &name, int flags,
128 const ByteVectorList &data) const;
129 ByteVector renderText(const ByteVector &name, const Item &item,
130 int flags = TypeUTF8) const;
131 ByteVector renderFreeForm(const String &name, const Item &item) const;
132 ByteVector renderBool(const ByteVector &name, const Item &item) const;
133 ByteVector renderInt(const ByteVector &name, const Item &item) const;
134 ByteVector renderByte(const ByteVector &name, const Item &item) const;
135 ByteVector renderUInt(const ByteVector &name, const Item &item) const;
136 ByteVector renderLongLong(const ByteVector &name, const Item &item) const;
137 ByteVector renderIntPair(const ByteVector &name, const Item &item) const;
138 ByteVector renderIntPairNoTrailing(const ByteVector &name, const Item &item) const;
139 ByteVector renderCovr(const ByteVector &name, const Item &item) const;
140
141 void updateParents(const AtomList &path, long delta, int ignore = 0);
142 void updateOffsets(long delta, long offset);
143
144 void saveNew(ByteVector data);
145 void saveExisting(ByteVector data, const AtomList &path);
146
147 void addItem(const String &name, const Item &value);
148
149 class TagPrivate;
150 TagPrivate *d;
151 };
152
153 }
154
155}
156
157#endif
158