Source

libtaginfo / bindings / c / taginfo_c.cc

  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
/*
 * 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 "taginfo.h"

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "taginfo_c.h"


using namespace TagInfo;
using namespace TagLib;


//*****************STRING MANAGEMENT*****************************************************
static List<char *> strings;
static bool stringManagementEnabled = false;

//! Enable string management for libtaginfo
void taginfo_info_enable_string_management(BOOL management) {
    stringManagementEnabled = bool(management);
}

//! Clean up used strings
//! To be used in case string management is used
void taginfo_info_free_strings() {
    if(!stringManagementEnabled)
        return;
    
    for(List<char *>::Iterator it = strings.begin(); it != strings.end(); ++it)
        free(*it);
    strings.clear();
}
//*****************/STRING MANAGEMENT****************************************************

static char **string_list_to_c_array(const StringList &list, int *out_length) {
    if(list.isEmpty()) {
        //cout << "list not there"  << endl;
        return NULL;
    }
    uint len = list.size();
    char **array = (char**)malloc(len * sizeof(char*));
    int j = 0;
    for(StringList::ConstIterator it = list.begin(); it != list.end(); ++it) {
        array[j] = ::strdup((*it).toCString(false));
        if(stringManagementEnabled && array[j])
            strings.prepend(array[j]);
        j++;
    }
    *out_length = len;
    return array;
}

static StringList string_list_from_c_array(const char* const* array, int length) {
    StringList list;
    for(int j = 0; j < length; j++) {
        if(array[j]) {
            list.append(array[j]);
        }
    }
    return list;
}


//*****************FACTORY CREATION******************************************************
/*!
 * Creates a TagInfo_Info object based on \a filename.  TagInfo will try to guess the file
 * type.
 *
 * \return NULL if the file type cannot be determined or the file cannot
 * be opened. The returned object should be freed with taginfo_info_free() after usage
 */
TagInfo_Info * taginfo_info_create(const char *filename) {
    return reinterpret_cast<TagInfo_Info *>(Info::create(filename));
}

/*!
 * Creates a TagInfo_Info object based on \a filename and TagInfo_MediaFileType
 *
 * \return NULL if the file type cannot be determined or the file cannot
 * be opened. The returned object should be freed with taginfo_info_free() after usage
 */
TagInfo_Info * taginfo_info_create_with_format(const char *filename,
                                                     TagInfo_MediaFileType media_file_type) {
    return reinterpret_cast<TagInfo_Info *>(Info::create_with_format(filename, 
                                                                              (MediaFileType)media_file_type)
    );
}

/*!
 * Creates a TagInfo_Info object based on \a filename and mimetype
 *
 * \return NULL if the file type cannot be determined or the file cannot
 * be opened. The returned object should be freed with taginfo_info_free() after usage
 */
TagInfo_Info * taginfo_info_create_from_mime(const char *filename, const char *mime_type) {
    return reinterpret_cast<TagInfo_Info *>(Info::create_from_mime(filename, 
                                                                            mime_type)
    );
}
//*****************/FACTORY CREATION*****************************************************


//*****************GENERAL MEMORY MANAGEMENT*********************************************
/*!
 * Frees a TagInfo_Info object.
 */
//! \param info A TagInfo_Info object
void taginfo_info_free(TagInfo_Info *info) {
    delete reinterpret_cast<Info *>(info);
}
//*****************/GENERAL MEMORY MANAGEMENT********************************************


//*****************TAG READ/WRITE API****************************************************
//! Load the tag information from the media file to the TagInfo_Info object
//! \param info A TagInfo_Info object
BOOL taginfo_info_load(TagInfo_Info *info) {
    Info *i = reinterpret_cast<Info *>(info);
    return i->load();
}
//! Save the tag information from the TagInfo_Info object to the media file.
//! \param info A TagInfo_Info object
BOOL taginfo_info_save(TagInfo_Info *info) {
    Info *i = reinterpret_cast<Info *>(info);
    return i->save();
}

