Merge pull request #1784 from ScudLee/audiochannelsfix
[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 namespace MUSIC_INFO
42 {
43   class EmbeddedArtInfo
44   {
45   public:
46     EmbeddedArtInfo() {};
47     EmbeddedArtInfo(size_t size, const std::string &mime);
48     void set(size_t size, const std::string &mime);
49     void clear();
50     bool empty() const;
51     bool matches(const EmbeddedArtInfo &right) const;
52     size_t      size;
53     std::string mime;
54   };
55
56   class EmbeddedArt : public EmbeddedArtInfo
57   {
58   public:
59     EmbeddedArt() {};
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;
63   };
64
65 class CMusicInfoTag : public IArchivable, public ISerializable, public ISortable
66 {
67 public:
68   CMusicInfoTag(void);
69   CMusicInfoTag(const CMusicInfoTag& tag);
70   virtual ~CMusicInfoTag();
71   const CMusicInfoTag& operator =(const CMusicInfoTag& tag);
72   bool operator !=(const CMusicInfoTag& tag) const;
73   bool Loaded() 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
85   int GetYear() const;
86   int GetDatabaseId() const;
87   const std::string &GetType() const;
88
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;
109
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);
149
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.
153    */
154   void AppendArtist(const CStdString &artist);
155
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.
159    */
160   void AppendAlbumArtist(const CStdString &albumArtist);
161
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.
165    */
166   void AppendGenre(const CStdString &genre);
167
168   virtual void Archive(CArchive& ar);
169   virtual void Serialize(CVariant& ar) const;
170   virtual void ToSortable(SortItem& sortable);
171
172   void Clear();
173 protected:
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.
177    */
178   CStdString Trim(const CStdString &value) const;
179
180   CStdString m_strURL;
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;
194   bool m_bCompilation;
195   int m_iDuration;
196   int m_iTrack;     // consists of the disk number in the high 16 bits, the track number in the low 16bits
197   int m_iDbId;
198   std::string m_type; ///< item type "song", "album", "artist"
199   bool m_bLoaded;
200   char m_rating;
201   int m_listeners;
202   int m_iTimesPlayed;
203   int m_iAlbumId;
204   SYSTEMTIME m_dwReleaseDate;
205
206   // ReplayGain
207   int m_iTrackGain; // measured in milliBels
208   int m_iAlbumGain;
209   float m_fTrackPeak; // 1.0 == full digital scale
210   float m_fAlbumPeak;
211   int m_iHasGainInfo;   // valid info
212   EmbeddedArtInfo m_coverArt; ///< art information
213 };
214 }