mp4tag.h

Go to the documentation of this file.
00001 /**************************************************************************
00002     copyright            : (C) 2007 by Lukáš Lalinský
00003     email                : lalinsky@gmail.com
00004  **************************************************************************/
00005 
00006 /***************************************************************************
00007  *   This library is free software; you can redistribute it and/or modify  *
00008  *   it under the terms of the GNU Lesser General Public License version   *
00009  *   2.1 as published by the Free Software Foundation.                     *
00010  *                                                                         *
00011  *   This library is distributed in the hope that it will be useful, but   *
00012  *   WITHOUT ANY WARRANTY; without even the implied warranty of            *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00014  *   Lesser General Public License for more details.                       *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Lesser General Public      *
00017  *   License along with this library; if not, write to the Free Software   *
00018  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  *
00019  *   USA                                                                   *
00020  *                                                                         *
00021  *   Alternatively, this file is available under the Mozilla Public        *
00022  *   License Version 1.1.  You may obtain a copy of the License at         *
00023  *   http://www.mozilla.org/MPL/                                           *
00024  ***************************************************************************/
00025 
00026 #ifndef TAGLIB_MP4TAG_H
00027 #define TAGLIB_MP4TAG_H
00028 
00029 #include "tag.h"
00030 #include "tbytevectorlist.h"
00031 #include "tfile.h"
00032 #include "tmap.h"
00033 #include "tstringlist.h"
00034 #include "taglib_export.h"
00035 #include "mp4atom.h"
00036 #include "mp4item.h"
00037 
00038 namespace TagLib {
00039 
00040   namespace MP4 {
00041 
00042     typedef TagLib::Map<String, Item> ItemListMap;
00043 
00044     class TAGLIB_EXPORT Tag: public TagLib::Tag
00045     {
00046     public:
00047         Tag(TagLib::File *file, Atoms *atoms);
00048         ~Tag();
00049         bool save();
00050 
00051         String title() const;
00052         String artist() const;
00053         String album() const;
00054         String comment() const;
00055         String genre() const;
00056         uint year() const;
00057         uint track() const;
00058 
00059         void setTitle(const String &value);
00060         void setArtist(const String &value);
00061         void setAlbum(const String &value);
00062         void setComment(const String &value);
00063         void setGenre(const String &value);
00064         void setYear(uint value);
00065         void setTrack(uint value);
00066 
00067         ItemListMap &itemListMap();
00068 
00069     private:
00070         TagLib::ByteVectorList parseData(Atom *atom, TagLib::File *file, int expectedFlags = -1, bool freeForm = false);
00071         void parseText(Atom *atom, TagLib::File *file, int expectedFlags = 1);
00072         void parseFreeForm(Atom *atom, TagLib::File *file);
00073         void parseInt(Atom *atom, TagLib::File *file);
00074         void parseGnre(Atom *atom, TagLib::File *file);
00075         void parseIntPair(Atom *atom, TagLib::File *file);
00076         void parseBool(Atom *atom, TagLib::File *file);
00077         void parseCovr(Atom *atom, TagLib::File *file);
00078 
00079         TagLib::ByteVector padIlst(const ByteVector &data, int length = -1);
00080         TagLib::ByteVector renderAtom(const ByteVector &name, const TagLib::ByteVector &data);
00081         TagLib::ByteVector renderData(const ByteVector &name, int flags, const TagLib::ByteVectorList &data);
00082         TagLib::ByteVector renderText(const ByteVector &name, Item &item, int flags = 1);
00083         TagLib::ByteVector renderFreeForm(const String &name, Item &item);
00084         TagLib::ByteVector renderBool(const ByteVector &name, Item &item);
00085         TagLib::ByteVector renderInt(const ByteVector &name, Item &item);
00086         TagLib::ByteVector renderIntPair(const ByteVector &name, Item &item);
00087         TagLib::ByteVector renderIntPairNoTrailing(const ByteVector &name, Item &item);
00088         TagLib::ByteVector renderCovr(const ByteVector &name, Item &item);
00089 
00090         void updateParents(AtomList &path, long delta, int ignore = 0);
00091         void updateOffsets(long delta, long offset);
00092 
00093         void saveNew(TagLib::ByteVector &data);
00094         void saveExisting(TagLib::ByteVector &data, AtomList &path);
00095 
00096         class TagPrivate;
00097         TagPrivate *d;
00098     };
00099 
00100   }
00101 
00102 }
00103 
00104 #endif