//! Get the artist tag of a media track.
/*!
\return The artist as char *. In case the string management is not enabled, the caller should free this string
*/
//! \param info A TagInfo_Info object
char * taginfo_info_get_artist(const TagInfo_Info *info) {
    const Info *i = reinterpret_cast<const Info *>(info);
    String artist = i->get_artist();
    char *s = ::strdup(artist.toCString(true));
    if(stringManagementEnabled && s)
        strings.prepend(s);
    return s;
}
//! Set the artist tag of a media track.
//! \param info A TagInfo_Info object
/*!
\param artist Artist as const char *.
*/
void taginfo_info_set_artist(TagInfo_Info *info, const char *artist) {
    Info *i = reinterpret_cast<Info *>(info);
    i->set_artist(String(artist, String::UTF8));
}

//! Get the original artist of a media track.
//! \param info A TagInfo_Info object
/*!
\return The original artist as char *. In case the string management is not enabled, the caller should free this string
*/
char * taginfo_info_get_original_artist (const TagInfo_Info *info) {
    const Info *i = reinterpret_cast<const Info *>(info);
    String artist = i->get_original_artist ();
    char *s = ::strdup(artist.toCString(true));
    if(stringManagementEnabled && s)
        strings.prepend(s);
    return s;
}
//! Set the original artist of a media track.
//! \param info A TagInfo_Info object
/*!
\param original_artist Original artist as const char *.
*/
void taginfo_info_set_original_artist (TagInfo_Info *info, const char *artist) {
    Info *i = reinterpret_cast<Info *>(info);
    i->set_original_artist (String(artist, String::UTF8));
}

//! Get the album of a media track.
//! \param info A TagInfo_Info object
/*!
\return The album as char *. In case the string management is not enabled, the caller should free this string
*/
char * taginfo_info_get_album(const TagInfo_Info *info) {
    const Info *i = reinterpret_cast<const Info *>(info);
    String album = i->get_album();
    char *s = ::strdup(album.toCString(true));
    if(stringManagementEnabled && s)
        strings.prepend(s);
    return s;
}
//! Set the album of a media track.
//! \param info A TagInfo_Info object
/*!
\param album Album as const char *.
*/
void taginfo_info_set_album(TagInfo_Info *info, const char *album) {
    Info *i = reinterpret_cast<Info *>(info);
    i->set_album(String(album, String::UTF8));
}

//! Get the title of a media track.
//! \param info A TagInfo_Info object
/*!
\return The title as char *. In case the string management is not enabled, the caller should free this string
*/
char * taginfo_info_get_title(const TagInfo_Info *info) {
    const Info *i = reinterpret_cast<const Info *>(info);
    String title = i->get_title();
    char *s = ::strdup(title.toCString(true));
    if(stringManagementEnabled && s)
        strings.prepend(s);
    return s;
}
//! Set the title of a media track.
//! \param info A TagInfo_Info object
/*!
\param title Title as const char *.
*/
void taginfo_info_set_title(TagInfo_Info *info, const char *title) {
    Info *i = reinterpret_cast<Info *>(info);
    i->set_title(String(title, String::UTF8));
}

//! Get the albumartist tag of a media track.
//! \param info A TagInfo_Info object
/*!
\return The albumartist as char *. In case the string management is not enabled, the caller should free this string
*/
char * taginfo_info_get_albumartist(const TagInfo_Info *info) {
    const Info *i = reinterpret_cast<const Info *>(info);
    String album_artist = i->get_album_artist();
    char *s = ::strdup(album_artist.toCString(true));
    if(stringManagementEnabled && s)
        strings.prepend(s);
    return s;
}
//! Set the album artist tag of a media track.
//! \param info A TagInfo_Info object
/*!
\param albumartist Album artist as const char *.
*/
void taginfo_info_set_albumartist(TagInfo_Info *info, const char *albumartist) {
    Info *i = reinterpret_cast<Info *>(info);
    i->set_album_artist(String(albumartist, String::UTF8));
}

