annotate osx/include/FLAC/metadata.h @ 83:ae30d91d2ffe

Replace these with versions built using an older toolset (so as to avoid ABI compatibilities when linking on Ubuntu 14.04 for packaging purposes)
author Chris Cannam
date Fri, 07 Feb 2020 11:51:13 +0000
parents cc5d363db385
children
rev   line source
Chris@2 1 /* libFLAC - Free Lossless Audio Codec library
Chris@2 2 * Copyright (C) 2001,2002,2003,2004,2005,2006,2007 Josh Coalson
Chris@2 3 *
Chris@2 4 * Redistribution and use in source and binary forms, with or without
Chris@2 5 * modification, are permitted provided that the following conditions
Chris@2 6 * are met:
Chris@2 7 *
Chris@2 8 * - Redistributions of source code must retain the above copyright
Chris@2 9 * notice, this list of conditions and the following disclaimer.
Chris@2 10 *
Chris@2 11 * - Redistributions in binary form must reproduce the above copyright
Chris@2 12 * notice, this list of conditions and the following disclaimer in the
Chris@2 13 * documentation and/or other materials provided with the distribution.
Chris@2 14 *
Chris@2 15 * - Neither the name of the Xiph.org Foundation nor the names of its
Chris@2 16 * contributors may be used to endorse or promote products derived from
Chris@2 17 * this software without specific prior written permission.
Chris@2 18 *
Chris@2 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
Chris@2 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
Chris@2 21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
Chris@2 22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
Chris@2 23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
Chris@2 24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
Chris@2 25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
Chris@2 26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
Chris@2 27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
Chris@2 28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
Chris@2 29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Chris@2 30 */
Chris@2 31
Chris@2 32 #ifndef FLAC__METADATA_H
Chris@2 33 #define FLAC__METADATA_H
Chris@2 34
Chris@2 35 #include <sys/types.h> /* for off_t */
Chris@2 36 #include "export.h"
Chris@2 37 #include "callback.h"
Chris@2 38 #include "format.h"
Chris@2 39
Chris@2 40 /* --------------------------------------------------------------------
Chris@2 41 (For an example of how all these routines are used, see the source
Chris@2 42 code for the unit tests in src/test_libFLAC/metadata_*.c, or
Chris@2 43 metaflac in src/metaflac/)
Chris@2 44 ------------------------------------------------------------------*/
Chris@2 45
Chris@2 46 /** \file include/FLAC/metadata.h
Chris@2 47 *
Chris@2 48 * \brief
Chris@2 49 * This module provides functions for creating and manipulating FLAC
Chris@2 50 * metadata blocks in memory, and three progressively more powerful
Chris@2 51 * interfaces for traversing and editing metadata in FLAC files.
Chris@2 52 *
Chris@2 53 * See the detailed documentation for each interface in the
Chris@2 54 * \link flac_metadata metadata \endlink module.
Chris@2 55 */
Chris@2 56
Chris@2 57 /** \defgroup flac_metadata FLAC/metadata.h: metadata interfaces
Chris@2 58 * \ingroup flac
Chris@2 59 *
Chris@2 60 * \brief
Chris@2 61 * This module provides functions for creating and manipulating FLAC
Chris@2 62 * metadata blocks in memory, and three progressively more powerful
Chris@2 63 * interfaces for traversing and editing metadata in native FLAC files.
Chris@2 64 * Note that currently only the Chain interface (level 2) supports Ogg
Chris@2 65 * FLAC files, and it is read-only i.e. no writing back changed
Chris@2 66 * metadata to file.
Chris@2 67 *
Chris@2 68 * There are three metadata interfaces of increasing complexity:
Chris@2 69 *
Chris@2 70 * Level 0:
Chris@2 71 * Read-only access to the STREAMINFO, VORBIS_COMMENT, CUESHEET, and
Chris@2 72 * PICTURE blocks.
Chris@2 73 *
Chris@2 74 * Level 1:
Chris@2 75 * Read-write access to all metadata blocks. This level is write-
Chris@2 76 * efficient in most cases (more on this below), and uses less memory
Chris@2 77 * than level 2.
Chris@2 78 *
Chris@2 79 * Level 2:
Chris@2 80 * Read-write access to all metadata blocks. This level is write-
Chris@2 81 * efficient in all cases, but uses more memory since all metadata for
Chris@2 82 * the whole file is read into memory and manipulated before writing
Chris@2 83 * out again.
Chris@2 84 *
Chris@2 85 * What do we mean by efficient? Since FLAC metadata appears at the
Chris@2 86 * beginning of the file, when writing metadata back to a FLAC file
Chris@2 87 * it is possible to grow or shrink the metadata such that the entire
Chris@2 88 * file must be rewritten. However, if the size remains the same during
Chris@2 89 * changes or PADDING blocks are utilized, only the metadata needs to be
Chris@2 90 * overwritten, which is much faster.
Chris@2 91 *
Chris@2 92 * Efficient means the whole file is rewritten at most one time, and only
Chris@2 93 * when necessary. Level 1 is not efficient only in the case that you
Chris@2 94 * cause more than one metadata block to grow or shrink beyond what can
Chris@2 95 * be accomodated by padding. In this case you should probably use level
Chris@2 96 * 2, which allows you to edit all the metadata for a file in memory and
Chris@2 97 * write it out all at once.
Chris@2 98 *
Chris@2 99 * All levels know how to skip over and not disturb an ID3v2 tag at the
Chris@2 100 * front of the file.
Chris@2 101 *
Chris@2 102 * All levels access files via their filenames. In addition, level 2
Chris@2 103 * has additional alternative read and write functions that take an I/O
Chris@2 104 * handle and callbacks, for situations where access by filename is not
Chris@2 105 * possible.
Chris@2 106 *
Chris@2 107 * In addition to the three interfaces, this module defines functions for
Chris@2 108 * creating and manipulating various metadata objects in memory. As we see
Chris@2 109 * from the Format module, FLAC metadata blocks in memory are very primitive
Chris@2 110 * structures for storing information in an efficient way. Reading
Chris@2 111 * information from the structures is easy but creating or modifying them
Chris@2 112 * directly is more complex. The metadata object routines here facilitate
Chris@2 113 * this by taking care of the consistency and memory management drudgery.
Chris@2 114 *
Chris@2 115 * Unless you will be using the level 1 or 2 interfaces to modify existing
Chris@2 116 * metadata however, you will not probably not need these.
Chris@2 117 *
Chris@2 118 * From a dependency standpoint, none of the encoders or decoders require
Chris@2 119 * the metadata module. This is so that embedded users can strip out the
Chris@2 120 * metadata module from libFLAC to reduce the size and complexity.
Chris@2 121 */
Chris@2 122
Chris@2 123 #ifdef __cplusplus
Chris@2 124 extern "C" {
Chris@2 125 #endif
Chris@2 126
Chris@2 127
Chris@2 128 /** \defgroup flac_metadata_level0 FLAC/metadata.h: metadata level 0 interface
Chris@2 129 * \ingroup flac_metadata
Chris@2 130 *
Chris@2 131 * \brief
Chris@2 132 * The level 0 interface consists of individual routines to read the
Chris@2 133 * STREAMINFO, VORBIS_COMMENT, CUESHEET, and PICTURE blocks, requiring
Chris@2 134 * only a filename.
Chris@2 135 *
Chris@2 136 * They try to skip any ID3v2 tag at the head of the file.
Chris@2 137 *
Chris@2 138 * \{
Chris@2 139 */
Chris@2 140
Chris@2 141 /** Read the STREAMINFO metadata block of the given FLAC file. This function
Chris@2 142 * will try to skip any ID3v2 tag at the head of the file.
Chris@2 143 *
Chris@2 144 * \param filename The path to the FLAC file to read.
Chris@2 145 * \param streaminfo A pointer to space for the STREAMINFO block. Since
Chris@2 146 * FLAC__StreamMetadata is a simple structure with no
Chris@2 147 * memory allocation involved, you pass the address of
Chris@2 148 * an existing structure. It need not be initialized.
Chris@2 149 * \assert
Chris@2 150 * \code filename != NULL \endcode
Chris@2 151 * \code streaminfo != NULL \endcode
Chris@2 152 * \retval FLAC__bool
Chris@2 153 * \c true if a valid STREAMINFO block was read from \a filename. Returns
Chris@2 154 * \c false if there was a memory allocation error, a file decoder error,
Chris@2 155 * or the file contained no STREAMINFO block. (A memory allocation error
Chris@2 156 * is possible because this function must set up a file decoder.)
Chris@2 157 */
Chris@2 158 FLAC_API FLAC__bool FLAC__metadata_get_streaminfo(const char *filename, FLAC__StreamMetadata *streaminfo);
Chris@2 159
Chris@2 160 /** Read the VORBIS_COMMENT metadata block of the given FLAC file. This
Chris@2 161 * function will try to skip any ID3v2 tag at the head of the file.
Chris@2 162 *
Chris@2 163 * \param filename The path to the FLAC file to read.
Chris@2 164 * \param tags The address where the returned pointer will be
Chris@2 165 * stored. The \a tags object must be deleted by
Chris@2 166 * the caller using FLAC__metadata_object_delete().
Chris@2 167 * \assert
Chris@2 168 * \code filename != NULL \endcode
Chris@2 169 * \code tags != NULL \endcode
Chris@2 170 * \retval FLAC__bool
Chris@2 171 * \c true if a valid VORBIS_COMMENT block was read from \a filename,
Chris@2 172 * and \a *tags will be set to the address of the metadata structure.
Chris@2 173 * Returns \c false if there was a memory allocation error, a file
Chris@2 174 * decoder error, or the file contained no VORBIS_COMMENT block, and
Chris@2 175 * \a *tags will be set to \c NULL.
Chris@2 176 */
Chris@2 177 FLAC_API FLAC__bool FLAC__metadata_get_tags(const char *filename, FLAC__StreamMetadata **tags);
Chris@2 178
Chris@2 179 /** Read the CUESHEET metadata block of the given FLAC file. This
Chris@2 180 * function will try to skip any ID3v2 tag at the head of the file.
Chris@2 181 *
Chris@2 182 * \param filename The path to the FLAC file to read.
Chris@2 183 * \param cuesheet The address where the returned pointer will be
Chris@2 184 * stored. The \a cuesheet object must be deleted by
Chris@2 185 * the caller using FLAC__metadata_object_delete().
Chris@2 186 * \assert
Chris@2 187 * \code filename != NULL \endcode
Chris@2 188 * \code cuesheet != NULL \endcode
Chris@2 189 * \retval FLAC__bool
Chris@2 190 * \c true if a valid CUESHEET block was read from \a filename,
Chris@2 191 * and \a *cuesheet will be set to the address of the metadata
Chris@2 192 * structure. Returns \c false if there was a memory allocation
Chris@2 193 * error, a file decoder error, or the file contained no CUESHEET
Chris@2 194 * block, and \a *cuesheet will be set to \c NULL.
Chris@2 195 */
Chris@2 196 FLAC_API FLAC__bool FLAC__metadata_get_cuesheet(const char *filename, FLAC__StreamMetadata **cuesheet);
Chris@2 197
Chris@2 198 /** Read a PICTURE metadata block of the given FLAC file. This
Chris@2 199 * function will try to skip any ID3v2 tag at the head of the file.
Chris@2 200 * Since there can be more than one PICTURE block in a file, this
Chris@2 201 * function takes a number of parameters that act as constraints to
Chris@2 202 * the search. The PICTURE block with the largest area matching all
Chris@2 203 * the constraints will be returned, or \a *picture will be set to
Chris@2 204 * \c NULL if there was no such block.
Chris@2 205 *
Chris@2 206 * \param filename The path to the FLAC file to read.
Chris@2 207 * \param picture The address where the returned pointer will be
Chris@2 208 * stored. The \a picture object must be deleted by
Chris@2 209 * the caller using FLAC__metadata_object_delete().
Chris@2 210 * \param type The desired picture type. Use \c -1 to mean
Chris@2 211 * "any type".
Chris@2 212 * \param mime_type The desired MIME type, e.g. "image/jpeg". The
Chris@2 213 * string will be matched exactly. Use \c NULL to
Chris@2 214 * mean "any MIME type".
Chris@2 215 * \param description The desired description. The string will be
Chris@2 216 * matched exactly. Use \c NULL to mean "any
Chris@2 217 * description".
Chris@2 218 * \param max_width The maximum width in pixels desired. Use
Chris@2 219 * \c (unsigned)(-1) to mean "any width".
Chris@2 220 * \param max_height The maximum height in pixels desired. Use
Chris@2 221 * \c (unsigned)(-1) to mean "any height".
Chris@2 222 * \param max_depth The maximum color depth in bits-per-pixel desired.
Chris@2 223 * Use \c (unsigned)(-1) to mean "any depth".
Chris@2 224 * \param max_colors The maximum number of colors desired. Use
Chris@2 225 * \c (unsigned)(-1) to mean "any number of colors".
Chris@2 226 * \assert
Chris@2 227 * \code filename != NULL \endcode
Chris@2 228 * \code picture != NULL \endcode
Chris@2 229 * \retval FLAC__bool
Chris@2 230 * \c true if a valid PICTURE block was read from \a filename,
Chris@2 231 * and \a *picture will be set to the address of the metadata
Chris@2 232 * structure. Returns \c false if there was a memory allocation
Chris@2 233 * error, a file decoder error, or the file contained no PICTURE
Chris@2 234 * block, and \a *picture will be set to \c NULL.
Chris@2 235 */
Chris@2 236 FLAC_API FLAC__bool FLAC__metadata_get_picture(const char *filename, FLAC__StreamMetadata **picture, FLAC__StreamMetadata_Picture_Type type, const char *mime_type, const FLAC__byte *description, unsigned max_width, unsigned max_height, unsigned max_depth, unsigned max_colors);
Chris@2 237
Chris@2 238 /* \} */
Chris@2 239
Chris@2 240
Chris@2 241 /** \defgroup flac_metadata_level1 FLAC/metadata.h: metadata level 1 interface
Chris@2 242 * \ingroup flac_metadata
Chris@2 243 *
Chris@2 244 * \brief
Chris@2 245 * The level 1 interface provides read-write access to FLAC file metadata and
Chris@2 246 * operates directly on the FLAC file.
Chris@2 247 *
Chris@2 248 * The general usage of this interface is:
Chris@2 249 *
Chris@2 250 * - Create an iterator using FLAC__metadata_simple_iterator_new()
Chris@2 251 * - Attach it to a file using FLAC__metadata_simple_iterator_init() and check
Chris@2 252 * the exit code. Call FLAC__metadata_simple_iterator_is_writable() to
Chris@2 253 * see if the file is writable, or only read access is allowed.
Chris@2 254 * - Use FLAC__metadata_simple_iterator_next() and
Chris@2 255 * FLAC__metadata_simple_iterator_prev() to traverse the blocks.
Chris@2 256 * This is does not read the actual blocks themselves.
Chris@2 257 * FLAC__metadata_simple_iterator_next() is relatively fast.
Chris@2 258 * FLAC__metadata_simple_iterator_prev() is slower since it needs to search
Chris@2 259 * forward from the front of the file.
Chris@2 260 * - Use FLAC__metadata_simple_iterator_get_block_type() or
Chris@2 261 * FLAC__metadata_simple_iterator_get_block() to access the actual data at
Chris@2 262 * the current iterator position. The returned object is yours to modify
Chris@2 263 * and free.
Chris@2 264 * - Use FLAC__metadata_simple_iterator_set_block() to write a modified block
Chris@2 265 * back. You must have write permission to the original file. Make sure to
Chris@2 266 * read the whole comment to FLAC__metadata_simple_iterator_set_block()
Chris@2 267 * below.
Chris@2 268 * - Use FLAC__metadata_simple_iterator_insert_block_after() to add new blocks.
Chris@2 269 * Use the object creation functions from
Chris@2 270 * \link flac_metadata_object here \endlink to generate new objects.
Chris@2 271 * - Use FLAC__metadata_simple_iterator_delete_block() to remove the block
Chris@2 272 * currently referred to by the iterator, or replace it with padding.
Chris@2 273 * - Destroy the iterator with FLAC__metadata_simple_iterator_delete() when
Chris@2 274 * finished.
Chris@2 275 *
Chris@2 276 * \note
Chris@2 277 * The FLAC file remains open the whole time between
Chris@2 278 * FLAC__metadata_simple_iterator_init() and
Chris@2 279 * FLAC__metadata_simple_iterator_delete(), so make sure you are not altering
Chris@2 280 * the file during this time.
Chris@2 281 *
Chris@2 282 * \note
Chris@2 283 * Do not modify the \a is_last, \a length, or \a type fields of returned
Chris@2 284 * FLAC__StreamMetadata objects. These are managed automatically.
Chris@2 285 *
Chris@2 286 * \note
Chris@2 287 * If any of the modification functions
Chris@2 288 * (FLAC__metadata_simple_iterator_set_block(),
Chris@2 289 * FLAC__metadata_simple_iterator_delete_block(),
Chris@2 290 * FLAC__metadata_simple_iterator_insert_block_after(), etc.) return \c false,
Chris@2 291 * you should delete the iterator as it may no longer be valid.
Chris@2 292 *
Chris@2 293 * \{
Chris@2 294 */
Chris@2 295
Chris@2 296 struct FLAC__Metadata_SimpleIterator;
Chris@2 297 /** The opaque structure definition for the level 1 iterator type.
Chris@2 298 * See the
Chris@2 299 * \link flac_metadata_level1 metadata level 1 module \endlink
Chris@2 300 * for a detailed description.
Chris@2 301 */
Chris@2 302 typedef struct FLAC__Metadata_SimpleIterator FLAC__Metadata_SimpleIterator;
Chris@2 303
Chris@2 304 /** Status type for FLAC__Metadata_SimpleIterator.
Chris@2 305 *
Chris@2 306 * The iterator's current status can be obtained by calling FLAC__metadata_simple_iterator_status().
Chris@2 307 */
Chris@2 308 typedef enum {
Chris@2 309
Chris@2 310 FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK = 0,
Chris@2 311 /**< The iterator is in the normal OK state */
Chris@2 312
Chris@2 313 FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ILLEGAL_INPUT,
Chris@2 314 /**< The data passed into a function violated the function's usage criteria */
Chris@2 315
Chris@2 316 FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ERROR_OPENING_FILE,
Chris@2 317 /**< The iterator could not open the target file */
Chris@2 318
Chris@2 319 FLAC__METADATA_SIMPLE_ITERATOR_STATUS_NOT_A_FLAC_FILE,
Chris@2 320 /**< The iterator could not find the FLAC signature at the start of the file */
Chris@2 321
Chris@2 322 FLAC__METADATA_SIMPLE_ITERATOR_STATUS_NOT_WRITABLE,
Chris@2 323 /**< The iterator tried to write to a file that was not writable */
Chris@2 324
Chris@2 325 FLAC__METADATA_SIMPLE_ITERATOR_STATUS_BAD_METADATA,
Chris@2 326 /**< The iterator encountered input that does not conform to the FLAC metadata specification */
Chris@2 327
Chris@2 328 FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR,
Chris@2 329 /**< The iterator encountered an error while reading the FLAC file */
Chris@2 330
Chris@2 331 FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR,
Chris@2 332 /**< The iterator encountered an error while seeking in the FLAC file */
Chris@2 333
Chris@2 334 FLAC__METADATA_SIMPLE_ITERATOR_STATUS_WRITE_ERROR,
Chris@2 335 /**< The iterator encountered an error while writing the FLAC file */
Chris@2 336
Chris@2 337 FLAC__METADATA_SIMPLE_ITERATOR_STATUS_RENAME_ERROR,
Chris@2 338 /**< The iterator encountered an error renaming the FLAC file */
Chris@2 339
Chris@2 340 FLAC__METADATA_SIMPLE_ITERATOR_STATUS_UNLINK_ERROR,
Chris@2 341 /**< The iterator encountered an error removing the temporary file */
Chris@2 342
Chris@2 343 FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR,
Chris@2 344 /**< Memory allocation failed */
Chris@2 345
Chris@2 346 FLAC__METADATA_SIMPLE_ITERATOR_STATUS_INTERNAL_ERROR
Chris@2 347 /**< The caller violated an assertion or an unexpected error occurred */
Chris@2 348
Chris@2 349 } FLAC__Metadata_SimpleIteratorStatus;
Chris@2 350
Chris@2 351 /** Maps a FLAC__Metadata_SimpleIteratorStatus to a C string.
Chris@2 352 *
Chris@2 353 * Using a FLAC__Metadata_SimpleIteratorStatus as the index to this array
Chris@2 354 * will give the string equivalent. The contents should not be modified.
Chris@2 355 */
Chris@2 356 extern FLAC_API const char * const FLAC__Metadata_SimpleIteratorStatusString[];
Chris@2 357
Chris@2 358
Chris@2 359 /** Create a new iterator instance.
Chris@2 360 *
Chris@2 361 * \retval FLAC__Metadata_SimpleIterator*
Chris@2 362 * \c NULL if there was an error allocating memory, else the new instance.
Chris@2 363 */
Chris@2 364 FLAC_API FLAC__Metadata_SimpleIterator *FLAC__metadata_simple_iterator_new(void);
Chris@2 365
Chris@2 366 /** Free an iterator instance. Deletes the object pointed to by \a iterator.
Chris@2 367 *
Chris@2 368 * \param iterator A pointer to an existing iterator.
Chris@2 369 * \assert
Chris@2 370 * \code iterator != NULL \endcode
Chris@2 371 */
Chris@2 372 FLAC_API void FLAC__metadata_simple_iterator_delete(FLAC__Metadata_SimpleIterator *iterator);
Chris@2 373
Chris@2 374 /** Get the current status of the iterator. Call this after a function
Chris@2 375 * returns \c false to get the reason for the error. Also resets the status
Chris@2 376 * to FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK.
Chris@2 377 *
Chris@2 378 * \param iterator A pointer to an existing iterator.
Chris@2 379 * \assert
Chris@2 380 * \code iterator != NULL \endcode
Chris@2 381 * \retval FLAC__Metadata_SimpleIteratorStatus
Chris@2 382 * The current status of the iterator.
Chris@2 383 */
Chris@2 384 FLAC_API FLAC__Metadata_SimpleIteratorStatus FLAC__metadata_simple_iterator_status(FLAC__Metadata_SimpleIterator *iterator);
Chris@2 385
Chris@2 386 /** Initialize the iterator to point to the first metadata block in the
Chris@2 387 * given FLAC file.
Chris@2 388 *
Chris@2 389 * \param iterator A pointer to an existing iterator.
Chris@2 390 * \param filename The path to the FLAC file.
Chris@2 391 * \param read_only If \c true, the FLAC file will be opened
Chris@2 392 * in read-only mode; if \c false, the FLAC
Chris@2 393 * file will be opened for edit even if no
Chris@2 394 * edits are performed.
Chris@2 395 * \param preserve_file_stats If \c true, the owner and modification
Chris@2 396 * time will be preserved even if the FLAC
Chris@2 397 * file is written to.
Chris@2 398 * \assert
Chris@2 399 * \code iterator != NULL \endcode
Chris@2 400 * \code filename != NULL \endcode
Chris@2 401 * \retval FLAC__bool
Chris@2 402 * \c false if a memory allocation error occurs, the file can't be
Chris@2 403 * opened, or another error occurs, else \c true.
Chris@2 404 */
Chris@2 405 FLAC_API FLAC__bool FLAC__metadata_simple_iterator_init(FLAC__Metadata_SimpleIterator *iterator, const char *filename, FLAC__bool read_only, FLAC__bool preserve_file_stats);
Chris@2 406
Chris@2 407 /** Returns \c true if the FLAC file is writable. If \c false, calls to
Chris@2 408 * FLAC__metadata_simple_iterator_set_block() and
Chris@2 409 * FLAC__metadata_simple_iterator_insert_block_after() will fail.
Chris@2 410 *
Chris@2 411 * \param iterator A pointer to an existing iterator.
Chris@2 412 * \assert
Chris@2 413 * \code iterator != NULL \endcode
Chris@2 414 * \retval FLAC__bool
Chris@2 415 * See above.
Chris@2 416 */
Chris@2 417 FLAC_API FLAC__bool FLAC__metadata_simple_iterator_is_writable(const FLAC__Metadata_SimpleIterator *iterator);
Chris@2 418
Chris@2 419 /** Moves the iterator forward one metadata block, returning \c false if
Chris@2 420 * already at the end.
Chris@2 421 *
Chris@2 422 * \param iterator A pointer to an existing initialized iterator.
Chris@2 423 * \assert
Chris@2 424 * \code iterator != NULL \endcode
Chris@2 425 * \a iterator has been successfully initialized with
Chris@2 426 * FLAC__metadata_simple_iterator_init()
Chris@2 427 * \retval FLAC__bool
Chris@2 428 * \c false if already at the last metadata block of the chain, else
Chris@2 429 * \c true.
Chris@2 430 */
Chris@2 431 FLAC_API FLAC__bool FLAC__metadata_simple_iterator_next(FLAC__Metadata_SimpleIterator *iterator);
Chris@2 432
Chris@2 433 /** Moves the iterator backward one metadata block, returning \c false if
Chris@2 434 * already at the beginning.
Chris@2 435 *
Chris@2 436 * \param iterator A pointer to an existing initialized iterator.
Chris@2 437 * \assert
Chris@2 438 * \code iterator != NULL \endcode
Chris@2 439 * \a iterator has been successfully initialized with
Chris@2 440 * FLAC__metadata_simple_iterator_init()
Chris@2 441 * \retval FLAC__bool
Chris@2 442 * \c false if already at the first metadata block of the chain, else
Chris@2 443 * \c true.
Chris@2 444 */
Chris@2 445 FLAC_API FLAC__bool FLAC__metadata_simple_iterator_prev(FLAC__Metadata_SimpleIterator *iterator);
Chris@2 446
Chris@2 447 /** Returns a flag telling if the current metadata block is the last.
Chris@2 448 *
Chris@2 449 * \param iterator A pointer to an existing initialized iterator.
Chris@2 450 * \assert
Chris@2 451 * \code iterator != NULL \endcode
Chris@2 452 * \a iterator has been successfully initialized with
Chris@2 453 * FLAC__metadata_simple_iterator_init()
Chris@2 454 * \retval FLAC__bool
Chris@2 455 * \c true if the current metadata block is the last in the file,
Chris@2 456 * else \c false.
Chris@2 457 */
Chris@2 458 FLAC_API FLAC__bool FLAC__metadata_simple_iterator_is_last(const FLAC__Metadata_SimpleIterator *iterator);
Chris@2 459
Chris@2 460 /** Get the offset of the metadata block at the current position. This
Chris@2 461 * avoids reading the actual block data which can save time for large
Chris@2 462 * blocks.
Chris@2 463 *
Chris@2 464 * \param iterator A pointer to an existing initialized iterator.
Chris@2 465 * \assert
Chris@2 466 * \code iterator != NULL \endcode
Chris@2 467 * \a iterator has been successfully initialized with
Chris@2 468 * FLAC__metadata_simple_iterator_init()
Chris@2 469 * \retval off_t
Chris@2 470 * The offset of the metadata block at the current iterator position.
Chris@2 471 * This is the byte offset relative to the beginning of the file of
Chris@2 472 * the current metadata block's header.
Chris@2 473 */
Chris@2 474 FLAC_API off_t FLAC__metadata_simple_iterator_get_block_offset(const FLAC__Metadata_SimpleIterator *iterator);
Chris@2 475
Chris@2 476 /** Get the type of the metadata block at the current position. This
Chris@2 477 * avoids reading the actual block data which can save time for large
Chris@2 478 * blocks.
Chris@2 479 *
Chris@2 480 * \param iterator A pointer to an existing initialized iterator.
Chris@2 481 * \assert
Chris@2 482 * \code iterator != NULL \endcode
Chris@2 483 * \a iterator has been successfully initialized with
Chris@2 484 * FLAC__metadata_simple_iterator_init()
Chris@2 485 * \retval FLAC__MetadataType
Chris@2 486 * The type of the metadata block at the current iterator position.
Chris@2 487 */
Chris@2 488 FLAC_API FLAC__MetadataType FLAC__metadata_simple_iterator_get_block_type(const FLAC__Metadata_SimpleIterator *iterator);
Chris@2 489
Chris@2 490 /** Get the length of the metadata block at the current position. This
Chris@2 491 * avoids reading the actual block data which can save time for large
Chris@2 492 * blocks.
Chris@2 493 *
Chris@2 494 * \param iterator A pointer to an existing initialized iterator.
Chris@2 495 * \assert
Chris@2 496 * \code iterator != NULL \endcode
Chris@2 497 * \a iterator has been successfully initialized with
Chris@2 498 * FLAC__metadata_simple_iterator_init()
Chris@2 499 * \retval unsigned
Chris@2 500 * The length of the metadata block at the current iterator position.
Chris@2 501 * The is same length as that in the
Chris@2 502 * <a href="http://flac.sourceforge.net/format.html#metadata_block_header">metadata block header</a>,
Chris@2 503 * i.e. the length of the metadata body that follows the header.
Chris@2 504 */
Chris@2 505 FLAC_API unsigned FLAC__metadata_simple_iterator_get_block_length(const FLAC__Metadata_SimpleIterator *iterator);
Chris@2 506
Chris@2 507 /** Get the application ID of the \c APPLICATION block at the current
Chris@2 508 * position. This avoids reading the actual block data which can save
Chris@2 509 * time for large blocks.
Chris@2 510 *
Chris@2 511 * \param iterator A pointer to an existing initialized iterator.
Chris@2 512 * \param id A pointer to a buffer of at least \c 4 bytes where
Chris@2 513 * the ID will be stored.
Chris@2 514 * \assert
Chris@2 515 * \code iterator != NULL \endcode
Chris@2 516 * \code id != NULL \endcode
Chris@2 517 * \a iterator has been successfully initialized with
Chris@2 518 * FLAC__metadata_simple_iterator_init()
Chris@2 519 * \retval FLAC__bool
Chris@2 520 * \c true if the ID was successfully read, else \c false, in which
Chris@2 521 * case you should check FLAC__metadata_simple_iterator_status() to
Chris@2 522 * find out why. If the status is
Chris@2 523 * \c FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ILLEGAL_INPUT, then the
Chris@2 524 * current metadata block is not an \c APPLICATION block. Otherwise
Chris@2 525 * if the status is
Chris@2 526 * \c FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR or
Chris@2 527 * \c FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR, an I/O error
Chris@2 528 * occurred and the iterator can no longer be used.
Chris@2 529 */
Chris@2 530 FLAC_API FLAC__bool FLAC__metadata_simple_iterator_get_application_id(FLAC__Metadata_SimpleIterator *iterator, FLAC__byte *id);
Chris@2 531
Chris@2 532 /** Get the metadata block at the current position. You can modify the
Chris@2 533 * block but must use FLAC__metadata_simple_iterator_set_block() to
Chris@2 534 * write it back to the FLAC file.
Chris@2 535 *
Chris@2 536 * You must call FLAC__metadata_object_delete() on the returned object
Chris@2 537 * when you are finished with it.
Chris@2 538 *
Chris@2 539 * \param iterator A pointer to an existing initialized iterator.
Chris@2 540 * \assert
Chris@2 541 * \code iterator != NULL \endcode
Chris@2 542 * \a iterator has been successfully initialized with
Chris@2 543 * FLAC__metadata_simple_iterator_init()
Chris@2 544 * \retval FLAC__StreamMetadata*
Chris@2 545 * The current metadata block, or \c NULL if there was a memory
Chris@2 546 * allocation error.
Chris@2 547 */
Chris@2 548 FLAC_API FLAC__StreamMetadata *FLAC__metadata_simple_iterator_get_block(FLAC__Metadata_SimpleIterator *iterator);
Chris@2 549
Chris@2 550 /** Write a block back to the FLAC file. This function tries to be
Chris@2 551 * as efficient as possible; how the block is actually written is
Chris@2 552 * shown by the following:
Chris@2 553 *
Chris@2 554 * Existing block is a STREAMINFO block and the new block is a
Chris@2 555 * STREAMINFO block: the new block is written in place. Make sure
Chris@2 556 * you know what you're doing when changing the values of a
Chris@2 557 * STREAMINFO block.
Chris@2 558 *
Chris@2 559 * Existing block is a STREAMINFO block and the new block is a
Chris@2 560 * not a STREAMINFO block: this is an error since the first block
Chris@2 561 * must be a STREAMINFO block. Returns \c false without altering the
Chris@2 562 * file.
Chris@2 563 *
Chris@2 564 * Existing block is not a STREAMINFO block and the new block is a
Chris@2 565 * STREAMINFO block: this is an error since there may be only one
Chris@2 566 * STREAMINFO block. Returns \c false without altering the file.
Chris@2 567 *
Chris@2 568 * Existing block and new block are the same length: the existing
Chris@2 569 * block will be replaced by the new block, written in place.
Chris@2 570 *
Chris@2 571 * Existing block is longer than new block: if use_padding is \c true,
Chris@2 572 * the existing block will be overwritten in place with the new
Chris@2 573 * block followed by a PADDING block, if possible, to make the total
Chris@2 574 * size the same as the existing block. Remember that a padding
Chris@2 575 * block requires at least four bytes so if the difference in size
Chris@2 576 * between the new block and existing block is less than that, the
Chris@2 577 * entire file will have to be rewritten, using the new block's
Chris@2 578 * exact size. If use_padding is \c false, the entire file will be
Chris@2 579 * rewritten, replacing the existing block by the new block.
Chris@2 580 *
Chris@2 581 * Existing block is shorter than new block: if use_padding is \c true,
Chris@2 582 * the function will try and expand the new block into the following
Chris@2 583 * PADDING block, if it exists and doing so won't shrink the PADDING
Chris@2 584 * block to less than 4 bytes. If there is no following PADDING
Chris@2 585 * block, or it will shrink to less than 4 bytes, or use_padding is
Chris@2 586 * \c false, the entire file is rewritten, replacing the existing block
Chris@2 587 * with the new block. Note that in this case any following PADDING
Chris@2 588 * block is preserved as is.
Chris@2 589 *
Chris@2 590 * After writing the block, the iterator will remain in the same
Chris@2 591 * place, i.e. pointing to the new block.
Chris@2 592 *
Chris@2 593 * \param iterator A pointer to an existing initialized iterator.
Chris@2 594 * \param block The block to set.
Chris@2 595 * \param use_padding See above.
Chris@2 596 * \assert
Chris@2 597 * \code iterator != NULL \endcode
Chris@2 598 * \a iterator has been successfully initialized with
Chris@2 599 * FLAC__metadata_simple_iterator_init()
Chris@2 600 * \code block != NULL \endcode
Chris@2 601 * \retval FLAC__bool
Chris@2 602 * \c true if successful, else \c false.
Chris@2 603 */
Chris@2 604 FLAC_API FLAC__bool FLAC__metadata_simple_iterator_set_block(FLAC__Metadata_SimpleIterator *iterator, FLAC__StreamMetadata *block, FLAC__bool use_padding);
Chris@2 605
Chris@2 606 /** This is similar to FLAC__metadata_simple_iterator_set_block()
Chris@2 607 * except that instead of writing over an existing block, it appends
Chris@2 608 * a block after the existing block. \a use_padding is again used to
Chris@2 609 * tell the function to try an expand into following padding in an
Chris@2 610 * attempt to avoid rewriting the entire file.
Chris@2 611 *
Chris@2 612 * This function will fail and return \c false if given a STREAMINFO
Chris@2 613 * block.
Chris@2 614 *
Chris@2 615 * After writing the block, the iterator will be pointing to the
Chris@2 616 * new block.
Chris@2 617 *
Chris@2 618 * \param iterator A pointer to an existing initialized iterator.
Chris@2 619 * \param block The block to set.
Chris@2 620 * \param use_padding See above.
Chris@2 621 * \assert
Chris@2 622 * \code iterator != NULL \endcode
Chris@2 623 * \a iterator has been successfully initialized with
Chris@2 624 * FLAC__metadata_simple_iterator_init()
Chris@2 625 * \code block != NULL \endcode
Chris@2 626 * \retval FLAC__bool
Chris@2 627 * \c true if successful, else \c false.
Chris@2 628 */
Chris@2 629 FLAC_API FLAC__bool FLAC__metadata_simple_iterator_insert_block_after(FLAC__Metadata_SimpleIterator *iterator, FLAC__StreamMetadata *block, FLAC__bool use_padding);
Chris@2 630
Chris@2 631 /** Deletes the block at the current position. This will cause the
Chris@2 632 * entire FLAC file to be rewritten, unless \a use_padding is \c true,
Chris@2 633 * in which case the block will be replaced by an equal-sized PADDING
Chris@2 634 * block. The iterator will be left pointing to the block before the
Chris@2 635 * one just deleted.
Chris@2 636 *
Chris@2 637 * You may not delete the STREAMINFO block.
Chris@2 638 *
Chris@2 639 * \param iterator A pointer to an existing initialized iterator.
Chris@2 640 * \param use_padding See above.
Chris@2 641 * \assert
Chris@2 642 * \code iterator != NULL \endcode
Chris@2 643 * \a iterator has been successfully initialized with
Chris@2 644 * FLAC__metadata_simple_iterator_init()
Chris@2 645 * \retval FLAC__bool
Chris@2 646 * \c true if successful, else \c false.
Chris@2 647 */
Chris@2 648 FLAC_API FLAC__bool FLAC__metadata_simple_iterator_delete_block(FLAC__Metadata_SimpleIterator *iterator, FLAC__bool use_padding);
Chris@2 649
Chris@2 650 /* \} */
Chris@2 651
Chris@2 652
Chris@2 653 /** \defgroup flac_metadata_level2 FLAC/metadata.h: metadata level 2 interface
Chris@2 654 * \ingroup flac_metadata
Chris@2 655 *
Chris@2 656 * \brief
Chris@2 657 * The level 2 interface provides read-write access to FLAC file metadata;
Chris@2 658 * all metadata is read into memory, operated on in memory, and then written
Chris@2 659 * to file, which is more efficient than level 1 when editing multiple blocks.
Chris@2 660 *
Chris@2 661 * Currently Ogg FLAC is supported for read only, via
Chris@2 662 * FLAC__metadata_chain_read_ogg() but a subsequent
Chris@2 663 * FLAC__metadata_chain_write() will fail.
Chris@2 664 *
Chris@2 665 * The general usage of this interface is:
Chris@2 666 *
Chris@2 667 * - Create a new chain using FLAC__metadata_chain_new(). A chain is a
Chris@2 668 * linked list of FLAC metadata blocks.
Chris@2 669 * - Read all metadata into the the chain from a FLAC file using
Chris@2 670 * FLAC__metadata_chain_read() or FLAC__metadata_chain_read_ogg() and
Chris@2 671 * check the status.
Chris@2 672 * - Optionally, consolidate the padding using
Chris@2 673 * FLAC__metadata_chain_merge_padding() or
Chris@2 674 * FLAC__metadata_chain_sort_padding().
Chris@2 675 * - Create a new iterator using FLAC__metadata_iterator_new()
Chris@2 676 * - Initialize the iterator to point to the first element in the chain
Chris@2 677 * using FLAC__metadata_iterator_init()
Chris@2 678 * - Traverse the chain using FLAC__metadata_iterator_next and
Chris@2 679 * FLAC__metadata_iterator_prev().
Chris@2 680 * - Get a block for reading or modification using
Chris@2 681 * FLAC__metadata_iterator_get_block(). The pointer to the object
Chris@2 682 * inside the chain is returned, so the block is yours to modify.
Chris@2 683 * Changes will be reflected in the FLAC file when you write the
Chris@2 684 * chain. You can also add and delete blocks (see functions below).
Chris@2 685 * - When done, write out the chain using FLAC__metadata_chain_write().
Chris@2 686 * Make sure to read the whole comment to the function below.
Chris@2 687 * - Delete the chain using FLAC__metadata_chain_delete().
Chris@2 688 *
Chris@2 689 * \note
Chris@2 690 * Even though the FLAC file is not open while the chain is being
Chris@2 691 * manipulated, you must not alter the file externally during
Chris@2 692 * this time. The chain assumes the FLAC file will not change
Chris@2 693 * between the time of FLAC__metadata_chain_read()/FLAC__metadata_chain_read_ogg()
Chris@2 694 * and FLAC__metadata_chain_write().
Chris@2 695 *
Chris@2 696 * \note
Chris@2 697 * Do not modify the is_last, length, or type fields of returned
Chris@2 698 * FLAC__StreamMetadata objects. These are managed automatically.
Chris@2 699 *
Chris@2 700 * \note
Chris@2 701 * The metadata objects returned by FLAC__metadata_iterator_get_block()
Chris@2 702 * are owned by the chain; do not FLAC__metadata_object_delete() them.
Chris@2 703 * In the same way, blocks passed to FLAC__metadata_iterator_set_block()
Chris@2 704 * become owned by the chain and they will be deleted when the chain is
Chris@2 705 * deleted.
Chris@2 706 *
Chris@2 707 * \{
Chris@2 708 */
Chris@2 709
Chris@2 710 struct FLAC__Metadata_Chain;
Chris@2 711 /** The opaque structure definition for the level 2 chain type.
Chris@2 712 */
Chris@2 713 typedef struct FLAC__Metadata_Chain FLAC__Metadata_Chain;
Chris@2 714
Chris@2 715 struct FLAC__Metadata_Iterator;
Chris@2 716 /** The opaque structure definition for the level 2 iterator type.
Chris@2 717 */
Chris@2 718 typedef struct FLAC__Metadata_Iterator FLAC__Metadata_Iterator;
Chris@2 719
Chris@2 720 typedef enum {
Chris@2 721 FLAC__METADATA_CHAIN_STATUS_OK = 0,
Chris@2 722 /**< The chain is in the normal OK state */
Chris@2 723
Chris@2 724 FLAC__METADATA_CHAIN_STATUS_ILLEGAL_INPUT,
Chris@2 725 /**< The data passed into a function violated the function's usage criteria */
Chris@2 726
Chris@2 727 FLAC__METADATA_CHAIN_STATUS_ERROR_OPENING_FILE,
Chris@2 728 /**< The chain could not open the target file */
Chris@2 729
Chris@2 730 FLAC__METADATA_CHAIN_STATUS_NOT_A_FLAC_FILE,
Chris@2 731 /**< The chain could not find the FLAC signature at the start of the file */
Chris@2 732
Chris@2 733 FLAC__METADATA_CHAIN_STATUS_NOT_WRITABLE,
Chris@2 734 /**< The chain tried to write to a file that was not writable */
Chris@2 735
Chris@2 736 FLAC__METADATA_CHAIN_STATUS_BAD_METADATA,
Chris@2 737 /**< The chain encountered input that does not conform to the FLAC metadata specification */
Chris@2 738
Chris@2 739 FLAC__METADATA_CHAIN_STATUS_READ_ERROR,
Chris@2 740 /**< The chain encountered an error while reading the FLAC file */
Chris@2 741
Chris@2 742 FLAC__METADATA_CHAIN_STATUS_SEEK_ERROR,
Chris@2 743 /**< The chain encountered an error while seeking in the FLAC file */
Chris@2 744
Chris@2 745 FLAC__METADATA_CHAIN_STATUS_WRITE_ERROR,
Chris@2 746 /**< The chain encountered an error while writing the FLAC file */
Chris@2 747
Chris@2 748 FLAC__METADATA_CHAIN_STATUS_RENAME_ERROR,
Chris@2 749 /**< The chain encountered an error renaming the FLAC file */
Chris@2 750
Chris@2 751 FLAC__METADATA_CHAIN_STATUS_UNLINK_ERROR,
Chris@2 752 /**< The chain encountered an error removing the temporary file */
Chris@2 753
Chris@2 754 FLAC__METADATA_CHAIN_STATUS_MEMORY_ALLOCATION_ERROR,
Chris@2 755 /**< Memory allocation failed */
Chris@2 756
Chris@2 757 FLAC__METADATA_CHAIN_STATUS_INTERNAL_ERROR,
Chris@2 758 /**< The caller violated an assertion or an unexpected error occurred */
Chris@2 759
Chris@2 760 FLAC__METADATA_CHAIN_STATUS_INVALID_CALLBACKS,
Chris@2 761 /**< One or more of the required callbacks was NULL */
Chris@2 762
Chris@2 763 FLAC__METADATA_CHAIN_STATUS_READ_WRITE_MISMATCH,
Chris@2 764 /**< FLAC__metadata_chain_write() was called on a chain read by
Chris@2 765 * FLAC__metadata_chain_read_with_callbacks()/FLAC__metadata_chain_read_ogg_with_callbacks(),
Chris@2 766 * or
Chris@2 767 * FLAC__metadata_chain_write_with_callbacks()/FLAC__metadata_chain_write_with_callbacks_and_tempfile()
Chris@2 768 * was called on a chain read by
Chris@2 769 * FLAC__metadata_chain_read()/FLAC__metadata_chain_read_ogg().
Chris@2 770 * Matching read/write methods must always be used. */
Chris@2 771
Chris@2 772 FLAC__METADATA_CHAIN_STATUS_WRONG_WRITE_CALL
Chris@2 773 /**< FLAC__metadata_chain_write_with_callbacks() was called when the
Chris@2 774 * chain write requires a tempfile; use
Chris@2 775 * FLAC__metadata_chain_write_with_callbacks_and_tempfile() instead.
Chris@2 776 * Or, FLAC__metadata_chain_write_with_callbacks_and_tempfile() was
Chris@2 777 * called when the chain write does not require a tempfile; use
Chris@2 778 * FLAC__metadata_chain_write_with_callbacks() instead.
Chris@2 779 * Always check FLAC__metadata_chain_check_if_tempfile_needed()
Chris@2 780 * before writing via callbacks. */
Chris@2 781
Chris@2 782 } FLAC__Metadata_ChainStatus;
Chris@2 783
Chris@2 784 /** Maps a FLAC__Metadata_ChainStatus to a C string.
Chris@2 785 *
Chris@2 786 * Using a FLAC__Metadata_ChainStatus as the index to this array
Chris@2 787 * will give the string equivalent. The contents should not be modified.
Chris@2 788 */
Chris@2 789 extern FLAC_API const char * const FLAC__Metadata_ChainStatusString[];
Chris@2 790
Chris@2 791 /*********** FLAC__Metadata_Chain ***********/
Chris@2 792
Chris@2 793 /** Create a new chain instance.
Chris@2 794 *
Chris@2 795 * \retval FLAC__Metadata_Chain*
Chris@2 796 * \c NULL if there was an error allocating memory, else the new instance.
Chris@2 797 */
Chris@2 798 FLAC_API FLAC__Metadata_Chain *FLAC__metadata_chain_new(void);
Chris@2 799
Chris@2 800 /** Free a chain instance. Deletes the object pointed to by \a chain.
Chris@2 801 *
Chris@2 802 * \param chain A pointer to an existing chain.
Chris@2 803 * \assert
Chris@2 804 * \code chain != NULL \endcode
Chris@2 805 */
Chris@2 806 FLAC_API void FLAC__metadata_chain_delete(FLAC__Metadata_Chain *chain);
Chris@2 807
Chris@2 808 /** Get the current status of the chain. Call this after a function
Chris@2 809 * returns \c false to get the reason for the error. Also resets the
Chris@2 810 * status to FLAC__METADATA_CHAIN_STATUS_OK.
Chris@2 811 *
Chris@2 812 * \param chain A pointer to an existing chain.
Chris@2 813 * \assert
Chris@2 814 * \code chain != NULL \endcode
Chris@2 815 * \retval FLAC__Metadata_ChainStatus
Chris@2 816 * The current status of the chain.
Chris@2 817 */
Chris@2 818 FLAC_API FLAC__Metadata_ChainStatus FLAC__metadata_chain_status(FLAC__Metadata_Chain *chain);
Chris@2 819
Chris@2 820 /** Read all metadata from a FLAC file into the chain.
Chris@2 821 *
Chris@2 822 * \param chain A pointer to an existing chain.
Chris@2 823 * \param filename The path to the FLAC file to read.
Chris@2 824 * \assert
Chris@2 825 * \code chain != NULL \endcode
Chris@2 826 * \code filename != NULL \endcode
Chris@2 827 * \retval FLAC__bool
Chris@2 828 * \c true if a valid list of metadata blocks was read from
Chris@2 829 * \a filename, else \c false. On failure, check the status with
Chris@2 830 * FLAC__metadata_chain_status().
Chris@2 831 */
Chris@2 832 FLAC_API FLAC__bool FLAC__metadata_chain_read(FLAC__Metadata_Chain *chain, const char *filename);
Chris@2 833
Chris@2 834 /** Read all metadata from an Ogg FLAC file into the chain.
Chris@2 835 *
Chris@2 836 * \note Ogg FLAC metadata data writing is not supported yet and
Chris@2 837 * FLAC__metadata_chain_write() will fail.
Chris@2 838 *
Chris@2 839 * \param chain A pointer to an existing chain.
Chris@2 840 * \param filename The path to the Ogg FLAC file to read.
Chris@2 841 * \assert
Chris@2 842 * \code chain != NULL \endcode
Chris@2 843 * \code filename != NULL \endcode
Chris@2 844 * \retval FLAC__bool
Chris@2 845 * \c true if a valid list of metadata blocks was read from
Chris@2 846 * \a filename, else \c false. On failure, check the status with
Chris@2 847 * FLAC__metadata_chain_status().
Chris@2 848 */
Chris@2 849 FLAC_API FLAC__bool FLAC__metadata_chain_read_ogg(FLAC__Metadata_Chain *chain, const char *filename);
Chris@2 850
Chris@2 851 /** Read all metadata from a FLAC stream into the chain via I/O callbacks.
Chris@2 852 *
Chris@2 853 * The \a handle need only be open for reading, but must be seekable.
Chris@2 854 * The equivalent minimum stdio fopen() file mode is \c "r" (or \c "rb"
Chris@2 855 * for Windows).
Chris@2 856 *
Chris@2 857 * \param chain A pointer to an existing chain.
Chris@2 858 * \param handle The I/O handle of the FLAC stream to read. The
Chris@2 859 * handle will NOT be closed after the metadata is read;
Chris@2 860 * that is the duty of the caller.
Chris@2 861 * \param callbacks
Chris@2 862 * A set of callbacks to use for I/O. The mandatory
Chris@2 863 * callbacks are \a read, \a seek, and \a tell.
Chris@2 864 * \assert
Chris@2 865 * \code chain != NULL \endcode
Chris@2 866 * \retval FLAC__bool
Chris@2 867 * \c true if a valid list of metadata blocks was read from
Chris@2 868 * \a handle, else \c false. On failure, check the status with
Chris@2 869 * FLAC__metadata_chain_status().
Chris@2 870 */
Chris@2 871 FLAC_API FLAC__bool FLAC__metadata_chain_read_with_callbacks(FLAC__Metadata_Chain *chain, FLAC__IOHandle handle, FLAC__IOCallbacks callbacks);
Chris@2 872
Chris@2 873 /** Read all metadata from an Ogg FLAC stream into the chain via I/O callbacks.
Chris@2 874 *
Chris@2 875 * The \a handle need only be open for reading, but must be seekable.
Chris@2 876 * The equivalent minimum stdio fopen() file mode is \c "r" (or \c "rb"
Chris@2 877 * for Windows).
Chris@2 878 *
Chris@2 879 * \note Ogg FLAC metadata data writing is not supported yet and
Chris@2 880 * FLAC__metadata_chain_write() will fail.
Chris@2 881 *
Chris@2 882 * \param chain A pointer to an existing chain.
Chris@2 883 * \param handle The I/O handle of the Ogg FLAC stream to read. The
Chris@2 884 * handle will NOT be closed after the metadata is read;
Chris@2 885 * that is the duty of the caller.
Chris@2 886 * \param callbacks
Chris@2 887 * A set of callbacks to use for I/O. The mandatory
Chris@2 888 * callbacks are \a read, \a seek, and \a tell.
Chris@2 889 * \assert
Chris@2 890 * \code chain != NULL \endcode
Chris@2 891 * \retval FLAC__bool
Chris@2 892 * \c true if a valid list of metadata blocks was read from
Chris@2 893 * \a handle, else \c false. On failure, check the status with
Chris@2 894 * FLAC__metadata_chain_status().
Chris@2 895 */
Chris@2 896 FLAC_API FLAC__bool FLAC__metadata_chain_read_ogg_with_callbacks(FLAC__Metadata_Chain *chain, FLAC__IOHandle handle, FLAC__IOCallbacks callbacks);
Chris@2 897
Chris@2 898 /** Checks if writing the given chain would require the use of a
Chris@2 899 * temporary file, or if it could be written in place.
Chris@2 900 *
Chris@2 901 * Under certain conditions, padding can be utilized so that writing
Chris@2 902 * edited metadata back to the FLAC file does not require rewriting the
Chris@2 903 * entire file. If rewriting is required, then a temporary workfile is
Chris@2 904 * required. When writing metadata using callbacks, you must check
Chris@2 905 * this function to know whether to call
Chris@2 906 * FLAC__metadata_chain_write_with_callbacks() or
Chris@2 907 * FLAC__metadata_chain_write_with_callbacks_and_tempfile(). When
Chris@2 908 * writing with FLAC__metadata_chain_write(), the temporary file is
Chris@2 909 * handled internally.
Chris@2 910 *
Chris@2 911 * \param chain A pointer to an existing chain.
Chris@2 912 * \param use_padding
Chris@2 913 * Whether or not padding will be allowed to be used
Chris@2 914 * during the write. The value of \a use_padding given
Chris@2 915 * here must match the value later passed to
Chris@2 916 * FLAC__metadata_chain_write_with_callbacks() or
Chris@2 917 * FLAC__metadata_chain_write_with_callbacks_with_tempfile().
Chris@2 918 * \assert
Chris@2 919 * \code chain != NULL \endcode
Chris@2 920 * \retval FLAC__bool
Chris@2 921 * \c true if writing the current chain would require a tempfile, or
Chris@2 922 * \c false if metadata can be written in place.
Chris@2 923 */
Chris@2 924 FLAC_API FLAC__bool FLAC__metadata_chain_check_if_tempfile_needed(FLAC__Metadata_Chain *chain, FLAC__bool use_padding);
Chris@2 925
Chris@2 926 /** Write all metadata out to the FLAC file. This function tries to be as
Chris@2 927 * efficient as possible; how the metadata is actually written is shown by
Chris@2 928 * the following:
Chris@2 929 *
Chris@2 930 * If the current chain is the same size as the existing metadata, the new
Chris@2 931 * data is written in place.
Chris@2 932 *
Chris@2 933 * If the current chain is longer than the existing metadata, and
Chris@2 934 * \a use_padding is \c true, and the last block is a PADDING block of
Chris@2 935 * sufficient length, the function will truncate the final padding block
Chris@2 936 * so that the overall size of the metadata is the same as the existing
Chris@2 937 * metadata, and then just rewrite the metadata. Otherwise, if not all of
Chris@2 938 * the above conditions are met, the entire FLAC file must be rewritten.
Chris@2 939 * If you want to use padding this way it is a good idea to call
Chris@2 940 * FLAC__metadata_chain_sort_padding() first so that you have the maximum
Chris@2 941 * amount of padding to work with, unless you need to preserve ordering
Chris@2 942 * of the PADDING blocks for some reason.
Chris@2 943 *
Chris@2 944 * If the current chain is shorter than the existing metadata, and
Chris@2 945 * \a use_padding is \c true, and the final block is a PADDING block, the padding
Chris@2 946 * is extended to make the overall size the same as the existing data. If
Chris@2 947 * \a use_padding is \c true and the last block is not a PADDING block, a new
Chris@2 948 * PADDING block is added to the end of the new data to make it the same
Chris@2 949 * size as the existing data (if possible, see the note to
Chris@2 950 * FLAC__metadata_simple_iterator_set_block() about the four byte limit)
Chris@2 951 * and the new data is written in place. If none of the above apply or
Chris@2 952 * \a use_padding is \c false, the entire FLAC file is rewritten.
Chris@2 953 *
Chris@2 954 * If \a preserve_file_stats is \c true, the owner and modification time will
Chris@2 955 * be preserved even if the FLAC file is written.
Chris@2 956 *
Chris@2 957 * For this write function to be used, the chain must have been read with
Chris@2 958 * FLAC__metadata_chain_read()/FLAC__metadata_chain_read_ogg(), not
Chris@2 959 * FLAC__metadata_chain_read_with_callbacks()/FLAC__metadata_chain_read_ogg_with_callbacks().
Chris@2 960 *
Chris@2 961 * \param chain A pointer to an existing chain.
Chris@2 962 * \param use_padding See above.
Chris@2 963 * \param preserve_file_stats See above.
Chris@2 964 * \assert
Chris@2 965 * \code chain != NULL \endcode
Chris@2 966 * \retval FLAC__bool
Chris@2 967 * \c true if the write succeeded, else \c false. On failure,
Chris@2 968 * check the status with FLAC__metadata_chain_status().
Chris@2 969 */
Chris@2 970 FLAC_API FLAC__bool FLAC__metadata_chain_write(FLAC__Metadata_Chain *chain, FLAC__bool use_padding, FLAC__bool preserve_file_stats);
Chris@2 971
Chris@2 972 /** Write all metadata out to a FLAC stream via callbacks.
Chris@2 973 *
Chris@2 974 * (See FLAC__metadata_chain_write() for the details on how padding is
Chris@2 975 * used to write metadata in place if possible.)
Chris@2 976 *
Chris@2 977 * The \a handle must be open for updating and be seekable. The
Chris@2 978 * equivalent minimum stdio fopen() file mode is \c "r+" (or \c "r+b"
Chris@2 979 * for Windows).
Chris@2 980 *
Chris@2 981 * For this write function to be used, the chain must have been read with
Chris@2 982 * FLAC__metadata_chain_read_with_callbacks()/FLAC__metadata_chain_read_ogg_with_callbacks(),
Chris@2 983 * not FLAC__metadata_chain_read()/FLAC__metadata_chain_read_ogg().
Chris@2 984 * Also, FLAC__metadata_chain_check_if_tempfile_needed() must have returned
Chris@2 985 * \c false.
Chris@2 986 *
Chris@2 987 * \param chain A pointer to an existing chain.
Chris@2 988 * \param use_padding See FLAC__metadata_chain_write()
Chris@2 989 * \param handle The I/O handle of the FLAC stream to write. The
Chris@2 990 * handle will NOT be closed after the metadata is
Chris@2 991 * written; that is the duty of the caller.
Chris@2 992 * \param callbacks A set of callbacks to use for I/O. The mandatory
Chris@2 993 * callbacks are \a write and \a seek.
Chris@2 994 * \assert
Chris@2 995 * \code chain != NULL \endcode
Chris@2 996 * \retval FLAC__bool
Chris@2 997 * \c true if the write succeeded, else \c false. On failure,
Chris@2 998 * check the status with FLAC__metadata_chain_status().
Chris@2 999 */
Chris@2 1000 FLAC_API FLAC__bool FLAC__metadata_chain_write_with_callbacks(FLAC__Metadata_Chain *chain, FLAC__bool use_padding, FLAC__IOHandle handle, FLAC__IOCallbacks callbacks);
Chris@2 1001
Chris@2 1002 /** Write all metadata out to a FLAC stream via callbacks.
Chris@2 1003 *
Chris@2 1004 * (See FLAC__metadata_chain_write() for the details on how padding is
Chris@2 1005 * used to write metadata in place if possible.)
Chris@2 1006 *
Chris@2 1007 * This version of the write-with-callbacks function must be used when
Chris@2 1008 * FLAC__metadata_chain_check_if_tempfile_needed() returns true. In
Chris@2 1009 * this function, you must supply an I/O handle corresponding to the
Chris@2 1010 * FLAC file to edit, and a temporary handle to which the new FLAC
Chris@2 1011 * file will be written. It is the caller's job to move this temporary
Chris@2 1012 * FLAC file on top of the original FLAC file to complete the metadata
Chris@2 1013 * edit.
Chris@2 1014 *
Chris@2 1015 * The \a handle must be open for reading and be seekable. The
Chris@2 1016 * equivalent minimum stdio fopen() file mode is \c "r" (or \c "rb"
Chris@2 1017 * for Windows).
Chris@2 1018 *
Chris@2 1019 * The \a temp_handle must be open for writing. The
Chris@2 1020 * equivalent minimum stdio fopen() file mode is \c "w" (or \c "wb"
Chris@2 1021 * for Windows). It should be an empty stream, or at least positioned
Chris@2 1022 * at the start-of-file (in which case it is the caller's duty to
Chris@2 1023 * truncate it on return).
Chris@2 1024 *
Chris@2 1025 * For this write function to be used, the chain must have been read with
Chris@2 1026 * FLAC__metadata_chain_read_with_callbacks()/FLAC__metadata_chain_read_ogg_with_callbacks(),
Chris@2 1027 * not FLAC__metadata_chain_read()/FLAC__metadata_chain_read_ogg().
Chris@2 1028 * Also, FLAC__metadata_chain_check_if_tempfile_needed() must have returned
Chris@2 1029 * \c true.
Chris@2 1030 *
Chris@2 1031 * \param chain A pointer to an existing chain.
Chris@2 1032 * \param use_padding See FLAC__metadata_chain_write()
Chris@2 1033 * \param handle The I/O handle of the original FLAC stream to read.
Chris@2 1034 * The handle will NOT be closed after the metadata is
Chris@2 1035 * written; that is the duty of the caller.
Chris@2 1036 * \param callbacks A set of callbacks to use for I/O on \a handle.
Chris@2 1037 * The mandatory callbacks are \a read, \a seek, and
Chris@2 1038 * \a eof.
Chris@2 1039 * \param temp_handle The I/O handle of the FLAC stream to write. The
Chris@2 1040 * handle will NOT be closed after the metadata is
Chris@2 1041 * written; that is the duty of the caller.
Chris@2 1042 * \param temp_callbacks
Chris@2 1043 * A set of callbacks to use for I/O on temp_handle.
Chris@2 1044 * The only mandatory callback is \a write.
Chris@2 1045 * \assert
Chris@2 1046 * \code chain != NULL \endcode
Chris@2 1047 * \retval FLAC__bool
Chris@2 1048 * \c true if the write succeeded, else \c false. On failure,
Chris@2 1049 * check the status with FLAC__metadata_chain_status().
Chris@2 1050 */
Chris@2 1051 FLAC_API FLAC__bool FLAC__metadata_chain_write_with_callbacks_and_tempfile(FLAC__Metadata_Chain *chain, FLAC__bool use_padding, FLAC__IOHandle handle, FLAC__IOCallbacks callbacks, FLAC__IOHandle temp_handle, FLAC__IOCallbacks temp_callbacks);
Chris@2 1052
Chris@2 1053 /** Merge adjacent PADDING blocks into a single block.
Chris@2 1054 *
Chris@2 1055 * \note This function does not write to the FLAC file, it only
Chris@2 1056 * modifies the chain.
Chris@2 1057 *
Chris@2 1058 * \warning Any iterator on the current chain will become invalid after this
Chris@2 1059 * call. You should delete the iterator and get a new one.
Chris@2 1060 *
Chris@2 1061 * \param chain A pointer to an existing chain.
Chris@2 1062 * \assert
Chris@2 1063 * \code chain != NULL \endcode
Chris@2 1064 */
Chris@2 1065 FLAC_API void FLAC__metadata_chain_merge_padding(FLAC__Metadata_Chain *chain);
Chris@2 1066
Chris@2 1067 /** This function will move all PADDING blocks to the end on the metadata,
Chris@2 1068 * then merge them into a single block.
Chris@2 1069 *
Chris@2 1070 * \note This function does not write to the FLAC file, it only
Chris@2 1071 * modifies the chain.
Chris@2 1072 *
Chris@2 1073 * \warning Any iterator on the current chain will become invalid after this
Chris@2 1074 * call. You should delete the iterator and get a new one.
Chris@2 1075 *
Chris@2 1076 * \param chain A pointer to an existing chain.
Chris@2 1077 * \assert
Chris@2 1078 * \code chain != NULL \endcode
Chris@2 1079 */
Chris@2 1080 FLAC_API void FLAC__metadata_chain_sort_padding(FLAC__Metadata_Chain *chain);
Chris@2 1081
Chris@2 1082
Chris@2 1083 /*********** FLAC__Metadata_Iterator ***********/
Chris@2 1084
Chris@2 1085 /** Create a new iterator instance.
Chris@2 1086 *
Chris@2 1087 * \retval FLAC__Metadata_Iterator*
Chris@2 1088 * \c NULL if there was an error allocating memory, else the new instance.
Chris@2 1089 */
Chris@2 1090 FLAC_API FLAC__Metadata_Iterator *FLAC__metadata_iterator_new(void);
Chris@2 1091
Chris@2 1092 /** Free an iterator instance. Deletes the object pointed to by \a iterator.
Chris@2 1093 *
Chris@2 1094 * \param iterator A pointer to an existing iterator.
Chris@2 1095 * \assert
Chris@2 1096 * \code iterator != NULL \endcode
Chris@2 1097 */
Chris@2 1098 FLAC_API void FLAC__metadata_iterator_delete(FLAC__Metadata_Iterator *iterator);
Chris@2 1099
Chris@2 1100 /** Initialize the iterator to point to the first metadata block in the
Chris@2 1101 * given chain.
Chris@2 1102 *
Chris@2 1103 * \param iterator A pointer to an existing iterator.
Chris@2 1104 * \param chain A pointer to an existing and initialized (read) chain.
Chris@2 1105 * \assert
Chris@2 1106 * \code iterator != NULL \endcode
Chris@2 1107 * \code chain != NULL \endcode
Chris@2 1108 */
Chris@2 1109 FLAC_API void FLAC__metadata_iterator_init(FLAC__Metadata_Iterator *iterator, FLAC__Metadata_Chain *chain);
Chris@2 1110
Chris@2 1111 /** Moves the iterator forward one metadata block, returning \c false if
Chris@2 1112 * already at the end.
Chris@2 1113 *
Chris@2 1114 * \param iterator A pointer to an existing initialized iterator.
Chris@2 1115 * \assert
Chris@2 1116 * \code iterator != NULL \endcode
Chris@2 1117 * \a iterator has been successfully initialized with
Chris@2 1118 * FLAC__metadata_iterator_init()
Chris@2 1119 * \retval FLAC__bool
Chris@2 1120 * \c false if already at the last metadata block of the chain, else
Chris@2 1121 * \c true.
Chris@2 1122 */
Chris@2 1123 FLAC_API FLAC__bool FLAC__metadata_iterator_next(FLAC__Metadata_Iterator *iterator);
Chris@2 1124
Chris@2 1125 /** Moves the iterator backward one metadata block, returning \c false if
Chris@2 1126 * already at the beginning.
Chris@2 1127 *
Chris@2 1128 * \param iterator A pointer to an existing initialized iterator.
Chris@2 1129 * \assert
Chris@2 1130 * \code iterator != NULL \endcode
Chris@2 1131 * \a iterator has been successfully initialized with
Chris@2 1132 * FLAC__metadata_iterator_init()
Chris@2 1133 * \retval FLAC__bool
Chris@2 1134 * \c false if already at the first metadata block of the chain, else
Chris@2 1135 * \c true.
Chris@2 1136 */
Chris@2 1137 FLAC_API FLAC__bool FLAC__metadata_iterator_prev(FLAC__Metadata_Iterator *iterator);
Chris@2 1138
Chris@2 1139 /** Get the type of the metadata block at the current position.
Chris@2 1140 *
Chris@2 1141 * \param iterator A pointer to an existing initialized iterator.
Chris@2 1142 * \assert
Chris@2 1143 * \code iterator != NULL \endcode
Chris@2 1144 * \a iterator has been successfully initialized with
Chris@2 1145 * FLAC__metadata_iterator_init()
Chris@2 1146 * \retval FLAC__MetadataType
Chris@2 1147 * The type of the metadata block at the current iterator position.
Chris@2 1148 */
Chris@2 1149 FLAC_API FLAC__MetadataType FLAC__metadata_iterator_get_block_type(const FLAC__Metadata_Iterator *iterator);
Chris@2 1150
Chris@2 1151 /** Get the metadata block at the current position. You can modify
Chris@2 1152 * the block in place but must write the chain before the changes
Chris@2 1153 * are reflected to the FLAC file. You do not need to call
Chris@2 1154 * FLAC__metadata_iterator_set_block() to reflect the changes;
Chris@2 1155 * the pointer returned by FLAC__metadata_iterator_get_block()
Chris@2 1156 * points directly into the chain.
Chris@2 1157 *
Chris@2 1158 * \warning
Chris@2 1159 * Do not call FLAC__metadata_object_delete() on the returned object;
Chris@2 1160 * to delete a block use FLAC__metadata_iterator_delete_block().
Chris@2 1161 *
Chris@2 1162 * \param iterator A pointer to an existing initialized iterator.
Chris@2 1163 * \assert
Chris@2 1164 * \code iterator != NULL \endcode
Chris@2 1165 * \a iterator has been successfully initialized with
Chris@2 1166 * FLAC__metadata_iterator_init()
Chris@2 1167 * \retval FLAC__StreamMetadata*
Chris@2 1168 * The current metadata block.
Chris@2 1169 */
Chris@2 1170 FLAC_API FLAC__StreamMetadata *FLAC__metadata_iterator_get_block(FLAC__Metadata_Iterator *iterator);
Chris@2 1171
Chris@2 1172 /** Set the metadata block at the current position, replacing the existing
Chris@2 1173 * block. The new block passed in becomes owned by the chain and it will be
Chris@2 1174 * deleted when the chain is deleted.
Chris@2 1175 *
Chris@2 1176 * \param iterator A pointer to an existing initialized iterator.
Chris@2 1177 * \param block A pointer to a metadata block.
Chris@2 1178 * \assert
Chris@2 1179 * \code iterator != NULL \endcode
Chris@2 1180 * \a iterator has been successfully initialized with
Chris@2 1181 * FLAC__metadata_iterator_init()
Chris@2 1182 * \code block != NULL \endcode
Chris@2 1183 * \retval FLAC__bool
Chris@2 1184 * \c false if the conditions in the above description are not met, or
Chris@2 1185 * a memory allocation error occurs, otherwise \c true.
Chris@2 1186 */
Chris@2 1187 FLAC_API FLAC__bool FLAC__metadata_iterator_set_block(FLAC__Metadata_Iterator *iterator, FLAC__StreamMetadata *block);
Chris@2 1188
Chris@2 1189 /** Removes the current block from the chain. If \a replace_with_padding is
Chris@2 1190 * \c true, the block will instead be replaced with a padding block of equal
Chris@2 1191 * size. You can not delete the STREAMINFO block. The iterator will be
Chris@2 1192 * left pointing to the block before the one just "deleted", even if
Chris@2 1193 * \a replace_with_padding is \c true.
Chris@2 1194 *
Chris@2 1195 * \param iterator A pointer to an existing initialized iterator.
Chris@2 1196 * \param replace_with_padding See above.
Chris@2 1197 * \assert
Chris@2 1198 * \code iterator != NULL \endcode
Chris@2 1199 * \a iterator has been successfully initialized with
Chris@2 1200 * FLAC__metadata_iterator_init()
Chris@2 1201 * \retval FLAC__bool
Chris@2 1202 * \c false if the conditions in the above description are not met,
Chris@2 1203 * otherwise \c true.
Chris@2 1204 */
Chris@2 1205 FLAC_API FLAC__bool FLAC__metadata_iterator_delete_block(FLAC__Metadata_Iterator *iterator, FLAC__bool replace_with_padding);
Chris@2 1206
Chris@2 1207 /** Insert a new block before the current block. You cannot insert a block
Chris@2 1208 * before the first STREAMINFO block. You cannot insert a STREAMINFO block
Chris@2 1209 * as there can be only one, the one that already exists at the head when you
Chris@2 1210 * read in a chain. The chain takes ownership of the new block and it will be
Chris@2 1211 * deleted when the chain is deleted. The iterator will be left pointing to
Chris@2 1212 * the new block.
Chris@2 1213 *
Chris@2 1214 * \param iterator A pointer to an existing initialized iterator.
Chris@2 1215 * \param block A pointer to a metadata block to insert.
Chris@2 1216 * \assert
Chris@2 1217 * \code iterator != NULL \endcode
Chris@2 1218 * \a iterator has been successfully initialized with
Chris@2 1219 * FLAC__metadata_iterator_init()
Chris@2 1220 * \retval FLAC__bool
Chris@2 1221 * \c false if the conditions in the above description are not met, or
Chris@2 1222 * a memory allocation error occurs, otherwise \c true.
Chris@2 1223 */
Chris@2 1224 FLAC_API FLAC__bool FLAC__metadata_iterator_insert_block_before(FLAC__Metadata_Iterator *iterator, FLAC__StreamMetadata *block);
Chris@2 1225
Chris@2 1226 /** Insert a new block after the current block. You cannot insert a STREAMINFO
Chris@2 1227 * block as there can be only one, the one that already exists at the head when
Chris@2 1228 * you read in a chain. The chain takes ownership of the new block and it will
Chris@2 1229 * be deleted when the chain is deleted. The iterator will be left pointing to
Chris@2 1230 * the new block.
Chris@2 1231 *
Chris@2 1232 * \param iterator A pointer to an existing initialized iterator.
Chris@2 1233 * \param block A pointer to a metadata block to insert.
Chris@2 1234 * \assert
Chris@2 1235 * \code iterator != NULL \endcode
Chris@2 1236 * \a iterator has been successfully initialized with
Chris@2 1237 * FLAC__metadata_iterator_init()
Chris@2 1238 * \retval FLAC__bool
Chris@2 1239 * \c false if the conditions in the above description are not met, or
Chris@2 1240 * a memory allocation error occurs, otherwise \c true.
Chris@2 1241 */
Chris@2 1242 FLAC_API FLAC__bool FLAC__metadata_iterator_insert_block_after(FLAC__Metadata_Iterator *iterator, FLAC__StreamMetadata *block);
Chris@2 1243
Chris@2 1244 /* \} */
Chris@2 1245
Chris@2 1246
Chris@2 1247 /** \defgroup flac_metadata_object FLAC/metadata.h: metadata object methods
Chris@2 1248 * \ingroup flac_metadata
Chris@2 1249 *
Chris@2 1250 * \brief
Chris@2 1251 * This module contains methods for manipulating FLAC metadata objects.
Chris@2 1252 *
Chris@2 1253 * Since many are variable length we have to be careful about the memory
Chris@2 1254 * management. We decree that all pointers to data in the object are
Chris@2 1255 * owned by the object and memory-managed by the object.
Chris@2 1256 *
Chris@2 1257 * Use the FLAC__metadata_object_new() and FLAC__metadata_object_delete()
Chris@2 1258 * functions to create all instances. When using the
Chris@2 1259 * FLAC__metadata_object_set_*() functions to set pointers to data, set
Chris@2 1260 * \a copy to \c true to have the function make it's own copy of the data, or
Chris@2 1261 * to \c false to give the object ownership of your data. In the latter case
Chris@2 1262 * your pointer must be freeable by free() and will be free()d when the object
Chris@2 1263 * is FLAC__metadata_object_delete()d. It is legal to pass a null pointer as
Chris@2 1264 * the data pointer to a FLAC__metadata_object_set_*() function as long as
Chris@2 1265 * the length argument is 0 and the \a copy argument is \c false.
Chris@2 1266 *
Chris@2 1267 * The FLAC__metadata_object_new() and FLAC__metadata_object_clone() function
Chris@2 1268 * will return \c NULL in the case of a memory allocation error, otherwise a new
Chris@2 1269 * object. The FLAC__metadata_object_set_*() functions return \c false in the
Chris@2 1270 * case of a memory allocation error.
Chris@2 1271 *
Chris@2 1272 * We don't have the convenience of C++ here, so note that the library relies
Chris@2 1273 * on you to keep the types straight. In other words, if you pass, for
Chris@2 1274 * example, a FLAC__StreamMetadata* that represents a STREAMINFO block to
Chris@2 1275 * FLAC__metadata_object_application_set_data(), you will get an assertion
Chris@2 1276 * failure.
Chris@2 1277 *
Chris@2 1278 * For convenience the FLAC__metadata_object_vorbiscomment_*() functions
Chris@2 1279 * maintain a trailing NUL on each Vorbis comment entry. This is not counted
Chris@2 1280 * toward the length or stored in the stream, but it can make working with plain
Chris@2 1281 * comments (those that don't contain embedded-NULs in the value) easier.
Chris@2 1282 * Entries passed into these functions have trailing NULs added if missing, and
Chris@2 1283 * returned entries are guaranteed to have a trailing NUL.
Chris@2 1284 *
Chris@2 1285 * The FLAC__metadata_object_vorbiscomment_*() functions that take a Vorbis
Chris@2 1286 * comment entry/name/value will first validate that it complies with the Vorbis
Chris@2 1287 * comment specification and return false if it does not.
Chris@2 1288 *
Chris@2 1289 * There is no need to recalculate the length field on metadata blocks you
Chris@2 1290 * have modified. They will be calculated automatically before they are
Chris@2 1291 * written back to a file.
Chris@2 1292 *
Chris@2 1293 * \{
Chris@2 1294 */
Chris@2 1295
Chris@2 1296
Chris@2 1297 /** Create a new metadata object instance of the given type.
Chris@2 1298 *
Chris@2 1299 * The object will be "empty"; i.e. values and data pointers will be \c 0,
Chris@2 1300 * with the exception of FLAC__METADATA_TYPE_VORBIS_COMMENT, which will have
Chris@2 1301 * the vendor string set (but zero comments).
Chris@2 1302 *
Chris@2 1303 * Do not pass in a value greater than or equal to
Chris@2 1304 * \a FLAC__METADATA_TYPE_UNDEFINED unless you really know what you're
Chris@2 1305 * doing.
Chris@2 1306 *
Chris@2 1307 * \param type Type of object to create
Chris@2 1308 * \retval FLAC__StreamMetadata*
Chris@2 1309 * \c NULL if there was an error allocating memory or the type code is
Chris@2 1310 * greater than FLAC__MAX_METADATA_TYPE_CODE, else the new instance.
Chris@2 1311 */
Chris@2 1312 FLAC_API FLAC__StreamMetadata *FLAC__metadata_object_new(FLAC__MetadataType type);
Chris@2 1313
Chris@2 1314 /** Create a copy of an existing metadata object.
Chris@2 1315 *
Chris@2 1316 * The copy is a "deep" copy, i.e. dynamically allocated data within the
Chris@2 1317 * object is also copied. The caller takes ownership of the new block and
Chris@2 1318 * is responsible for freeing it with FLAC__metadata_object_delete().
Chris@2 1319 *
Chris@2 1320 * \param object Pointer to object to copy.
Chris@2 1321 * \assert
Chris@2 1322 * \code object != NULL \endcode
Chris@2 1323 * \retval FLAC__StreamMetadata*
Chris@2 1324 * \c NULL if there was an error allocating memory, else the new instance.
Chris@2 1325 */
Chris@2 1326 FLAC_API FLAC__StreamMetadata *FLAC__metadata_object_clone(const FLAC__StreamMetadata *object);
Chris@2 1327
Chris@2 1328 /** Free a metadata object. Deletes the object pointed to by \a object.
Chris@2 1329 *
Chris@2 1330 * The delete is a "deep" delete, i.e. dynamically allocated data within the
Chris@2 1331 * object is also deleted.
Chris@2 1332 *
Chris@2 1333 * \param object A pointer to an existing object.
Chris@2 1334 * \assert
Chris@2 1335 * \code object != NULL \endcode
Chris@2 1336 */
Chris@2 1337 FLAC_API void FLAC__metadata_object_delete(FLAC__StreamMetadata *object);
Chris@2 1338
Chris@2 1339 /** Compares two metadata objects.
Chris@2 1340 *
Chris@2 1341 * The compare is "deep", i.e. dynamically allocated data within the
Chris@2 1342 * object is also compared.
Chris@2 1343 *
Chris@2 1344 * \param block1 A pointer to an existing object.
Chris@2 1345 * \param block2 A pointer to an existing object.
Chris@2 1346 * \assert
Chris@2 1347 * \code block1 != NULL \endcode
Chris@2 1348 * \code block2 != NULL \endcode
Chris@2 1349 * \retval FLAC__bool
Chris@2 1350 * \c true if objects are identical, else \c false.
Chris@2 1351 */
Chris@2 1352 FLAC_API FLAC__bool FLAC__metadata_object_is_equal(const FLAC__StreamMetadata *block1, const FLAC__StreamMetadata *block2);
Chris@2 1353
Chris@2 1354 /** Sets the application data of an APPLICATION block.
Chris@2 1355 *
Chris@2 1356 * If \a copy is \c true, a copy of the data is stored; otherwise, the object
Chris@2 1357 * takes ownership of the pointer. The existing data will be freed if this
Chris@2 1358 * function is successful, otherwise the original data will remain if \a copy
Chris@2 1359 * is \c true and malloc() fails.
Chris@2 1360 *
Chris@2 1361 * \note It is safe to pass a const pointer to \a data if \a copy is \c true.
Chris@2 1362 *
Chris@2 1363 * \param object A pointer to an existing APPLICATION object.
Chris@2 1364 * \param data A pointer to the data to set.
Chris@2 1365 * \param length The length of \a data in bytes.
Chris@2 1366 * \param copy See above.
Chris@2 1367 * \assert
Chris@2 1368 * \code object != NULL \endcode
Chris@2 1369 * \code object->type == FLAC__METADATA_TYPE_APPLICATION \endcode
Chris@2 1370 * \code (data != NULL && length > 0) ||
Chris@2 1371 * (data == NULL && length == 0 && copy == false) \endcode
Chris@2 1372 * \retval FLAC__bool
Chris@2 1373 * \c false if \a copy is \c true and malloc() fails, else \c true.
Chris@2 1374 */
Chris@2 1375 FLAC_API FLAC__bool FLAC__metadata_object_application_set_data(FLAC__StreamMetadata *object, FLAC__byte *data, unsigned length, FLAC__bool copy);
Chris@2 1376
Chris@2 1377 /** Resize the seekpoint array.
Chris@2 1378 *
Chris@2 1379 * If the size shrinks, elements will truncated; if it grows, new placeholder
Chris@2 1380 * points will be added to the end.
Chris@2 1381 *
Chris@2 1382 * \param object A pointer to an existing SEEKTABLE object.
Chris@2 1383 * \param new_num_points The desired length of the array; may be \c 0.
Chris@2 1384 * \assert
Chris@2 1385 * \code object != NULL \endcode
Chris@2 1386 * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode
Chris@2 1387 * \code (object->data.seek_table.points == NULL && object->data.seek_table.num_points == 0) ||
Chris@2 1388 * (object->data.seek_table.points != NULL && object->data.seek_table.num_points > 0) \endcode
Chris@2 1389 * \retval FLAC__bool
Chris@2 1390 * \c false if memory allocation error, else \c true.
Chris@2 1391 */
Chris@2 1392 FLAC_API FLAC__bool FLAC__metadata_object_seektable_resize_points(FLAC__StreamMetadata *object, unsigned new_num_points);
Chris@2 1393
Chris@2 1394 /** Set a seekpoint in a seektable.
Chris@2 1395 *
Chris@2 1396 * \param object A pointer to an existing SEEKTABLE object.
Chris@2 1397 * \param point_num Index into seekpoint array to set.
Chris@2 1398 * \param point The point to set.
Chris@2 1399 * \assert
Chris@2 1400 * \code object != NULL \endcode
Chris@2 1401 * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode
Chris@2 1402 * \code object->data.seek_table.num_points > point_num \endcode
Chris@2 1403 */
Chris@2 1404 FLAC_API void FLAC__metadata_object_seektable_set_point(FLAC__StreamMetadata *object, unsigned point_num, FLAC__StreamMetadata_SeekPoint point);
Chris@2 1405
Chris@2 1406 /** Insert a seekpoint into a seektable.
Chris@2 1407 *
Chris@2 1408 * \param object A pointer to an existing SEEKTABLE object.
Chris@2 1409 * \param point_num Index into seekpoint array to set.
Chris@2 1410 * \param point The point to set.
Chris@2 1411 * \assert
Chris@2 1412 * \code object != NULL \endcode
Chris@2 1413 * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode
Chris@2 1414 * \code object->data.seek_table.num_points >= point_num \endcode
Chris@2 1415 * \retval FLAC__bool
Chris@2 1416 * \c false if memory allocation error, else \c true.
Chris@2 1417 */
Chris@2 1418 FLAC_API FLAC__bool FLAC__metadata_object_seektable_insert_point(FLAC__StreamMetadata *object, unsigned point_num, FLAC__StreamMetadata_SeekPoint point);
Chris@2 1419
Chris@2 1420 /** Delete a seekpoint from a seektable.
Chris@2 1421 *
Chris@2 1422 * \param object A pointer to an existing SEEKTABLE object.
Chris@2 1423 * \param point_num Index into seekpoint array to set.
Chris@2 1424 * \assert
Chris@2 1425 * \code object != NULL \endcode
Chris@2 1426 * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode
Chris@2 1427 * \code object->data.seek_table.num_points > point_num \endcode
Chris@2 1428 * \retval FLAC__bool
Chris@2 1429 * \c false if memory allocation error, else \c true.
Chris@2 1430 */
Chris@2 1431 FLAC_API FLAC__bool FLAC__metadata_object_seektable_delete_point(FLAC__StreamMetadata *object, unsigned point_num);
Chris@2 1432
Chris@2 1433 /** Check a seektable to see if it conforms to the FLAC specification.
Chris@2 1434 * See the format specification for limits on the contents of the
Chris@2 1435 * seektable.
Chris@2 1436 *
Chris@2 1437 * \param object A pointer to an existing SEEKTABLE object.
Chris@2 1438 * \assert
Chris@2 1439 * \code object != NULL \endcode
Chris@2 1440 * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode
Chris@2 1441 * \retval FLAC__bool
Chris@2 1442 * \c false if seek table is illegal, else \c true.
Chris@2 1443 */
Chris@2 1444 FLAC_API FLAC__bool FLAC__metadata_object_seektable_is_legal(const FLAC__StreamMetadata *object);
Chris@2 1445
Chris@2 1446 /** Append a number of placeholder points to the end of a seek table.
Chris@2 1447 *
Chris@2 1448 * \note
Chris@2 1449 * As with the other ..._seektable_template_... functions, you should
Chris@2 1450 * call FLAC__metadata_object_seektable_template_sort() when finished
Chris@2 1451 * to make the seek table legal.
Chris@2 1452 *
Chris@2 1453 * \param object A pointer to an existing SEEKTABLE object.
Chris@2 1454 * \param num The number of placeholder points to append.
Chris@2 1455 * \assert
Chris@2 1456 * \code object != NULL \endcode
Chris@2 1457 * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode
Chris@2 1458 * \retval FLAC__bool
Chris@2 1459 * \c false if memory allocation fails, else \c true.
Chris@2 1460 */
Chris@2 1461 FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_placeholders(FLAC__StreamMetadata *object, unsigned num);
Chris@2 1462
Chris@2 1463 /** Append a specific seek point template to the end of a seek table.
Chris@2 1464 *
Chris@2 1465 * \note
Chris@2 1466 * As with the other ..._seektable_template_... functions, you should
Chris@2 1467 * call FLAC__metadata_object_seektable_template_sort() when finished
Chris@2 1468 * to make the seek table legal.
Chris@2 1469 *
Chris@2 1470 * \param object A pointer to an existing SEEKTABLE object.
Chris@2 1471 * \param sample_number The sample number of the seek point template.
Chris@2 1472 * \assert
Chris@2 1473 * \code object != NULL \endcode
Chris@2 1474 * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode
Chris@2 1475 * \retval FLAC__bool
Chris@2 1476 * \c false if memory allocation fails, else \c true.
Chris@2 1477 */
Chris@2 1478 FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_point(FLAC__StreamMetadata *object, FLAC__uint64 sample_number);
Chris@2 1479
Chris@2 1480 /** Append specific seek point templates to the end of a seek table.
Chris@2 1481 *
Chris@2 1482 * \note
Chris@2 1483 * As with the other ..._seektable_template_... functions, you should
Chris@2 1484 * call FLAC__metadata_object_seektable_template_sort() when finished
Chris@2 1485 * to make the seek table legal.
Chris@2 1486 *
Chris@2 1487 * \param object A pointer to an existing SEEKTABLE object.
Chris@2 1488 * \param sample_numbers An array of sample numbers for the seek points.
Chris@2 1489 * \param num The number of seek point templates to append.
Chris@2 1490 * \assert
Chris@2 1491 * \code object != NULL \endcode
Chris@2 1492 * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode
Chris@2 1493 * \retval FLAC__bool
Chris@2 1494 * \c false if memory allocation fails, else \c true.
Chris@2 1495 */
Chris@2 1496 FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_points(FLAC__StreamMetadata *object, FLAC__uint64 sample_numbers[], unsigned num);
Chris@2 1497
Chris@2 1498 /** Append a set of evenly-spaced seek point templates to the end of a
Chris@2 1499 * seek table.
Chris@2 1500 *
Chris@2 1501 * \note
Chris@2 1502 * As with the other ..._seektable_template_... functions, you should
Chris@2 1503 * call FLAC__metadata_object_seektable_template_sort() when finished
Chris@2 1504 * to make the seek table legal.
Chris@2 1505 *
Chris@2 1506 * \param object A pointer to an existing SEEKTABLE object.
Chris@2 1507 * \param num The number of placeholder points to append.
Chris@2 1508 * \param total_samples The total number of samples to be encoded;
Chris@2 1509 * the seekpoints will be spaced approximately
Chris@2 1510 * \a total_samples / \a num samples apart.
Chris@2 1511 * \assert
Chris@2 1512 * \code object != NULL \endcode
Chris@2 1513 * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode
Chris@2 1514 * \code total_samples > 0 \endcode
Chris@2 1515 * \retval FLAC__bool
Chris@2 1516 * \c false if memory allocation fails, else \c true.
Chris@2 1517 */
Chris@2 1518 FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_spaced_points(FLAC__StreamMetadata *object, unsigned num, FLAC__uint64 total_samples);
Chris@2 1519
Chris@2 1520 /** Append a set of evenly-spaced seek point templates to the end of a
Chris@2 1521 * seek table.
Chris@2 1522 *
Chris@2 1523 * \note
Chris@2 1524 * As with the other ..._seektable_template_... functions, you should
Chris@2 1525 * call FLAC__metadata_object_seektable_template_sort() when finished
Chris@2 1526 * to make the seek table legal.
Chris@2 1527 *
Chris@2 1528 * \param object A pointer to an existing SEEKTABLE object.
Chris@2 1529 * \param samples The number of samples apart to space the placeholder
Chris@2 1530 * points. The first point will be at sample \c 0, the
Chris@2 1531 * second at sample \a samples, then 2*\a samples, and
Chris@2 1532 * so on. As long as \a samples and \a total_samples
Chris@2 1533 * are greater than \c 0, there will always be at least
Chris@2 1534 * one seekpoint at sample \c 0.
Chris@2 1535 * \param total_samples The total number of samples to be encoded;
Chris@2 1536 * the seekpoints will be spaced
Chris@2 1537 * \a samples samples apart.
Chris@2 1538 * \assert
Chris@2 1539 * \code object != NULL \endcode
Chris@2 1540 * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode
Chris@2 1541 * \code samples > 0 \endcode
Chris@2 1542 * \code total_samples > 0 \endcode
Chris@2 1543 * \retval FLAC__bool
Chris@2 1544 * \c false if memory allocation fails, else \c true.
Chris@2 1545 */
Chris@2 1546 FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_spaced_points_by_samples(FLAC__StreamMetadata *object, unsigned samples, FLAC__uint64 total_samples);
Chris@2 1547
Chris@2 1548 /** Sort a seek table's seek points according to the format specification,
Chris@2 1549 * removing duplicates.
Chris@2 1550 *
Chris@2 1551 * \param object A pointer to a seek table to be sorted.
Chris@2 1552 * \param compact If \c false, behaves like FLAC__format_seektable_sort().
Chris@2 1553 * If \c true, duplicates are deleted and the seek table is
Chris@2 1554 * shrunk appropriately; the number of placeholder points
Chris@2 1555 * present in the seek table will be the same after the call
Chris@2 1556 * as before.
Chris@2 1557 * \assert
Chris@2 1558 * \code object != NULL \endcode
Chris@2 1559 * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode
Chris@2 1560 * \retval FLAC__bool
Chris@2 1561 * \c false if realloc() fails, else \c true.
Chris@2 1562 */
Chris@2 1563 FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_sort(FLAC__StreamMetadata *object, FLAC__bool compact);
Chris@2 1564
Chris@2 1565 /** Sets the vendor string in a VORBIS_COMMENT block.
Chris@2 1566 *
Chris@2 1567 * For convenience, a trailing NUL is added to the entry if it doesn't have
Chris@2 1568 * one already.
Chris@2 1569 *
Chris@2 1570 * If \a copy is \c true, a copy of the entry is stored; otherwise, the object
Chris@2 1571 * takes ownership of the \c entry.entry pointer.
Chris@2 1572 *
Chris@2 1573 * \note If this function returns \c false, the caller still owns the
Chris@2 1574 * pointer.
Chris@2 1575 *
Chris@2 1576 * \param object A pointer to an existing VORBIS_COMMENT object.
Chris@2 1577 * \param entry The entry to set the vendor string to.
Chris@2 1578 * \param copy See above.
Chris@2 1579 * \assert
Chris@2 1580 * \code object != NULL \endcode
Chris@2 1581 * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode
Chris@2 1582 * \code (entry.entry != NULL && entry.length > 0) ||
Chris@2 1583 * (entry.entry == NULL && entry.length == 0) \endcode
Chris@2 1584 * \retval FLAC__bool
Chris@2 1585 * \c false if memory allocation fails or \a entry does not comply with the
Chris@2 1586 * Vorbis comment specification, else \c true.
Chris@2 1587 */
Chris@2 1588 FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_set_vendor_string(FLAC__StreamMetadata *object, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool copy);
Chris@2 1589
Chris@2 1590 /** Resize the comment array.
Chris@2 1591 *
Chris@2 1592 * If the size shrinks, elements will truncated; if it grows, new empty
Chris@2 1593 * fields will be added to the end.
Chris@2 1594 *
Chris@2 1595 * \param object A pointer to an existing VORBIS_COMMENT object.
Chris@2 1596 * \param new_num_comments The desired length of the array; may be \c 0.
Chris@2 1597 * \assert
Chris@2 1598 * \code object != NULL \endcode
Chris@2 1599 * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode
Chris@2 1600 * \code (object->data.vorbis_comment.comments == NULL && object->data.vorbis_comment.num_comments == 0) ||
Chris@2 1601 * (object->data.vorbis_comment.comments != NULL && object->data.vorbis_comment.num_comments > 0) \endcode
Chris@2 1602 * \retval FLAC__bool
Chris@2 1603 * \c false if memory allocation fails, else \c true.
Chris@2 1604 */
Chris@2 1605 FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_resize_comments(FLAC__StreamMetadata *object, unsigned new_num_comments);
Chris@2 1606
Chris@2 1607 /** Sets a comment in a VORBIS_COMMENT block.
Chris@2 1608 *
Chris@2 1609 * For convenience, a trailing NUL is added to the entry if it doesn't have
Chris@2 1610 * one already.
Chris@2 1611 *
Chris@2 1612 * If \a copy is \c true, a copy of the entry is stored; otherwise, the object
Chris@2 1613 * takes ownership of the \c entry.entry pointer.
Chris@2 1614 *
Chris@2 1615 * \note If this function returns \c false, the caller still owns the
Chris@2 1616 * pointer.
Chris@2 1617 *
Chris@2 1618 * \param object A pointer to an existing VORBIS_COMMENT object.
Chris@2 1619 * \param comment_num Index into comment array to set.
Chris@2 1620 * \param entry The entry to set the comment to.
Chris@2 1621 * \param copy See above.
Chris@2 1622 * \assert
Chris@2 1623 * \code object != NULL \endcode
Chris@2 1624 * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode
Chris@2 1625 * \code comment_num < object->data.vorbis_comment.num_comments \endcode
Chris@2 1626 * \code (entry.entry != NULL && entry.length > 0) ||
Chris@2 1627 * (entry.entry == NULL && entry.length == 0) \endcode
Chris@2 1628 * \retval FLAC__bool
Chris@2 1629 * \c false if memory allocation fails or \a entry does not comply with the
Chris@2 1630 * Vorbis comment specification, else \c true.
Chris@2 1631 */
Chris@2 1632 FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_set_comment(FLAC__StreamMetadata *object, unsigned comment_num, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool copy);
Chris@2 1633
Chris@2 1634 /** Insert a comment in a VORBIS_COMMENT block at the given index.
Chris@2 1635 *
Chris@2 1636 * For convenience, a trailing NUL is added to the entry if it doesn't have
Chris@2 1637 * one already.
Chris@2 1638 *
Chris@2 1639 * If \a copy is \c true, a copy of the entry is stored; otherwise, the object
Chris@2 1640 * takes ownership of the \c entry.entry pointer.
Chris@2 1641 *
Chris@2 1642 * \note If this function returns \c false, the caller still owns the
Chris@2 1643 * pointer.
Chris@2 1644 *
Chris@2 1645 * \param object A pointer to an existing VORBIS_COMMENT object.
Chris@2 1646 * \param comment_num The index at which to insert the comment. The comments
Chris@2 1647 * at and after \a comment_num move right one position.
Chris@2 1648 * To append a comment to the end, set \a comment_num to
Chris@2 1649 * \c object->data.vorbis_comment.num_comments .
Chris@2 1650 * \param entry The comment to insert.
Chris@2 1651 * \param copy See above.
Chris@2 1652 * \assert
Chris@2 1653 * \code object != NULL \endcode
Chris@2 1654 * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode
Chris@2 1655 * \code object->data.vorbis_comment.num_comments >= comment_num \endcode
Chris@2 1656 * \code (entry.entry != NULL && entry.length > 0) ||
Chris@2 1657 * (entry.entry == NULL && entry.length == 0 && copy == false) \endcode
Chris@2 1658 * \retval FLAC__bool
Chris@2 1659 * \c false if memory allocation fails or \a entry does not comply with the
Chris@2 1660 * Vorbis comment specification, else \c true.
Chris@2 1661 */
Chris@2 1662 FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_insert_comment(FLAC__StreamMetadata *object, unsigned comment_num, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool copy);
Chris@2 1663
Chris@2 1664 /** Appends a comment to a VORBIS_COMMENT block.
Chris@2 1665 *
Chris@2 1666 * For convenience, a trailing NUL is added to the entry if it doesn't have
Chris@2 1667 * one already.
Chris@2 1668 *
Chris@2 1669 * If \a copy is \c true, a copy of the entry is stored; otherwise, the object
Chris@2 1670 * takes ownership of the \c entry.entry pointer.
Chris@2 1671 *
Chris@2 1672 * \note If this function returns \c false, the caller still owns the
Chris@2 1673 * pointer.
Chris@2 1674 *
Chris@2 1675 * \param object A pointer to an existing VORBIS_COMMENT object.
Chris@2 1676 * \param entry The comment to insert.
Chris@2 1677 * \param copy See above.
Chris@2 1678 * \assert
Chris@2 1679 * \code object != NULL \endcode
Chris@2 1680 * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode
Chris@2 1681 * \code (entry.entry != NULL && entry.length > 0) ||
Chris@2 1682 * (entry.entry == NULL && entry.length == 0 && copy == false) \endcode
Chris@2 1683 * \retval FLAC__bool
Chris@2 1684 * \c false if memory allocation fails or \a entry does not comply with the
Chris@2 1685 * Vorbis comment specification, else \c true.
Chris@2 1686 */
Chris@2 1687 FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_append_comment(FLAC__StreamMetadata *object, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool copy);
Chris@2 1688
Chris@2 1689 /** Replaces comments in a VORBIS_COMMENT block with a new one.
Chris@2 1690 *
Chris@2 1691 * For convenience, a trailing NUL is added to the entry if it doesn't have
Chris@2 1692 * one already.
Chris@2 1693 *
Chris@2 1694 * Depending on the the value of \a all, either all or just the first comment
Chris@2 1695 * whose field name(s) match the given entry's name will be replaced by the
Chris@2 1696 * given entry. If no comments match, \a entry will simply be appended.
Chris@2 1697 *
Chris@2 1698 * If \a copy is \c true, a copy of the entry is stored; otherwise, the object
Chris@2 1699 * takes ownership of the \c entry.entry pointer.
Chris@2 1700 *
Chris@2 1701 * \note If this function returns \c false, the caller still owns the
Chris@2 1702 * pointer.
Chris@2 1703 *
Chris@2 1704 * \param object A pointer to an existing VORBIS_COMMENT object.
Chris@2 1705 * \param entry The comment to insert.
Chris@2 1706 * \param all If \c true, all comments whose field name matches
Chris@2 1707 * \a entry's field name will be removed, and \a entry will
Chris@2 1708 * be inserted at the position of the first matching
Chris@2 1709 * comment. If \c false, only the first comment whose
Chris@2 1710 * field name matches \a entry's field name will be
Chris@2 1711 * replaced with \a entry.
Chris@2 1712 * \param copy See above.
Chris@2 1713 * \assert
Chris@2 1714 * \code object != NULL \endcode
Chris@2 1715 * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode
Chris@2 1716 * \code (entry.entry != NULL && entry.length > 0) ||
Chris@2 1717 * (entry.entry == NULL && entry.length == 0 && copy == false) \endcode
Chris@2 1718 * \retval FLAC__bool
Chris@2 1719 * \c false if memory allocation fails or \a entry does not comply with the
Chris@2 1720 * Vorbis comment specification, else \c true.
Chris@2 1721 */
Chris@2 1722 FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_replace_comment(FLAC__StreamMetadata *object, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool all, FLAC__bool copy);
Chris@2 1723
Chris@2 1724 /** Delete a comment in a VORBIS_COMMENT block at the given index.
Chris@2 1725 *
Chris@2 1726 * \param object A pointer to an existing VORBIS_COMMENT object.
Chris@2 1727 * \param comment_num The index of the comment to delete.
Chris@2 1728 * \assert
Chris@2 1729 * \code object != NULL \endcode
Chris@2 1730 * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode
Chris@2 1731 * \code object->data.vorbis_comment.num_comments > comment_num \endcode
Chris@2 1732 * \retval FLAC__bool
Chris@2 1733 * \c false if realloc() fails, else \c true.
Chris@2 1734 */
Chris@2 1735 FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_delete_comment(FLAC__StreamMetadata *object, unsigned comment_num);
Chris@2 1736
Chris@2 1737 /** Creates a Vorbis comment entry from NUL-terminated name and value strings.
Chris@2 1738 *
Chris@2 1739 * On return, the filled-in \a entry->entry pointer will point to malloc()ed
Chris@2 1740 * memory and shall be owned by the caller. For convenience the entry will
Chris@2 1741 * have a terminating NUL.
Chris@2 1742 *
Chris@2 1743 * \param entry A pointer to a Vorbis comment entry. The entry's
Chris@2 1744 * \c entry pointer should not point to allocated
Chris@2 1745 * memory as it will be overwritten.
Chris@2 1746 * \param field_name The field name in ASCII, \c NUL terminated.
Chris@2 1747 * \param field_value The field value in UTF-8, \c NUL terminated.
Chris@2 1748 * \assert
Chris@2 1749 * \code entry != NULL \endcode
Chris@2 1750 * \code field_name != NULL \endcode
Chris@2 1751 * \code field_value != NULL \endcode
Chris@2 1752 * \retval FLAC__bool
Chris@2 1753 * \c false if malloc() fails, or if \a field_name or \a field_value does
Chris@2 1754 * not comply with the Vorbis comment specification, else \c true.
Chris@2 1755 */
Chris@2 1756 FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair(FLAC__StreamMetadata_VorbisComment_Entry *entry, const char *field_name, const char *field_value);
Chris@2 1757
Chris@2 1758 /** Splits a Vorbis comment entry into NUL-terminated name and value strings.
Chris@2 1759 *
Chris@2 1760 * The returned pointers to name and value will be allocated by malloc()
Chris@2 1761 * and shall be owned by the caller.
Chris@2 1762 *
Chris@2 1763 * \param entry An existing Vorbis comment entry.
Chris@2 1764 * \param field_name The address of where the returned pointer to the
Chris@2 1765 * field name will be stored.
Chris@2 1766 * \param field_value The address of where the returned pointer to the
Chris@2 1767 * field value will be stored.
Chris@2 1768 * \assert
Chris@2 1769 * \code (entry.entry != NULL && entry.length > 0) \endcode
Chris@2 1770 * \code memchr(entry.entry, '=', entry.length) != NULL \endcode
Chris@2 1771 * \code field_name != NULL \endcode
Chris@2 1772 * \code field_value != NULL \endcode
Chris@2 1773 * \retval FLAC__bool
Chris@2 1774 * \c false if memory allocation fails or \a entry does not comply with the
Chris@2 1775 * Vorbis comment specification, else \c true.
Chris@2 1776 */
Chris@2 1777 FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_entry_to_name_value_pair(const FLAC__StreamMetadata_VorbisComment_Entry entry, char **field_name, char **field_value);
Chris@2 1778
Chris@2 1779 /** Check if the given Vorbis comment entry's field name matches the given
Chris@2 1780 * field name.
Chris@2 1781 *
Chris@2 1782 * \param entry An existing Vorbis comment entry.
Chris@2 1783 * \param field_name The field name to check.
Chris@2 1784 * \param field_name_length The length of \a field_name, not including the
Chris@2 1785 * terminating \c NUL.
Chris@2 1786 * \assert
Chris@2 1787 * \code (entry.entry != NULL && entry.length > 0) \endcode
Chris@2 1788 * \retval FLAC__bool
Chris@2 1789 * \c true if the field names match, else \c false
Chris@2 1790 */
Chris@2 1791 FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_entry_matches(const FLAC__StreamMetadata_VorbisComment_Entry entry, const char *field_name, unsigned field_name_length);
Chris@2 1792
Chris@2 1793 /** Find a Vorbis comment with the given field name.
Chris@2 1794 *
Chris@2 1795 * The search begins at entry number \a offset; use an offset of 0 to
Chris@2 1796 * search from the beginning of the comment array.
Chris@2 1797 *
Chris@2 1798 * \param object A pointer to an existing VORBIS_COMMENT object.
Chris@2 1799 * \param offset The offset into the comment array from where to start
Chris@2 1800 * the search.
Chris@2 1801 * \param field_name The field name of the comment to find.
Chris@2 1802 * \assert
Chris@2 1803 * \code object != NULL \endcode
Chris@2 1804 * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode
Chris@2 1805 * \code field_name != NULL \endcode
Chris@2 1806 * \retval int
Chris@2 1807 * The offset in the comment array of the first comment whose field
Chris@2 1808 * name matches \a field_name, or \c -1 if no match was found.
Chris@2 1809 */
Chris@2 1810 FLAC_API int FLAC__metadata_object_vorbiscomment_find_entry_from(const FLAC__StreamMetadata *object, unsigned offset, const char *field_name);
Chris@2 1811
Chris@2 1812 /** Remove first Vorbis comment matching the given field name.
Chris@2 1813 *
Chris@2 1814 * \param object A pointer to an existing VORBIS_COMMENT object.
Chris@2 1815 * \param field_name The field name of comment to delete.
Chris@2 1816 * \assert
Chris@2 1817 * \code object != NULL \endcode
Chris@2 1818 * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode
Chris@2 1819 * \retval int
Chris@2 1820 * \c -1 for memory allocation error, \c 0 for no matching entries,
Chris@2 1821 * \c 1 for one matching entry deleted.
Chris@2 1822 */
Chris@2 1823 FLAC_API int FLAC__metadata_object_vorbiscomment_remove_entry_matching(FLAC__StreamMetadata *object, const char *field_name);
Chris@2 1824
Chris@2 1825 /** Remove all Vorbis comments matching the given field name.
Chris@2 1826 *
Chris@2 1827 * \param object A pointer to an existing VORBIS_COMMENT object.
Chris@2 1828 * \param field_name The field name of comments to delete.
Chris@2 1829 * \assert
Chris@2 1830 * \code object != NULL \endcode
Chris@2 1831 * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode
Chris@2 1832 * \retval int
Chris@2 1833 * \c -1 for memory allocation error, \c 0 for no matching entries,
Chris@2 1834 * else the number of matching entries deleted.
Chris@2 1835 */
Chris@2 1836 FLAC_API int FLAC__metadata_object_vorbiscomment_remove_entries_matching(FLAC__StreamMetadata *object, const char *field_name);
Chris@2 1837
Chris@2 1838 /** Create a new CUESHEET track instance.
Chris@2 1839 *
Chris@2 1840 * The object will be "empty"; i.e. values and data pointers will be \c 0.
Chris@2 1841 *
Chris@2 1842 * \retval FLAC__StreamMetadata_CueSheet_Track*
Chris@2 1843 * \c NULL if there was an error allocating memory, else the new instance.
Chris@2 1844 */
Chris@2 1845 FLAC_API FLAC__StreamMetadata_CueSheet_Track *FLAC__metadata_object_cuesheet_track_new(void);
Chris@2 1846
Chris@2 1847 /** Create a copy of an existing CUESHEET track object.
Chris@2 1848 *
Chris@2 1849 * The copy is a "deep" copy, i.e. dynamically allocated data within the
Chris@2 1850 * object is also copied. The caller takes ownership of the new object and
Chris@2 1851 * is responsible for freeing it with
Chris@2 1852 * FLAC__metadata_object_cuesheet_track_delete().
Chris@2 1853 *
Chris@2 1854 * \param object Pointer to object to copy.
Chris@2 1855 * \assert
Chris@2 1856 * \code object != NULL \endcode
Chris@2 1857 * \retval FLAC__StreamMetadata_CueSheet_Track*
Chris@2 1858 * \c NULL if there was an error allocating memory, else the new instance.
Chris@2 1859 */
Chris@2 1860 FLAC_API FLAC__StreamMetadata_CueSheet_Track *FLAC__metadata_object_cuesheet_track_clone(const FLAC__StreamMetadata_CueSheet_Track *object);
Chris@2 1861
Chris@2 1862 /** Delete a CUESHEET track object
Chris@2 1863 *
Chris@2 1864 * \param object A pointer to an existing CUESHEET track object.
Chris@2 1865 * \assert
Chris@2 1866 * \code object != NULL \endcode
Chris@2 1867 */
Chris@2 1868 FLAC_API void FLAC__metadata_object_cuesheet_track_delete(FLAC__StreamMetadata_CueSheet_Track *object);
Chris@2 1869
Chris@2 1870 /** Resize a track's index point array.
Chris@2 1871 *
Chris@2 1872 * If the size shrinks, elements will truncated; if it grows, new blank
Chris@2 1873 * indices will be added to the end.
Chris@2 1874 *
Chris@2 1875 * \param object A pointer to an existing CUESHEET object.
Chris@2 1876 * \param track_num The index of the track to modify. NOTE: this is not
Chris@2 1877 * necessarily the same as the track's \a number field.
Chris@2 1878 * \param new_num_indices The desired length of the array; may be \c 0.
Chris@2 1879 * \assert
Chris@2 1880 * \code object != NULL \endcode
Chris@2 1881 * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode
Chris@2 1882 * \code object->data.cue_sheet.num_tracks > track_num \endcode
Chris@2 1883 * \code (object->data.cue_sheet.tracks[track_num].indices == NULL && object->data.cue_sheet.tracks[track_num].num_indices == 0) ||
Chris@2 1884 * (object->data.cue_sheet.tracks[track_num].indices != NULL && object->data.cue_sheet.tracks[track_num].num_indices > 0) \endcode
Chris@2 1885 * \retval FLAC__bool
Chris@2 1886 * \c false if memory allocation error, else \c true.
Chris@2 1887 */
Chris@2 1888 FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_track_resize_indices(FLAC__StreamMetadata *object, unsigned track_num, unsigned new_num_indices);
Chris@2 1889
Chris@2 1890 /** Insert an index point in a CUESHEET track at the given index.
Chris@2 1891 *
Chris@2 1892 * \param object A pointer to an existing CUESHEET object.
Chris@2 1893 * \param track_num The index of the track to modify. NOTE: this is not
Chris@2 1894 * necessarily the same as the track's \a number field.
Chris@2 1895 * \param index_num The index into the track's index array at which to
Chris@2 1896 * insert the index point. NOTE: this is not necessarily
Chris@2 1897 * the same as the index point's \a number field. The
Chris@2 1898 * indices at and after \a index_num move right one
Chris@2 1899 * position. To append an index point to the end, set
Chris@2 1900 * \a index_num to
Chris@2 1901 * \c object->data.cue_sheet.tracks[track_num].num_indices .
Chris@2 1902 * \param index The index point to insert.
Chris@2 1903 * \assert
Chris@2 1904 * \code object != NULL \endcode
Chris@2 1905 * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode
Chris@2 1906 * \code object->data.cue_sheet.num_tracks > track_num \endcode
Chris@2 1907 * \code object->data.cue_sheet.tracks[track_num].num_indices >= index_num \endcode
Chris@2 1908 * \retval FLAC__bool
Chris@2 1909 * \c false if realloc() fails, else \c true.
Chris@2 1910 */
Chris@2 1911 FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_track_insert_index(FLAC__StreamMetadata *object, unsigned track_num, unsigned index_num, FLAC__StreamMetadata_CueSheet_Index index);
Chris@2 1912
Chris@2 1913 /** Insert a blank index point in a CUESHEET track at the given index.
Chris@2 1914 *
Chris@2 1915 * A blank index point is one in which all field values are zero.
Chris@2 1916 *
Chris@2 1917 * \param object A pointer to an existing CUESHEET object.
Chris@2 1918 * \param track_num The index of the track to modify. NOTE: this is not
Chris@2 1919 * necessarily the same as the track's \a number field.
Chris@2 1920 * \param index_num The index into the track's index array at which to
Chris@2 1921 * insert the index point. NOTE: this is not necessarily
Chris@2 1922 * the same as the index point's \a number field. The
Chris@2 1923 * indices at and after \a index_num move right one
Chris@2 1924 * position. To append an index point to the end, set
Chris@2 1925 * \a index_num to
Chris@2 1926 * \c object->data.cue_sheet.tracks[track_num].num_indices .
Chris@2 1927 * \assert
Chris@2 1928 * \code object != NULL \endcode
Chris@2 1929 * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode
Chris@2 1930 * \code object->data.cue_sheet.num_tracks > track_num \endcode
Chris@2 1931 * \code object->data.cue_sheet.tracks[track_num].num_indices >= index_num \endcode
Chris@2 1932 * \retval FLAC__bool
Chris@2 1933 * \c false if realloc() fails, else \c true.
Chris@2 1934 */
Chris@2 1935 FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_track_insert_blank_index(FLAC__StreamMetadata *object, unsigned track_num, unsigned index_num);
Chris@2 1936
Chris@2 1937 /** Delete an index point in a CUESHEET track at the given index.
Chris@2 1938 *
Chris@2 1939 * \param object A pointer to an existing CUESHEET object.
Chris@2 1940 * \param track_num The index into the track array of the track to
Chris@2 1941 * modify. NOTE: this is not necessarily the same
Chris@2 1942 * as the track's \a number field.
Chris@2 1943 * \param index_num The index into the track's index array of the index
Chris@2 1944 * to delete. NOTE: this is not necessarily the same
Chris@2 1945 * as the index's \a number field.
Chris@2 1946 * \assert
Chris@2 1947 * \code object != NULL \endcode
Chris@2 1948 * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode
Chris@2 1949 * \code object->data.cue_sheet.num_tracks > track_num \endcode
Chris@2 1950 * \code object->data.cue_sheet.tracks[track_num].num_indices > index_num \endcode
Chris@2 1951 * \retval FLAC__bool
Chris@2 1952 * \c false if realloc() fails, else \c true.
Chris@2 1953 */
Chris@2 1954 FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_track_delete_index(FLAC__StreamMetadata *object, unsigned track_num, unsigned index_num);
Chris@2 1955
Chris@2 1956 /** Resize the track array.
Chris@2 1957 *
Chris@2 1958 * If the size shrinks, elements will truncated; if it grows, new blank
Chris@2 1959 * tracks will be added to the end.
Chris@2 1960 *
Chris@2 1961 * \param object A pointer to an existing CUESHEET object.
Chris@2 1962 * \param new_num_tracks The desired length of the array; may be \c 0.
Chris@2 1963 * \assert
Chris@2 1964 * \code object != NULL \endcode
Chris@2 1965 * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode
Chris@2 1966 * \code (object->data.cue_sheet.tracks == NULL && object->data.cue_sheet.num_tracks == 0) ||
Chris@2 1967 * (object->data.cue_sheet.tracks != NULL && object->data.cue_sheet.num_tracks > 0) \endcode
Chris@2 1968 * \retval FLAC__bool
Chris@2 1969 * \c false if memory allocation error, else \c true.
Chris@2 1970 */
Chris@2 1971 FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_resize_tracks(FLAC__StreamMetadata *object, unsigned new_num_tracks);
Chris@2 1972
Chris@2 1973 /** Sets a track in a CUESHEET block.
Chris@2 1974 *
Chris@2 1975 * If \a copy is \c true, a copy of the track is stored; otherwise, the object
Chris@2 1976 * takes ownership of the \a track pointer.
Chris@2 1977 *
Chris@2 1978 * \param object A pointer to an existing CUESHEET object.
Chris@2 1979 * \param track_num Index into track array to set. NOTE: this is not
Chris@2 1980 * necessarily the same as the track's \a number field.
Chris@2 1981 * \param track The track to set the track to. You may safely pass in
Chris@2 1982 * a const pointer if \a copy is \c true.
Chris@2 1983 * \param copy See above.
Chris@2 1984 * \assert
Chris@2 1985 * \code object != NULL \endcode
Chris@2 1986 * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode
Chris@2 1987 * \code track_num < object->data.cue_sheet.num_tracks \endcode
Chris@2 1988 * \code (track->indices != NULL && track->num_indices > 0) ||
Chris@2 1989 * (track->indices == NULL && track->num_indices == 0)
Chris@2 1990 * \retval FLAC__bool
Chris@2 1991 * \c false if \a copy is \c true and malloc() fails, else \c true.
Chris@2 1992 */
Chris@2 1993 FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_set_track(FLAC__StreamMetadata *object, unsigned track_num, FLAC__StreamMetadata_CueSheet_Track *track, FLAC__bool copy);
Chris@2 1994
Chris@2 1995 /** Insert a track in a CUESHEET block at the given index.
Chris@2 1996 *
Chris@2 1997 * If \a copy is \c true, a copy of the track is stored; otherwise, the object
Chris@2 1998 * takes ownership of the \a track pointer.
Chris@2 1999 *
Chris@2 2000 * \param object A pointer to an existing CUESHEET object.
Chris@2 2001 * \param track_num The index at which to insert the track. NOTE: this
Chris@2 2002 * is not necessarily the same as the track's \a number
Chris@2 2003 * field. The tracks at and after \a track_num move right
Chris@2 2004 * one position. To append a track to the end, set
Chris@2 2005 * \a track_num to \c object->data.cue_sheet.num_tracks .
Chris@2 2006 * \param track The track to insert. You may safely pass in a const
Chris@2 2007 * pointer if \a copy is \c true.
Chris@2 2008 * \param copy See above.
Chris@2 2009 * \assert
Chris@2 2010 * \code object != NULL \endcode
Chris@2 2011 * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode
Chris@2 2012 * \code object->data.cue_sheet.num_tracks >= track_num \endcode
Chris@2 2013 * \retval FLAC__bool
Chris@2 2014 * \c false if \a copy is \c true and malloc() fails, else \c true.
Chris@2 2015 */
Chris@2 2016 FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_insert_track(FLAC__StreamMetadata *object, unsigned track_num, FLAC__StreamMetadata_CueSheet_Track *track, FLAC__bool copy);
Chris@2 2017
Chris@2 2018 /** Insert a blank track in a CUESHEET block at the given index.
Chris@2 2019 *
Chris@2 2020 * A blank track is one in which all field values are zero.
Chris@2 2021 *
Chris@2 2022 * \param object A pointer to an existing CUESHEET object.
Chris@2 2023 * \param track_num The index at which to insert the track. NOTE: this
Chris@2 2024 * is not necessarily the same as the track's \a number
Chris@2 2025 * field. The tracks at and after \a track_num move right
Chris@2 2026 * one position. To append a track to the end, set
Chris@2 2027 * \a track_num to \c object->data.cue_sheet.num_tracks .
Chris@2 2028 * \assert
Chris@2 2029 * \code object != NULL \endcode
Chris@2 2030 * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode
Chris@2 2031 * \code object->data.cue_sheet.num_tracks >= track_num \endcode
Chris@2 2032 * \retval FLAC__bool
Chris@2 2033 * \c false if \a copy is \c true and malloc() fails, else \c true.
Chris@2 2034 */
Chris@2 2035 FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_insert_blank_track(FLAC__StreamMetadata *object, unsigned track_num);
Chris@2 2036
Chris@2 2037 /** Delete a track in a CUESHEET block at the given index.
Chris@2 2038 *
Chris@2 2039 * \param object A pointer to an existing CUESHEET object.
Chris@2 2040 * \param track_num The index into the track array of the track to
Chris@2 2041 * delete. NOTE: this is not necessarily the same
Chris@2 2042 * as the track's \a number field.
Chris@2 2043 * \assert
Chris@2 2044 * \code object != NULL \endcode
Chris@2 2045 * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode
Chris@2 2046 * \code object->data.cue_sheet.num_tracks > track_num \endcode
Chris@2 2047 * \retval FLAC__bool
Chris@2 2048 * \c false if realloc() fails, else \c true.
Chris@2 2049 */
Chris@2 2050 FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_delete_track(FLAC__StreamMetadata *object, unsigned track_num);
Chris@2 2051
Chris@2 2052 /** Check a cue sheet to see if it conforms to the FLAC specification.
Chris@2 2053 * See the format specification for limits on the contents of the
Chris@2 2054 * cue sheet.
Chris@2 2055 *
Chris@2 2056 * \param object A pointer to an existing CUESHEET object.
Chris@2 2057 * \param check_cd_da_subset If \c true, check CUESHEET against more
Chris@2 2058 * stringent requirements for a CD-DA (audio) disc.
Chris@2 2059 * \param violation Address of a pointer to a string. If there is a
Chris@2 2060 * violation, a pointer to a string explanation of the
Chris@2 2061 * violation will be returned here. \a violation may be
Chris@2 2062 * \c NULL if you don't need the returned string. Do not
Chris@2 2063 * free the returned string; it will always point to static
Chris@2 2064 * data.
Chris@2 2065 * \assert
Chris@2 2066 * \code object != NULL \endcode
Chris@2 2067 * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode
Chris@2 2068 * \retval FLAC__bool
Chris@2 2069 * \c false if cue sheet is illegal, else \c true.
Chris@2 2070 */
Chris@2 2071 FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_is_legal(const FLAC__StreamMetadata *object, FLAC__bool check_cd_da_subset, const char **violation);
Chris@2 2072
Chris@2 2073 /** Calculate and return the CDDB/freedb ID for a cue sheet. The function
Chris@2 2074 * assumes the cue sheet corresponds to a CD; the result is undefined
Chris@2 2075 * if the cuesheet's is_cd bit is not set.
Chris@2 2076 *
Chris@2 2077 * \param object A pointer to an existing CUESHEET object.
Chris@2 2078 * \assert
Chris@2 2079 * \code object != NULL \endcode
Chris@2 2080 * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode
Chris@2 2081 * \retval FLAC__uint32
Chris@2 2082 * The unsigned integer representation of the CDDB/freedb ID
Chris@2 2083 */
Chris@2 2084 FLAC_API FLAC__uint32 FLAC__metadata_object_cuesheet_calculate_cddb_id(const FLAC__StreamMetadata *object);
Chris@2 2085
Chris@2 2086 /** Sets the MIME type of a PICTURE block.
Chris@2 2087 *
Chris@2 2088 * If \a copy is \c true, a copy of the string is stored; otherwise, the object
Chris@2 2089 * takes ownership of the pointer. The existing string will be freed if this
Chris@2 2090 * function is successful, otherwise the original string will remain if \a copy
Chris@2 2091 * is \c true and malloc() fails.
Chris@2 2092 *
Chris@2 2093 * \note It is safe to pass a const pointer to \a mime_type if \a copy is \c true.
Chris@2 2094 *
Chris@2 2095 * \param object A pointer to an existing PICTURE object.
Chris@2 2096 * \param mime_type A pointer to the MIME type string. The string must be
Chris@2 2097 * ASCII characters 0x20-0x7e, NUL-terminated. No validation
Chris@2 2098 * is done.
Chris@2 2099 * \param copy See above.
Chris@2 2100 * \assert
Chris@2 2101 * \code object != NULL \endcode
Chris@2 2102 * \code object->type == FLAC__METADATA_TYPE_PICTURE \endcode
Chris@2 2103 * \code (mime_type != NULL) \endcode
Chris@2 2104 * \retval FLAC__bool
Chris@2 2105 * \c false if \a copy is \c true and malloc() fails, else \c true.
Chris@2 2106 */
Chris@2 2107 FLAC_API FLAC__bool FLAC__metadata_object_picture_set_mime_type(FLAC__StreamMetadata *object, char *mime_type, FLAC__bool copy);
Chris@2 2108
Chris@2 2109 /** Sets the description of a PICTURE block.
Chris@2 2110 *
Chris@2 2111 * If \a copy is \c true, a copy of the string is stored; otherwise, the object
Chris@2 2112 * takes ownership of the pointer. The existing string will be freed if this
Chris@2 2113 * function is successful, otherwise the original string will remain if \a copy
Chris@2 2114 * is \c true and malloc() fails.
Chris@2 2115 *
Chris@2 2116 * \note It is safe to pass a const pointer to \a description if \a copy is \c true.
Chris@2 2117 *
Chris@2 2118 * \param object A pointer to an existing PICTURE object.
Chris@2 2119 * \param description A pointer to the description string. The string must be
Chris@2 2120 * valid UTF-8, NUL-terminated. No validation is done.
Chris@2 2121 * \param copy See above.
Chris@2 2122 * \assert
Chris@2 2123 * \code object != NULL \endcode
Chris@2 2124 * \code object->type == FLAC__METADATA_TYPE_PICTURE \endcode
Chris@2 2125 * \code (description != NULL) \endcode
Chris@2 2126 * \retval FLAC__bool
Chris@2 2127 * \c false if \a copy is \c true and malloc() fails, else \c true.
Chris@2 2128 */
Chris@2 2129 FLAC_API FLAC__bool FLAC__metadata_object_picture_set_description(FLAC__StreamMetadata *object, FLAC__byte *description, FLAC__bool copy);
Chris@2 2130
Chris@2 2131 /** Sets the picture data of a PICTURE block.
Chris@2 2132 *
Chris@2 2133 * If \a copy is \c true, a copy of the data is stored; otherwise, the object
Chris@2 2134 * takes ownership of the pointer. Also sets the \a data_length field of the
Chris@2 2135 * metadata object to what is passed in as the \a length parameter. The
Chris@2 2136 * existing data will be freed if this function is successful, otherwise the
Chris@2 2137 * original data and data_length will remain if \a copy is \c true and
Chris@2 2138 * malloc() fails.
Chris@2 2139 *
Chris@2 2140 * \note It is safe to pass a const pointer to \a data if \a copy is \c true.
Chris@2 2141 *
Chris@2 2142 * \param object A pointer to an existing PICTURE object.
Chris@2 2143 * \param data A pointer to the data to set.
Chris@2 2144 * \param length The length of \a data in bytes.
Chris@2 2145 * \param copy See above.
Chris@2 2146 * \assert
Chris@2 2147 * \code object != NULL \endcode
Chris@2 2148 * \code object->type == FLAC__METADATA_TYPE_PICTURE \endcode
Chris@2 2149 * \code (data != NULL && length > 0) ||
Chris@2 2150 * (data == NULL && length == 0 && copy == false) \endcode
Chris@2 2151 * \retval FLAC__bool
Chris@2 2152 * \c false if \a copy is \c true and malloc() fails, else \c true.
Chris@2 2153 */
Chris@2 2154 FLAC_API FLAC__bool FLAC__metadata_object_picture_set_data(FLAC__StreamMetadata *object, FLAC__byte *data, FLAC__uint32 length, FLAC__bool copy);
Chris@2 2155
Chris@2 2156 /** Check a PICTURE block to see if it conforms to the FLAC specification.
Chris@2 2157 * See the format specification for limits on the contents of the
Chris@2 2158 * PICTURE block.
Chris@2 2159 *
Chris@2 2160 * \param object A pointer to existing PICTURE block to be checked.
Chris@2 2161 * \param violation Address of a pointer to a string. If there is a
Chris@2 2162 * violation, a pointer to a string explanation of the
Chris@2 2163 * violation will be returned here. \a violation may be
Chris@2 2164 * \c NULL if you don't need the returned string. Do not
Chris@2 2165 * free the returned string; it will always point to static
Chris@2 2166 * data.
Chris@2 2167 * \assert
Chris@2 2168 * \code object != NULL \endcode
Chris@2 2169 * \code object->type == FLAC__METADATA_TYPE_PICTURE \endcode
Chris@2 2170 * \retval FLAC__bool
Chris@2 2171 * \c false if PICTURE block is illegal, else \c true.
Chris@2 2172 */
Chris@2 2173 FLAC_API FLAC__bool FLAC__metadata_object_picture_is_legal(const FLAC__StreamMetadata *object, const char **violation);
Chris@2 2174
Chris@2 2175 /* \} */
Chris@2 2176
Chris@2 2177 #ifdef __cplusplus
Chris@2 2178 }
Chris@2 2179 #endif
Chris@2 2180
Chris@2 2181 #endif