Source

libtaginfo / libtaginfo / info.cc

Full commit
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
/*
 * Copyright (C) 2008-2013 J.Rios <anonbeat@gmail.com>
 * Copyright (C) 2013 Jörn Magens
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This Program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; see the file LICENSE.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth 
 * Floor, Boston, MA  02110-1301  USA
 * https://www.gnu.org/licenses/lgpl-2.1.txt
 *
 * Author:
 * 	Jörn Magens <shuerhaaken@googlemail.com>
 * 	Matias De lellis <mati86dl@gmail.com>
 * 	Pavel Vasin <rat4vier@gmail.com>
 */


#include <algorithm>
#include "taginfo.h"
#include "taginfo_internal.h"

#include "taginfo_apetags.h"
#include "taginfo_asftags.h"
#include "taginfo_modtags.h"
#include "taginfo_mp4tags.h"
#include "taginfo_id3tags.h"
#include "taginfo_xiphtags.h"



using namespace TagInfo;

/*!
 * Create a Info from \a file. If \a format is given, libtaginfo will try to create 
 * an Info object for the desired \a format.
 * This is a recommended way for accessing media tags through libtaginfo.
 * create_tag_info_with_format() will return a matching Info subclass
 * \return the according Info subclass
 * \param file is the path to a media file.
 * \param format is the MediaFileType.
 */
Info * Info::create_tag_info_with_format(const String &filename, MediaFileType format) {
    Info * info = NULL;
    switch(format) {
        case  MEDIA_FILE_TYPE_UNKNOWN :
            break;
        case  MEDIA_FILE_TYPE_MP3 :
            info = new Mp3Info(filename);
            break;
        case  MEDIA_FILE_TYPE_FLAC :
            info = new FlacInfo(filename);
            break;
        case  MEDIA_FILE_TYPE_OGG :
        case  MEDIA_FILE_TYPE_OGA :
            info = new OggInfo(filename);
            break;
        case  MEDIA_FILE_TYPE_MP4 :
        case  MEDIA_FILE_TYPE_M4A :
        case  MEDIA_FILE_TYPE_M4B :
        case  MEDIA_FILE_TYPE_M4P :
        case  MEDIA_FILE_TYPE_AAC : 
            info = new Mp4Info(filename);
            break;
        case  MEDIA_FILE_TYPE_WMA :
        case  MEDIA_FILE_TYPE_WMV :
        case  MEDIA_FILE_TYPE_ASF :
            info = new AsfInfo(filename);
            break;
        case MEDIA_FILE_TYPE_APE :
            info = new ApeInfo(filename);
            break;
        case MEDIA_FILE_TYPE_WAV :
            info = new WaveInfo(filename);
            break;
        case MEDIA_FILE_TYPE_AIF :
            info = new AiffInfo(filename);
            break;
        case MEDIA_FILE_TYPE_WV : 
            info = new WavPackInfo(filename);
            break;
        case MEDIA_FILE_TYPE_TTA :
            info = new TrueAudioInfo(filename);
            break;
        case MEDIA_FILE_TYPE_MPC :
            info = new MpcInfo(filename);
            break;
        case MEDIA_FILE_TYPE_SPEEX :
            info = new SpeexInfo(filename);
            break;
        case MEDIA_FILE_TYPE_MOD :
            info = new ModInfo(filename);
            break;
        case MEDIA_FILE_TYPE_S3M :
            info = new S3mInfo(filename);
            break;
        case MEDIA_FILE_TYPE_IT :
            info = new ItInfo(filename);
            break;
        case MEDIA_FILE_TYPE_XM :
            info = new XmInfo(filename);
            break;
        default :
            break;
    }
    if(!info || !info->is_valid()) {
        std::cout << "NOT valid OR unrecognized: " << filename << std::endl;
        return NULL;
    }
    return info;
}

/*!
 * Create a Info object from a media file.
 *
 * This is a recommended way for accessing media tags through libtaginfo.
 * create_tag_info() will return a matching Info subclass
 * \return the according Info subclass
 * \param file is the path to a media file.
 *
 * This function will make use of the file extension to find out the media type
 */