//! Get the comment tag of a media track.
//! \param info A TagInfo_Info object
/*!
\return The comment as char *. In case the string management is not enabled, the caller should free this string
*/
char * taginfo_info_get_comment(const TagInfo_Info *info) {
    const Info *i = reinterpret_cast<const Info *>(info);
    String comments = i->get_comments();
    char *s = ::strdup(comments.toCString(true));
    if(stringManagementEnabled && s)
        strings.prepend(s);
    return s;
}
//! Set the comment of a media track.
//! \param info A TagInfo_Info object
/*!
\param comment Comment as const char *.
*/
void taginfo_info_set_comment(TagInfo_Info *info, const char *comment) {
    Info *i = reinterpret_cast<Info *>(info);
    i->set_comments(String(comment, String::UTF8));
}

//! Get the composer tag of a media track.
//! \param info A TagInfo_Info object
/*!
\return The composer as char *. In case the string management is not enabled, the caller should free this string
*/
char * taginfo_info_get_composer(const TagInfo_Info *info) {
    const Info *i = reinterpret_cast<const Info *>(info);
    String composer = i->get_composer();
    char *s = ::strdup(composer.toCString(true));
    if(stringManagementEnabled && s)
        strings.prepend(s);
    return s;
}
//! Set the composer of a media track.
//! \param info A TagInfo_Info object
/*!
\param composer Composer as const char *.
*/
void taginfo_info_set_composer(TagInfo_Info *info, const char *composer) {
    Info *i = reinterpret_cast<Info *>(info);
    i->set_composer(String(composer, String::UTF8));
}

//! Get the homepage tag of a media track.
//! \param info A TagInfo_Info object
/*!
\return The homepage as char *. In case the string management is not enabled, the caller should free this string
*/
char * taginfo_info_get_homepage(const TagInfo_Info *info) {
    const Info *i = reinterpret_cast<const Info *>(info);
    String homepage = i->get_homepage();
    char *s = ::strdup(homepage.toCString(true));
    if(stringManagementEnabled && s)
        strings.prepend(s);
    return s;
}
//! Set the homepage tag of a media track.
//! \param info A TagInfo_Info object
/*!
\param homepage Homepage tag as const char *.
*/
void taginfo_info_set_homepage(TagInfo_Info *info, const char *homepage) {
    Info *i = reinterpret_cast<Info *>(info);
    i->set_homepage(String(homepage, String::UTF8));
}

//! Get the encoder tag of a media track.
//! \param info A TagInfo_Info object
/*!
\return The encoder as char *. In case the string management is not enabled, the caller should free this string
*/
char * taginfo_info_get_encoder(const TagInfo_Info *info) {
    const Info *i = reinterpret_cast<const Info *>(info);
    String encoder = i->get_encoder();
    char *s = ::strdup(encoder.toCString(true));
    if(stringManagementEnabled && s)
        strings.prepend(s);
    return s;
}
//! Set the encoder of a media track.
//! \param info A TagInfo_Info object
/*!
\param encoder Encoder tag as const char *.
*/
void taginfo_info_set_encoder(TagInfo_Info *info, const char *encoder) {
    Info *i = reinterpret_cast<Info *>(info);
    i->set_encoder(String(encoder, String::UTF8));
}

//! Get the copyright tag of a media track.
//! \param info A TagInfo_Info object
/*!
\return The copyright as char *. In case the string management is not enabled, the caller should free this string
*/
char * taginfo_info_get_copyright(const TagInfo_Info *info) {
    const Info *i = reinterpret_cast<const Info *>(info);
    String copyright = i->get_copyright();
    char *s = ::strdup(copyright.toCString(true));
    if(stringManagementEnabled && s)
        strings.prepend(s);
    return s;
}
//! Set the copyright tag of a media track.
//! \param info A TagInfo_Info object
/*!
\param copyright Copyright tag as const char *.
*/
void taginfo_info_set_copyright(TagInfo_Info *info, const char *copyright) {
    Info *i = reinterpret_cast<Info *>(info);
    i->set_copyright(String(copyright, String::UTF8));
}

