annotate win64-mingw/include/FLAC/metadata.h @ 43:5ea0608b923f

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