Info * Info::create_tag_info(const String &filename) {
    MediaFileType format = MEDIA_FILE_TYPE_UNKNOWN;
    String fnex = filename.substr(filename.rfind(".") + 1);
    fnex = fnex.upper();
    
    if(fnex == "MP3")
        format = MEDIA_FILE_TYPE_MP3; 
    else if(fnex == "OGG")
        format = MEDIA_FILE_TYPE_OGG; 
    else if(fnex == "FLAC")
        format = MEDIA_FILE_TYPE_FLAC; 
    else if(fnex == "WMA")
        format = MEDIA_FILE_TYPE_WMA; 
    else if(fnex == "WAV")
        format = MEDIA_FILE_TYPE_WAV; 
    else if(fnex == "APE")
        format = MEDIA_FILE_TYPE_APE; 
    else if(fnex == "OGA")
        format = MEDIA_FILE_TYPE_OGA; 
    else if(fnex == "MP4")
        format = MEDIA_FILE_TYPE_MP4; 
    else if(fnex == "ASF")
        format = MEDIA_FILE_TYPE_ASF; 
    else if(fnex == "M4A")
        format = MEDIA_FILE_TYPE_M4A; 
    else if(fnex == "M4B")
        format = MEDIA_FILE_TYPE_M4B; 
    else if(fnex == "M4P")
        format = MEDIA_FILE_TYPE_M4P; 
    else if(fnex == "AAC")
        format = MEDIA_FILE_TYPE_AAC; 
    else if(fnex == "AIF")
        format = MEDIA_FILE_TYPE_AIF; 
    else if(fnex == "AIFF")
        format = MEDIA_FILE_TYPE_AIF; 
    else if(fnex == "WV")
        format = MEDIA_FILE_TYPE_WV; 
    else if(fnex == "TTA")
        format = MEDIA_FILE_TYPE_TTA; 
    else if(fnex == "MPC")
        format = MEDIA_FILE_TYPE_MPC; 
    else if(fnex == "SPX")
        format = MEDIA_FILE_TYPE_SPEEX; 
    else if(fnex == "WMV")
        format = MEDIA_FILE_TYPE_WMV; 
    else if(fnex == "MOD")
        format = MEDIA_FILE_TYPE_MOD; 
    else if(fnex == "IT")
        format = MEDIA_FILE_TYPE_IT; 
    else if(fnex == "S3M")
        format = MEDIA_FILE_TYPE_S3M; 
    else if(fnex == "XM")
        format = MEDIA_FILE_TYPE_XM; 
    
    return Info::create_tag_info_with_format(filename, format);
}

/*!
 * Create a Info from \param filename . If \param mime_type is given, libtaginfo 
 * will try to create an Info object for the desired mime_type.
 * This is a recommended way for accessing media tags through libtaginfo.
 * create_tag_info_from_mime() will return a matching Info subclass
 * \return the according Info subclass
 * \param filename is the path to a media file.
 * \param mime_type is the mime type of the media file (e.g. "audio/x-vorbis+ogg") 
 * as TagLib::String.
 */