//! Get the genre tag of a media track.
//! \param info A TagInfo_Info object
/*!
\return The genre as char *. In case the string management is not enabled, the caller should free this string
*/
char * taginfo_info_get_genre(const TagInfo_Info *info) {
    const Info *i = reinterpret_cast<const Info *>(info);
    String genre = i->get_genre();
    char *s = ::strdup(genre.toCString(true));
    if(stringManagementEnabled && s)
        strings.prepend(s);
    return s;
}
//! Set the genre tag of a media track.
//! \param info A TagInfo_Info object
/*!
\param genre Genre tag as const char *.
*/
void taginfo_info_set_genre(TagInfo_Info *info, const char *genre) {
    Info *i = reinterpret_cast<Info *>(info);
    i->set_genre(String(genre, String::UTF8));
}

//! Get the track number of a media track.
//! \param info A TagInfo_Info object
/*!
\return The track number as int.
*/
int taginfo_info_get_track_number(const TagInfo_Info *info) {
    const Info *i = reinterpret_cast<const Info *>(info);
    return i->get_track_number();
}
//! Set the track number tag of a media track.
//! \param info A TagInfo_Info object
/*!
\param track_number Track number tag as int.
*/
void taginfo_info_set_track_number(TagInfo_Info *info, int track_number) {
    Info *i = reinterpret_cast<Info *>(info);
    i->set_track_number(track_number);
}

//! Get the track count of a media track.
//! \param info A TagInfo_Info object
/*!
\return The track count as int.
*/
int taginfo_info_get_track_count(const TagInfo_Info *info) {
    const Info *i = reinterpret_cast<const Info *>(info);
    return i->get_track_count();
}
//! Set the track count tag of a media track.
//! \param info A TagInfo_Info object
/*!
\param track_count Track count tag as int.
*/
void taginfo_info_set_track_count(TagInfo_Info *info, int track_count) {
    Info *i = reinterpret_cast<Info *>(info);
    i->set_track_count(track_count);
}

//! Get the publishing year of a media track.
//! \param info A TagInfo_Info object
/*!
\return The year as int.
*/
int taginfo_info_get_year(const TagInfo_Info *info) {
    const Info *i = reinterpret_cast<const Info *>(info);
    return i->get_year();
}
//! Set the year tag of a media track.
//! \param info A TagInfo_Info object
/*!
\param year Year tag as int.
*/
void taginfo_info_set_year(TagInfo_Info *info, int year) {
    Info *i = reinterpret_cast<Info *>(info);
    i->set_year(year);
}

/*!
Get the bitrate audio property
\param info A TagInfo_Info object
\return The bitrate as int.
*/
int taginfo_info_get_bitrate(const TagInfo_Info *info) {
    const Info *i = reinterpret_cast<const Info *>(info);
    return i->get_bitrate();
}

/*!
Get the samplerate audio property
\param info A TagInfo_Info object
\return The samplerate as int.
*/
int taginfo_info_get_samplerate(const TagInfo_Info *info) {
    const Info *i = reinterpret_cast<const Info *>(info);
    return i->get_samplerate();
}

/*!
Get the channels audio property
\param info A TagInfo_Info object
\return The number of channels as int.
*/
int taginfo_info_get_channels(const TagInfo_Info *info) {
    const Info *i = reinterpret_cast<const Info *>(info);
    return i->get_channels();
}

/*!
Get the length audio property
\param info A TagInfo_Info object
\return The length in seconds as int.
*/
int taginfo_info_get_length(const TagInfo_Info *info) {
    const Info *i = reinterpret_cast<const Info *>(info);
    return i->get_length_seconds();
}

//! Get information on the availability of an image that is embedded in the media file.
/*!
\param info A TagInfo_Info object
\return TRUE if there is an image
*/
BOOL taginfo_info_get_has_image(const TagInfo_Info *info) {
    const Info *i = reinterpret_cast<const Info *>(info);
    //bool image_available = i->get_has_image();
    return i->get_has_image();
}

