4 * Copyright (C) 2005-2013 Team XBMC
7 * This Program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
12 * This Program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with XBMC; see the file COPYING. If not, see
19 * <http://www.gnu.org/licenses/>.
31 #include "utils/Archive.h"
32 #include "utils/ISerializable.h"
33 #include "utils/ISortable.h"
34 #include "XBDateTime.h"
36 #define REPLAY_GAIN_HAS_TRACK_INFO 1
37 #define REPLAY_GAIN_HAS_ALBUM_INFO 2
38 #define REPLAY_GAIN_HAS_TRACK_PEAK 4
39 #define REPLAY_GAIN_HAS_ALBUM_PEAK 8
54 EmbeddedArtInfo(size_t size, const std::string &mime);
55 void set(size_t size, const std::string &mime);
58 bool matches(const EmbeddedArtInfo &right) const;
63 class EmbeddedArt : public EmbeddedArtInfo
67 EmbeddedArt(const uint8_t *data, size_t size, const std::string &mime);
68 void set(const uint8_t *data, size_t size, const std::string &mime);
69 std::vector<uint8_t> data;
72 class CMusicInfoTag : public IArchivable, public ISerializable, public ISortable
76 CMusicInfoTag(const CMusicInfoTag& tag);
77 virtual ~CMusicInfoTag();
78 const CMusicInfoTag& operator =(const CMusicInfoTag& tag);
79 bool operator !=(const CMusicInfoTag& tag) const;
81 const CStdString& GetTitle() const;
82 const CStdString& GetURL() const;
83 const std::vector<std::string>& GetArtist() const;
84 const CStdString& GetAlbum() const;
85 int GetAlbumId() const;
86 const std::vector<std::string>& GetAlbumArtist() const;
87 const std::vector<std::string>& GetGenre() const;
88 int GetTrackNumber() const;
89 int GetDiscNumber() const;
90 int GetTrackAndDiskNumber() const;
91 int GetDuration() const; // may be set even if Loaded() returns false
93 int GetDatabaseId() const;
94 const std::string &GetType() const;
96 void GetReleaseDate(SYSTEMTIME& dateTime) const;
97 CStdString GetYearString() const;
98 const CStdString& GetMusicBrainzTrackID() const;
99 const std::vector<std::string>& GetMusicBrainzArtistID() const;
100 const CStdString& GetMusicBrainzAlbumID() const;
101 const std::vector<std::string>& GetMusicBrainzAlbumArtistID() const;
102 const CStdString& GetMusicBrainzTRMID() const;
103 const CStdString& GetComment() const;
104 const CStdString& GetLyrics() const;
105 const CDateTime& GetLastPlayed() const;
106 bool GetCompilation() const;
107 char GetRating() const;
108 int GetListeners() const;
109 int GetPlayCount() const;
110 const EmbeddedArtInfo &GetCoverArtInfo() const;
111 int GetReplayGainTrackGain() const;
112 int GetReplayGainAlbumGain() const;
113 float GetReplayGainTrackPeak() const;
114 float GetReplayGainAlbumPeak() const;
115 int HasReplayGainInfo() const;
117 void SetURL(const CStdString& strURL);
118 void SetTitle(const CStdString& strTitle);
119 void SetArtist(const CStdString& strArtist);
120 void SetArtist(const std::vector<std::string>& artists);
121 void SetAlbum(const CStdString& strAlbum);
122 void SetAlbumId(const int iAlbumId);
123 void SetAlbumArtist(const CStdString& strAlbumArtist);
124 void SetAlbumArtist(const std::vector<std::string>& albumArtists);
125 void SetGenre(const CStdString& strGenre);
126 void SetGenre(const std::vector<std::string>& genres);
127 void SetYear(int year);
128 void SetDatabaseId(long id, const std::string &type);
129 void SetReleaseDate(SYSTEMTIME& dateTime);
130 void SetTrackNumber(int iTrack);
131 void SetPartOfSet(int m_iPartOfSet);
132 void SetTrackAndDiskNumber(int iTrackAndDisc);
133 void SetDuration(int iSec);
134 void SetLoaded(bool bOnOff = true);
135 void SetArtist(const CArtist& artist);
136 void SetAlbum(const CAlbum& album);
137 void SetSong(const CSong& song);
138 void SetMusicBrainzTrackID(const CStdString& strTrackID);
139 void SetMusicBrainzArtistID(const std::vector<std::string>& musicBrainzArtistId);
140 void SetMusicBrainzAlbumID(const CStdString& strAlbumID);
141 void SetMusicBrainzAlbumArtistID(const std::vector<std::string>& musicBrainzAlbumArtistId);
142 void SetMusicBrainzTRMID(const CStdString& strTRMID);
143 void SetComment(const CStdString& comment);
144 void SetLyrics(const CStdString& lyrics);
145 void SetRating(char rating);
146 void SetListeners(int listeners);
147 void SetPlayCount(int playcount);
148 void SetLastPlayed(const CStdString& strLastPlayed);
149 void SetLastPlayed(const CDateTime& strLastPlayed);
150 void SetCompilation(bool compilation);
151 void SetCoverArtInfo(size_t size, const std::string &mimeType);
152 void SetReplayGainTrackGain(int trackGain);
153 void SetReplayGainAlbumGain(int albumGain);
154 void SetReplayGainTrackPeak(float trackPeak);
155 void SetReplayGainAlbumPeak(float albumPeak);
157 /*! \brief Append a unique artist to the artist list
158 Checks if we have this artist already added, and if not adds it to the songs artist list.
159 \param value artist to add.
161 void AppendArtist(const CStdString &artist);
163 /*! \brief Append a unique album artist to the artist list
164 Checks if we have this album artist already added, and if not adds it to the songs album artist list.
165 \param albumArtist album artist to add.
167 void AppendAlbumArtist(const CStdString &albumArtist);
169 /*! \brief Append a unique genre to the genre list
170 Checks if we have this genre already added, and if not adds it to the songs genre list.
171 \param genre genre to add.
173 void AppendGenre(const CStdString &genre);
175 virtual void Archive(CArchive& ar);
176 virtual void Serialize(CVariant& ar) const;
177 virtual void ToSortable(SortItem& sortable);
181 /*! \brief Trim whitespace off the given string
182 \param value string to trim
183 \return trimmed value, with spaces removed from left and right, as well as carriage returns from the right.
185 CStdString Trim(const CStdString &value) const;
188 CStdString m_strTitle;
189 std::vector<std::string> m_artist;
190 CStdString m_strAlbum;
191 std::vector<std::string> m_albumArtist;
192 std::vector<std::string> m_genre;
193 CStdString m_strMusicBrainzTrackID;
194 std::vector<std::string> m_musicBrainzArtistID;
195 CStdString m_strMusicBrainzAlbumID;
196 std::vector<std::string> m_musicBrainzAlbumArtistID;
197 CStdString m_strMusicBrainzTRMID;
198 CStdString m_strComment;
199 CStdString m_strLyrics;
200 CDateTime m_lastPlayed;
203 int m_iTrack; // consists of the disk number in the high 16 bits, the track number in the low 16bits
205 std::string m_type; ///< item type "song", "album", "artist"
211 SYSTEMTIME m_dwReleaseDate;
214 int m_iTrackGain; // measured in milliBels
216 float m_fTrackPeak; // 1.0 == full digital scale
218 int m_iHasGainInfo; // valid info
219 EmbeddedArtInfo m_coverArt; ///< art information