Info * Info::create_tag_info_from_mime(const String &filename, const String &mime_type) {
    MediaFileType format = MEDIA_FILE_TYPE_UNKNOWN;
    String mime = mime_type;
    
    if(mime == "audio/mpeg" || mime == "audio/x-mpegurl")
        format = MEDIA_FILE_TYPE_MP3; 
    else if(mime == "audio/x-vorbis+ogg" || mime == "audio/ogg")
        format = MEDIA_FILE_TYPE_OGG; 
    else if(mime == "audio/flac" || mime == "audio/x-flac+ogg" || mime == "audio/x-flac")
        format = MEDIA_FILE_TYPE_FLAC; 
    else if(mime == "audio/x-ms-wma")
        format = MEDIA_FILE_TYPE_WMA; 
    else if(mime == "video/x-ms-wmv" || mime == "video/x-msvideo")
        format = MEDIA_FILE_TYPE_WMV; 
    else if(mime == "audio/x-spx" || mime == "audio/x-speex" || mime == "audio/x-speex+ogg")
        format = MEDIA_FILE_TYPE_SPEEX;
    else if(mime == "audio/mp4" || mime == "video/mp4")
        format = MEDIA_FILE_TYPE_MP4; 
    else if(mime == "audio/mp4a-latm" || mime == "audio/x-m4a")
        format = MEDIA_FILE_TYPE_M4A; 
    else if(mime == "audio/m4b")
        format = MEDIA_FILE_TYPE_M4B; 
    else if(mime == "audio/x-m4p")
        format = MEDIA_FILE_TYPE_M4P; 
    else if(mime == "audio/aac" || mime == "audio/x-aac" || mime == "audio/x-aac")
        format = MEDIA_FILE_TYPE_AAC; 
    else if(mime == "audio/x-ms-asf" || mime == "video/x-ms-asf")
        format = MEDIA_FILE_TYPE_ASF; 
    else if(mime == "audio/x-wav")
        format = MEDIA_FILE_TYPE_WAV; 
    else if(mime == "audio/ape")
        format = MEDIA_FILE_TYPE_APE; 
    else if(mime == "audio/x-aiff")
        format = MEDIA_FILE_TYPE_AIF; 
    else if(mime == "application/x-wavpack" || mime == "audio/wavpack" || mime == "audio/x-wavpack")
        format = MEDIA_FILE_TYPE_WV; 
    else if(mime == "audio/x-mod")
        format = MEDIA_FILE_TYPE_MOD; 
    else if(mime == "audio/x-it")
        format = MEDIA_FILE_TYPE_IT; 
    else if(mime == "audio/x-s3m")
        format = MEDIA_FILE_TYPE_S3M; 
    else if(mime == "audio/x-xm")
        format = MEDIA_FILE_TYPE_XM; 
    else if(mime == "audio/mpc" || mime == "audio/x-musepack")
        format = MEDIA_FILE_TYPE_MPC; 
    else if(mime == "audio/tta" || mime == "audio/x-tta")
        format = MEDIA_FILE_TYPE_TTA; 
    
    
    return Info::create_tag_info_with_format(filename, format);
}


// Info

Info::Info(const String &filename) {
    
    taglib_fileref  = NULL;
    taglib_file     = NULL;
    taglib_tag      = NULL;
    
    file_name       = filename;
    artist          = String::null;
    title           = String::null;
    album_artist    = String::null;
    album           = String::null;
    genre           = String::null;
    composer        = String::null;
    comments        = String::null;
    homepage        = String::null;
    encoder         = String::null;
    copyright       = String::null;
    original_artist = String::null;
    
    track_number    = 0;
    track_count     = 0;
    volume_number   = 0;
    volume_count    = 0;
    year            = 0;
    length_seconds  = 0;
    bitrate         = 0;
    rating          = 0;
    playcount       = 0;
    
    is_compilation  = false;
    has_image       = false;
    
    valid           = true;
    changedflag     = CHANGED_DATA_NONE;
}


Info::~Info() {
    if(taglib_fileref)
        delete taglib_fileref;
    if(taglib_file)
        delete taglib_file;
}


bool Info::is_valid() {
    return valid;
}


bool Info::setup_file_ref() {
    return false;
}


void Info::load_base_tags(TagLib::Tag * tag) {
    if(tag) {
        title        = tag->title();
        artist       = tag->artist();
        album        = tag->album();
        genre        = tag->genre();
        comments     = tag->comment();
        track_number = tag->track();
        year         = tag->year();
    }
}


bool Info::load(void) {
    AudioProperties * properties;
    if(taglib_tag) {
        load_base_tags(taglib_tag);
    }
    
    if(taglib_file && 
       (properties = taglib_file->audioProperties())) {
        length_seconds = properties->length();
        bitrate        = properties->bitrate();
        samplerate     = properties->sampleRate();
        channels       = properties->channels();
        return true;
    }
    else if(taglib_fileref && 
            (properties = taglib_fileref->audioProperties())) {
        length_seconds = properties->length();
        bitrate        = properties->bitrate();
        samplerate     = properties->sampleRate();
        channels       = properties->channels();
        return true;
    }
    printf("Problem with Info::load for %s\n", file_name.toCString(false));
    return false;
}


void Info::save_base_tags(TagLib::Tag * tag) {
    if(changedflag & CHANGED_TITLE_TAG)
        tag->setTitle(title);
    if(changedflag & CHANGED_ARTIST_TAG)
        tag->setArtist(artist);
    if(changedflag & CHANGED_ALBUM_TAG)
        tag->setAlbum(album);
    if(changedflag & CHANGED_GENRE_TAG)
        tag->setGenre(genre);
    if(changedflag & CHANGED_COMMENT_TAG)
        tag->setComment(comments);
    if(changedflag & CHANGED_TRACK_NUMBER)
        tag->setTrack(track_number);
    if(changedflag & CHANGED_YEAR_TAG)
        tag->setYear(year);
}