//! Get the volume number of a media track.
/*!
\param info A TagInfo_Info object
\return The volume number as int.
*/
int taginfo_info_get_volume_number(const TagInfo_Info *info) {
    const Info *i = reinterpret_cast<const Info *>(info);
    return i->get_volume_number();
}
//! Set the volume number tag of a media track.
/*!
\param info A TagInfo_Info object
\param number Volume number tag as int.
*/
void taginfo_info_set_volume_number(TagInfo_Info *info, int number) {
    Info *i = reinterpret_cast<Info *>(info);
    i->set_volume_number(number);
}

//! Get the volume count of a media track.
/*!
\param info A TagInfo_Info object
\return The volume_count as int.
*/
int taginfo_info_get_volume_count(const TagInfo_Info *info) {
    const Info *i = reinterpret_cast<const Info *>(info);
    return i->get_volume_count();
}
//! Set the volume count tag of a media track.
/*!
\param info A TagInfo_Info object
\param count Volume count tag as int.
*/
void taginfo_info_set_volume_count(TagInfo_Info *info, int count) {
    Info *i = reinterpret_cast<Info *>(info);
    i->set_volume_count(count);
}

//! Get the rating of a media track. rating 1 - 5; 0 -> not set
/*!
\param info A TagInfo_Info object
\return The rating as int.
*/
int taginfo_info_get_rating(const TagInfo_Info *info) {
    const Info *i = reinterpret_cast<const Info *>(info);
    return i->get_rating();
}
//! Set the rating tag of a media track. rating 1 - 5; 0 -> not set
/*!
\param info A TagInfo_Info object
\param rating Rating as int.
*/
void taginfo_info_set_rating(TagInfo_Info *info, int rating) {
    Info *i = reinterpret_cast<Info *>(info);
    i->set_rating(rating);
}

//! Get the play count of a media track.
/*!
\param info A TagInfo_Info object
\return The play count as int.
*/
int  taginfo_info_get_playcount(const TagInfo_Info *info) {
    const Info *i = reinterpret_cast<const Info *>(info);
    return i->get_playcount();
}
//! Set the play count tag of a media track.
/*!
\param info A TagInfo_Info object
\param count Play count tag as int.
*/
void taginfo_info_set_playcount(TagInfo_Info *info, int count) {
    Info *i = reinterpret_cast<Info *>(info);
    i->set_playcount(count);
}

//! Get the information if the media file is part of a compilation / VA album.
/*!
\param info A TagInfo_Info object
\return TRUE if it is part of a compilation
*/
BOOL taginfo_info_get_is_compilation(const TagInfo_Info *info) {
    const Info *i = reinterpret_cast<const Info *>(info);
    BOOL s = i->get_is_compilation();
    return s;
}
//! Set the information if the media file is part of a compilation / VA album.
/*!
\param info A TagInfo_Info object
\param is_compilation TRUE if it is part of a compilation
*/
void taginfo_info_set_is_compilation(TagInfo_Info *info, BOOL is_compilation) {
    Info *i = reinterpret_cast<Info *>(info);
    i->set_is_compilation((bool)is_compilation);
}

//! Get an array of user defined track labels.
/*!
\param info A TagInfo_Info object
\return Array of track labels
\param labels_length The return location for the length of the returned array.
*/
char **taginfo_info_get_track_labels(const TagInfo_Info *info,
                                     int *labels_length) {
    const Info *i = reinterpret_cast<const Info *>(info);
    StringList list = i->get_track_labels_list();
    return string_list_to_c_array(list, labels_length);
}
//! Set an array of user defined track labels.
/*!
\param info A TagInfo_Info object
\param labels An array of user defined track labels
\param labels_length The length of the array
*/
void taginfo_info_set_track_labels(TagInfo_Info *info,
                                   const char* const* labels, int labels_length) {
    Info *i = reinterpret_cast<Info *>(info);
    StringList list = string_list_from_c_array(labels, labels_length);
    i->set_track_labels_list(list);
}

