libtaginfo  0.2.0
taginfo.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2013 J.Rios <anonbeat@gmail.com>
3  * Copyright (C) 2013 Jörn Magens
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This Program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; see the file LICENSE. If not, write to
17  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth
18  * Floor, Boston, MA 02110-1301 USA
19  * https://www.gnu.org/licenses/lgpl-2.1.txt
20  *
21  * Author:
22  * Jörn Magens <shuerhaaken@googlemail.com>
23  * Matias De lellis <mati86dl@gmail.com>
24  * Pavel Vasin <rat4vier@gmail.com>
25  */
26 
27 
28 #ifndef TAGINFO_H
29 #define TAGINFO_H
30 
31 #include <stdio.h>
32 #include <string.h>
33 
34 #include <tag.h>
35 #include <apetag.h>
36 #include <asftag.h>
37 #include <fileref.h>
38 #include <id3v2tag.h>
39 #include <flacfile.h>
40 #include <modtag.h>
41 #include <mp4tag.h>
42 #include <xiphcomment.h>
43 
44 #include "taginfo_image.h"
45 
46 
47 using namespace TagLib;
48 using namespace std;
49 
57 namespace TagInfo {
58 
62  typedef TagLib::List<Image *> ImageList;
63 
65 
117  };
118 
119 
120 
122 
125  class Info {
126  public:
127  virtual ~Info();
128 
129  // CREATION METHODS
130  static Info * create(const String &filename);
131  static Info * create_with_file_type(const String &file, MediaFileType format);
132  static Info * create_from_mime(const String &filename, const String &mime_type);
133 
134  //General stuff
135 
137  String get_file_name(void);
138 
141  bool is_valid();
142 
143 
144  //Tag access functions
145 
146  String get_album_artist(void) const;
147  void set_album_artist(const String new_artist);
148 
149  String get_album(void) const;
150  void set_album(const String new_album);
151 
152  String get_artist(void) const;
153  void set_artist(const String new_artist);
154 
155  int get_beats_per_minute() const;
156  void set_beats_per_minute(const int new_bpm);
157 
158  String get_comments(void) const;
159  void set_comments(const String new_comments);
160 
161  String get_composer(void) const;
162  void set_composer(const String new_composer);
163 
164  String get_copyright(void) const;
165  void set_copyright(const String new_copyright);
166 
167  String get_encoder(void) const;
168  void set_encoder(const String new_encoder);
169 
170  String get_genre(void) const;
171  void set_genre(const String new_genre);
172 
173  bool get_has_image() const;
174 
175  String get_homepage(void) const;
176  void set_homepage(const String new_homepage);
177 
178  bool get_is_compilation() const;
179  void set_is_compilation(bool compilation);
180 
181  String get_original_artist(void) const;
182  void set_original_artist(const String new_artist);
183 
184  int get_playcount() const;
185  void set_playcount(int new_playcount);
186 
187  int get_rating() const;
188  void set_rating(const int new_rating);
189 
190  String get_title(void) const;
191  void set_title(const String new_title);
192 
193  int get_track_count() const;
194  void set_track_count(const int new_track_count);
195 
196  int get_track_number() const;
197  void set_track_number(const int new_track_number);
198 
199  int get_volume_count() const;
200  void set_volume_count(const int count);
201 
202  int get_volume_number() const;
203  void set_volume_number(const int number);
204 
205  int get_year() const;
206  void set_year(const int new_year);
207 
208  //Audio properties
209  int get_length_seconds() const;
210  int get_bitrate() const;
211  int get_channels() const;
212  int get_samplerate() const;
213 
214 
215  //Labels
216  StringList get_track_labels_list() const;
217  void set_track_labels_list(const StringList &new_track_labels_list);
218 
219  StringList get_artist_labels_list() const;
220  void set_artist_labels_list(const StringList &new_artist_labels_list);
221 
222  StringList get_album_labels_list() const;
223  void set_album_labels_list(const StringList &new_album_labels_list);
224 
225 
226 
231  virtual bool load(void);
232 
236  virtual bool save(void);
237 
238 
239  virtual ImageList get_images() const;
240  virtual void set_images(const ImageList images);
241 
242  virtual String get_lyrics(void) const;
243  virtual void set_lyrics(const String &lyrics);
244 
245 
246  protected :
248  Info(const String &filename = "");
249 
251  TagLib::FileRef * taglib_fileref;
252 
254  TagLib::File * taglib_file;
255 
257  TagLib::Tag * taglib_tag;
258 
260  String file_name;
261 
262  //Tags
263 
265  String title;
267  String genre;
269  String artist;
271  String album_artist;
273  String album;
275  String composer;
277  String comments;
279  String homepage;
281  String encoder;
283  String copyright;
291  int year;
300 
301 
302  //Audioproperties
306  int bitrate;
310  int channels;
311 
312  //Extras
316  int rating;
317 
319  StringList track_labels;
323  StringList artist_labels;
327  StringList album_labels;
330 
332  ulong changedflag;
333 
335  bool has_image;
336 
338  bool valid;
339 
342  void load_base_tags(TagLib::Tag * tag);
343 
346  void save_base_tags(TagLib::Tag * tag);
347  };
348 
350 
351  /* ! InfoRef exists to provide a minimal, generic and value-based wrapper around
352  * a Info. It is lightweight and suitable for pass-by-value use.
353  * This hides the TagInfo::Info memory management.
354  */
355  class InfoRef {
356  public:
357  InfoRef(const String &filename);
358  InfoRef(const String &filename, MediaFileType format);
359  InfoRef(const String &filename, const String &mime);
360  ~InfoRef();
361 
362  Info * info() const;
363  bool is_valid() const;
364  bool load() const;
365  bool save();
366 
367  private:
368  Info * i;
369  };
370 
371 }
372 #endif
Asf media file.
Definition: taginfo.h:76
TagLib::File * taglib_file
TagLib::File of the media file
Definition: taginfo.h:254
A simple, value based wrapper round Info.
Definition: taginfo.h:355
String composer
Composer of the Info object.
Definition: taginfo.h:275
Aac media file.
Definition: taginfo.h:70
Flac media file.
Definition: taginfo.h:78
MP3 media file.
Definition: taginfo.h:86
String file_name
The path of the media file.
Definition: taginfo.h:260
String artist_labels_string
User defined artist labels as string with "|" as delimiter.
Definition: taginfo.h:325
String comments
Comments of the Info object.
Definition: taginfo.h:277
int track_number
Track number of the Info object.
Definition: taginfo.h:287
Speex media file.
Definition: taginfo.h:104
Impulse Tracker media file.
Definition: taginfo.h:110
String title
Title of the Info object.
Definition: taginfo.h:265
MP4 media file.
Definition: taginfo.h:88
String album
Album of the Info object.
Definition: taginfo.h:273
bool valid
Whether the info object is valid.
Definition: taginfo.h:338
bool has_image
Whether there is image data available.
Definition: taginfo.h:335
int playcount
Play count.
Definition: taginfo.h:314
MediaFileType
describes the media file type
Definition: taginfo.h:66
int beats_per_minute
Speed in beats per minute.
Definition: taginfo.h:295
M4A media file.
Definition: taginfo.h:80
int length_seconds
Lenght in seconds.
Definition: taginfo.h:304
String track_labels_string
User defined track labels as string with "|" as delimiter.
Definition: taginfo.h:321
M4P media file.
Definition: taginfo.h:84
StringList album_labels
User defined album labels.
Definition: taginfo.h:327
Unknown media file type.
Definition: taginfo.h:68
Opus media file.
Definition: taginfo.h:116
int volume_number
Volume number of the Info object.
Definition: taginfo.h:297
Wmv media file.
Definition: taginfo.h:106
Tta media file.
Definition: taginfo.h:96
Ape media file.
Definition: taginfo.h:74
MPC media file.
Definition: taginfo.h:90
int bitrate
Bitrate.
Definition: taginfo.h:306
String genre
Genre of the Info object.
Definition: taginfo.h:267
String copyright
Copyright of the Info object.
Definition: taginfo.h:283
M4B media file.
Definition: taginfo.h:82
String original_artist
Original artist of the Info object.
Definition: taginfo.h:285
TagLib::FileRef * taglib_fileref
TagLib::FileRef of the media file
Definition: taginfo.h:251
S3m media file.
Definition: taginfo.h:114
int samplerate
Sample rate.
Definition: taginfo.h:308
String album_labels_string
User defined album labels as string with "|" as delimiter.
Definition: taginfo.h:329
WavPack media file.
Definition: taginfo.h:102
Mod media file.
Definition: taginfo.h:108
Ogg media file.
Definition: taginfo.h:94
int channels
Channel count.
Definition: taginfo.h:310
Xm media file.
Definition: taginfo.h:112
TagLib::List< Image * > ImageList
Definition: taginfo.h:62
Aiff media file.
Definition: taginfo.h:72
ulong changedflag
The setters for the tags on the info object will set these ChangedFlags flags.
Definition: taginfo.h:332
String artist
Artist of the Info object.
Definition: taginfo.h:269
int year
Year of the Info object.
Definition: taginfo.h:291
TagLib::Tag * taglib_tag
TagLib::Tag of the media file
Definition: taginfo.h:257
int volume_count
Volume count of the Info object.
Definition: taginfo.h:299
StringList track_labels
User defined track labels.
Definition: taginfo.h:319
int track_count
Track count of the Info object.
Definition: taginfo.h:289
Oga media file.
Definition: taginfo.h:92
String album_artist
Album artist of the Info object.
Definition: taginfo.h:271
String homepage
Homepage of the Info object.
Definition: taginfo.h:279
String encoder
Encoder of the Info object.
Definition: taginfo.h:281
Wave media file.
Definition: taginfo.h:98
Wma media file.
Definition: taginfo.h:100
bool is_compilation
Whether the media file is part of a compilation.
Definition: taginfo.h:293
StringList artist_labels
User defined artist labels.
Definition: taginfo.h:323
int rating
Rating (1 - 5 stars, 0 not set)
Definition: taginfo.h:316
A simple, generic interface to common audio meta data fields and media properties.
Definition: taginfo.h:125