mpegfile.h
Go to the documentation of this file.
00001 /***************************************************************************
00002     copyright            : (C) 2002 - 2008 by Scott Wheeler
00003     email                : wheeler@kde.org
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., 51 Franklin Street, Fifth Floor, Boston, MA         *
00019  *   02110-1301  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_MPEGFILE_H
00027 #define TAGLIB_MPEGFILE_H
00028 
00029 #include "taglib_export.h"
00030 #include "tfile.h"
00031 #include "tag.h"
00032 
00033 #include "mpegproperties.h"
00034 
00035 namespace TagLib {
00036 
00037   namespace ID3v2 { class Tag; class FrameFactory; }
00038   namespace ID3v1 { class Tag; }
00039   namespace APE { class Tag; }
00040 
00042 
00043   namespace MPEG {
00044 
00046 
00053     class TAGLIB_EXPORT File : public TagLib::File
00054     {
00055     public:
00060       enum TagTypes {
00062         NoTags  = 0x0000,
00064         ID3v1   = 0x0001,
00066         ID3v2   = 0x0002,
00068         APE     = 0x0004,
00070         AllTags = 0xffff
00071       };
00072 
00081       File(FileName file, bool readProperties = true,
00082            Properties::ReadStyle propertiesStyle = Properties::Average);
00083 
00093       File(FileName file, ID3v2::FrameFactory *frameFactory,
00094            bool readProperties = true,
00095            Properties::ReadStyle propertiesStyle = Properties::Average);
00096 
00106       // BIC: merge with the above constructor
00107       File(IOStream *stream, ID3v2::FrameFactory *frameFactory,
00108            bool readProperties = true,
00109            Properties::ReadStyle propertiesStyle = Properties::Average);
00110 
00114       virtual ~File();
00115 
00133       virtual Tag *tag() const;
00134 
00141       PropertyMap properties() const;
00142 
00143       void removeUnsupportedProperties(const StringList &properties);
00144 
00150       PropertyMap setProperties(const PropertyMap &);
00151 
00156       virtual Properties *audioProperties() const;
00157 
00173       virtual bool save();
00174 
00184       bool save(int tags);
00185 
00195       // BIC: combine with the above method
00196       bool save(int tags, bool stripOthers);
00197 
00210       // BIC: combine with the above method
00211       bool save(int tags, bool stripOthers, int id3v2Version);
00212 
00224       ID3v2::Tag *ID3v2Tag(bool create = false);
00225 
00237       ID3v1::Tag *ID3v1Tag(bool create = false);
00238 
00250       APE::Tag *APETag(bool create = false);
00251 
00262       bool strip(int tags = AllTags);
00263 
00272       // BIC: merge with the method above
00273       bool strip(int tags, bool freeMemory);
00274 
00280       void setID3v2FrameFactory(const ID3v2::FrameFactory *factory);
00281 
00285       long firstFrameOffset();
00286 
00291       long nextFrameOffset(long position);
00292 
00297       long previousFrameOffset(long position);
00298 
00302       long lastFrameOffset();
00303 
00304     private:
00305       File(const File &);
00306       File &operator=(const File &);
00307 
00308       void read(bool readProperties, Properties::ReadStyle propertiesStyle);
00309       long findID3v2();
00310       long findID3v1();
00311       void findAPE();
00312 
00318       static bool secondSynchByte(char byte);
00319 
00320       class FilePrivate;
00321       FilePrivate *d;
00322     };
00323   }
00324 }
00325 
00326 #endif