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
47 EmbeddedArtInfo(size_t size, const std::string &mime);
48 void set(size_t size, const std::string &mime);
51 bool matches(const EmbeddedArtInfo &right) const;
56 class EmbeddedArt : public EmbeddedArtInfo
60 EmbeddedArt(const uint8_t *data, size_t size, const std::string &mime);
61 void set(const uint8_t *data, size_t size, const std::string &mime);
62 std::vector<uint8_t> data;
65 class CMusicInfoTag : public IArchivable, public ISerializable, public ISortable
69 CMusicInfoTag(const CMusicInfoTag& tag);
70 virtual ~CMusicInfoTag();
71 const CMusicInfoTag& operator =(const CMusicInfoTag& tag);
72 bool operator !=(const CMusicInfoTag& tag) const;
74 const CStdString& GetTitle() const;
75 const CStdString& GetURL() const;
76 const std::vector<std::string>& GetArtist() const;
77 const CStdString& GetAlbum() const;
78 int GetAlbumId() const;
79 const std::vector<std::string>& GetAlbumArtist() const;
80 const std::vector<std::string>& GetGenre() const;
81 int GetTrackNumber() const;
82 int GetDiscNumber() const;
83 int GetTrackAndDiskNumber() const;
84 int GetDuration() const; // may be set even if Loaded() returns false
86 int GetDatabaseId() const;
87 const std::string &GetType() const;
89 void GetReleaseDate(SYSTEMTIME& dateTime) const;
90 CStdString GetYearString() const;
91 const CStdString& GetMusicBrainzTrackID() const;
92 const CStdString& GetMusicBrainzArtistID() const;
93 const CStdString& GetMusicBrainzAlbumID() const;
94 const CStdString& GetMusicBrainzAlbumArtistID() const;
95 const CStdString& GetMusicBrainzTRMID() const;
96 const CStdString& GetComment() const;
97 const CStdString& GetLyrics() const;
98 const CDateTime& GetLastPlayed() const;
99 bool GetCompilation() const;
100 char GetRating() const;
101 int GetListeners() const;
102 int GetPlayCount() const;
103 const EmbeddedArtInfo &GetCoverArtInfo() const;
104 int GetReplayGainTrackGain() const;
105 int GetReplayGainAlbumGain() const;
106 float GetReplayGainTrackPeak() const;
107 float GetReplayGainAlbumPeak() const;
108 int HasReplayGainInfo() const;
110 void SetURL(const CStdString& strURL);
111 void SetTitle(const CStdString& strTitle);
112 void SetArtist(const CStdString& strArtist);
113 void SetArtist(const std::vector<std::string>& artists);
114 void SetAlbum(const CStdString& strAlbum);
115 void SetAlbumId(const int iAlbumId);
116 void SetAlbumArtist(const CStdString& strAlbumArtist);
117 void SetAlbumArtist(const std::vector<std::string>& albumArtists);
118 void SetGenre(const CStdString& strGenre);
119 void SetGenre(const std::vector<std::string>& genres);
120 void SetYear(int year);
121 void SetDatabaseId(long id, const std::string &type);
122 void SetReleaseDate(SYSTEMTIME& dateTime);
123 void SetTrackNumber(int iTrack);
124 void SetPartOfSet(int m_iPartOfSet);
125 void SetTrackAndDiskNumber(int iTrackAndDisc);
126 void SetDuration(int iSec);
127 void SetLoaded(bool bOnOff = true);
128 void SetArtist(const CArtist& artist);
129 void SetAlbum(const CAlbum& album);
130 void SetSong(const CSong& song);
131 void SetMusicBrainzTrackID(const CStdString& strTrackID);
132 void SetMusicBrainzArtistID(const CStdString& strArtistID);
133 void SetMusicBrainzAlbumID(const CStdString& strAlbumID);
134 void SetMusicBrainzAlbumArtistID(const CStdString& strAlbumArtistID);
135 void SetMusicBrainzTRMID(const CStdString& strTRMID);
136 void SetComment(const CStdString& comment);
137 void SetLyrics(const CStdString& lyrics);
138 void SetRating(char rating);
139 void SetListeners(int listeners);
140 void SetPlayCount(int playcount);
141 void SetLastPlayed(const CStdString& strLastPlayed);
142 void SetLastPlayed(const CDateTime& strLastPlayed);
143 void SetCompilation(bool compilation);
144 void SetCoverArtInfo(size_t size, const std::string &mimeType);
145 void SetReplayGainTrackGain(int trackGain);
146 void SetReplayGainAlbumGain(int albumGain);
147 void SetReplayGainTrackPeak(float trackPeak);
148 void SetReplayGainAlbumPeak(float albumPeak);
150 /*! \brief Append a unique artist to the artist list
151 Checks if we have this artist already added, and if not adds it to the songs artist list.
152 \param value artist to add.
154 void AppendArtist(const CStdString &artist);
156 /*! \brief Append a unique album artist to the artist list
157 Checks if we have this album artist already added, and if not adds it to the songs album artist list.
158 \param albumArtist album artist to add.
160 void AppendAlbumArtist(const CStdString &albumArtist);
162 /*! \brief Append a unique genre to the genre list
163 Checks if we have this genre already added, and if not adds it to the songs genre list.
164 \param genre genre to add.
166 void AppendGenre(const CStdString &genre);
168 virtual void Archive(CArchive& ar);
169 virtual void Serialize(CVariant& ar) const;
170 virtual void ToSortable(SortItem& sortable);
174 /*! \brief Trim whitespace off the given string
175 \param value string to trim
176 \return trimmed value, with spaces removed from left and right, as well as carriage returns from the right.
178 CStdString Trim(const CStdString &value) const;
181 CStdString m_strTitle;
182 std::vector<std::string> m_artist;
183 CStdString m_strAlbum;
184 std::vector<std::string> m_albumArtist;
185 std::vector<std::string> m_genre;
186 CStdString m_strMusicBrainzTrackID;
187 CStdString m_strMusicBrainzArtistID;
188 CStdString m_strMusicBrainzAlbumID;
189 CStdString m_strMusicBrainzAlbumArtistID;
190 CStdString m_strMusicBrainzTRMID;
191 CStdString m_strComment;
192 CStdString m_strLyrics;
193 CDateTime m_lastPlayed;
196 int m_iTrack; // consists of the disk number in the high 16 bits, the track number in the low 16bits
198 std::string m_type; ///< item type "song", "album", "artist"
204 SYSTEMTIME m_dwReleaseDate;
207 int m_iTrackGain; // measured in milliBels
209 float m_fTrackPeak; // 1.0 == full digital scale
211 int m_iHasGainInfo; // valid info
212 EmbeddedArtInfo m_coverArt; ///< art information