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