bool Info::save() {
    if(taglib_tag && changedflag)
        save_base_tags(taglib_tag);
    
    if(!taglib_file->save())
      return false;
    
    return true;
}


//Tag access functions

//! Set the title tag.
//! This function will set the according ChangedData flag
//! This will not be saved to file before save() is called on the Info object.
/*!
\param new_title is a TagLib::String.
*/
void Info::set_title(const String new_title) {
    title = new_title;
    changedflag |= CHANGED_TITLE_TAG;
}
//! Get the title of a media track.
/*!
\return The title as %TagLib::String
*/
String Info::get_title() const {
    if(String::null != title)
        return title;
    else
        return String();
}


/*!
 * Set the genre tag.
 */
//! This function will set the according ChangedData flag
//! This will not be saved to file before save() is called on the Info object.
void Info::set_genre(const String new_genre) {
    genre = new_genre;
    changedflag |= CHANGED_GENRE_TAG;
}
//! Get the genre of a media track.
/*!
\return The genre as TagLib::String
*/
String Info::get_genre() const {
    if(String::null != genre)
        return genre;
    else
        return String();
}


//! Set volume number of a media track. (like CD 2 of 3)
//! This function will set the according ChangedData flag
//! This will not be saved to file before save() is called on the Info object.
/*!
\param number as int
*/
void Info::set_volume_number(const int number) {
    volume_number = number;
    if(volume_number < 0)
        volume_number = 0;
    changedflag |= CHANGED_DATA_VOL_NUM;
}
//! Get volume number of a media track. (like CD 2 of 3)
/*!
\return The volume number as int
*/
int Info::get_volume_number() const {
    return volume_number;
}

//! Set volume count of a media track. (like CD 2 of 3)
//! This function will set the according ChangedData flag
//! This will not be saved to file before save() is called on the Info object.
/*!
\param count as int
*/
void Info::set_volume_count(const int count) {
    volume_count = count;
    if(volume_count < 0)
        volume_count = 0;
    changedflag |= CHANGED_DATA_VOL_CNT;
}
//! Get volume count of a media track. (like CD 2 of 3)
/*!
\return The volume count as int
*/
int Info::get_volume_count() const {
    return volume_count;
}

//! Set the artist tag of a media track.
//! This function will set the according ChangedData flag
//! This will not be saved to file before save() is called on the Info object.
/*!
\param new_artist as TagLib::String
*/
void Info::set_artist(const String new_artist) {
    artist = new_artist;
    changedflag |= CHANGED_ARTIST_TAG;
}
//! Get the artist tag of a media track.
/*!
\return The artist tag as TagLib::String
*/
String Info::get_artist() const {
    if(String::null != artist)
        return artist;
    else
        return String();
}

//! Set the original artist tag of a media track.
//! For some implementations this is the performer tag 
//! This function will set the according ChangedData flag
//! This will not be saved to file before save() is called on the Info object.
/*!
\param new_artist as TagLib::String
*/
void Info::set_original_artist (const String new_artist) {
    original_artist = new_artist;
    changedflag |= CHANGED_ORIGINALARTIST_TAG;
}
//! Get the original artist tag of a media track.
/*!
\return The original artist tag as TagLib::String
*/
String Info::get_original_artist() const {
    if(String::null != original_artist)
        return original_artist;
    else
        return String();
}

//! Set the encoder tag of a media track.
//! This function will set the according ChangedData flag
//! This will not be saved to file before save() is called on the Info object.
/*!
\param new_encoder as TagLib::String
*/
void Info::set_encoder(const String new_encoder) {
    encoder = new_encoder;
    changedflag |= CHANGED_ENCODER_TAG;
}
//! Get the encoder tag of a media track.
/*!
\return The encoder tag as TagLib::String
*/
String Info::get_encoder() const {
    if(String::null != encoder)
        return encoder;
    else
        return String();
}

//! Set the homepage tag of a media track.
//! This function will set the according ChangedData flag
//! This will not be saved to file before save() is called on the Info object.
/*!
\param new_homepage as TagLib::String
*/
void Info::set_homepage(const String new_homepage) {
    homepage = new_homepage;
    changedflag |= CHANGED_HOMEPAGE_TAG;
}
//! Get the homepage tag of a media track.
/*!
\return The homepage tag as TagLib::String
*/
String Info::get_homepage() const {
    if(String::null != homepage)
        return homepage;
    else
        return String();
}

