1 /*************************************************************************** 2 copyright : (C) 2005 by Martin Aumueller 3 email : aumuell@reserv.at 4 5 copyright : (C) 2005 by Andy Leadbetter 6 email : andrew.leadbetter@gmail.com 7 (original mp4 implementation) 8 ***************************************************************************/ 9 10 /*************************************************************************** 11 * This library is free software; you can redistribute it and/or modify * 12 * it under the terms of the GNU Lesser General Public License version * 13 * 2.1 as published by the Free Software Foundation. * 14 * * 15 * This library is distributed in the hope that it will be useful, but * 16 * WITHOUT ANY WARRANTY; without even the implied warranty of * 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 18 * Lesser General Public License for more details. * 19 * * 20 * You should have received a copy of the GNU Lesser General Public * 21 * License along with this library; if not, write to the Free Software * 22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * 23 * MA 02110-1301 USA * 24 ***************************************************************************/ 25 26 #ifndef TAGLIB_AUDIBLETAG_H 27 #define TAGLIB_AUDIBLETAG_H 28 29 #include <taglib-extras_export.h> 30 #include <tag.h> 31 32 namespace TagLibExtras { 33 34 namespace Audible { 35 /*! 36 * This implements the generic TagLib::Tag API 37 */ 38 class TAGLIB_EXTRAS_EXPORT Tag : public TagLib::Tag 39 { 40 public: 41 Tag(); 42 43 /*! 44 * read tags from the aa file. 45 */ 46 void readTags( FILE *file ); 47 48 /*! 49 * Destroys this AudibleTag instance. 50 */ 51 virtual ~Tag(); 52 53 /*! 54 * Returns the track name; if no track name is present in the tag 55 * TagLib::String::null will be returned. 56 */ title()57 virtual TagLib::String title() const { return m_title; } 58 59 /*! 60 * Returns the artist name; if no artist name is present in the tag 61 * TagLib::String::null will be returned. 62 */ artist()63 virtual TagLib::String artist() const { return m_artist; } 64 65 /*! 66 * Returns the album name; if no album name is present in the tag 67 * TagLib::String::null will be returned. 68 */ album()69 virtual TagLib::String album() const { return m_album; } 70 71 /*! 72 * Returns the track comment; if no comment is present in the tag 73 * TagLib::String::null will be returned. 74 */ comment()75 virtual TagLib::String comment() const { return m_comment; } 76 77 /*! 78 * Returns the genre name; if no genre is present in the tag TagLib::String::null 79 * will be returned. 80 */ genre()81 virtual TagLib::String genre() const { return m_genre; } 82 83 /*! 84 * Returns the year; if there is no year set, this will return 0. 85 */ year()86 virtual TagLib::uint year() const { return m_year; } 87 88 /*! 89 * Returns the track number; if there is no track number set, this will 90 * return 0. 91 */ track()92 virtual TagLib::uint track() const { return m_track; } 93 94 /*! 95 * Returns the user id for this file. 96 */ userID()97 virtual TagLib::uint userID() const { return m_userID; } 98 99 /*! 100 * Sets the title to \a s. If \a s is TagLib::String::null then this value will be 101 * cleared. 102 */ setTitle(const TagLib::String & s)103 virtual void setTitle(const TagLib::String &s) { m_title = s; } 104 105 /*! 106 * Sets the artist to \a s. If \a s is TagLib::String::null then this value will be 107 * cleared. 108 */ setArtist(const TagLib::String & s)109 virtual void setArtist(const TagLib::String &s) { m_artist = s; } 110 111 /*! 112 * Sets the album to \a s. If \a s is TagLib::String::null then this value will be 113 * cleared. 114 */ setAlbum(const TagLib::String & s)115 virtual void setAlbum(const TagLib::String &s) { m_album = s; } 116 117 /*! 118 * Sets the album to \a s. If \a s is TagLib::String::null then this value will be 119 * cleared. 120 */ setComment(const TagLib::String & s)121 virtual void setComment(const TagLib::String &s) { m_comment = s; } 122 123 /*! 124 * Sets the genre to \a s. If \a s is TagLib::String::null then this value will be 125 * cleared. For tag formats that use a fixed set of genres, the appropriate 126 * value will be selected based on a string comparison. A list of available 127 * genres for those formats should be available in that type's 128 * implementation. 129 */ setGenre(const TagLib::String & s)130 virtual void setGenre(const TagLib::String &s) { m_genre = s; } 131 132 /*! 133 * Sets the year to \a i. If \a s is 0 then this value will be cleared. 134 */ setYear(TagLib::uint i)135 virtual void setYear(TagLib::uint i) { m_year = i; } 136 137 /*! 138 * Sets the track to \a i. If \a s is 0 then this value will be cleared. 139 */ setTrack(TagLib::uint i)140 virtual void setTrack(TagLib::uint i) { m_track = i; } 141 142 /*! 143 * Returns true if the tag does not contain any data. This should be 144 * reimplemented in subclasses that provide more than the basic tagging 145 * abilities in this class. 146 */ 147 virtual bool isEmpty() const; 148 149 /*! 150 * Copies the generic data from one tag to another. 151 * 152 * \note This will not affect any of the lower level details of the tag. For 153 * instance if any of the tag type specific data (maybe a URL for a band) is 154 * set, this will not modify or copy that. This just copies using the API 155 * in this class. 156 * 157 * If \a overwrite is true then the values will be unconditionally copied. 158 * If false only empty values will be overwritten. 159 */ 160 static void duplicate(const Tag *source, Tag *target, bool overwrite = true); 161 setUserID(TagLib::uint id)162 virtual void setUserID(TagLib::uint id) { m_userID = id; } 163 164 int getTagsEndOffset(); 165 166 167 168 protected: 169 TagLib::String m_title; 170 TagLib::String m_artist; 171 TagLib::String m_album; 172 TagLib::String m_comment; 173 TagLib::String m_genre; 174 TagLib::uint m_year; 175 TagLib::uint m_track; 176 TagLib::uint m_userID; 177 bool readTag( FILE *fp, char **name, char **value); 178 int m_tagsEndOffset; 179 }; 180 } 181 } 182 183 #endif 184