settings: replace CSettings and CGUISettings with new CSettings
[vuplus_xbmc] / xbmc / music / tags / MusicInfoTag.h
1 #pragma once
2
3 /*
4  *      Copyright (C) 2005-2013 Team XBMC
5  *      http://www.xbmc.org
6  *
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)
10  *  any later version.
11  *
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.
16  *
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/>.
20  *
21  */
22
23 class CSong;
24 class CAlbum;
25 class CArtist;
26
27 #include <vector>
28 #include <string>
29 #include <stdint.h>
30
31 #include "utils/Archive.h"
32 #include "utils/ISerializable.h"
33 #include "utils/ISortable.h"
34 #include "XBDateTime.h"
35
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
40
41 enum ReplayGain
42 {
43   REPLAY_GAIN_NONE  = 0,
44   REPLAY_GAIN_ALBUM,
45   REPLAY_GAIN_TRACK
46 };
47
48 namespace MUSIC_INFO
49 {
50   class EmbeddedArtInfo
51   {
52   public:
53     EmbeddedArtInfo() {};
54     EmbeddedArtInfo(size_t size, const std::string &mime);
55     void set(size_t size, const std::string &mime);
56     void clear();
57     bool empty() const;
58     bool matches(const EmbeddedArtInfo &right) const;
59     size_t      size;
60     std::string mime;
61   };
62
63   class EmbeddedArt : public EmbeddedArtInfo
64   {
65   public:
66     EmbeddedArt() {};
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;
70   };
71
72 class CMusicInfoTag : public IArchivable, public ISerializable, public ISortable
73 {
74 public:
75   CMusicInfoTag(void);
76   CMusicInfoTag(const CMusicInfoTag& tag);
77   virtual ~CMusicInfoTag();
78   const CMusicInfoTag& operator =(const CMusicInfoTag& tag);
79   bool operator !=(const CMusicInfoTag& tag) const;
80   bool Loaded() 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
92   int GetYear() const;
93   int GetDatabaseId() const;
94   const std::string &GetType() const;
95
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;
116
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);
156
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.
160    */
161   void AppendArtist(const CStdString &artist);
162
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.
166    */
167   void AppendAlbumArtist(const CStdString &albumArtist);
168
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.
172    */
173   void AppendGenre(const CStdString &genre);
174
175   virtual void Archive(CArchive& ar);
176   virtual void Serialize(CVariant& ar) const;
177   virtual void ToSortable(SortItem& sortable);
178
179   void Clear();
180 protected:
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.
184    */
185   CStdString Trim(const CStdString &value) const;
186
187   CStdString m_strURL;
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;
201   bool m_bCompilation;
202   int m_iDuration;
203   int m_iTrack;     // consists of the disk number in the high 16 bits, the track number in the low 16bits
204   int m_iDbId;
205   std::string m_type; ///< item type "song", "album", "artist"
206   bool m_bLoaded;
207   char m_rating;
208   int m_listeners;
209   int m_iTimesPlayed;
210   int m_iAlbumId;
211   SYSTEMTIME m_dwReleaseDate;
212
213   // ReplayGain
214   int m_iTrackGain; // measured in milliBels
215   int m_iAlbumGain;
216   float m_fTrackPeak; // 1.0 == full digital scale
217   float m_fAlbumPeak;
218   int m_iHasGainInfo;   // valid info
219   EmbeddedArtInfo m_coverArt; ///< art information
220 };
221 }