1 /*************************************************************************** 2 copyright : (C) 2008 by Scott Wheeler 3 email : [email protected] 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_WAVFILE_H 27 #define TAGLIB_WAVFILE_H 28 29 #include "rifffile.h" 30 #include "id3v2tag.h" 31 #include "infotag.h" 32 #include "wavproperties.h" 33 34 namespace TagLib { 35 36 namespace RIFF { 37 38 //! An implementation of WAV metadata 39 40 /*! 41 * This is implementation of WAV metadata. 42 * 43 * This supports an ID3v2 tag as well as reading stream from the ID3 RIFF 44 * chunk as well as properties from the file. 45 */ 46 47 namespace WAV { 48 49 //! An implementation of TagLib::File with WAV specific methods 50 51 /*! 52 * This implements and provides an interface for WAV files to the 53 * TagLib::Tag and TagLib::AudioProperties interfaces by way of implementing 54 * the abstract TagLib::File API as well as providing some additional 55 * information specific to WAV files. 56 */ 57 58 class TAGLIB_EXPORT File : public TagLib::RIFF::File 59 { 60 public: 61 enum TagTypes { 62 //! Empty set. Matches no tag types. 63 NoTags = 0x0000, 64 //! Matches ID3v2 tags. 65 ID3v2 = 0x0001, 66 //! Matches INFO tags. 67 Info = 0x0002, 68 //! Matches all tag types. 69 AllTags = 0xffff 70 }; 71 72 /*! 73 * Constructs a WAV file from \a file. If \a readProperties is true the 74 * file's audio properties will also be read. 75 * 76 * \note In the current implementation, \a propertiesStyle is ignored. 77 */ 78 File(FileName file, bool readProperties = true, 79 Properties::ReadStyle propertiesStyle = Properties::Average); 80 81 /*! 82 * Constructs a WAV file from \a stream. If \a readProperties is true the 83 * file's audio properties will also be read. 84 * 85 * \note TagLib will *not* take ownership of the stream, the caller is 86 * responsible for deleting it after the File object. 87 * 88 * \note In the current implementation, \a propertiesStyle is ignored. 89 */ 90 File(IOStream *stream, bool readProperties = true, 91 Properties::ReadStyle propertiesStyle = Properties::Average); 92 93 /*! 94 * Destroys this instance of the File. 95 */ 96 virtual ~File(); 97 98 /*! 99 * Returns the ID3v2 Tag for this file. 100 * 101 * \note This method does not return all the tags for this file for 102 * backward compatibility. Will be fixed in TagLib 2.0. 103 */ 104 ID3v2::Tag *tag() const; 105 106 /*! 107 * Returns the ID3v2 Tag for this file. 108 * 109 * \note This always returns a valid pointer regardless of whether or not 110 * the file on disk has an ID3v2 tag. Use hasID3v2Tag() to check if the 111 * file on disk actually has an ID3v2 tag. 112 * 113 * \see hasID3v2Tag() 114 */ 115 ID3v2::Tag *ID3v2Tag() const; 116 117 /*! 118 * Returns the RIFF INFO Tag for this file. 119 * 120 * \note This always returns a valid pointer regardless of whether or not 121 * the file on disk has a RIFF INFO tag. Use hasInfoTag() to check if the 122 * file on disk actually has a RIFF INFO tag. 123 * 124 * \see hasInfoTag() 125 */ 126 Info::Tag *InfoTag() const; 127 128 /*! 129 * This will strip the tags that match the OR-ed together TagTypes from the 130 * file. By default it strips all tags. It returns true if the tags are 131 * successfully stripped. 132 * 133 * \note This will update the file immediately. 134 */ 135 void strip(TagTypes tags = AllTags); 136 137 /*! 138 * Implements the unified property interface -- export function. 139 * This method forwards to ID3v2::Tag::properties(). 140 */ 141 PropertyMap properties() const; 142 143 void removeUnsupportedProperties(const StringList &properties); 144 145 /*! 146 * Implements the unified property interface -- import function. 147 * This method forwards to ID3v2::Tag::setProperties(). 148 */ 149 PropertyMap setProperties(const PropertyMap &); 150 151 /*! 152 * Returns the WAV::Properties for this file. If no audio properties 153 * were read then this will return a null pointer. 154 */ 155 virtual Properties *audioProperties() const; 156 157 /*! 158 * Saves the file. 159 */ 160 virtual bool save(); 161 162 /*! 163 * \deprecated 164 */ 165 TAGLIB_DEPRECATED bool save(TagTypes tags, bool stripOthers, int id3v2Version = 4); 166 167 /*! 168 * Save the file. If \a strip is specified, it is possible to choose if 169 * tags not specified in \a tags should be stripped from the file or 170 * retained. With \a version, it is possible to specify whether ID3v2.4 171 * or ID3v2.3 should be used. 172 */ 173 bool save(TagTypes tags, StripTags strip = StripOthers, 174 ID3v2::Version version = ID3v2::v4); 175 176 /*! 177 * Returns whether or not the file on disk actually has an ID3v2 tag. 178 * 179 * \see ID3v2Tag() 180 */ 181 bool hasID3v2Tag() const; 182 183 /*! 184 * Returns whether or not the file on disk actually has a RIFF INFO tag. 185 * 186 * \see InfoTag() 187 */ 188 bool hasInfoTag() const; 189 190 /*! 191 * Returns whether or not the given \a stream can be opened as a WAV 192 * file. 193 * 194 * \note This method is designed to do a quick check. The result may 195 * not necessarily be correct. 196 */ 197 static bool isSupported(IOStream *stream); 198 199 private: 200 File(const File &); 201 File &operator=(const File &); 202 203 void read(bool readProperties); 204 void removeTagChunks(TagTypes tags); 205 206 friend class Properties; 207 208 class FilePrivate; 209 FilePrivate *d; 210 }; 211 } 212 } 213 } 214 215 #endif 216