| 1 | /*************************************************************************** |
| 2 | copyright : (C) 2003 by Scott Wheeler |
| 3 | email : [email protected] |
| 4 | ***************************************************************************/ |
| 5 | |
| 6 | /*************************************************************************** |
| 7 | * This library is free software; you can redistribute it and/or modify * |
| 8 | * it under the terms of the GNU Lesser General Public License version * |
| 9 | * 2.1 as published by the Free Software Foundation. * |
| 10 | * * |
| 11 | * This library is distributed in the hope that it will be useful, but * |
| 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * |
| 14 | * Lesser General Public License for more details. * |
| 15 | * * |
| 16 | * You should have received a copy of the GNU Lesser General Public * |
| 17 | * License along with this library; if not, write to the Free Software * |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * |
| 19 | * USA * |
| 20 | ***************************************************************************/ |
| 21 | |
| 22 | #ifndef TAGLIB_TAG_C |
| 23 | #define TAGLIB_TAG_C |
| 24 | |
| 25 | /* Do not include this in the main TagLib documentation. */ |
| 26 | #ifndef DO_NOT_DOCUMENT |
| 27 | |
| 28 | #ifdef __cplusplus |
| 29 | extern "C" { |
| 30 | #endif |
| 31 | |
| 32 | #if defined(TAGLIB_STATIC) |
| 33 | #define TAGLIB_C_EXPORT |
| 34 | #elif defined(_WIN32) || defined(_WIN64) |
| 35 | #ifdef MAKE_TAGLIB_C_LIB |
| 36 | #define TAGLIB_C_EXPORT __declspec(dllexport) |
| 37 | #else |
| 38 | #define TAGLIB_C_EXPORT __declspec(dllimport) |
| 39 | #endif |
| 40 | #elif defined(__GNUC__) && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 1) |
| 41 | #define TAGLIB_C_EXPORT __attribute__ ((visibility("default"))) |
| 42 | #else |
| 43 | #define TAGLIB_C_EXPORT |
| 44 | #endif |
| 45 | |
| 46 | #include <wchar.h> |
| 47 | #ifdef _MSC_VER |
| 48 | /* minwindef.h contains typedef int BOOL */ |
| 49 | #include <windows.h> |
| 50 | #elif !defined BOOL |
| 51 | #define BOOL int |
| 52 | #endif |
| 53 | |
| 54 | /******************************************************************************* |
| 55 | * [ TagLib C Binding ] |
| 56 | * |
| 57 | * This is an interface to TagLib's "simple" API, meaning that you can read and |
| 58 | * modify media files in a generic, but not specialized way. This is a rough |
| 59 | * representation of TagLib::File and TagLib::Tag, for which the documentation |
| 60 | * is somewhat more complete and worth consulting. |
| 61 | *******************************************************************************/ |
| 62 | |
| 63 | /* |
| 64 | * These are used to give the C API some type safety (as opposed to |
| 65 | * using void * ), but pointers to them are simply cast to the corresponding C++ |
| 66 | * types in the implementation. |
| 67 | */ |
| 68 | |
| 69 | typedef struct { int dummy; } TagLib_File; |
| 70 | typedef struct { int dummy; } TagLib_Tag; |
| 71 | typedef struct { int dummy; } TagLib_AudioProperties; |
| 72 | typedef struct { int dummy; } TagLib_IOStream; |
| 73 | |
| 74 | /*! |
| 75 | * By default all strings coming into or out of TagLib's C API are in UTF8. |
| 76 | * However, it may be desirable for TagLib to operate on Latin1 (ISO-8859-1) |
| 77 | * strings in which case this should be set to FALSE. |
| 78 | */ |
| 79 | TAGLIB_C_EXPORT void taglib_set_strings_unicode(BOOL unicode); |
| 80 | |
| 81 | /*! |
| 82 | * TagLib can keep track of strings that are created when outputting tag values |
| 83 | * and clear them using taglib_tag_clear_strings(). This is enabled by default. |
| 84 | * However if you wish to do more fine grained management of strings, you can do |
| 85 | * so by setting \a management to FALSE. |
| 86 | */ |
| 87 | TAGLIB_C_EXPORT void taglib_set_string_management_enabled(BOOL management); |
| 88 | |
| 89 | /*! |
| 90 | * Explicitly free a string returned from TagLib |
| 91 | */ |
| 92 | TAGLIB_C_EXPORT void taglib_free(void* pointer); |
| 93 | |
| 94 | /******************************************************************************* |
| 95 | * Stream API |
| 96 | ******************************************************************************/ |
| 97 | |
| 98 | /*! |
| 99 | * Creates a byte vector stream from \a size bytes of \a data. |
| 100 | * Such a stream can be used with taglib_file_new_iostream() to create a file |
| 101 | * from memory. |
| 102 | */ |
| 103 | TAGLIB_C_EXPORT TagLib_IOStream *taglib_memory_iostream_new(const char *data, unsigned int size); |
| 104 | |
| 105 | /*! |
| 106 | * Frees and closes the stream. |
| 107 | */ |
| 108 | TAGLIB_C_EXPORT void taglib_iostream_free(TagLib_IOStream *stream); |
| 109 | |
| 110 | /******************************************************************************* |
| 111 | * File API |
| 112 | ******************************************************************************/ |
| 113 | |
| 114 | typedef enum { |
| 115 | TagLib_File_MPEG, |
| 116 | TagLib_File_OggVorbis, |
| 117 | TagLib_File_FLAC, |
| 118 | TagLib_File_MPC, |
| 119 | TagLib_File_OggFlac, |
| 120 | TagLib_File_WavPack, |
| 121 | TagLib_File_Speex, |
| 122 | TagLib_File_TrueAudio, |
| 123 | TagLib_File_MP4, |
| 124 | TagLib_File_ASF, |
| 125 | TagLib_File_AIFF, |
| 126 | TagLib_File_WAV, |
| 127 | TagLib_File_APE, |
| 128 | TagLib_File_IT, |
| 129 | TagLib_File_Mod, |
| 130 | TagLib_File_S3M, |
| 131 | TagLib_File_XM, |
| 132 | TagLib_File_Opus, |
| 133 | TagLib_File_DSF, |
| 134 | TagLib_File_DSDIFF, |
| 135 | TagLib_File_SHORTEN, |
| 136 | TagLib_File_MATROSKA |
| 137 | } TagLib_File_Type; |
| 138 | |
| 139 | /*! |
| 140 | * Creates a TagLib file based on \a filename. TagLib will try to guess the file |
| 141 | * type. |
| 142 | * |
| 143 | * \returns NULL if the file type cannot be determined or the file cannot |
| 144 | * be opened. |
| 145 | */ |
| 146 | TAGLIB_C_EXPORT TagLib_File *taglib_file_new(const char *filename); |
| 147 | #ifdef _WIN32 |
| 148 | TAGLIB_C_EXPORT TagLib_File *taglib_file_new_wchar(const wchar_t *filename); |
| 149 | #endif |
| 150 | |
| 151 | /*! |
| 152 | * Creates a TagLib file based on \a filename. Rather than attempting to guess |
| 153 | * the type, it will use the one specified by \a type. |
| 154 | */ |
| 155 | TAGLIB_C_EXPORT TagLib_File *taglib_file_new_type(const char *filename, TagLib_File_Type type); |
| 156 | #ifdef _WIN32 |
| 157 | TAGLIB_C_EXPORT TagLib_File *taglib_file_new_type_wchar(const wchar_t *filename, TagLib_File_Type type); |
| 158 | #endif |
| 159 | |
| 160 | /*! |
| 161 | * Creates a TagLib file from a \a stream. |
| 162 | * A byte vector stream can be used to read a file from memory and write to |
| 163 | * memory, e.g. when fetching network data. |
| 164 | * The stream has to be created using taglib_memory_iostream_new() and shall be |
| 165 | * freed using taglib_iostream_free() \e after this file is freed with |
| 166 | * taglib_file_free(). |
| 167 | */ |
| 168 | TAGLIB_C_EXPORT TagLib_File *taglib_file_new_iostream(TagLib_IOStream *stream); |
| 169 | |
| 170 | /*! |
| 171 | * Frees and closes the file. |
| 172 | */ |
| 173 | TAGLIB_C_EXPORT void taglib_file_free(TagLib_File *file); |
| 174 | |
| 175 | /*! |
| 176 | * Returns \c true if the file is open and readable and valid information for |
| 177 | * the Tag and / or AudioProperties was found. |
| 178 | */ |
| 179 | |
| 180 | TAGLIB_C_EXPORT BOOL taglib_file_is_valid(const TagLib_File *file); |
| 181 | |
| 182 | /*! |
| 183 | * Returns a pointer to the tag associated with this file. This will be freed |
| 184 | * automatically when the file is freed. |
| 185 | */ |
| 186 | TAGLIB_C_EXPORT TagLib_Tag *taglib_file_tag(const TagLib_File *file); |
| 187 | |
| 188 | /*! |
| 189 | * Returns a pointer to the audio properties associated with this file. This |
| 190 | * will be freed automatically when the file is freed. |
| 191 | */ |
| 192 | TAGLIB_C_EXPORT const TagLib_AudioProperties *taglib_file_audioproperties(const TagLib_File *file); |
| 193 | |
| 194 | /*! |
| 195 | * Saves the \a file to disk. |
| 196 | */ |
| 197 | TAGLIB_C_EXPORT BOOL taglib_file_save(TagLib_File *file); |
| 198 | |
| 199 | /****************************************************************************** |
| 200 | * Tag API |
| 201 | ******************************************************************************/ |
| 202 | |
| 203 | /*! |
| 204 | * Returns a string with this tag's title. |
| 205 | * |
| 206 | * \note By default this string should be UTF8 encoded and its memory should be |
| 207 | * freed using taglib_tag_free_strings(). |
| 208 | */ |
| 209 | TAGLIB_C_EXPORT char *taglib_tag_title(const TagLib_Tag *tag); |
| 210 | |
| 211 | /*! |
| 212 | * Returns a string with this tag's artist. |
| 213 | * |
| 214 | * \note By default this string should be UTF8 encoded and its memory should be |
| 215 | * freed using taglib_tag_free_strings(). |
| 216 | */ |
| 217 | TAGLIB_C_EXPORT char *taglib_tag_artist(const TagLib_Tag *tag); |
| 218 | |
| 219 | /*! |
| 220 | * Returns a string with this tag's album name. |
| 221 | * |
| 222 | * \note By default this string should be UTF8 encoded and its memory should be |
| 223 | * freed using taglib_tag_free_strings(). |
| 224 | */ |
| 225 | TAGLIB_C_EXPORT char *taglib_tag_album(const TagLib_Tag *tag); |
| 226 | |
| 227 | /*! |
| 228 | * Returns a string with this tag's comment. |
| 229 | * |
| 230 | * \note By default this string should be UTF8 encoded and its memory should be |
| 231 | * freed using taglib_tag_free_strings(). |
| 232 | */ |
| 233 | TAGLIB_C_EXPORT char *taglib_tag_comment(const TagLib_Tag *tag); |
| 234 | |
| 235 | /*! |
| 236 | * Returns a string with this tag's genre. |
| 237 | * |
| 238 | * \note By default this string should be UTF8 encoded and its memory should be |
| 239 | * freed using taglib_tag_free_strings(). |
| 240 | */ |
| 241 | TAGLIB_C_EXPORT char *taglib_tag_genre(const TagLib_Tag *tag); |
| 242 | |
| 243 | /*! |
| 244 | * Returns the tag's year or 0 if the year is not set. |
| 245 | */ |
| 246 | TAGLIB_C_EXPORT unsigned int taglib_tag_year(const TagLib_Tag *tag); |
| 247 | |
| 248 | /*! |
| 249 | * Returns the tag's track number or 0 if the track number is not set. |
| 250 | */ |
| 251 | TAGLIB_C_EXPORT unsigned int taglib_tag_track(const TagLib_Tag *tag); |
| 252 | |
| 253 | /*! |
| 254 | * Sets the tag's title. |
| 255 | * |
| 256 | * \note By default this string should be UTF8 encoded. |
| 257 | */ |
| 258 | TAGLIB_C_EXPORT void taglib_tag_set_title(TagLib_Tag *tag, const char *title); |
| 259 | |
| 260 | /*! |
| 261 | * Sets the tag's artist. |
| 262 | * |
| 263 | * \note By default this string should be UTF8 encoded. |
| 264 | */ |
| 265 | TAGLIB_C_EXPORT void taglib_tag_set_artist(TagLib_Tag *tag, const char *artist); |
| 266 | |
| 267 | /*! |
| 268 | * Sets the tag's album. |
| 269 | * |
| 270 | * \note By default this string should be UTF8 encoded. |
| 271 | */ |
| 272 | TAGLIB_C_EXPORT void taglib_tag_set_album(TagLib_Tag *tag, const char *album); |
| 273 | |
| 274 | /*! |
| 275 | * Sets the tag's comment. |
| 276 | * |
| 277 | * \note By default this string should be UTF8 encoded. |
| 278 | */ |
| 279 | TAGLIB_C_EXPORT void taglib_tag_set_comment(TagLib_Tag *tag, const char *comment); |
| 280 | |
| 281 | /*! |
| 282 | * Sets the tag's genre. |
| 283 | * |
| 284 | * \note By default this string should be UTF8 encoded. |
| 285 | */ |
| 286 | TAGLIB_C_EXPORT void taglib_tag_set_genre(TagLib_Tag *tag, const char *genre); |
| 287 | |
| 288 | /*! |
| 289 | * Sets the tag's year. 0 indicates that this field should be cleared. |
| 290 | */ |
| 291 | TAGLIB_C_EXPORT void taglib_tag_set_year(TagLib_Tag *tag, unsigned int year); |
| 292 | |
| 293 | /*! |
| 294 | * Sets the tag's track number. 0 indicates that this field should be cleared. |
| 295 | */ |
| 296 | TAGLIB_C_EXPORT void taglib_tag_set_track(TagLib_Tag *tag, unsigned int track); |
| 297 | |
| 298 | /*! |
| 299 | * Frees all of the strings that have been created by the tag. |
| 300 | */ |
| 301 | TAGLIB_C_EXPORT void taglib_tag_free_strings(void); |
| 302 | |
| 303 | /****************************************************************************** |
| 304 | * Audio Properties API |
| 305 | ******************************************************************************/ |
| 306 | |
| 307 | /*! |
| 308 | * Returns the length of the file in seconds. |
| 309 | */ |
| 310 | TAGLIB_C_EXPORT int taglib_audioproperties_length(const TagLib_AudioProperties *audioProperties); |
| 311 | |
| 312 | /*! |
| 313 | * Returns the bitrate of the file in kb/s. |
| 314 | */ |
| 315 | TAGLIB_C_EXPORT int taglib_audioproperties_bitrate(const TagLib_AudioProperties *audioProperties); |
| 316 | |
| 317 | /*! |
| 318 | * Returns the sample rate of the file in Hz. |
| 319 | */ |
| 320 | TAGLIB_C_EXPORT int taglib_audioproperties_samplerate(const TagLib_AudioProperties *audioProperties); |
| 321 | |
| 322 | /*! |
| 323 | * Returns the number of channels in the audio stream. |
| 324 | */ |
| 325 | TAGLIB_C_EXPORT int taglib_audioproperties_channels(const TagLib_AudioProperties *audioProperties); |
| 326 | |
| 327 | /******************************************************************************* |
| 328 | * Special convenience ID3v2 functions |
| 329 | *******************************************************************************/ |
| 330 | |
| 331 | typedef enum { |
| 332 | TagLib_ID3v2_Latin1, |
| 333 | TagLib_ID3v2_UTF16, |
| 334 | TagLib_ID3v2_UTF16BE, |
| 335 | TagLib_ID3v2_UTF8 |
| 336 | } TagLib_ID3v2_Encoding; |
| 337 | |
| 338 | /*! |
| 339 | * This sets the default encoding for ID3v2 frames that are written to tags. |
| 340 | */ |
| 341 | |
| 342 | TAGLIB_C_EXPORT void taglib_id3v2_set_default_text_encoding(TagLib_ID3v2_Encoding encoding); |
| 343 | |
| 344 | /****************************************************************************** |
| 345 | * Properties API |
| 346 | ******************************************************************************/ |
| 347 | |
| 348 | /*! |
| 349 | * Sets the property \a prop with \a value. Use \a value = NULL to remove |
| 350 | * the property, otherwise it will be replaced. |
| 351 | */ |
| 352 | TAGLIB_C_EXPORT void taglib_property_set(TagLib_File *file, const char *prop, const char *value); |
| 353 | |
| 354 | /*! |
| 355 | * Appends \a value to the property \a prop (sets it if non-existing). |
| 356 | * Use \a value = NULL to remove all values associated with the property. |
| 357 | */ |
| 358 | TAGLIB_C_EXPORT void taglib_property_set_append(TagLib_File *file, const char *prop, const char *value); |
| 359 | |
| 360 | /*! |
| 361 | * Get the keys of the property map. |
| 362 | * |
| 363 | * \return NULL terminated array of C-strings (char *), only NULL if empty. |
| 364 | * It must be freed by the client using taglib_property_free(). |
| 365 | */ |
| 366 | TAGLIB_C_EXPORT char** taglib_property_keys(const TagLib_File *file); |
| 367 | |
| 368 | /*! |
| 369 | * Get value(s) of property \a prop. |
| 370 | * |
| 371 | * \return NULL terminated array of C-strings (char *), only NULL if empty. |
| 372 | * It must be freed by the client using taglib_property_free(). |
| 373 | */ |
| 374 | TAGLIB_C_EXPORT char** taglib_property_get(const TagLib_File *file, const char *prop); |
| 375 | |
| 376 | /*! |
| 377 | * Frees the NULL terminated array \a props and the C-strings it contains. |
| 378 | */ |
| 379 | TAGLIB_C_EXPORT void taglib_property_free(char **props); |
| 380 | |
| 381 | /****************************************************************************** |
| 382 | * Complex Properties API |
| 383 | ******************************************************************************/ |
| 384 | |
| 385 | /*! |
| 386 | * Types which can be stored in a TagLib_Variant. |
| 387 | * |
| 388 | * \related TagLib::Variant::Type |
| 389 | * These correspond to TagLib::Variant::Type, but ByteVectorList, VariantList, |
| 390 | * VariantMap are not supported and will be returned as their string |
| 391 | * representation. |
| 392 | */ |
| 393 | typedef enum { |
| 394 | TagLib_Variant_Void, |
| 395 | TagLib_Variant_Bool, |
| 396 | TagLib_Variant_Int, |
| 397 | TagLib_Variant_UInt, |
| 398 | TagLib_Variant_LongLong, |
| 399 | TagLib_Variant_ULongLong, |
| 400 | TagLib_Variant_Double, |
| 401 | TagLib_Variant_String, |
| 402 | TagLib_Variant_StringList, |
| 403 | TagLib_Variant_ByteVector |
| 404 | } TagLib_Variant_Type; |
| 405 | |
| 406 | /*! |
| 407 | * Discriminated union used in complex property attributes. |
| 408 | * |
| 409 | * \e type must be set according to the \e value union used. |
| 410 | * \e size is only required for TagLib_Variant_ByteVector and must contain |
| 411 | * the number of bytes. |
| 412 | * |
| 413 | * \related TagLib::Variant. |
| 414 | */ |
| 415 | typedef struct { |
| 416 | TagLib_Variant_Type type; |
| 417 | unsigned int size; |
| 418 | union { |
| 419 | char *stringValue; |
| 420 | char *byteVectorValue; |
| 421 | char **stringListValue; |
| 422 | BOOL boolValue; |
| 423 | int intValue; |
| 424 | unsigned int uIntValue; |
| 425 | long long longLongValue; |
| 426 | unsigned long long uLongLongValue; |
| 427 | double doubleValue; |
| 428 | } value; |
| 429 | } TagLib_Variant; |
| 430 | |
| 431 | /*! |
| 432 | * Attribute of a complex property. |
| 433 | * Complex properties consist of a NULL-terminated array of pointers to |
| 434 | * this structure with \e key and \e value. |
| 435 | */ |
| 436 | typedef struct { |
| 437 | char *key; |
| 438 | TagLib_Variant value; |
| 439 | } TagLib_Complex_Property_Attribute; |
| 440 | |
| 441 | /*! |
| 442 | * Picture data extracted from a complex property by the convenience function |
| 443 | * taglib_picture_from_complex_property(). |
| 444 | */ |
| 445 | typedef struct { |
| 446 | char *mimeType; |
| 447 | char *description; |
| 448 | char *pictureType; |
| 449 | char *data; |
| 450 | unsigned int size; |
| 451 | } TagLib_Complex_Property_Picture_Data; |
| 452 | |
| 453 | /*! |
| 454 | * Declare complex property attributes to set a picture. |
| 455 | * Can be used to define a variable \a var which can be used with |
| 456 | * taglib_complex_property_set() and a "PICTURE" key to set an |
| 457 | * embedded picture with the picture data \a dat of size \a siz |
| 458 | * and description \a desc, mime type \a mime and picture type |
| 459 | * \a typ (size is unsigned int, the other input parameters char *). |
| 460 | */ |
| 461 | #define TAGLIB_COMPLEX_PROPERTY_PICTURE(var, dat, siz, desc, mime, typ) \ |
| 462 | const TagLib_Complex_Property_Attribute \ |
| 463 | var##Attrs[] = { \ |
| 464 | { \ |
| 465 | (char *)"data", \ |
| 466 | { \ |
| 467 | TagLib_Variant_ByteVector, \ |
| 468 | (siz), \ |
| 469 | { \ |
| 470 | (char *)(dat) \ |
| 471 | } \ |
| 472 | } \ |
| 473 | }, \ |
| 474 | { \ |
| 475 | (char *)"mimeType", \ |
| 476 | { \ |
| 477 | TagLib_Variant_String, \ |
| 478 | 0U, \ |
| 479 | { \ |
| 480 | (char *)(mime) \ |
| 481 | } \ |
| 482 | } \ |
| 483 | }, \ |
| 484 | { \ |
| 485 | (char *)"description", \ |
| 486 | { \ |
| 487 | TagLib_Variant_String, \ |
| 488 | 0U, \ |
| 489 | { \ |
| 490 | (char *)(desc) \ |
| 491 | } \ |
| 492 | } \ |
| 493 | }, \ |
| 494 | { \ |
| 495 | (char *)"pictureType", \ |
| 496 | { \ |
| 497 | TagLib_Variant_String, \ |
| 498 | 0U, \ |
| 499 | { \ |
| 500 | (char *)(typ) \ |
| 501 | } \ |
| 502 | } \ |
| 503 | } \ |
| 504 | }; \ |
| 505 | const TagLib_Complex_Property_Attribute *var[] = { \ |
| 506 | &var##Attrs[0], &var##Attrs[1], &var##Attrs[2], \ |
| 507 | &var##Attrs[3], NULL \ |
| 508 | } |
| 509 | |
| 510 | /*! |
| 511 | * Sets the complex property \a key with \a value. Use \a value = NULL to |
| 512 | * remove the property, otherwise it will be replaced with the NULL |
| 513 | * terminated array of attributes in \a value. |
| 514 | * |
| 515 | * A picture can be set with the TAGLIB_COMPLEX_PROPERTY_PICTURE macro: |
| 516 | * |
| 517 | * \code {.c} |
| 518 | * TagLib_File *file = taglib_file_new("myfile.mp3"); |
| 519 | * FILE *fh = fopen("mypicture.jpg", "rb"); |
| 520 | * if(fh) { |
| 521 | * fseek(fh, 0L, SEEK_END); |
| 522 | * long size = ftell(fh); |
| 523 | * fseek(fh, 0L, SEEK_SET); |
| 524 | * char *data = (char *)malloc(size); |
| 525 | * fread(data, size, 1, fh); |
| 526 | * TAGLIB_COMPLEX_PROPERTY_PICTURE(props, data, size, "Written by TagLib", |
| 527 | * "image/jpeg", "Front Cover"); |
| 528 | * taglib_complex_property_set(file, "PICTURE", props); |
| 529 | * taglib_file_save(file); |
| 530 | * free(data); |
| 531 | * fclose(fh); |
| 532 | * } |
| 533 | * \endcode |
| 534 | */ |
| 535 | TAGLIB_C_EXPORT BOOL taglib_complex_property_set( |
| 536 | TagLib_File *file, const char *key, |
| 537 | const TagLib_Complex_Property_Attribute **value); |
| 538 | |
| 539 | /*! |
| 540 | * Appends \a value to the complex property \a key (sets it if non-existing). |
| 541 | * Use \a value = NULL to remove all values associated with the \a key. |
| 542 | */ |
| 543 | TAGLIB_C_EXPORT BOOL taglib_complex_property_set_append( |
| 544 | TagLib_File *file, const char *key, |
| 545 | const TagLib_Complex_Property_Attribute **value); |
| 546 | |
| 547 | /*! |
| 548 | * Get the keys of the complex properties. |
| 549 | * |
| 550 | * \return NULL terminated array of C-strings (char *), only NULL if empty. |
| 551 | * It must be freed by the client using taglib_complex_property_free_keys(). |
| 552 | */ |
| 553 | TAGLIB_C_EXPORT char** taglib_complex_property_keys(const TagLib_File *file); |
| 554 | |
| 555 | /*! |
| 556 | * Get value(s) of complex property \a key. |
| 557 | * |
| 558 | * \return NULL terminated array of property values, which are themselves an |
| 559 | * array of property attributes, only NULL if empty. |
| 560 | * It must be freed by the client using taglib_complex_property_free(). |
| 561 | */ |
| 562 | TAGLIB_C_EXPORT TagLib_Complex_Property_Attribute*** taglib_complex_property_get( |
| 563 | const TagLib_File *file, const char *key); |
| 564 | |
| 565 | /*! |
| 566 | * Extract the complex property values of a picture. |
| 567 | * |
| 568 | * This function can be used to get the data from a "PICTURE" complex property |
| 569 | * without having to traverse the whole variant map. A picture can be |
| 570 | * retrieved like this: |
| 571 | * |
| 572 | * \code {.c} |
| 573 | * TagLib_File *file = taglib_file_new("myfile.mp3"); |
| 574 | * TagLib_Complex_Property_Attribute*** properties = |
| 575 | * taglib_complex_property_get(file, "PICTURE"); |
| 576 | * TagLib_Complex_Property_Picture_Data picture; |
| 577 | * taglib_picture_from_complex_property(properties, &picture); |
| 578 | * // Do something with picture.mimeType, picture.description, |
| 579 | * // picture.pictureType, picture.data, picture.size, e.g. extract it. |
| 580 | * FILE *fh = fopen("mypicture.jpg", "wb"); |
| 581 | * if(fh) { |
| 582 | * fwrite(picture.data, picture.size, 1, fh); |
| 583 | * fclose(fh); |
| 584 | * } |
| 585 | * taglib_complex_property_free(properties); |
| 586 | * \endcode |
| 587 | * |
| 588 | * Note that the data in \a picture contains pointers to data in \a properties, |
| 589 | * i.e. it only lives as long as the properties, until they are freed with |
| 590 | * taglib_complex_property_free(). |
| 591 | * If you want to access multiple pictures or additional properties of FLAC |
| 592 | * pictures ("width", "height", "numColors", "colorDepth" int values), you |
| 593 | * have to traverse the \a properties yourself. |
| 594 | */ |
| 595 | TAGLIB_C_EXPORT void taglib_picture_from_complex_property( |
| 596 | TagLib_Complex_Property_Attribute*** properties, |
| 597 | TagLib_Complex_Property_Picture_Data *picture); |
| 598 | |
| 599 | /*! |
| 600 | * Frees the NULL terminated array \a keys (as returned by |
| 601 | * taglib_complex_property_keys()) and the C-strings it contains. |
| 602 | */ |
| 603 | TAGLIB_C_EXPORT void taglib_complex_property_free_keys(char **keys); |
| 604 | |
| 605 | /*! |
| 606 | * Frees the NULL terminated array \a props of property attribute arrays |
| 607 | * (as returned by taglib_complex_property_get()) and the data such as |
| 608 | * C-strings and byte vectors contained in these attributes. |
| 609 | */ |
| 610 | TAGLIB_C_EXPORT void taglib_complex_property_free( |
| 611 | TagLib_Complex_Property_Attribute ***props); |
| 612 | |
| 613 | #ifdef __cplusplus |
| 614 | } |
| 615 | #endif |
| 616 | #endif /* DO_NOT_DOCUMENT */ |
| 617 | #endif |