//! Set the copyright tag of a media track.
//! This function will set the according ChangedData flag
//! This will not be saved to file before save() is called on the Info object.
/*!
\param new_copyright as TagLib::String
*/
void Info::set_copyright(const String new_copyright) {
    copyright = new_copyright;
    changedflag |= CHANGED_COPYRIGHT_TAG;
}
//! Get the copyright tag of a media track.
/*!
\return The copyright tag as TagLib::String
*/
String Info::get_copyright() const {
    if(String::null != copyright)
        return copyright;
    else
        return String();
}

//! Set wether the media file is part of a compilation/various artists album, or not.
//! This function will set the according ChangedData flag
//! This will not be saved to file before save() is called on the Info object.
void Info::set_is_compilation(bool compilation) {
    is_compilation = compilation;
    changedflag |= CHANGED_IS_COMPILATION_TAG;
}
//! Get wether the media file is part of a compilation/various artists album, or not.
bool Info::get_is_compilation() const {
    return is_compilation;
}

//! Set the album artist tag of a media track.
//! This function will set the according ChangedData flag
//! This will not be saved to file before save() is called on the Info object.
/*!
\param new_artist as TagLib::String
*/
void Info::set_album_artist(const String new_album_artist) {
    album_artist = new_album_artist;
    changedflag |= CHANGED_DATA_ALBUMARTIST;
}
//! Get the album artist tag of a media track.
/*!
\return The album artist tag as TagLib::String
*/
String Info::get_album_artist() const {
    if(String::null != album_artist)
        return album_artist;
    else
        return String();
}

//! Set the album tag of a media track.
//! This function will set the according ChangedData flag
//! This will not be saved to file before save() is called on the Info object.
/*!
\param new_album as TagLib::String
*/
void Info::set_album(const String new_album) {
    album = new_album;
    changedflag |= CHANGED_ALBUM_TAG;
}
//! Get the album tag of a media track.
/*!
\return The album tag as TagLib::String
*/
String Info::get_album() const {
    if(String::null != album)
        return album;
    else
        return String();
}

//! Set the composer tag of a media track.
//! This function will set the according ChangedData flag
//! This will not be saved to file before save() is called on the Info object.
/*!
\param new_composer as TagLib::String
*/
void Info::set_composer(const String new_composer) {
    composer = new_composer;
    changedflag |= CHANGED_COMPOSER_TAG;
}
//! Get the composer tag of a media track.
/*!
\return The composer tag as TagLib::String
*/
String Info::get_composer() const {
    if(String::null != composer)
        return composer;
    else
        return String();
}

//! Set the comments tag of a media track.
//! This function will set the according ChangedData flag
//! This will not be saved to file before save() is called on the Info object.
/*!
\param new_comments as TagLib::String
*/
void Info::set_comments(const String new_comments) {
    comments = new_comments.stripWhiteSpace();
    changedflag |= CHANGED_COMMENT_TAG;
}
//! Get the comments tag of a media track.
/*!
\return The comments tag as TagLib::String
*/
String Info::get_comments(void) const {
    if(String::null != comments)
        return comments.stripWhiteSpace();
    else
        return String();
}

//! Set the track number of a media track.
//! This function will set the according ChangedData flag
//! This will not be saved to file before save() is called on the Info object.
/*!
\param new_track_number as int
*/
void Info::set_track_number(const int new_track_number) {
    track_number = new_track_number;
    changedflag |= CHANGED_TRACK_NUMBER;
}
//! Get the track_number tag of a media track.
/*!
\return The track_number tag as int
*/
int Info::get_track_number() const {
    return track_number;
}

//! Set the track count of a media track.
//! This is the amount of tracks of the album the media file was taken from.
//! This function will set the according ChangedData flag
//! This will not be saved to file before save() is called on the Info object.
/*!
\param new_track_count as int
*/
void Info::set_track_count(const int new_track_count) {
    track_count = new_track_count;
    changedflag |= CHANGED_TRACK_COUNT;
}
//! Get the track_count tag of a media track.
//! This is the amount of tracks of the album the media file was taken from.
/*!
\return The track_count tag as int
*/
int Info::get_track_count() const {
    return track_count;
}