//! Get an array of user defined album labels.
/*!
\param info A TagInfo_Info object
\return Array of album labels
\param labels_length The return location for the length of the returned array.
*/
char **taginfo_info_get_album_labels(const TagInfo_Info *info,
                                     int *labels_length) {
    const Info *i = reinterpret_cast<const Info *>(info);
    StringList list = i->get_album_labels_list();
    return string_list_to_c_array(list, labels_length);
}
//! Set an array of user defined album labels.
/*!
\param info A TagInfo_Info object
\param labels An array of user defined album labels
\param labels_length The length of the array
*/
void taginfo_info_set_album_labels(TagInfo_Info *info,
                                   const char* const* labels, int labels_length) {
    Info *i = reinterpret_cast<Info *>(info);
    StringList list = string_list_from_c_array(labels, labels_length);
    i->set_album_labels_list(list);
}

//! Get an array of user defined artist labels.
/*!
\param info A TagInfo_Info object
\return Array of artist labels
\param labels_length The return location for the length of the returned array.
*/
char** taginfo_info_get_artist_labels(const TagInfo_Info *info,
                                      int * labels_length) {
    const Info *i = reinterpret_cast<const Info *>(info);
    StringList list = i->get_artist_labels_list();
    return string_list_to_c_array(list, labels_length);
}
//! Set an array of user defined artist labels.
/*!
\param labels An array of user defined artist labels
\param labels_length The length of the array
*/
void taginfo_info_set_artist_labels(TagInfo_Info *info,
                                    const char* const* labels, int labels_length) {
    Info *i = reinterpret_cast<Info *>(info);
    StringList list = string_list_from_c_array(labels, labels_length);
    i->set_artist_labels_list(list);
}

//****************/TAG READ/WRITE API****************************************************


//*****************IMAGES****************************************************************
//! Get an array of images copied from the file embedded images.
/*!
\return Array of TagInfo_Image
\param info A TagInfo_Info object
\param image_count The return location for the length of the returned array.
*/
TagInfo_Image ** taginfo_info_get_images(const TagInfo_Info *info,
                             int *image_count) {
    const Info *i = reinterpret_cast<const Info *>(info);
    TagInfo_Image ** images = NULL;
    images = reinterpret_cast<TagInfo_Image **> (i->get_images((*image_count)));
    return images;
}
//! Set an array of TagInfo_Image to be embedded into the media file.
/*!
\param info A TagInfo_Info object
\param labels An array of TagInfo_Image
\param image_count The length of the TagInfo_Image array
*/
void taginfo_info_set_images(TagInfo_Info *info,
                             const TagInfo_Image ** images, const int image_count) {
    Info *i = reinterpret_cast<Info *>(info);
    const Image ** imgs = reinterpret_cast<const Image **>(images);
    i->set_images(imgs, image_count);
}

/*!
 * Frees a TagInfo_Image object.
 */
//!\param img A TagInfo_Image object
void taginfo_image_free(TagInfo_Image * img) {
    if(!img)
        return;
    Image *i = reinterpret_cast<Image *>(img);
    delete i;
    i = NULL;
}

/*!
 * Frees an array of TagInfo_Image as returned from taginfo_info_get_images()..
 */
//!\param img_arr An array of TagInfo_Image
void taginfo_image_array_free(TagInfo_Image ** img_arr) {
    if(!img_arr)
        return;
    for(TagInfo_Image ** it = img_arr; *it != NULL; it++) {
        taginfo_image_free(*it);
    }
    img_arr = NULL;
}
//*****************/IMAGES***************************************************************


//*****************LYRICS****************************************************************
//! Get a lyrics string from the media file.
/*!
\return Lyrics string
*/
//! \param info A TagInfo_Info object
char * taginfo_info_get_lyrics(const TagInfo_Info *info) {
    const Info *i = reinterpret_cast<const Info *>(info);
    String lyrics = i->get_lyrics();
    char *s = ::strdup(lyrics.toCString(true));
    if(stringManagementEnabled && s)
        strings.prepend(s);
    return s;
}

//! Set a lyrics string to the media file.
/*!
\param lyrics Lyrics string
*/
//! \param info A TagInfo_Info object
BOOL taginfo_info_set_lyrics(TagInfo_Info *info, const char * lyrics) {
    Info *i = reinterpret_cast<Info *>(info);
    return i->set_lyrics(String(lyrics, String::UTF8));
}
//*****************/LYRICS***************************************************************