//! Set the year of a media track.
//! This function will set the according ChangedData flag
//! This will not be saved to file before save() is called on the Info object.
/*!
\param new_year as int
*/
void Info::set_year(const int new_year) {
    year = new_year;
    changedflag |= CHANGED_YEAR_TAG;
}
//! Get the year tag of a media track.
/*!
\return The year tag as int
*/
int Info::get_year() const {
    return year;
}

//! Get the number of channels of the media file.
int Info::get_channels() const {
    return channels;
}

//! Get the bitrate of the media file.
int Info::get_bitrate() const {
    return bitrate;
}

//! Get the samplerate of the media file.
int Info::get_samplerate() const {
    return samplerate;
}

//! Get the length of the media file in seconds.
int Info::get_length_seconds() const {
    return length_seconds;
}

//! Get the playcount tag of a media track.
/*!
\return The playcount tag as int
*/
int  Info::get_playcount() const {
    return playcount;
}
//! Set the playcount tag of a media track.
//! Some implementations may not support this tag
//! This function will set the according ChangedData flag
//! This will not be saved to file before save() is called on the Info object.
/*!
\param new_playcount as int
*/
void Info::set_playcount(const int new_playcount) {
    changedflag |= CHANGED_DATA_PLAYCOUNT;
    playcount = new_playcount;
    if(playcount < 0)
        playcount = 0;
}

//! Get the rating tag of a media track.
//! rating 1 - 5 ;  0 -> not set
/*!
\return The rating tag as int
*/
int  Info::get_rating() const {
    return rating;
}
//! Set the rating tag of a media track.
//! rating 1 - 5 ;  0 -> not set
//! This function will set the according ChangedData flag
//! This will not be saved to file before save() is called on the Info object.
/*!
\param new_rating as integer
*/
void Info::set_rating(const int new_rating) {
    changedflag |= CHANGED_DATA_RATING;
    rating = new_rating;
    if(rating < 0)
        rating = 0;
}

//! Set a list of embedded track labels.
//! This function will set the according ChangedData flag
//! This will not be saved to file before save() is called on the Info object.
void Info::set_track_labels_list(const StringList &new_track_labels_list) {
    track_labels = new_track_labels_list;
    track_labels_string = new_track_labels_list.toString("|");
    changedflag |= CHANGED_TRACK_LABELS;
}
//! Get a list of embedded track labels.
StringList Info::get_track_labels_list() const {
    return track_labels;
}

//! Set a list of embedded artist labels.
//! This function will set the according ChangedData flag
//! This will not be saved to file before save() is called on the Info object.
void Info::set_artist_labels_list(const StringList &new_artist_labels_list) {
    artist_labels = new_artist_labels_list;
    artist_labels_string = new_artist_labels_list.toString("|");
    changedflag |= CHANGED_ARTIST_LABELS;
}
//! Get a list of embedded artist labels.
StringList Info::get_artist_labels_list() const {
    return artist_labels;
}

//! Set a list of embedded album labels.
//! This function will set the according ChangedData flag
//! This will not be saved to file before save() is called on the Info object.
void Info::set_album_labels_list(const StringList &new_album_labels_list) {
    album_labels = new_album_labels_list;
    album_labels_string = new_album_labels_list.toString("|");
    changedflag |= CHANGED_ALBUM_LABELS;
}
//! Get a list of embedded album labels.
StringList Info::get_album_labels_list() const {
    return album_labels;
}

//! Get information on the availability of an image
/*!
 * This information is just a quick lookup if something is there.
\return true if there is image data
*/
bool Info::get_has_image() const {
    return has_image;
}

//! Get an array of images from the Info object.
//! After this function was called, \param image_count will 
//! hold the number of images in the returend array.
//! The ownership of the images is on the caller side. You have
//! to destroy all the images in the retured array 
//! \return Array of Image
Image ** Info::get_images(int &image_count) const {
    return NULL;
}
//! Set an array of Image to the Info object.
//! The ownership of the images remains on the caller side.
//! \param images is an array of Image. Will overwrite any other Image in the
//! Info object 
//! \param image_count shall be the lenght of the image array.
void Info::set_images(const Image ** images, const int image_count) {
}

//! Get an embedded Lyrics String from the Info object.
//! \return String with lyrics
String Info::get_lyrics() const {
    return String();
}
//! Set an embedded Lyrics String to be saved to Info object.
bool Info::set_lyrics(const String &lyrics) {
    return false;
}